From 94271af2eec172479c8e30d61d92e9fe0ffee440 Mon Sep 17 00:00:00 2001 From: Joaquim Verges Date: Mon, 26 Feb 2024 19:31:02 -0800 Subject: [PATCH] fix ethers5 adapter --- packages/thirdweb/src/adapters/ethers5.ts | 4 ++-- .../src/transaction/read-contract.test.ts | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/packages/thirdweb/src/adapters/ethers5.ts b/packages/thirdweb/src/adapters/ethers5.ts index e676bfe2984..df2ef7d3252 100644 --- a/packages/thirdweb/src/adapters/ethers5.ts +++ b/packages/thirdweb/src/adapters/ethers5.ts @@ -376,7 +376,7 @@ async function toEthersSigner( function alignTxToEthers( tx: TransactionSerializable, ): ethers5.ethers.utils.Deferrable { - const { to: viemTo, type: viemType, ...rest } = tx; + const { to: viemTo, type: viemType, gas, ...rest } = tx; // massage "to" to fit ethers const to = !viemTo ? Promise.resolve(undefined) : viemTo; // massage "type" to fit ethers @@ -404,7 +404,7 @@ function alignTxToEthers( } } - return { ...rest, to, type }; + return { ...rest, gasLimit: gas, to, type }; } async function alignTxFromEthers( diff --git a/packages/thirdweb/src/transaction/read-contract.test.ts b/packages/thirdweb/src/transaction/read-contract.test.ts index 7859d649197..4efd5349194 100644 --- a/packages/thirdweb/src/transaction/read-contract.test.ts +++ b/packages/thirdweb/src/transaction/read-contract.test.ts @@ -1,6 +1,9 @@ import { describe, it, expect, vi } from "vitest"; -import { USDC_CONTRACT } from "../../test/src/test-contracts.js"; +import { + DOODLES_CONTRACT, + USDC_CONTRACT, +} from "../../test/src/test-contracts.js"; import { VITALIK_WALLET } from "../../test/src/addresses.js"; import { readContract } from "./read-contract.js"; @@ -38,4 +41,18 @@ describe("transaction: read", () => { }), ); }); + + it("should parse errors correctly", async () => { + try { + await readContract({ + contract: DOODLES_CONTRACT, + method: "function tokenURI(uint256) returns (string)", + params: [99999990n], + }); + } catch (e: any) { + expect(e.message).eq( + "execution reverted: revert: ERC721Metadata: URI query for nonexistent token", + ); + } + }); });