From 4c4e61d1c42d0ea783c0ffa4bda18bb7db978ced Mon Sep 17 00:00:00 2001 From: Reza Rahemtola Date: Tue, 3 Sep 2024 00:17:27 +0900 Subject: [PATCH] wip --- package-lock.json | 432 ++++++-------------------- package.json | 9 +- src/utils/aleph-persistent-storage.ts | 40 ++- 3 files changed, 127 insertions(+), 354 deletions(-) diff --git a/package-lock.json b/package-lock.json index 78260c3..7f23915 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,10 +9,12 @@ "version": "0.0.1", "license": "MIT", "dependencies": { + "@aleph-sdk/base": "file:../aleph-sdk-ts/packages/base", "@aleph-sdk/client": "^1.0.6", - "@aleph-sdk/ethereum": "file:../aleph-sdk-ts/packages/ethereum/aleph-sdk-ethereum-1.0.3.tgz", - "@aleph-sdk/evm": "file:../aleph-sdk-ts/packages/evm/aleph-sdk-evm-1.0.4.tgz", - "@aleph-sdk/message": "^1.0.7", + "@aleph-sdk/core": "file:../aleph-sdk-ts/packages/core", + "@aleph-sdk/ethereum": "file:../aleph-sdk-ts/packages/ethereum", + "@aleph-sdk/evm": "file:../aleph-sdk-ts/packages/evm", + "@aleph-sdk/message": "file:../aleph-sdk-ts/packages/message", "@libertai/libertai-js": "0.0.10-beta", "@quasar/extras": "^1.16.12", "@tanstack/vue-query": "^5.51.21", @@ -22,6 +24,7 @@ "dompurify": "^3.1.6", "dotenv": "^16.4.5", "eciesjs": "^0.4.7", + "ethers": "^5.7.2", "filesize": "^10.1.4", "highlight.js": "^11.10.0", "langchain": "^0.2.13", @@ -68,42 +71,34 @@ "yarn": "please-use-npm" } }, - "node_modules/@adraffy/ens-normalize": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", - "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==", - "license": "MIT" - }, - "node_modules/@aleph-sdk/account": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@aleph-sdk/account/-/account-1.0.3.tgz", - "integrity": "sha512-LVeY3bJ5pg1JxQpnIB7f1Dz4TVN1SuJeI4dFKJy/71r6foF1zUxzWt+dbedc1zhOspjlgf5oU6gsXZrkzUGLhQ==", - "license": "MIT", - "peer": true, - "peerDependencies": { - "@aleph-sdk/core": "^1.x.x" - } - }, - "node_modules/@aleph-sdk/client": { - "version": "1.0.6", + "../aleph-sdk-ts/packages/base": { + "name": "@aleph-sdk/base", + "version": "1.0.0", "license": "MIT", + "dependencies": { + "eciesjs": "^0.4.6", + "sha.js": "^2.4.11" + }, + "devDependencies": { + "@types/sha.js": "^2.4.0" + }, "peerDependencies": { "@aleph-sdk/account": "^1.x.x", - "@aleph-sdk/core": "^1.x.x", - "@aleph-sdk/message": "^1.x.x" + "@aleph-sdk/core": "^1.0.4", + "@aleph-sdk/ethereum": "^1.x.x", + "@aleph-sdk/evm": "^1.0.4", + "avalanche": "^3.15.3", + "ethers": "^5.x.x" } }, - "node_modules/@aleph-sdk/core": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@aleph-sdk/core/-/core-1.0.3.tgz", - "integrity": "sha512-+enhpR4U7jcEvKDRPuaQo2+Qxw2L0ZEDGLtDsKiwpBqYaNHkreCtTpD0gZy+eNulpFYLifv5q8FE6m+Hvvc9OA==", - "license": "MIT", - "peer": true + "../aleph-sdk-ts/packages/core": { + "name": "@aleph-sdk/core", + "version": "1.0.4", + "license": "MIT" }, - "node_modules/@aleph-sdk/ethereum": { + "../aleph-sdk-ts/packages/ethereum": { + "name": "@aleph-sdk/ethereum", "version": "1.0.3", - "resolved": "file:../aleph-sdk-ts/packages/ethereum/aleph-sdk-ethereum-1.0.3.tgz", - "integrity": "sha512-u+OU1J6uGFxpTlmnS+MmYotXYRvvdHOUMLEBYYQjEVtHlI3YlEwn5ro9xNCzjH1Vh9z48FEuMZzqVHWuSuzi2w==", "license": "MIT", "dependencies": { "bip39": "^3.1.0", @@ -116,34 +111,86 @@ "ethers": "^5.x.x" } }, - "node_modules/@aleph-sdk/evm": { + "../aleph-sdk-ts/packages/evm": { + "name": "@aleph-sdk/evm", "version": "1.0.4", - "resolved": "file:../aleph-sdk-ts/packages/evm/aleph-sdk-evm-1.0.4.tgz", - "integrity": "sha512-msCd/ssASraYoO8VDpQWsN/LJBWac9lKm3nqo5ttdQMfJDvr+7kkYeVmaAy6j3R1b4zvppLRIo9Mh2ZsibOS/g==", "license": "MIT", "dependencies": { "@metamask/eth-sig-util": "^7.0.1", "ethereumjs-util": "^7.1.5" }, + "devDependencies": { + "ethers": "^5.x.x" + }, "peerDependencies": { "@aleph-sdk/account": "^1.x.x", "@aleph-sdk/core": "^1.x.x", "ethers": "^5.x.x" } }, - "node_modules/@aleph-sdk/message": { - "version": "1.0.7", + "../aleph-sdk-ts/packages/message": { + "name": "@aleph-sdk/message", + "version": "1.0.8", "license": "MIT", "dependencies": { "axios": "^1.5.1", "form-data": "^4.0.0", "sha.js": "^2.4.11" }, + "devDependencies": { + "@types/sha.js": "^2.4.4" + }, "peerDependencies": { "@aleph-sdk/account": "^1.x.x", + "@aleph-sdk/core": "^1.x.x", + "@aleph-sdk/evm": "^1.x.x" + } + }, + "node_modules/@adraffy/ens-normalize": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz", + "integrity": "sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q==", + "license": "MIT" + }, + "node_modules/@aleph-sdk/account": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/@aleph-sdk/account/-/account-1.0.3.tgz", + "integrity": "sha512-LVeY3bJ5pg1JxQpnIB7f1Dz4TVN1SuJeI4dFKJy/71r6foF1zUxzWt+dbedc1zhOspjlgf5oU6gsXZrkzUGLhQ==", + "license": "MIT", + "peer": true, + "peerDependencies": { "@aleph-sdk/core": "^1.x.x" } }, + "node_modules/@aleph-sdk/base": { + "resolved": "../aleph-sdk-ts/packages/base", + "link": true + }, + "node_modules/@aleph-sdk/client": { + "version": "1.0.6", + "license": "MIT", + "peerDependencies": { + "@aleph-sdk/account": "^1.x.x", + "@aleph-sdk/core": "^1.x.x", + "@aleph-sdk/message": "^1.x.x" + } + }, + "node_modules/@aleph-sdk/core": { + "resolved": "../aleph-sdk-ts/packages/core", + "link": true + }, + "node_modules/@aleph-sdk/ethereum": { + "resolved": "../aleph-sdk-ts/packages/ethereum", + "link": true + }, + "node_modules/@aleph-sdk/evm": { + "resolved": "../aleph-sdk-ts/packages/evm", + "link": true + }, + "node_modules/@aleph-sdk/message": { + "resolved": "../aleph-sdk-ts/packages/message", + "link": true + }, "node_modules/@alloc/quick-lru": { "version": "5.2.0", "dev": true, @@ -2628,7 +2675,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -2656,7 +2702,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -2682,7 +2727,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -2706,7 +2750,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -2730,7 +2773,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0" } @@ -2750,7 +2792,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/properties": "^5.7.0" @@ -2771,7 +2812,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", @@ -2782,8 +2822,7 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@ethersproject/bytes": { "version": "5.7.0", @@ -2800,7 +2839,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/logger": "^5.7.0" } @@ -2820,7 +2858,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bignumber": "^5.7.0" } @@ -2840,7 +2877,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abi": "^5.7.0", "@ethersproject/abstract-provider": "^5.7.0", @@ -2869,7 +2905,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/address": "^5.7.0", @@ -2897,7 +2932,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/basex": "^5.7.0", @@ -2928,7 +2962,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-signer": "^5.7.0", "@ethersproject/address": "^5.7.0", @@ -2960,7 +2993,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "js-sha3": "0.8.0" @@ -2980,8 +3012,7 @@ "url": "https://www.buymeacoffee.com/ricmoo" } ], - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@ethersproject/networks": { "version": "5.7.1", @@ -2998,7 +3029,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/logger": "^5.7.0" } @@ -3018,7 +3048,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/sha2": "^5.7.0" @@ -3039,7 +3068,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/logger": "^5.7.0" } @@ -3059,7 +3087,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/abstract-signer": "^5.7.0", @@ -3088,7 +3115,6 @@ "resolved": "https://registry.npmjs.org/ws/-/ws-7.4.6.tgz", "integrity": "sha512-YmhHDO4MzaDLB+M9ym/mDA5z0naX8j7SIlT8f8z+I0VtzsRbekxEutHSme7NPS2qE8StCYQNUnfWdXta/Yu85A==", "license": "MIT", - "peer": true, "engines": { "node": ">=8.3.0" }, @@ -3120,7 +3146,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0" @@ -3141,7 +3166,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0" @@ -3162,7 +3186,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", @@ -3184,7 +3207,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/logger": "^5.7.0", @@ -3198,15 +3220,13 @@ "version": "5.2.1", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@ethersproject/signing-key/node_modules/elliptic": { "version": "6.5.4", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.5.4.tgz", "integrity": "sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ==", "license": "MIT", - "peer": true, "dependencies": { "bn.js": "^4.11.9", "brorand": "^1.1.0", @@ -3221,8 +3241,7 @@ "version": "4.12.0", "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz", "integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/@ethersproject/solidity": { "version": "5.7.0", @@ -3239,7 +3258,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -3264,7 +3282,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/constants": "^5.7.0", @@ -3286,7 +3303,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/address": "^5.7.0", "@ethersproject/bignumber": "^5.7.0", @@ -3314,7 +3330,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bignumber": "^5.7.0", "@ethersproject/constants": "^5.7.0", @@ -3336,7 +3351,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abstract-provider": "^5.7.0", "@ethersproject/abstract-signer": "^5.7.0", @@ -3370,7 +3384,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/base64": "^5.7.0", "@ethersproject/bytes": "^5.7.0", @@ -3394,7 +3407,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/bytes": "^5.7.0", "@ethersproject/hash": "^5.7.0", @@ -3747,52 +3759,6 @@ "@lit-labs/ssr-dom-shim": "^1.0.0" } }, - "node_modules/@metamask/abi-utils": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@metamask/abi-utils/-/abi-utils-2.0.4.tgz", - "integrity": "sha512-StnIgUB75x7a7AgUhiaUZDpCsqGp7VkNnZh2XivXkJ6mPkE83U8ARGQj5MbRis7VJY8BC5V1AbB1fjdh0hupPQ==", - "license": "(Apache-2.0 AND MIT)", - "dependencies": { - "@metamask/superstruct": "^3.1.0", - "@metamask/utils": "^9.0.0" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "node_modules/@metamask/abi-utils/node_modules/@metamask/utils": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-9.1.0.tgz", - "integrity": "sha512-g2REf+xSt0OZfMoNNdC4+/Yy8eP3KUqvIArel54XRFKPoXbHI6+YjFfrLtfykWBjffOp7DTfIc3Kvk5TLfuiyg==", - "license": "ISC", - "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/abi-utils/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" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@metamask/eth-json-rpc-provider": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@metamask/eth-json-rpc-provider/-/eth-json-rpc-provider-1.0.1.tgz", @@ -3869,56 +3835,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/@metamask/eth-sig-util": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/@metamask/eth-sig-util/-/eth-sig-util-7.0.3.tgz", - "integrity": "sha512-PAtGnOkYvh90k2lEZldq/FK7GTLF6WxE+2bV85PoA3pqlJnmJCAY62tuvxHSwnVngSKlc4mcNvjnUg2eYO6JGg==", - "license": "ISC", - "dependencies": { - "@ethereumjs/util": "^8.1.0", - "@metamask/abi-utils": "^2.0.4", - "@metamask/utils": "^9.0.0", - "@scure/base": "~1.1.3", - "ethereum-cryptography": "^2.1.2", - "tweetnacl": "^1.0.3" - }, - "engines": { - "node": "^16.20 || ^18.16 || >=20" - } - }, - "node_modules/@metamask/eth-sig-util/node_modules/@metamask/utils": { - "version": "9.1.0", - "resolved": "https://registry.npmjs.org/@metamask/utils/-/utils-9.1.0.tgz", - "integrity": "sha512-g2REf+xSt0OZfMoNNdC4+/Yy8eP3KUqvIArel54XRFKPoXbHI6+YjFfrLtfykWBjffOp7DTfIc3Kvk5TLfuiyg==", - "license": "ISC", - "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/eth-sig-util/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" - ], - "license": "MIT", - "bin": { - "uuid": "dist/bin/uuid" - } - }, "node_modules/@metamask/json-rpc-engine": { "version": "8.0.2", "resolved": "https://registry.npmjs.org/@metamask/json-rpc-engine/-/json-rpc-engine-8.0.2.tgz", @@ -5868,15 +5784,6 @@ } } }, - "node_modules/@types/bn.js": { - "version": "5.1.5", - "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-5.1.5.tgz", - "integrity": "sha512-V46N0zwKRF5Q00AZ6hWtN0T8gGmDUaUzLWQvHFo5yThtVwK/VCenFY3wXVbOvNfajEpsTfQM4IN9k/d6gUVX3A==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/body-parser": { "version": "1.19.5", "dev": true, @@ -6052,15 +5959,6 @@ "@types/node": "*" } }, - "node_modules/@types/pbkdf2": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@types/pbkdf2/-/pbkdf2-3.1.2.tgz", - "integrity": "sha512-uRwJqmiXmh9++aSu1VNEn3iIxWOhd8AHXNSdlaLfdAAdSTY9jYVeGWnzejM3dvrkbqE3/hyQkQQ29IFATEGlew==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/qs": { "version": "6.9.15", "dev": true, @@ -7336,8 +7234,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.0.0.tgz", "integrity": "sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/agentkeepalive": { "version": "4.5.0", @@ -7851,15 +7748,6 @@ "version": "1.0.2", "license": "MIT" }, - "node_modules/base-x": { - "version": "3.0.10", - "resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.10.tgz", - "integrity": "sha512-7d0s06rR9rYaIWHkpfLIFICM/tkSVdoPC9qYAQRpxn9DdKNWNsKC0uk++akckyLq16Tx2WIinnZ6WRriAt6njQ==", - "license": "MIT", - "dependencies": { - "safe-buffer": "^5.0.1" - } - }, "node_modules/base64-js": { "version": "1.5.1", "funding": [ @@ -7882,8 +7770,7 @@ "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", "integrity": "sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/binary-extensions": { "version": "2.3.0", @@ -7901,13 +7788,6 @@ "integrity": "sha512-nbE1WxOTTrUWIfsfZ4aHGYu5DOuNkbxGokjV6Z2kxfJK3uaAb8zNK1muzOeipoLHZjInT4Br88BHpzevc681xA==", "license": "CC0-1.0" }, - "node_modules/bip39": { - "version": "3.1.0", - "license": "ISC", - "dependencies": { - "@noble/hashes": "^1.2.0" - } - }, "node_modules/bl": { "version": "4.1.0", "license": "MIT", @@ -7939,12 +7819,6 @@ "ieee754": "^1.1.13" } }, - "node_modules/blakejs": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/blakejs/-/blakejs-1.2.1.tgz", - "integrity": "sha512-QXUSXI3QVc/gJME0dBpXrag1kbzOqCjCX8/b54ntNyW6sjtoqxqRk3LTmXzaJoh71zMsDCjM+47jS7XiwN/+fQ==", - "license": "MIT" - }, "node_modules/bn.js": { "version": "4.12.0", "license": "MIT" @@ -8028,6 +7902,7 @@ }, "node_modules/browserify-aes": { "version": "1.2.0", + "dev": true, "license": "MIT", "dependencies": { "buffer-xor": "^1.0.3", @@ -8170,26 +8045,6 @@ "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" } }, - "node_modules/bs58": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", - "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", - "license": "MIT", - "dependencies": { - "base-x": "^3.0.2" - } - }, - "node_modules/bs58check": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/bs58check/-/bs58check-2.1.2.tgz", - "integrity": "sha512-0TS1jicxdU09dwJMNZtVAfzPi6Q6QeN0pM1Fkzrjn+XYHvzMKPU3pHVpva+769iNVSfIYWf7LJ6WR+BuuMf8cA==", - "license": "MIT", - "dependencies": { - "bs58": "^4.0.0", - "create-hash": "^1.1.0", - "safe-buffer": "^5.1.2" - } - }, "node_modules/bser": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", @@ -8238,6 +8093,7 @@ }, "node_modules/buffer-xor": { "version": "1.0.3", + "dev": true, "license": "MIT" }, "node_modules/bufferutil": { @@ -8484,6 +8340,7 @@ }, "node_modules/cipher-base": { "version": "1.0.4", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.1", @@ -9160,6 +9017,7 @@ }, "node_modules/create-hash": { "version": "1.2.0", + "dev": true, "license": "MIT", "dependencies": { "cipher-base": "^1.0.1", @@ -9171,6 +9029,7 @@ }, "node_modules/create-hmac": { "version": "1.1.7", + "dev": true, "license": "MIT", "dependencies": { "cipher-base": "^1.0.3", @@ -10115,72 +9974,6 @@ "@scure/bip39": "1.3.0" } }, - "node_modules/ethereumjs-util": { - "version": "7.1.5", - "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-7.1.5.tgz", - "integrity": "sha512-SDl5kKrQAudFBUe5OJM9Ac6WmMyYmXX/6sTmLZ3ffG2eY6ZIGBes3pEDxNN6V72WyOw4CPD5RomKdsa8DAAwLg==", - "license": "MPL-2.0", - "dependencies": { - "@types/bn.js": "^5.1.0", - "bn.js": "^5.1.2", - "create-hash": "^1.1.2", - "ethereum-cryptography": "^0.1.3", - "rlp": "^2.2.4" - }, - "engines": { - "node": ">=10.0.0" - } - }, - "node_modules/ethereumjs-util/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT" - }, - "node_modules/ethereumjs-util/node_modules/ethereum-cryptography": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/ethereum-cryptography/-/ethereum-cryptography-0.1.3.tgz", - "integrity": "sha512-w8/4x1SGGzc+tO97TASLja6SLd3fRIK2tLVcV2Gx4IB21hE19atll5Cq9o3d0ZmAYC/8aw0ipieTSiekAea4SQ==", - "license": "MIT", - "dependencies": { - "@types/pbkdf2": "^3.0.0", - "@types/secp256k1": "^4.0.1", - "blakejs": "^1.1.0", - "browserify-aes": "^1.2.0", - "bs58check": "^2.1.2", - "create-hash": "^1.2.0", - "create-hmac": "^1.1.7", - "hash.js": "^1.1.7", - "keccak": "^3.0.0", - "pbkdf2": "^3.0.17", - "randombytes": "^2.1.0", - "safe-buffer": "^5.1.2", - "scrypt-js": "^3.0.0", - "secp256k1": "^4.0.1", - "setimmediate": "^1.0.5" - } - }, - "node_modules/ethereumjs-util/node_modules/node-addon-api": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-2.0.2.tgz", - "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==", - "license": "MIT" - }, - "node_modules/ethereumjs-util/node_modules/secp256k1": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-4.0.3.tgz", - "integrity": "sha512-NLZVf+ROMxwtEj3Xa562qgv2BK5e2WNmXPiOdVIPLgs6lyTzMvBq0aWTYMI5XCP9jZMVKOcqZLw/Wc4vDkuxhA==", - "hasInstallScript": true, - "license": "MIT", - "dependencies": { - "elliptic": "^6.5.4", - "node-addon-api": "^2.0.0", - "node-gyp-build": "^4.2.0" - }, - "engines": { - "node": ">=10.0.0" - } - }, "node_modules/ethers": { "version": "5.7.2", "resolved": "https://registry.npmjs.org/ethers/-/ethers-5.7.2.tgz", @@ -10196,7 +9989,6 @@ } ], "license": "MIT", - "peer": true, "dependencies": { "@ethersproject/abi": "5.7.0", "@ethersproject/abstract-provider": "5.7.0", @@ -10256,6 +10048,7 @@ }, "node_modules/evp_bytestokey": { "version": "1.0.3", + "dev": true, "license": "MIT", "dependencies": { "md5.js": "^1.3.4", @@ -11988,8 +11781,7 @@ "version": "0.8.0", "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==", - "license": "MIT", - "peer": true + "license": "MIT" }, "node_modules/js-tiktoken": { "version": "1.0.12", @@ -13036,6 +12828,7 @@ }, "node_modules/md5.js": { "version": "1.3.5", + "dev": true, "license": "MIT", "dependencies": { "hash-base": "^3.0.0", @@ -13045,6 +12838,7 @@ }, "node_modules/md5.js/node_modules/hash-base": { "version": "3.1.0", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.4", @@ -14554,6 +14348,7 @@ }, "node_modules/pbkdf2": { "version": "3.1.2", + "dev": true, "license": "MIT", "dependencies": { "create-hash": "^1.1.2", @@ -15300,6 +15095,7 @@ }, "node_modules/randombytes": { "version": "2.1.0", + "dev": true, "license": "MIT", "dependencies": { "safe-buffer": "^5.1.0" @@ -15774,6 +15570,7 @@ }, "node_modules/ripemd160": { "version": "2.0.2", + "dev": true, "license": "MIT", "dependencies": { "hash-base": "^3.0.0", @@ -15782,6 +15579,7 @@ }, "node_modules/ripemd160/node_modules/hash-base": { "version": "3.1.0", + "dev": true, "license": "MIT", "dependencies": { "inherits": "^2.0.4", @@ -15792,24 +15590,6 @@ "node": ">=4" } }, - "node_modules/rlp": { - "version": "2.2.7", - "resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.7.tgz", - "integrity": "sha512-d5gdPmgQ0Z+AklL2NVXr/IoSjNZFfTVvQWzL/AM2AOcSzYP2xjlb0AC8YyCLc41MSNf6P6QVtjgPdmVtzb+4lQ==", - "license": "MPL-2.0", - "dependencies": { - "bn.js": "^5.2.0" - }, - "bin": { - "rlp": "bin/rlp" - } - }, - "node_modules/rlp/node_modules/bn.js": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz", - "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==", - "license": "MIT" - }, "node_modules/rollup": { "version": "3.29.4", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", @@ -16948,12 +16728,6 @@ "dev": true, "license": "MIT" }, - "node_modules/tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", - "license": "Unlicense" - }, "node_modules/type-check": { "version": "0.4.0", "dev": true, diff --git a/package.json b/package.json index a2e7e56..b390862 100644 --- a/package.json +++ b/package.json @@ -24,10 +24,12 @@ "build": "quasar build" }, "dependencies": { + "@aleph-sdk/base": "file:../aleph-sdk-ts/packages/base", "@aleph-sdk/client": "^1.0.6", - "@aleph-sdk/ethereum": "file:../aleph-sdk-ts/packages/ethereum/aleph-sdk-ethereum-1.0.3.tgz", - "@aleph-sdk/evm": "file:../aleph-sdk-ts/packages/evm/aleph-sdk-evm-1.0.4.tgz", - "@aleph-sdk/message": "^1.0.7", + "@aleph-sdk/core": "file:../aleph-sdk-ts/packages/core", + "@aleph-sdk/ethereum": "file:../aleph-sdk-ts/packages/ethereum", + "@aleph-sdk/evm": "file:../aleph-sdk-ts/packages/evm", + "@aleph-sdk/message": "file:../aleph-sdk-ts/packages/message", "@libertai/libertai-js": "0.0.10-beta", "@quasar/extras": "^1.16.12", "@tanstack/vue-query": "^5.51.21", @@ -37,6 +39,7 @@ "dompurify": "^3.1.6", "dotenv": "^16.4.5", "eciesjs": "^0.4.7", + "ethers": "^5.7.2", "filesize": "^10.1.4", "highlight.js": "^11.10.0", "langchain": "^0.2.13", diff --git a/src/utils/aleph-persistent-storage.ts b/src/utils/aleph-persistent-storage.ts index 2170772..b34fdc8 100644 --- a/src/utils/aleph-persistent-storage.ts +++ b/src/utils/aleph-persistent-storage.ts @@ -1,10 +1,10 @@ import { AuthenticatedAlephHttpClient } from '@aleph-sdk/client'; -import { ETHAccount, getAccountFromProvider, importAccountFromPrivateKey } from '@aleph-sdk/ethereum'; +import { BaseAccount, getAccountFromProvider, importAccountFromPrivateKey } from '@aleph-sdk/base'; import web3 from 'web3'; import { ItemType } from '@aleph-sdk/message'; -import { type Config, getClient, signMessage } from '@wagmi/core'; +import { type Config, getConnectorClient, signMessage } from '@wagmi/core'; import { config } from 'src/config/wagmi'; -import type { Chain, Client, Transport } from 'viem'; +import type { Account, Chain, Client, Transport } from 'viem'; import { SignMessageReturnType } from 'viem'; import { KnowledgeBase, @@ -25,33 +25,28 @@ const LIBERTAI_SETTINGS_KEY = `${LIBERTAI_CHANNEL}-settings`; const LIBERTAI_KNOWLEDGE_BASE_IDENTIFIERS_KEY = `${LIBERTAI_CHANNEL}-knowledge-base-identifiers-test-12`; const LIBERTAI_KNOWLEDGE_BASE_POST_TYPE = `${LIBERTAI_CHANNEL}-knowledge-base-test-12`; -export function clientToProvider(client: Client) { - const { chain, transport } = client; +export function clientToSigner(client: Client) { + const { account, chain, transport } = client; const network = { chainId: chain.id, name: chain.name, ensAddress: chain.contracts?.ensRegistry?.address, }; - if (transport.type === 'fallback') - return new providers.FallbackProvider( - (transport.transports as ReturnType[]).map( - ({ value }) => new providers.JsonRpcProvider(value?.url, network), - ), - ); - return new providers.JsonRpcProvider(transport.url, network); + const provider = new providers.Web3Provider(transport, network); + const signer = provider.getSigner(account.address); + return signer; } -/** Action to convert a viem Public Client to an ethers.js Provider. */ -export function getEthersProvider(config: Config, { chainId }: { chainId?: number } = {}) { - const client = getClient(config, { chainId }); - if (!client) return; - return clientToProvider(client); +/** Action to convert a Viem Client to an ethers.js Signer. */ +export async function getEthersSigner(config: Config, { chainId }: { chainId?: number } = {}) { + const client = await getConnectorClient(config, { chainId }); + return clientToSigner(client); } export class AlephPersistentStorage { constructor( /* eslint-disable-next-line no-unused-vars */ - private account: ETHAccount, + private account: BaseAccount, /* eslint-disable-next-line no-unused-vars */ private subAccountClient: AuthenticatedAlephHttpClient, // eslint-disable-next-line no-unused-vars @@ -72,9 +67,10 @@ export class AlephPersistentStorage { const encryptionPrivateKey = PrivateKey.fromHex(privateKey); const subAccount = importAccountFromPrivateKey(privateKey); - const provider = getEthersProvider(config); + const signer = await getEthersSigner(config); + const web3Provider = signer.provider; - const account = await getAccountFromProvider(provider as unknown as any); + const account = await getAccountFromProvider(web3Provider as unknown as any); const accountClient = new AuthenticatedAlephHttpClient(account, process.env.ALEPH_API_URL); const subAccountClient = new AuthenticatedAlephHttpClient(subAccount, process.env.ALEPH_API_URL); @@ -84,8 +80,8 @@ export class AlephPersistentStorage { } static async getSecurityPermission( - account: ETHAccount, - subAccount: ETHAccount, + account: BaseAccount, + subAccount: BaseAccount, accountClient: AuthenticatedAlephHttpClient, ) { try {