Skip to content

Commit 81de10a

Browse files
committed
Merge branch 'main' into joaquim/gas
2 parents 6d1b829 + 3115375 commit 81de10a

File tree

42 files changed

+1636
-808
lines changed

Some content is hidden

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

42 files changed

+1636
-808
lines changed

.env.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
THIRDWEB_API_SECRET_KEY="test"
2+
POSTGRES_CONNECTION_URL="postgresql://postgres:postgres@localhost:5432/postgres?sslmode=disable"
3+
ADMIN_WALLET_ADDRESS="test"
4+
ENCRYPTION_PASSWORD="test"
5+
ENABLE_KEYPAIR_AUTH="true"

.github/workflows/tagBasedImageBuild.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
name: Tag Based Image Build
22

33
on:
4-
create: # This listens to create events, which includes tag creations
4+
release:
5+
types: [created] # This listens to release creation events
56

67
jobs:
78
buildImageForNewTag:
8-
if: startsWith(github.ref, 'refs/tags/') # Only run this job when a tag is created
99
runs-on: ubuntu-latest
10+
# Set environment variables
11+
env:
12+
LATEST_TAG: ${{ (github.event.release.target_commitish == 'main') && 'thirdweb/engine:latest' || '' }}
1013

1114
steps:
1215
- name: Check Disk Space Before Build
@@ -17,6 +20,9 @@ jobs:
1720

1821
- name: Checkout code
1922
uses: actions/checkout@v2
23+
with:
24+
# Fetches the branch at which the release was made
25+
ref: ${{ github.event.release.target_commitish }}
2026

2127
- name: Set up Docker Buildx
2228
uses: docker/setup-buildx-action@v1
@@ -35,10 +41,10 @@ jobs:
3541
platforms: linux/amd64,linux/arm64
3642
push: true
3743
tags: |
38-
thirdweb/engine:${{ github.ref_name }}
39-
thirdweb/engine:latest
44+
thirdweb/engine:${{ github.event.release.tag_name }}
45+
${{ env.LATEST_TAG }}
4046
build-args: |
41-
ENGINE_VERSION=${{ github.ref_name }}
47+
ENGINE_VERSION=${{ github.event.release.tag_name }}
4248
4349
- name: Check Disk Space After Build
4450
run: df -h

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Host Engine on your own instructure for free. [View self-host instructions](http
4646

4747
Other deployment options:
4848

49-
- [Deploy on Railway](https://railway.app/template/EASlyJ)
49+
[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/template/fcEVay)
5050

5151
### Cloud-host
5252

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
"@prisma/client": "5.2.0",
4040
"@sinclair/typebox": "^0.31.28",
4141
"@t3-oss/env-core": "^0.6.0",
42-
"@thirdweb-dev/auth": "^4.1.47",
42+
"@thirdweb-dev/auth": "^4.1.55",
4343
"@thirdweb-dev/chains": "^0.1.77",
44-
"@thirdweb-dev/sdk": "^4.0.49",
44+
"@thirdweb-dev/sdk": "^4.0.59",
4545
"@thirdweb-dev/service-utils": "0.4.17",
46-
"@thirdweb-dev/wallets": "2.4.17",
46+
"@thirdweb-dev/wallets": "^2.4.36-nightly-6961e09a4cec4c276b233285e721dc0505792be5-20240408215531",
4747
"@types/base-64": "^1.0.2",
4848
"base-64": "^1.0.0",
4949
"body-parser": "^1.20.2",
@@ -59,6 +59,7 @@
5959
"fastify": "^4.15.0",
6060
"fastify-plugin": "^4.5.0",
6161
"http-status-codes": "^2.2.0",
62+
"jsonwebtoken": "^9.0.2",
6263
"knex": "^3.1.0",
6364
"mnemonist": "^0.39.8",
6465
"node-cron": "^3.0.2",
@@ -77,6 +78,7 @@
7778
"@types/crypto-js": "^4.2.2",
7879
"@types/express": "^4.17.17",
7980
"@types/jest": "^29.5.11",
81+
"@types/jsonwebtoken": "^9.0.6",
8082
"@types/node": "^18.15.4",
8183
"@types/node-cron": "^3.0.8",
8284
"@types/pg": "^8.6.6",

src/db/keypair/delete.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Keypairs } from "@prisma/client";
2+
import { prisma } from "../client";
3+
4+
export const deleteKeypair = async ({
5+
hash,
6+
}: {
7+
hash: string;
8+
}): Promise<Keypairs> => {
9+
return prisma.keypairs.delete({
10+
where: { hash },
11+
});
12+
};

src/db/keypair/get.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { Keypairs } from "@prisma/client";
2+
import { createHash } from "crypto";
3+
import { prisma } from "../client";
4+
5+
export const getKeypairByPublicKey = async ({
6+
publicKey,
7+
}: {
8+
publicKey: string;
9+
}): Promise<Keypairs | null> => {
10+
const hash = createHash("sha256").update(publicKey).digest("hex");
11+
12+
return prisma.keypairs.findUnique({
13+
where: { hash },
14+
});
15+
};

src/db/keypair/insert.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Keypairs } from "@prisma/client";
2+
import { createHash } from "crypto";
3+
import { KeypairAlgorithm } from "../../server/schemas/keypairs";
4+
import { prisma } from "../client";
5+
6+
export const insertKeypair = async ({
7+
publicKey,
8+
algorithm,
9+
label,
10+
}: {
11+
publicKey: string;
12+
algorithm: KeypairAlgorithm;
13+
label?: string;
14+
}): Promise<Keypairs> => {
15+
const hash = createHash("sha256").update(publicKey).digest("hex");
16+
17+
return prisma.keypairs.create({
18+
data: {
19+
hash,
20+
publicKey,
21+
algorithm,
22+
label,
23+
},
24+
});
25+
};

src/db/keypair/list.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Keypairs } from "@prisma/client";
2+
import { prisma } from "../client";
3+
4+
export const listKeypairs = async (): Promise<Keypairs[]> => {
5+
return prisma.keypairs.findMany();
6+
};

src/db/tokens/getToken.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import { parseJWT } from "@thirdweb-dev/auth";
22
import { prisma } from "../client";
33

4-
interface GetTokenParams {
5-
jwt: string;
6-
}
7-
8-
export const getToken = async ({ jwt }: GetTokenParams) => {
4+
export const getToken = async (jwt: string) => {
95
const { payload } = parseJWT(jwt);
10-
return prisma.tokens.findUnique({
11-
where: {
12-
id: payload.jti,
13-
},
14-
});
6+
if (payload.jti) {
7+
return prisma.tokens.findUnique({
8+
where: {
9+
id: payload.jti,
10+
},
11+
});
12+
}
13+
return null;
1514
};

src/db/transactions/cleanTxs.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,14 @@ export const cleanTxs = (
1515
sentAt: tx.sentAt?.toISOString() || null,
1616
minedAt: tx.minedAt?.toISOString() || null,
1717
cancelledAt: tx.cancelledAt?.toISOString() || null,
18-
status: !!tx.errorMessage
18+
status: tx.errorMessage
1919
? "errored"
20-
: !!tx.minedAt
20+
: tx.minedAt
2121
? "mined"
22-
: !!tx.cancelledAt
22+
: tx.cancelledAt
2323
? "cancelled"
24-
: !!tx.sentAt && tx.retryCount === 0
24+
: tx.sentAt
2525
? "sent"
26-
: !!tx.sentAt && tx.retryCount > 0
27-
? "retried"
2826
: "queued",
2927
};
3028
});

src/db/transactions/queueTx.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,12 @@ export const queueTx = async ({
6060
return queueId;
6161
} else {
6262
const fromAddress = await tx.getSignerAddress();
63-
const toAddress = tx.getTarget();
63+
const toAddress =
64+
tx.getTarget() === "0x0000000000000000000000000000000000000000" &&
65+
txData.functionName === "deploy" &&
66+
extension === "deploy-published"
67+
? null
68+
: tx.getTarget();
6469

6570
const { id: queueId } = await queueTxRaw({
6671
pgtx,

src/db/transactions/updateTx.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type UpdateTxData =
2424
res: ethers.providers.TransactionRequest;
2525
sentAtBlockNumber: number;
2626
retryCount?: number;
27+
deployedContractAddress?: string;
2728
}
2829
| {
2930
status: TransactionStatus.UserOpSent;
@@ -84,6 +85,7 @@ export const updateTx = async ({ pgtx, queueId, data }: UpdateTxParams) => {
8485
maxFeePerGas: data.res?.maxFeePerGas?.toString(),
8586
maxPriorityFeePerGas: data.res?.maxPriorityFeePerGas?.toString(),
8687
value: data.res?.value?.toString(),
88+
deployedContractAddress: data.deployedContractAddress,
8789
},
8890
});
8991
break;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- CreateTable
2+
CREATE TABLE "keypairs" (
3+
"hash" TEXT NOT NULL,
4+
"publicKey" TEXT NOT NULL,
5+
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
6+
7+
CONSTRAINT "keypairs_pkey" PRIMARY KEY ("hash")
8+
);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
Warnings:
3+
4+
- Added the required column `algorithm` to the `keypairs` table without a default value. This is not possible if the table is not empty.
5+
6+
*/
7+
-- AlterTable
8+
ALTER TABLE "keypairs" ADD COLUMN "algorithm" TEXT NOT NULL;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-- AlterTable
2+
ALTER TABLE "keypairs" ADD COLUMN "label" TEXT,
3+
ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

src/prisma/schema.prisma

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,3 +265,14 @@ model ChainIndexers {
265265
266266
@@map("chain_indexers")
267267
}
268+
269+
model Keypairs {
270+
hash String @id
271+
publicKey String
272+
algorithm String
273+
label String?
274+
createdAt DateTime @default(now())
275+
updatedAt DateTime @default(now())
276+
277+
@@map("keypairs")
278+
}

0 commit comments

Comments
 (0)