Skip to content

Commit a3b8fd7

Browse files
Support hex transaction types in fromTransactionType
1 parent eef9c43 commit a3b8fd7

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/shared/utils/sdk.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { sha256HexSync } from "@thirdweb-dev/crypto";
2-
import { createThirdwebClient } from "thirdweb";
2+
import { createThirdwebClient, hexToNumber, isHex } from "thirdweb";
33
import type { TransactionReceipt } from "thirdweb/transaction";
44
import { env } from "./env";
55

@@ -27,14 +27,6 @@ export const fromTransactionType = (type: TransactionReceipt["type"]) => {
2727
if (type === "eip2930") return 2;
2828
if (type === "eip4844") return 3;
2929
if (type === "eip7702") return 4;
30+
if (isHex(type)) return hexToNumber(type);
3031
throw new Error(`Unexpected transaction type ${type}`);
3132
};
32-
33-
export const toTransactionType = (value: number) => {
34-
if (value === 0) return "legacy";
35-
if (value === 1) return "eip1559";
36-
if (value === 2) return "eip2930";
37-
if (value === 3) return "eip4844";
38-
if (value === 4) return "eip7702";
39-
throw new Error(`Unexpected transaction type number ${value}`);
40-
};

0 commit comments

Comments
 (0)