Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/oms-wallet-wagmi-connector/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function normalizeChainId(chainId: Hex | bigint | number | string | undefined):
} else if (typeof chainId === "string" && isHex(chainId)) {
normalized = Number(hexToBigInt(chainId));
} else if (typeof chainId === "string") {
normalized = Number(chainId);
normalized = /^[1-9]\d*$/u.test(chainId) ? Number(chainId) : Number.NaN;
} else {
throw invalidParams("Chain ID is required.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,30 @@ describe("omsWalletConnector", () => {
expect(client.wallet.sendTransaction).not.toHaveBeenCalled();
});

it("rejects non-decimal transaction request chainId strings before calling OMS", async () => {
const client = createClient({walletAddress: "0x9999999999999999999999999999999999999999"});
const config = createWagmiConfig(client);
const connector = config.connectors[0];

await connect(config, {connector});
const provider = await connector.getProvider();

await expect(provider.request({
method: "eth_sendTransaction",
params: [{
from: client.wallet.walletAddress,
to: "0x1111111111111111111111111111111111111111",
value: "0x1",
chainId: "1e2",
}],
})).rejects.toMatchObject({
name: "OmsWalletProviderRpcError",
code: -32602,
message: "Chain ID must be a positive safe integer.",
});
expect(client.wallet.sendTransaction).not.toHaveBeenCalled();
});

it("rejects non-quantity transaction values at the provider boundary", async () => {
const client = createClient({walletAddress: "0x9999999999999999999999999999999999999999"});
const config = createWagmiConfig(client);
Expand Down