Skip to content

Commit 4f89bb9

Browse files
update send signed transaction to v5 to support zksync transactions (#537)
1 parent 5301ccd commit 4f89bb9

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"pino-pretty": "^10.0.0",
7171
"prisma": "5.14.0-dev.61",
7272
"superjson": "^2.2.1",
73-
"thirdweb": "^5.1.0",
73+
"thirdweb": "^5.25.1",
7474
"uuid": "^9.0.1",
7575
"viem": "^1.14.0",
7676
"zod": "^3.21.4"

src/server/routes/transaction/blockchain/sendSignedTx.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
import { Static, Type } from "@sinclair/typebox";
22
import { FastifyInstance } from "fastify";
33
import { StatusCodes } from "http-status-codes";
4-
import { getSdk } from "../../../../utils/cache/getSdk";
4+
import {
5+
defineChain,
6+
eth_sendRawTransaction,
7+
getRpcClient,
8+
isHex,
9+
} from "thirdweb";
10+
import { thirdwebClient } from "../../../../utils/sdk";
11+
import { createCustomError } from "../../../middleware/error";
512
import { standardResponseSchema } from "../../../schemas/sharedApiSchemas";
613
import { getChainIdFromChain } from "../../../utils/chain";
714

@@ -43,13 +50,27 @@ export async function sendSignedTransaction(fastify: FastifyInstance) {
4350
const { chain } = req.params;
4451
const { signedTransaction } = req.body;
4552
const chainId = await getChainIdFromChain(chain);
46-
const sdk = await getSdk({ chainId });
4753

48-
const txRes = await sdk.getProvider().sendTransaction(signedTransaction);
54+
if (!isHex(signedTransaction)) {
55+
throw createCustomError(
56+
"SignedTransaction is not a valid hex string.",
57+
StatusCodes.BAD_REQUEST,
58+
"SendSignedTxError",
59+
);
60+
}
61+
62+
const rpc = getRpcClient({
63+
chain: defineChain(chainId),
64+
client: thirdwebClient,
65+
});
66+
const transactionHash = await eth_sendRawTransaction(
67+
rpc,
68+
signedTransaction,
69+
);
4970

5071
res.status(200).send({
5172
result: {
52-
transactionHash: txRes.hash,
73+
transactionHash,
5374
},
5475
});
5576
},

yarn.lock

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8084,11 +8084,6 @@ isomorphic-ws@^4.0.1:
80848084
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc"
80858085
integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==
80868086

8087-
isows@1.0.3:
8088-
version "1.0.3"
8089-
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.3.tgz#93c1cf0575daf56e7120bab5c8c448b0809d0d74"
8090-
integrity sha512-2cKei4vlmg2cxEjm3wVSqn8pcoRF/LX/wpifuuNquFO4SQmPwarClT+SUCA2lt+l581tTeZIPIZuIDo2jWN1fg==
8091-
80928087
isows@1.0.4:
80938088
version "1.0.4"
80948089
resolved "https://registry.yarnpkg.com/isows/-/isows-1.0.4.tgz#810cd0d90cc4995c26395d2aa4cfa4037ebdf061"
@@ -11148,17 +11143,18 @@ thirdweb@5.24.0-nightly-4abd5591068bfa9217ec65e5830fba0cd14d11b9-20240522224005:
1114811143
uqr "0.1.2"
1114911144
viem "2.10.9"
1115011145

11151-
thirdweb@^5.1.0:
11152-
version "5.18.1"
11153-
resolved "https://registry.yarnpkg.com/thirdweb/-/thirdweb-5.18.1.tgz#55d7ce851b5c5205ffe26ed29824740b4a27b2ff"
11154-
integrity sha512-YbtVw0Zcnzlcmrjcaq9FIGavSkfgiAiYonOvAmneLgKblsi1C0HscVh4gxcpwJoOWL4zg5JBRcOo1X81pWn4DA==
11146+
thirdweb@^5.25.1:
11147+
version "5.25.1"
11148+
resolved "https://registry.yarnpkg.com/thirdweb/-/thirdweb-5.25.1.tgz#889157f13d0caa59b5373cf60a13de5b67ace34b"
11149+
integrity sha512-WGPkA50UgzX8aw4x6Hkrb5XUrJ+x5ulCJ0VV9fjit7tz8mUPhKXQPlsenlCahFJWY381tR+vNXMhVMjFVeKHQA==
1115511150
dependencies:
1115611151
"@coinbase/wallet-sdk" "4.0.0-rc.2"
1115711152
"@emotion/react" "11.11.4"
1115811153
"@emotion/styled" "11.11.0"
1115911154
"@google/model-viewer" "2.1.1"
1116011155
"@noble/curves" "1.4.0"
1116111156
"@noble/hashes" "1.4.0"
11157+
"@passwordless-id/webauthn" "^1.6.1"
1116211158
"@radix-ui/react-dialog" "1.0.5"
1116311159
"@radix-ui/react-focus-scope" "1.0.4"
1116411160
"@radix-ui/react-icons" "1.3.0"
@@ -11168,10 +11164,11 @@ thirdweb@^5.1.0:
1116811164
abitype "1.0.0"
1116911165
fast-text-encoding "^1.0.6"
1117011166
fuse.js "7.0.0"
11167+
input-otp "^1.2.4"
1117111168
mipd "0.0.7"
1117211169
node-libs-browser "2.2.1"
1117311170
uqr "0.1.2"
11174-
viem "2.9.18"
11171+
viem "2.10.9"
1117511172

1117611173
thread-stream@^0.15.1:
1117711174
version "0.15.2"
@@ -11698,20 +11695,6 @@ viem@2.10.9:
1169811695
isows "1.0.4"
1169911696
ws "8.13.0"
1170011697

11701-
viem@2.9.18:
11702-
version "2.9.18"
11703-
resolved "https://registry.yarnpkg.com/viem/-/viem-2.9.18.tgz#5f24982fd4f186e90f1ed304e05054ebb4f263b9"
11704-
integrity sha512-QULuau6DWDVRjGDVIUPuUybqiYu8mxscvwkKQ7dqNRl6w/t8RWs92aJZSQpqEULoERlKYyFFlj7cz4mWFEchsg==
11705-
dependencies:
11706-
"@adraffy/ens-normalize" "1.10.0"
11707-
"@noble/curves" "1.2.0"
11708-
"@noble/hashes" "1.3.2"
11709-
"@scure/bip32" "1.3.2"
11710-
"@scure/bip39" "1.2.1"
11711-
abitype "1.0.0"
11712-
isows "1.0.3"
11713-
ws "8.13.0"
11714-
1171511698
viem@^1.14.0:
1171611699
version "1.14.0"
1171711700
resolved "https://registry.yarnpkg.com/viem/-/viem-1.14.0.tgz#e4b305c4cce500e04a66b951c01856d7b04ab403"

0 commit comments

Comments
 (0)