From 05fb0b6e3719591427fcad185a86f92d77130d35 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 24 Jun 2021 17:44:24 +0800 Subject: [PATCH 01/22] Initial implementation --- imports/ui/ledger/LedgerActions.jsx | 4 +- imports/ui/ledger/ledger.js | 110 +++++++- imports/ui/proposals/Proposal.jsx | 4 +- package-lock.json | 416 ++++++++++++++++++++++++++++ package.json | 7 + 5 files changed, 531 insertions(+), 10 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 2e5d76cd0..6bdb14817 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -426,7 +426,7 @@ class LedgerButton extends Component { if (res){ let gasPrice = calculateGasPrice(res) let amountToTransfer = this.state.transferAmount?.amount || this.state.delegateAmount?.amount || this.state.depositAmount?.amount - let totalAmount = this.props.rewards || this.props.commission || this.state.actionType === 'redelegate' || this.state.actionType === 'undelegate'? gasPrice : amountToTransfer + gasPrice; + let totalAmount = this.props.rewards || this.props.commission || this.state.actionType === 'redelegate' || this.state.actionType === 'undelegate' || this.state.actionType === 'vote'? gasPrice : amountToTransfer + gasPrice; if (totalAmount <= this.state.currentUser?.availableCoin?._amount){ Ledger.applyGas(txMsg, res, Meteor.settings.public.ledger.gasPrice, Coin.StakingCoin.denom); this.setStateOnSuccess('simulating', { @@ -452,7 +452,7 @@ class LedgerButton extends Component { let txMsg = this.state.txMsg; const txContext = this.getTxContext(); const bytesToSign = Ledger.getBytesToSign(txMsg, txContext); - this.ledger.sign(bytesToSign, this.state.transportBLE).then((sig) => { + this.ledger.sign(bytesToSign, txMsg, txContext, this.state.transportBLE).then((sig) => { try { Ledger.applySignature(txMsg, txContext, sig); Meteor.call('transaction.submit', txMsg, (err, res) => { diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 330103c63..9e7890f09 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -11,6 +11,20 @@ import bech32 from "bech32"; import sha256 from "crypto-js/sha256" import ripemd160 from "crypto-js/ripemd160" import CryptoJS from "crypto-js" +import { LedgerSigner } from "@cosmjs/ledger-amino"; +import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet } from "@cosmjs/launchpad"; +import { + assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessStargate, + SigningStargateClient, + AminoTypes, + coins +} from "@cosmjs/stargate"; +import { decodeTxRaw, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; +// import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad"; +// import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; +import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; + + // TODO: discuss TIMEOUT value const INTERACTION_TIMEOUT = 10000 @@ -100,7 +114,7 @@ export class Ledger { transport= await TransportWebUSB.create(timeout) } const cosmosLedgerApp = new CosmosApp(transport) - + this.ledgerSigner = this.getLedgerWallet(transport) this.cosmosApp = cosmosLedgerApp await this.isSendingData() @@ -177,13 +191,97 @@ export class Ledger { }) } - async sign(signMessage, transportBLE) { + getLedgerWallet(ledgerTransport) { + return new LedgerSigner(ledgerTransport, { hdPaths: [makeCosmoshubPath(0)] }); + } + + async sign(signMessage, txMsg, txContext, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) + const customRegistry = new Registry(); + + const [firstAccount] = await this.ledgerSigner.getAccounts(); + const msgDelegateTypeUrl = "/cosmos.gov.v1beta1.MsgVote"; + const CustomMsgDelegate = { + encode( + message, + writer + ){ + writer.uint32(10).string(message.option ?? ""); + writer.uint32(18).string(message.proposalId ?? ""); + writer.uint32(18).string(message.voter ?? ""); + return writer; + }, + } + customRegistry.register(msgDelegateTypeUrl, CustomMsgDelegate); + + const customAminoTypes = new AminoTypes({ + additions: { + "/cosmos.gov.v1beta1.MsgVote": { + aminoType: "cosmos-sdk/MsgVote", + toAmino( + option, + proposalId, + voter, + ){ + assert(option, "missing option"); + assert(proposalId, "missing proposalId"); + assert(voter, "missing voter"); + + return { + option: option, + proposal_id: proposalId, + voter:voter + }; + }, + fromAmino( + option, + proposal_id, + voter,) + { + return{ + option: option, + proposalId: proposal_id, + voer: voter + } + } + } + } + }); + const options = { registry: customRegistry, aminoTypes: customAminoTypes }; + console.log("trying to fetch..") + // const client = await SigningCosmWasmClient.connectWithSigner("http://139.162.187.197:1317", this.ledgerSigner, options); - const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) - this.checkLedgerErrors(response) + // const client = await SigningStargateClient.connectWithSigner("http://139.162.187.197:1317", this.ledgerSigner, options); + // console.log(client) + + const msg = { + option: txMsg.value.msg[0].value.option, + proposalId: txMsg.value.msg[0].value.proposal_id, + voter: txMsg.value.msg[0].value.voter + }; + console.log(msg) + const msgAny = { + typeUrl: "/cosmos.gov.v1beta1.MsgVote", + value: msg, + }; + console.log(msgAny) + + const fee = { + amount: coins(Number(txMsg.value.fee.amount[0].amount), txMsg.value.fee.amount[0].denom.toString()), + gas: "200000", + }; + console.log(fee) + + const memo = DEFAULT_MEMO; + const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); + assertIsBroadcastTxSuccess(result); + + + // const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) + // this.checkLedgerErrors(response) // we have to parse the signature from Ledger as it's in DER format - const parsedSignature = signatureImport(response.signature) + const parsedSignature = "" + // signatureImport(response.signature) return parsedSignature } @@ -309,7 +407,7 @@ export class Ledger { } // Creates a new tx skeleton - static createSkeleton(txContext, msgs=[]) { + static createSkeleton(txContext, msgs = []) { if (typeof txContext === 'undefined') { throw new Error('undefined txContext'); } diff --git a/imports/ui/proposals/Proposal.jsx b/imports/ui/proposals/Proposal.jsx index d7ef6f60f..da348950b 100644 --- a/imports/ui/proposals/Proposal.jsx +++ b/imports/ui/proposals/Proposal.jsx @@ -14,7 +14,7 @@ import i18n from 'meteor/universe:i18n'; import { Meteor } from 'meteor/meteor'; import Coin from '/both/utils/coins.js'; import TimeStamp from '../components/TimeStamp.jsx'; -// import { ProposalActionButtons } from '../ledger/LedgerActions.jsx'; +import { ProposalActionButtons } from '../ledger/LedgerActions.jsx'; import voca from 'voca'; const T = i18n.createComponent(); @@ -293,7 +293,7 @@ export default class Proposal extends Component{ proposals.proposalID {this.props.proposal.proposalId} - {/* {this.state.user?:null} */} + {this.state.user?:null} proposals.proposer diff --git a/package-lock.json b/package-lock.json index e68db2b43..252aed392 100644 --- a/package-lock.json +++ b/package-lock.json @@ -173,6 +173,228 @@ "to-fast-properties": "^2.0.0" } }, + "@confio/ics23": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@confio/ics23/-/ics23-0.6.5.tgz", + "integrity": "sha512-1GdPMsaP/l8JSF4P4HWFLBhdcxHcJT8lS0nknBYNSZ1XrJOsJKUy6EkOwd9Pa1qJkXzY2gyNv7MdHR+AIwSTAg==", + "requires": { + "js-sha512": "^0.8.0", + "protobufjs": "^6.8.8", + "ripemd160": "^2.0.2", + "sha.js": "^2.4.11" + } + }, + "@cosmjs/amino": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.25.5.tgz", + "integrity": "sha512-q9tU2b9hJ3S/KxYCLSyiZCfkaidbSPBr2sJ5HPLxz48y5O4k9sYM7bPa0zioeePaIBnby3AOgyjucVxlbzUlYg==", + "requires": { + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/utils": "^0.25.5" + } + }, + "@cosmjs/cosmwasm": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm/-/cosmwasm-0.25.5.tgz", + "integrity": "sha512-PsK28ARcow5hEd+hKAdGsjtjz/g5UMtPpSWD7l1WxWhuASLmJVXFebBUPJAu3CDeFG3FrlCRP5J8tLvJOisuJQ==", + "requires": { + "@cosmjs/cosmwasm-launchpad": "^0.25.5" + } + }, + "@cosmjs/cosmwasm-launchpad": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-launchpad/-/cosmwasm-launchpad-0.25.5.tgz", + "integrity": "sha512-9/Z8m9rfovtgchN1thcdVBEBXCrh5clVNgpVp1rpbkUSSGA7T5tCR8H1qX0+Yd3HLRh212O5EnCfzzXjNxR21A==", + "requires": { + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/launchpad": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "pako": "^2.0.2" + } + }, + "@cosmjs/cosmwasm-stargate": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.25.5.tgz", + "integrity": "sha512-lUwjXMnVO+8iZtqwKr4hEBgA9q03AqAhUBNNyyG8oeTpgASrQ1ZlLjjmBWgvEpw4JokRduDf7il+NNENjaeAhQ==", + "requires": { + "@cosmjs/amino": "^0.25.5", + "@cosmjs/cosmwasm-launchpad": "^0.25.5", + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/proto-signing": "^0.25.5", + "@cosmjs/stargate": "^0.25.5", + "@cosmjs/tendermint-rpc": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "long": "^4.0.0", + "pako": "^2.0.2", + "protobufjs": "~6.10.2" + } + }, + "@cosmjs/crypto": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.25.5.tgz", + "integrity": "sha512-i0Nfbk4JXAwyKNGPFu0o1xV6IJUbYmmveySytbU/yweybcZppxoczjSQ1sGrUaLVLvgfcpfwZte3jKqDR67+dg==", + "requires": { + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "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": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/encoding/-/encoding-0.25.5.tgz", + "integrity": "sha512-QT7MaPBiMeCaMJ6VZZKeOqDQlAxMEzTFjBFhbkdyx5DVRc4dPOVO4HbTggmIN5/eizIv4/CNJSVTR//tO53J0A==", + "requires": { + "base64-js": "^1.3.0", + "bech32": "^1.1.4", + "readonly-date": "^1.0.0" + } + }, + "@cosmjs/json-rpc": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.25.5.tgz", + "integrity": "sha512-WFDallAolxBqB8V/mYxU0riF/OBoc6Fc2DDsZhds5xOZxeN9sTX0qWhu1UiFyURw4Z9D+SjB9QngqSDBTMTdjw==", + "requires": { + "@cosmjs/stream": "^0.25.5", + "xstream": "^11.14.0" + } + }, + "@cosmjs/launchpad": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/launchpad/-/launchpad-0.25.5.tgz", + "integrity": "sha512-7zsFWQHLAiOUBXV/QWvffI/5Ssma67lEO3V01DZ8CtfnWiO4bCSbnU2sslSAH11RkrPdNfRBM7WOBczMMigIzw==", + "requires": { + "@cosmjs/amino": "^0.25.5", + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "axios": "^0.21.1", + "fast-deep-equal": "^3.1.3" + }, + "dependencies": { + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==" + } + } + }, + "@cosmjs/ledger-amino": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/ledger-amino/-/ledger-amino-0.25.5.tgz", + "integrity": "sha512-Ml9i0NQkJBKChn6hvcr4R8EBp/P6EaCQCO7FOLBMBSazbwqV/F/MtUuNjMNAjPlMrWkFVzJwUq73ZRx+MM6GQw==", + "requires": { + "@cosmjs/amino": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "ledger-cosmos-js": "^2.1.8", + "semver": "^7.3.2" + }, + "dependencies": { + "semver": { + "version": "7.3.5", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.5.tgz", + "integrity": "sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, + "@cosmjs/math": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/math/-/math-0.25.5.tgz", + "integrity": "sha512-LWovT1uTHlr+VEce27/14Wrgc4INJYOYk1+ncyvbZertixNFH6OMnc9Xkk0DIV4RYmW+/fvB9kCXVnNtQGSuHg==", + "requires": { + "bn.js": "^4.11.8" + } + }, + "@cosmjs/proto-signing": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.25.5.tgz", + "integrity": "sha512-YWVp+dGHt7v6ZKjOs8CI9xkpOV49eweHbYMv/vCVYF4cEh0kWwy2WzbWIkUH9zwwUqCxigVOTBYUCfbsjEbfug==", + "requires": { + "@cosmjs/amino": "^0.25.5", + "long": "^4.0.0", + "protobufjs": "~6.10.2" + } + }, + "@cosmjs/socket": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.25.5.tgz", + "integrity": "sha512-wcJVbD4xlF4+5hMum4tOmAy5ppX+E9qrB9Pvt3T7BK+6T5uobxiBQCLEiDwHP3n42RBj+xQWJrScPf5IEWmZKg==", + "requires": { + "@cosmjs/stream": "^0.25.5", + "isomorphic-ws": "^4.0.1", + "ws": "^7", + "xstream": "^11.14.0" + }, + "dependencies": { + "ws": { + "version": "7.5.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", + "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==" + } + } + }, + "@cosmjs/stargate": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.25.5.tgz", + "integrity": "sha512-cOZ+fOC16YT7W2vjBnnk9oJfuIlB02KdK6dn6aigMd4mx+7DS2jvNslpQrfKmtrwB9AVsgc6tklBkYwG5qAuKQ==", + "requires": { + "@confio/ics23": "^0.6.3", + "@cosmjs/amino": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/proto-signing": "^0.25.5", + "@cosmjs/stream": "^0.25.5", + "@cosmjs/tendermint-rpc": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "long": "^4.0.0", + "protobufjs": "~6.10.2" + } + }, + "@cosmjs/stream": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.25.5.tgz", + "integrity": "sha512-a+0sDNKZTxw9p4j5tl7SI0siMTii7AQot1+5vkH5BkQoAv3C3D8jagPouUz3RUFuh13qftPxPLiHzDFLNSjTnQ==", + "requires": { + "xstream": "^11.14.0" + } + }, + "@cosmjs/tendermint-rpc": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.25.5.tgz", + "integrity": "sha512-WlUCFVdhbwA3IDA1C858S8WOtLseZLXKTdj5fz1sTKSBmtrig4l1ZMKHHlZRprvmjSpkpbjgSQU+RjjvBd75BA==", + "requires": { + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/json-rpc": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/socket": "^0.25.5", + "@cosmjs/stream": "^0.25.5", + "axios": "^0.21.1", + "readonly-date": "^1.0.0", + "xstream": "^11.14.0" + } + }, + "@cosmjs/utils": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.25.5.tgz", + "integrity": "sha512-U4YdgJadFgXWblthgyXqP28Yw5rsw2IX/cOES0pa6fiB81hoYl2LXqXiuKp2yVPoAgk8JpkFh3i5KchcD9muJg==" + }, "@emotion/is-prop-valid": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.7.3.tgz", @@ -294,6 +516,60 @@ } } }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, "@types/d3": { "version": "4.13.12", "resolved": "https://registry.npmjs.org/@types/d3/-/d3-4.13.12.tgz", @@ -538,6 +814,11 @@ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.163.tgz", "integrity": "sha512-BeZM/FZaV53emqyHxn9L39Oz6XbHMBRLA1b1quROku48J/1kYYxPmVOJ/qSQheb81on4BI7H6QDo6bkUuRaDNQ==" }, + "@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + }, "@types/meteor-universe-i18n": { "version": "1.14.5", "resolved": "https://registry.npmjs.org/@types/meteor-universe-i18n/-/meteor-universe-i18n-1.14.5.tgz", @@ -1333,6 +1614,11 @@ "resolved": "https://registry.npmjs.org/base16/-/base16-1.0.0.tgz", "integrity": "sha1-4pf2DX7BAUp6lxo568ipjAtoHnA=" }, + "base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" + }, "bech32": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/bech32/-/bech32-1.1.4.tgz", @@ -1351,6 +1637,24 @@ "file-uri-to-path": "1.0.0" } }, + "bip39": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/bip39/-/bip39-3.0.4.tgz", + "integrity": "sha512-YZKQlb752TrUWqHWj7XAwCSjYEgGAk+/Aas3V7NyjQeZYsztO8JnQUaCWhcnL4T+jL8nvB8typ2jRPzTlgugNw==", + "requires": { + "@types/node": "11.11.6", + "create-hash": "^1.1.0", + "pbkdf2": "^3.0.9", + "randombytes": "^2.0.1" + }, + "dependencies": { + "@types/node": { + "version": "11.11.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-11.11.6.tgz", + "integrity": "sha512-Exw4yUWMBXM3X+8oqzJNRqZSwUAaS4+7NdvHqQuFi/d+synz++xmX3QIf+BFqneW8N31R8Ky+sikfZUXq07ggQ==" + } + } + }, "bip66": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", @@ -3373,6 +3677,14 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, + "globalthis": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.2.tgz", + "integrity": "sha512-ZQnSFO1la8P7auIOQECnm0sSuoMeaSq0EEdXMBFF2QJO4uNcwbyhSgG3MruWNbFTqCLmxVwGOl7LZ9kASvHdeQ==", + "requires": { + "define-properties": "^1.1.3" + } + }, "graceful-fs": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", @@ -3763,6 +4075,11 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" + }, "jquery": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", @@ -3773,6 +4090,16 @@ "resolved": "https://registry.npmjs.org/js-sha256/-/js-sha256-0.9.0.tgz", "integrity": "sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==" }, + "js-sha3": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", + "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" + }, + "js-sha512": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz", + "integrity": "sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -3962,6 +4289,19 @@ "type-check": "~0.3.2" } }, + "libsodium": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/libsodium/-/libsodium-0.7.9.tgz", + "integrity": "sha512-gfeADtR4D/CM0oRUviKBViMGXZDgnFdMKMzHsvBdqLBHd9ySi6EtYnmuhHVDDYgYpAO8eU8hEY+F8vIUAPh08A==" + }, + "libsodium-wrappers": { + "version": "0.7.9", + "resolved": "https://registry.npmjs.org/libsodium-wrappers/-/libsodium-wrappers-0.7.9.tgz", + "integrity": "sha512-9HaAeBGk1nKTRFRHkt7nzxqCvnkWTjn1pdjKgcUnZxj0FyOP4CnhgFhMdrFfgNsukijBGyBLpP2m2uKT1vuWhQ==", + "requires": { + "libsodium": "^0.7.0" + } + }, "load-json-file": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", @@ -3999,6 +4339,11 @@ "resolved": "https://registry.npmjs.org/lodash.flow/-/lodash.flow-3.5.0.tgz", "integrity": "sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o=" }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5183,6 +5528,11 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, + "pako": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.3.tgz", + "integrity": "sha512-WjR1hOeg+kki3ZIOjaf4b5WVcay1jaliKSYiEaB1XzwhMQZJxRdQRv0V31EKBYlxb4T7SK3hjfc/jxyU64BoSw==" + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -5273,6 +5623,18 @@ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true }, + "pbkdf2": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.1.2.tgz", + "integrity": "sha512-iuh7L6jA7JEGu2WxDwtQP1ddOpaJNC4KlDEFfdQajSGgGPNi4OyDc2R7QnbY2bR9QjBVGwgvTdNJZoE7RaxUMA==", + "requires": { + "create-hash": "^1.1.2", + "create-hmac": "^1.1.4", + "ripemd160": "^2.0.1", + "safe-buffer": "^5.0.1", + "sha.js": "^2.4.8" + } + }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", @@ -5670,6 +6032,33 @@ "react-is": "^16.8.1" } }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "requires": { + "@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" + }, + "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + } + } + }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", @@ -5700,6 +6089,14 @@ "resolved": "https://registry.npmjs.org/pure-color/-/pure-color-1.3.0.tgz", "integrity": "sha1-H+Bk+wrIUfDeYTIKi/eWg2Qi8z4=" }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "requires": { + "safe-buffer": "^5.1.0" + } + }, "react": { "version": "16.14.0", "resolved": "https://registry.npmjs.org/react/-/react-16.14.0.tgz", @@ -5962,6 +6359,11 @@ "util-deprecate": "^1.0.1" } }, + "readonly-date": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/readonly-date/-/readonly-date-1.0.0.tgz", + "integrity": "sha512-tMKIV7hlk0h4mO3JTmmVuIlJVXjKk3Sep9Bf5OH0O+758ruuVkUy2J9SttDLm91IEX/WHlXPSpxMGjPj4beMIQ==" + }, "regenerator-runtime": { "version": "0.13.7", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz", @@ -6774,6 +7176,11 @@ "has-flag": "^3.0.0" } }, + "symbol-observable": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-2.0.3.tgz", + "integrity": "sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA==" + }, "table": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", @@ -7240,6 +7647,15 @@ "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" }, + "xstream": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/xstream/-/xstream-11.14.0.tgz", + "integrity": "sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw==", + "requires": { + "globalthis": "^1.0.1", + "symbol-observable": "^2.0.3" + } + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 66660a810..e01cb7936 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,13 @@ }, "dependencies": { "@babel/runtime": "^7.13.17", + "@cosmjs/cosmwasm": "^0.25.5", + "@cosmjs/cosmwasm-launchpad": "^0.25.5", + "@cosmjs/cosmwasm-stargate": "^0.25.5", + "@cosmjs/launchpad": "^0.25.5", + "@cosmjs/ledger-amino": "^0.25.5", + "@cosmjs/proto-signing": "^0.25.5", + "@cosmjs/stargate": "^0.25.5", "@ledgerhq/hw-transport-web-ble": "^5.50.0", "@ledgerhq/hw-transport-webusb": "^5.53.0", "@types/meteor-universe-i18n": "^1.14.5", From a5a6a377e3cdf6e468444555e1e874ca43fb311f Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Fri, 25 Jun 2021 19:14:21 +0800 Subject: [PATCH 02/22] Update vote options --- imports/ui/ledger/LedgerActions.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 6bdb14817..79a801786 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -968,10 +968,10 @@ class ProposalActionButtons extends LedgerButton { title=`Vote on Proposal ${this.props.proposalId}` inputs = ( - - - - + + + + ) break; case Types.DEPOSIT: @@ -1018,7 +1018,7 @@ class ProposalActionButtons extends LedgerButton { isDataValid = () => { if (!this.state.currentUser) return false if (this.state.actionType === Types.VOTE) { - return ['Yes', 'No', 'NoWithVeto', 'Abstain'].indexOf(this.state.voteOption) !== -1; + return ['VOTE_OPTION_YES', 'VOTE_OPTION_NO', 'VOTE_OPTION_NO_WITH_VETO', 'VOTE_OPTION_ABSTAIN'].indexOf(this.state.voteOption) !== -1; } else { return isBetween(this.state.depositAmount, 1, this.state.currentUser.availableCoin) } From 74f81158c7a7e1cb2c061cc71b173722434facd0 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Fri, 25 Jun 2021 19:18:42 +0800 Subject: [PATCH 03/22] Updated AminoTypes, signing --- imports/ui/ledger/ledger.js | 69 +++++++++++++++++-------------------- package.json | 1 + 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 9e7890f09..4f3b7f16e 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -17,8 +17,10 @@ import { assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessStargate, SigningStargateClient, AminoTypes, - coins + coins, + StargateClient } from "@cosmjs/stargate"; +import { assert, sleep } from "@cosmjs/utils"; import { decodeTxRaw, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; // import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad"; // import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; @@ -32,6 +34,7 @@ const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersi const DEFAULT_DENOM = Meteor.settings.public.bondDenom || 'uatom'; export const DEFAULT_GAS_PRICE = parseFloat(Meteor.settings.public.ledger.gasPrice) || 0.025; export const DEFAULT_MEMO = 'Sent via Big Dipper' +const RPC = "http://139.162.187.197:26657" /* HD wallet derivation path (BIP44) @@ -198,15 +201,14 @@ export class Ledger { async sign(signMessage, txMsg, txContext, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) const customRegistry = new Registry(); - const [firstAccount] = await this.ledgerSigner.getAccounts(); const msgDelegateTypeUrl = "/cosmos.gov.v1beta1.MsgVote"; const CustomMsgDelegate = { encode( - message, + message = txMsg.value.msg[0].value, writer ){ - writer.uint32(10).string(message.option ?? ""); + writer.uint32(10).string(txMsg.value.msg[0].value.option || ""); writer.uint32(18).string(message.proposalId ?? ""); writer.uint32(18).string(message.voter ?? ""); return writer; @@ -218,41 +220,31 @@ export class Ledger { additions: { "/cosmos.gov.v1beta1.MsgVote": { aminoType: "cosmos-sdk/MsgVote", - toAmino( - option, - proposalId, - voter, - ){ - assert(option, "missing option"); - assert(proposalId, "missing proposalId"); - assert(voter, "missing voter"); - - return { - option: option, - proposal_id: proposalId, - voter:voter - }; - }, - fromAmino( - option, - proposal_id, - voter,) - { - return{ - option: option, - proposalId: proposal_id, - voer: voter - } - } + toAmino: ({ option = txMsg.value.msg[0].value.option, + proposalId = txMsg.value.msg[0].value.proposal_id, + voter = txMsg.value.msg[0].value.voter + }) => ({ + option: option, + proposal_id: proposalId, + voter: voter + }), + fromAmino: ({ option = txMsg.value.msg[0].value.option, + proposal_id = txMsg.value.msg[0].value.proposal_id, + voter = txMsg.value.msg[0].value.voter + }) => ({ + option: option, + proposalId: proposal_id, + voer: voter + }), } } }); - const options = { registry: customRegistry, aminoTypes: customAminoTypes }; - console.log("trying to fetch..") - // const client = await SigningCosmWasmClient.connectWithSigner("http://139.162.187.197:1317", this.ledgerSigner, options); - // const client = await SigningStargateClient.connectWithSigner("http://139.162.187.197:1317", this.ledgerSigner, options); - // console.log(client) + const options = { registry: customRegistry, aminoTypes: customAminoTypes }; + // const client = await SigningCosmWasmClient.connectWithSigner(RPC, this.ledgerSigner); + // const client = await StargateClient.connect(RPC); + const client = await SigningStargateClient.connectWithSigner(RPC, this.ledgerSigner, options) + console.log(client) const msg = { option: txMsg.value.msg[0].value.option, @@ -273,8 +265,11 @@ export class Ledger { console.log(fee) const memo = DEFAULT_MEMO; - const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); - assertIsBroadcastTxSuccess(result); + const signed = await client.sign(txContext.bech32, [msgAny], fee, memo) + // const signed = await client.signAmino(txContext.bech32, [msgAny], fee, memo, { accountNumber: txContext.accountNumber, sequence: txContext.sequence, chainId:txContext.chainId }); + console.log(signed) + // const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); + // assertIsBroadcastTxSuccess(result); // const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) diff --git a/package.json b/package.json index e01cb7936..5a3503c15 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "@cosmjs/ledger-amino": "^0.25.5", "@cosmjs/proto-signing": "^0.25.5", "@cosmjs/stargate": "^0.25.5", + "@cosmjs/utils": "^0.25.5", "@ledgerhq/hw-transport-web-ble": "^5.50.0", "@ledgerhq/hw-transport-webusb": "^5.53.0", "@types/meteor-universe-i18n": "^1.14.5", From c9feaa592ddbc154349fd7d357c1181223cb920d Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 28 Jun 2021 18:46:36 +0800 Subject: [PATCH 04/22] Updated CustomMsgType, customAminoTypes and sign --- imports/ui/ledger/ledger.js | 99 ++++++++++++++++++++++++++----------- package-lock.json | 81 ++++++++++++++++++++++++++++++ package.json | 2 + 3 files changed, 154 insertions(+), 28 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 4f3b7f16e..956e82bd8 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -12,7 +12,7 @@ import sha256 from "crypto-js/sha256" import ripemd160 from "crypto-js/ripemd160" import CryptoJS from "crypto-js" import { LedgerSigner } from "@cosmjs/ledger-amino"; -import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet } from "@cosmjs/launchpad"; +import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet, makeStdTx} from "@cosmjs/launchpad"; import { assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessStargate, SigningStargateClient, @@ -25,6 +25,8 @@ import { decodeTxRaw, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-si // import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad"; // import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; +import protobuf from "protobufjs/minimal"; +import { Fee, Tx, TxRaw } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx"; @@ -202,50 +204,81 @@ export class Ledger { await this.connect(INTERACTION_TIMEOUT, transportBLE) const customRegistry = new Registry(); const [firstAccount] = await this.ledgerSigner.getAccounts(); - const msgDelegateTypeUrl = "/cosmos.gov.v1beta1.MsgVote"; - const CustomMsgDelegate = { + const msgVoteTypeUrl = "/cosmos.gov.v1beta1.MsgVote"; + const CustomMsgVote = { encode( - message = txMsg.value.msg[0].value, - writer - ){ - writer.uint32(10).string(txMsg.value.msg[0].value.option || ""); + message, + writer = protobuf.Writer.create(), + ) { + writer.uint32(10).string(message.option || ""); writer.uint32(18).string(message.proposalId ?? ""); writer.uint32(18).string(message.voter ?? ""); return writer; }, - } - customRegistry.register(msgDelegateTypeUrl, CustomMsgDelegate); + + decode() { + throw new Error("decode method should not be required"); + }, + fromJSON() { + throw new Error("fromJSON method should not be required"); + }, + fromPartial(object) { + const message = { + option: "", + proposalId: "", + voter: "" + }; + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } else { + message.option = ""; + } + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = ""; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter + } else { + message.voter = undefined; + } + return message; + }, + toJSON() { + throw new Error("toJSON method should not be required"); + }, + }; + customRegistry.register(msgVoteTypeUrl, CustomMsgVote); const customAminoTypes = new AminoTypes({ additions: { "/cosmos.gov.v1beta1.MsgVote": { aminoType: "cosmos-sdk/MsgVote", - toAmino: ({ option = txMsg.value.msg[0].value.option, - proposalId = txMsg.value.msg[0].value.proposal_id, - voter = txMsg.value.msg[0].value.voter + toAmino: ({ option, + proposalId, + voter }) => ({ option: option, proposal_id: proposalId, voter: voter }), - fromAmino: ({ option = txMsg.value.msg[0].value.option, - proposal_id = txMsg.value.msg[0].value.proposal_id, - voter = txMsg.value.msg[0].value.voter + fromAmino: ({ option, + proposal_id, + voter }) => ({ option: option, proposalId: proposal_id, - voer: voter + voter: voter }), } } }); - const options = { registry: customRegistry, aminoTypes: customAminoTypes }; + const options = { prefix: 'cosmos', registry: customRegistry, aminoTypes: customAminoTypes }; // const client = await SigningCosmWasmClient.connectWithSigner(RPC, this.ledgerSigner); // const client = await StargateClient.connect(RPC); const client = await SigningStargateClient.connectWithSigner(RPC, this.ledgerSigner, options) - console.log(client) - const msg = { option: txMsg.value.msg[0].value.option, proposalId: txMsg.value.msg[0].value.proposal_id, @@ -254,7 +287,7 @@ export class Ledger { console.log(msg) const msgAny = { typeUrl: "/cosmos.gov.v1beta1.MsgVote", - value: msg, + value: CustomMsgVote.fromPartial(msg), }; console.log(msgAny) @@ -265,19 +298,29 @@ export class Ledger { console.log(fee) const memo = DEFAULT_MEMO; - const signed = await client.sign(txContext.bech32, [msgAny], fee, memo) - // const signed = await client.signAmino(txContext.bech32, [msgAny], fee, memo, { accountNumber: txContext.accountNumber, sequence: txContext.sequence, chainId:txContext.chainId }); - console.log(signed) - // const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); + // const signed = await client.sign(txContext.bech32, [msgAny], fee, memo) + // const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); // assertIsBroadcastTxSuccess(result); + // const signed = await client.signAmino(txContext.bech32, [msgAny], fee, memo, { accountNumber: txContext.accountNumber, sequence: txContext.sequence, chainId:txContext.chainId }); + // console.log(signed) + // let broadcast = await client.broadcastTx(signed) + // console.loog(broadcast) + + // const signedTx = makeStdTx(signed, signed.signatures); + // console.log(signedTx) + + const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); + console.log(result) + assertIsBroadcastTxSuccess(result); + + // const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) // this.checkLedgerErrors(response) // we have to parse the signature from Ledger as it's in DER format - const parsedSignature = "" - // signatureImport(response.signature) - return parsedSignature + // const parsedSignature = signatureImport(response.signature) + return "" } /* istanbul ignore next: maps a bunch of errors */ @@ -559,7 +602,7 @@ export class Ledger { type: 'cosmos-sdk/MsgVote', value: { option, - proposal_id: proposalId.toString(), + proposal_id: (proposalId).toString(), voter: txContext.bech32 } }; diff --git a/package-lock.json b/package-lock.json index 252aed392..956cd4fe9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -233,6 +233,33 @@ "long": "^4.0.0", "pako": "^2.0.2", "protobufjs": "~6.10.2" + }, + "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "requires": { + "@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" + } + } } }, "@cosmjs/crypto": { @@ -329,6 +356,33 @@ "@cosmjs/amino": "^0.25.5", "long": "^4.0.0", "protobufjs": "~6.10.2" + }, + "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "requires": { + "@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" + } + } } }, "@cosmjs/socket": { @@ -364,6 +418,33 @@ "@cosmjs/utils": "^0.25.5", "long": "^4.0.0", "protobufjs": "~6.10.2" + }, + "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "requires": { + "@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" + } + } } }, "@cosmjs/stream": { diff --git a/package.json b/package.json index 5a3503c15..c8f99587b 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,14 @@ "js-sha256": "^0.9.0", "ledger-cosmos-js": "^2.1.8", "lodash": "^4.17.21", + "long": "^4.0.0", "meteor-node-stubs": "^0.4.1", "moment": "^2.27.0", "moment-timezone": "^0.5.33", "numbro": "^2.3.2", "plottable": "^3.9.0", "prop-types": "^15.7.2", + "protobufjs": "^6.10.2", "react": "^16.14.0", "react-chartjs-2": "^2.11.1", "react-dom": "^16.13.1", From ece818865acf7b1cf70470d993ea971c931013ee Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Jul 2021 16:35:04 +0800 Subject: [PATCH 05/22] Implmeneted proposal voting with ledger --- imports/ui/ledger/LedgerActions.jsx | 51 +++++--- imports/ui/ledger/ledger.js | 187 ++++++++++------------------ 2 files changed, 100 insertions(+), 138 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 79a801786..9310bb854 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -452,23 +452,34 @@ class LedgerButton extends Component { let txMsg = this.state.txMsg; const txContext = this.getTxContext(); const bytesToSign = Ledger.getBytesToSign(txMsg, txContext); - this.ledger.sign(bytesToSign, txMsg, txContext, this.state.transportBLE).then((sig) => { - try { - Ledger.applySignature(txMsg, txContext, sig); - Meteor.call('transaction.submit', txMsg, (err, res) => { - if (err) { - this.setStateOnError('signing', err.reason) - } else if (res) { - this.setStateOnSuccess('signing', { - txHash: res, - activeTab: '4' - }) - } + + if (txMsg.value.msg[0].type === "cosmos-sdk/MsgVote"){ + this.ledger.signAmino(txMsg, txContext, this.state.transportBLE).then((res) => { + this.setStateOnSuccess('signing', { + txHash: res, + activeTab: '4' }) - } catch (e) { - this.setStateOnError('signing', e.message) - } - }, (err) => this.setStateOnError('signing', err.message)) + }, (err) => this.setStateOnError('signing', err.message)) + } + else{ + this.ledger.sign(bytesToSign, this.state.transportBLE).then((sig) => { + try { + Ledger.applySignature(txMsg, txContext, sig); + Meteor.call('transaction.submit', txMsg, (err, res) => { + if (err) { + this.setStateOnError('signing', err.reason) + } else if (res) { + this.setStateOnSuccess('signing', { + txHash: res, + activeTab: '4' + }) + } + }) + } catch (e) { + this.setStateOnError('signing', e.message) + } + }, (err) => this.setStateOnError('signing', err.message)) + } } catch (e) { this.setStateOnError('signing', e.message) } @@ -960,7 +971,6 @@ class ProposalActionButtons extends LedgerButton { renderActionTab = () => { if (!this.state.currentUser) return null; let maxAmount = this.state.currentUser.availableCoin; - let inputs; let title; switch (this.state.actionType) { @@ -982,8 +992,8 @@ class ProposalActionButtons extends LedgerButton { min={Coin.MinStake} max={maxAmount.stakingAmount} type="number" invalid={this.state.depositAmount != null && !isBetween(this.state.depositAmount, 1, maxAmount)}/> {Coin.StakingCoin.displayName} -
your available balance:
- ) + + ) break; } return @@ -991,6 +1001,7 @@ class ProposalActionButtons extends LedgerButton { {inputs} + {this.state.actionType === 'deposit' ?
your available balance:
: null}
} @@ -1027,7 +1038,7 @@ class ProposalActionButtons extends LedgerButton { getConfirmationMessage = () => { switch (this.state.actionType) { case Types.VOTE: - return You are voting {this.state.voteOption} on proposal {this.props.proposalId} + return You are voting {this.state.voteOption?.substring(12).replace(/_/g, " ")} on proposal {this.props.proposalId} with . break; diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 956e82bd8..18abe039a 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -12,7 +12,7 @@ import sha256 from "crypto-js/sha256" import ripemd160 from "crypto-js/ripemd160" import CryptoJS from "crypto-js" import { LedgerSigner } from "@cosmjs/ledger-amino"; -import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet, makeStdTx} from "@cosmjs/launchpad"; +import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet, makeStdTx, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; import { assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessStargate, SigningStargateClient, @@ -36,7 +36,7 @@ const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersi const DEFAULT_DENOM = Meteor.settings.public.bondDenom || 'uatom'; export const DEFAULT_GAS_PRICE = parseFloat(Meteor.settings.public.ledger.gasPrice) || 0.025; export const DEFAULT_MEMO = 'Sent via Big Dipper' -const RPC = "http://139.162.187.197:26657" +const API = Meteor.settings.public.remote.api /* HD wallet derivation path (BIP44) @@ -200,128 +200,79 @@ export class Ledger { return new LedgerSigner(ledgerTransport, { hdPaths: [makeCosmoshubPath(0)] }); } - async sign(signMessage, txMsg, txContext, transportBLE) { + async sign(signMessage, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) - const customRegistry = new Registry(); - const [firstAccount] = await this.ledgerSigner.getAccounts(); - const msgVoteTypeUrl = "/cosmos.gov.v1beta1.MsgVote"; - const CustomMsgVote = { - encode( - message, - writer = protobuf.Writer.create(), - ) { - writer.uint32(10).string(message.option || ""); - writer.uint32(18).string(message.proposalId ?? ""); - writer.uint32(18).string(message.voter ?? ""); - return writer; - }, - - decode() { - throw new Error("decode method should not be required"); - }, - fromJSON() { - throw new Error("fromJSON method should not be required"); - }, - fromPartial(object) { - const message = { - option: "", - proposalId: "", - voter: "" - }; - if (object.option !== undefined && object.option !== null) { - message.option = object.option; - } else { - message.option = ""; - } - if (object.proposalId !== undefined && object.proposalId !== null) { - message.proposalId = object.proposalId; - } else { - message.proposalId = ""; - } - if (object.voter !== undefined && object.voter !== null) { - message.voter = object.voter - } else { - message.voter = undefined; - } - return message; - }, - toJSON() { - throw new Error("toJSON method should not be required"); - }, - }; - customRegistry.register(msgVoteTypeUrl, CustomMsgVote); - - const customAminoTypes = new AminoTypes({ - additions: { - "/cosmos.gov.v1beta1.MsgVote": { - aminoType: "cosmos-sdk/MsgVote", - toAmino: ({ option, - proposalId, - voter - }) => ({ - option: option, - proposal_id: proposalId, - voter: voter - }), - fromAmino: ({ option, - proposal_id, - voter - }) => ({ - option: option, - proposalId: proposal_id, - voter: voter - }), - } - } - }); - - const options = { prefix: 'cosmos', registry: customRegistry, aminoTypes: customAminoTypes }; - // const client = await SigningCosmWasmClient.connectWithSigner(RPC, this.ledgerSigner); - // const client = await StargateClient.connect(RPC); - const client = await SigningStargateClient.connectWithSigner(RPC, this.ledgerSigner, options) - const msg = { - option: txMsg.value.msg[0].value.option, - proposalId: txMsg.value.msg[0].value.proposal_id, - voter: txMsg.value.msg[0].value.voter - }; - console.log(msg) - const msgAny = { - typeUrl: "/cosmos.gov.v1beta1.MsgVote", - value: CustomMsgVote.fromPartial(msg), - }; - console.log(msgAny) - const fee = { - amount: coins(Number(txMsg.value.fee.amount[0].amount), txMsg.value.fee.amount[0].denom.toString()), - gas: "200000", - }; - console.log(fee) - - const memo = DEFAULT_MEMO; - // const signed = await client.sign(txContext.bech32, [msgAny], fee, memo) - // const result = await client.broadcastTx(Uint8Array.from(TxRaw.encode(signed).finish())); - // assertIsBroadcastTxSuccess(result); - - - // const signed = await client.signAmino(txContext.bech32, [msgAny], fee, memo, { accountNumber: txContext.accountNumber, sequence: txContext.sequence, chainId:txContext.chainId }); - // console.log(signed) - // let broadcast = await client.broadcastTx(signed) - // console.loog(broadcast) + const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) + this.checkLedgerErrors(response) + // we have to parse the signature from Ledger as it's in DER format + const parsedSignature = signatureImport(response.signature) + return parsedSignature + } - // const signedTx = makeStdTx(signed, signed.signatures); - // console.log(signedTx) + async signAmino(txMsg, txContext, transportBLE) { + await this.connect(INTERACTION_TIMEOUT, transportBLE) + let address = txContext.bech32; + let fee = txMsg.value.fee; + let chainId = txContext.chainId; + let accountNumber = txContext.accountNumber.toString(); + let sequence = txContext.sequence.toString(); + let signResponse, proposalResult; + + const getVoteOption = (option) =>{ + switch (option) { + case "VOTE_OPTION_YES": + return 1; + case "VOTE_OPTION_ABSTAIN": + return 2; + case "VOTE_OPTION_NO": + return 3; + case "VOTE_OPTION_NO_WITH_VETO": + return 4; + } + } - const result = await client.signAndBroadcast(txContext.bech32, [msgAny], fee, memo); - console.log(result) - assertIsBroadcastTxSuccess(result); + const client = new SigningCosmosClient(API, address, this.ledgerSigner, undefined, undefined, 'sync') + txMsg.value.msg[0].value.option = getVoteOption(txMsg.value.msg[0].value.option) + let msgs = txMsg.value.msg[0] + const signDoc = makeSignDoc( + [msgs], + fee, + chainId, + DEFAULT_MEMO, + accountNumber, + sequence + ); + + try{ + signResponse = await this.ledgerSigner.signAmino( + txContext.bech32, + signDoc, + ); + } + catch(e){ + console.log(e) + } + const proposalTx = { + msg: [msgs], + fee: fee, + memo: DEFAULT_MEMO, + signatures: [signResponse.signature], + }; - // const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) - // this.checkLedgerErrors(response) - // we have to parse the signature from Ledger as it's in DER format - // const parsedSignature = signatureImport(response.signature) - return "" - } + try{ + proposalResult = await client.broadcastTx(proposalTx); + await sleep(75); + assertIsBroadcastTxSuccess(proposalResult); + } + catch(e){ + console.log(e) + } + + return proposalResult.transactionHash + + }; /* istanbul ignore next: maps a bunch of errors */ checkLedgerErrors( From 0e5dfcfff44c7a4dfb01e60d53e1174d9f35617d Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Jul 2021 16:43:47 +0800 Subject: [PATCH 06/22] code cleanup --- imports/ui/ledger/ledger.js | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 18abe039a..5ceb787c2 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -12,22 +12,8 @@ import sha256 from "crypto-js/sha256" import ripemd160 from "crypto-js/ripemd160" import CryptoJS from "crypto-js" import { LedgerSigner } from "@cosmjs/ledger-amino"; -import { GasLimits, GasPrice, makeCosmoshubPath, OfflineSigner, Secp256k1HdWallet, makeStdTx, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; -import { - assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessStargate, - SigningStargateClient, - AminoTypes, - coins, - StargateClient -} from "@cosmjs/stargate"; -import { assert, sleep } from "@cosmjs/utils"; -import { decodeTxRaw, DirectSecp256k1HdWallet, Registry } from "@cosmjs/proto-signing"; -// import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-launchpad"; -// import { SigningCosmWasmClient } from "@cosmjs/cosmwasm"; -import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate"; -import protobuf from "protobufjs/minimal"; -import { Fee, Tx, TxRaw } from "@cosmjs/stargate/build/codec/cosmos/tx/v1beta1/tx"; - +import { makeCosmoshubPath, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; +import { sleep } from "@cosmjs/utils"; // TODO: discuss TIMEOUT value @@ -217,7 +203,7 @@ export class Ledger { let chainId = txContext.chainId; let accountNumber = txContext.accountNumber.toString(); let sequence = txContext.sequence.toString(); - let signResponse, proposalResult; + let signAmino, proposalResult; const getVoteOption = (option) =>{ switch (option) { @@ -245,9 +231,9 @@ export class Ledger { ); try{ - signResponse = await this.ledgerSigner.signAmino( + signAmino = await this.ledgerSigner.signAmino( txContext.bech32, - signDoc, + signDoc ); } catch(e){ @@ -258,7 +244,7 @@ export class Ledger { msg: [msgs], fee: fee, memo: DEFAULT_MEMO, - signatures: [signResponse.signature], + signatures: [signAmino.signature], }; try{ @@ -269,8 +255,8 @@ export class Ledger { catch(e){ console.log(e) } - - return proposalResult.transactionHash + + return proposalResult?.transactionHash ?? '' }; @@ -396,7 +382,7 @@ export class Ledger { } // Creates a new tx skeleton - static createSkeleton(txContext, msgs = []) { + static createSkeleton(txContext, msgs=[]) { if (typeof txContext === 'undefined') { throw new Error('undefined txContext'); } @@ -553,7 +539,7 @@ export class Ledger { type: 'cosmos-sdk/MsgVote', value: { option, - proposal_id: (proposalId).toString(), + proposal_id: proposalId.toString(), voter: txContext.bech32 } }; From d23da51b340524d32461816b160bf88c2f96e10a Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Jul 2021 16:55:49 +0800 Subject: [PATCH 07/22] Removed unused packages --- package-lock.json | 247 ---------------------------------------------- package.json | 5 - 2 files changed, 252 deletions(-) diff --git a/package-lock.json b/package-lock.json index 956cd4fe9..98dd19e7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -173,17 +173,6 @@ "to-fast-properties": "^2.0.0" } }, - "@confio/ics23": { - "version": "0.6.5", - "resolved": "https://registry.npmjs.org/@confio/ics23/-/ics23-0.6.5.tgz", - "integrity": "sha512-1GdPMsaP/l8JSF4P4HWFLBhdcxHcJT8lS0nknBYNSZ1XrJOsJKUy6EkOwd9Pa1qJkXzY2gyNv7MdHR+AIwSTAg==", - "requires": { - "js-sha512": "^0.8.0", - "protobufjs": "^6.8.8", - "ripemd160": "^2.0.2", - "sha.js": "^2.4.11" - } - }, "@cosmjs/amino": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.25.5.tgz", @@ -195,73 +184,6 @@ "@cosmjs/utils": "^0.25.5" } }, - "@cosmjs/cosmwasm": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm/-/cosmwasm-0.25.5.tgz", - "integrity": "sha512-PsK28ARcow5hEd+hKAdGsjtjz/g5UMtPpSWD7l1WxWhuASLmJVXFebBUPJAu3CDeFG3FrlCRP5J8tLvJOisuJQ==", - "requires": { - "@cosmjs/cosmwasm-launchpad": "^0.25.5" - } - }, - "@cosmjs/cosmwasm-launchpad": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-launchpad/-/cosmwasm-launchpad-0.25.5.tgz", - "integrity": "sha512-9/Z8m9rfovtgchN1thcdVBEBXCrh5clVNgpVp1rpbkUSSGA7T5tCR8H1qX0+Yd3HLRh212O5EnCfzzXjNxR21A==", - "requires": { - "@cosmjs/crypto": "^0.25.5", - "@cosmjs/encoding": "^0.25.5", - "@cosmjs/launchpad": "^0.25.5", - "@cosmjs/math": "^0.25.5", - "@cosmjs/utils": "^0.25.5", - "pako": "^2.0.2" - } - }, - "@cosmjs/cosmwasm-stargate": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/cosmwasm-stargate/-/cosmwasm-stargate-0.25.5.tgz", - "integrity": "sha512-lUwjXMnVO+8iZtqwKr4hEBgA9q03AqAhUBNNyyG8oeTpgASrQ1ZlLjjmBWgvEpw4JokRduDf7il+NNENjaeAhQ==", - "requires": { - "@cosmjs/amino": "^0.25.5", - "@cosmjs/cosmwasm-launchpad": "^0.25.5", - "@cosmjs/crypto": "^0.25.5", - "@cosmjs/encoding": "^0.25.5", - "@cosmjs/math": "^0.25.5", - "@cosmjs/proto-signing": "^0.25.5", - "@cosmjs/stargate": "^0.25.5", - "@cosmjs/tendermint-rpc": "^0.25.5", - "@cosmjs/utils": "^0.25.5", - "long": "^4.0.0", - "pako": "^2.0.2", - "protobufjs": "~6.10.2" - }, - "dependencies": { - "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, - "protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", - "requires": { - "@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" - } - } - } - }, "@cosmjs/crypto": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/crypto/-/crypto-0.25.5.tgz", @@ -289,15 +211,6 @@ "readonly-date": "^1.0.0" } }, - "@cosmjs/json-rpc": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.25.5.tgz", - "integrity": "sha512-WFDallAolxBqB8V/mYxU0riF/OBoc6Fc2DDsZhds5xOZxeN9sTX0qWhu1UiFyURw4Z9D+SjB9QngqSDBTMTdjw==", - "requires": { - "@cosmjs/stream": "^0.25.5", - "xstream": "^11.14.0" - } - }, "@cosmjs/launchpad": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/launchpad/-/launchpad-0.25.5.tgz", @@ -348,129 +261,6 @@ "bn.js": "^4.11.8" } }, - "@cosmjs/proto-signing": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.25.5.tgz", - "integrity": "sha512-YWVp+dGHt7v6ZKjOs8CI9xkpOV49eweHbYMv/vCVYF4cEh0kWwy2WzbWIkUH9zwwUqCxigVOTBYUCfbsjEbfug==", - "requires": { - "@cosmjs/amino": "^0.25.5", - "long": "^4.0.0", - "protobufjs": "~6.10.2" - }, - "dependencies": { - "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, - "protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", - "requires": { - "@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" - } - } - } - }, - "@cosmjs/socket": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.25.5.tgz", - "integrity": "sha512-wcJVbD4xlF4+5hMum4tOmAy5ppX+E9qrB9Pvt3T7BK+6T5uobxiBQCLEiDwHP3n42RBj+xQWJrScPf5IEWmZKg==", - "requires": { - "@cosmjs/stream": "^0.25.5", - "isomorphic-ws": "^4.0.1", - "ws": "^7", - "xstream": "^11.14.0" - }, - "dependencies": { - "ws": { - "version": "7.5.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.0.tgz", - "integrity": "sha512-6ezXvzOZupqKj4jUqbQ9tXuJNo+BR2gU8fFRk3XCP3e0G6WT414u5ELe6Y0vtp7kmSJ3F7YWObSNr1ESsgi4vw==" - } - } - }, - "@cosmjs/stargate": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.25.5.tgz", - "integrity": "sha512-cOZ+fOC16YT7W2vjBnnk9oJfuIlB02KdK6dn6aigMd4mx+7DS2jvNslpQrfKmtrwB9AVsgc6tklBkYwG5qAuKQ==", - "requires": { - "@confio/ics23": "^0.6.3", - "@cosmjs/amino": "^0.25.5", - "@cosmjs/encoding": "^0.25.5", - "@cosmjs/math": "^0.25.5", - "@cosmjs/proto-signing": "^0.25.5", - "@cosmjs/stream": "^0.25.5", - "@cosmjs/tendermint-rpc": "^0.25.5", - "@cosmjs/utils": "^0.25.5", - "long": "^4.0.0", - "protobufjs": "~6.10.2" - }, - "dependencies": { - "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - }, - "protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", - "requires": { - "@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" - } - } - } - }, - "@cosmjs/stream": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.25.5.tgz", - "integrity": "sha512-a+0sDNKZTxw9p4j5tl7SI0siMTii7AQot1+5vkH5BkQoAv3C3D8jagPouUz3RUFuh13qftPxPLiHzDFLNSjTnQ==", - "requires": { - "xstream": "^11.14.0" - } - }, - "@cosmjs/tendermint-rpc": { - "version": "0.25.5", - "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.25.5.tgz", - "integrity": "sha512-WlUCFVdhbwA3IDA1C858S8WOtLseZLXKTdj5fz1sTKSBmtrig4l1ZMKHHlZRprvmjSpkpbjgSQU+RjjvBd75BA==", - "requires": { - "@cosmjs/crypto": "^0.25.5", - "@cosmjs/encoding": "^0.25.5", - "@cosmjs/json-rpc": "^0.25.5", - "@cosmjs/math": "^0.25.5", - "@cosmjs/socket": "^0.25.5", - "@cosmjs/stream": "^0.25.5", - "axios": "^0.21.1", - "readonly-date": "^1.0.0", - "xstream": "^11.14.0" - } - }, "@cosmjs/utils": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.25.5.tgz", @@ -3758,14 +3548,6 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, - "globalthis": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.2.tgz", - "integrity": "sha512-ZQnSFO1la8P7auIOQECnm0sSuoMeaSq0EEdXMBFF2QJO4uNcwbyhSgG3MruWNbFTqCLmxVwGOl7LZ9kASvHdeQ==", - "requires": { - "define-properties": "^1.1.3" - } - }, "graceful-fs": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", @@ -4156,11 +3938,6 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, - "isomorphic-ws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" - }, "jquery": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", @@ -4176,11 +3953,6 @@ "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, - "js-sha512": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz", - "integrity": "sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==" - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -5609,11 +5381,6 @@ "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true }, - "pako": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/pako/-/pako-2.0.3.tgz", - "integrity": "sha512-WjR1hOeg+kki3ZIOjaf4b5WVcay1jaliKSYiEaB1XzwhMQZJxRdQRv0V31EKBYlxb4T7SK3hjfc/jxyU64BoSw==" - }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -7257,11 +7024,6 @@ "has-flag": "^3.0.0" } }, - "symbol-observable": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-2.0.3.tgz", - "integrity": "sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA==" - }, "table": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", @@ -7728,15 +7490,6 @@ "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" }, - "xstream": { - "version": "11.14.0", - "resolved": "https://registry.npmjs.org/xstream/-/xstream-11.14.0.tgz", - "integrity": "sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw==", - "requires": { - "globalthis": "^1.0.1", - "symbol-observable": "^2.0.3" - } - }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index c8f99587b..d8f18c78f 100644 --- a/package.json +++ b/package.json @@ -11,13 +11,8 @@ }, "dependencies": { "@babel/runtime": "^7.13.17", - "@cosmjs/cosmwasm": "^0.25.5", - "@cosmjs/cosmwasm-launchpad": "^0.25.5", - "@cosmjs/cosmwasm-stargate": "^0.25.5", "@cosmjs/launchpad": "^0.25.5", "@cosmjs/ledger-amino": "^0.25.5", - "@cosmjs/proto-signing": "^0.25.5", - "@cosmjs/stargate": "^0.25.5", "@cosmjs/utils": "^0.25.5", "@ledgerhq/hw-transport-web-ble": "^5.50.0", "@ledgerhq/hw-transport-webusb": "^5.53.0", From c2c52ff4627848c8ae255e5d0dd4c7921b30e708 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Jul 2021 17:33:32 +0800 Subject: [PATCH 08/22] Remove unused packages --- package-lock.json | 91 ----------------------------------------------- package.json | 2 -- 2 files changed, 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 98dd19e7a..6d137e126 100644 --- a/package-lock.json +++ b/package-lock.json @@ -387,60 +387,6 @@ } } }, - "@protobufjs/aspromise": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", - "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" - }, - "@protobufjs/base64": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", - "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" - }, - "@protobufjs/codegen": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", - "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" - }, - "@protobufjs/eventemitter": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", - "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" - }, - "@protobufjs/fetch": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", - "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", - "requires": { - "@protobufjs/aspromise": "^1.1.1", - "@protobufjs/inquire": "^1.1.0" - } - }, - "@protobufjs/float": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", - "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" - }, - "@protobufjs/inquire": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", - "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" - }, - "@protobufjs/path": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", - "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" - }, - "@protobufjs/pool": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", - "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" - }, - "@protobufjs/utf8": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", - "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" - }, "@types/d3": { "version": "4.13.12", "resolved": "https://registry.npmjs.org/@types/d3/-/d3-4.13.12.tgz", @@ -685,11 +631,6 @@ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.163.tgz", "integrity": "sha512-BeZM/FZaV53emqyHxn9L39Oz6XbHMBRLA1b1quROku48J/1kYYxPmVOJ/qSQheb81on4BI7H6QDo6bkUuRaDNQ==" }, - "@types/long": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", - "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" - }, "@types/meteor-universe-i18n": { "version": "1.14.5", "resolved": "https://registry.npmjs.org/@types/meteor-universe-i18n/-/meteor-universe-i18n-1.14.5.tgz", @@ -4192,11 +4133,6 @@ "resolved": "https://registry.npmjs.org/lodash.flow/-/lodash.flow-3.5.0.tgz", "integrity": "sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o=" }, - "long": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", - "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" - }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5880,33 +5816,6 @@ "react-is": "^16.8.1" } }, - "protobufjs": { - "version": "6.10.2", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", - "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", - "requires": { - "@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" - }, - "dependencies": { - "@types/node": { - "version": "13.13.52", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", - "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" - } - } - }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", diff --git a/package.json b/package.json index d8f18c78f..6d8905243 100644 --- a/package.json +++ b/package.json @@ -31,14 +31,12 @@ "js-sha256": "^0.9.0", "ledger-cosmos-js": "^2.1.8", "lodash": "^4.17.21", - "long": "^4.0.0", "meteor-node-stubs": "^0.4.1", "moment": "^2.27.0", "moment-timezone": "^0.5.33", "numbro": "^2.3.2", "plottable": "^3.9.0", "prop-types": "^15.7.2", - "protobufjs": "^6.10.2", "react": "^16.14.0", "react-chartjs-2": "^2.11.1", "react-dom": "^16.13.1", From be5a36120f435e7644607123db0629859ba3ad42 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Mon, 5 Jul 2021 18:49:06 +0800 Subject: [PATCH 09/22] Added checkLedgerError to signAmino --- imports/ui/ledger/ledger.js | 77 +++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 42 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 5ceb787c2..6117857da 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -230,15 +230,11 @@ export class Ledger { sequence ); - try{ - signAmino = await this.ledgerSigner.signAmino( - txContext.bech32, - signDoc - ); - } - catch(e){ - console.log(e) - } + signAmino = await this.ledgerSigner.signAmino( + txContext.bech32, + signDoc + ); + this.checkLedgerErrors(signAmino) const proposalTx = { msg: [msgs], @@ -247,17 +243,12 @@ export class Ledger { signatures: [signAmino.signature], }; - try{ - proposalResult = await client.broadcastTx(proposalTx); - await sleep(75); - assertIsBroadcastTxSuccess(proposalResult); - } - catch(e){ - console.log(e) - } + proposalResult = await client.broadcastTx(proposalTx); + await sleep(75); + assertIsBroadcastTxSuccess(proposalResult); - return proposalResult?.transactionHash ?? '' - + let txHash = proposalResult?.transactionHash ?? '' + return txHash }; /* istanbul ignore next: maps a bunch of errors */ @@ -271,34 +262,36 @@ export class Ledger { if (device_locked) { throw new Error(`Ledger's screensaver mode is on`) } - switch (error_message) { - case `U2F: Timeout`: - throw new Error(timeoutMessag) - case `${Meteor.settings.public.ledger.appName} app does not seem to be open`: + if(error_message != null){ + switch (error_message) { + case `U2F: Timeout`: + throw new Error(timeoutMessag) + case `${Meteor.settings.public.ledger.appName} app does not seem to be open`: // hack: // It seems that when switching app in Ledger, WebUSB will disconnect, disabling further action. // So we clean up here, and re-initialize this.cosmosApp next time when calling `connect` - this.cosmosApp.transport.close() - this.cosmosApp = undefined - throw new Error(`${Meteor.settings.public.ledger.appName} app is not open`) - case `Command not allowed`: - throw new Error(`Transaction rejected`) - case `Transaction rejected`: - throw new Error(rejectionMessage) - case `Unknown error code`: - throw new Error(`Ledger's screensaver mode is on`) - case `Instruction not supported`: - throw new Error( - `Your ${Meteor.settings.public.ledger.appName} Ledger App is not up to date. ` + + this.cosmosApp.transport.close() + this.cosmosApp = undefined + throw new Error(`${Meteor.settings.public.ledger.appName} app is not open`) + case `Command not allowed`: + throw new Error(`Transaction rejected`) + case `Transaction rejected`: + throw new Error(rejectionMessage) + case `Unknown error code`: + throw new Error(`Ledger's screensaver mode is on`) + case `Instruction not supported`: + throw new Error( + `Your ${Meteor.settings.public.ledger.appName} Ledger App is not up to date. ` + `Please update to version ${REQUIRED_COSMOS_APP_VERSION}.` - ) - case `Web Bluetooth API globally disabled`: - throw new Error(`Bluetooth not supported. Please use the latest version of Chrome browser.`) - case `No errors`: + ) + case `Web Bluetooth API globally disabled`: + throw new Error(`Bluetooth not supported. Please use the latest version of Chrome browser.`) + case `No errors`: // do nothing - break - default: - throw new Error(error_message) + break + default: + throw new Error(error_message) + } } } From b83857edd48b87c1c8ca89993998071c4984e99c Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Wed, 7 Jul 2021 20:23:11 +0800 Subject: [PATCH 10/22] Add signTx --- imports/ui/ledger/ledger.js | 77 ++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 6117857da..df1530d06 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -14,8 +14,16 @@ import CryptoJS from "crypto-js" import { LedgerSigner } from "@cosmjs/ledger-amino"; import { makeCosmoshubPath, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; import { sleep } from "@cosmjs/utils"; - - +import { SigningStargateClient, assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessful, defaultRegistryTypes, AminoTypes } from "@cosmjs/stargate" +// import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; +import { Registry } from '@cosmjs/proto-signing'; +import { + MsgDelegate, + MsgUndelegate, +} from '@cosmjs/stargate/build/codec/cosmos/staking/v1beta1/tx'; +import { + MsgSend, +} from '@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx'; // TODO: discuss TIMEOUT value const INTERACTION_TIMEOUT = 10000 const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersion || "2.16.0"; @@ -23,6 +31,7 @@ const DEFAULT_DENOM = Meteor.settings.public.bondDenom || 'uatom'; export const DEFAULT_GAS_PRICE = parseFloat(Meteor.settings.public.ledger.gasPrice) || 0.025; export const DEFAULT_MEMO = 'Sent via Big Dipper' const API = Meteor.settings.public.remote.api +const RPC = Meteor.settings.public.remote.rpc /* HD wallet derivation path (BIP44) @@ -196,6 +205,70 @@ export class Ledger { return parsedSignature } + async signTx(txMsg, txContext, transportBLE) { + await this.connect(INTERACTION_TIMEOUT, transportBLE) + + let address = txContext.bech32; + let fee = txMsg.value.fee + let chainId = txContext.chainId; + let accountNumber = txContext.accountNumber.toString(); + let sequence = txContext.sequence.toString(); + const myRegistry = new Registry([...defaultRegistryTypes]); + + const client = await SigningStargateClient.connectWithSigner( + RPC, + this.ledgerSigner, + ); + + const getTypeUrl = (option) => { + switch (option) { + case "cosmos-sdk/MsgDelegate": + return "/cosmos.staking.v1beta1.MsgDelegate"; + case "cosmos-sdk/MsgUndelegate": + return "/cosmos.staking.v1beta1.MsgUndelegate"; + case "cosmos-sdk/MsgBeginRedelegate": + return "/cosmos.staking.v1beta1.MsgBeginRedelegate"; + case "cosmos-sdk/MsgSend": + return "/cosmos.bank.v1beta1.MsgSend"; + case "cosmos-sdk/MsgSubmitProposal": + return "/cosmos.gov.v1beta1.MsgSubmitProposal"; + case "cosmos-sdk/MsgDeposit": + return "/cosmos.gov.v1beta1.MsgDeposit"; + } + } + + txMsg.value.msg[0].type = getTypeUrl(txMsg.value.msg[0].type) + let msgs = txMsg.value.msg[0] + const signDoc = makeSignDoc( + [msgs], + fee, + chainId, + DEFAULT_MEMO, + accountNumber, + sequence + ); + + let fromAddress = txMsg.value.msg[0].value.from_address + let toAddress = txMsg.value.msg[0].value.to_address + + const result = await client.signAndBroadcast( + address, + [ + { + typeUrl: '/cosmos.bank.v1beta1.MsgSend', + value: MsgSend.fromPartial({ + fromAddress, + toAddress, + amount: txMsg.value.msg[0].value.amount, + }), + }, + ], + fee, + DEFAULT_MEMO + ); + console.log(result) + } + async signAmino(txMsg, txContext, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) let address = txContext.bech32; From 7971c11431b8337b85afc42660d29613db5db756 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 14:29:18 +0800 Subject: [PATCH 11/22] Format messages to stargate format --- imports/ui/ledger/ledger.js | 96 ++++++++++++++++++------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index df1530d06..856d5a0d0 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -15,15 +15,13 @@ import { LedgerSigner } from "@cosmjs/ledger-amino"; import { makeCosmoshubPath, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; import { sleep } from "@cosmjs/utils"; import { SigningStargateClient, assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessful, defaultRegistryTypes, AminoTypes } from "@cosmjs/stargate" -// import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Registry } from '@cosmjs/proto-signing'; import { MsgDelegate, MsgUndelegate, + MsgBeginRedelegate } from '@cosmjs/stargate/build/codec/cosmos/staking/v1beta1/tx'; -import { - MsgSend, -} from '@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx'; +import { MsgSend } from '@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx'; // TODO: discuss TIMEOUT value const INTERACTION_TIMEOUT = 10000 const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersion || "2.16.0"; @@ -207,66 +205,66 @@ export class Ledger { async signTx(txMsg, txContext, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) - let address = txContext.bech32; let fee = txMsg.value.fee - let chainId = txContext.chainId; - let accountNumber = txContext.accountNumber.toString(); - let sequence = txContext.sequence.toString(); const myRegistry = new Registry([...defaultRegistryTypes]); const client = await SigningStargateClient.connectWithSigner( RPC, this.ledgerSigner, + 'sync' ); - const getTypeUrl = (option) => { + const formatMessage = (option) => { switch (option) { case "cosmos-sdk/MsgDelegate": - return "/cosmos.staking.v1beta1.MsgDelegate"; + return { + typeUrl: '/cosmos.staking.v1beta1.MsgDelegate', + value: MsgDelegate.fromPartial({ + amount: txMsg.value.msg[0].value.amount, + delegatorAddress: address, + validatorAddress: txMsg.value.msg[0].value.validator_address, + }) + } case "cosmos-sdk/MsgUndelegate": - return "/cosmos.staking.v1beta1.MsgUndelegate"; + return { + typeUrl: '/cosmos.staking.v1beta1.MsgUndelegate', + value: MsgUndelegate.fromPartial({ + amount: txMsg.value.msg[0].value.amount, + delegatorAddress: address, + validatorAddress: txMsg.value.msg[0].value.validator_address, + }) + } case "cosmos-sdk/MsgBeginRedelegate": - return "/cosmos.staking.v1beta1.MsgBeginRedelegate"; + return { + typeUrl: '/cosmos.staking.v1beta1.MsgBeginRedelegate', + value: MsgBeginRedelegate.fromPartial({ + amount: txMsg.value.msg[0].value.amount, + delegatorAddress: address, + validatorDstAddress: txMsg.value.msg[0].value.validator_dst_address, + validatorSrcAddress: txMsg.value.msg[0].value.validator_src_address, + }) + } case "cosmos-sdk/MsgSend": - return "/cosmos.bank.v1beta1.MsgSend"; - case "cosmos-sdk/MsgSubmitProposal": - return "/cosmos.gov.v1beta1.MsgSubmitProposal"; - case "cosmos-sdk/MsgDeposit": - return "/cosmos.gov.v1beta1.MsgDeposit"; + return { + typeUrl: '/cosmos.bank.v1beta1.MsgSend', + value: MsgSend.fromPartial({ + fromAddress: address, + toAddress: txMsg.value.msg[0].value.to_address, + amount: txMsg.value.msg[0].value.amount, + }), + } } } - txMsg.value.msg[0].type = getTypeUrl(txMsg.value.msg[0].type) - let msgs = txMsg.value.msg[0] - const signDoc = makeSignDoc( - [msgs], - fee, - chainId, - DEFAULT_MEMO, - accountNumber, - sequence - ); - - let fromAddress = txMsg.value.msg[0].value.from_address - let toAddress = txMsg.value.msg[0].value.to_address - + let msg = formatMessage(txMsg.value.msg[0].type) ?? txMsg.value.msg[0] const result = await client.signAndBroadcast( address, - [ - { - typeUrl: '/cosmos.bank.v1beta1.MsgSend', - value: MsgSend.fromPartial({ - fromAddress, - toAddress, - amount: txMsg.value.msg[0].value.amount, - }), - }, - ], + [msg], fee, DEFAULT_MEMO ); - console.log(result) + return result.transactionHash } async signAmino(txMsg, txContext, transportBLE) { @@ -276,7 +274,7 @@ export class Ledger { let chainId = txContext.chainId; let accountNumber = txContext.accountNumber.toString(); let sequence = txContext.sequence.toString(); - let signAmino, proposalResult; + let signAmino, txResult; const getVoteOption = (option) =>{ switch (option) { @@ -292,7 +290,9 @@ export class Ledger { } const client = new SigningCosmosClient(API, address, this.ledgerSigner, undefined, undefined, 'sync') - txMsg.value.msg[0].value.option = getVoteOption(txMsg.value.msg[0].value.option) + if (txMsg.value.msg[0].value.option){ + txMsg.value.msg[0].value.option = getVoteOption(txMsg.value.msg[0].value.option) + } let msgs = txMsg.value.msg[0] const signDoc = makeSignDoc( [msgs], @@ -309,18 +309,18 @@ export class Ledger { ); this.checkLedgerErrors(signAmino) - const proposalTx = { + const tx = { msg: [msgs], fee: fee, memo: DEFAULT_MEMO, signatures: [signAmino.signature], }; - proposalResult = await client.broadcastTx(proposalTx); + txResult = await client.broadcastTx(tx); await sleep(75); - assertIsBroadcastTxSuccess(proposalResult); + assertIsBroadcastTxSuccess(txResult); - let txHash = proposalResult?.transactionHash ?? '' + let txHash = txResult?.transactionHash ?? '' return txHash }; From 30c740a4305e1859e8f37050c63cb6770ae558ed Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 14:31:08 +0800 Subject: [PATCH 12/22] Update signing method for gov modules --- imports/ui/ledger/LedgerActions.jsx | 27 +++++++++------------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 9310bb854..ced6cb33e 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -453,7 +453,9 @@ class LedgerButton extends Component { const txContext = this.getTxContext(); const bytesToSign = Ledger.getBytesToSign(txMsg, txContext); - if (txMsg.value.msg[0].type === "cosmos-sdk/MsgVote"){ + if (txMsg.value.msg[0].type === "cosmos-sdk/MsgVote" || + txMsg.value.msg[0].type === "cosmos-sdk/MsgDeposit" || + txMsg.value.msg[0].type === "cosmos-sdk/MsgSubmitProposal") { this.ledger.signAmino(txMsg, txContext, this.state.transportBLE).then((res) => { this.setStateOnSuccess('signing', { txHash: res, @@ -461,23 +463,12 @@ class LedgerButton extends Component { }) }, (err) => this.setStateOnError('signing', err.message)) } - else{ - this.ledger.sign(bytesToSign, this.state.transportBLE).then((sig) => { - try { - Ledger.applySignature(txMsg, txContext, sig); - Meteor.call('transaction.submit', txMsg, (err, res) => { - if (err) { - this.setStateOnError('signing', err.reason) - } else if (res) { - this.setStateOnSuccess('signing', { - txHash: res, - activeTab: '4' - }) - } - }) - } catch (e) { - this.setStateOnError('signing', e.message) - } + else { + this.ledger.signTx(txMsg, txContext, this.state.transportBLE).then((hash) => { + this.setStateOnSuccess('signing', { + txHash: hash, + activeTab: '4' + }) }, (err) => this.setStateOnError('signing', err.message)) } } catch (e) { From 82e32214a2a34a506782a09b4fac7fb3bf2f9402 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 14:32:55 +0800 Subject: [PATCH 13/22] Updated withdraw reward and commission message to stargate format --- imports/ui/ledger/LedgerActions.jsx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index ced6cb33e..1fbe3e6fe 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -12,6 +12,7 @@ import numbro from 'numbro'; import TimeStamp from '../components/TimeStamp.jsx'; import { PropTypes } from 'prop-types'; import i18n from 'meteor/universe:i18n'; +import { MsgWithdrawValidatorCommission, MsgWithdrawDelegatorReward } from '@cosmjs/stargate/build/codec/cosmos/distribution/v1beta1/tx'; const T = i18n.createComponent(); @@ -772,24 +773,26 @@ class WithdrawButton extends LedgerButton { createMessage = (callback) => { Meteor.call('transaction.execute', {from: this.state.user}, this.getPath(), (err, res) =>{ - if (res){ + if (res) { + res.value.msg[0] = { + typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', + value: MsgWithdrawDelegatorReward.fromPartial({ + delegatorAddress: res.value.msg[0].value.delegator_address, + validatorAddress: res.value.msg[0].value.validator_address + }) + } Meteor.call('isValidator', this.state.user, (error, result) => { - if (result && result.operator_address){ + if (result && result.operator_address) { res.value.msg.push({ - type: 'cosmos-sdk/MsgWithdrawValidatorCommission', - value: { validator_address: result.operator_address } + typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission', + value: MsgWithdrawValidatorCommission.fromPartial({ + validatorAddress: result.operator_address + }) }) } callback(res, res) }) } - else { - this.setState({ - loading: false, - simulating: false, - errorMessage: 'something went wrong' - }) - } }) } From c5d0205b1729b83b4be8a06e69af3d94730684c3 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 14:42:09 +0800 Subject: [PATCH 14/22] Update packages --- package-lock.json | 212 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 213 insertions(+) diff --git a/package-lock.json b/package-lock.json index 6d137e126..e42ebada3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -173,6 +173,17 @@ "to-fast-properties": "^2.0.0" } }, + "@confio/ics23": { + "version": "0.6.5", + "resolved": "https://registry.npmjs.org/@confio/ics23/-/ics23-0.6.5.tgz", + "integrity": "sha512-1GdPMsaP/l8JSF4P4HWFLBhdcxHcJT8lS0nknBYNSZ1XrJOsJKUy6EkOwd9Pa1qJkXzY2gyNv7MdHR+AIwSTAg==", + "requires": { + "js-sha512": "^0.8.0", + "protobufjs": "^6.8.8", + "ripemd160": "^2.0.2", + "sha.js": "^2.4.11" + } + }, "@cosmjs/amino": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/amino/-/amino-0.25.5.tgz", @@ -211,6 +222,15 @@ "readonly-date": "^1.0.0" } }, + "@cosmjs/json-rpc": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/json-rpc/-/json-rpc-0.25.5.tgz", + "integrity": "sha512-WFDallAolxBqB8V/mYxU0riF/OBoc6Fc2DDsZhds5xOZxeN9sTX0qWhu1UiFyURw4Z9D+SjB9QngqSDBTMTdjw==", + "requires": { + "@cosmjs/stream": "^0.25.5", + "xstream": "^11.14.0" + } + }, "@cosmjs/launchpad": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/launchpad/-/launchpad-0.25.5.tgz", @@ -261,6 +281,75 @@ "bn.js": "^4.11.8" } }, + "@cosmjs/proto-signing": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/proto-signing/-/proto-signing-0.25.5.tgz", + "integrity": "sha512-YWVp+dGHt7v6ZKjOs8CI9xkpOV49eweHbYMv/vCVYF4cEh0kWwy2WzbWIkUH9zwwUqCxigVOTBYUCfbsjEbfug==", + "requires": { + "@cosmjs/amino": "^0.25.5", + "long": "^4.0.0", + "protobufjs": "~6.10.2" + } + }, + "@cosmjs/socket": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/socket/-/socket-0.25.5.tgz", + "integrity": "sha512-wcJVbD4xlF4+5hMum4tOmAy5ppX+E9qrB9Pvt3T7BK+6T5uobxiBQCLEiDwHP3n42RBj+xQWJrScPf5IEWmZKg==", + "requires": { + "@cosmjs/stream": "^0.25.5", + "isomorphic-ws": "^4.0.1", + "ws": "^7", + "xstream": "^11.14.0" + }, + "dependencies": { + "ws": { + "version": "7.5.2", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.2.tgz", + "integrity": "sha512-lkF7AWRicoB9mAgjeKbGqVUekLnSNO4VjKVnuPHpQeOxZOErX6BPXwJk70nFslRCEEA8EVW7ZjKwXaP9N+1sKQ==" + } + } + }, + "@cosmjs/stargate": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/stargate/-/stargate-0.25.5.tgz", + "integrity": "sha512-cOZ+fOC16YT7W2vjBnnk9oJfuIlB02KdK6dn6aigMd4mx+7DS2jvNslpQrfKmtrwB9AVsgc6tklBkYwG5qAuKQ==", + "requires": { + "@confio/ics23": "^0.6.3", + "@cosmjs/amino": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/proto-signing": "^0.25.5", + "@cosmjs/stream": "^0.25.5", + "@cosmjs/tendermint-rpc": "^0.25.5", + "@cosmjs/utils": "^0.25.5", + "long": "^4.0.0", + "protobufjs": "~6.10.2" + } + }, + "@cosmjs/stream": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/stream/-/stream-0.25.5.tgz", + "integrity": "sha512-a+0sDNKZTxw9p4j5tl7SI0siMTii7AQot1+5vkH5BkQoAv3C3D8jagPouUz3RUFuh13qftPxPLiHzDFLNSjTnQ==", + "requires": { + "xstream": "^11.14.0" + } + }, + "@cosmjs/tendermint-rpc": { + "version": "0.25.5", + "resolved": "https://registry.npmjs.org/@cosmjs/tendermint-rpc/-/tendermint-rpc-0.25.5.tgz", + "integrity": "sha512-WlUCFVdhbwA3IDA1C858S8WOtLseZLXKTdj5fz1sTKSBmtrig4l1ZMKHHlZRprvmjSpkpbjgSQU+RjjvBd75BA==", + "requires": { + "@cosmjs/crypto": "^0.25.5", + "@cosmjs/encoding": "^0.25.5", + "@cosmjs/json-rpc": "^0.25.5", + "@cosmjs/math": "^0.25.5", + "@cosmjs/socket": "^0.25.5", + "@cosmjs/stream": "^0.25.5", + "axios": "^0.21.1", + "readonly-date": "^1.0.0", + "xstream": "^11.14.0" + } + }, "@cosmjs/utils": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/@cosmjs/utils/-/utils-0.25.5.tgz", @@ -387,6 +476,60 @@ } } }, + "@protobufjs/aspromise": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/aspromise/-/aspromise-1.1.2.tgz", + "integrity": "sha1-m4sMxmPWaafY9vXQiToU00jzD78=" + }, + "@protobufjs/base64": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/base64/-/base64-1.1.2.tgz", + "integrity": "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg==" + }, + "@protobufjs/codegen": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@protobufjs/codegen/-/codegen-2.0.4.tgz", + "integrity": "sha512-YyFaikqM5sH0ziFZCN3xDC7zeGaB/d0IUb9CATugHWbd1FRFwWwt4ld4OYMPWu5a3Xe01mGAULCdqhMlPl29Jg==" + }, + "@protobufjs/eventemitter": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/eventemitter/-/eventemitter-1.1.0.tgz", + "integrity": "sha1-NVy8mLr61ZePntCV85diHx0Ga3A=" + }, + "@protobufjs/fetch": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/fetch/-/fetch-1.1.0.tgz", + "integrity": "sha1-upn7WYYUr2VwDBYZ/wbUVLDYTEU=", + "requires": { + "@protobufjs/aspromise": "^1.1.1", + "@protobufjs/inquire": "^1.1.0" + } + }, + "@protobufjs/float": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@protobufjs/float/-/float-1.0.2.tgz", + "integrity": "sha1-Xp4avctz/Ap8uLKR33jIy9l7h9E=" + }, + "@protobufjs/inquire": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/inquire/-/inquire-1.1.0.tgz", + "integrity": "sha1-/yAOPnzyQp4tyvwRQIKOjMY48Ik=" + }, + "@protobufjs/path": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@protobufjs/path/-/path-1.1.2.tgz", + "integrity": "sha1-bMKyDFya1q0NzP0hynZz2Nf79o0=" + }, + "@protobufjs/pool": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/pool/-/pool-1.1.0.tgz", + "integrity": "sha1-Cf0V8tbTq/qbZbw2ZQbWrXhG/1Q=" + }, + "@protobufjs/utf8": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@protobufjs/utf8/-/utf8-1.1.0.tgz", + "integrity": "sha1-p3c2C1s5oaLlEG+OhY8v0tBgxXA=" + }, "@types/d3": { "version": "4.13.12", "resolved": "https://registry.npmjs.org/@types/d3/-/d3-4.13.12.tgz", @@ -631,6 +774,11 @@ "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.163.tgz", "integrity": "sha512-BeZM/FZaV53emqyHxn9L39Oz6XbHMBRLA1b1quROku48J/1kYYxPmVOJ/qSQheb81on4BI7H6QDo6bkUuRaDNQ==" }, + "@types/long": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.1.tgz", + "integrity": "sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w==" + }, "@types/meteor-universe-i18n": { "version": "1.14.5", "resolved": "https://registry.npmjs.org/@types/meteor-universe-i18n/-/meteor-universe-i18n-1.14.5.tgz", @@ -3489,6 +3637,14 @@ "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==" }, + "globalthis": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.2.tgz", + "integrity": "sha512-ZQnSFO1la8P7auIOQECnm0sSuoMeaSq0EEdXMBFF2QJO4uNcwbyhSgG3MruWNbFTqCLmxVwGOl7LZ9kASvHdeQ==", + "requires": { + "define-properties": "^1.1.3" + } + }, "graceful-fs": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", @@ -3879,6 +4035,11 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=" }, + "isomorphic-ws": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", + "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==" + }, "jquery": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/jquery/-/jquery-3.6.0.tgz", @@ -3894,6 +4055,11 @@ "resolved": "https://registry.npmjs.org/js-sha3/-/js-sha3-0.8.0.tgz", "integrity": "sha512-gF1cRrHhIzNfToc802P800N8PpXS+evLLXfsVpowqmAFR9uwbi89WvXg2QspOmXL8QL86J4T1EpFu+yUkwJY3Q==" }, + "js-sha512": { + "version": "0.8.0", + "resolved": "https://registry.npmjs.org/js-sha512/-/js-sha512-0.8.0.tgz", + "integrity": "sha512-PWsmefG6Jkodqt+ePTvBZCSMFgN7Clckjd0O7su3I0+BW2QWUTJNzjktHsztGLhncP2h8mcF9V9Y2Ha59pAViQ==" + }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -4133,6 +4299,11 @@ "resolved": "https://registry.npmjs.org/lodash.flow/-/lodash.flow-3.5.0.tgz", "integrity": "sha1-h79AKSuM+D5OjOGjrkIJ4gBxZ1o=" }, + "long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==" + }, "loose-envify": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", @@ -5816,6 +5987,33 @@ "react-is": "^16.8.1" } }, + "protobufjs": { + "version": "6.10.2", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-6.10.2.tgz", + "integrity": "sha512-27yj+04uF6ya9l+qfpH187aqEzfCF4+Uit0I9ZBQVqK09hk/SQzKa2MUqUpXaVa7LOFRg1TSSr3lVxGOk6c0SQ==", + "requires": { + "@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" + }, + "dependencies": { + "@types/node": { + "version": "13.13.52", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.52.tgz", + "integrity": "sha512-s3nugnZumCC//n4moGGe6tkNMyYEdaDBitVjwPxXmR5lnMG5dHePinH2EdxkG3Rh1ghFHHixAG4NJhpJW1rthQ==" + } + } + }, "pump": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/pump/-/pump-2.0.1.tgz", @@ -6933,6 +7131,11 @@ "has-flag": "^3.0.0" } }, + "symbol-observable": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-2.0.3.tgz", + "integrity": "sha512-sQV7phh2WCYAn81oAkakC5qjq2Ml0g8ozqz03wOGnx9dDlG1de6yrF+0RAzSJD8fPUow3PTSMf2SAbOGxb93BA==" + }, "table": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/table/-/table-5.4.1.tgz", @@ -7399,6 +7602,15 @@ "resolved": "https://registry.npmjs.org/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz", "integrity": "sha1-Z/4HXFwk/vOfnWX197f+dRcZaPw=" }, + "xstream": { + "version": "11.14.0", + "resolved": "https://registry.npmjs.org/xstream/-/xstream-11.14.0.tgz", + "integrity": "sha512-1bLb+kKKtKPbgTK6i/BaoAn03g47PpFstlbe1BA+y3pNS/LfvcaghS5BFf9+EE1J+KwSQsEpfJvFN5GqFtiNmw==", + "requires": { + "globalthis": "^1.0.1", + "symbol-observable": "^2.0.3" + } + }, "xtend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", diff --git a/package.json b/package.json index 6d8905243..546941d40 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@babel/runtime": "^7.13.17", "@cosmjs/launchpad": "^0.25.5", "@cosmjs/ledger-amino": "^0.25.5", + "@cosmjs/stargate": "^0.25.5", "@cosmjs/utils": "^0.25.5", "@ledgerhq/hw-transport-web-ble": "^5.50.0", "@ledgerhq/hw-transport-webusb": "^5.53.0", From 5c0003c6baea946dc75e055d4331b2b4ddfa085f Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 15:46:01 +0800 Subject: [PATCH 15/22] Update imports --- imports/ui/ledger/ledger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 856d5a0d0..faadb19e6 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -12,9 +12,9 @@ import sha256 from "crypto-js/sha256" import ripemd160 from "crypto-js/ripemd160" import CryptoJS from "crypto-js" import { LedgerSigner } from "@cosmjs/ledger-amino"; -import { makeCosmoshubPath, SigningCosmosClient, makeSignDoc, assertIsBroadcastTxSuccess } from "@cosmjs/launchpad"; +import { SigningCosmosClient, makeSignDoc } from "@cosmjs/launchpad"; import { sleep } from "@cosmjs/utils"; -import { SigningStargateClient, assertIsBroadcastTxSuccess as assertIsBroadcastTxSuccessful, defaultRegistryTypes, AminoTypes } from "@cosmjs/stargate" +import { SigningStargateClient, assertIsBroadcastTxSuccess, defaultRegistryTypes, makeCosmoshubPath } from "@cosmjs/stargate" import { Registry } from '@cosmjs/proto-signing'; import { MsgDelegate, From b9b041caa9e1e5f62493c10103f109ecc3a994a2 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 15:49:13 +0800 Subject: [PATCH 16/22] Rm transaction.execute method --- imports/api/ledger/server/methods.js | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/imports/api/ledger/server/methods.js b/imports/api/ledger/server/methods.js index 0626aa4fe..ea8ec6a43 100644 --- a/imports/api/ledger/server/methods.js +++ b/imports/api/ledger/server/methods.js @@ -2,25 +2,6 @@ import { HTTP } from 'meteor/http'; import { Validators } from '../../validators/validators'; Meteor.methods({ - 'transaction.submit': function(txInfo) { - this.unblock(); - const url = `${API}/txs`; - data = { - "tx": txInfo.value, - "mode": "sync" - } - const timestamp = new Date().getTime(); - console.log(`submitting transaction${timestamp} ${url} with data ${JSON.stringify(data)}`) - - let response = HTTP.post(url, {data}); - console.log(`response for transaction${timestamp} ${url}: ${JSON.stringify(response)}`) - if (response.statusCode == 200) { - let data = response.data - if (data.code) - throw new Meteor.Error(data.code, JSON.parse(data.raw_log).message) - return response.data.txhash; - } - }, 'transaction.execute': function(body, path) { this.unblock(); const url = `${API}/${path}`; From b3269a6f19575ffa250f86d7a66a21c11f4b45c8 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 15:57:48 +0800 Subject: [PATCH 17/22] rm sign func in ledger.js --- imports/ui/ledger/ledger.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index faadb19e6..a6fe10904 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -193,16 +193,6 @@ export class Ledger { return new LedgerSigner(ledgerTransport, { hdPaths: [makeCosmoshubPath(0)] }); } - async sign(signMessage, transportBLE) { - await this.connect(INTERACTION_TIMEOUT, transportBLE) - - const response = await this.cosmosApp.sign(this.getHDPath(), signMessage) - this.checkLedgerErrors(response) - // we have to parse the signature from Ledger as it's in DER format - const parsedSignature = signatureImport(response.signature) - return parsedSignature - } - async signTx(txMsg, txContext, transportBLE) { await this.connect(INTERACTION_TIMEOUT, transportBLE) let address = txContext.bech32; From eeea102efd00b984364bff53f81ca13b2aafd98e Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Thu, 8 Jul 2021 18:18:11 +0800 Subject: [PATCH 18/22] Added CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9129be2f..dfb5f1bdb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [UNRELEASED] +* [#529] Upgraded ledger transactions to stargate format + ## [v0.41.x-14.2] * Fixes Ledger WebUSB + Chrome 91.x issue (https://github.com/LedgerHQ/ledgerjs/issues/607) From 0671f0be2ffbafea4cb86f0af8d00f1d84a05177 Mon Sep 17 00:00:00 2001 From: Kwun Yeung Date: Fri, 9 Jul 2021 09:51:34 +0000 Subject: [PATCH 19/22] save packages --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index 546941d40..00cae80eb 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "@babel/runtime": "^7.13.17", "@cosmjs/launchpad": "^0.25.5", "@cosmjs/ledger-amino": "^0.25.5", + "@cosmjs/proto-signing": "^0.25.5", "@cosmjs/stargate": "^0.25.5", "@cosmjs/utils": "^0.25.5", "@ledgerhq/hw-transport-web-ble": "^5.50.0", From e2fb672e5086df88413b0a77489ccb5d8a1cd0fa Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Fri, 6 Aug 2021 16:07:46 +0100 Subject: [PATCH 20/22] Rm API from ledger.js --- imports/ui/ledger/ledger.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index a6fe10904..41351f0d3 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -28,8 +28,6 @@ const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersi const DEFAULT_DENOM = Meteor.settings.public.bondDenom || 'uatom'; export const DEFAULT_GAS_PRICE = parseFloat(Meteor.settings.public.ledger.gasPrice) || 0.025; export const DEFAULT_MEMO = 'Sent via Big Dipper' -const API = Meteor.settings.public.remote.api -const RPC = Meteor.settings.public.remote.rpc /* HD wallet derivation path (BIP44) From 46289e04f199f0698b17eb6c036433ebc26170b2 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Fri, 6 Aug 2021 16:30:11 +0100 Subject: [PATCH 21/22] Moved remote to public in settings.json --- client/main.js | 3 ++- default_settings.json | 8 ++++---- server/main.js | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/client/main.js b/client/main.js index 528dd4e48..5dde11831 100644 --- a/client/main.js +++ b/client/main.js @@ -15,7 +15,8 @@ CURRENTUSERADDR = 'ledgerUserAddress'; CURRENTUSERPUBKEY = 'ledgerUserPubKey'; BLELEDGERCONNECTION = 'ledgerBLEConnection' ADDRESSINDEX = 'addressIndex' - +RPC = Meteor.settings.public.remote.rpc; +API = Meteor.settings.public.remote.api; // import { onPageLoad } from 'meteor/server-render'; diff --git a/default_settings.json b/default_settings.json index c9933a8ff..58306c643 100644 --- a/default_settings.json +++ b/default_settings.json @@ -40,14 +40,14 @@ "gov": true, "distribution": false }, + "remote": { + "rpc": "https://rpc.stargate.forbole.com:443", + "api": "https://api.stargate.forbole.com:443" + }, "coingeckoId": "cosmos", "networks": "https://gist.githubusercontent.com/kwunyeung/8be4598c77c61e497dfc7220a678b3ee/raw/bd-networks.json", "banners": false }, - "remote":{ - "rpc":"https://rpc.stargate.forbole.com:443", - "api":"https://api.stargate.forbole.com:443" - }, "debug": { "startTimer": true }, diff --git a/server/main.js b/server/main.js index 1ef69d8d8..56737e742 100644 --- a/server/main.js +++ b/server/main.js @@ -9,8 +9,8 @@ SYNCING = false; TXSYNCING = false; COUNTMISSEDBLOCKS = false; COUNTMISSEDBLOCKSSTATS = false; -RPC = Meteor.settings.remote.rpc; -API = Meteor.settings.remote.api; +RPC = Meteor.settings.public.remote.rpc; +API = Meteor.settings.public.remote.api; timerBlocks = 0; timerTransactions = 0; From 0bd863dfda679c2a585651abd5bbf1757e6ed2d1 Mon Sep 17 00:00:00 2001 From: Magic Cat Date: Fri, 20 Aug 2021 17:14:13 +0100 Subject: [PATCH 22/22] Updated withdrawal --- imports/ui/ledger/LedgerActions.jsx | 23 ++++++++++------------- imports/ui/ledger/ledger.js | 19 ++++++++++++++++++- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/imports/ui/ledger/LedgerActions.jsx b/imports/ui/ledger/LedgerActions.jsx index 1fbe3e6fe..93023d2e4 100644 --- a/imports/ui/ledger/LedgerActions.jsx +++ b/imports/ui/ledger/LedgerActions.jsx @@ -12,7 +12,6 @@ import numbro from 'numbro'; import TimeStamp from '../components/TimeStamp.jsx'; import { PropTypes } from 'prop-types'; import i18n from 'meteor/universe:i18n'; -import { MsgWithdrawValidatorCommission, MsgWithdrawDelegatorReward } from '@cosmjs/stargate/build/codec/cosmos/distribution/v1beta1/tx'; const T = i18n.createComponent(); @@ -772,27 +771,25 @@ class DelegationButtons extends LedgerButton { class WithdrawButton extends LedgerButton { createMessage = (callback) => { - Meteor.call('transaction.execute', {from: this.state.user}, this.getPath(), (err, res) =>{ + Meteor.call('transaction.execute', { from: this.state.user }, this.getPath(), (err, res) => { if (res) { - res.value.msg[0] = { - typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', - value: MsgWithdrawDelegatorReward.fromPartial({ - delegatorAddress: res.value.msg[0].value.delegator_address, - validatorAddress: res.value.msg[0].value.validator_address - }) - } Meteor.call('isValidator', this.state.user, (error, result) => { if (result && result.operator_address) { res.value.msg.push({ - typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission', - value: MsgWithdrawValidatorCommission.fromPartial({ - validatorAddress: result.operator_address - }) + type: 'cosmos-sdk/MsgWithdrawValidatorCommission', + value: { validator_address: result.operator_address } }) } callback(res, res) }) } + else { + this.setState({ + loading: false, + simulating: false, + errorMessage: 'something went wrong' + }) + } }) } diff --git a/imports/ui/ledger/ledger.js b/imports/ui/ledger/ledger.js index 41351f0d3..ff98d8c22 100644 --- a/imports/ui/ledger/ledger.js +++ b/imports/ui/ledger/ledger.js @@ -22,6 +22,8 @@ import { MsgBeginRedelegate } from '@cosmjs/stargate/build/codec/cosmos/staking/v1beta1/tx'; import { MsgSend } from '@cosmjs/stargate/build/codec/cosmos/bank/v1beta1/tx'; +import { MsgWithdrawValidatorCommission, MsgWithdrawDelegatorReward } from '@cosmjs/stargate/build/codec/cosmos/distribution/v1beta1/tx'; + // TODO: discuss TIMEOUT value const INTERACTION_TIMEOUT = 10000 const REQUIRED_COSMOS_APP_VERSION = Meteor.settings.public.ledger.ledgerAppVersion || "2.16.0"; @@ -242,10 +244,25 @@ export class Ledger { amount: txMsg.value.msg[0].value.amount, }), } + case "cosmos-sdk/MsgWithdrawDelegationReward": + return { + typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', + value: MsgWithdrawDelegatorReward.fromPartial({ + delegatorAddress: txMsg.value.msg[0].value.delegator_address, + validatorAddress: txMsg.value.msg[0].value.validator_address + }) + } + case "cosmos-sdk/MsgWithdrawValidatorCommission": + return { + typeUrl: '/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission', + value: MsgWithdrawValidatorCommission.fromPartial({ + validatorAddress: txMsg.value.msg[0].operator_address + }) + } } } - let msg = formatMessage(txMsg.value.msg[0].type) ?? txMsg.value.msg[0] + let msg = txMsg.value.msg.length > 1 ? txMsg.value.msg.map((m) => formatMessage(m.type)) : formatMessage(txMsg.value.msg[0].type) const result = await client.signAndBroadcast( address, [msg],