Skip to content

Commit

Permalink
fix ethers5 adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
joaquim-verges committed Feb 27, 2024
1 parent de37c10 commit 94271af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/thirdweb/src/adapters/ethers5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ async function toEthersSigner(
function alignTxToEthers(
tx: TransactionSerializable,
): ethers5.ethers.utils.Deferrable<ethers5.ethers.providers.TransactionRequest> {
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
Expand Down Expand Up @@ -404,7 +404,7 @@ function alignTxToEthers(
}
}

return { ...rest, to, type };
return { ...rest, gasLimit: gas, to, type };
}

async function alignTxFromEthers(
Expand Down
19 changes: 18 additions & 1 deletion packages/thirdweb/src/transaction/read-contract.test.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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",
);
}
});
});

0 comments on commit 94271af

Please sign in to comment.