From d828c314a27771a7a1be898c9eaaadfb0cf3d480 Mon Sep 17 00:00:00 2001 From: 170210 <85928898+170210@users.noreply.github.com> Date: Thu, 14 Dec 2023 15:25:59 +0900 Subject: [PATCH 1/3] feat: add coinType feature (#8) * feat: add coinType feature Signed-off-by: 170210 * chore: add cosmjs/crypto dependency Signed-off-by: 170210 * style: format Signed-off-by: 170210 * fixup: fix the description of coinType Signed-off-by: 170210 * Update package.nls.json Co-authored-by: Shogo Hyodo * fixup: fix for comment Signed-off-by: 170210 * fix: delete unnecessary line Co-authored-by: Shogo Hyodo --------- Signed-off-by: 170210 Co-authored-by: Shogo Hyodo --- package-lock.json | 299 ++++++++++++++++++++++++-- package.json | 8 + package.nls.json | 1 + src/helpers/Cosmwasm/API.ts | 2 +- src/helpers/Cosmwasm/SmartExecutor.ts | 2 +- src/helpers/Sign/wrapwallet.ts | 20 +- src/helpers/Workspace.ts | 1 + src/models/Account.ts | 4 +- src/views/SignProvider.ts | 2 +- 9 files changed, 309 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index 08852cf..6d72408 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@cosmjs/amino": "^0.28.4", "@cosmjs/cosmwasm-stargate": "^0.28.4", + "@cosmjs/crypto": "^0.31.0", "@cosmjs/faucet-client": "^0.28.4", "@cosmjs/launchpad": "^0.27.1", "@cosmjs/math": "^0.30.1", @@ -653,6 +654,20 @@ "@cosmjs/utils": "0.28.13" } }, + "node_modules/@cosmjs/amino/node_modules/@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "dependencies": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "node_modules/@cosmjs/amino/node_modules/@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -679,15 +694,7 @@ "pako": "^2.0.2" } }, - "node_modules/@cosmjs/cosmwasm-stargate/node_modules/@cosmjs/math": { - "version": "0.28.13", - "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", - "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", - "dependencies": { - "bn.js": "^5.2.0" - } - }, - "node_modules/@cosmjs/crypto": { + "node_modules/@cosmjs/cosmwasm-stargate/node_modules/@cosmjs/crypto": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", @@ -701,7 +708,7 @@ "libsodium-wrappers": "^0.7.6" } }, - "node_modules/@cosmjs/crypto/node_modules/@cosmjs/math": { + "node_modules/@cosmjs/cosmwasm-stargate/node_modules/@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", @@ -709,6 +716,43 @@ "bn.js": "^5.2.0" } }, + "node_modules/@cosmjs/crypto": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.31.3.tgz", + "integrity": "sha512-vRbvM9ZKR2017TO73dtJ50KxoGcFzKtKI7C8iO302BQ5p+DuB+AirUg1952UpSoLfv5ki9O416MFANNg8UN/EQ==", + "dependencies": { + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/utils": "^0.31.3", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.4", + "libsodium-wrappers-sumo": "^0.7.11" + } + }, + "node_modules/@cosmjs/crypto/node_modules/@cosmjs/encoding": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.31.3.tgz", + "integrity": "sha512-6IRtG0fiVYwyP7n+8e54uTx2pLYijO48V3t9TLiROERm5aUAIzIlz6Wp0NYaI5he9nh1lcEGJ1lkquVKFw3sUg==", + "dependencies": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, + "node_modules/@cosmjs/crypto/node_modules/@cosmjs/math": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.31.3.tgz", + "integrity": "sha512-kZ2C6glA5HDb9hLz1WrftAjqdTBb3fWQsRR+Us2HsjAYdeE6M3VdXMsYCP5M3yiihal1WDwAY2U7HmfJw7Uh4A==", + "dependencies": { + "bn.js": "^5.2.0" + } + }, + "node_modules/@cosmjs/crypto/node_modules/@cosmjs/utils": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.31.3.tgz", + "integrity": "sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA==" + }, "node_modules/@cosmjs/encoding": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.28.13.tgz", @@ -823,6 +867,20 @@ "long": "^4.0.0" } }, + "node_modules/@cosmjs/proto-signing/node_modules/@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "dependencies": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "node_modules/@cosmjs/proto-signing/node_modules/@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -894,6 +952,20 @@ "xstream": "^11.14.0" } }, + "node_modules/@cosmjs/tendermint-rpc/node_modules/@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "dependencies": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "node_modules/@cosmjs/tendermint-rpc/node_modules/@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -2166,6 +2238,28 @@ "@babel/plugin-transform-react-jsx": "7.19.0" } }, + "node_modules/@terran-one/cosmwasm-vm-js/node_modules/@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "dependencies": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, + "node_modules/@terran-one/cosmwasm-vm-js/node_modules/@cosmjs/math": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", + "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", + "dependencies": { + "bn.js": "^5.2.0" + } + }, "node_modules/@terran-one/cosmwasm-vm-js/node_modules/bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", @@ -2192,6 +2286,28 @@ "node": ">=18" } }, + "node_modules/@terran-one/cw-simulate/node_modules/@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "dependencies": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, + "node_modules/@terran-one/cw-simulate/node_modules/@cosmjs/math": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", + "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", + "dependencies": { + "bn.js": "^5.2.0" + } + }, "node_modules/@terran-one/cw-simulate/node_modules/tslib": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", @@ -5083,6 +5199,11 @@ "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.10.tgz", "integrity": "sha512-eY+z7hDrDKxkAK+QKZVNv92A5KYkxfvIshtBJkmg5TSiCnYqZP3i9OO9whE79Pwgm4jGaoHgkM4ao/b9Cyu4zQ==" }, + "node_modules/libsodium-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", + "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==" + }, "node_modules/libsodium-wrappers": { "version": "0.7.10", "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.10.tgz", @@ -5091,6 +5212,14 @@ "libsodium": "^0.7.0" } }, + "node_modules/libsodium-wrappers-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", + "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", + "dependencies": { + "libsodium-sumo": "^0.7.13" + } + }, "node_modules/listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", @@ -7891,6 +8020,20 @@ "@cosmjs/utils": "0.28.13" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -7919,6 +8062,20 @@ "pako": "^2.0.2" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -7930,26 +8087,41 @@ } }, "@cosmjs/crypto": { - "version": "0.28.13", - "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", - "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.31.3.tgz", + "integrity": "sha512-vRbvM9ZKR2017TO73dtJ50KxoGcFzKtKI7C8iO302BQ5p+DuB+AirUg1952UpSoLfv5ki9O416MFANNg8UN/EQ==", "requires": { - "@cosmjs/encoding": "0.28.13", - "@cosmjs/math": "0.28.13", - "@cosmjs/utils": "0.28.13", + "@cosmjs/encoding": "^0.31.3", + "@cosmjs/math": "^0.31.3", + "@cosmjs/utils": "^0.31.3", "@noble/hashes": "^1", "bn.js": "^5.2.0", - "elliptic": "^6.5.3", - "libsodium-wrappers": "^0.7.6" + "elliptic": "^6.5.4", + "libsodium-wrappers-sumo": "^0.7.11" }, "dependencies": { + "@cosmjs/encoding": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.31.3.tgz", + "integrity": "sha512-6IRtG0fiVYwyP7n+8e54uTx2pLYijO48V3t9TLiROERm5aUAIzIlz6Wp0NYaI5he9nh1lcEGJ1lkquVKFw3sUg==", + "requires": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, "@cosmjs/math": { - "version": "0.28.13", - "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", - "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.31.3.tgz", + "integrity": "sha512-kZ2C6glA5HDb9hLz1WrftAjqdTBb3fWQsRR+Us2HsjAYdeE6M3VdXMsYCP5M3yiihal1WDwAY2U7HmfJw7Uh4A==", "requires": { "bn.js": "^5.2.0" } + }, + "@cosmjs/utils": { + "version": "0.31.3", + "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.31.3.tgz", + "integrity": "sha512-VBhAgzrrYdIe0O5IbKRqwszbQa7ZyQLx9nEQuHQ3HUplQW7P44COG/ye2n6AzCudtqxmwdX7nyX8ta1J07GoqA==" } } }, @@ -8069,6 +8241,20 @@ "long": "^4.0.0" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -8144,6 +8330,20 @@ "xstream": "^11.14.0" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, "@cosmjs/math": { "version": "0.28.13", "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", @@ -8965,6 +9165,28 @@ "util": "^0.12.4" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, + "@cosmjs/math": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", + "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", + "requires": { + "bn.js": "^5.2.0" + } + }, "bech32": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/bech32/-/bech32-2.0.0.tgz", @@ -8990,6 +9212,28 @@ "tslib": "^2.4.0" }, "dependencies": { + "@cosmjs/crypto": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.28.13.tgz", + "integrity": "sha512-ynKfM0q/tMBQMHJby6ad8lR3gkgBKaelQhIsCZTjClsnuC7oYT9y3ThSZCUWr7Pa9h0J8ahU2YV2oFWFVWJQzQ==", + "requires": { + "@cosmjs/encoding": "0.28.13", + "@cosmjs/math": "0.28.13", + "@cosmjs/utils": "0.28.13", + "@noble/hashes": "^1", + "bn.js": "^5.2.0", + "elliptic": "^6.5.3", + "libsodium-wrappers": "^0.7.6" + } + }, + "@cosmjs/math": { + "version": "0.28.13", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.28.13.tgz", + "integrity": "sha512-PDpL8W/kbyeWi0mQ2OruyqE8ZUAdxPs1xCbDX3WXJwy2oU+X2UTbkuweJHVpS9CIqmZulBoWQAmlf6t6zr1N/g==", + "requires": { + "bn.js": "^5.2.0" + } + }, "tslib": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", @@ -11173,6 +11417,11 @@ "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.10.tgz", "integrity": "sha512-eY+z7hDrDKxkAK+QKZVNv92A5KYkxfvIshtBJkmg5TSiCnYqZP3i9OO9whE79Pwgm4jGaoHgkM4ao/b9Cyu4zQ==" }, + "libsodium-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-sumo/-/libsodium-sumo-0.7.13.tgz", + "integrity": "sha512-zTGdLu4b9zSNLfovImpBCbdAA4xkpkZbMnSQjP8HShyOutnGjRHmSOKlsylh1okao6QhLiz7nG98EGn+04cZjQ==" + }, "libsodium-wrappers": { "version": "0.7.10", "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.10.tgz", @@ -11181,6 +11430,14 @@ "libsodium": "^0.7.0" } }, + "libsodium-wrappers-sumo": { + "version": "0.7.13", + "resolved": "https://registry.npmjs.org/libsodium-wrappers-sumo/-/libsodium-wrappers-sumo-0.7.13.tgz", + "integrity": "sha512-lz4YdplzDRh6AhnLGF2Dj2IUj94xRN6Bh8T0HLNwzYGwPehQJX6c7iYVrFUPZ3QqxE0bqC+K0IIqqZJYWumwSQ==", + "requires": { + "libsodium-sumo": "^0.7.13" + } + }, "listenercount": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/listenercount/-/listenercount-1.0.1.tgz", diff --git a/package.json b/package.json index fb0b9f5..863d672 100644 --- a/package.json +++ b/package.json @@ -315,6 +315,11 @@ "%cosmywasmy.chains.items.signType.ethsecp256k1.desc%" ] }, + "coinType": { + "type": "string", + "default": "118", + "description": "%cosmywasmy.chains.items.coinType.desc%" + }, "chainDenom": { "type": "string", "description": "%cosmywasmy.chains.items.chainDenom.desc%" @@ -483,6 +488,7 @@ "rpcEndpoint": "http://localhost:26657", "defaultGasPrice": "0.015", "chainDenom": "cony", + "coinType": "438", "faucetEndpoint": "http://localhost:8081" }, { @@ -493,6 +499,7 @@ "rpcEndpoint": "https://ebony-rpc.finschia.io/", "defaultGasPrice": "0.015", "chainDenom": "tcony", + "coinType": "438", "accountExplorerLink": "https://explorer.blockchain.line.me/ebony/address/${accountAddress}", "txExplorerLink": "https://explorer.blockchain.line.me/ebony/transaction/${txHash}", "faucetEndpoint": "https://faucet-ebonynw.line-apps.com" @@ -1237,6 +1244,7 @@ "@cosmjs/launchpad": "^0.27.1", "@cosmjs/math": "^0.30.1", "@cosmjs/proto-signing": "^0.28.4", + "@cosmjs/crypto": "^0.31.0", "@terran-one/cw-simulate": "^2.8.0", "@vscode/l10n": "^0.0.10", "@vscode/l10n-dev": "^0.0.24", diff --git a/package.nls.json b/package.nls.json index 30e2789..09c13f9 100644 --- a/package.nls.json +++ b/package.nls.json @@ -52,6 +52,7 @@ "cosmywasmy.chains.items.signType.desc": "The signature algorithm when signing transactions, `ethsecp256k1` or `tmsecp256k1`, default `tmsecp256k1`", "cosmywasmy.chains.items.signType.tmsecp256k1.desc": "Used for Cosmos/Tendermint chains signing", "cosmywasmy.chains.items.signType.ethsecp256k1.desc": "Used for Ethereum/EVM chains signing", + "cosmywasmy.chains.items.coinType.desc": "Used for distinguishing between different cryptocurrencies in hierarchical deterministic wallets, default `118`", "cosmywasmy.chains.items.faucetEndpoint.desc": "Faucet address and port to request funds", "cosmywasmy.chains.items.accountExplorerLink.desc": "Block explorer url which includes '${accountAddress}' text to generate account url", "cosmywasmy.chains.items.txExplorerLink.desc": "Block explorer url which includes '${txHash}' text to generate tx url", diff --git a/src/helpers/Cosmwasm/API.ts b/src/helpers/Cosmwasm/API.ts index 4cd7983..ac55fd6 100644 --- a/src/helpers/Cosmwasm/API.ts +++ b/src/helpers/Cosmwasm/API.ts @@ -68,7 +68,7 @@ export class Cosmwasm { public static async GetSigningClient(): Promise { const account = Workspace.GetSelectedAccount(); - let signer = await WrapWallet.fromMnemonic(global.workspaceChain.signType, account.mnemonic, { + let signer = await WrapWallet.fromMnemonic(global.workspaceChain.signType, global.workspaceChain.coinType, account.mnemonic, { prefix: global.workspaceChain.addressPrefix, }); let gasDenom = global.workspaceChain.chainGasDenom; diff --git a/src/helpers/Cosmwasm/SmartExecutor.ts b/src/helpers/Cosmwasm/SmartExecutor.ts index 1699241..5e453e9 100644 --- a/src/helpers/Cosmwasm/SmartExecutor.ts +++ b/src/helpers/Cosmwasm/SmartExecutor.ts @@ -11,7 +11,7 @@ export class SmartExecutor { private client: SigningCosmWasmClient; public async SetupAccount(mnemonic: string, addressPrefix: string) { - this.wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, mnemonic, { + this.wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, global.workspaceChain.coinType, mnemonic, { prefix: addressPrefix, }); const accounts = await this.wallet.getAccounts(); diff --git a/src/helpers/Sign/wrapwallet.ts b/src/helpers/Sign/wrapwallet.ts index cfcf3c5..5d9a7e2 100644 --- a/src/helpers/Sign/wrapwallet.ts +++ b/src/helpers/Sign/wrapwallet.ts @@ -2,7 +2,8 @@ import { EthSecp256k1HdWallet } from './ethsecp256k1hdwallet'; import { DirectSecp256k1HdWallet } from '@cosmjs/proto-signing'; import { Secp256k1HdWallet } from "@cosmjs/launchpad"; -import {DirectSecp256k1HdWalletOptions} from "@cosmjs/proto-signing/build/directsecp256k1hdwallet" +import { DirectSecp256k1HdWalletOptions } from "@cosmjs/proto-signing/build/directsecp256k1hdwallet"; +import { HdPath,Slip10RawIndex } from "@cosmjs/crypto"; export const SIGN_TYPE = { ethsecp256k1: 'ethsecp256k1', @@ -11,15 +12,24 @@ export const SIGN_TYPE = { export class WrapWallet { private signType; + private hdPath:HdPath; public mnemonic; - constructor(type, mnemonic, options) { + constructor(type, coinType, mnemonic, options) { this.mnemonic = mnemonic; this.signType = WrapWallet.isEthSecp256k1(type) ? SIGN_TYPE.ethsecp256k1 : SIGN_TYPE.tmsecp256k1; + const currentCoinType = coinType || "118"; + this.hdPath = [ + Slip10RawIndex.hardened(44), + Slip10RawIndex.hardened(Number(currentCoinType)), + Slip10RawIndex.hardened(0), + Slip10RawIndex.normal(0), + Slip10RawIndex.normal(0), + ]; } - static async fromMnemonic(type: string, mnemonic: string, options?: Partial): Promise{ - return new WrapWallet(type, mnemonic, { + static async fromMnemonic(type: string, coinType: string, mnemonic: string, options?: Partial): Promise{ + return new WrapWallet(type, coinType, mnemonic, { ...options, }); } @@ -60,10 +70,12 @@ export class WrapWallet { async getWallet(){ if (this.signType !== SIGN_TYPE.ethsecp256k1){ return DirectSecp256k1HdWallet.fromMnemonic(this.mnemonic, { + hdPaths: [this.hdPath], prefix: global.workspaceChain.addressPrefix, },); } return EthSecp256k1HdWallet.fromMnemonic(this.mnemonic, { + hdPaths: [this.hdPath], prefix: global.workspaceChain.addressPrefix, },); } diff --git a/src/helpers/Workspace.ts b/src/helpers/Workspace.ts index c6cbb80..2cb4cc6 100644 --- a/src/helpers/Workspace.ts +++ b/src/helpers/Workspace.ts @@ -136,6 +136,7 @@ export class ChainConfig { chainGasDenom!: string; chainDenomDecimals!: string; signType!: string; + coinType!: string; public Validate() { if (!this) { diff --git a/src/models/Account.ts b/src/models/Account.ts index cf43fe6..1e89042 100644 --- a/src/models/Account.ts +++ b/src/models/Account.ts @@ -23,7 +23,7 @@ export class Account extends vscode.TreeItem { public static async GetAccounts(context: vscode.Memento): Promise { const accountData = this.GetAccountsBasic(context); for (let account of accountData) { - const wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, account.mnemonic, { + const wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, global.workspaceChain.coinType, account.mnemonic, { prefix: global.workspaceChain.addressPrefix }); const accounts = await wallet.getAccounts(); @@ -45,7 +45,7 @@ export class Account extends vscode.TreeItem { public static async AddAccount(context: vscode.Memento, account: Account) { try{ //fix import error mnemonic, failed to load account when restart vscode - await (await WrapWallet.fromMnemonic(global.workspaceChain.signType, account.mnemonic, { + await (await WrapWallet.fromMnemonic(global.workspaceChain.signType, global.workspaceChain.coinType, account.mnemonic, { prefix: global.workspaceChain.addressPrefix })).getAccounts(); diff --git a/src/views/SignProvider.ts b/src/views/SignProvider.ts index 65ae7aa..5422b39 100644 --- a/src/views/SignProvider.ts +++ b/src/views/SignProvider.ts @@ -36,7 +36,7 @@ export class SignProvider implements vscode.WebviewViewProvider { return; } try { - let wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, account.mnemonic, { + let wallet = await WrapWallet.fromMnemonic(global.workspaceChain.signType, global.workspaceChain.coinType, account.mnemonic, { prefix: global.workspaceChain.addressPrefix, }); const signDoc = this.makeSignDoc(account.address, data.value); From ba3adda76b21218de4764dbddc4446ef9a8a3805 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Tue, 26 Dec 2023 12:30:24 +0900 Subject: [PATCH 2/3] Update README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 059f61f..57b0242 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,7 @@ The structure of the expected setting for `cosmywasamy.chains`: "chainGasDenom": "uosmo", // The micro denom used to pay for gas "chainDenomDecimals": "6", // Default decimals to display account balance "signType": "tmsecp256k1", // Which signing scheme to use? tmsecp256k1 or ethsecp256k1 + "coinType": "118", // Coin type registered for the chain "chainDenom": "uosmo", // the micro denom used to track account balance "faucetEndpoint": "http://localhost:8000", //Faucet address and port to request funds "accountExplorerLink": "https://testnet.mintscan.io/osmosis-testnet/account/${accountAddress}", //Block explorer url which includes '${accountAddress}' text to generate account url From 02d4471a8d804bf8b2849ebdcc02385d9666f106 Mon Sep 17 00:00:00 2001 From: Shogo Hyodo Date: Tue, 26 Dec 2023 13:38:24 +0900 Subject: [PATCH 3/3] Update CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c86ab4..58c75fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ All notable changes to the Cosmy Wasmy extension will be documented in this file - For localnet chains, all contracts on the chain can be imported in single click. - Support [Finschia testnet](https://www.finschia.io/) - Finschia aims to become the world’s No. 1 blockchain ecosystem, leading the popularization of Web3 and securing over 1 billion users. Added configurations for localnet as well as testnet chains +- Support `coinType` - Can use it when generate account, default `118`. ### Changed