Skip to content

Commit 1d6308c

Browse files
authored
Merge pull request #122 from thirdweb-dev/am/v2
2 parents 4d3b359 + 822f511 commit 1d6308c

File tree

136 files changed

+2551
-2412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+2551
-2412
lines changed

.dockerignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ Dockerfile
55
.env
66
yarn-error.log
77
.husky
8-
scripts
98
docker-compose*.yml
109
Dockerfile
1110
.DS_Store
1211
swagger.yml
13-
e2e
12+
test

.env.benchmark.example

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@
1212

1313
THIRDWEB_API_SECRET_KEY = ""
1414

15-
# At minimum, you need to configure a chain
15+
# At minimum, you need to configure a chain and a wallet address
1616
# ============================================================================= #
1717
BENCHMARK_CHAIN = "mumbai"
18+
BENCHMARK_WALLET_ADDRESS = ""
1819

1920
# Then you can configure the contract address and function to call
2021
# NOTE: If you don't configure a contract address and function call, an ERC20

.github/workflows/e2eTest.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@ export POSTGRES_PASSWORD=postgres
1010
export POSTGRES_PORT=5432
1111
export POSTGRES_USE_SSL=false
1212
export WALLET_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
13-
export THIRDWEB_API_SECRET_KEY=klRsqmatrdlEpik_pHKgYy_q2YzGe3bTewO1VC26eY_H184Kc7xOVqKVj0mHwOOW2AOx2N-a3GqLCQ7Z9s9-sw
13+
# export THIRDWEB_API_SECRET_KEY=klRsqmatrdlEpik_pHKgYy_q2YzGe3bTewO1VC26eY_H184Kc7xOVqKVj0mHwOOW2AOx2N-a3GqLCQ7Z9s9-sw
1414

1515
test-evm: FORCE
1616
docker compose -f docker-compose-test.yml up -d
1717
./test/e2e/hardhat/waitForHardhatNode.sh
18+
yarn prisma:migrate
1819
yarn test:all
1920
docker compose -f docker-compose-test.yml down
2021

core/database/dbOperation.ts

Lines changed: 0 additions & 196 deletions
This file was deleted.

core/database/dbPrereqs.ts

Lines changed: 1 addition & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { promises as fs } from "fs";
22
import { dirname } from "path";
33
import { fileURLToPath } from "url";
44

5-
import { FastifyInstance, FastifyRequest } from "fastify";
5+
import { FastifyInstance } from "fastify";
66
import { StatusCodes } from "http-status-codes";
77
import { env } from "../env";
88
import { createCustomError } from "../error/customError";
@@ -16,53 +16,6 @@ const connectionString = env.POSTGRES_CONNECTION_URL;
1616
const DATABASE_NAME =
1717
new URL(connectionString).pathname.split("/")[1] || "postgres";
1818

19-
export const checkTablesExistence = async (
20-
server: FastifyInstance,
21-
): Promise<void> => {
22-
try {
23-
const knex = await connectToDatabase();
24-
// Check if the tables Exists
25-
const tablesList: string[] = env.DB_TABLES_LIST.split(",").map(function (
26-
item: any,
27-
) {
28-
return item.trim();
29-
});
30-
31-
if (!tablesList) {
32-
const error = createCustomError(
33-
"DB_TABLES_LIST ENV variable is empty",
34-
StatusCodes.NOT_FOUND,
35-
"DB_TABLES_LIST_NOT_FOUND",
36-
);
37-
throw error;
38-
}
39-
40-
for (const tableName of tablesList) {
41-
const schemaSQL = await fs.readFile(
42-
`${__dirname}/sql-schemas/${tableName}.sql`,
43-
"utf-8",
44-
);
45-
// Create Table using schema
46-
await knex.schema.raw(schemaSQL);
47-
48-
server.log.info(
49-
`SQL for ${tableName} processed successfully on start-up`,
50-
);
51-
}
52-
53-
// Disconnect from DB
54-
await knex.destroy();
55-
} catch (error: any) {
56-
server.log.error(error);
57-
const customError = createCustomError(
58-
"Error while executing Table SQLs on startup",
59-
StatusCodes.INTERNAL_SERVER_ERROR,
60-
"SERVER_STARTUP_TABLES_CREATION_ERROR",
61-
);
62-
throw customError;
63-
}
64-
};
65-
6619
export const implementTriggerOnStartUp = async (
6720
server: FastifyInstance,
6821
): Promise<void> => {
@@ -118,49 +71,3 @@ export const implementTriggerOnStartUp = async (
11871
throw customError;
11972
}
12073
};
121-
122-
export const ensureDatabaseExists = async (
123-
server: FastifyInstance | FastifyRequest,
124-
): Promise<void> => {
125-
try {
126-
// Creating KNEX Config
127-
let modifiedConnectionString = connectionString;
128-
if (DATABASE_NAME !== "postgres") {
129-
// This is required if the Database mentioned in the connection string is not postgres
130-
// as we need to connect to the postgres database to create the user provied database
131-
// and then connect to the user provided database
132-
modifiedConnectionString = connectionString.replace(
133-
`/${DATABASE_NAME}`,
134-
"/postgres",
135-
);
136-
}
137-
138-
let knex = await connectToDatabase(modifiedConnectionString);
139-
140-
// Check if Database Exists & create if it doesn't
141-
let hasDatabase: any;
142-
switch (dbClient) {
143-
case "pg":
144-
server.log.debug("checking if pg database exists");
145-
hasDatabase = await knex.raw(
146-
`SELECT 1 from pg_database WHERE datname = '${DATABASE_NAME}'`,
147-
);
148-
server.log.info(`CHECKING for Database ${DATABASE_NAME}...`);
149-
if (!hasDatabase.rows.length) {
150-
await knex.raw(`CREATE DATABASE ${DATABASE_NAME}`);
151-
} else {
152-
server.log.info(`Database ${DATABASE_NAME} already exists`);
153-
}
154-
break;
155-
default:
156-
throw new Error(
157-
`Unsupported database client: ${dbClient}. Cannot create database ${DATABASE_NAME}`,
158-
);
159-
}
160-
161-
await knex.destroy();
162-
} catch (error) {
163-
server.log.error(error);
164-
throw new Error(`Error creating database ${DATABASE_NAME}`);
165-
}
166-
};

0 commit comments

Comments
 (0)