From bf2764b6c65ce93daa29f3c74cfaea60e8b81904 Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 28 Feb 2022 15:36:47 +0200 Subject: [PATCH 1/7] Use mnemonic-keystore and cosmos-wallet --- wallets/react-wallet-v2/package.json | 10 +- .../react-wallet-v2/src/utils/CosmosUtil.ts | 52 ++-- .../src/utils/CosmosWalletUtil.ts | 22 +- wallets/react-wallet-v2/yarn.lock | 280 +++++++++++++++--- 4 files changed, 282 insertions(+), 82 deletions(-) diff --git a/wallets/react-wallet-v2/package.json b/wallets/react-wallet-v2/package.json index 6a367ee..7b36952 100644 --- a/wallets/react-wallet-v2/package.json +++ b/wallets/react-wallet-v2/package.json @@ -12,24 +12,22 @@ "@walletconnect/utils": "2.0.0-beta.22", "@json-rpc-tools/utils": "1.7.6", "@nextui-org/react": "1.0.2-beta.4", - "bip39": "3.0.4", - "bip32": "3.0.1", - "bech32": "2.0.0", - "tiny-secp256k1": "1.1.6", + "mnemonic-keyring": "1.4.0", + "cosmos-wallet": "1.1.0", "next": "12.1.0", "react": "17.0.2", "react-dom": "17.0.2", "react-qr-reader-es6": "2.2.1-2", "framer-motion": "6.2.8", "ethers": "5.5.4", - "valtio": "1.3.0", + "valtio": "1.3.1", "react-code-blocks": "0.0.9-0" }, "devDependencies": { "@walletconnect/types": "2.0.0-beta.22", "@types/node": "17.0.21", "@types/react": "17.0.39", - "eslint": "8.9.0", + "eslint": "8.10.0", "eslint-config-next": "12.1.0", "eslint-config-prettier": "8.4.0", "prettier": "2.5.1", diff --git a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts index 895d132..d320a42 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts @@ -1,53 +1,41 @@ -import { bech32 } from 'bech32' -import BIP32Factory from 'bip32' -import * as bip39 from 'bip39' -// @ts-expect-error -import * as ecc from 'tiny-secp256k1' +import CosmosWallet from 'cosmos-wallet' +import MnemonicKeyring from 'mnemonic-keyring' /** - * Helpers + * Constants */ -const bip32 = BIP32Factory(ecc) +const DEFAULT_PATH = "m/44'/118'/0'/0/0" /** * Types */ -interface IConstructor { - url?: string - prefix?: string - chainId?: string - path?: string +interface IInitArguments { mnemonic?: string + path?: string } /** * Utility */ export class Cosmos { - url: string - prefix: string - chainId: string - path: string - mnemonic: string + keyring: MnemonicKeyring + wallet: CosmosWallet + derivationPath: string - constructor({ url, prefix, chainId, path, mnemonic }: IConstructor) { - this.url = url ?? 'https://api.cosmos.network' - this.prefix = prefix ?? 'cosmos' - this.chainId = chainId ?? 'cosmoshub-4' - this.path = path ?? "m/44'/118'/0'/0/0" - this.mnemonic = mnemonic ?? this.generateMnemonic() + constructor(keyring: MnemonicKeyring, wallet: CosmosWallet, derivationPath: string) { + this.wallet = wallet + this.keyring = keyring + this.derivationPath = derivationPath } - generateMnemonic(strength = 128) { - return bip39.generateMnemonic(strength) + static async init({ mnemonic, path }: IInitArguments) { + const keyring = await MnemonicKeyring.init({ mnemonic }) + const derivationPath = path ?? DEFAULT_PATH + const wallet = await CosmosWallet.init(keyring.getPrivateKey(derivationPath)) + return new Cosmos(keyring, wallet, derivationPath) } - async getAddress() { - const seed = await bip39.mnemonicToSeed(this.mnemonic) - const node = bip32.fromSeed(seed) - const child = node.derivePath(this.path) - const words = bech32.toWords(child.identifier) - - return bech32.encode(this.prefix, words) + public getPublicKey() { + return this.keyring.getPublicKey(this.derivationPath) } } diff --git a/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts index 1085710..bec6e32 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts @@ -15,17 +15,21 @@ export async function createOrRestoreCosmosWallet() { const mnemonic = localStorage.getItem('WALLET_MNEMONIC') if (mnemonic) { - wallet1 = new Cosmos({ mnemonic, path: "m/44'/118'/0'/0/0" }) - wallet2 = new Cosmos({ mnemonic, path: "m/44'/118'/0'/0/1" }) - address1 = await wallet1.getAddress() - address2 = await wallet2.getAddress() + wallet1 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/0" }) + wallet2 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/1" }) + const accounts1 = await wallet1.wallet.getAccounts() + const accounts2 = await wallet2.wallet.getAccounts() + address1 = accounts1[0].address + address2 = accounts2[0].address } else { - wallet1 = new Cosmos({ path: "m/44'/118'/0'/0/0" }) - const mnemonic = wallet1.mnemonic + wallet1 = await Cosmos.init({ path: "m/44'/118'/0'/0/0" }) + const mnemonic = wallet1.keyring.mnemonic // We can reuse same mnemonic for both wallets - wallet2 = new Cosmos({ mnemonic, path: "m/44'/118'/0'/0/1" }) - address1 = await wallet1.getAddress() - address2 = await wallet2.getAddress() + wallet2 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/1" }) + const accounts1 = await wallet1.wallet.getAccounts() + const accounts2 = await wallet2.wallet.getAccounts() + address1 = accounts1[0].address + address2 = accounts2[0].address // Don't store mnemonic in local storage in a production project! localStorage.setItem('WALLET_MNEMONIC', mnemonic) } diff --git a/wallets/react-wallet-v2/yarn.lock b/wallets/react-wallet-v2/yarn.lock index f06e6b1..645bf4f 100644 --- a/wallets/react-wallet-v2/yarn.lock +++ b/wallets/react-wallet-v2/yarn.lock @@ -143,6 +143,62 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" +"@cosmjs/amino@^0.25.4", "@cosmjs/amino@^0.25.6": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.25.6.tgz#cdf9632253bfab7b1d2ef967124953d7bf16351f" + integrity sha512-9dXN2W7LHjDtJUGNsQ9ok0DfxeN3ca/TXnxCR3Ikh/5YqBqxI8Gel1J9PQO9L6EheYyh045Wff4bsMaLjyEeqQ== + dependencies: + "@cosmjs/crypto" "^0.25.6" + "@cosmjs/encoding" "^0.25.6" + "@cosmjs/math" "^0.25.6" + "@cosmjs/utils" "^0.25.6" + +"@cosmjs/crypto@^0.25.6": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.25.6.tgz#695d2d0d2195bdbdd5825d415385646244900bbb" + integrity sha512-ec+YcQLrg2ibcxtNrh4FqQnG9kG9IE/Aik2NH6+OXQdFU/qFuBTxSFcKDgzzBOChwlkXwydllM9Jjbp+dgIzRw== + dependencies: + "@cosmjs/encoding" "^0.25.6" + "@cosmjs/math" "^0.25.6" + "@cosmjs/utils" "^0.25.6" + bip39 "^3.0.2" + bn.js "^4.11.8" + elliptic "^6.5.3" + js-sha3 "^0.8.0" + libsodium-wrappers "^0.7.6" + ripemd160 "^2.0.2" + sha.js "^2.4.11" + +"@cosmjs/encoding@^0.25.6": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.25.6.tgz#da741a33eaf063a6d3611d7d68db5ca3938e0ef5" + integrity sha512-0imUOB8XkUstI216uznPaX1hqgvLQ2Xso3zJj5IV5oJuNlsfDj9nt/iQxXWbJuettc6gvrFfpf+Vw2vBZSZ75g== + dependencies: + base64-js "^1.3.0" + bech32 "^1.1.4" + readonly-date "^1.0.0" + +"@cosmjs/math@^0.25.6": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.25.6.tgz#25c7b106aaded889a5b80784693caa9e654b0c28" + integrity sha512-Fmyc9FJ8KMU34n7rdapMJrT/8rx5WhMw2F7WLBu7AVLcBh0yWsXIcMSJCoPHTOnMIiABjXsnrrwEaLrOOBfu6A== + dependencies: + bn.js "^4.11.8" + +"@cosmjs/proto-signing@^0.25.4": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.25.6.tgz#d9fc57b8e0a46cda97e192bd0435157b24949ff8" + integrity sha512-JpQ+Vnv9s6i3x8f3Jo0lJZ3VMnj3R5sMgX+8ti1LtB7qEYRR85qbDrEG9hDGIKqJJabvrAuCHnO6hYi0vJEJHA== + dependencies: + "@cosmjs/amino" "^0.25.6" + long "^4.0.0" + protobufjs "~6.10.2" + +"@cosmjs/utils@^0.25.6": + version "0.25.6" + resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.25.6.tgz#934d9a967180baa66163847616a74358732227ca" + integrity sha512-ofOYiuxVKNo238vCPPlaDzqPXy2AQ/5/nashBo5rvPZJkxt9LciGfUEQWPCOb1BIJDNx2Dzu0z4XCf/dwzl0Dg== + "@emotion/is-prop-valid@^0.8.2", "@emotion/is-prop-valid@^0.8.8": version "0.8.8" resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a" @@ -165,10 +221,10 @@ resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== -"@eslint/eslintrc@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.1.0.tgz#583d12dbec5d4f22f333f9669f7d0b7c7815b4d3" - integrity sha512-C1DfL7XX4nPqGd6jcP01W9pVM1HYCuUkFk1432D7F0v3JSlUIeOYn9oCoi3eoLZ+iwBSb29BMFxxny0YrrEZqg== +"@eslint/eslintrc@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-1.2.0.tgz#7ce1547a5c46dfe56e1e45c3c9ed18038c721c6a" + integrity sha512-igm9SjJHNEJRiUnecP/1R5T3wKLEJ7pL6e2P+GUSfCd0dGjPYYZve08uzw8L2J8foVHFz+NGu12JxRcU2gGo6w== dependencies: ajv "^6.12.4" debug "^4.3.2" @@ -659,6 +715,68 @@ resolved "https://registry.yarnpkg.com/@pedrouid/environment/-/environment-1.0.1.tgz#858f0f8a057340e0b250398b75ead77d6f4342ec" integrity sha512-HaW78NszGzRZd9SeoI3JD11JqY+lubnaOx7Pewj5pfjqWXOEATpeKIFb9Z4t2WBUK2iryiXX3lzWwmYWgUL0Ug== +"@pedrouid/iso-random@^1.1.0": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@pedrouid/iso-random/-/iso-random-1.2.1.tgz#55178d9a2e7897b0f630dd1b4be76bc8460242d7" + integrity sha512-C35NqYMmLsg61WDiEup4OwjRhgfZIcK4BL+Qg49xowHUJ+f7/LFZCO+TGuQqoXFAj1beKIOpUN33f0fqV7zneQ== + dependencies: + "@pedrouid/environment" "^1.0.1" + enc-utils "^3.0.0" + randombytes "^2.1.0" + +"@protobufjs/aspromise@^1.1.1", "@protobufjs/aspromise@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/aspromise/-/aspromise-1.1.2.tgz#9b8b0cc663d669a7d8f6f5d0893a14d348f30fbf" + integrity sha1-m4sMxmPWaafY9vXQiToU00jzD78= + +"@protobufjs/base64@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/base64/-/base64-1.1.2.tgz#4c85730e59b9a1f1f349047dbf24296034bb2735" + integrity sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg== + +"@protobufjs/codegen@^2.0.4": + version "2.0.4" + resolved "https://registry.yarnpkg.com/@protobufjs/codegen/-/codegen-2.0.4.tgz#7ef37f0d010fb028ad1ad59722e506d9262815cb" + integrity sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg== + +"@protobufjs/eventemitter@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz#355cbc98bafad5978f9ed095f397621f1d066b70" + integrity sha1-NVy8mLr61ZePntCV85diHx0Ga3A= + +"@protobufjs/fetch@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/fetch/-/fetch-1.1.0.tgz#ba99fb598614af65700c1619ff06d454b0d84c45" + integrity sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU= + dependencies: + "@protobufjs/aspromise" "^1.1.1" + "@protobufjs/inquire" "^1.1.0" + +"@protobufjs/float@^1.0.2": + version "1.0.2" + resolved "https://registry.yarnpkg.com/@protobufjs/float/-/float-1.0.2.tgz#5e9e1abdcb73fc0a7cb8b291df78c8cbd97b87d1" + integrity sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E= + +"@protobufjs/inquire@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/inquire/-/inquire-1.1.0.tgz#ff200e3e7cf2429e2dcafc1140828e8cc638f089" + integrity sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik= + +"@protobufjs/path@^1.1.2": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@protobufjs/path/-/path-1.1.2.tgz#6cc2b20c5c9ad6ad0dccfd21ca7673d8d7fbf68d" + integrity sha1-bMKyDFya1q0NzP0hynZz2Nf79o0= + +"@protobufjs/pool@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/pool/-/pool-1.1.0.tgz#09fd15f2d6d3abfa9b65bc366506d6ad7846ff54" + integrity sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q= + +"@protobufjs/utf8@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@protobufjs/utf8/-/utf8-1.1.0.tgz#a777360b5b39a1a2e5106f8e858f2fd2d060c570" + integrity sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA= + "@react-aria/focus@3.5.0": version "3.5.0" resolved "https://registry.yarnpkg.com/@react-aria/focus/-/focus-3.5.0.tgz#02b85f97d6114af1eccc0902ce40723b626cb7f9" @@ -805,6 +923,11 @@ resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee" integrity sha1-7ihweulOEdK4J7y+UnC86n8+ce4= +"@types/long@^4.0.1": + version "4.0.1" + resolved "https://registry.yarnpkg.com/@types/long/-/long-4.0.1.tgz#459c65fa1867dafe6a8f322c4c51695663cc55e9" + integrity sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== + "@types/node@10.12.18": version "10.12.18" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.12.18.tgz#1d3ca764718915584fcd9f6344621b7672665c67" @@ -820,6 +943,11 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== +"@types/node@^13.7.0": + version "13.13.52" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.13.52.tgz#03c13be70b9031baaed79481c0c0cfb0045e53f7" + integrity sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ== + "@types/prop-types@*": version "15.7.4" resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11" @@ -1229,21 +1357,24 @@ base-x@^3.0.2: dependencies: safe-buffer "^5.0.1" -base64-js@^1.3.1: +base64-js@^1.3.0, base64-js@^1.3.1: version "1.5.1" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -bech32@1.1.4: +bcrypto@^5.4.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/bcrypto/-/bcrypto-5.4.0.tgz#4046f0c44a4b301eff84de593b4f86fce8d91db2" + integrity sha512-KDX2CR29o6ZoqpQndcCxFZAtYA1jDMnXU3jmCfzP44g++Cu7AHHtZN/JbrN/MXAg9SLvtQ8XISG+eVD9zH1+Jg== + dependencies: + bufio "~1.0.7" + loady "~0.0.5" + +bech32@1.1.4, bech32@^1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/bech32/-/bech32-1.1.4.tgz#e38c9f37bf179b8eb16ae3a772b40c356d4832e9" integrity sha512-s0IrSOzLlbvX7yp4WBfPITzpAU8sqQcpsmwXDiKwrG4r491vwCO/XpejasRNl0piBMe/DvP4Tz0mIS/X1DPJBQ== -bech32@2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/bech32/-/bech32-2.0.0.tgz#078d3686535075c8c79709f054b1b226a133b355" - integrity sha512-LcknSilhIGatDAsY1ak2I8VtGaHNhgMSYVxFrGLXv+xLHytaKZKcaUJJUE7qmBr7h33o5YQwP55pMI0xmkpJwg== - better-sqlite3@^7.1.2: version "7.5.0" resolved "https://registry.yarnpkg.com/better-sqlite3/-/better-sqlite3-7.5.0.tgz#2a91cb616453f002096743b0e5b66a7021cd1c63" @@ -1259,19 +1390,20 @@ bindings@^1.3.0, bindings@^1.5.0: dependencies: file-uri-to-path "1.0.0" -bip32@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/bip32/-/bip32-3.0.1.tgz#1d1121469cce6e910e0ec3a5a1990dd62687e2a3" - integrity sha512-Uhpp9aEx3iyiO7CpbNGFxv9WcMIVdGoHG04doQ5Ln0u60uwDah7jUSc3QMV/fSZGm/Oo01/OeAmYevXV+Gz5jQ== +bip32@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/bip32/-/bip32-2.0.6.tgz#6a81d9f98c4cd57d05150c60d8f9e75121635134" + integrity sha512-HpV5OMLLGTjSVblmrtYRfFFKuQB+GArM0+XP8HGWfJ5vxYBqo+DesvJwOdC2WJ3bCkZShGf0QIfoIpeomVzVdA== dependencies: "@types/node" "10.12.18" bs58check "^2.1.1" create-hash "^1.2.0" create-hmac "^1.1.7" + tiny-secp256k1 "^1.1.3" typeforce "^1.11.5" wif "^2.0.6" -bip39@3.0.4: +bip39@^3.0.2, bip39@^3.0.3: version "3.0.4" resolved "https://registry.yarnpkg.com/bip39/-/bip39-3.0.4.tgz#5b11fed966840b5e1b8539f0f54ab6392969b2a0" integrity sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw== @@ -1339,6 +1471,11 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" +bufio@~1.0.7: + version "1.0.7" + resolved "https://registry.yarnpkg.com/bufio/-/bufio-1.0.7.tgz#b7f63a1369a0829ed64cc14edf0573b3e382a33e" + integrity sha512-bd1dDQhiC+bEbEfg56IdBv7faWa6OipMs/AFFFvtFnB3wAYjlwQpQRZ0pm6ZkgtfL0pILRXhKxOiQj6UzoMR7A== + call-bind@^1.0.0, call-bind@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -1480,6 +1617,14 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cosmos-wallet@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/cosmos-wallet/-/cosmos-wallet-1.1.0.tgz#ca554d19fda1a1a7a8ee21fef4e0ef8f7fa9ef7b" + integrity sha512-jm5MFRYzvOCA/mhULObpaoE2Na0shBn3lrkv2GDedmRZfuoDvOa63WID4qMoIycteefjRKdxXf+26vDrgd79aQ== + dependencies: + "@cosmjs/amino" "^0.25.4" + "@cosmjs/proto-signing" "^0.25.4" + create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" @@ -1627,7 +1772,7 @@ doctrine@^3.0.0: dependencies: esutils "^2.0.2" -elliptic@6.5.4, elliptic@^6.4.0: +elliptic@6.5.4, elliptic@^6.4.0, elliptic@^6.5.3: version "6.5.4" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb" integrity sha512-iLhC6ULemrljPZb+QutR5TQGB+pdW6KGD5RSegS+8sorOZT+rdQFbsQFJgvN3eRqNALqJer4oQ16YvJHlU8hzQ== @@ -1650,6 +1795,14 @@ emoji-regex@^9.2.2: resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-9.2.2.tgz#840c8803b0d8047f4ff0cf963176b32d4ef3ed72" integrity sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg== +enc-utils@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/enc-utils/-/enc-utils-3.0.0.tgz#65935d2d6a867fa0ae995f05f3a2f055ce764dcf" + integrity sha512-e57t/Z2HzWOLwOp7DZcV0VMEY8t7ptWwsxyp6kM2b2zrk6JqIpXxzkruHAMiBsy5wg9jp/183GdiRXCvBtzsYg== + dependencies: + is-typedarray "1.0.0" + typedarray-to-buffer "3.1.5" + end-of-stream@^1.1.0, end-of-stream@^1.4.1: version "1.4.4" resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" @@ -1836,12 +1989,12 @@ eslint-visitor-keys@^3.0.0, eslint-visitor-keys@^3.3.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz#f6480fa6b1f30efe2d1968aa8ac745b862469826" integrity sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA== -eslint@8.9.0: - version "8.9.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.9.0.tgz#a2a8227a99599adc4342fd9b854cb8d8d6412fdb" - integrity sha512-PB09IGwv4F4b0/atrbcMFboF/giawbBLVC7fyDamk5Wtey4Jh2K+rYaBhCAbUyEI4QzB1ly09Uglc9iCtFaG2Q== +eslint@8.10.0: + version "8.10.0" + resolved "https://registry.yarnpkg.com/eslint/-/eslint-8.10.0.tgz#931be395eb60f900c01658b278e05b6dae47199d" + integrity sha512-tcI1D9lfVec+R4LE1mNDnzoJ/f71Kl/9Cv4nG47jOueCMBrCCKYXr4AUVS7go6mWYGFD4+EoN6+eXSrEbRzXVw== dependencies: - "@eslint/eslintrc" "^1.1.0" + "@eslint/eslintrc" "^1.2.0" "@humanwhocodes/config-array" "^0.9.2" ajv "^6.10.0" chalk "^4.0.0" @@ -2509,7 +2662,7 @@ joycon@^2.2.5: resolved "https://registry.yarnpkg.com/joycon/-/joycon-2.2.5.tgz#8d4cf4cbb2544d7b7583c216fcdfec19f6be1615" integrity sha512-YqvUxoOcVPnCp0VU1/56f+iKSdvIRJYPznH22BdXV3xMk75SFXhWeJkZ8C9XxUWt1b5x2X1SxuFygW1U0FmkEQ== -js-sha3@0.8.0: +js-sha3@0.8.0, js-sha3@^0.8.0: version "0.8.0" resolved "https://registry.yarnpkg.com/js-sha3/-/js-sha3-0.8.0.tgz#b9b7a5da73afad7dedd0f8c463954cbde6818840" integrity sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q== @@ -2601,6 +2754,23 @@ levn@^0.4.1: prelude-ls "^1.2.1" type-check "~0.4.0" +libsodium-wrappers@^0.7.6: + version "0.7.9" + resolved "https://registry.yarnpkg.com/libsodium-wrappers/-/libsodium-wrappers-0.7.9.tgz#4ffc2b69b8f7c7c7c5594a93a4803f80f6d0f346" + integrity sha512-9HaAeBGk1nKTRFRHkt7nzxqCvnkWTjn1pdjKgcUnZxj0FyOP4CnhgFhMdrFfgNsukijBGyBLpP2m2uKT1vuWhQ== + dependencies: + libsodium "^0.7.0" + +libsodium@^0.7.0: + version "0.7.9" + resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.9.tgz#4bb7bcbf662ddd920d8795c227ae25bbbfa3821b" + integrity sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A== + +loady@~0.0.5: + version "0.0.5" + resolved "https://registry.yarnpkg.com/loady/-/loady-0.0.5.tgz#b17adb52d2fb7e743f107b0928ba0b591da5d881" + integrity sha512-uxKD2HIj042/HBx77NBcmEPsD+hxCgAtjEWlYNScuUjIsh/62Uyu39GOR68TBR68v+jqDL9zfftCWoUo4y03sQ== + localStorage@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/localStorage/-/localStorage-1.0.4.tgz#57dfa28084385f81431accb8ae24b196398223f7" @@ -2629,6 +2799,11 @@ lodash@^4.17.11: resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c" integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg== +long@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28" + integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA== + loose-envify@^1.1.0, loose-envify@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -2705,6 +2880,17 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== +mnemonic-keyring@1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/mnemonic-keyring/-/mnemonic-keyring-1.4.0.tgz#f766c3ef660981030903ddc6bb44f240cfbeeda1" + integrity sha512-Peo4oupSy4UkeeqYpuJ5PUw4mjDj4lVetoD2R1LloMzoeA8UAXdLOXCUpooQZp7fq7kqtZeOUhDjoLcOWIJUiQ== + dependencies: + "@pedrouid/iso-random" "^1.1.0" + bcrypto "^5.4.0" + bip32 "^2.0.6" + bip39 "^3.0.3" + keyvaluestorage "^0.7.1" + mri@1.1.4: version "1.1.4" resolved "https://registry.yarnpkg.com/mri/-/mri-1.1.4.tgz#7cb1dd1b9b40905f1fac053abe25b6720f44744a" @@ -3080,10 +3266,29 @@ property-information@^5.0.0: dependencies: xtend "^4.0.0" -proxy-compare@2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.0.2.tgz#343e624d0ec399dfbe575f1d365d4fa042c9fc69" - integrity sha512-3qUXJBariEj3eO90M3Rgqq3+/P5Efl0t/dl9g/1uVzIQmO3M+ql4hvNH3mYdu8H+1zcKv07YvL55tsY74jmH1A== +protobufjs@~6.10.2: + version "6.10.2" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.10.2.tgz#b9cb6bd8ec8f87514592ba3fdfd28e93f33a469b" + integrity sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.1" + "@types/node" "^13.7.0" + long "^4.0.0" + +proxy-compare@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.0.3.tgz#13fac7a72ca186a3f4a5e99bdff4863f2ced85c1" + integrity sha512-YEmiPmDvwSUwudfjt68DTRo0VaUC2WrDOfktTYEICInBDCIwveTsnn0cRxkWPSUvZBhzRIxtI0ZoYeUpXU870Q== pump@^3.0.0: version "3.0.0" @@ -3208,6 +3413,11 @@ readable-stream@^3.0.0, readable-stream@^3.1.1, readable-stream@^3.4.0, readable string_decoder "^1.1.1" util-deprecate "^1.0.1" +readonly-date@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/readonly-date/-/readonly-date-1.0.0.tgz#5af785464d8c7d7c40b9d738cbde8c646f97dcd9" + integrity sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ== + refractor@^2.4.1: version "2.10.1" resolved "https://registry.yarnpkg.com/refractor/-/refractor-2.10.1.tgz#166c32f114ed16fd96190ad21d5193d3afc7d34e" @@ -3274,7 +3484,7 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -ripemd160@^2.0.0, ripemd160@^2.0.1: +ripemd160@^2.0.0, ripemd160@^2.0.1, ripemd160@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== @@ -3339,7 +3549,7 @@ set-blocking@~2.0.0: resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= -sha.js@^2.4.0, sha.js@^2.4.8: +sha.js@^2.4.0, sha.js@^2.4.11, sha.js@^2.4.8: version "2.4.11" resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== @@ -3607,7 +3817,7 @@ tiny-emitter@^2.0.0: resolved "https://registry.yarnpkg.com/tiny-emitter/-/tiny-emitter-2.1.0.tgz#1d1a56edfc51c43e863cbb5382a72330e3555423" integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q== -tiny-secp256k1@1.1.6: +tiny-secp256k1@^1.1.3: version "1.1.6" resolved "https://registry.yarnpkg.com/tiny-secp256k1/-/tiny-secp256k1-1.1.6.tgz#7e224d2bee8ab8283f284e40e6b4acb74ffe047c" integrity sha512-FmqJZGduTyvsr2cF3375fqGHUovSwDi/QytexX1Se4BPuPZpTE5Ftp5fg+EFSuEf3lhZqgCRjEG3ydUQ/aNiwA== @@ -3727,12 +3937,12 @@ v8-compile-cache@^2.0.3: resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee" integrity sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA== -valtio@1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/valtio/-/valtio-1.3.0.tgz#b83cfcca8455940119738659946565d5c0389af8" - integrity sha512-wsE6EDIkt+CNZPNHOxNVzoi026Fyt6ZRT750etZCAvrndcdT3N7Z+SSV4kJQdCwl5gNxsnU4BhP1wFS7cu21oA== +valtio@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/valtio/-/valtio-1.3.1.tgz#4532cc2e24dd7a38884fc8e1b1b2a3054b3707d8" + integrity sha512-k1eCoGbt88KuYT6fTRXb4lSZcuh4qLhhhNFwlZP8wItY7ue/3FJeZRCcM1YB3gNNKAMk5WlupQeVZbOp8EPRBg== dependencies: - proxy-compare "2.0.2" + proxy-compare "2.0.3" which-boxed-primitive@^1.0.2: version "1.0.2" From 30f5f7cb1e6d7eec5980e3e523f0416c94bf3a8c Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 28 Feb 2022 15:45:44 +0200 Subject: [PATCH 2/7] Cleanup CosmosUtil api --- .../react-wallet-v2/src/utils/CosmosUtil.ts | 24 +++++++++++-------- .../src/utils/CosmosWalletUtil.ts | 18 +++++++------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts index d320a42..4a4ce0c 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts @@ -18,24 +18,28 @@ interface IInitArguments { * Utility */ export class Cosmos { - keyring: MnemonicKeyring - wallet: CosmosWallet - derivationPath: string + private keyring: MnemonicKeyring + private wallet: CosmosWallet - constructor(keyring: MnemonicKeyring, wallet: CosmosWallet, derivationPath: string) { + constructor(keyring: MnemonicKeyring, wallet: CosmosWallet) { this.wallet = wallet this.keyring = keyring - this.derivationPath = derivationPath } static async init({ mnemonic, path }: IInitArguments) { const keyring = await MnemonicKeyring.init({ mnemonic }) - const derivationPath = path ?? DEFAULT_PATH - const wallet = await CosmosWallet.init(keyring.getPrivateKey(derivationPath)) - return new Cosmos(keyring, wallet, derivationPath) + const wallet = await CosmosWallet.init(keyring.getPrivateKey(path ?? DEFAULT_PATH)) + + return new Cosmos(keyring, wallet) } - public getPublicKey() { - return this.keyring.getPublicKey(this.derivationPath) + public async getAccount(number = 0) { + const account = await this.wallet.getAccounts() + + return account[number] + } + + public getMnemonic() { + return this.keyring.mnemonic } } diff --git a/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts index bec6e32..4eb2f9f 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosWalletUtil.ts @@ -17,19 +17,19 @@ export async function createOrRestoreCosmosWallet() { if (mnemonic) { wallet1 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/0" }) wallet2 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/1" }) - const accounts1 = await wallet1.wallet.getAccounts() - const accounts2 = await wallet2.wallet.getAccounts() - address1 = accounts1[0].address - address2 = accounts2[0].address + const account1 = await wallet1.getAccount() + const account2 = await wallet2.getAccount() + address1 = account1.address + address2 = account2.address } else { wallet1 = await Cosmos.init({ path: "m/44'/118'/0'/0/0" }) - const mnemonic = wallet1.keyring.mnemonic + const mnemonic = wallet1.getMnemonic() // We can reuse same mnemonic for both wallets wallet2 = await Cosmos.init({ mnemonic, path: "m/44'/118'/0'/0/1" }) - const accounts1 = await wallet1.wallet.getAccounts() - const accounts2 = await wallet2.wallet.getAccounts() - address1 = accounts1[0].address - address2 = accounts2[0].address + const account1 = await wallet1.getAccount() + const account2 = await wallet2.getAccount() + address1 = account1.address + address2 = account2.address // Don't store mnemonic in local storage in a production project! localStorage.setItem('WALLET_MNEMONIC', mnemonic) } From 9217bee15b9d70f378254dc10965a8c3700e4fba Mon Sep 17 00:00:00 2001 From: Ilja Date: Mon, 28 Feb 2022 16:16:30 +0200 Subject: [PATCH 3/7] Add ui to select pairing accs cross chain --- .../react-wallet-v2/src/utils/HelperUtil.ts | 8 + .../src/views/SessionProposalModal.tsx | 140 +++++++++++++----- 2 files changed, 109 insertions(+), 39 deletions(-) diff --git a/wallets/react-wallet-v2/src/utils/HelperUtil.ts b/wallets/react-wallet-v2/src/utils/HelperUtil.ts index 9ddf3da..8c7b3a1 100644 --- a/wallets/react-wallet-v2/src/utils/HelperUtil.ts +++ b/wallets/react-wallet-v2/src/utils/HelperUtil.ts @@ -69,3 +69,11 @@ export function getWalletAddressFromParams(addresses: string[], params: any) { return address } + +export function isEIP155Chain(chain: string) { + return chain.includes('eip155') +} + +export function isCosmosChain(chain: string) { + return chain.includes('cosmos') +} diff --git a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx index baed015..194fd7f 100644 --- a/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionProposalModal.tsx @@ -1,7 +1,9 @@ import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData' import { EIP155_CHAINS, TEIP155Chain } from '@/data/EIP155Data' import ModalStore from '@/store/ModalStore' +import { cosmosAddresses } from '@/utils/CosmosWalletUtil' import { eip155Addresses } from '@/utils/EIP155WalletUtil' +import { isCosmosChain, isEIP155Chain, truncate } from '@/utils/HelperUtil' import { walletConnectClient } from '@/utils/WalletConnectUtil' import { Avatar, @@ -19,7 +21,8 @@ import { import { Fragment, useState } from 'react' export default function SessionProposalModal() { - const [selectedAddresses, setSelectedAddresses] = useState([]) + const [selectedEIP155, setSelectedEip155] = useState([]) + const [selectedCosmos, setSelectedCosmos] = useState([]) // Get proposal data and wallet address from store const proposal = ModalStore.state.data?.proposal @@ -36,13 +39,23 @@ export default function SessionProposalModal() { const { methods } = permissions.jsonrpc const { protocol } = relay - // Add / remove address from selection - function onSelectAddress(address: string) { - if (selectedAddresses.includes(address)) { - const newAddresses = selectedAddresses.filter(a => a !== address) - setSelectedAddresses(newAddresses) + // Add / remove address from EIP155 selection + function onSelectEIP155(address: string) { + if (selectedEIP155.includes(address)) { + const newAddresses = selectedEIP155.filter(a => a !== address) + setSelectedEip155(newAddresses) } else { - setSelectedAddresses([...selectedAddresses, address]) + setSelectedEip155([...selectedEIP155, address]) + } + } + + // Add / remove address from Cosmos selection + function onSelectCosmos(address: string) { + if (selectedCosmos.includes(address)) { + const newAddresses = selectedCosmos.filter(a => a !== address) + setSelectedCosmos(newAddresses) + } else { + setSelectedCosmos([...selectedCosmos, address]) } } @@ -51,9 +64,15 @@ export default function SessionProposalModal() { if (proposal) { const accounts: string[] = [] chains.forEach(chain => { - selectedAddresses.forEach(address => { - accounts.push(`${chain}:${address}`) - }) + if (isEIP155Chain(chain)) { + selectedEIP155.forEach(address => { + accounts.push(`${chain}:${address}`) + }) + } else if (isCosmosChain(chain)) { + cosmosAddresses.forEach(address => { + accounts.push(`${chain}:${address}`) + }) + } }) const response = { @@ -128,36 +147,79 @@ export default function SessionProposalModal() { - + {chains.map(chain => { + if (isEIP155Chain(chain)) { + return ( + + - - - Select Accounts to Connect - {eip155Addresses.map((address, index) => ( - onSelectAddress(address)} - clickable - key={address} - css={{ - marginTop: '$5', - backgroundColor: selectedAddresses.includes(address) - ? 'rgba(23, 200, 100, 0.2)' - : '$accents2' - }} - > - - + + + Select EIP155 Accounts + {eip155Addresses.map((address, index) => ( + onSelectEIP155(address)} + clickable + key={address} + css={{ + marginTop: '$5', + backgroundColor: selectedEIP155.includes(address) + ? 'rgba(23, 200, 100, 0.2)' + : '$accents2' + }} + > + + - {`Account ${index + 1}`} + {`${truncate(address, 14)} - Account ${index + 1}`} + + + ))} + - - ))} - - + + ) + } else if (isCosmosChain(chain)) { + return ( + + + + + + Select Cosmos Accounts + {cosmosAddresses.map((address, index) => ( + onSelectCosmos(address)} + clickable + key={address} + css={{ + marginTop: '$5', + backgroundColor: selectedCosmos.includes(address) + ? 'rgba(23, 200, 100, 0.2)' + : '$accents2' + }} + > + + + + {`${truncate(address, 14)} - Account ${index + 1}`} + + + ))} + + + + ) + } + })} @@ -171,8 +233,8 @@ export default function SessionProposalModal() { flat color="success" onClick={onApprove} - disabled={!selectedAddresses.length} - css={{ opacity: selectedAddresses.length ? 1 : 0.4 }} + disabled={![...selectedEIP155, ...selectedCosmos].length} + css={{ opacity: [...selectedEIP155, ...selectedCosmos].length ? 1 : 0.4 }} > Approve From 24f5aa1a1582c1329c9865a0db43c836a2eb9c3e Mon Sep 17 00:00:00 2001 From: Ilja Date: Tue, 1 Mar 2022 14:43:09 +0200 Subject: [PATCH 4/7] Cosmos signing wip --- wallets/react-wallet-v2/package.json | 5 +- .../react-wallet-v2/src/components/Modal.tsx | 2 + .../react-wallet-v2/src/data/COSMOSData.ts | 8 ++ .../hooks/useWalletConnectEventsManager.ts | 5 + .../react-wallet-v2/src/store/ModalStore.ts | 1 + .../src/utils/CosmosRequestHandler.ts | 30 +++++ .../react-wallet-v2/src/utils/CosmosUtil.ts | 10 ++ .../react-wallet-v2/src/utils/HelperUtil.ts | 6 + .../src/views/SessionSignCosmosModal.tsx | 125 ++++++++++++++++++ wallets/react-wallet-v2/yarn.lock | 101 +++++++++++++- 10 files changed, 286 insertions(+), 7 deletions(-) create mode 100644 wallets/react-wallet-v2/src/utils/CosmosRequestHandler.ts create mode 100644 wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx diff --git a/wallets/react-wallet-v2/package.json b/wallets/react-wallet-v2/package.json index 7b36952..a3846b9 100644 --- a/wallets/react-wallet-v2/package.json +++ b/wallets/react-wallet-v2/package.json @@ -21,7 +21,8 @@ "framer-motion": "6.2.8", "ethers": "5.5.4", "valtio": "1.3.1", - "react-code-blocks": "0.0.9-0" + "react-code-blocks": "0.0.9-0", + "@cosmjs/proto-signing": "0.27.1" }, "devDependencies": { "@walletconnect/types": "2.0.0-beta.22", @@ -31,6 +32,6 @@ "eslint-config-next": "12.1.0", "eslint-config-prettier": "8.4.0", "prettier": "2.5.1", - "typescript": "4.5.5" + "typescript": "4.6.2" } } diff --git a/wallets/react-wallet-v2/src/components/Modal.tsx b/wallets/react-wallet-v2/src/components/Modal.tsx index ff2fdc9..7a2990c 100644 --- a/wallets/react-wallet-v2/src/components/Modal.tsx +++ b/wallets/react-wallet-v2/src/components/Modal.tsx @@ -1,6 +1,7 @@ import ModalStore from '@/store/ModalStore' import SessionProposalModal from '@/views/SessionProposalModal' import SessionSendTransactionModal from '@/views/SessionSendTransactionModal' +import SessionSignCosmosModal from '@/views/SessionSignCosmosModal' import SessionRequestModal from '@/views/SessionSignModal' import SessionSignTypedDataModal from '@/views/SessionSignTypedDataModal' import SessionUnsuportedMethodModal from '@/views/SessionUnsuportedMethodModal' @@ -17,6 +18,7 @@ export default function Modal() { {view === 'SessionSignTypedDataModal' && } {view === 'SessionSendTransactionModal' && } {view === 'SessionUnsuportedMethodModal' && } + {view === 'SessionSignCosmosModal' && } ) } diff --git a/wallets/react-wallet-v2/src/data/COSMOSData.ts b/wallets/react-wallet-v2/src/data/COSMOSData.ts index ae0d4aa..9d7bd87 100644 --- a/wallets/react-wallet-v2/src/data/COSMOSData.ts +++ b/wallets/react-wallet-v2/src/data/COSMOSData.ts @@ -15,3 +15,11 @@ export const COSMOS_MAINNET_CHAINS = { rpc: '' } } + +/** + * Methods + */ +export const COSMOS_SIGNING_METHODS = { + COSMOS_SIGN_DIRECT: 'cosmos_signDirect', + COSMOS_SIGN_AMINO: 'cosmos_signAmino' +} diff --git a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts index 8c4358e..0d31254 100644 --- a/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts +++ b/wallets/react-wallet-v2/src/hooks/useWalletConnectEventsManager.ts @@ -1,3 +1,4 @@ +import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData' import { EIP155_SIGNING_METHODS } from '@/data/EIP155Data' import ModalStore from '@/store/ModalStore' import { walletConnectClient } from '@/utils/WalletConnectUtil' @@ -40,6 +41,10 @@ export default function useWalletConnectEventsManager(initialized: boolean) { case EIP155_SIGNING_METHODS.ETH_SIGN_TRANSACTION: return ModalStore.open('SessionSendTransactionModal', { requestEvent, requestSession }) + case COSMOS_SIGNING_METHODS.COSMOS_SIGN_DIRECT: + case COSMOS_SIGNING_METHODS.COSMOS_SIGN_AMINO: + return ModalStore.open('SessionSignCosmosModal', { requestEvent, requestSession }) + default: return ModalStore.open('SessionUnsuportedMethodModal', { requestEvent, requestSession }) } diff --git a/wallets/react-wallet-v2/src/store/ModalStore.ts b/wallets/react-wallet-v2/src/store/ModalStore.ts index 656d1ba..1225f19 100644 --- a/wallets/react-wallet-v2/src/store/ModalStore.ts +++ b/wallets/react-wallet-v2/src/store/ModalStore.ts @@ -19,6 +19,7 @@ interface State { | 'SessionSignTypedDataModal' | 'SessionSendTransactionModal' | 'SessionUnsuportedMethodModal' + | 'SessionSignCosmosModal' data?: ModalData } diff --git a/wallets/react-wallet-v2/src/utils/CosmosRequestHandler.ts b/wallets/react-wallet-v2/src/utils/CosmosRequestHandler.ts new file mode 100644 index 0000000..a15c496 --- /dev/null +++ b/wallets/react-wallet-v2/src/utils/CosmosRequestHandler.ts @@ -0,0 +1,30 @@ +import { COSMOS_SIGNING_METHODS } from '@/data/COSMOSData' +import { cosmosAddresses, cosmosWallets } from '@/utils/CosmosWalletUtil' +import { getWalletAddressFromParams } from '@/utils/HelperUtil' +import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils' +import { RequestEvent } from '@walletconnect/types' +import { ERROR } from '@walletconnect/utils' + +export async function approveCosmosRequest(requestEvent: RequestEvent) { + const { method, params, id } = requestEvent.request + const wallet = cosmosWallets[getWalletAddressFromParams(cosmosAddresses, params)] + + switch (method) { + case COSMOS_SIGNING_METHODS.COSMOS_SIGN_DIRECT: + const signedDirect = await wallet.signDirect(params.signerAddress, params.signDoc) + return formatJsonRpcResult(id, signedDirect.signature) + + case COSMOS_SIGNING_METHODS.COSMOS_SIGN_AMINO: + const signedAmino = await wallet.signAmino(params.signerAddress, params.signDoc) + return formatJsonRpcResult(id, signedAmino.signature) + + default: + throw new Error(ERROR.UNKNOWN_JSONRPC_METHOD.format().message) + } +} + +export function rejectCosmosRequest(request: RequestEvent['request']) { + const { id } = request + + return formatJsonRpcError(id, ERROR.JSONRPC_REQUEST_METHOD_REJECTED.format().message) +} diff --git a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts index 4a4ce0c..912b6f0 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts @@ -1,3 +1,5 @@ +// @ts-expect-error +import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx' import CosmosWallet from 'cosmos-wallet' import MnemonicKeyring from 'mnemonic-keyring' @@ -42,4 +44,12 @@ export class Cosmos { public getMnemonic() { return this.keyring.mnemonic } + + public signDirect(address: string, signDoc: SignDoc) { + return this.wallet.signDirect(address, signDoc) + } + + public signAmino(address: string, signDoc: SignDoc) { + return this.wallet.signAmino(address, signDoc) + } } diff --git a/wallets/react-wallet-v2/src/utils/HelperUtil.ts b/wallets/react-wallet-v2/src/utils/HelperUtil.ts index 8c7b3a1..64a4bcf 100644 --- a/wallets/react-wallet-v2/src/utils/HelperUtil.ts +++ b/wallets/react-wallet-v2/src/utils/HelperUtil.ts @@ -70,10 +70,16 @@ export function getWalletAddressFromParams(addresses: string[], params: any) { return address } +/** + * Check if chain is part of EIP155 standard + */ export function isEIP155Chain(chain: string) { return chain.includes('eip155') } +/** + * Check if chain is part of COSMOS standard + */ export function isCosmosChain(chain: string) { return chain.includes('cosmos') } diff --git a/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx b/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx new file mode 100644 index 0000000..412e228 --- /dev/null +++ b/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx @@ -0,0 +1,125 @@ +import { COSMOS_MAINNET_CHAINS, TCosmosChain } from '@/data/COSMOSData' +import ModalStore from '@/store/ModalStore' +import { approveCosmosRequest, rejectCosmosRequest } from '@/utils/CosmosRequestHandler' +import { walletConnectClient } from '@/utils/WalletConnectUtil' +import { Avatar, Button, Col, Container, Divider, Link, Modal, Row, Text } from '@nextui-org/react' +import { Fragment } from 'react' + +export default function SessionSignCosmosModal() { + // Get request and wallet data from store + const requestEvent = ModalStore.state.data?.requestEvent + const requestSession = ModalStore.state.data?.requestSession + + // Ensure request and wallet are defined + if (!requestEvent || !requestSession) { + return Missing request data + } + + // Get required request data + const { chainId } = requestEvent + const { method, params } = requestEvent.request + const { protocol } = requestSession.relay + const { name, icons, url } = requestSession.peer.metadata + + // Handle approve action (logic varies based on request method) + async function onApprove() { + if (requestEvent) { + const response = await approveCosmosRequest(requestEvent) + await walletConnectClient.respond({ + topic: requestEvent.topic, + response + }) + ModalStore.close() + } + } + + // Handle reject action + async function onReject() { + if (requestEvent) { + const response = rejectCosmosRequest(requestEvent.request) + await walletConnectClient.respond({ + topic: requestEvent.topic, + response + }) + ModalStore.close() + } + } + + return ( + + + Sign Message + + + + + + + + + + {name} + {url} + + + + + + + + Blockchain + + {COSMOS_MAINNET_CHAINS[chainId as TCosmosChain]?.name ?? chainId} + + + + + + + + + Message + {JSON.stringify(params.signDoc.msgs) ?? 'No Message'} + + + + + + + + Memo + {JSON.stringify(params.signDoc.memo)} + + + + + + + + Method + {method} + + + + + + + + Relay Protocol + {protocol} + + + + + + + + + + + ) +} diff --git a/wallets/react-wallet-v2/yarn.lock b/wallets/react-wallet-v2/yarn.lock index 645bf4f..8f5c634 100644 --- a/wallets/react-wallet-v2/yarn.lock +++ b/wallets/react-wallet-v2/yarn.lock @@ -143,6 +143,16 @@ "@babel/helper-validator-identifier" "^7.16.7" to-fast-properties "^2.0.0" +"@cosmjs/amino@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.27.1.tgz#0910256b5aecd794420bb5f7319d98fc63252fa1" + integrity sha512-w56ar/nK9+qlvWDpBPRmD0Blk2wfkkLqRi1COs1x7Ll1LF0AtkIBUjbRKplENLbNovK0T3h+w8bHiFm+GBGQOA== + dependencies: + "@cosmjs/crypto" "0.27.1" + "@cosmjs/encoding" "0.27.1" + "@cosmjs/math" "0.27.1" + "@cosmjs/utils" "0.27.1" + "@cosmjs/amino@^0.25.4", "@cosmjs/amino@^0.25.6": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.25.6.tgz#cdf9632253bfab7b1d2ef967124953d7bf16351f" @@ -153,6 +163,22 @@ "@cosmjs/math" "^0.25.6" "@cosmjs/utils" "^0.25.6" +"@cosmjs/crypto@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.27.1.tgz#271c853089a3baf3acd6cf0b2122fd49f8815743" + integrity sha512-vbcxwSt99tIYJg8Spp00wc3zx72qx+pY3ozGuBN8gAvySnagK9dQ/jHwtWQWdammmdD6oW+75WfIHZ+gNa+Ybg== + dependencies: + "@cosmjs/encoding" "0.27.1" + "@cosmjs/math" "0.27.1" + "@cosmjs/utils" "0.27.1" + bip39 "^3.0.2" + bn.js "^5.2.0" + elliptic "^6.5.3" + js-sha3 "^0.8.0" + libsodium-wrappers "^0.7.6" + ripemd160 "^2.0.2" + sha.js "^2.4.11" + "@cosmjs/crypto@^0.25.6": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.25.6.tgz#695d2d0d2195bdbdd5825d415385646244900bbb" @@ -169,6 +195,15 @@ ripemd160 "^2.0.2" sha.js "^2.4.11" +"@cosmjs/encoding@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.27.1.tgz#3cd5bc0af743485eb2578cdb08cfa84c86d610e1" + integrity sha512-rayLsA0ojHeniaRfWWcqSsrE/T1rl1gl0OXVNtXlPwLJifKBeLEefGbOUiAQaT0wgJ8VNGBazVtAZBpJidfDhw== + dependencies: + base64-js "^1.3.0" + bech32 "^1.1.4" + readonly-date "^1.0.0" + "@cosmjs/encoding@^0.25.6": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.25.6.tgz#da741a33eaf063a6d3611d7d68db5ca3938e0ef5" @@ -178,6 +213,13 @@ bech32 "^1.1.4" readonly-date "^1.0.0" +"@cosmjs/math@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.27.1.tgz#be78857b008ffc6b1ed6fecaa1c4cd5bc38c07d7" + integrity sha512-cHWVjmfIjtRc7f80n7x+J5k8pe+vTVTQ0lA82tIxUgqUvgS6rogPP/TmGtTiZ4+NxWxd11DUISY6gVpr18/VNQ== + dependencies: + bn.js "^5.2.0" + "@cosmjs/math@^0.25.6": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.25.6.tgz#25c7b106aaded889a5b80784693caa9e654b0c28" @@ -185,6 +227,18 @@ dependencies: bn.js "^4.11.8" +"@cosmjs/proto-signing@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.27.1.tgz#1f8f662550aab012d957d02f43c77d914c2ae0db" + integrity sha512-t7/VvQivMdM1KgKWai/9ZCEcGFXJtr9Xo0hGcPLTn9wGkh9tmOsUXINYVMsf5D/jWIm1MDPbGCYfdb9V1Od4hw== + dependencies: + "@cosmjs/amino" "0.27.1" + "@cosmjs/crypto" "0.27.1" + "@cosmjs/math" "0.27.1" + cosmjs-types "^0.4.0" + long "^4.0.0" + protobufjs "~6.10.2" + "@cosmjs/proto-signing@^0.25.4": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.25.6.tgz#d9fc57b8e0a46cda97e192bd0435157b24949ff8" @@ -194,6 +248,11 @@ long "^4.0.0" protobufjs "~6.10.2" +"@cosmjs/utils@0.27.1": + version "0.27.1" + resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.27.1.tgz#1c8efde17256346ef142a3bd15158ee4055470e2" + integrity sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg== + "@cosmjs/utils@^0.25.6": version "0.25.6" resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.25.6.tgz#934d9a967180baa66163847616a74358732227ca" @@ -938,7 +997,7 @@ resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.6.tgz#df929d1bb2eee5afdda598a41930fe50b43eaa6a" integrity sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ== -"@types/node@17.0.21": +"@types/node@17.0.21", "@types/node@>=13.7.0": version "17.0.21" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.21.tgz#864b987c0c68d07b4345845c3e63b75edd143644" integrity sha512-DBZCJbhII3r90XbQxI8Y9IjjiiOGlZ0Hr32omXIZvwwZ7p4DMMXGrKXVyPfuoBOri9XNtL0UK69jYIBIsRX3QQ== @@ -1427,6 +1486,11 @@ bn.js@^4.11.8, bn.js@^4.11.9: resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.12.0.tgz#775b3f278efbb9718eec7361f483fb36fbbfea88" integrity sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA== +bn.js@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.0.tgz#358860674396c6997771a9d051fcc1b57d4ae002" + integrity sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw== + brace-expansion@^1.1.7: version "1.1.11" resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" @@ -1617,6 +1681,14 @@ core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85" integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ== +cosmjs-types@^0.4.0: + version "0.4.1" + resolved "https://registry.yarnpkg.com/cosmjs-types/-/cosmjs-types-0.4.1.tgz#3b2a53ba60d33159dd075596ce8267cfa7027063" + integrity sha512-I7E/cHkIgoJzMNQdFF0YVqPlaTqrqKHrskuSTIqlEyxfB5Lf3WKCajSXVK2yHOfOFfSux/RxEdpMzw/eO4DIog== + dependencies: + long "^4.0.0" + protobufjs "~6.11.2" + cosmos-wallet@1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/cosmos-wallet/-/cosmos-wallet-1.1.0.tgz#ca554d19fda1a1a7a8ee21fef4e0ef8f7fa9ef7b" @@ -3285,6 +3357,25 @@ protobufjs@~6.10.2: "@types/node" "^13.7.0" long "^4.0.0" +protobufjs@~6.11.2: + version "6.11.2" + resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.2.tgz#de39fabd4ed32beaa08e9bb1e30d08544c1edf8b" + integrity sha512-4BQJoPooKJl2G9j3XftkIXjoC9C0Av2NOrWmbLWT1vH32GcSUHjM0Arra6UfTsVyfMAuFzaLucXn1sadxJydAw== + dependencies: + "@protobufjs/aspromise" "^1.1.2" + "@protobufjs/base64" "^1.1.2" + "@protobufjs/codegen" "^2.0.4" + "@protobufjs/eventemitter" "^1.1.0" + "@protobufjs/fetch" "^1.1.0" + "@protobufjs/float" "^1.0.2" + "@protobufjs/inquire" "^1.1.0" + "@protobufjs/path" "^1.1.2" + "@protobufjs/pool" "^1.1.0" + "@protobufjs/utf8" "^1.1.0" + "@types/long" "^4.0.1" + "@types/node" ">=13.7.0" + long "^4.0.0" + proxy-compare@2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/proxy-compare/-/proxy-compare-2.0.3.tgz#13fac7a72ca186a3f4a5e99bdff4863f2ced85c1" @@ -3898,10 +3989,10 @@ typeforce@^1.11.5: resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc" integrity sha512-7uc1O8h1M1g0rArakJdf0uLRSSgFcYexrVoKo+bzJd32gd4gDy2L/Z+8/FjPnU9ydY3pEnVPtr9FyscYY60K1g== -typescript@4.5.5: - version "4.5.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.5.tgz#d8c953832d28924a9e3d37c73d729c846c5896f3" - integrity sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA== +typescript@4.6.2: + version "4.6.2" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.2.tgz#fe12d2727b708f4eef40f51598b3398baa9611d4" + integrity sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg== unbox-primitive@^1.0.1: version "1.0.1" From 643b38a3a85a07c8628329c1aa60fd5a45d3daa5 Mon Sep 17 00:00:00 2001 From: Ilja Date: Tue, 1 Mar 2022 15:34:37 +0200 Subject: [PATCH 5/7] wrap up cosmos js --- wallets/react-wallet-v2/package.json | 5 +- .../react-wallet-v2/src/utils/CosmosUtil.ts | 39 +++++--- .../src/views/SessionSignCosmosModal.tsx | 19 ++-- wallets/react-wallet-v2/yarn.lock | 89 ++++++++++--------- 4 files changed, 84 insertions(+), 68 deletions(-) diff --git a/wallets/react-wallet-v2/package.json b/wallets/react-wallet-v2/package.json index a3846b9..4d8b3f4 100644 --- a/wallets/react-wallet-v2/package.json +++ b/wallets/react-wallet-v2/package.json @@ -22,7 +22,10 @@ "ethers": "5.5.4", "valtio": "1.3.1", "react-code-blocks": "0.0.9-0", - "@cosmjs/proto-signing": "0.27.1" + "@cosmjs/proto-signing": "0.27.1", + "@cosmjs/crypto": "0.27.1", + "@cosmjs/encoding": "0.27.1", + "@cosmjs/amino": "0.27.1" }, "devDependencies": { "@walletconnect/types": "2.0.0-beta.22", diff --git a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts index 912b6f0..3f81dbf 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts @@ -1,6 +1,8 @@ +import { Secp256k1Wallet } from '@cosmjs/amino' +import { fromHex } from '@cosmjs/encoding' +import { DirectSecp256k1Wallet, makeSignBytes } from '@cosmjs/proto-signing' // @ts-expect-error import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx' -import CosmosWallet from 'cosmos-wallet' import MnemonicKeyring from 'mnemonic-keyring' /** @@ -14,6 +16,7 @@ const DEFAULT_PATH = "m/44'/118'/0'/0/0" interface IInitArguments { mnemonic?: string path?: string + prefix?: string } /** @@ -21,22 +24,31 @@ interface IInitArguments { */ export class Cosmos { private keyring: MnemonicKeyring - private wallet: CosmosWallet + private directSigner: DirectSecp256k1Wallet + private aminoSigner: Secp256k1Wallet - constructor(keyring: MnemonicKeyring, wallet: CosmosWallet) { - this.wallet = wallet + constructor( + keyring: MnemonicKeyring, + directSigner: DirectSecp256k1Wallet, + aminoSigner: Secp256k1Wallet + ) { + this.directSigner = directSigner this.keyring = keyring + this.aminoSigner = aminoSigner } - static async init({ mnemonic, path }: IInitArguments) { + static async init({ mnemonic, path, prefix }: IInitArguments) { const keyring = await MnemonicKeyring.init({ mnemonic }) - const wallet = await CosmosWallet.init(keyring.getPrivateKey(path ?? DEFAULT_PATH)) + const privateKey = fromHex(keyring.getPrivateKey(path ?? DEFAULT_PATH)) + const chainPrefix = prefix ?? 'cosmos' + const directSigner = await DirectSecp256k1Wallet.fromKey(privateKey, chainPrefix) + const aminoSigner = await Secp256k1Wallet.fromKey(privateKey, chainPrefix) - return new Cosmos(keyring, wallet) + return new Cosmos(keyring, directSigner, aminoSigner) } public async getAccount(number = 0) { - const account = await this.wallet.getAccounts() + const account = await this.directSigner.getAccounts() return account[number] } @@ -45,11 +57,14 @@ export class Cosmos { return this.keyring.mnemonic } - public signDirect(address: string, signDoc: SignDoc) { - return this.wallet.signDirect(address, signDoc) + public async signDirect(address: string, signDoc: SignDoc) { + console.log(signDoc) + const signDocBytes = makeSignBytes(signDoc) + // @ts-expect-error + return await this.directSigner.signDirect(address, signDocBytes) } - public signAmino(address: string, signDoc: SignDoc) { - return this.wallet.signAmino(address, signDoc) + public async signAmino(address: string, signDoc: SignDoc) { + return await this.aminoSigner.signAmino(address, signDoc) } } diff --git a/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx b/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx index 412e228..ada2364 100644 --- a/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx +++ b/wallets/react-wallet-v2/src/views/SessionSignCosmosModal.tsx @@ -4,6 +4,7 @@ import { approveCosmosRequest, rejectCosmosRequest } from '@/utils/CosmosRequest import { walletConnectClient } from '@/utils/WalletConnectUtil' import { Avatar, Button, Col, Container, Divider, Link, Modal, Row, Text } from '@nextui-org/react' import { Fragment } from 'react' +import { CodeBlock, codepen } from 'react-code-blocks' export default function SessionSignCosmosModal() { // Get request and wallet data from store @@ -78,17 +79,13 @@ export default function SessionSignCosmosModal() { - Message - {JSON.stringify(params.signDoc.msgs) ?? 'No Message'} - - - - - - - - Memo - {JSON.stringify(params.signDoc.memo)} + Data + diff --git a/wallets/react-wallet-v2/yarn.lock b/wallets/react-wallet-v2/yarn.lock index 8f5c634..ad34311 100644 --- a/wallets/react-wallet-v2/yarn.lock +++ b/wallets/react-wallet-v2/yarn.lock @@ -641,9 +641,9 @@ integrity sha512-WEezM1FWztfbzqIUbsDzFRVMxSoLy3HugVcux6KDDtTqzPsLE8NDRHfXvev66aH1i2oOKKar3/XDjbvh/OUBdg== "@humanwhocodes/config-array@^0.9.2": - version "0.9.3" - resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.3.tgz#f2564c744b387775b436418491f15fce6601f63e" - integrity sha512-3xSMlXHh03hCcCmFc0rbKp3Ivt2PFEJnQUJDDMTJQ2wkECZWdq4GePs2ctc5H8zV+cHPaq8k2vU8mrQjA6iHdQ== + version "0.9.5" + resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.9.5.tgz#2cbaf9a89460da24b5ca6531b8bbfc23e1df50c7" + integrity sha512-ObyMyWxZiCu/yTisA7uzx81s40xR2fD5Cg/2Kq7G02ajkNubJf6BopgDTmDyc3U7sXpNKM8cYOw7s7Tyr+DnCw== dependencies: "@humanwhocodes/object-schema" "^1.2.1" debug "^4.1.1" @@ -1027,47 +1027,47 @@ integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew== "@typescript-eslint/parser@^5.0.0": - version "5.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.12.0.tgz#0ca669861813df99ce54916f66f524c625ed2434" - integrity sha512-MfSwg9JMBojMUoGjUmX+D2stoQj1CBYTCP0qnnVtu9A+YQXVKNtLjasYh+jozOcrb/wau8TCfWOkQTiOAruBog== + version "5.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.13.0.tgz#0394ed8f2f849273c0bf4b811994d177112ced5c" + integrity sha512-GdrU4GvBE29tm2RqWOM0P5QfCtgCyN4hXICj/X9ibKED16136l9ZpoJvCL5pSKtmJzA+NRDzQ312wWMejCVVfg== dependencies: - "@typescript-eslint/scope-manager" "5.12.0" - "@typescript-eslint/types" "5.12.0" - "@typescript-eslint/typescript-estree" "5.12.0" + "@typescript-eslint/scope-manager" "5.13.0" + "@typescript-eslint/types" "5.13.0" + "@typescript-eslint/typescript-estree" "5.13.0" debug "^4.3.2" -"@typescript-eslint/scope-manager@5.12.0": - version "5.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.12.0.tgz#59619e6e5e2b1ce6cb3948b56014d3a24da83f5e" - integrity sha512-GAMobtIJI8FGf1sLlUWNUm2IOkIjvn7laFWyRx7CLrv6nLBI7su+B7lbStqVlK5NdLvHRFiJo2HhiDF7Ki01WQ== +"@typescript-eslint/scope-manager@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.13.0.tgz#cf6aff61ca497cb19f0397eea8444a58f46156b6" + integrity sha512-T4N8UvKYDSfVYdmJq7g2IPJYCRzwtp74KyDZytkR4OL3NRupvswvmJQJ4CX5tDSurW2cvCc1Ia1qM7d0jpa7IA== dependencies: - "@typescript-eslint/types" "5.12.0" - "@typescript-eslint/visitor-keys" "5.12.0" + "@typescript-eslint/types" "5.13.0" + "@typescript-eslint/visitor-keys" "5.13.0" -"@typescript-eslint/types@5.12.0": - version "5.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.12.0.tgz#5b4030a28222ee01e851836562c07769eecda0b8" - integrity sha512-JowqbwPf93nvf8fZn5XrPGFBdIK8+yx5UEGs2QFAYFI8IWYfrzz+6zqlurGr2ctShMaJxqwsqmra3WXWjH1nRQ== +"@typescript-eslint/types@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.13.0.tgz#da1de4ae905b1b9ff682cab0bed6b2e3be9c04e5" + integrity sha512-LmE/KO6DUy0nFY/OoQU0XelnmDt+V8lPQhh8MOVa7Y5k2gGRd6U9Kp3wAjhB4OHg57tUO0nOnwYQhRRyEAyOyg== -"@typescript-eslint/typescript-estree@5.12.0": - version "5.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.12.0.tgz#cabf545fd592722f0e2b4104711e63bf89525cd2" - integrity sha512-Dd9gVeOqt38QHR0BEA8oRaT65WYqPYbIc5tRFQPkfLquVEFPD1HAtbZT98TLBkEcCkvwDYOAvuSvAD9DnQhMfQ== +"@typescript-eslint/typescript-estree@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.13.0.tgz#b37c07b748ff030a3e93d87c842714e020b78141" + integrity sha512-Q9cQow0DeLjnp5DuEDjLZ6JIkwGx3oYZe+BfcNuw/POhtpcxMTy18Icl6BJqTSd+3ftsrfuVb7mNHRZf7xiaNA== dependencies: - "@typescript-eslint/types" "5.12.0" - "@typescript-eslint/visitor-keys" "5.12.0" + "@typescript-eslint/types" "5.13.0" + "@typescript-eslint/visitor-keys" "5.13.0" debug "^4.3.2" globby "^11.0.4" is-glob "^4.0.3" semver "^7.3.5" tsutils "^3.21.0" -"@typescript-eslint/visitor-keys@5.12.0": - version "5.12.0" - resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.12.0.tgz#1ac9352ed140b07ba144ebf371b743fdf537ec16" - integrity sha512-cFwTlgnMV6TgezQynx2c/4/tx9Tufbuo9LPzmWqyRC3QC4qTGkAG1C6pBr0/4I10PAI/FlYunI3vJjIcu+ZHMg== +"@typescript-eslint/visitor-keys@5.13.0": + version "5.13.0" + resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.13.0.tgz#f45ff55bcce16403b221ac9240fbeeae4764f0fd" + integrity sha512-HLKEAS/qA1V7d9EzcpLFykTePmOQqOFim8oCvhY3pZgQ8Hi38hYpHd9e5GN6nQBFQNecNhws5wkS9Y5XIO0s/g== dependencies: - "@typescript-eslint/types" "5.12.0" + "@typescript-eslint/types" "5.13.0" eslint-visitor-keys "^3.0.0" "@walletconnect/client@2.0.0-beta.22": @@ -1390,14 +1390,15 @@ axobject-query@^2.2.0: integrity sha512-Td525n+iPOOyUQIeBfcASuG6uJsDOITl7Mds5gFyerkWiX7qhUTdYUBlSgNMyVqtSJqwpt1kXGLdUt6SykLMRA== "babel-plugin-styled-components@>= 1.12.0": - version "2.0.2" - resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.2.tgz#0fac11402dc9db73698b55847ab1dc73f5197c54" - integrity sha512-7eG5NE8rChnNTDxa6LQfynwgHTVOYYaHJbUYSlOhk8QBXIQiMBKq4gyfHBBKPrxUcVBXVJL61ihduCpCQbuNbw== + version "2.0.6" + resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-2.0.6.tgz#6f76c7f7224b7af7edc24a4910351948c691fc90" + integrity sha512-Sk+7o/oa2HfHv3Eh8sxoz75/fFvEdHsXV4grdeHufX0nauCmymlnN0rGhIvfpMQSJMvGutJ85gvCGea4iqmDpg== dependencies: "@babel/helper-annotate-as-pure" "^7.16.0" "@babel/helper-module-imports" "^7.16.0" babel-plugin-syntax-jsx "^6.18.0" lodash "^4.17.11" + picomatch "^2.3.0" babel-plugin-syntax-jsx@^6.18.0: version "6.18.0" @@ -2017,21 +2018,21 @@ eslint-plugin-react-hooks@^4.3.0: integrity sha512-XslZy0LnMn+84NEG9jSGR6eGqaZB3133L8xewQo3fQagbQuGt7a63gf+P1NGKZavEYEC3UXaWEAA/AqDkuN6xA== eslint-plugin-react@^7.27.0: - version "7.28.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.28.0.tgz#8f3ff450677571a659ce76efc6d80b6a525adbdf" - integrity sha512-IOlFIRHzWfEQQKcAD4iyYDndHwTQiCMcJVJjxempf203jnNLUnW34AXLrV33+nEXoifJE2ZEGmcjKPL8957eSw== + version "7.29.2" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.29.2.tgz#2d4da69d30d0a736efd30890dc6826f3e91f3f7c" + integrity sha512-ypEBTKOy5liFQXZWMchJ3LN0JX1uPI6n7MN7OPHKacqXAxq5gYC30TdO7wqGYQyxD1OrzpobdHC3hDmlRWDg9w== dependencies: array-includes "^3.1.4" array.prototype.flatmap "^1.2.5" doctrine "^2.1.0" estraverse "^5.3.0" jsx-ast-utils "^2.4.1 || ^3.0.0" - minimatch "^3.0.4" + minimatch "^3.1.2" object.entries "^1.1.5" object.fromentries "^2.0.5" object.hasown "^1.1.0" object.values "^1.1.5" - prop-types "^15.7.2" + prop-types "^15.8.1" resolve "^2.0.0-next.3" semver "^6.3.0" string.prototype.matchall "^4.0.6" @@ -2203,9 +2204,9 @@ fast-levenshtein@^2.0.6: integrity sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc= fast-redact@^3.0.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.1.0.tgz#37c26cda9cab70bc04393f7ba1feb2d176da6c6b" - integrity sha512-dir8LOnvialLxiXDPESMDHGp82CHi6ZEYTVkcvdn5d7psdv9ZkkButXrOeXST4aqreIRR+N7CYlsrwFuorurVg== + version "3.1.1" + resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.1.1.tgz#790fcff8f808c2e12fabbfb2be5cb2deda448fa0" + integrity sha512-odVmjC8x8jNeMZ3C+rPMESzXVSEU8tSWSHv9HFxP2mm89G/1WwqhrerJDQm9Zus8X6aoRgQDThKqptdNA6bt+A== fast-safe-stringify@^2.0.7, fast-safe-stringify@^2.0.8: version "2.1.1" @@ -2935,7 +2936,7 @@ minimalistic-crypto-utils@^1.0.1: resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= -minimatch@^3.0.4: +minimatch@^3.0.4, minimatch@^3.1.2: version "3.1.2" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== @@ -3206,7 +3207,7 @@ picocolors@^1.0.0: resolved "https://registry.yarnpkg.com/picocolors/-/picocolors-1.0.0.tgz#cb5bdc74ff3f51892236eaf79d68bc44564ab81c" integrity sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ== -picomatch@^2.2.3: +picomatch@^2.2.3, picomatch@^2.3.0: version "2.3.1" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== @@ -3322,7 +3323,7 @@ process-warning@^1.0.0: resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-1.0.0.tgz#980a0b25dc38cd6034181be4b7726d89066b4616" integrity sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q== -prop-types@^15.7.2: +prop-types@^15.7.2, prop-types@^15.8.1: version "15.8.1" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.8.1.tgz#67d87bf1a694f48435cf332c24af10214a3140b5" integrity sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg== From 5bf6c7bc8c87b81d14b39d3819b74594a69bd958 Mon Sep 17 00:00:00 2001 From: Ilja Date: Tue, 1 Mar 2022 15:35:50 +0200 Subject: [PATCH 6/7] add proper types --- wallets/react-wallet-v2/package.json | 1 - wallets/react-wallet-v2/src/utils/CosmosUtil.ts | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/wallets/react-wallet-v2/package.json b/wallets/react-wallet-v2/package.json index 4d8b3f4..24c4506 100644 --- a/wallets/react-wallet-v2/package.json +++ b/wallets/react-wallet-v2/package.json @@ -23,7 +23,6 @@ "valtio": "1.3.1", "react-code-blocks": "0.0.9-0", "@cosmjs/proto-signing": "0.27.1", - "@cosmjs/crypto": "0.27.1", "@cosmjs/encoding": "0.27.1", "@cosmjs/amino": "0.27.1" }, diff --git a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts index 3f81dbf..5e423f4 100644 --- a/wallets/react-wallet-v2/src/utils/CosmosUtil.ts +++ b/wallets/react-wallet-v2/src/utils/CosmosUtil.ts @@ -1,4 +1,4 @@ -import { Secp256k1Wallet } from '@cosmjs/amino' +import { Secp256k1Wallet, StdSignDoc } from '@cosmjs/amino' import { fromHex } from '@cosmjs/encoding' import { DirectSecp256k1Wallet, makeSignBytes } from '@cosmjs/proto-signing' // @ts-expect-error @@ -64,7 +64,7 @@ export class Cosmos { return await this.directSigner.signDirect(address, signDocBytes) } - public async signAmino(address: string, signDoc: SignDoc) { + public async signAmino(address: string, signDoc: StdSignDoc) { return await this.aminoSigner.signAmino(address, signDoc) } } From 320a4e9c61e8e7f7ec1ca2ad6065bc478724cf7e Mon Sep 17 00:00:00 2001 From: Ilja Date: Tue, 1 Mar 2022 15:36:14 +0200 Subject: [PATCH 7/7] remove cosmos wallet --- wallets/react-wallet-v2/package.json | 1 - wallets/react-wallet-v2/yarn.lock | 64 ---------------------------- 2 files changed, 65 deletions(-) diff --git a/wallets/react-wallet-v2/package.json b/wallets/react-wallet-v2/package.json index 24c4506..c4271fc 100644 --- a/wallets/react-wallet-v2/package.json +++ b/wallets/react-wallet-v2/package.json @@ -13,7 +13,6 @@ "@json-rpc-tools/utils": "1.7.6", "@nextui-org/react": "1.0.2-beta.4", "mnemonic-keyring": "1.4.0", - "cosmos-wallet": "1.1.0", "next": "12.1.0", "react": "17.0.2", "react-dom": "17.0.2", diff --git a/wallets/react-wallet-v2/yarn.lock b/wallets/react-wallet-v2/yarn.lock index ad34311..847a587 100644 --- a/wallets/react-wallet-v2/yarn.lock +++ b/wallets/react-wallet-v2/yarn.lock @@ -153,16 +153,6 @@ "@cosmjs/math" "0.27.1" "@cosmjs/utils" "0.27.1" -"@cosmjs/amino@^0.25.4", "@cosmjs/amino@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.25.6.tgz#cdf9632253bfab7b1d2ef967124953d7bf16351f" - integrity sha512-9dXN2W7LHjDtJUGNsQ9ok0DfxeN3ca/TXnxCR3Ikh/5YqBqxI8Gel1J9PQO9L6EheYyh045Wff4bsMaLjyEeqQ== - dependencies: - "@cosmjs/crypto" "^0.25.6" - "@cosmjs/encoding" "^0.25.6" - "@cosmjs/math" "^0.25.6" - "@cosmjs/utils" "^0.25.6" - "@cosmjs/crypto@0.27.1": version "0.27.1" resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.27.1.tgz#271c853089a3baf3acd6cf0b2122fd49f8815743" @@ -179,22 +169,6 @@ ripemd160 "^2.0.2" sha.js "^2.4.11" -"@cosmjs/crypto@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.25.6.tgz#695d2d0d2195bdbdd5825d415385646244900bbb" - integrity sha512-ec+YcQLrg2ibcxtNrh4FqQnG9kG9IE/Aik2NH6+OXQdFU/qFuBTxSFcKDgzzBOChwlkXwydllM9Jjbp+dgIzRw== - dependencies: - "@cosmjs/encoding" "^0.25.6" - "@cosmjs/math" "^0.25.6" - "@cosmjs/utils" "^0.25.6" - bip39 "^3.0.2" - bn.js "^4.11.8" - elliptic "^6.5.3" - js-sha3 "^0.8.0" - libsodium-wrappers "^0.7.6" - ripemd160 "^2.0.2" - sha.js "^2.4.11" - "@cosmjs/encoding@0.27.1": version "0.27.1" resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.27.1.tgz#3cd5bc0af743485eb2578cdb08cfa84c86d610e1" @@ -204,15 +178,6 @@ bech32 "^1.1.4" readonly-date "^1.0.0" -"@cosmjs/encoding@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.25.6.tgz#da741a33eaf063a6d3611d7d68db5ca3938e0ef5" - integrity sha512-0imUOB8XkUstI216uznPaX1hqgvLQ2Xso3zJj5IV5oJuNlsfDj9nt/iQxXWbJuettc6gvrFfpf+Vw2vBZSZ75g== - dependencies: - base64-js "^1.3.0" - bech32 "^1.1.4" - readonly-date "^1.0.0" - "@cosmjs/math@0.27.1": version "0.27.1" resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.27.1.tgz#be78857b008ffc6b1ed6fecaa1c4cd5bc38c07d7" @@ -220,13 +185,6 @@ dependencies: bn.js "^5.2.0" -"@cosmjs/math@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.25.6.tgz#25c7b106aaded889a5b80784693caa9e654b0c28" - integrity sha512-Fmyc9FJ8KMU34n7rdapMJrT/8rx5WhMw2F7WLBu7AVLcBh0yWsXIcMSJCoPHTOnMIiABjXsnrrwEaLrOOBfu6A== - dependencies: - bn.js "^4.11.8" - "@cosmjs/proto-signing@0.27.1": version "0.27.1" resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.27.1.tgz#1f8f662550aab012d957d02f43c77d914c2ae0db" @@ -239,25 +197,11 @@ long "^4.0.0" protobufjs "~6.10.2" -"@cosmjs/proto-signing@^0.25.4": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.25.6.tgz#d9fc57b8e0a46cda97e192bd0435157b24949ff8" - integrity sha512-JpQ+Vnv9s6i3x8f3Jo0lJZ3VMnj3R5sMgX+8ti1LtB7qEYRR85qbDrEG9hDGIKqJJabvrAuCHnO6hYi0vJEJHA== - dependencies: - "@cosmjs/amino" "^0.25.6" - long "^4.0.0" - protobufjs "~6.10.2" - "@cosmjs/utils@0.27.1": version "0.27.1" resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.27.1.tgz#1c8efde17256346ef142a3bd15158ee4055470e2" integrity sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg== -"@cosmjs/utils@^0.25.6": - version "0.25.6" - resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.25.6.tgz#934d9a967180baa66163847616a74358732227ca" - integrity sha512-ofOYiuxVKNo238vCPPlaDzqPXy2AQ/5/nashBo5rvPZJkxt9LciGfUEQWPCOb1BIJDNx2Dzu0z4XCf/dwzl0Dg== - "@emotion/is-prop-valid@^0.8.2", "@emotion/is-prop-valid@^0.8.8": version "0.8.8" resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a" @@ -1690,14 +1634,6 @@ cosmjs-types@^0.4.0: long "^4.0.0" protobufjs "~6.11.2" -cosmos-wallet@1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/cosmos-wallet/-/cosmos-wallet-1.1.0.tgz#ca554d19fda1a1a7a8ee21fef4e0ef8f7fa9ef7b" - integrity sha512-jm5MFRYzvOCA/mhULObpaoE2Na0shBn3lrkv2GDedmRZfuoDvOa63WID4qMoIycteefjRKdxXf+26vDrgd79aQ== - dependencies: - "@cosmjs/amino" "^0.25.4" - "@cosmjs/proto-signing" "^0.25.4" - create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196"