@multiplatform.one/web3 7.82.5 → 7.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@multiplatform.one/web3",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.83.0",
|
|
4
4
|
"description": "Web3 wallet integration for multiplatform.one ecosystem with ConnectKit and wagmi",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"connectkit",
|
|
@@ -120,10 +120,10 @@
|
|
|
120
120
|
"@aave/account": "^0.2.1",
|
|
121
121
|
"@coinbase/wallet-sdk": "^4.4.0",
|
|
122
122
|
"@metamask/connect-evm": "^2.1.1",
|
|
123
|
-
"@multiplatform.one/connectkit": "^7.
|
|
124
|
-
"@multiplatform.one/gpg": "^7.
|
|
125
|
-
"@multiplatform.one/platform": "^7.
|
|
126
|
-
"@multiplatform.one/theme": "^7.
|
|
123
|
+
"@multiplatform.one/connectkit": "^7.83.0",
|
|
124
|
+
"@multiplatform.one/gpg": "^7.83.0",
|
|
125
|
+
"@multiplatform.one/platform": "^7.83.0",
|
|
126
|
+
"@multiplatform.one/theme": "^7.83.0",
|
|
127
127
|
"@noble/ciphers": "^1.3.0",
|
|
128
128
|
"@noble/curves": "^1.9.7",
|
|
129
129
|
"@phosphor-icons/react": "^2.1.10",
|
|
@@ -147,7 +147,7 @@
|
|
|
147
147
|
"wagmi": "^3.7.1"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
|
-
"@multiplatform.one/config": "7.
|
|
150
|
+
"@multiplatform.one/config": "7.83.0",
|
|
151
151
|
"@tamagui/build": "2.7.6",
|
|
152
152
|
"@tanstack/react-query": "^5.104.3",
|
|
153
153
|
"@testing-library/jest-dom": "^7.0.1",
|
|
@@ -390,6 +390,63 @@ describe("metaMaskConnect under wagmi", () => {
|
|
|
390
390
|
);
|
|
391
391
|
});
|
|
392
392
|
|
|
393
|
+
it("refuses a transaction and a typed signature with 4901 while the desktop extension sits on a chain the app does not list", async () => {
|
|
394
|
+
const codes = (error: unknown) => {
|
|
395
|
+
const found: unknown[] = [];
|
|
396
|
+
for (let at = error as { code?: unknown; cause?: unknown } | undefined; at; ) {
|
|
397
|
+
found.push(at.code);
|
|
398
|
+
at = at.cause as typeof at;
|
|
399
|
+
}
|
|
400
|
+
return found;
|
|
401
|
+
};
|
|
402
|
+
const provider = {
|
|
403
|
+
selectedChainId: "0x2105" as string | undefined,
|
|
404
|
+
request: vi.fn(async ({ method }: { method: string }) =>
|
|
405
|
+
method === "eth_chainId" ? provider.selectedChainId : "0xabc",
|
|
406
|
+
),
|
|
407
|
+
};
|
|
408
|
+
client.getChainId.mockImplementation(() => provider.selectedChainId!);
|
|
409
|
+
client.getProvider.mockReturnValue(provider as never);
|
|
410
|
+
client.connect.mockImplementationOnce(async () => ({ accounts: [first], chainId: "0x1" }));
|
|
411
|
+
const config = createConfig({
|
|
412
|
+
chains: [polygon, mainnet],
|
|
413
|
+
connectors: [metaMaskConnect({ dapp: { name: "test", url: "https://example.test" } })],
|
|
414
|
+
transports: { [polygon.id]: http(), [mainnet.id]: http() },
|
|
415
|
+
multiInjectedProviderDiscovery: false,
|
|
416
|
+
storage: null,
|
|
417
|
+
});
|
|
418
|
+
await connect(config, { connector: config.connectors[0]! });
|
|
419
|
+
(await clientEvents()).chainChanged("0x2105");
|
|
420
|
+
const wrapped = (await config.connectors[0]!.getProvider()) as {
|
|
421
|
+
request(args: { method: string; params?: unknown }): Promise<unknown>;
|
|
422
|
+
};
|
|
423
|
+
const typedData = {
|
|
424
|
+
domain: { name: "t", chainId: base.id },
|
|
425
|
+
types: { Mail: [{ name: "body", type: "string" }] },
|
|
426
|
+
primaryType: "Mail",
|
|
427
|
+
message: { body: "x" },
|
|
428
|
+
} as const;
|
|
429
|
+
|
|
430
|
+
for (const method of [
|
|
431
|
+
"eth_sendTransaction",
|
|
432
|
+
"eth_signTypedData",
|
|
433
|
+
"eth_signTypedData_v3",
|
|
434
|
+
"eth_signTypedData_v4",
|
|
435
|
+
])
|
|
436
|
+
await expect(wrapped.request({ method, params: [first, "{}"] })).rejects.toMatchObject({
|
|
437
|
+
code: 4901,
|
|
438
|
+
});
|
|
439
|
+
expect(
|
|
440
|
+
codes(await sendTransaction(config, { to: second, value: 1n, gas: 21000n }).catch((e) => e)),
|
|
441
|
+
).toContain(4901);
|
|
442
|
+
expect(codes(await signTypedData(config, typedData).catch((e) => e))).toContain(4901);
|
|
443
|
+
|
|
444
|
+
const sent = provider.request.mock.calls.map(([call]) => call.method);
|
|
445
|
+
expect(sent).not.toContain("eth_sendTransaction");
|
|
446
|
+
expect(sent.filter((method) => method.startsWith("eth_signTypedData"))).toEqual([]);
|
|
447
|
+
expect(provider.selectedChainId).toBe("0x2105");
|
|
448
|
+
});
|
|
449
|
+
|
|
393
450
|
it("sends no transaction or typed signature on mainnet for an app that does not list it", async () => {
|
|
394
451
|
const request = vi.fn(async ({ method }: { method: string }) =>
|
|
395
452
|
method === "eth_chainId" ? "0x1" : "0xabc",
|