From 3e8630379f268d0850db8f83fccaebb222cd831d Mon Sep 17 00:00:00 2001 From: philogicae Date: Thu, 12 Sep 2024 13:02:55 +0300 Subject: [PATCH 1/8] Missing fields: features / node_hash --- packages/message/src/types/execution.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/message/src/types/execution.ts b/packages/message/src/types/execution.ts index 14851f72..5984101c 100644 --- a/packages/message/src/types/execution.ts +++ b/packages/message/src/types/execution.ts @@ -68,6 +68,7 @@ export type MachineResources = { export type CpuProperties = { architecture?: 'x86_64' | 'arm64' vendor?: 'AuthenticAMD' | 'GenuineIntel' | string + features?: string[] } /** @@ -79,6 +80,7 @@ export type CpuProperties = { export type NodeRequirements = { owner?: string address_regex?: string + node_hash?: string } /** From b39983ab38e5cdf3930658e981ff3d1a18263f8d Mon Sep 17 00:00:00 2001 From: philogicae Date: Thu, 12 Sep 2024 20:03:34 +0300 Subject: [PATCH 2/8] Fix wrong fallback logic on switch/add network --- packages/evm/src/account.ts | 4 +--- packages/evm/src/provider/constants.ts | 4 ++++ packages/evm/src/provider/rpc.ts | 22 ++++++++++++++++++---- packages/superfluid/src/account.ts | 1 - 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 packages/evm/src/provider/constants.ts diff --git a/packages/evm/src/account.ts b/packages/evm/src/account.ts index 19729003..09873c91 100644 --- a/packages/evm/src/account.ts +++ b/packages/evm/src/account.ts @@ -47,9 +47,7 @@ export abstract class EVMAccount extends ECIESAccount { public async changeNetwork(chainOrRpc: RpcType | RpcId = RpcId.ETH): Promise { if (this.wallet instanceof JsonRPCWallet) { await this.wallet.changeNetwork(chainOrRpc) - } - if (this.wallet instanceof ethers.Wallet) { - //await this.wallet.provider.send("wallet_switchEthereumChain", [{ chainId: chainId.toString(16) }]); + } else if (this.wallet instanceof ethers.Wallet) { throw new Error('Not implemented for ethers.Wallet') } } diff --git a/packages/evm/src/provider/constants.ts b/packages/evm/src/provider/constants.ts new file mode 100644 index 00000000..512a87ca --- /dev/null +++ b/packages/evm/src/provider/constants.ts @@ -0,0 +1,4 @@ +export const MetamaskErrorCodes: Record = { + REJECTED: 4001, + UNRECOGNIZED: 4902, +} diff --git a/packages/evm/src/provider/rpc.ts b/packages/evm/src/provider/rpc.ts index 047e9c99..c72f4095 100644 --- a/packages/evm/src/provider/rpc.ts +++ b/packages/evm/src/provider/rpc.ts @@ -1,5 +1,6 @@ import { ethers } from 'ethers' import { BaseProviderWallet } from '@aleph-sdk/account' +import { MetamaskErrorCodes } from './constants' const RPC_WARNING = `DEPRECATION WARNING: Encryption/Decryption features may become obsolete, for more information: https://github.com/aleph-im/aleph-sdk-ts/issues/37` @@ -226,8 +227,15 @@ export class JsonRPCWallet extends BaseProviderWallet { try { await this.provider.send('wallet_switchEthereumChain', [{ chainId: chainData.chainId }]) - } catch (error) { - await this.addNetwork(chainData) + } catch (e) { + const err = e as { code?: number; message?: string } + if (err?.code === MetamaskErrorCodes.UNRECOGNIZED) { + await this.addNetwork(chainData) + } else if (err?.code === MetamaskErrorCodes.REJECTED) { + console.warn(`[Switch Network]: ${err?.message}`) + } else { + throw new Error(`[Switch Network]: ${err?.message}`) + } } } @@ -248,8 +256,14 @@ export class JsonRPCWallet extends BaseProviderWallet { private async addNetwork(chainData: RpcType): Promise { try { await this.provider.send('wallet_addEthereumChain', [chainData]) - } catch (error) { - throw new Error(`Could not add network to provider: ${error}`) + await this.changeNetwork(chainData) + } catch (e) { + const err = e as { code?: number; message?: string } + if (err?.code === MetamaskErrorCodes.REJECTED) { + console.warn(`[Add Network]: ${err?.message}`) + } else { + throw new Error(`[Add Network]: ${err?.message}`) + } } } } diff --git a/packages/superfluid/src/account.ts b/packages/superfluid/src/account.ts index bce44906..a64f273d 100644 --- a/packages/superfluid/src/account.ts +++ b/packages/superfluid/src/account.ts @@ -21,7 +21,6 @@ import { Blockchain } from '@aleph-sdk/core' * It is used to represent a Superfluid account when publishing a message on the Aleph network. */ - export class SuperfluidAccount extends EVMAccount { public override wallet: JsonRPCWallet private account: EVMAccount From f3dbae5bb1fc46ca34071500211bc92e497e8b5e Mon Sep 17 00:00:00 2001 From: philogicae Date: Tue, 24 Sep 2024 15:59:25 +0300 Subject: [PATCH 3/8] Fix examples for devtests --- examples/stake-on-me/cli.ts | 13 +- examples/stake-on-me/src/helpers.ts | 14 +- examples/toolshed/package-lock.json | 700 +++++++++++++++++- examples/toolshed/package.json | 1 + examples/toolshed/readme.md | 2 +- examples/toolshed/src/App.tsx | 40 +- .../toolshed/src/components/BalanceConfig.tsx | 58 ++ .../toolshed/src/components/KeypairConfig.tsx | 34 +- .../toolshed/src/components/MessageConfig.tsx | 9 +- .../src/components/SelectProvider.tsx | 14 +- .../toolshed/src/components/WalletConfig.tsx | 51 +- .../toolshed/src/components/WebSocket.tsx | 3 +- examples/toolshed/src/main.tsx | 1 + examples/toolshed/src/model/chains.ts | 12 +- examples/toolshed/src/reducer.ts | 11 +- examples/toolshed/vite.config.ts | 6 +- 16 files changed, 864 insertions(+), 105 deletions(-) create mode 100644 examples/toolshed/src/components/BalanceConfig.tsx diff --git a/examples/stake-on-me/cli.ts b/examples/stake-on-me/cli.ts index 3db604d0..64ace568 100644 --- a/examples/stake-on-me/cli.ts +++ b/examples/stake-on-me/cli.ts @@ -1,8 +1,8 @@ -import { logo, separator } from './src/logo' import { askChoices, getNodeList, getRandomNode, keypress } from './src/helpers' -import { GetAccountFromLedger } from '../../src/accounts/providers/Ledger/ethereum' -import { ItemType } from '../../src/messages/types' -import * as post from '../../src/messages/post' +import { logo, separator } from './src/logo' +import { AuthenticatedAlephHttpClient } from '../../packages/client/src' +import { GetAccountFromLedger } from '../../packages/ethereum-ledger/src' +import { ItemType } from '../../packages/message/src/types' const main = async () => { console.log(logo) @@ -46,9 +46,8 @@ const main = async () => { console.log(separator) console.log('Sending a stake message on selected Node. Please check your Ledger to sign the message.') - const stakeMessage = await post.Publish({ - account, - APIServer: 'https://api2.aleph.im', + const client = new AuthenticatedAlephHttpClient(account) + const stakeMessage = await client.createPost({ channel: 'FOUNDATION', storageEngine: ItemType.inline, postType: 'corechan-operation', diff --git a/examples/stake-on-me/src/helpers.ts b/examples/stake-on-me/src/helpers.ts index b15eb7d9..36caa75a 100644 --- a/examples/stake-on-me/src/helpers.ts +++ b/examples/stake-on-me/src/helpers.ts @@ -1,6 +1,7 @@ -import * as readline from 'readline' import { stdin as input, stdout as output } from 'process' -import * as aggregate from '../../../src/messages/aggregate' +import * as readline from 'readline' + +import { AlephHttpClient } from '../../../packages/client/src' type NodeListResponse = { corechannel: { @@ -9,10 +10,11 @@ type NodeListResponse = { } export const getNodeList = async () => { - const list: NodeListResponse = await aggregate.Get({ - address: '0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10', - keys: ['corechannel'], - }) + const client = new AlephHttpClient() + const list: NodeListResponse = await client.fetchAggregate( + '0xa1B3bb7d2332383D96b7796B908fB7f7F3c2Be10', + 'corechannel', + ) return list.corechannel.nodes.filter((node) => node.status === 'active' && !node.locked) } diff --git a/examples/toolshed/package-lock.json b/examples/toolshed/package-lock.json index eebf09d8..da4697ac 100644 --- a/examples/toolshed/package-lock.json +++ b/examples/toolshed/package-lock.json @@ -9,6 +9,7 @@ "version": "0.0.0", "dependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.1.1", + "@metamask/providers": "^17.2.0", "buffer": "^6.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", @@ -907,6 +908,53 @@ "node": ">=12" } }, + "node_modules/@ethereumjs/common": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-3.2.0.tgz", + "integrity": "sha512-pksvzI0VyLgmuEF2FA/JR/4/y6hcPq8OUail3/AvycBaW1d5VSauOZzqGvJ3RTmR4MU35lWE8KseKOsEhrFRBA==", + "dependencies": { + "@ethereumjs/util": "^8.1.0", + "crc-32": "^1.2.0" + } + }, + "node_modules/@ethereumjs/rlp": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.1.tgz", + "integrity": "sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==", + "bin": { + "rlp": "bin/rlp" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@ethereumjs/tx": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-4.2.0.tgz", + "integrity": "sha512-1nc6VO4jtFd172BbSnTnDQVr9IYBFl1y4xPzZdtkrkKIncBCkdbgfdRV+MiTkJYAtTxvV12GRZLqBFT1PNK6Yw==", + "dependencies": { + "@ethereumjs/common": "^3.2.0", + "@ethereumjs/rlp": "^4.0.1", + "@ethereumjs/util": "^8.1.0", + "ethereum-cryptography": "^2.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@ethereumjs/util": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.1.0.tgz", + "integrity": "sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==", + "dependencies": { + "@ethereumjs/rlp": "^4.0.1", + "ethereum-cryptography": "^2.0.0", + "micro-ftch": "^0.3.1" + }, + "engines": { + "node": ">=14" + } + }, "node_modules/@floating-ui/core": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.2.1.tgz", @@ -962,6 +1010,228 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "node_modules/@metamask/json-rpc-engine": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@metamask/json-rpc-engine/-/json-rpc-engine-9.0.3.tgz", + "integrity": "sha512-efeRXW7KaL0BJcAeudSGhzu6sD3hMpxx9nl3V+Yemm1bsyc66yVUhYPR+XH+Y6ZvB2p05ywgvd1Ev5PBwFzr/g==", + "dependencies": { + "@metamask/rpc-errors": "^6.3.1", + "@metamask/safe-event-emitter": "^3.0.0", + "@metamask/utils": "^9.1.0" + }, + "engines": { + "node": "^18.18 || >=20" + } + }, + "node_modules/@metamask/json-rpc-middleware-stream": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@metamask/json-rpc-middleware-stream/-/json-rpc-middleware-stream-8.0.3.tgz", + "integrity": "sha512-x0rh4EzzLtkpBi7adrAZ2qSAXBwk4knARZdR1j5YOyXYN7r0AeoTiTgmw7pfrUIF62x2si+WAOMm9R1hWNteGw==", + "dependencies": { + "@metamask/json-rpc-engine": "^9.0.3", + "@metamask/safe-event-emitter": "^3.0.0", + "@metamask/utils": "^9.1.0", + "readable-stream": "^3.6.2" + }, + "engines": { + "node": "^18.18 || >=20" + } + }, + "node_modules/@metamask/object-multiplex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@metamask/object-multiplex/-/object-multiplex-2.0.0.tgz", + "integrity": "sha512-+ItrieVZie3j2LfYE0QkdW3dsEMfMEp419IGx1zyeLqjRZ14iQUPRO0H6CGgfAAoC0x6k2PfCAGRwJUA9BMrqA==", + "dependencies": { + "once": "^1.4.0", + "readable-stream": "^3.6.2" + }, + "engines": { + "node": "^16.20 || ^18.16 || >=20" + } + }, + "node_modules/@metamask/providers": { + "version": "17.2.0", + "resolved": "https://registry.npmjs.org/@metamask/providers/-/providers-17.2.0.tgz", + "integrity": "sha512-99EIsZo1vIuA7Wc9ruWOd9LGr0GCqEY9lR0/hcjasUZH31MGUe0H/0NdMcz2tRXhsYRvt6M+2lsM4dDG1+atRw==", + "dependencies": { + "@metamask/json-rpc-engine": "^9.0.1", + "@metamask/json-rpc-middleware-stream": "^8.0.1", + "@metamask/object-multiplex": "^2.0.0", + "@metamask/rpc-errors": "^6.3.1", + "@metamask/safe-event-emitter": "^3.1.1", + "@metamask/utils": "^9.0.0", + "detect-browser": "^5.2.0", + "extension-port-stream": "^4.1.0", + "fast-deep-equal": "^3.1.3", + "is-stream": "^2.0.0", + "readable-stream": "^3.6.2" + }, + "engines": { + "node": "^18.18 || >=20" + }, + "peerDependencies": { + "webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0" + } + }, + "node_modules/@metamask/rpc-errors": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@metamask/rpc-errors/-/rpc-errors-6.3.1.tgz", + "integrity": "sha512-ugDY7cKjF4/yH5LtBaOIKHw/AiGGSAmzptAUEiAEGr/78LwuzcXAxmzEQfSfMIfI+f9Djr8cttq1pRJJKfTuCg==", + "dependencies": { + "@metamask/utils": "^9.0.0", + "fast-safe-stringify": "^2.0.6" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@metamask/safe-event-emitter": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@metamask/safe-event-emitter/-/safe-event-emitter-3.1.1.tgz", + "integrity": "sha512-ihb3B0T/wJm1eUuArYP4lCTSEoZsClHhuWyfo/kMX3m/odpqNcPfsz5O2A3NT7dXCAgWPGDQGPqygCpgeniKMw==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/@metamask/superstruct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@metamask/superstruct/-/superstruct-3.1.0.tgz", + "integrity": "sha512-N08M56HdOgBfRKkrgCMZvQppkZGcArEop3kixNEtVbJKm6P9Cfg0YkI6X0s1g78sNrj2fWUwvJADdZuzJgFttA==", + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@metamask/utils": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-9.2.1.tgz", + "integrity": "sha512-/u663aUaB6+Xe75i3Mt/1cCljm41HDYIsna5oBrwGvgkY2zH7/9k9Zjd706cxoAbxN7QgLSVAReUiGnuxCuXrQ==", + "dependencies": { + "@ethereumjs/tx": "^4.2.0", + "@metamask/superstruct": "^3.1.0", + "@noble/hashes": "^1.3.1", + "@scure/base": "^1.1.3", + "@types/debug": "^4.1.7", + "debug": "^4.3.4", + "pony-cause": "^2.1.10", + "semver": "^7.5.4", + "uuid": "^9.0.1" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/@metamask/utils/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", + "dependencies": { + "@noble/hashes": "1.4.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/curves/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/base": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", + "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==", + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", + "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", + "dependencies": { + "@noble/curves": "~1.4.0", + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip32/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.3.0.tgz", + "integrity": "sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==", + "dependencies": { + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@scure/bip39/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "dependencies": { + "@types/ms": "*" + } + }, + "node_modules/@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "node_modules/@types/node": { "version": "18.13.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", @@ -1306,6 +1576,17 @@ "node": ">=10" } }, + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/create-ecdh": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", @@ -1402,6 +1683,11 @@ "minimalistic-assert": "^1.0.0" } }, + "node_modules/detect-browser": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.3.0.tgz", + "integrity": "sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w==" + }, "node_modules/diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -1835,6 +2121,28 @@ "node": ">=0.8.0" } }, + "node_modules/ethereum-cryptography": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.2.1.tgz", + "integrity": "sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==", + "dependencies": { + "@noble/curves": "1.4.2", + "@noble/hashes": "1.4.0", + "@scure/bip32": "1.4.0", + "@scure/bip39": "1.3.0" + } + }, + "node_modules/ethereum-cryptography/node_modules/@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==", + "engines": { + "node": ">= 16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -1845,6 +2153,30 @@ "safe-buffer": "^5.1.1" } }, + "node_modules/extension-port-stream": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/extension-port-stream/-/extension-port-stream-4.2.0.tgz", + "integrity": "sha512-i5IgiPVMVrHN+Zx8PRjvFsOw8L1A3sboVwPZghDjW9Yp1BMmBDE6mCcTNu4xMXPYduBOwI3CBK7wd72LcOyD6g==", + "dependencies": { + "readable-stream": "^3.6.2 || ^4.4.2" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "webextension-polyfill": "^0.10.0 || ^0.11.0 || ^0.12.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "node_modules/find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", @@ -1984,8 +2316,7 @@ "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "node_modules/is-arrayish": { "version": "0.2.1", @@ -2003,6 +2334,17 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -2087,6 +2429,11 @@ "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" }, + "node_modules/micro-ftch": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/micro-ftch/-/micro-ftch-0.3.1.tgz", + "integrity": "sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==" + }, "node_modules/miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", @@ -2148,6 +2495,14 @@ "node": ">=0.10.0" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -2223,6 +2578,14 @@ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, + "node_modules/pony-cause": { + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/pony-cause/-/pony-cause-2.1.11.tgz", + "integrity": "sha512-M7LhCsdNbNgiLYiP4WjsfLUuFmCfnjdF6jKe2R9NKl4WFN+HZPGHJZ9lnLP7f9ZnKe3U9nuWD0szirmj+migUg==", + "engines": { + "node": ">=12.0.0" + } + }, "node_modules/postcss": { "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", @@ -2369,10 +2732,9 @@ } }, "node_modules/readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -2440,7 +2802,6 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true, "funding": [ { "type": "github", @@ -2519,7 +2880,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, "dependencies": { "safe-buffer": "~5.2.0" } @@ -2613,8 +2973,19 @@ "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "bin": { + "uuid": "dist/bin/uuid" + } }, "node_modules/vite": { "version": "3.2.5", @@ -2734,6 +3105,17 @@ "esbuild-windows-arm64": "0.15.18" } }, + "node_modules/webextension-polyfill": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.12.0.tgz", + "integrity": "sha512-97TBmpoWJEE+3nFBQ4VocyCdLKfw54rFaJ6EVQYLBCXqCIpLSZkwGgASpv4oPt9gdKCJ80RJlcmNzNn008Ag6Q==", + "peer": true + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "node_modules/yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", @@ -3296,6 +3678,41 @@ "optional": true, "peer": true }, + "@ethereumjs/common": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/common/-/common-3.2.0.tgz", + "integrity": "sha512-pksvzI0VyLgmuEF2FA/JR/4/y6hcPq8OUail3/AvycBaW1d5VSauOZzqGvJ3RTmR4MU35lWE8KseKOsEhrFRBA==", + "requires": { + "@ethereumjs/util": "^8.1.0", + "crc-32": "^1.2.0" + } + }, + "@ethereumjs/rlp": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@ethereumjs/rlp/-/rlp-4.0.1.tgz", + "integrity": "sha512-tqsQiBQDQdmPWE1xkkBq4rlSW5QZpLOUJ5RJh2/9fug+q9tnUhuZoVLk7s0scUIKTOzEtR72DFBXI4WiZcMpvw==" + }, + "@ethereumjs/tx": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/tx/-/tx-4.2.0.tgz", + "integrity": "sha512-1nc6VO4jtFd172BbSnTnDQVr9IYBFl1y4xPzZdtkrkKIncBCkdbgfdRV+MiTkJYAtTxvV12GRZLqBFT1PNK6Yw==", + "requires": { + "@ethereumjs/common": "^3.2.0", + "@ethereumjs/rlp": "^4.0.1", + "@ethereumjs/util": "^8.1.0", + "ethereum-cryptography": "^2.0.0" + } + }, + "@ethereumjs/util": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@ethereumjs/util/-/util-8.1.0.tgz", + "integrity": "sha512-zQ0IqbdX8FZ9aw11vP+dZkKDkS+kgIvQPHnSAXzP9pLu+Rfu3D3XEeLbicvoXJTYnhZiPmsZUxgdzXwNKxRPbA==", + "requires": { + "@ethereumjs/rlp": "^4.0.1", + "ethereum-cryptography": "^2.0.0", + "micro-ftch": "^0.3.1" + } + }, "@floating-ui/core": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.2.1.tgz", @@ -3342,6 +3759,167 @@ "@jridgewell/sourcemap-codec": "1.4.14" } }, + "@metamask/json-rpc-engine": { + "version": "9.0.3", + "resolved": "https://registry.npmjs.org/@metamask/json-rpc-engine/-/json-rpc-engine-9.0.3.tgz", + "integrity": "sha512-efeRXW7KaL0BJcAeudSGhzu6sD3hMpxx9nl3V+Yemm1bsyc66yVUhYPR+XH+Y6ZvB2p05ywgvd1Ev5PBwFzr/g==", + "requires": { + "@metamask/rpc-errors": "^6.3.1", + "@metamask/safe-event-emitter": "^3.0.0", + "@metamask/utils": "^9.1.0" + } + }, + "@metamask/json-rpc-middleware-stream": { + "version": "8.0.3", + "resolved": "https://registry.npmjs.org/@metamask/json-rpc-middleware-stream/-/json-rpc-middleware-stream-8.0.3.tgz", + "integrity": "sha512-x0rh4EzzLtkpBi7adrAZ2qSAXBwk4knARZdR1j5YOyXYN7r0AeoTiTgmw7pfrUIF62x2si+WAOMm9R1hWNteGw==", + "requires": { + "@metamask/json-rpc-engine": "^9.0.3", + "@metamask/safe-event-emitter": "^3.0.0", + "@metamask/utils": "^9.1.0", + "readable-stream": "^3.6.2" + } + }, + "@metamask/object-multiplex": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@metamask/object-multiplex/-/object-multiplex-2.0.0.tgz", + "integrity": "sha512-+ItrieVZie3j2LfYE0QkdW3dsEMfMEp419IGx1zyeLqjRZ14iQUPRO0H6CGgfAAoC0x6k2PfCAGRwJUA9BMrqA==", + "requires": { + "once": "^1.4.0", + "readable-stream": "^3.6.2" + } + }, + "@metamask/providers": { + "version": "17.2.0", + "resolved": "https://registry.npmjs.org/@metamask/providers/-/providers-17.2.0.tgz", + "integrity": "sha512-99EIsZo1vIuA7Wc9ruWOd9LGr0GCqEY9lR0/hcjasUZH31MGUe0H/0NdMcz2tRXhsYRvt6M+2lsM4dDG1+atRw==", + "requires": { + "@metamask/json-rpc-engine": "^9.0.1", + "@metamask/json-rpc-middleware-stream": "^8.0.1", + "@metamask/object-multiplex": "^2.0.0", + "@metamask/rpc-errors": "^6.3.1", + "@metamask/safe-event-emitter": "^3.1.1", + "@metamask/utils": "^9.0.0", + "detect-browser": "^5.2.0", + "extension-port-stream": "^4.1.0", + "fast-deep-equal": "^3.1.3", + "is-stream": "^2.0.0", + "readable-stream": "^3.6.2" + } + }, + "@metamask/rpc-errors": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/@metamask/rpc-errors/-/rpc-errors-6.3.1.tgz", + "integrity": "sha512-ugDY7cKjF4/yH5LtBaOIKHw/AiGGSAmzptAUEiAEGr/78LwuzcXAxmzEQfSfMIfI+f9Djr8cttq1pRJJKfTuCg==", + "requires": { + "@metamask/utils": "^9.0.0", + "fast-safe-stringify": "^2.0.6" + } + }, + "@metamask/safe-event-emitter": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@metamask/safe-event-emitter/-/safe-event-emitter-3.1.1.tgz", + "integrity": "sha512-ihb3B0T/wJm1eUuArYP4lCTSEoZsClHhuWyfo/kMX3m/odpqNcPfsz5O2A3NT7dXCAgWPGDQGPqygCpgeniKMw==" + }, + "@metamask/superstruct": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@metamask/superstruct/-/superstruct-3.1.0.tgz", + "integrity": "sha512-N08M56HdOgBfRKkrgCMZvQppkZGcArEop3kixNEtVbJKm6P9Cfg0YkI6X0s1g78sNrj2fWUwvJADdZuzJgFttA==" + }, + "@metamask/utils": { + "version": "9.2.1", + "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-9.2.1.tgz", + "integrity": "sha512-/u663aUaB6+Xe75i3Mt/1cCljm41HDYIsna5oBrwGvgkY2zH7/9k9Zjd706cxoAbxN7QgLSVAReUiGnuxCuXrQ==", + "requires": { + "@ethereumjs/tx": "^4.2.0", + "@metamask/superstruct": "^3.1.0", + "@noble/hashes": "^1.3.1", + "@scure/base": "^1.1.3", + "@types/debug": "^4.1.7", + "debug": "^4.3.4", + "pony-cause": "^2.1.10", + "semver": "^7.5.4", + "uuid": "^9.0.1" + }, + "dependencies": { + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==" + } + } + }, + "@noble/curves": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.4.2.tgz", + "integrity": "sha512-TavHr8qycMChk8UwMld0ZDRvatedkzWfH8IiaeGCfymOP5i0hSCozz9vHOL0nkwk7HRMlFnAiKpS2jrUmSybcw==", + "requires": { + "@noble/hashes": "1.4.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==" + } + } + }, + "@noble/hashes": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.5.0.tgz", + "integrity": "sha512-1j6kQFb7QRru7eKN3ZDvRcP13rugwdxZqCjbiAVZfIJwgj2A65UmT4TgARXGlXgnRkORLTDTrO19ZErt7+QXgA==" + }, + "@scure/base": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/@scure/base/-/base-1.1.9.tgz", + "integrity": "sha512-8YKhl8GHiNI/pU2VMaofa2Tor7PJRAjwQLBBuilkJ9L5+13yVbC7JO/wS7piioAvPSwR3JKM1IJ/u4xQzbcXKg==" + }, + "@scure/bip32": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@scure/bip32/-/bip32-1.4.0.tgz", + "integrity": "sha512-sVUpc0Vq3tXCkDGYVWGIZTRfnvu8LoTDaev7vbwh0omSvVORONr960MQWdKqJDCReIEmTj3PAr73O3aoxz7OPg==", + "requires": { + "@noble/curves": "~1.4.0", + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==" + } + } + }, + "@scure/bip39": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@scure/bip39/-/bip39-1.3.0.tgz", + "integrity": "sha512-disdg7gHuTDZtY+ZdkmLpPCk7fxZSu3gBiEGuoC1XYxv9cGx3Z6cpTggCgW6odSOOIXCiDjuGejW+aJKCY/pIQ==", + "requires": { + "@noble/hashes": "~1.4.0", + "@scure/base": "~1.1.6" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==" + } + } + }, + "@types/debug": { + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@types/debug/-/debug-4.1.12.tgz", + "integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==", + "requires": { + "@types/ms": "*" + } + }, + "@types/ms": { + "version": "0.7.34", + "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", + "integrity": "sha512-nG96G3Wp6acyAgJqGasjODb+acrI7KltPiRxzHPXnP3NgI28bpQDRv53olbqGXbfcgF5aiiHmO3xpwEpS5Ld9g==" + }, "@types/node": { "version": "18.13.0", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.13.0.tgz", @@ -3612,6 +4190,11 @@ "yaml": "^1.10.0" } }, + "crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" + }, "create-ecdh": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/create-ecdh/-/create-ecdh-4.0.4.tgz", @@ -3699,6 +4282,11 @@ "minimalistic-assert": "^1.0.0" } }, + "detect-browser": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/detect-browser/-/detect-browser-5.3.0.tgz", + "integrity": "sha512-53rsFbGdwMwlF7qvCt0ypLM5V5/Mbl0szB7GPN8y9NCcbknYOeVVXdrXEq+90IwAfrrzt6Hd+u2E2ntakICU8w==" + }, "diffie-hellman": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/diffie-hellman/-/diffie-hellman-5.0.3.tgz", @@ -3943,6 +4531,24 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==" }, + "ethereum-cryptography": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-2.2.1.tgz", + "integrity": "sha512-r/W8lkHSiTLxUxW8Rf3u4HGB0xQweG2RyETjywylKZSzLWoWAijRz8WCuOtJ6wah+avllXBqZuk29HCCvhEIRg==", + "requires": { + "@noble/curves": "1.4.2", + "@noble/hashes": "1.4.0", + "@scure/bip32": "1.4.0", + "@scure/bip39": "1.3.0" + }, + "dependencies": { + "@noble/hashes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.4.0.tgz", + "integrity": "sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==" + } + } + }, "evp_bytestokey": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz", @@ -3953,6 +4559,24 @@ "safe-buffer": "^5.1.1" } }, + "extension-port-stream": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/extension-port-stream/-/extension-port-stream-4.2.0.tgz", + "integrity": "sha512-i5IgiPVMVrHN+Zx8PRjvFsOw8L1A3sboVwPZghDjW9Yp1BMmBDE6mCcTNu4xMXPYduBOwI3CBK7wd72LcOyD6g==", + "requires": { + "readable-stream": "^3.6.2 || ^4.4.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + }, + "fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "find-root": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/find-root/-/find-root-1.1.0.tgz", @@ -4050,8 +4674,7 @@ "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", - "dev": true + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, "is-arrayish": { "version": "0.2.1", @@ -4066,6 +4689,11 @@ "has": "^1.0.3" } }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4132,6 +4760,11 @@ "resolved": "https://registry.npmjs.org/memoize-one/-/memoize-one-6.0.0.tgz", "integrity": "sha512-rkpe71W0N0c0Xz6QD0eJETuWAJGnJ9afsl1srmwPrI+yBCkge5EycXXbYRyvL29zZVUWQCY7InPRCv3GDXuZNw==" }, + "micro-ftch": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/micro-ftch/-/micro-ftch-0.3.1.tgz", + "integrity": "sha512-/0LLxhzP0tfiR5hcQebtudP56gUurs2CLkGarnCiB/OqEyUFQ6U3paQi/tgLv0hBJYt2rnr9MNpxz4fiiugstg==" + }, "miller-rabin": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/miller-rabin/-/miller-rabin-4.0.1.tgz", @@ -4183,6 +4816,14 @@ "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==" }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -4243,6 +4884,11 @@ "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==" }, + "pony-cause": { + "version": "2.1.11", + "resolved": "https://registry.npmjs.org/pony-cause/-/pony-cause-2.1.11.tgz", + "integrity": "sha512-M7LhCsdNbNgiLYiP4WjsfLUuFmCfnjdF6jKe2R9NKl4WFN+HZPGHJZ9lnLP7f9ZnKe3U9nuWD0szirmj+migUg==" + }, "postcss": { "version": "8.4.21", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.21.tgz", @@ -4361,10 +5007,9 @@ } }, "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "dev": true, + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", "requires": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -4413,8 +5058,7 @@ "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", - "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", - "dev": true + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" }, "safer-buffer": { "version": "2.1.2", @@ -4466,7 +5110,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", - "dev": true, "requires": { "safe-buffer": "~5.2.0" } @@ -4518,8 +5161,12 @@ "util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", - "dev": true + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" + }, + "uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==" }, "vite": { "version": "3.2.5", @@ -4580,6 +5227,17 @@ } } }, + "webextension-polyfill": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.12.0.tgz", + "integrity": "sha512-97TBmpoWJEE+3nFBQ4VocyCdLKfw54rFaJ6EVQYLBCXqCIpLSZkwGgASpv4oPt9gdKCJ80RJlcmNzNn008Ag6Q==", + "peer": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "yallist": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", diff --git a/examples/toolshed/package.json b/examples/toolshed/package.json index 749a53e3..a87c9666 100644 --- a/examples/toolshed/package.json +++ b/examples/toolshed/package.json @@ -10,6 +10,7 @@ }, "dependencies": { "@esbuild-plugins/node-globals-polyfill": "^0.1.1", + "@metamask/providers": "^17.2.0", "buffer": "^6.0.3", "react": "^18.2.0", "react-dom": "^18.2.0", diff --git a/examples/toolshed/readme.md b/examples/toolshed/readme.md index 71d87b71..3648e1c3 100644 --- a/examples/toolshed/readme.md +++ b/examples/toolshed/readme.md @@ -8,7 +8,7 @@ You must install all the dependencies from the typescript sdk at the root of the ```shell # assumes you are in the root of the project -npm install && npm build +npm install && npm run build # now we can go to the toolshed example cd examples/toolshed diff --git a/examples/toolshed/src/App.tsx b/examples/toolshed/src/App.tsx index 40b2c235..be36b86e 100644 --- a/examples/toolshed/src/App.tsx +++ b/examples/toolshed/src/App.tsx @@ -1,25 +1,40 @@ -import { useReducer } from 'react' +import { useCallback, useReducer } from 'react' -import { initState, reducer } from './reducer' - -import SelectProvider from './components/SelectProvider' +import BalanceConfig from './components/BalanceConfig' +import HardwareConfig from './components/HardwareConfig' import KeypairConfig from './components/KeypairConfig' -import WalletConfig from './components/WalletConfig' import MessageConfig from './components/MessageConfig' +import SelectProvider from './components/SelectProvider' +import WalletConfig from './components/WalletConfig' import WebSocket from './components/WebSocket' -import HardwareConfig from './components/HardwareConfig' +import { HardwareChains, KeypairChains, WalletChains } from './model/chains' +import { initState, reducer } from './reducer' import { ECIESAccount } from '../../../packages/account/src' +import { ChainMetadata, EVMAccount } from '../../../packages/evm/src' function App() { const [state, dispatch] = useReducer(reducer, initState) + const connectedChain = useCallback( + () => + (state?.account as EVMAccount)?.selectedRpcId !== undefined + ? `${ChainMetadata[(state.account as EVMAccount).selectedRpcId!].chainName}` + : undefined, + [state?.account], + ) const connection = () => { if (state.account) { return (
+ {connectedChain() ? ( + <> +

Connected to:

+ {connectedChain()} + + ) : null}

Your address is:

{state.account.address} - {state.account instanceof ECIESAccount && ( + {state.account instanceof ECIESAccount && state.account.publicKey && ( <>

Your public key is:

{state.account.publicKey} @@ -65,7 +80,16 @@ function App() {
{state.account && } - + {state.account && + [ + HardwareChains.Ethereum, + KeypairChains.Ethereum, + KeypairChains.Avalanche, + KeypairChains.Base, + WalletChains.Ethereum, + WalletChains.Avalanche, + WalletChains.Base, + ].includes(state.selectedChain) && }
{ + if (!evmAccount.address) setBalance(-2) + else + evmAccount + .getALEPHBalance() + .then(Number) + .then(setBalance) + .catch(async (err) => { + console.error(err) + if (err.message.startsWith('No token address found')) setBalance(-2) + else if (err.message.startsWith('underlying network changed')) { + const rpcId = evmAccount.selectedRpcId! + const _account = [RpcId.AVAX, RpcId.AVAX_TESTNET].includes(rpcId) + ? avalanche + : [RpcId.BASE, RpcId.BASE_TESTNET].includes(rpcId) + ? base + : ethereum + dispatch({ + type: Actions.SET_ACCOUNT, + payload: await _account.getAccountFromProvider(window.ethereum as any, rpcId), + }) + } else { + setBalance(-3) + console.error(err) + } + }) + }, [evmAccount]) + + return ( +
+

+ ALEPH Balance:{' '} + {balance >= 0 + ? balance.toString() + : balance === -1 + ? 'Loading...' + : balance === -2 + ? 'No token address on this chain' + : 'Error'} +

+
+ ) +} + +export default BalanceConfig diff --git a/examples/toolshed/src/components/KeypairConfig.tsx b/examples/toolshed/src/components/KeypairConfig.tsx index ef2e69ee..5bae6787 100644 --- a/examples/toolshed/src/components/KeypairConfig.tsx +++ b/examples/toolshed/src/components/KeypairConfig.tsx @@ -1,9 +1,11 @@ import { useState } from 'react' -import * as ethereum from '../../../../packages/ethereum/src' + import * as avalanche from '../../../../packages/avalanche/src' -import * as substrate from '../../../../packages/substrate/src' -import * as solana from '../../../../packages/solana/src' +import * as base from '../../../../packages/base/src' +import * as ethereum from '../../../../packages/ethereum/src' import * as nuls2 from '../../../../packages/nuls2/src' +import * as solana from '../../../../packages/solana/src' +import * as substrate from '../../../../packages/substrate/src' import { KeypairChains } from '../model/chains' import { dispatchAndConsume } from '../model/componentProps' import { Actions } from '../reducer' @@ -12,20 +14,22 @@ function KeypairConfig({ state, dispatch }: dispatchAndConsume) { const [mnemonicOrPk, setMnemonicOrPk] = useState('') const _account = (() => - state.selectedChain === KeypairChains.Avalanche - ? avalanche - : state.selectedChain === KeypairChains.Ethereum - ? ethereum - : state.selectedChain === KeypairChains.NULS2 - ? nuls2 - : state.selectedChain === KeypairChains.Polkadot - ? substrate - : state.selectedChain === KeypairChains.Solana - ? solana - : null)() + state.selectedChain === KeypairChains.Ethereum + ? ethereum + : state.selectedChain === KeypairChains.Avalanche + ? avalanche + : state.selectedChain === KeypairChains.Base + ? base + : state.selectedChain === KeypairChains.Solana + ? solana + : state.selectedChain === KeypairChains.NULS2 + ? nuls2 + : state.selectedChain === KeypairChains.Polkadot + ? substrate + : undefined)() const getKeypair = async () => { - if (_account === null) return console.error('Internal error') + if (!_account) return console.error('Internal error') const { account } = await _account.newAccount() dispatch({ diff --git a/examples/toolshed/src/components/MessageConfig.tsx b/examples/toolshed/src/components/MessageConfig.tsx index d8de7409..25950965 100644 --- a/examples/toolshed/src/components/MessageConfig.tsx +++ b/examples/toolshed/src/components/MessageConfig.tsx @@ -1,13 +1,15 @@ import { useState } from 'react' +import { Account } from '../../../../packages/account/src' +import { AuthenticatedAlephHttpClient } from '../../../../packages/client/src' +import { ItemType } from '../../../../packages/message/src' import { consumeProps } from '../model/componentProps' -import { ItemType, PostMessageClient } from '../../../../packages/message' function MessageConfig({ state }: consumeProps) { const [messageHash, setMessageHash]: [string | null, any] = useState(null) const [isSending, setIsSending] = useState(false) const [messageContent, setMessageContent] = useState('Did the quick brown fox jump over the lazy dog?!') - const postClient = new PostMessageClient() + const client = new AuthenticatedAlephHttpClient(state.account as Account) const handleChange = (e: any) => { setMessageContent(e.target.value) @@ -19,10 +21,9 @@ function MessageConfig({ state }: consumeProps) { if (!state.account) return alert('No account selected') - const message = await postClient.send({ + const message = await client.createPost({ channel: 'Typescript-SDK-Toolshed', storageEngine: ItemType.inline, - account: state.account, postType: 'Toolshed', content: messageContent, }) diff --git a/examples/toolshed/src/components/SelectProvider.tsx b/examples/toolshed/src/components/SelectProvider.tsx index 3cee5597..6fd87a14 100644 --- a/examples/toolshed/src/components/SelectProvider.tsx +++ b/examples/toolshed/src/components/SelectProvider.tsx @@ -1,4 +1,5 @@ -import Select, { SingleValue } from 'react-select' +import Select, { type SingleValue } from 'react-select' + import { HardwareChains, KeypairChains, WalletChains } from '../model/chains' import { dispatchProps } from '../model/componentProps' import { Actions } from '../reducer' @@ -10,19 +11,20 @@ type Option = { } export const availableKeypairs: Option[] = [ + { label: 'Ethereum', value: KeypairChains.Ethereum }, { label: 'Avalanche', value: KeypairChains.Avalanche }, + { label: 'Base', value: KeypairChains.Base }, + { label: 'Solana', value: KeypairChains.Solana }, + { label: 'Tezos', value: KeypairChains.Tezos }, { label: 'Cosmos', value: 'CSDK_KP' }, - { label: 'Ethereum', value: KeypairChains.Ethereum }, { label: 'NULS2', value: KeypairChains.NULS2 }, { label: 'Polkadot/Substrate', value: KeypairChains.Polkadot }, - { label: 'Solana', value: KeypairChains.Solana }, - { label: 'Tezos', value: KeypairChains.Tezos }, ] export const availableWallets: Option[] = [ - { label: 'PolkaDot (via Polka.js)', value: WalletChains.Substrate }, - { label: 'Ethereum (via Metamask)', value: WalletChains.Ethereum }, + { label: 'EVM (via Metamask)', value: WalletChains.Ethereum }, { label: 'Solana (via Phantom)', value: WalletChains.Solana }, + { label: 'PolkaDot (via Polka.js)', value: WalletChains.Substrate }, ] export const availableHardware: Option[] = [{ label: 'Ethereum (via Ledger)', value: HardwareChains.Ethereum }] diff --git a/examples/toolshed/src/components/WalletConfig.tsx b/examples/toolshed/src/components/WalletConfig.tsx index cb21020a..e068b54e 100644 --- a/examples/toolshed/src/components/WalletConfig.tsx +++ b/examples/toolshed/src/components/WalletConfig.tsx @@ -1,13 +1,15 @@ -import { WalletChains } from '../model/chains' -import { dispatchAndConsume } from '../model/componentProps' -import { Actions } from '../reducer' -import Select, { SingleValue } from 'react-select' -import { useState } from 'react' -import { RpcId } from '../../../../packages/evm' +import { useCallback, useState } from 'react' +import Select, { type SingleValue } from 'react-select' + import * as avalanche from '../../../../packages/avalanche/src' +import * as base from '../../../../packages/base/src' import * as ethereum from '../../../../packages/ethereum/src' -import * as substrate from '../../../../packages/substrate/src' +import { RpcId } from '../../../../packages/evm/src' import * as solana from '../../../../packages/solana/src' +import * as substrate from '../../../../packages/substrate/src' +import { WalletChains } from '../model/chains' +import { dispatchAndConsume } from '../model/componentProps' +import { Actions } from '../reducer' type Option = { readonly label: string @@ -18,34 +20,37 @@ type Option = { const availableChains: Option[] = [ { label: 'Ethereum Mainnet', value: RpcId.ETH }, { label: 'Ethereum Mainnet (FLASHBOT)', value: RpcId.ETH_FLASHBOTS }, + { label: 'Ethereum Sepolia (Testnet)', value: RpcId.ETH_SEPOLIA }, { label: 'Avalanche Mainnet', value: RpcId.AVAX }, + { label: 'Avalanche Fuji (Testnet)', value: RpcId.AVAX_TESTNET }, + { label: 'Base Mainnet', value: RpcId.BASE }, + { label: 'Base Sepolia (Testnet)', value: RpcId.BASE_TESTNET }, { label: 'Polygon Mainnet', value: RpcId.POLYGON }, { label: 'BSC Mainnet', value: RpcId.BSC }, ] -function WalletConfig({ dispatch, state }: dispatchAndConsume) { - const [customEndpoint, setCustomEndpoint] = useState(availableChains[0].value) +function WalletConfig({ state, dispatch }: dispatchAndConsume) { + const [rpcId, setRpcId] = useState(availableChains[0].value) + const getAccountClass = () => - state.selectedChain === WalletChains.Avalanche - ? [avalanche, window.ethereum] + state.selectedChain === WalletChains.Solana + ? [solana, window.phantom?.solana] : state.selectedChain === WalletChains.Substrate ? [substrate, null] - : state.selectedChain === WalletChains.Ethereum + : [RpcId.ETH, RpcId.ETH_FLASHBOTS, RpcId.ETH_SEPOLIA].includes(rpcId) ? [ethereum, window.ethereum] - : state.selectedChain === WalletChains.Solana - ? [solana, window.phantom?.solana] - : [null, null] + : [RpcId.AVAX, RpcId.AVAX_TESTNET].includes(rpcId) + ? [avalanche, window.ethereum] + : [RpcId.BASE, RpcId.BASE_TESTNET].includes(rpcId) + ? [base, window.ethereum] + : [null, null] - const connectToMetamask = async () => { + const connectToMetamask = useCallback(async () => { const [_account, provider] = getAccountClass() - if (_account === null) return try { - const account = - state.selectedChain === WalletChains.Ethereum - ? await _account.getAccountFromProvider(provider, customEndpoint) - : await _account.getAccountFromProvider(provider) + const account = await _account.getAccountFromProvider(provider, rpcId) dispatch({ type: Actions.SET_ACCOUNT, payload: account, @@ -53,10 +58,10 @@ function WalletConfig({ dispatch, state }: dispatchAndConsume) { } catch (err) { alert(err) } - } + }, [rpcId]) const handleChange = (x: SingleValue