Skip to content

Commit 109f250

Browse files
[SDK] fix: Handle authorizationList tx prop in ethers5 adapter (#6447)
1 parent f7cf09b commit 109f250

File tree

4 files changed

+125
-20
lines changed

4 files changed

+125
-20
lines changed

.changeset/true-actors-agree.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"thirdweb": patch
3+
---
4+
5+
Fix ethers5 adapter not handling authorizationList tx prop

packages/thirdweb/src/adapters/ethers5.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { TEST_CLIENT } from "../../test/src/test-clients.js";
77
import { ANVIL_PKEY_A, TEST_ACCOUNT_B } from "../../test/src/test-wallets.js";
88
import { resolveContractAbi } from "../contract/actions/resolve-abi.js";
99
import { decimals } from "../extensions/erc20/__generated__/IERC20/read/decimals.js";
10+
import { sendTransaction } from "../transaction/actions/send-transaction.js";
11+
import { prepareTransaction } from "../transaction/prepare-transaction.js";
1012
import { randomBytesBuffer } from "../utils/random.js";
1113
import { privateKeyToAccount } from "../wallets/private-key.js";
1214
import {
@@ -209,6 +211,25 @@ describe("fromEthersSigner", () => {
209211
expect(signedTransaction).toBe(await wallet.signTransaction(transaction));
210212
});
211213

214+
it("should send a transaction", async () => {
215+
const wallet = new ethers5.Wallet(
216+
ANVIL_PKEY_A,
217+
ethers5.getDefaultProvider(ANVIL_CHAIN.rpc),
218+
);
219+
const account = await fromEthersSigner(wallet);
220+
221+
const transaction = prepareTransaction({
222+
client: TEST_CLIENT,
223+
chain: ANVIL_CHAIN,
224+
to: TEST_ACCOUNT_B.address,
225+
value: 1n,
226+
});
227+
228+
const txResponse = await sendTransaction({ transaction, account });
229+
230+
expect(txResponse.transactionHash.length).toBe(66);
231+
});
232+
212233
it("should sign typed data", async () => {
213234
const wallet = new ethers5.Wallet(ANVIL_PKEY_A);
214235
const account = await fromEthersSigner(wallet);

packages/thirdweb/src/adapters/ethers5.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,9 @@ function alignTxToEthers(
624624
}
625625
}
626626

627+
// biome-ignore lint/performance/noDelete: ethers5 doesn't support authorizationList
628+
delete rest.authorizationList;
629+
627630
return {
628631
...rest,
629632
gasLimit: gas,

packages/thirdweb/src/adapters/ethers6.test.ts

Lines changed: 96 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as ethers6 from "ethers6";
2-
import { describe, expect, test } from "vitest";
2+
import { describe, expect, it, test } from "vitest";
33
import { ANVIL_CHAIN } from "../../test/src/chains.js";
44
import { TEST_CLIENT } from "../../test/src/test-clients.js";
55
import { ANVIL_PKEY_A, TEST_ACCOUNT_B } from "../../test/src/test-wallets.js";
6+
import { sendTransaction } from "../transaction/actions/send-transaction.js";
7+
import { prepareTransaction } from "../transaction/prepare-transaction.js";
68
import { randomBytesBuffer } from "../utils/random.js";
79
import { privateKeyToAccount } from "../wallets/private-key.js";
8-
import { toEthersSigner } from "./ethers6.js";
10+
import { fromEthersSigner, toEthersSigner } from "./ethers6.js";
911

1012
const account = privateKeyToAccount({
1113
privateKey: ANVIL_PKEY_A,
@@ -14,12 +16,7 @@ const account = privateKeyToAccount({
1416

1517
describe("toEthersSigner", () => {
1618
test("should return an ethers 6 signer", async () => {
17-
const signer = await toEthersSigner(
18-
ethers6,
19-
TEST_CLIENT,
20-
account,
21-
ANVIL_CHAIN,
22-
);
19+
const signer = toEthersSigner(ethers6, TEST_CLIENT, account, ANVIL_CHAIN);
2320
expect(signer).toBeDefined();
2421
expect(signer.signMessage).toBeDefined();
2522
});
@@ -40,12 +37,7 @@ describe("toEthersSigner", () => {
4037
});
4138

4239
test("should sign typed data", async () => {
43-
const signer = await toEthersSigner(
44-
ethers6,
45-
TEST_CLIENT,
46-
account,
47-
ANVIL_CHAIN,
48-
);
40+
const signer = toEthersSigner(ethers6, TEST_CLIENT, account, ANVIL_CHAIN);
4941
expect(signer.signTypedData).toBeDefined();
5042

5143
// All properties on a domain are optional
@@ -88,16 +80,100 @@ describe("toEthersSigner", () => {
8880
});
8981

9082
test("should send a tx", async () => {
91-
const signer = await toEthersSigner(
92-
ethers6,
93-
TEST_CLIENT,
94-
account,
95-
ANVIL_CHAIN,
96-
);
83+
const signer = toEthersSigner(ethers6, TEST_CLIENT, account, ANVIL_CHAIN);
9784
const txResponse = await signer.sendTransaction({
9885
to: TEST_ACCOUNT_B.address,
9986
value: 100,
10087
});
10188
expect(txResponse.hash.length).toBe(66);
10289
});
10390
});
91+
92+
describe("fromEthersSigner", () => {
93+
it("should convert an ethers6 Signer to an Account", async () => {
94+
const wallet = new ethers6.Wallet(ANVIL_PKEY_A);
95+
const account = await fromEthersSigner(wallet);
96+
97+
expect(account).toBeDefined();
98+
expect(account.address).toBe(await wallet.getAddress());
99+
});
100+
101+
it("should sign a message", async () => {
102+
const wallet = new ethers6.Wallet(ANVIL_PKEY_A);
103+
const account = await fromEthersSigner(wallet);
104+
105+
const message = "Hello, world!";
106+
const signature = await account.signMessage({ message });
107+
108+
expect(signature).toBe(await wallet.signMessage(message));
109+
});
110+
111+
it("should sign a transaction", async () => {
112+
const wallet = new ethers6.Wallet(
113+
ANVIL_PKEY_A,
114+
ethers6.getDefaultProvider(),
115+
);
116+
const account = await fromEthersSigner(wallet);
117+
118+
const transaction = {
119+
to: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
120+
value: 1n,
121+
};
122+
123+
const signedTransaction = await account.signTransaction?.(transaction);
124+
125+
expect(signedTransaction).toBe(await wallet.signTransaction(transaction));
126+
});
127+
128+
it("should send a transaction", async () => {
129+
const wallet = new ethers6.Wallet(
130+
ANVIL_PKEY_A,
131+
ethers6.getDefaultProvider(ANVIL_CHAIN.rpc),
132+
);
133+
const account = await fromEthersSigner(wallet);
134+
135+
const transaction = prepareTransaction({
136+
client: TEST_CLIENT,
137+
chain: ANVIL_CHAIN,
138+
to: TEST_ACCOUNT_B.address,
139+
value: 1n,
140+
});
141+
142+
const txResponse = await sendTransaction({ transaction, account });
143+
144+
expect(txResponse.transactionHash.length).toBe(66);
145+
});
146+
147+
it("should sign typed data", async () => {
148+
const wallet = new ethers6.Wallet(ANVIL_PKEY_A);
149+
const account = await fromEthersSigner(wallet);
150+
151+
const domain = {
152+
name: "Ether Mail",
153+
version: "1",
154+
chainId: 1,
155+
verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
156+
};
157+
158+
const types = {
159+
Person: [
160+
{ name: "name", type: "string" },
161+
{ name: "wallet", type: "address" },
162+
],
163+
};
164+
165+
const value = {
166+
name: "Alice",
167+
wallet: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
168+
};
169+
170+
const signature = await account.signTypedData({
171+
primaryType: "Person",
172+
domain,
173+
types,
174+
message: value,
175+
});
176+
177+
expect(signature).toBeDefined();
178+
});
179+
});

0 commit comments

Comments
 (0)