diff --git a/docs/architecture/adr-050-sign-mode-textual.md b/docs/architecture/adr-050-sign-mode-textual.md index 64536c753f75..82993bc3fc4f 100644 --- a/docs/architecture/adr-050-sign-mode-textual.md +++ b/docs/architecture/adr-050-sign-mode-textual.md @@ -9,6 +9,8 @@ * Sep 07, 2022: Add custom `Msg`-renderers. * Sep 18, 2022: Structured format instead of lines of text * Nov 23, 2022: Specify CBOR encoding. +* Dec 01, 2022: Link to examples in separate JSON file. +* Dec 06, 2022: Re-ordering of envelope screens. * Dec 14, 2022: Mention exceptions for invertability. ## Status @@ -176,29 +178,30 @@ We define "transaction envelope" as all data in a transaction that is not in the ``` Chain ID: Account number: -*Public Key: Sequence: - // See #8. -Fee: // See value renderers for coins encoding. -*Fee payer: // Skipped if no fee_payer set -*Fee granter: // Skipped if no fee_granter set -Memo: // Skipped if no memo set +Address: +*Public Key: +This transaction has Message(s) // Pluralize "Message" only when int>1 +> Message (/): // See value renderers for Any rendering. +End of Message +Memo: // Skipped if no memo set. +Fee: // See value renderers for coins rendering. +*Fee payer: // Skipped if no fee_payer set. +*Fee granter: // Skipped if no fee_granter set. +Tip: // Skippted if no tip. +Tipper: *Gas Limit: -*Timeout Height: // Skipped if no timeout_height set -Tipper: // If there's a tip -Tip: -*This transaction has body extension: // Skipped if no body extension options -* -*This transaction has body non-critical extensions: // Skipped if no body non-critical extension options -* // See value renderers for Any and array encoding. -*This transaction has body auth info extensions: // Skipped if no auth info extension options -* -*This transaction has other signers: // Skipped if there is only one signer -*Signer (/): -*Public Key: -*Sequence: +*Timeout Height: // Skipped if no timeout_height set. +*Other signer: SignerInfo // Skipped if the transaction only has 1 signer. +*> Other signer (/): *End of other signers -*Hash of raw bytes: // Hex encoding of bytes defined in #10, to prevent tx hash malleability. +*Extension options: Any: // Skipped if no body extension options +*> Extension options (/): +*End of extension options +*Non critical extension options: Any: // Skipped if no body non critical extension options +*> Non critical extension options (/): +*End of Non critical extension options +*Hash of raw bytes: // Hex encoding of bytes defined, to prevent tx hash malleability. ``` ### Encoding of the Transaction Body @@ -289,304 +292,13 @@ See [annex 2](./adr-050-sign-mode-textual-annex2.md). ## Examples -#### Example 1: Simple `MsgSend` - -JSON: - -```json -{ - "body": { - "messages": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...abc", - "to": "cosmos1...def", - "amount": [ - { - "denom": "uatom", - "amount": 10000000 - } - ] - } - ] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": "iQ...==", - "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, - "sequence": 2 - } - ], - "fee": { - "amount": [ - { - "denom": "atom", - "amount": 0.002 - } - ], - "gas_limit": 100000 - } - }, - // Additional SignerData. - "chain_id": "simapp-1", - "account_number": 10 -} -``` - -SIGN_MODE_TEXTUAL: - -``` -Chain ID: simapp-1 -Account number: 10 -*Public Key: iQ...== // Hex pubkey -Sequence: 2 -This transaction has 1 message: -Message (1/1): bank v1beta1 send coins -From: cosmos1...abc -To: cosmos1...def -Amount: 10 atom // Conversion from uatom to atom using value renderers -End of transaction messages -Fee: 0.002 atom -*Gas: 100'000 -*Hash of raw bytes: -``` - -#### Example 2: Multi-Msg Transaction with 3 signers - -#### Example 3: Legacy Multisig - -#### Example 4: Fee Payer with Tips - -```json -{ - "body": { - "messages": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...tipper", - "to": "cosmos1...abc", - "amount": [ - { - "denom": "uatom", - "amount": 10000000 - } - ] - } - ] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": "iQ...==", - "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT_AUX" } }, - "sequence": 42 - }, - { - "public_key": "iR...==", - "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, - "sequence": 2 - } - ], - "fee": { - "amount": [ - { - "denom": "atom", - "amount": 0.002 - } - ], - "gas_limit": 100000, - "payer": "cosmos1...feepayer" - }, - "tip": { - "amount": [ - { - "denom": "ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D", - "amount": 200 - } - ], - "tipper": "cosmos1...tipper" - } - }, - // Additional SignerData. - "chain_id": "simapp-1", - "account_number": 10 -} -``` - -SIGN_MODE_TEXTUAL for the feepayer: - -``` -Chain ID: simapp-1 -Account number: 10 -*Public Key: iR...== -Sequence: 2 -This transaction has 1 message: -Message (1/1): bank v1beta1 send coins -From: cosmos1...abc -To: cosmos1...def -Amount: 10 atom -End of transaction messages -Fee: 0.002 atom -Fee Payer: cosmos1...feepayer -Tipper: cosmos1...tipper -Tip: 200 ibc/CDC4587874B85BEA4FCEC3CEA5A1195139799A1FEE711A07D972537E18FDA39D -*Gas: 100'000 -*This transaction has 1 other signer: -*Signer (1/2): -*Public Key: iQ...== -*Sign mode: SIGN_MODE_DIRECT_AUX -*Sequence: 42 -*End of other signers -*Hash of raw bytes: -``` - -#### Example 5: Complex Transaction with Nested Messages - -JSON: - -```json -{ - "body": { - "messages": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...abc", - "to": "cosmos1...def", - "amount": [ - { - "denom": "uatom", - "amount": 10000000 - } - ] - }, - { - "@type": "/cosmos.gov.v1.MsgSubmitProposal", - "proposer": "cosmos1...ghi", - "messages": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...jkl", - "to": "cosmos1...mno", - "amount": [ - { - "denom": "uatom", - "amount": 20000000 - } - ] - }, - { - "@type": "/cosmos.authz.v1beta1.MsgExec", - "grantee": "cosmos1...pqr", - "msgs": [ - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...stu", - "to": "cosmos1...vwx", - "amount": [ - { - "denom": "uatom", - "amount": 30000000 - } - ] - }, - { - "@type": "/cosmos.bank.v1beta1.MsgSend", - "from": "cosmos1...abc", - "to": "cosmos1...def", - "amount": [ - { - "denom": "uatom", - "amount": 40000000 - } - ] - } - ] - } - ], - "initial_deposit": [ - { - "denom": "atom", - "amount": 100.01 - } - ] - } - ] - }, - "auth_info": { - "signer_infos": [ - { - "public_key": "iQ...==", - "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, - "sequence": 2 - }, - { - "public_key": "iR...==", - "mode_info": { "single": { "mode": "SIGN_MODE_DIRECT" } }, - "sequence": 42 - } - ], - "fee": { - "amount": [ - { - "denom": "atom", - "amount": 0.002 - } - ], - "gas_limit": 100000 - } - }, - // Additional SignerData. - "chain_id": "simapp-1", - "account_number": 10 -} -} -``` - -SIGN_MODE_TEXTUAL for 1st signer `cosmos1...abc`: +1. A minimal MsgSend: [see transaction](https://github.com/cosmos/cosmos-sdk/blob/094abcd393379acbbd043996024d66cd65246fb1/tx/textual/internal/testdata/e2e.json#L2-L70). +2. A transaction with a bit of everything: [see transaction](https://github.com/cosmos/cosmos-sdk/blob/094abcd393379acbbd043996024d66cd65246fb1/tx/textual/internal/testdata/e2e.json#L71-L270). -``` -Chain ID: simapp-1 -Account number: 10 -*Public Key: iQ...== -Sequence: 2 -This transaction has 2 messages: -Message (1/2): bank v1beta1 send coins -From: cosmos1...abc -To: cosmos1...def -Amount: 10 atom -Message (2/2): gov v1 submit proposal -Messages: 2 Messages -> Message (1/2): bank v1beta1 send coins -> From: cosmos1...jkl -> To: cosmos1...mno -> Amount: 20 atom -> Message (2/2): authz v1beta exec -> Grantee: cosmos1...pqr -> Msgs: 2 Msgs ->> Msg (1/2): bank v1beta1 send coins ->> From: cosmos1...stu ->> To: cosmos1...vwx ->> Amount: 30 atom ->> Msg (2/2): bank v1beta1 send coins ->> From: cosmos1...abc ->> To: cosmos1...def ->> Amount: 40 atom -> End of Msgs -End of transaction messages -Proposer: cosmos1...ghi -Initial Deposit: 100.01 atom -End of transaction messages -Fee: 0.002 atom -*Gas: 100'000 -*This transaction has 1 other signer: -*Signer (2/2): -*Public Key: iR...== -*Sign mode: SIGN_MODE_DIRECT -*Sequence: 42 -*End of other signers -*Hash of raw bytes: -``` +The examples below are stored in a JSON file with the following fields: +- `proto`: the representation of the transaction in ProtoJSON, +- `screens`: the transaction rendered into SIGN_MODE_TEXTUAL screens, +- `cbor`: the sign bytes of the transaction, which is the CBOR encoding of the screens. ## Consequences diff --git a/tx/signing/sign_mode_handler.go b/tx/signing/sign_mode_handler.go new file mode 100644 index 000000000000..a4ac86eb7d5c --- /dev/null +++ b/tx/signing/sign_mode_handler.go @@ -0,0 +1,34 @@ +package signing + +import "google.golang.org/protobuf/types/known/anypb" + +// SignerData is the specific information needed to sign a transaction that generally +// isn't included in the transaction body itself +type SignerData struct { + // The address of the signer. + // + // In case of multisigs, this should be the multisig's address. + Address string + + // ChainId is the chain that this transaction is targeted + ChainId string + + // AccountNumber is the account number of the signer. + // + // In case of multisigs, this should be the multisig account number. + AccountNumber uint64 + + // Sequence is the account sequence number of the signer that is used + // for replay protection. This field is only useful for Legacy Amino signing, + // since in SIGN_MODE_DIRECT the account sequence is already in the signer + // info. + // + // In case of multisigs, this should be the multisig sequence. + Sequence uint64 + + // PubKey is the public key of the signer. + // + // In case of multisigs, this should be the pubkey of the member of the + // multisig that is signing the current sign doc. + PubKey *anypb.Any +} diff --git a/tx/textual/internal/testdata/coin.json b/tx/textual/internal/testdata/coin.json index ea4de172db83..29e6cf01c9a4 100644 --- a/tx/textual/internal/testdata/coin.json +++ b/tx/textual/internal/testdata/coin.json @@ -94,36 +94,6 @@ "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, "text": "0 ucosm" }, - { - "proto": {"amount": "0.000001", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "1 ucosm" - }, - { - "proto": {"amount": "0.00001", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "10 ucosm" - }, - { - "proto": {"amount": "0.0001", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "100 ucosm" - }, - { - "proto": {"amount": "0.001", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "1'000 ucosm" - }, - { - "proto": {"amount": "0.01", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "10'000 ucosm" - }, - { - "proto": {"amount": "0.1", "denom": "COSM"}, - "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, - "text": "100'000 ucosm" - }, { "proto": {"amount": "1", "denom": "COSM"}, "metadata": {"display": "ucosm", "base":"COSM", "denom_units": [{"denom": "COSM", "exponent": 6}, {"denom": "ucosm", "exponent": 0}]}, diff --git a/tx/textual/internal/testdata/e2e.json b/tx/textual/internal/testdata/e2e.json new file mode 100644 index 000000000000..5eb670f92921 --- /dev/null +++ b/tx/textual/internal/testdata/e2e.json @@ -0,0 +1,271 @@ +[ + { + "name": "minimal", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "to_address": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "amount": [{ "denom": "uatom", "amount": "10000000" }] + } + ] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000 + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 1 Message" }, + { "text": "Message (1/1): /cosmos.bank.v1beta1.MsgSend", "indent": 1 }, + { "text": "MsgSend object", "indent": 2 }, + { "text": "From address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "To address: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "indent": 3 }, + { "text": "Amount: 10 ATOM", "indent": 3 }, + { "text": "End of Message" }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Hash of raw bytes: 785bd306ea8962cdb9600089bdd65f3dc029e1aea112dee69e19546c9adad86e", "expert": true } + ], + "cbor": "91a10172436861696e2069643a206d792d636861696ea101714163636f756e74206e756d6265723a2031a1016b53657175656e63653a2032a1017836416464726573733a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e7671613865796873a201782b5075626c6963206b65793a202f636f736d6f732e63727970746f2e736563703235366b312e5075624b657903f5a3016d5075624b6579206f626a656374020103f5a301785c4b65793a205348412d3235363d46373935203246374620343132302043383136204446434620463036302045343836203733344220303134352035393042203139363820333835362044443030203330373420424430442031343643020203f5a101781e54686973207472616e73616374696f6e206861732031204d657373616765a201782b4d6573736167652028312f31293a202f636f736d6f732e62616e6b2e763162657461312e4d736753656e640201a2016e4d736753656e64206f626a6563740202a201783b46726f6d20616464726573733a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730203a2017839546f20616464726573733a20636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b6835740203a2016f416d6f756e743a2031302041544f4d0203a1016e456e64206f66204d657373616765a10170466565733a20302e3030322041544f4da20172476173206c696d69743a203130302730303003f5a201785348617368206f66207261772062797465733a203738356264333036656138393632636462393630303038396264643635663364633032396531616561313132646565363965313935343663396164616438366503f5" + }, + { + "name": "a bit of everything", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "msgs": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "to_address": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "amount": [{ "denom": "uatom", "amount": "10000000" }] + } + ] + }, + { + "@type": "/cosmos.gov.v1.MsgVote", + "proposal_id": 1, + "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "option": "VOTE_OPTION_YES", + "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" + } + ], + "memo": "> ⚛️\\u269B⚛️ ", + "timeout_height": 20, + "extension_options": [ + { + "@type": "/cosmos.base.v1beta1.Coin", + "amount": "5000000", + "denom": "uatom" + } + ], + "non_critical_extension_options": [ + { + "@type": "/cosmos.auth.v1beta1.Params", + "maxMemoCharacters": 10 + } + ] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + }, + { + "public_key": { + "@type": "/cosmos.crypto.multisig.LegacyAminoPubKey", + "threshold": 2, + "public_keys": [ + { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "AldOvgv8dU9ZZzuhGydQD5FYreLhfhoBgrDKi8ZSTbCT" + }, + { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "AxUMR/GKoycWplR+2otzaQZ9zhHRQWJFt3h1bPg1lnh3" + } + ] + }, + "mode_info": { + "multi": { + "bitarray": { + "extra_bits_stored": 5, + "elems": "SA==" + }, + "mode_infos": [ + { + "single": { + "mode": "SIGN_MODE_LEGACY_AMINO_JSON" + } + }, + { + "single": { + "mode": "SIGN_MODE_LEGACY_AMINO_JSON" + } + } + ] + } + }, + "sequence": 5 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000, + "payer": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "granter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" + }, + "tip": { + "amount": [ + { "amount": "20000", "denom": "uatom" }, + { "amount": "30000", "denom": "uosmo" } + ], + "tipper": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t" + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 2 Messages" }, + { "text": "Message (1/2): /cosmos.authz.v1beta1.MsgExec", "indent": 1 }, + { "text": "MsgExec object", "indent": 2 }, + { "text": "Grantee: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "Msgs: 1 Any", "indent": 3 }, + { "text": "Msgs (1/1): /cosmos.bank.v1beta1.MsgSend", "indent": 4 }, + { "text": "MsgSend object", "indent": 5 }, + { "text": "From address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 6 }, + { "text": "To address: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "indent": 6 }, + { "text": "Amount: 10 ATOM", "indent": 6 }, + { "text": "End of Msgs", "indent": 3 }, + { "text": "Message (2/2): /cosmos.gov.v1.MsgVote", "indent": 1 }, + { "text": "MsgVote object", "indent": 2 }, + { "text": "Proposal id: 1", "indent": 3 }, + { "text": "Voter: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "Option: VOTE_OPTION_YES", "indent": 3 }, + { + "text": "Metadata: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", + "indent": 3 + }, + { "text": "End of Message" }, + { "text": "Memo: > ⚛️\\u269B⚛️ " }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Fee payer: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "expert": true }, + { "text": "Fee granter: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "expert": true }, + { "text": "Tip: 0.02 ATOM, 30'000 uosmo" }, + { "text": "Tipper: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Timeout height: 20", "expert": true }, + { "text": "Other signer: 1 SignerInfo", "expert": true }, + { "text": "Other signer (1/1): SignerInfo object", "indent": 1, "expert": true }, + { "text": "Public key: /cosmos.crypto.multisig.LegacyAminoPubKey", "indent": 2, "expert": true }, + { "text": "LegacyAminoPubKey object", "indent": 3, "expert": true }, + { "text": "Threshold: 2", "indent": 4, "expert": true }, + { "text": "Public keys: 2 Any", "indent": 4, "expert": true }, + { "text": "Public keys (1/2): /cosmos.crypto.secp256k1.PubKey", "indent": 5, "expert": true }, + { "text": "PubKey object", "indent": 6, "expert": true }, + { "text": "Key: SHA-256=8560 3B16 9613 06E3 9D23 BEE0 3156 7D77 F9BB 5977 A249 529F 8D9C AE2D 71CA 0ADE", "indent": 7, "expert": true }, + { "text": "Public keys (2/2): /cosmos.crypto.ed25519.PubKey", "indent": 5, "expert": true }, + { "text": "PubKey object", "indent": 6, "expert": true }, + { "text": "Key: SHA-256=2DEF 8D73 17D8 7F1F A337 CA21 9CDE 80EC C602 6605 1328 B964 E27D 056A 94DD AC64", "indent": 7, "expert": true }, + { "text": "End of Public keys", "indent": 4, "expert": true }, + { "text": "Mode info: ModeInfo object", "indent": 2, "expert": true }, + { "text": "Multi: Multi object", "indent": 3, "expert": true }, + { "text": "Bitarray: CompactBitArray object", "indent": 4, "expert": true }, + { "text": "Extra bits stored: 5", "indent": 5, "expert": true }, + { "text": "Elems: 48", "indent": 5, "expert": true }, + { "text": "Mode infos: 2 ModeInfo", "indent": 4, "expert": true }, + { "text": "Mode infos (1/2): ModeInfo object", "indent": 5, "expert": true }, + { "text": "Single: Single object", "indent": 6, "expert": true }, + { "text": "Mode: SIGN_MODE_LEGACY_AMINO_JSON", "indent": 7, "expert": true }, + { "text": "Mode infos (2/2): ModeInfo object", "indent": 5, "expert": true }, + { "text": "Single: Single object", "indent": 6, "expert": true }, + { "text": "Mode: SIGN_MODE_LEGACY_AMINO_JSON", "indent": 7, "expert": true }, + { "text": "End of Mode infos", "indent": 4, "expert": true }, + { "text": "Sequence: 5", "indent": 2, "expert": true }, + { "text": "End of Other signer", "expert": true }, + { "text": "Extension options: 1 Any", "expert": true }, + { "text": "Extension options (1/1): /cosmos.base.v1beta1.Coin", "indent": 1, "expert": true }, + { "text": "5 ATOM", "indent": 2, "expert": true }, + { "text": "End of Extension options", "expert": true }, + { "text": "Non critical extension options: 1 Any", "expert": true }, + { "text": "Non critical extension options (1/1): /cosmos.auth.v1beta1.Params", "indent": 1, "expert": true }, + { "text": "Params object", "indent": 2, "expert": true }, + { "text": "Max memo characters: 10", "indent": 3, "expert": true }, + { "text": "End of Non critical extension options", "expert": true }, + { "text": "Hash of raw bytes: 7ea02e8f0baed2db969e2d9ae4dc51fa31116259bd42897588072faf0ebb4d2e", "expert": true } + ], + "cbor": "9847a10172436861696e2069643a206d792d636861696ea101714163636f756e74206e756d6265723a2031a1016b53657175656e63653a2032a1017836416464726573733a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e7671613865796873a201782b5075626c6963206b65793a202f636f736d6f732e63727970746f2e736563703235366b312e5075624b657903f5a3016d5075624b6579206f626a656374020103f5a301785c4b65793a205348412d3235363d46373935203246374620343132302043383136204446434620463036302045343836203733344220303134352035393042203139363820333835362044443030203330373420424430442031343643020203f5a101781f54686973207472616e73616374696f6e206861732032204d65737361676573a201782c4d6573736167652028312f32293a202f636f736d6f732e617574687a2e763162657461312e4d7367457865630201a2016e4d736745786563206f626a6563740202a20178364772616e7465653a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730203a2016b4d7367733a203120416e790203a20178284d7367732028312f31293a202f636f736d6f732e62616e6b2e763162657461312e4d736753656e640204a2016e4d736753656e64206f626a6563740205a201783b46726f6d20616464726573733a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730206a2017839546f20616464726573733a20636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b6835740206a2016f416d6f756e743a2031302041544f4d0206a2016b456e64206f66204d7367730203a20178254d6573736167652028322f32293a202f636f736d6f732e676f762e76312e4d7367566f74650201a2016e4d7367566f7465206f626a6563740202a2016e50726f706f73616c2069643a20310203a2017834566f7465723a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e76716138657968730203a201774f7074696f6e3a20564f54455f4f5054494f4e5f5945530203a2017901ed4d657461646174613a204c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742c2073656420646f20656975736d6f642074656d706f7220696e6369646964756e74207574206c61626f726520657420646f6c6f7265206d61676e6120616c697175612e20557420656e696d206164206d696e696d2076656e69616d2c2071756973206e6f737472756420657865726369746174696f6e20756c6c616d636f206c61626f726973206e69736920757420616c697175697020657820656120636f6d6d6f646f20636f6e7365717561742e2044756973206175746520697275726520646f6c6f7220696e20726570726568656e646572697420696e20766f6c7570746174652076656c697420657373652063696c6c756d20646f6c6f726520657520667567696174206e756c6c612070617269617475722e204578636570746575722073696e74206f6363616563617420637570696461746174206e6f6e2070726f6964656e742c2073756e7420696e2063756c706120717569206f666669636961206465736572756e74206d6f6c6c697420616e696d20696420657374206c61626f72756d2e20416c736f20697420656e647320696e2020612073696e676c6520616d70657273616e6420400203a1016e456e64206f66204d657373616765a101781f4d656d6f3a203e20e29a9befb88f5c7532363942e29a9befb88f2020202020a10170466565733a20302e3030322041544f4da20178384665652070617965723a20636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b68357403f5a201783a466565206772616e7465723a20636f736d6f7331756c6176336873656e7570737771666b77327933737570356b677471776e767161386579687303f5a101781c5469703a20302e30322041544f4d2c2033302730303020756f736d6fa10178355469707065723a20636f736d6f7331656a726634637572327779366b667572673966326a707070326833616665356836706b683574a20172476173206c696d69743a203130302730303003f5a2017254696d656f7574206865696768743a20323003f5a201781a4f74686572207369676e65723a2031205369676e6572496e666f03f5a30178254f74686572207369676e65722028312f31293a205369676e6572496e666f206f626a656374020103f5a30178355075626c6963206b65793a202f636f736d6f732e63727970746f2e6d756c74697369672e4c6567616379416d696e6f5075624b6579020203f5a30178184c6567616379416d696e6f5075624b6579206f626a656374020303f5a3016c5468726573686f6c643a2032020403f5a301725075626c6963206b6579733a203220416e79020403f5a30178325075626c6963206b6579732028312f32293a202f636f736d6f732e63727970746f2e736563703235366b312e5075624b6579020503f5a3016d5075624b6579206f626a656374020603f5a301785c4b65793a205348412d3235363d38353630203342313620393631332030364533203944323320424545302033313536203744373720463942422035393737204132343920353239462038443943204145324420373143412030414445020703f5a30178305075626c6963206b6579732028322f32293a202f636f736d6f732e63727970746f2e656432353531392e5075624b6579020503f5a3016d5075624b6579206f626a656374020603f5a301785c4b65793a205348412d3235363d32444546203844373320313744382037463146204133333720434132312039434445203830454320433630322036363035203133323820423936342045323744203035364120393444442041433634020703f5a30172456e64206f66205075626c6963206b657973020403f5a301781a4d6f646520696e666f3a204d6f6465496e666f206f626a656374020203f5a301734d756c74693a204d756c7469206f626a656374020303f5a301782042697461727261793a20436f6d706163744269744172726179206f626a656374020403f5a30174457874726120626974732073746f7265643a2035020503f5a30169456c656d733a203438020503f5a301764d6f646520696e666f733a2032204d6f6465496e666f020403f5a30178214d6f646520696e666f732028312f32293a204d6f6465496e666f206f626a656374020503f5a3017553696e676c653a2053696e676c65206f626a656374020603f5a30178214d6f64653a205349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e020703f5a30178214d6f646520696e666f732028322f32293a204d6f6465496e666f206f626a656374020503f5a3017553696e676c653a2053696e676c65206f626a656374020603f5a30178214d6f64653a205349474e5f4d4f44455f4c45474143595f414d494e4f5f4a534f4e020703f5a30171456e64206f66204d6f646520696e666f73020403f5a3016b53657175656e63653a2035020203f5a20173456e64206f66204f74686572207369676e657203f5a2017818457874656e73696f6e206f7074696f6e733a203120416e7903f5a3017832457874656e73696f6e206f7074696f6e732028312f31293a202f636f736d6f732e626173652e763162657461312e436f696e020103f5a30166352041544f4d020203f5a2017818456e64206f6620457874656e73696f6e206f7074696f6e7303f5a20178254e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e733a203120416e7903f5a30178414e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e732028312f31293a202f636f736d6f732e617574682e763162657461312e506172616d73020103f5a3016d506172616d73206f626a656374020203f5a301774d6178206d656d6f20636861726163746572733a203130020303f5a2017825456e64206f66204e6f6e20637269746963616c20657874656e73696f6e206f7074696f6e7303f5a201785348617368206f66207261772062797465733a203765613032653866306261656432646239363965326439616534646335316661333131313632353962643432383937353838303732666166306562623464326503f5" + } +] diff --git a/tx/textual/internal/testdata/enum.json b/tx/textual/internal/testdata/enum.json index 47c73c600b89..1238797e8ba1 100644 --- a/tx/textual/internal/testdata/enum.json +++ b/tx/textual/internal/testdata/enum.json @@ -2,8 +2,8 @@ { "proto": { "ee": 0 }, "text": "One" }, { "proto": { "ee": 1 }, "text": "Two" }, { "proto": { "ee": 127 }, "text": "EXTERNAL_ENUM_THREE" }, - { "proto": { "ie": 0 }, "text": "Baz.Four" }, - { "proto": { "ie": 1 }, "text": "Baz.Five" }, + { "proto": { "ie": 0 }, "text": "Four" }, + { "proto": { "ie": 1 }, "text": "Five" }, { "proto": { "option": 0 }, "text": "BALLOT_OPTION_UNSPECIFIED" }, { "proto": { "option": 1 }, "text": "BALLOT_OPTION_YES" }, { "proto": { "option": 4 }, "text": "BALLOT_OPTION_NO_WITH_VETO" } diff --git a/tx/textual/internal/testdata/tx.json b/tx/textual/internal/testdata/tx.json new file mode 100644 index 000000000000..1f59ba62449d --- /dev/null +++ b/tx/textual/internal/testdata/tx.json @@ -0,0 +1,412 @@ +[ + { + "name": "minimal", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "to_address": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "amount": [{ "denom": "uatom", "amount": "10000000" }] + } + ] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000 + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 1 Message" }, + { "text": "Message (1/1): /cosmos.bank.v1beta1.MsgSend", "indent": 1 }, + { "text": "MsgSend object", "indent": 2 }, + { "text": "From address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "To address: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "indent": 3 }, + { "text": "Amount: 10 ATOM", "indent": 3 }, + { "text": "End of Message" }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Hash of raw bytes: 785bd306ea8962cdb9600089bdd65f3dc029e1aea112dee69e19546c9adad86e", "expert": true } + ] + }, + { + "name": "tricky memo (starts with >, utf-8, trailing whitespaces)", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "to_address": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "amount": [{ "denom": "uatom", "amount": "10000000" }] + } + ], + "memo": "> ⚛️\\u269B⚛️ " + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000 + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 1 Message" }, + { "text": "Message (1/1): /cosmos.bank.v1beta1.MsgSend", "indent": 1 }, + { "text": "MsgSend object", "indent": 2 }, + { "text": "From address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "To address: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "indent": 3 }, + { "text": "Amount: 10 ATOM", "indent": 3 }, + { "text": "End of Message" }, + { "text": "Memo: > ⚛️\\u269B⚛️ " }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Hash of raw bytes: 9c043290109c270b2ffa9f3c0fa55a090c0125ebef881f7da53978dbf93f7385", "expert": true } + ] + }, + { + "name": "long text in nested value", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.gov.v1.MsgVote", + "proposal_id": 1, + "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "option": "VOTE_OPTION_YES", + "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" + } + ] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000 + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 1 Message" }, + { "text": "Message (1/1): /cosmos.gov.v1.MsgVote", "indent": 1 }, + { "text": "MsgVote object", "indent": 2 }, + { "text": "Proposal id: 1", "indent": 3 }, + { "text": "Voter: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "Option: VOTE_OPTION_YES", "indent": 3 }, + { + "text": "Metadata: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", + "indent": 3 + }, + { "text": "End of Message" }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Hash of raw bytes: 0397a88038a9d5f4cc60e3e06bb02bb9f093209fd72057008fddaeab6f039d74", "expert": true } + ] + }, + { + "name": "a bit of everything", + "proto": { + "body": { + "messages": [ + { + "@type": "/cosmos.authz.v1beta1.MsgExec", + "grantee": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "msgs": [ + { + "@type": "/cosmos.bank.v1beta1.MsgSend", + "from_address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "to_address": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "amount": [{ "denom": "uatom", "amount": "10000000" }] + } + ] + }, + { + "@type": "/cosmos.gov.v1.MsgVote", + "proposal_id": 1, + "voter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "option": "VOTE_OPTION_YES", + "metadata": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @" + } + ], + "memo": "> ⚛️\\u269B⚛️ ", + "timeout_height": 20, + "extension_options": [ + { + "@type": "/cosmos.base.v1beta1.Coin", + "amount": "5000000", + "denom": "uatom" + } + ], + "non_critical_extension_options": [ + { + "@type": "/cosmos.auth.v1beta1.Params", + "maxMemoCharacters": 10 + } + ] + }, + "auth_info": { + "signer_infos": [ + { + "public_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "mode_info": { "single": { "mode": "SIGN_MODE_TEXTUAL" } }, + "sequence": 2 + }, + { + "public_key": { + "@type": "/cosmos.crypto.multisig.LegacyAminoPubKey", + "threshold": 2, + "public_keys": [ + { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "AldOvgv8dU9ZZzuhGydQD5FYreLhfhoBgrDKi8ZSTbCT" + }, + { + "@type": "/cosmos.crypto.ed25519.PubKey", + "key": "AxUMR/GKoycWplR+2otzaQZ9zhHRQWJFt3h1bPg1lnh3" + } + ] + }, + "mode_info": { + "multi": { + "bitarray": { + "extra_bits_stored": 5, + "elems": "SA==" + }, + "mode_infos": [ + { + "single": { + "mode": "SIGN_MODE_LEGACY_AMINO_JSON" + } + }, + { + "single": { + "mode": "SIGN_MODE_LEGACY_AMINO_JSON" + } + } + ] + } + }, + "sequence": 5 + } + ], + "fee": { + "amount": [{ "denom": "uatom", "amount": "2000" }], + "gas_limit": 100000, + "payer": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", + "granter": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" + }, + "tip": { + "amount": [ + { "amount": "20000", "denom": "uatom" }, + { "amount": "30000", "denom": "uosmo" } + ], + "tipper": "cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t" + } + } + }, + "signer_data": { + "account_number": 1, + "address": "cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", + "chain_id": "my-chain", + "pub_key": { + "@type": "/cosmos.crypto.secp256k1.PubKey", + "key": "Auvdf+T963bciiBe9l15DNMOijdaXCUo6zqSOvH7TXlN" + }, + "sequence": 2 + }, + "metadata": { + "display": "ATOM", + "base": "uatom", + "denom_units": [ + { "denom": "ATOM", "exponent": 6 }, + { "denom": "uatom", "exponent": 0 } + ] + }, + "screens": [ + { "text": "Chain id: my-chain" }, + { "text": "Account number: 1" }, + { "text": "Sequence: 2" }, + { "text": "Address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs" }, + { "text": "Public key: /cosmos.crypto.secp256k1.PubKey", "expert": true }, + { "text": "PubKey object", "indent": 1, "expert": true }, + { "text": "Key: SHA-256=F795 2F7F 4120 C816 DFCF F060 E486 734B 0145 590B 1968 3856 DD00 3074 BD0D 146C", "indent": 2, "expert": true }, + { "text": "This transaction has 2 Messages" }, + { "text": "Message (1/2): /cosmos.authz.v1beta1.MsgExec", "indent": 1 }, + { "text": "MsgExec object", "indent": 2 }, + { "text": "Grantee: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "Msgs: 1 Any", "indent": 3 }, + { "text": "Msgs (1/1): /cosmos.bank.v1beta1.MsgSend", "indent": 4 }, + { "text": "MsgSend object", "indent": 5 }, + { "text": "From address: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 6 }, + { "text": "To address: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "indent": 6 }, + { "text": "Amount: 10 ATOM", "indent": 6 }, + { "text": "End of Msgs", "indent": 3 }, + { "text": "Message (2/2): /cosmos.gov.v1.MsgVote", "indent": 1 }, + { "text": "MsgVote object", "indent": 2 }, + { "text": "Proposal id: 1", "indent": 3 }, + { "text": "Voter: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "indent": 3 }, + { "text": "Option: VOTE_OPTION_YES", "indent": 3 }, + { + "text": "Metadata: Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Also it ends in a single ampersand @", + "indent": 3 + }, + { "text": "End of Message" }, + { "text": "Memo: > ⚛️\\u269B⚛️ " }, + { "text": "Fees: 0.002 ATOM" }, + { "text": "Fee payer: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t", "expert": true }, + { "text": "Fee granter: cosmos1ulav3hsenupswqfkw2y3sup5kgtqwnvqa8eyhs", "expert": true }, + { "text": "Tip: 0.02 ATOM, 30'000 uosmo" }, + { "text": "Tipper: cosmos1ejrf4cur2wy6kfurg9f2jppp2h3afe5h6pkh5t" }, + { "text": "Gas limit: 100'000", "expert": true }, + { "text": "Timeout height: 20", "expert": true }, + { "text": "Other signer: 1 SignerInfo", "expert": true }, + { "text": "Other signer (1/1): SignerInfo object", "indent": 1, "expert": true }, + { "text": "Public key: /cosmos.crypto.multisig.LegacyAminoPubKey", "indent": 2, "expert": true }, + { "text": "LegacyAminoPubKey object", "indent": 3, "expert": true }, + { "text": "Threshold: 2", "indent": 4, "expert": true }, + { "text": "Public keys: 2 Any", "indent": 4, "expert": true }, + { "text": "Public keys (1/2): /cosmos.crypto.secp256k1.PubKey", "indent": 5, "expert": true }, + { "text": "PubKey object", "indent": 6, "expert": true }, + { "text": "Key: SHA-256=8560 3B16 9613 06E3 9D23 BEE0 3156 7D77 F9BB 5977 A249 529F 8D9C AE2D 71CA 0ADE", "indent": 7, "expert": true }, + { "text": "Public keys (2/2): /cosmos.crypto.ed25519.PubKey", "indent": 5, "expert": true }, + { "text": "PubKey object", "indent": 6, "expert": true }, + { "text": "Key: SHA-256=2DEF 8D73 17D8 7F1F A337 CA21 9CDE 80EC C602 6605 1328 B964 E27D 056A 94DD AC64", "indent": 7, "expert": true }, + { "text": "End of Public keys", "indent": 4, "expert": true }, + { "text": "Mode info: ModeInfo object", "indent": 2, "expert": true }, + { "text": "Multi: Multi object", "indent": 3, "expert": true }, + { "text": "Bitarray: CompactBitArray object", "indent": 4, "expert": true }, + { "text": "Extra bits stored: 5", "indent": 5, "expert": true }, + { "text": "Elems: 48", "indent": 5, "expert": true }, + { "text": "Mode infos: 2 ModeInfo", "indent": 4, "expert": true }, + { "text": "Mode infos (1/2): ModeInfo object", "indent": 5, "expert": true }, + { "text": "Single: Single object", "indent": 6, "expert": true }, + { "text": "Mode: SIGN_MODE_LEGACY_AMINO_JSON", "indent": 7, "expert": true }, + { "text": "Mode infos (2/2): ModeInfo object", "indent": 5, "expert": true }, + { "text": "Single: Single object", "indent": 6, "expert": true }, + { "text": "Mode: SIGN_MODE_LEGACY_AMINO_JSON", "indent": 7, "expert": true }, + { "text": "End of Mode infos", "indent": 4, "expert": true }, + { "text": "Sequence: 5", "indent": 2, "expert": true }, + { "text": "End of Other signer", "expert": true }, + { "text": "Extension options: 1 Any", "expert": true }, + { "text": "Extension options (1/1): /cosmos.base.v1beta1.Coin", "indent": 1, "expert": true }, + { "text": "5 ATOM", "indent": 2, "expert": true }, + { "text": "End of Extension options", "expert": true }, + { "text": "Non critical extension options: 1 Any", "expert": true }, + { "text": "Non critical extension options (1/1): /cosmos.auth.v1beta1.Params", "indent": 1, "expert": true }, + { "text": "Params object", "indent": 2, "expert": true }, + { "text": "Max memo characters: 10", "indent": 3, "expert": true }, + { "text": "End of Non critical extension options", "expert": true }, + { "text": "Hash of raw bytes: 7ea02e8f0baed2db969e2d9ae4dc51fa31116259bd42897588072faf0ebb4d2e", "expert": true } + ] + } +] diff --git a/tx/textual/internal/textualpb/Makefile b/tx/textual/internal/textualpb/Makefile new file mode 100644 index 000000000000..f102fd503e2a --- /dev/null +++ b/tx/textual/internal/textualpb/Makefile @@ -0,0 +1,2 @@ +codegen: + @(buf generate) diff --git a/tx/textual/internal/textualpb/buf.gen.yaml b/tx/textual/internal/textualpb/buf.gen.yaml new file mode 100644 index 000000000000..cb7e5827824c --- /dev/null +++ b/tx/textual/internal/textualpb/buf.gen.yaml @@ -0,0 +1,15 @@ +version: v1 +managed: + enabled: true + go_package_prefix: + default: cosmossdk.io/tx/textual/internal/textualpb + except: + - buf.build/googleapis/googleapis + - buf.build/cosmos/gogo-proto + - buf.build/cosmos/cosmos-proto + override: + buf.build/cosmos/cosmos-sdk: cosmossdk.io/api +plugins: + - name: go-pulsar + out: . + opt: paths=source_relative diff --git a/tx/textual/internal/textualpb/buf.lock b/tx/textual/internal/textualpb/buf.lock new file mode 100644 index 000000000000..259bd9ce82b1 --- /dev/null +++ b/tx/textual/internal/textualpb/buf.lock @@ -0,0 +1,11 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: cosmos + repository: cosmos-proto + commit: 1935555c206d4afb9e94615dfd0fad31 + - remote: buf.build + owner: cosmos + repository: gogo-proto + commit: 6652e3443c3b4504bb3bf82e73a7e409 diff --git a/tx/textual/internal/textualpb/buf.yaml b/tx/textual/internal/textualpb/buf.yaml new file mode 100644 index 000000000000..5aee45ac2b4f --- /dev/null +++ b/tx/textual/internal/textualpb/buf.yaml @@ -0,0 +1,12 @@ +version: v1 +deps: + - buf.build/cosmos/cosmos-proto + - buf.build/cosmos/gogo-proto +lint: + use: + - DEFAULT + except: + - PACKAGE_VERSION_SUFFIX +breaking: + ignore: + - testpb diff --git a/tx/textual/internal/textualpb/doc.go b/tx/textual/internal/textualpb/doc.go new file mode 100644 index 000000000000..ecb2df9801b9 --- /dev/null +++ b/tx/textual/internal/textualpb/doc.go @@ -0,0 +1,3 @@ +// Package textualpb contains all protobuf definitions and generated codes +// used internally by Textual. +package textualpb diff --git a/tx/textual/internal/textualpb/textual.proto b/tx/textual/internal/textualpb/textual.proto new file mode 100644 index 000000000000..3a3056ef8539 --- /dev/null +++ b/tx/textual/internal/textualpb/textual.proto @@ -0,0 +1,89 @@ +syntax = "proto3"; + +import "cosmos/base/v1beta1/coin.proto"; +import "cosmos/tx/v1beta1/tx.proto"; +import "cosmos_proto/cosmos.proto"; +import "google/protobuf/any.proto"; + +// TextualData represents all the information needed to generate +// the textual SignDoc (which is []Screen encoded to CBOR). It is meant to be +// used as an internal type in Textual's implementations. +message TextualData { + // body_bytes is a protobuf serialization of a TxBody that matches the + // representation in SignDoc. + bytes body_bytes = 1; + + // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + // representation in SignDoc. + bytes auth_info_bytes = 2; + + // signer_data represents all data in Textual's SignDoc that are not + // inside the Tx body and auth_info. + SignerData signer_data = 3; +} + +// SignerData is the specific information needed to sign a transaction that generally +// isn't included in the transaction body itself. +// +// It is the same struct as signing.SignerData, but only used internally +// in Textual because we need it as a proto.Message. If that struct is updated, +// then this proto SignerData also needs to be modified. +message SignerData { + // address is the address of the signer. + // + // In case of multisigs, this should be the multisig's address. + string address = 1 [(cosmos_proto.scalar) = "AddressString"]; + + // chain_id is the chain that this transaction is targeting. + string chain_id = 2; + + // account_number is the account number of the signer. + // + // In case of multisigs, this should be the multisig account number. + uint64 account_number = 3; + + // sequence is the account sequence number of the signer that is used + // for replay protection. This field is only useful for Legacy Amino signing, + // since in SIGN_MODE_DIRECT the account sequence is already in the signer + // info. + // + // In case of multisigs, this should be the multisig sequence. + uint64 sequence = 4; + + // pub_key is the public key of the signer. + // + // In case of multisigs, this should be the pubkey of the member of the + // multisig that is signing the current sign doc. + google.protobuf.Any pub_key = 5; +} + +// Envelope is an internal data structure used to generate the tx envelope +// screens. It is derived from the TextualData struct (also internal) which +// contains the three following fields: +// - body_bytes (from the original tx), +// - auth_info_bytes (from the original tx), +// - signer_data (passed in by the sign mode handler) +// +// If any of the three structs above is modified, then this Envelope message +// also needs to be updated. +message Envelope { + string chain_id = 1; + uint64 account_number = 2; + uint64 sequence = 3; + string address = 4; + google.protobuf.Any public_key = 5; + repeated google.protobuf.Any message = 6; + string memo = 7; + repeated cosmos.base.v1beta1.Coin fees = 8; + string fee_payer = 9; + string fee_granter = 10; + repeated cosmos.base.v1beta1.Coin tip = 11; + string tipper = 12; + uint64 gas_limit = 13; + uint64 timeout_height = 14; + repeated cosmos.tx.v1beta1.SignerInfo other_signer = 15; + repeated google.protobuf.Any extension_options = 16; + repeated google.protobuf.Any non_critical_extension_options = 17; + string hash_of_raw_bytes = 18; +} + diff --git a/tx/textual/internal/textualpb/textual.pulsar.go b/tx/textual/internal/textualpb/textual.pulsar.go new file mode 100644 index 000000000000..14b94260756f --- /dev/null +++ b/tx/textual/internal/textualpb/textual.pulsar.go @@ -0,0 +1,3682 @@ +// Code generated by protoc-gen-go-pulsar. DO NOT EDIT. +package textualpb + +import ( + v1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + v1beta11 "cosmossdk.io/api/cosmos/tx/v1beta1" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + runtime "github.com/cosmos/cosmos-proto/runtime" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoiface "google.golang.org/protobuf/runtime/protoiface" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + io "io" + reflect "reflect" + sync "sync" +) + +var ( + md_TextualData protoreflect.MessageDescriptor + fd_TextualData_body_bytes protoreflect.FieldDescriptor + fd_TextualData_auth_info_bytes protoreflect.FieldDescriptor + fd_TextualData_signer_data protoreflect.FieldDescriptor +) + +func init() { + file_textual_proto_init() + md_TextualData = File_textual_proto.Messages().ByName("TextualData") + fd_TextualData_body_bytes = md_TextualData.Fields().ByName("body_bytes") + fd_TextualData_auth_info_bytes = md_TextualData.Fields().ByName("auth_info_bytes") + fd_TextualData_signer_data = md_TextualData.Fields().ByName("signer_data") +} + +var _ protoreflect.Message = (*fastReflection_TextualData)(nil) + +type fastReflection_TextualData TextualData + +func (x *TextualData) ProtoReflect() protoreflect.Message { + return (*fastReflection_TextualData)(x) +} + +func (x *TextualData) slowProtoReflect() protoreflect.Message { + mi := &file_textual_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_TextualData_messageType fastReflection_TextualData_messageType +var _ protoreflect.MessageType = fastReflection_TextualData_messageType{} + +type fastReflection_TextualData_messageType struct{} + +func (x fastReflection_TextualData_messageType) Zero() protoreflect.Message { + return (*fastReflection_TextualData)(nil) +} +func (x fastReflection_TextualData_messageType) New() protoreflect.Message { + return new(fastReflection_TextualData) +} +func (x fastReflection_TextualData_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_TextualData +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_TextualData) Descriptor() protoreflect.MessageDescriptor { + return md_TextualData +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_TextualData) Type() protoreflect.MessageType { + return _fastReflection_TextualData_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_TextualData) New() protoreflect.Message { + return new(fastReflection_TextualData) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_TextualData) Interface() protoreflect.ProtoMessage { + return (*TextualData)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_TextualData) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if len(x.BodyBytes) != 0 { + value := protoreflect.ValueOfBytes(x.BodyBytes) + if !f(fd_TextualData_body_bytes, value) { + return + } + } + if len(x.AuthInfoBytes) != 0 { + value := protoreflect.ValueOfBytes(x.AuthInfoBytes) + if !f(fd_TextualData_auth_info_bytes, value) { + return + } + } + if x.SignerData != nil { + value := protoreflect.ValueOfMessage(x.SignerData.ProtoReflect()) + if !f(fd_TextualData_signer_data, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_TextualData) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "TextualData.body_bytes": + return len(x.BodyBytes) != 0 + case "TextualData.auth_info_bytes": + return len(x.AuthInfoBytes) != 0 + case "TextualData.signer_data": + return x.SignerData != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TextualData) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "TextualData.body_bytes": + x.BodyBytes = nil + case "TextualData.auth_info_bytes": + x.AuthInfoBytes = nil + case "TextualData.signer_data": + x.SignerData = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_TextualData) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "TextualData.body_bytes": + value := x.BodyBytes + return protoreflect.ValueOfBytes(value) + case "TextualData.auth_info_bytes": + value := x.AuthInfoBytes + return protoreflect.ValueOfBytes(value) + case "TextualData.signer_data": + value := x.SignerData + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TextualData) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "TextualData.body_bytes": + x.BodyBytes = value.Bytes() + case "TextualData.auth_info_bytes": + x.AuthInfoBytes = value.Bytes() + case "TextualData.signer_data": + x.SignerData = value.Message().Interface().(*SignerData) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TextualData) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "TextualData.signer_data": + if x.SignerData == nil { + x.SignerData = new(SignerData) + } + return protoreflect.ValueOfMessage(x.SignerData.ProtoReflect()) + case "TextualData.body_bytes": + panic(fmt.Errorf("field body_bytes of message TextualData is not mutable")) + case "TextualData.auth_info_bytes": + panic(fmt.Errorf("field auth_info_bytes of message TextualData is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_TextualData) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "TextualData.body_bytes": + return protoreflect.ValueOfBytes(nil) + case "TextualData.auth_info_bytes": + return protoreflect.ValueOfBytes(nil) + case "TextualData.signer_data": + m := new(SignerData) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: TextualData")) + } + panic(fmt.Errorf("message TextualData does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_TextualData) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in TextualData", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_TextualData) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_TextualData) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_TextualData) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_TextualData) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*TextualData) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.BodyBytes) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.AuthInfoBytes) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.SignerData != nil { + l = options.Size(x.SignerData) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*TextualData) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.SignerData != nil { + encoded, err := options.Marshal(x.SignerData) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1a + } + if len(x.AuthInfoBytes) > 0 { + i -= len(x.AuthInfoBytes) + copy(dAtA[i:], x.AuthInfoBytes) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.AuthInfoBytes))) + i-- + dAtA[i] = 0x12 + } + if len(x.BodyBytes) > 0 { + i -= len(x.BodyBytes) + copy(dAtA[i:], x.BodyBytes) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.BodyBytes))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*TextualData) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TextualData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: TextualData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field BodyBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.BodyBytes = append(x.BodyBytes[:0], dAtA[iNdEx:postIndex]...) + if x.BodyBytes == nil { + x.BodyBytes = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AuthInfoBytes", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.AuthInfoBytes = append(x.AuthInfoBytes[:0], dAtA[iNdEx:postIndex]...) + if x.AuthInfoBytes == nil { + x.AuthInfoBytes = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field SignerData", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.SignerData == nil { + x.SignerData = &SignerData{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.SignerData); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var ( + md_SignerData protoreflect.MessageDescriptor + fd_SignerData_address protoreflect.FieldDescriptor + fd_SignerData_chain_id protoreflect.FieldDescriptor + fd_SignerData_account_number protoreflect.FieldDescriptor + fd_SignerData_sequence protoreflect.FieldDescriptor + fd_SignerData_pub_key protoreflect.FieldDescriptor +) + +func init() { + file_textual_proto_init() + md_SignerData = File_textual_proto.Messages().ByName("SignerData") + fd_SignerData_address = md_SignerData.Fields().ByName("address") + fd_SignerData_chain_id = md_SignerData.Fields().ByName("chain_id") + fd_SignerData_account_number = md_SignerData.Fields().ByName("account_number") + fd_SignerData_sequence = md_SignerData.Fields().ByName("sequence") + fd_SignerData_pub_key = md_SignerData.Fields().ByName("pub_key") +} + +var _ protoreflect.Message = (*fastReflection_SignerData)(nil) + +type fastReflection_SignerData SignerData + +func (x *SignerData) ProtoReflect() protoreflect.Message { + return (*fastReflection_SignerData)(x) +} + +func (x *SignerData) slowProtoReflect() protoreflect.Message { + mi := &file_textual_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_SignerData_messageType fastReflection_SignerData_messageType +var _ protoreflect.MessageType = fastReflection_SignerData_messageType{} + +type fastReflection_SignerData_messageType struct{} + +func (x fastReflection_SignerData_messageType) Zero() protoreflect.Message { + return (*fastReflection_SignerData)(nil) +} +func (x fastReflection_SignerData_messageType) New() protoreflect.Message { + return new(fastReflection_SignerData) +} +func (x fastReflection_SignerData_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_SignerData +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_SignerData) Descriptor() protoreflect.MessageDescriptor { + return md_SignerData +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_SignerData) Type() protoreflect.MessageType { + return _fastReflection_SignerData_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_SignerData) New() protoreflect.Message { + return new(fastReflection_SignerData) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_SignerData) Interface() protoreflect.ProtoMessage { + return (*SignerData)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_SignerData) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.Address != "" { + value := protoreflect.ValueOfString(x.Address) + if !f(fd_SignerData_address, value) { + return + } + } + if x.ChainId != "" { + value := protoreflect.ValueOfString(x.ChainId) + if !f(fd_SignerData_chain_id, value) { + return + } + } + if x.AccountNumber != uint64(0) { + value := protoreflect.ValueOfUint64(x.AccountNumber) + if !f(fd_SignerData_account_number, value) { + return + } + } + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_SignerData_sequence, value) { + return + } + } + if x.PubKey != nil { + value := protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) + if !f(fd_SignerData_pub_key, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_SignerData) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "SignerData.address": + return x.Address != "" + case "SignerData.chain_id": + return x.ChainId != "" + case "SignerData.account_number": + return x.AccountNumber != uint64(0) + case "SignerData.sequence": + return x.Sequence != uint64(0) + case "SignerData.pub_key": + return x.PubKey != nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SignerData) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "SignerData.address": + x.Address = "" + case "SignerData.chain_id": + x.ChainId = "" + case "SignerData.account_number": + x.AccountNumber = uint64(0) + case "SignerData.sequence": + x.Sequence = uint64(0) + case "SignerData.pub_key": + x.PubKey = nil + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_SignerData) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "SignerData.address": + value := x.Address + return protoreflect.ValueOfString(value) + case "SignerData.chain_id": + value := x.ChainId + return protoreflect.ValueOfString(value) + case "SignerData.account_number": + value := x.AccountNumber + return protoreflect.ValueOfUint64(value) + case "SignerData.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + case "SignerData.pub_key": + value := x.PubKey + return protoreflect.ValueOfMessage(value.ProtoReflect()) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SignerData) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "SignerData.address": + x.Address = value.Interface().(string) + case "SignerData.chain_id": + x.ChainId = value.Interface().(string) + case "SignerData.account_number": + x.AccountNumber = value.Uint() + case "SignerData.sequence": + x.Sequence = value.Uint() + case "SignerData.pub_key": + x.PubKey = value.Message().Interface().(*anypb.Any) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SignerData) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "SignerData.pub_key": + if x.PubKey == nil { + x.PubKey = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.PubKey.ProtoReflect()) + case "SignerData.address": + panic(fmt.Errorf("field address of message SignerData is not mutable")) + case "SignerData.chain_id": + panic(fmt.Errorf("field chain_id of message SignerData is not mutable")) + case "SignerData.account_number": + panic(fmt.Errorf("field account_number of message SignerData is not mutable")) + case "SignerData.sequence": + panic(fmt.Errorf("field sequence of message SignerData is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_SignerData) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "SignerData.address": + return protoreflect.ValueOfString("") + case "SignerData.chain_id": + return protoreflect.ValueOfString("") + case "SignerData.account_number": + return protoreflect.ValueOfUint64(uint64(0)) + case "SignerData.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + case "SignerData.pub_key": + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: SignerData")) + } + panic(fmt.Errorf("message SignerData does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_SignerData) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in SignerData", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_SignerData) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_SignerData) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_SignerData) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_SignerData) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*SignerData) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.Address) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.ChainId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.AccountNumber != 0 { + n += 1 + runtime.Sov(uint64(x.AccountNumber)) + } + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) + } + if x.PubKey != nil { + l = options.Size(x.PubKey) + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*SignerData) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if x.PubKey != nil { + encoded, err := options.Marshal(x.PubKey) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + i-- + dAtA[i] = 0x20 + } + if x.AccountNumber != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.AccountNumber)) + i-- + dAtA[i] = 0x18 + } + if len(x.ChainId) > 0 { + i -= len(x.ChainId) + copy(dAtA[i:], x.ChainId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ChainId))) + i-- + dAtA[i] = 0x12 + } + if len(x.Address) > 0 { + i -= len(x.Address) + copy(dAtA[i:], x.Address) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*SignerData) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SignerData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: SignerData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) + } + x.AccountNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.AccountNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + x.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PubKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.PubKey == nil { + x.PubKey = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.PubKey); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +var _ protoreflect.List = (*_Envelope_6_list)(nil) + +type _Envelope_6_list struct { + list *[]*anypb.Any +} + +func (x *_Envelope_6_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_6_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_6_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_6_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_6_list) AppendMutable() protoreflect.Value { + v := new(anypb.Any) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_6_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_6_list) NewElement() protoreflect.Value { + v := new(anypb.Any) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_6_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Envelope_8_list)(nil) + +type _Envelope_8_list struct { + list *[]*v1beta1.Coin +} + +func (x *_Envelope_8_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_8_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_8_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_8_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_8_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Coin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_8_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_8_list) NewElement() protoreflect.Value { + v := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_8_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Envelope_11_list)(nil) + +type _Envelope_11_list struct { + list *[]*v1beta1.Coin +} + +func (x *_Envelope_11_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_11_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_11_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_11_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta1.Coin) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_11_list) AppendMutable() protoreflect.Value { + v := new(v1beta1.Coin) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_11_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_11_list) NewElement() protoreflect.Value { + v := new(v1beta1.Coin) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_11_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Envelope_15_list)(nil) + +type _Envelope_15_list struct { + list *[]*v1beta11.SignerInfo +} + +func (x *_Envelope_15_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_15_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_15_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta11.SignerInfo) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_15_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*v1beta11.SignerInfo) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_15_list) AppendMutable() protoreflect.Value { + v := new(v1beta11.SignerInfo) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_15_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_15_list) NewElement() protoreflect.Value { + v := new(v1beta11.SignerInfo) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_15_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Envelope_16_list)(nil) + +type _Envelope_16_list struct { + list *[]*anypb.Any +} + +func (x *_Envelope_16_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_16_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_16_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_16_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_16_list) AppendMutable() protoreflect.Value { + v := new(anypb.Any) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_16_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_16_list) NewElement() protoreflect.Value { + v := new(anypb.Any) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_16_list) IsValid() bool { + return x.list != nil +} + +var _ protoreflect.List = (*_Envelope_17_list)(nil) + +type _Envelope_17_list struct { + list *[]*anypb.Any +} + +func (x *_Envelope_17_list) Len() int { + if x.list == nil { + return 0 + } + return len(*x.list) +} + +func (x *_Envelope_17_list) Get(i int) protoreflect.Value { + return protoreflect.ValueOfMessage((*x.list)[i].ProtoReflect()) +} + +func (x *_Envelope_17_list) Set(i int, value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + (*x.list)[i] = concreteValue +} + +func (x *_Envelope_17_list) Append(value protoreflect.Value) { + valueUnwrapped := value.Message() + concreteValue := valueUnwrapped.Interface().(*anypb.Any) + *x.list = append(*x.list, concreteValue) +} + +func (x *_Envelope_17_list) AppendMutable() protoreflect.Value { + v := new(anypb.Any) + *x.list = append(*x.list, v) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_17_list) Truncate(n int) { + for i := n; i < len(*x.list); i++ { + (*x.list)[i] = nil + } + *x.list = (*x.list)[:n] +} + +func (x *_Envelope_17_list) NewElement() protoreflect.Value { + v := new(anypb.Any) + return protoreflect.ValueOfMessage(v.ProtoReflect()) +} + +func (x *_Envelope_17_list) IsValid() bool { + return x.list != nil +} + +var ( + md_Envelope protoreflect.MessageDescriptor + fd_Envelope_chain_id protoreflect.FieldDescriptor + fd_Envelope_account_number protoreflect.FieldDescriptor + fd_Envelope_sequence protoreflect.FieldDescriptor + fd_Envelope_address protoreflect.FieldDescriptor + fd_Envelope_public_key protoreflect.FieldDescriptor + fd_Envelope_message protoreflect.FieldDescriptor + fd_Envelope_memo protoreflect.FieldDescriptor + fd_Envelope_fees protoreflect.FieldDescriptor + fd_Envelope_fee_payer protoreflect.FieldDescriptor + fd_Envelope_fee_granter protoreflect.FieldDescriptor + fd_Envelope_tip protoreflect.FieldDescriptor + fd_Envelope_tipper protoreflect.FieldDescriptor + fd_Envelope_gas_limit protoreflect.FieldDescriptor + fd_Envelope_timeout_height protoreflect.FieldDescriptor + fd_Envelope_other_signer protoreflect.FieldDescriptor + fd_Envelope_extension_options protoreflect.FieldDescriptor + fd_Envelope_non_critical_extension_options protoreflect.FieldDescriptor + fd_Envelope_hash_of_raw_bytes protoreflect.FieldDescriptor +) + +func init() { + file_textual_proto_init() + md_Envelope = File_textual_proto.Messages().ByName("Envelope") + fd_Envelope_chain_id = md_Envelope.Fields().ByName("chain_id") + fd_Envelope_account_number = md_Envelope.Fields().ByName("account_number") + fd_Envelope_sequence = md_Envelope.Fields().ByName("sequence") + fd_Envelope_address = md_Envelope.Fields().ByName("address") + fd_Envelope_public_key = md_Envelope.Fields().ByName("public_key") + fd_Envelope_message = md_Envelope.Fields().ByName("message") + fd_Envelope_memo = md_Envelope.Fields().ByName("memo") + fd_Envelope_fees = md_Envelope.Fields().ByName("fees") + fd_Envelope_fee_payer = md_Envelope.Fields().ByName("fee_payer") + fd_Envelope_fee_granter = md_Envelope.Fields().ByName("fee_granter") + fd_Envelope_tip = md_Envelope.Fields().ByName("tip") + fd_Envelope_tipper = md_Envelope.Fields().ByName("tipper") + fd_Envelope_gas_limit = md_Envelope.Fields().ByName("gas_limit") + fd_Envelope_timeout_height = md_Envelope.Fields().ByName("timeout_height") + fd_Envelope_other_signer = md_Envelope.Fields().ByName("other_signer") + fd_Envelope_extension_options = md_Envelope.Fields().ByName("extension_options") + fd_Envelope_non_critical_extension_options = md_Envelope.Fields().ByName("non_critical_extension_options") + fd_Envelope_hash_of_raw_bytes = md_Envelope.Fields().ByName("hash_of_raw_bytes") +} + +var _ protoreflect.Message = (*fastReflection_Envelope)(nil) + +type fastReflection_Envelope Envelope + +func (x *Envelope) ProtoReflect() protoreflect.Message { + return (*fastReflection_Envelope)(x) +} + +func (x *Envelope) slowProtoReflect() protoreflect.Message { + mi := &file_textual_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +var _fastReflection_Envelope_messageType fastReflection_Envelope_messageType +var _ protoreflect.MessageType = fastReflection_Envelope_messageType{} + +type fastReflection_Envelope_messageType struct{} + +func (x fastReflection_Envelope_messageType) Zero() protoreflect.Message { + return (*fastReflection_Envelope)(nil) +} +func (x fastReflection_Envelope_messageType) New() protoreflect.Message { + return new(fastReflection_Envelope) +} +func (x fastReflection_Envelope_messageType) Descriptor() protoreflect.MessageDescriptor { + return md_Envelope +} + +// Descriptor returns message descriptor, which contains only the protobuf +// type information for the message. +func (x *fastReflection_Envelope) Descriptor() protoreflect.MessageDescriptor { + return md_Envelope +} + +// Type returns the message type, which encapsulates both Go and protobuf +// type information. If the Go type information is not needed, +// it is recommended that the message descriptor be used instead. +func (x *fastReflection_Envelope) Type() protoreflect.MessageType { + return _fastReflection_Envelope_messageType +} + +// New returns a newly allocated and mutable empty message. +func (x *fastReflection_Envelope) New() protoreflect.Message { + return new(fastReflection_Envelope) +} + +// Interface unwraps the message reflection interface and +// returns the underlying ProtoMessage interface. +func (x *fastReflection_Envelope) Interface() protoreflect.ProtoMessage { + return (*Envelope)(x) +} + +// Range iterates over every populated field in an undefined order, +// calling f for each field descriptor and value encountered. +// Range returns immediately if f returns false. +// While iterating, mutating operations may only be performed +// on the current field descriptor. +func (x *fastReflection_Envelope) Range(f func(protoreflect.FieldDescriptor, protoreflect.Value) bool) { + if x.ChainId != "" { + value := protoreflect.ValueOfString(x.ChainId) + if !f(fd_Envelope_chain_id, value) { + return + } + } + if x.AccountNumber != uint64(0) { + value := protoreflect.ValueOfUint64(x.AccountNumber) + if !f(fd_Envelope_account_number, value) { + return + } + } + if x.Sequence != uint64(0) { + value := protoreflect.ValueOfUint64(x.Sequence) + if !f(fd_Envelope_sequence, value) { + return + } + } + if x.Address != "" { + value := protoreflect.ValueOfString(x.Address) + if !f(fd_Envelope_address, value) { + return + } + } + if x.PublicKey != nil { + value := protoreflect.ValueOfMessage(x.PublicKey.ProtoReflect()) + if !f(fd_Envelope_public_key, value) { + return + } + } + if len(x.Message) != 0 { + value := protoreflect.ValueOfList(&_Envelope_6_list{list: &x.Message}) + if !f(fd_Envelope_message, value) { + return + } + } + if x.Memo != "" { + value := protoreflect.ValueOfString(x.Memo) + if !f(fd_Envelope_memo, value) { + return + } + } + if len(x.Fees) != 0 { + value := protoreflect.ValueOfList(&_Envelope_8_list{list: &x.Fees}) + if !f(fd_Envelope_fees, value) { + return + } + } + if x.FeePayer != "" { + value := protoreflect.ValueOfString(x.FeePayer) + if !f(fd_Envelope_fee_payer, value) { + return + } + } + if x.FeeGranter != "" { + value := protoreflect.ValueOfString(x.FeeGranter) + if !f(fd_Envelope_fee_granter, value) { + return + } + } + if len(x.Tip) != 0 { + value := protoreflect.ValueOfList(&_Envelope_11_list{list: &x.Tip}) + if !f(fd_Envelope_tip, value) { + return + } + } + if x.Tipper != "" { + value := protoreflect.ValueOfString(x.Tipper) + if !f(fd_Envelope_tipper, value) { + return + } + } + if x.GasLimit != uint64(0) { + value := protoreflect.ValueOfUint64(x.GasLimit) + if !f(fd_Envelope_gas_limit, value) { + return + } + } + if x.TimeoutHeight != uint64(0) { + value := protoreflect.ValueOfUint64(x.TimeoutHeight) + if !f(fd_Envelope_timeout_height, value) { + return + } + } + if len(x.OtherSigner) != 0 { + value := protoreflect.ValueOfList(&_Envelope_15_list{list: &x.OtherSigner}) + if !f(fd_Envelope_other_signer, value) { + return + } + } + if len(x.ExtensionOptions) != 0 { + value := protoreflect.ValueOfList(&_Envelope_16_list{list: &x.ExtensionOptions}) + if !f(fd_Envelope_extension_options, value) { + return + } + } + if len(x.NonCriticalExtensionOptions) != 0 { + value := protoreflect.ValueOfList(&_Envelope_17_list{list: &x.NonCriticalExtensionOptions}) + if !f(fd_Envelope_non_critical_extension_options, value) { + return + } + } + if x.HashOfRawBytes != "" { + value := protoreflect.ValueOfString(x.HashOfRawBytes) + if !f(fd_Envelope_hash_of_raw_bytes, value) { + return + } + } +} + +// Has reports whether a field is populated. +// +// Some fields have the property of nullability where it is possible to +// distinguish between the default value of a field and whether the field +// was explicitly populated with the default value. Singular message fields, +// member fields of a oneof, and proto2 scalar fields are nullable. Such +// fields are populated only if explicitly set. +// +// In other cases (aside from the nullable cases above), +// a proto3 scalar field is populated if it contains a non-zero value, and +// a repeated field is populated if it is non-empty. +func (x *fastReflection_Envelope) Has(fd protoreflect.FieldDescriptor) bool { + switch fd.FullName() { + case "Envelope.chain_id": + return x.ChainId != "" + case "Envelope.account_number": + return x.AccountNumber != uint64(0) + case "Envelope.sequence": + return x.Sequence != uint64(0) + case "Envelope.address": + return x.Address != "" + case "Envelope.public_key": + return x.PublicKey != nil + case "Envelope.message": + return len(x.Message) != 0 + case "Envelope.memo": + return x.Memo != "" + case "Envelope.fees": + return len(x.Fees) != 0 + case "Envelope.fee_payer": + return x.FeePayer != "" + case "Envelope.fee_granter": + return x.FeeGranter != "" + case "Envelope.tip": + return len(x.Tip) != 0 + case "Envelope.tipper": + return x.Tipper != "" + case "Envelope.gas_limit": + return x.GasLimit != uint64(0) + case "Envelope.timeout_height": + return x.TimeoutHeight != uint64(0) + case "Envelope.other_signer": + return len(x.OtherSigner) != 0 + case "Envelope.extension_options": + return len(x.ExtensionOptions) != 0 + case "Envelope.non_critical_extension_options": + return len(x.NonCriticalExtensionOptions) != 0 + case "Envelope.hash_of_raw_bytes": + return x.HashOfRawBytes != "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", fd.FullName())) + } +} + +// Clear clears the field such that a subsequent Has call reports false. +// +// Clearing an extension field clears both the extension type and value +// associated with the given field number. +// +// Clear is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Envelope) Clear(fd protoreflect.FieldDescriptor) { + switch fd.FullName() { + case "Envelope.chain_id": + x.ChainId = "" + case "Envelope.account_number": + x.AccountNumber = uint64(0) + case "Envelope.sequence": + x.Sequence = uint64(0) + case "Envelope.address": + x.Address = "" + case "Envelope.public_key": + x.PublicKey = nil + case "Envelope.message": + x.Message = nil + case "Envelope.memo": + x.Memo = "" + case "Envelope.fees": + x.Fees = nil + case "Envelope.fee_payer": + x.FeePayer = "" + case "Envelope.fee_granter": + x.FeeGranter = "" + case "Envelope.tip": + x.Tip = nil + case "Envelope.tipper": + x.Tipper = "" + case "Envelope.gas_limit": + x.GasLimit = uint64(0) + case "Envelope.timeout_height": + x.TimeoutHeight = uint64(0) + case "Envelope.other_signer": + x.OtherSigner = nil + case "Envelope.extension_options": + x.ExtensionOptions = nil + case "Envelope.non_critical_extension_options": + x.NonCriticalExtensionOptions = nil + case "Envelope.hash_of_raw_bytes": + x.HashOfRawBytes = "" + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", fd.FullName())) + } +} + +// Get retrieves the value for a field. +// +// For unpopulated scalars, it returns the default value, where +// the default value of a bytes scalar is guaranteed to be a copy. +// For unpopulated composite types, it returns an empty, read-only view +// of the value; to obtain a mutable reference, use Mutable. +func (x *fastReflection_Envelope) Get(descriptor protoreflect.FieldDescriptor) protoreflect.Value { + switch descriptor.FullName() { + case "Envelope.chain_id": + value := x.ChainId + return protoreflect.ValueOfString(value) + case "Envelope.account_number": + value := x.AccountNumber + return protoreflect.ValueOfUint64(value) + case "Envelope.sequence": + value := x.Sequence + return protoreflect.ValueOfUint64(value) + case "Envelope.address": + value := x.Address + return protoreflect.ValueOfString(value) + case "Envelope.public_key": + value := x.PublicKey + return protoreflect.ValueOfMessage(value.ProtoReflect()) + case "Envelope.message": + if len(x.Message) == 0 { + return protoreflect.ValueOfList(&_Envelope_6_list{}) + } + listValue := &_Envelope_6_list{list: &x.Message} + return protoreflect.ValueOfList(listValue) + case "Envelope.memo": + value := x.Memo + return protoreflect.ValueOfString(value) + case "Envelope.fees": + if len(x.Fees) == 0 { + return protoreflect.ValueOfList(&_Envelope_8_list{}) + } + listValue := &_Envelope_8_list{list: &x.Fees} + return protoreflect.ValueOfList(listValue) + case "Envelope.fee_payer": + value := x.FeePayer + return protoreflect.ValueOfString(value) + case "Envelope.fee_granter": + value := x.FeeGranter + return protoreflect.ValueOfString(value) + case "Envelope.tip": + if len(x.Tip) == 0 { + return protoreflect.ValueOfList(&_Envelope_11_list{}) + } + listValue := &_Envelope_11_list{list: &x.Tip} + return protoreflect.ValueOfList(listValue) + case "Envelope.tipper": + value := x.Tipper + return protoreflect.ValueOfString(value) + case "Envelope.gas_limit": + value := x.GasLimit + return protoreflect.ValueOfUint64(value) + case "Envelope.timeout_height": + value := x.TimeoutHeight + return protoreflect.ValueOfUint64(value) + case "Envelope.other_signer": + if len(x.OtherSigner) == 0 { + return protoreflect.ValueOfList(&_Envelope_15_list{}) + } + listValue := &_Envelope_15_list{list: &x.OtherSigner} + return protoreflect.ValueOfList(listValue) + case "Envelope.extension_options": + if len(x.ExtensionOptions) == 0 { + return protoreflect.ValueOfList(&_Envelope_16_list{}) + } + listValue := &_Envelope_16_list{list: &x.ExtensionOptions} + return protoreflect.ValueOfList(listValue) + case "Envelope.non_critical_extension_options": + if len(x.NonCriticalExtensionOptions) == 0 { + return protoreflect.ValueOfList(&_Envelope_17_list{}) + } + listValue := &_Envelope_17_list{list: &x.NonCriticalExtensionOptions} + return protoreflect.ValueOfList(listValue) + case "Envelope.hash_of_raw_bytes": + value := x.HashOfRawBytes + return protoreflect.ValueOfString(value) + default: + if descriptor.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", descriptor.FullName())) + } +} + +// Set stores the value for a field. +// +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType. +// When setting a composite type, it is unspecified whether the stored value +// aliases the source's memory in any way. If the composite value is an +// empty, read-only value, then it panics. +// +// Set is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Envelope) Set(fd protoreflect.FieldDescriptor, value protoreflect.Value) { + switch fd.FullName() { + case "Envelope.chain_id": + x.ChainId = value.Interface().(string) + case "Envelope.account_number": + x.AccountNumber = value.Uint() + case "Envelope.sequence": + x.Sequence = value.Uint() + case "Envelope.address": + x.Address = value.Interface().(string) + case "Envelope.public_key": + x.PublicKey = value.Message().Interface().(*anypb.Any) + case "Envelope.message": + lv := value.List() + clv := lv.(*_Envelope_6_list) + x.Message = *clv.list + case "Envelope.memo": + x.Memo = value.Interface().(string) + case "Envelope.fees": + lv := value.List() + clv := lv.(*_Envelope_8_list) + x.Fees = *clv.list + case "Envelope.fee_payer": + x.FeePayer = value.Interface().(string) + case "Envelope.fee_granter": + x.FeeGranter = value.Interface().(string) + case "Envelope.tip": + lv := value.List() + clv := lv.(*_Envelope_11_list) + x.Tip = *clv.list + case "Envelope.tipper": + x.Tipper = value.Interface().(string) + case "Envelope.gas_limit": + x.GasLimit = value.Uint() + case "Envelope.timeout_height": + x.TimeoutHeight = value.Uint() + case "Envelope.other_signer": + lv := value.List() + clv := lv.(*_Envelope_15_list) + x.OtherSigner = *clv.list + case "Envelope.extension_options": + lv := value.List() + clv := lv.(*_Envelope_16_list) + x.ExtensionOptions = *clv.list + case "Envelope.non_critical_extension_options": + lv := value.List() + clv := lv.(*_Envelope_17_list) + x.NonCriticalExtensionOptions = *clv.list + case "Envelope.hash_of_raw_bytes": + x.HashOfRawBytes = value.Interface().(string) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", fd.FullName())) + } +} + +// Mutable returns a mutable reference to a composite type. +// +// If the field is unpopulated, it may allocate a composite value. +// For a field belonging to a oneof, it implicitly clears any other field +// that may be currently set within the same oneof. +// For extension fields, it implicitly stores the provided ExtensionType +// if not already stored. +// It panics if the field does not contain a composite type. +// +// Mutable is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Envelope) Mutable(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "Envelope.public_key": + if x.PublicKey == nil { + x.PublicKey = new(anypb.Any) + } + return protoreflect.ValueOfMessage(x.PublicKey.ProtoReflect()) + case "Envelope.message": + if x.Message == nil { + x.Message = []*anypb.Any{} + } + value := &_Envelope_6_list{list: &x.Message} + return protoreflect.ValueOfList(value) + case "Envelope.fees": + if x.Fees == nil { + x.Fees = []*v1beta1.Coin{} + } + value := &_Envelope_8_list{list: &x.Fees} + return protoreflect.ValueOfList(value) + case "Envelope.tip": + if x.Tip == nil { + x.Tip = []*v1beta1.Coin{} + } + value := &_Envelope_11_list{list: &x.Tip} + return protoreflect.ValueOfList(value) + case "Envelope.other_signer": + if x.OtherSigner == nil { + x.OtherSigner = []*v1beta11.SignerInfo{} + } + value := &_Envelope_15_list{list: &x.OtherSigner} + return protoreflect.ValueOfList(value) + case "Envelope.extension_options": + if x.ExtensionOptions == nil { + x.ExtensionOptions = []*anypb.Any{} + } + value := &_Envelope_16_list{list: &x.ExtensionOptions} + return protoreflect.ValueOfList(value) + case "Envelope.non_critical_extension_options": + if x.NonCriticalExtensionOptions == nil { + x.NonCriticalExtensionOptions = []*anypb.Any{} + } + value := &_Envelope_17_list{list: &x.NonCriticalExtensionOptions} + return protoreflect.ValueOfList(value) + case "Envelope.chain_id": + panic(fmt.Errorf("field chain_id of message Envelope is not mutable")) + case "Envelope.account_number": + panic(fmt.Errorf("field account_number of message Envelope is not mutable")) + case "Envelope.sequence": + panic(fmt.Errorf("field sequence of message Envelope is not mutable")) + case "Envelope.address": + panic(fmt.Errorf("field address of message Envelope is not mutable")) + case "Envelope.memo": + panic(fmt.Errorf("field memo of message Envelope is not mutable")) + case "Envelope.fee_payer": + panic(fmt.Errorf("field fee_payer of message Envelope is not mutable")) + case "Envelope.fee_granter": + panic(fmt.Errorf("field fee_granter of message Envelope is not mutable")) + case "Envelope.tipper": + panic(fmt.Errorf("field tipper of message Envelope is not mutable")) + case "Envelope.gas_limit": + panic(fmt.Errorf("field gas_limit of message Envelope is not mutable")) + case "Envelope.timeout_height": + panic(fmt.Errorf("field timeout_height of message Envelope is not mutable")) + case "Envelope.hash_of_raw_bytes": + panic(fmt.Errorf("field hash_of_raw_bytes of message Envelope is not mutable")) + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", fd.FullName())) + } +} + +// NewField returns a new value that is assignable to the field +// for the given descriptor. For scalars, this returns the default value. +// For lists, maps, and messages, this returns a new, empty, mutable value. +func (x *fastReflection_Envelope) NewField(fd protoreflect.FieldDescriptor) protoreflect.Value { + switch fd.FullName() { + case "Envelope.chain_id": + return protoreflect.ValueOfString("") + case "Envelope.account_number": + return protoreflect.ValueOfUint64(uint64(0)) + case "Envelope.sequence": + return protoreflect.ValueOfUint64(uint64(0)) + case "Envelope.address": + return protoreflect.ValueOfString("") + case "Envelope.public_key": + m := new(anypb.Any) + return protoreflect.ValueOfMessage(m.ProtoReflect()) + case "Envelope.message": + list := []*anypb.Any{} + return protoreflect.ValueOfList(&_Envelope_6_list{list: &list}) + case "Envelope.memo": + return protoreflect.ValueOfString("") + case "Envelope.fees": + list := []*v1beta1.Coin{} + return protoreflect.ValueOfList(&_Envelope_8_list{list: &list}) + case "Envelope.fee_payer": + return protoreflect.ValueOfString("") + case "Envelope.fee_granter": + return protoreflect.ValueOfString("") + case "Envelope.tip": + list := []*v1beta1.Coin{} + return protoreflect.ValueOfList(&_Envelope_11_list{list: &list}) + case "Envelope.tipper": + return protoreflect.ValueOfString("") + case "Envelope.gas_limit": + return protoreflect.ValueOfUint64(uint64(0)) + case "Envelope.timeout_height": + return protoreflect.ValueOfUint64(uint64(0)) + case "Envelope.other_signer": + list := []*v1beta11.SignerInfo{} + return protoreflect.ValueOfList(&_Envelope_15_list{list: &list}) + case "Envelope.extension_options": + list := []*anypb.Any{} + return protoreflect.ValueOfList(&_Envelope_16_list{list: &list}) + case "Envelope.non_critical_extension_options": + list := []*anypb.Any{} + return protoreflect.ValueOfList(&_Envelope_17_list{list: &list}) + case "Envelope.hash_of_raw_bytes": + return protoreflect.ValueOfString("") + default: + if fd.IsExtension() { + panic(fmt.Errorf("proto3 declared messages do not support extensions: Envelope")) + } + panic(fmt.Errorf("message Envelope does not contain field %s", fd.FullName())) + } +} + +// WhichOneof reports which field within the oneof is populated, +// returning nil if none are populated. +// It panics if the oneof descriptor does not belong to this message. +func (x *fastReflection_Envelope) WhichOneof(d protoreflect.OneofDescriptor) protoreflect.FieldDescriptor { + switch d.FullName() { + default: + panic(fmt.Errorf("%s is not a oneof field in Envelope", d.FullName())) + } + panic("unreachable") +} + +// GetUnknown retrieves the entire list of unknown fields. +// The caller may only mutate the contents of the RawFields +// if the mutated bytes are stored back into the message with SetUnknown. +func (x *fastReflection_Envelope) GetUnknown() protoreflect.RawFields { + return x.unknownFields +} + +// SetUnknown stores an entire list of unknown fields. +// The raw fields must be syntactically valid according to the wire format. +// An implementation may panic if this is not the case. +// Once stored, the caller must not mutate the content of the RawFields. +// An empty RawFields may be passed to clear the fields. +// +// SetUnknown is a mutating operation and unsafe for concurrent use. +func (x *fastReflection_Envelope) SetUnknown(fields protoreflect.RawFields) { + x.unknownFields = fields +} + +// IsValid reports whether the message is valid. +// +// An invalid message is an empty, read-only value. +// +// An invalid message often corresponds to a nil pointer of the concrete +// message type, but the details are implementation dependent. +// Validity is not part of the protobuf data model, and may not +// be preserved in marshaling or other operations. +func (x *fastReflection_Envelope) IsValid() bool { + return x != nil +} + +// ProtoMethods returns optional fastReflectionFeature-path implementations of various operations. +// This method may return nil. +// +// The returned methods type is identical to +// "google.golang.org/protobuf/runtime/protoiface".Methods. +// Consult the protoiface package documentation for details. +func (x *fastReflection_Envelope) ProtoMethods() *protoiface.Methods { + size := func(input protoiface.SizeInput) protoiface.SizeOutput { + x := input.Message.Interface().(*Envelope) + if x == nil { + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: 0, + } + } + options := runtime.SizeInputToOptions(input) + _ = options + var n int + var l int + _ = l + l = len(x.ChainId) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.AccountNumber != 0 { + n += 1 + runtime.Sov(uint64(x.AccountNumber)) + } + if x.Sequence != 0 { + n += 1 + runtime.Sov(uint64(x.Sequence)) + } + l = len(x.Address) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.PublicKey != nil { + l = options.Size(x.PublicKey) + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Message) > 0 { + for _, e := range x.Message { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.Memo) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Fees) > 0 { + for _, e := range x.Fees { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.FeePayer) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + l = len(x.FeeGranter) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if len(x.Tip) > 0 { + for _, e := range x.Tip { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.Tipper) + if l > 0 { + n += 1 + l + runtime.Sov(uint64(l)) + } + if x.GasLimit != 0 { + n += 1 + runtime.Sov(uint64(x.GasLimit)) + } + if x.TimeoutHeight != 0 { + n += 1 + runtime.Sov(uint64(x.TimeoutHeight)) + } + if len(x.OtherSigner) > 0 { + for _, e := range x.OtherSigner { + l = options.Size(e) + n += 1 + l + runtime.Sov(uint64(l)) + } + } + if len(x.ExtensionOptions) > 0 { + for _, e := range x.ExtensionOptions { + l = options.Size(e) + n += 2 + l + runtime.Sov(uint64(l)) + } + } + if len(x.NonCriticalExtensionOptions) > 0 { + for _, e := range x.NonCriticalExtensionOptions { + l = options.Size(e) + n += 2 + l + runtime.Sov(uint64(l)) + } + } + l = len(x.HashOfRawBytes) + if l > 0 { + n += 2 + l + runtime.Sov(uint64(l)) + } + if x.unknownFields != nil { + n += len(x.unknownFields) + } + return protoiface.SizeOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Size: n, + } + } + + marshal := func(input protoiface.MarshalInput) (protoiface.MarshalOutput, error) { + x := input.Message.Interface().(*Envelope) + if x == nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + options := runtime.MarshalInputToOptions(input) + _ = options + size := options.Size(x) + dAtA := make([]byte, size) + i := len(dAtA) + _ = i + var l int + _ = l + if x.unknownFields != nil { + i -= len(x.unknownFields) + copy(dAtA[i:], x.unknownFields) + } + if len(x.HashOfRawBytes) > 0 { + i -= len(x.HashOfRawBytes) + copy(dAtA[i:], x.HashOfRawBytes) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.HashOfRawBytes))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x92 + } + if len(x.NonCriticalExtensionOptions) > 0 { + for iNdEx := len(x.NonCriticalExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.NonCriticalExtensionOptions[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x8a + } + } + if len(x.ExtensionOptions) > 0 { + for iNdEx := len(x.ExtensionOptions) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.ExtensionOptions[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x1 + i-- + dAtA[i] = 0x82 + } + } + if len(x.OtherSigner) > 0 { + for iNdEx := len(x.OtherSigner) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.OtherSigner[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x7a + } + } + if x.TimeoutHeight != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.TimeoutHeight)) + i-- + dAtA[i] = 0x70 + } + if x.GasLimit != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.GasLimit)) + i-- + dAtA[i] = 0x68 + } + if len(x.Tipper) > 0 { + i -= len(x.Tipper) + copy(dAtA[i:], x.Tipper) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Tipper))) + i-- + dAtA[i] = 0x62 + } + if len(x.Tip) > 0 { + for iNdEx := len(x.Tip) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Tip[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x5a + } + } + if len(x.FeeGranter) > 0 { + i -= len(x.FeeGranter) + copy(dAtA[i:], x.FeeGranter) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeeGranter))) + i-- + dAtA[i] = 0x52 + } + if len(x.FeePayer) > 0 { + i -= len(x.FeePayer) + copy(dAtA[i:], x.FeePayer) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.FeePayer))) + i-- + dAtA[i] = 0x4a + } + if len(x.Fees) > 0 { + for iNdEx := len(x.Fees) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Fees[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x42 + } + } + if len(x.Memo) > 0 { + i -= len(x.Memo) + copy(dAtA[i:], x.Memo) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Memo))) + i-- + dAtA[i] = 0x3a + } + if len(x.Message) > 0 { + for iNdEx := len(x.Message) - 1; iNdEx >= 0; iNdEx-- { + encoded, err := options.Marshal(x.Message[iNdEx]) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x32 + } + } + if x.PublicKey != nil { + encoded, err := options.Marshal(x.PublicKey) + if err != nil { + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, err + } + i -= len(encoded) + copy(dAtA[i:], encoded) + i = runtime.EncodeVarint(dAtA, i, uint64(len(encoded))) + i-- + dAtA[i] = 0x2a + } + if len(x.Address) > 0 { + i -= len(x.Address) + copy(dAtA[i:], x.Address) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.Address))) + i-- + dAtA[i] = 0x22 + } + if x.Sequence != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.Sequence)) + i-- + dAtA[i] = 0x18 + } + if x.AccountNumber != 0 { + i = runtime.EncodeVarint(dAtA, i, uint64(x.AccountNumber)) + i-- + dAtA[i] = 0x10 + } + if len(x.ChainId) > 0 { + i -= len(x.ChainId) + copy(dAtA[i:], x.ChainId) + i = runtime.EncodeVarint(dAtA, i, uint64(len(x.ChainId))) + i-- + dAtA[i] = 0xa + } + if input.Buf != nil { + input.Buf = append(input.Buf, dAtA...) + } else { + input.Buf = dAtA + } + return protoiface.MarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Buf: input.Buf, + }, nil + } + unmarshal := func(input protoiface.UnmarshalInput) (protoiface.UnmarshalOutput, error) { + x := input.Message.Interface().(*Envelope) + if x == nil { + return protoiface.UnmarshalOutput{ + NoUnkeyedLiterals: input.NoUnkeyedLiterals, + Flags: input.Flags, + }, nil + } + options := runtime.UnmarshalInputToOptions(input) + _ = options + dAtA := input.Buf + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Envelope: wiretype end group for non-group") + } + if fieldNum <= 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: Envelope: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ChainId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ChainId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field AccountNumber", wireType) + } + x.AccountNumber = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.AccountNumber |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType) + } + x.Sequence = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.Sequence |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field PublicKey", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if x.PublicKey == nil { + x.PublicKey = &anypb.Any{} + } + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.PublicKey); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Message = append(x.Message, &anypb.Any{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Message[len(x.Message)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Memo", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Memo = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 8: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Fees", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Fees = append(x.Fees, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Fees[len(x.Fees)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeePayer", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FeePayer = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field FeeGranter", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.FeeGranter = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 11: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Tip", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Tip = append(x.Tip, &v1beta1.Coin{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.Tip[len(x.Tip)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field Tipper", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.Tipper = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 13: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field GasLimit", wireType) + } + x.GasLimit = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.GasLimit |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 14: + if wireType != 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field TimeoutHeight", wireType) + } + x.TimeoutHeight = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + x.TimeoutHeight |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 15: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field OtherSigner", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.OtherSigner = append(x.OtherSigner, &v1beta11.SignerInfo{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.OtherSigner[len(x.OtherSigner)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 16: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field ExtensionOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.ExtensionOptions = append(x.ExtensionOptions, &anypb.Any{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.ExtensionOptions[len(x.ExtensionOptions)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 17: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field NonCriticalExtensionOptions", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.NonCriticalExtensionOptions = append(x.NonCriticalExtensionOptions, &anypb.Any{}) + if err := options.Unmarshal(dAtA[iNdEx:postIndex], x.NonCriticalExtensionOptions[len(x.NonCriticalExtensionOptions)-1]); err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + iNdEx = postIndex + case 18: + if wireType != 2 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, fmt.Errorf("proto: wrong wireType = %d for field HashOfRawBytes", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrIntOverflow + } + if iNdEx >= l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if postIndex > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + x.HashOfRawBytes = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := runtime.Skip(dAtA[iNdEx:]) + if err != nil { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, runtime.ErrInvalidLength + } + if (iNdEx + skippy) > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + if !options.DiscardUnknown { + x.unknownFields = append(x.unknownFields, dAtA[iNdEx:iNdEx+skippy]...) + } + iNdEx += skippy + } + } + + if iNdEx > l { + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, io.ErrUnexpectedEOF + } + return protoiface.UnmarshalOutput{NoUnkeyedLiterals: input.NoUnkeyedLiterals, Flags: input.Flags}, nil + } + return &protoiface.Methods{ + NoUnkeyedLiterals: struct{}{}, + Flags: protoiface.SupportMarshalDeterministic | protoiface.SupportUnmarshalDiscardUnknown, + Size: size, + Marshal: marshal, + Unmarshal: unmarshal, + Merge: nil, + CheckInitialized: nil, + } +} + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.0 +// protoc (unknown) +// source: textual.proto + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// TextualData represents all the information needed to generate +// the textual SignDoc (which is []Screen encoded to XBOR). It is meant to be +// used as an internal type in Textual's implementations. +type TextualData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // body_bytes is a protobuf serialization of a TxBody that matches the + // representation in SignDoc. + BodyBytes []byte `protobuf:"bytes,1,opt,name=body_bytes,json=bodyBytes,proto3" json:"body_bytes,omitempty"` + // auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + // representation in SignDoc. + AuthInfoBytes []byte `protobuf:"bytes,2,opt,name=auth_info_bytes,json=authInfoBytes,proto3" json:"auth_info_bytes,omitempty"` + // signer_data represents all data in Textual's SignDoc that are not + // inside the Tx body and auth_info. + SignerData *SignerData `protobuf:"bytes,3,opt,name=signer_data,json=signerData,proto3" json:"signer_data,omitempty"` +} + +func (x *TextualData) Reset() { + *x = TextualData{} + if protoimpl.UnsafeEnabled { + mi := &file_textual_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *TextualData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TextualData) ProtoMessage() {} + +// Deprecated: Use TextualData.ProtoReflect.Descriptor instead. +func (*TextualData) Descriptor() ([]byte, []int) { + return file_textual_proto_rawDescGZIP(), []int{0} +} + +func (x *TextualData) GetBodyBytes() []byte { + if x != nil { + return x.BodyBytes + } + return nil +} + +func (x *TextualData) GetAuthInfoBytes() []byte { + if x != nil { + return x.AuthInfoBytes + } + return nil +} + +func (x *TextualData) GetSignerData() *SignerData { + if x != nil { + return x.SignerData + } + return nil +} + +// SignerData is the specific information needed to sign a transaction that generally +// isn't included in the transaction body itself. +// +// It is the same struct as signing.SignerData, but only used internally +// in Textual because we need it as a proto.Message. +type SignerData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // address is the address of the signer. + // + // In case of multisigs, this should be the multisig's address. + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + // chain_id is the chain that this transaction is targeting. + ChainId string `protobuf:"bytes,2,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + // account_number is the account number of the signer. + // + // In case of multisigs, this should be the multisig account number. + AccountNumber uint64 `protobuf:"varint,3,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` + // sequence is the account sequence number of the signer that is used + // for replay protection. This field is only useful for Legacy Amino signing, + // since in SIGN_MODE_DIRECT the account sequence is already in the signer + // info. + // + // In case of multisigs, this should be the multisig sequence. + Sequence uint64 `protobuf:"varint,4,opt,name=sequence,proto3" json:"sequence,omitempty"` + // pub_key is the public key of the signer. + // + // In case of multisigs, this should be the pubkey of the member of the + // multisig that is signing the current sign doc. + PubKey *anypb.Any `protobuf:"bytes,5,opt,name=pub_key,json=pubKey,proto3" json:"pub_key,omitempty"` +} + +func (x *SignerData) Reset() { + *x = SignerData{} + if protoimpl.UnsafeEnabled { + mi := &file_textual_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *SignerData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SignerData) ProtoMessage() {} + +// Deprecated: Use SignerData.ProtoReflect.Descriptor instead. +func (*SignerData) Descriptor() ([]byte, []int) { + return file_textual_proto_rawDescGZIP(), []int{1} +} + +func (x *SignerData) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *SignerData) GetChainId() string { + if x != nil { + return x.ChainId + } + return "" +} + +func (x *SignerData) GetAccountNumber() uint64 { + if x != nil { + return x.AccountNumber + } + return 0 +} + +func (x *SignerData) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *SignerData) GetPubKey() *anypb.Any { + if x != nil { + return x.PubKey + } + return nil +} + +// Envelope is an internal data structure used to generate the tx envelope +// screens. It is derived from the TextualData struct (also internal) which +// contains the three following fields: +// - body_bytes (from the original tx), +// - auth_info_bytes (from the original tx), +// - signer_data (passed in by the sign mode handler) +// +// If any of the three structs above is modified, then this Envelope message +// also needs to be updated. +type Envelope struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ChainId string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + AccountNumber uint64 `protobuf:"varint,2,opt,name=account_number,json=accountNumber,proto3" json:"account_number,omitempty"` + Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"` + Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` + PublicKey *anypb.Any `protobuf:"bytes,5,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"` + Message []*anypb.Any `protobuf:"bytes,6,rep,name=message,proto3" json:"message,omitempty"` + Memo string `protobuf:"bytes,7,opt,name=memo,proto3" json:"memo,omitempty"` + Fees []*v1beta1.Coin `protobuf:"bytes,8,rep,name=fees,proto3" json:"fees,omitempty"` + FeePayer string `protobuf:"bytes,9,opt,name=fee_payer,json=feePayer,proto3" json:"fee_payer,omitempty"` + FeeGranter string `protobuf:"bytes,10,opt,name=fee_granter,json=feeGranter,proto3" json:"fee_granter,omitempty"` + Tip []*v1beta1.Coin `protobuf:"bytes,11,rep,name=tip,proto3" json:"tip,omitempty"` + Tipper string `protobuf:"bytes,12,opt,name=tipper,proto3" json:"tipper,omitempty"` + GasLimit uint64 `protobuf:"varint,13,opt,name=gas_limit,json=gasLimit,proto3" json:"gas_limit,omitempty"` + TimeoutHeight uint64 `protobuf:"varint,14,opt,name=timeout_height,json=timeoutHeight,proto3" json:"timeout_height,omitempty"` + OtherSigner []*v1beta11.SignerInfo `protobuf:"bytes,15,rep,name=other_signer,json=otherSigner,proto3" json:"other_signer,omitempty"` + ExtensionOptions []*anypb.Any `protobuf:"bytes,16,rep,name=extension_options,json=extensionOptions,proto3" json:"extension_options,omitempty"` + NonCriticalExtensionOptions []*anypb.Any `protobuf:"bytes,17,rep,name=non_critical_extension_options,json=nonCriticalExtensionOptions,proto3" json:"non_critical_extension_options,omitempty"` + HashOfRawBytes string `protobuf:"bytes,18,opt,name=hash_of_raw_bytes,json=hashOfRawBytes,proto3" json:"hash_of_raw_bytes,omitempty"` +} + +func (x *Envelope) Reset() { + *x = Envelope{} + if protoimpl.UnsafeEnabled { + mi := &file_textual_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Envelope) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Envelope) ProtoMessage() {} + +// Deprecated: Use Envelope.ProtoReflect.Descriptor instead. +func (*Envelope) Descriptor() ([]byte, []int) { + return file_textual_proto_rawDescGZIP(), []int{2} +} + +func (x *Envelope) GetChainId() string { + if x != nil { + return x.ChainId + } + return "" +} + +func (x *Envelope) GetAccountNumber() uint64 { + if x != nil { + return x.AccountNumber + } + return 0 +} + +func (x *Envelope) GetSequence() uint64 { + if x != nil { + return x.Sequence + } + return 0 +} + +func (x *Envelope) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *Envelope) GetPublicKey() *anypb.Any { + if x != nil { + return x.PublicKey + } + return nil +} + +func (x *Envelope) GetMessage() []*anypb.Any { + if x != nil { + return x.Message + } + return nil +} + +func (x *Envelope) GetMemo() string { + if x != nil { + return x.Memo + } + return "" +} + +func (x *Envelope) GetFees() []*v1beta1.Coin { + if x != nil { + return x.Fees + } + return nil +} + +func (x *Envelope) GetFeePayer() string { + if x != nil { + return x.FeePayer + } + return "" +} + +func (x *Envelope) GetFeeGranter() string { + if x != nil { + return x.FeeGranter + } + return "" +} + +func (x *Envelope) GetTip() []*v1beta1.Coin { + if x != nil { + return x.Tip + } + return nil +} + +func (x *Envelope) GetTipper() string { + if x != nil { + return x.Tipper + } + return "" +} + +func (x *Envelope) GetGasLimit() uint64 { + if x != nil { + return x.GasLimit + } + return 0 +} + +func (x *Envelope) GetTimeoutHeight() uint64 { + if x != nil { + return x.TimeoutHeight + } + return 0 +} + +func (x *Envelope) GetOtherSigner() []*v1beta11.SignerInfo { + if x != nil { + return x.OtherSigner + } + return nil +} + +func (x *Envelope) GetExtensionOptions() []*anypb.Any { + if x != nil { + return x.ExtensionOptions + } + return nil +} + +func (x *Envelope) GetNonCriticalExtensionOptions() []*anypb.Any { + if x != nil { + return x.NonCriticalExtensionOptions + } + return nil +} + +func (x *Envelope) GetHashOfRawBytes() string { + if x != nil { + return x.HashOfRawBytes + } + return "" +} + +var File_textual_proto protoreflect.FileDescriptor + +var file_textual_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x76, 0x31, 0x62, + 0x65, 0x74, 0x61, 0x31, 0x2f, 0x63, 0x6f, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x2f, 0x74, 0x78, 0x2f, 0x76, 0x31, 0x62, 0x65, 0x74, + 0x61, 0x31, 0x2f, 0x74, 0x78, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x63, 0x6f, 0x73, + 0x6d, 0x6f, 0x73, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x22, 0x82, 0x01, 0x0a, 0x0b, 0x54, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x44, 0x61, 0x74, + 0x61, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6f, 0x64, 0x79, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x09, 0x62, 0x6f, 0x64, 0x79, 0x42, 0x79, 0x74, 0x65, 0x73, + 0x12, 0x26, 0x0a, 0x0f, 0x61, 0x75, 0x74, 0x68, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x5f, 0x62, 0x79, + 0x74, 0x65, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0d, 0x61, 0x75, 0x74, 0x68, 0x49, + 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x74, 0x65, 0x73, 0x12, 0x2c, 0x0a, 0x0b, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x72, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0b, 0x2e, + 0x53, 0x69, 0x67, 0x6e, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x0a, 0x73, 0x69, 0x67, 0x6e, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0xc6, 0x01, 0x0a, 0x0a, 0x53, 0x69, 0x67, 0x6e, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x2b, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x42, 0x11, 0xd2, 0xb4, 0x2d, 0x0d, 0x41, 0x64, 0x64, 0x72, + 0x65, 0x73, 0x73, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, + 0x73, 0x73, 0x12, 0x19, 0x0a, 0x08, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, + 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x75, + 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, + 0x12, 0x2d, 0x0a, 0x07, 0x70, 0x75, 0x62, 0x5f, 0x6b, 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x06, 0x70, 0x75, 0x62, 0x4b, 0x65, 0x79, 0x22, + 0xfc, 0x05, 0x0a, 0x08, 0x45, 0x6e, 0x76, 0x65, 0x6c, 0x6f, 0x70, 0x65, 0x12, 0x19, 0x0a, 0x08, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x63, 0x68, 0x61, 0x69, 0x6e, 0x49, 0x64, 0x12, 0x25, 0x0a, 0x0e, 0x61, 0x63, 0x63, 0x6f, 0x75, + 0x6e, 0x74, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, + 0x0d, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1a, + 0x0a, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, + 0x52, 0x08, 0x73, 0x65, 0x71, 0x75, 0x65, 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x64, + 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x64, 0x64, + 0x72, 0x65, 0x73, 0x73, 0x12, 0x33, 0x0a, 0x0a, 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x5f, 0x6b, + 0x65, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, + 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x09, + 0x70, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x12, 0x2e, 0x0a, 0x07, 0x6d, 0x65, 0x73, + 0x73, 0x61, 0x67, 0x65, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, + 0x52, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x6d, 0x65, 0x6d, + 0x6f, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6d, 0x65, 0x6d, 0x6f, 0x12, 0x2d, 0x0a, + 0x04, 0x66, 0x65, 0x65, 0x73, 0x18, 0x08, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, + 0x73, 0x6d, 0x6f, 0x73, 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, + 0x31, 0x2e, 0x43, 0x6f, 0x69, 0x6e, 0x52, 0x04, 0x66, 0x65, 0x65, 0x73, 0x12, 0x1b, 0x0a, 0x09, + 0x66, 0x65, 0x65, 0x5f, 0x70, 0x61, 0x79, 0x65, 0x72, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x66, 0x65, 0x65, 0x50, 0x61, 0x79, 0x65, 0x72, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x65, 0x65, + 0x5f, 0x67, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, + 0x66, 0x65, 0x65, 0x47, 0x72, 0x61, 0x6e, 0x74, 0x65, 0x72, 0x12, 0x2b, 0x0a, 0x03, 0x74, 0x69, + 0x70, 0x18, 0x0b, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, + 0x2e, 0x62, 0x61, 0x73, 0x65, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x43, 0x6f, + 0x69, 0x6e, 0x52, 0x03, 0x74, 0x69, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, + 0x72, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x69, 0x70, 0x70, 0x65, 0x72, 0x12, + 0x1b, 0x0a, 0x09, 0x67, 0x61, 0x73, 0x5f, 0x6c, 0x69, 0x6d, 0x69, 0x74, 0x18, 0x0d, 0x20, 0x01, + 0x28, 0x04, 0x52, 0x08, 0x67, 0x61, 0x73, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x25, 0x0a, 0x0e, + 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x0e, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x0d, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x48, 0x65, 0x69, + 0x67, 0x68, 0x74, 0x12, 0x40, 0x0a, 0x0c, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x5f, 0x73, 0x69, 0x67, + 0x6e, 0x65, 0x72, 0x18, 0x0f, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1d, 0x2e, 0x63, 0x6f, 0x73, 0x6d, + 0x6f, 0x73, 0x2e, 0x74, 0x78, 0x2e, 0x76, 0x31, 0x62, 0x65, 0x74, 0x61, 0x31, 0x2e, 0x53, 0x69, + 0x67, 0x6e, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x0b, 0x6f, 0x74, 0x68, 0x65, 0x72, 0x53, + 0x69, 0x67, 0x6e, 0x65, 0x72, 0x12, 0x41, 0x0a, 0x11, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x10, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x10, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, + 0x6e, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x59, 0x0a, 0x1e, 0x6e, 0x6f, 0x6e, 0x5f, + 0x63, 0x72, 0x69, 0x74, 0x69, 0x63, 0x61, 0x6c, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, + 0x6f, 0x6e, 0x5f, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x11, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x1b, 0x6e, 0x6f, 0x6e, 0x43, 0x72, 0x69, 0x74, 0x69, + 0x63, 0x61, 0x6c, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x4f, 0x70, 0x74, 0x69, + 0x6f, 0x6e, 0x73, 0x12, 0x29, 0x0a, 0x11, 0x68, 0x61, 0x73, 0x68, 0x5f, 0x6f, 0x66, 0x5f, 0x72, + 0x61, 0x77, 0x5f, 0x62, 0x79, 0x74, 0x65, 0x73, 0x18, 0x12, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, + 0x68, 0x61, 0x73, 0x68, 0x4f, 0x66, 0x52, 0x61, 0x77, 0x42, 0x79, 0x74, 0x65, 0x73, 0x42, 0x3c, + 0x42, 0x0c, 0x54, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x2a, 0x63, 0x6f, 0x73, 0x6d, 0x6f, 0x73, 0x73, 0x64, 0x6b, 0x2e, 0x69, 0x6f, 0x2f, 0x74, + 0x78, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x2f, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x75, 0x61, 0x6c, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_textual_proto_rawDescOnce sync.Once + file_textual_proto_rawDescData = file_textual_proto_rawDesc +) + +func file_textual_proto_rawDescGZIP() []byte { + file_textual_proto_rawDescOnce.Do(func() { + file_textual_proto_rawDescData = protoimpl.X.CompressGZIP(file_textual_proto_rawDescData) + }) + return file_textual_proto_rawDescData +} + +var file_textual_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_textual_proto_goTypes = []interface{}{ + (*TextualData)(nil), // 0: TextualData + (*SignerData)(nil), // 1: SignerData + (*Envelope)(nil), // 2: Envelope + (*anypb.Any)(nil), // 3: google.protobuf.Any + (*v1beta1.Coin)(nil), // 4: cosmos.base.v1beta1.Coin + (*v1beta11.SignerInfo)(nil), // 5: cosmos.tx.v1beta1.SignerInfo +} +var file_textual_proto_depIdxs = []int32{ + 1, // 0: TextualData.signer_data:type_name -> SignerData + 3, // 1: SignerData.pub_key:type_name -> google.protobuf.Any + 3, // 2: Envelope.public_key:type_name -> google.protobuf.Any + 3, // 3: Envelope.message:type_name -> google.protobuf.Any + 4, // 4: Envelope.fees:type_name -> cosmos.base.v1beta1.Coin + 4, // 5: Envelope.tip:type_name -> cosmos.base.v1beta1.Coin + 5, // 6: Envelope.other_signer:type_name -> cosmos.tx.v1beta1.SignerInfo + 3, // 7: Envelope.extension_options:type_name -> google.protobuf.Any + 3, // 8: Envelope.non_critical_extension_options:type_name -> google.protobuf.Any + 9, // [9:9] is the sub-list for method output_type + 9, // [9:9] is the sub-list for method input_type + 9, // [9:9] is the sub-list for extension type_name + 9, // [9:9] is the sub-list for extension extendee + 0, // [0:9] is the sub-list for field type_name +} + +func init() { file_textual_proto_init() } +func file_textual_proto_init() { + if File_textual_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_textual_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*TextualData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_textual_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*SignerData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_textual_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Envelope); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_textual_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_textual_proto_goTypes, + DependencyIndexes: file_textual_proto_depIdxs, + MessageInfos: file_textual_proto_msgTypes, + }.Build() + File_textual_proto = out.File + file_textual_proto_rawDesc = nil + file_textual_proto_goTypes = nil + file_textual_proto_depIdxs = nil +} diff --git a/tx/textual/valuerenderer/bytes.go b/tx/textual/valuerenderer/bytes.go index 59aa2b86bdf6..7b12a027572f 100644 --- a/tx/textual/valuerenderer/bytes.go +++ b/tx/textual/valuerenderer/bytes.go @@ -53,9 +53,9 @@ func (vr bytesValueRenderer) Parse(_ context.Context, screens []Screen) (protore formatted := screens[0].Text // If the formatted string starts with `SHA-256=`, then we can't actually - // invert to get the original bytes. In this case, we error. + // invert to get the original bytes. In this case, we return empty bytes. if strings.HasPrefix(formatted, hashPrefix) { - return nilValue, fmt.Errorf("cannot parse bytes hash") + return protoreflect.ValueOfBytes([]byte{}), nil } // Remove all spaces between every 4th char, then we can decode hex. diff --git a/tx/textual/valuerenderer/bytes_test.go b/tx/textual/valuerenderer/bytes_test.go index b7c7d48f60c5..9f094ac55b85 100644 --- a/tx/textual/valuerenderer/bytes_test.go +++ b/tx/textual/valuerenderer/bytes_test.go @@ -2,7 +2,6 @@ package valuerenderer_test import ( "context" - "encoding/base64" "encoding/json" "os" "testing" @@ -21,35 +20,30 @@ func TestBytesJsonTestCases(t *testing.T) { err = json.Unmarshal(raw, &testcases) require.NoError(t, err) - textual := valuerenderer.NewTextual(mockCoinMetadataQuerier) + textual := valuerenderer.NewTextual(nil) for _, tc := range testcases { - data, err := base64.StdEncoding.DecodeString(tc.base64) - require.NoError(t, err) - valrend, err := textual.GetFieldValueRenderer(fieldDescriptorFromName("BYTES")) require.NoError(t, err) - screens, err := valrend.Format(context.Background(), protoreflect.ValueOfBytes(data)) + screens, err := valrend.Format(context.Background(), protoreflect.ValueOfBytes(tc.base64)) require.NoError(t, err) require.Equal(t, 1, len(screens)) require.Equal(t, tc.hex, screens[0].Text) // Round trip val, err := valrend.Parse(context.Background(), screens) - if err != nil { - // Make sure Parse() only errors because of hashed bytes. - require.Equal(t, "cannot parse bytes hash", err.Error()) - require.Greater(t, len(tc.base64), 32) - continue - } require.NoError(t, err) - require.Equal(t, tc.base64, base64.StdEncoding.EncodeToString(val.Bytes())) + if len(tc.base64) > 32 { + require.Equal(t, 0, len(val.Bytes())) + } else { + require.Equal(t, tc.base64, val.Bytes()) + } } } type bytesTest struct { - base64 string + base64 []byte hex string } diff --git a/tx/textual/valuerenderer/coin_test.go b/tx/textual/valuerenderer/coin_test.go index 8023f9f4f835..77a4c94c0f47 100644 --- a/tx/textual/valuerenderer/coin_test.go +++ b/tx/textual/valuerenderer/coin_test.go @@ -31,6 +31,20 @@ func mockCoinMetadataQuerier(ctx context.Context, denom string) (*bankv1beta1.Me return v.(*bankv1beta1.Metadata), nil } +// addMetadataToContext appends relevant coin metadata to the mock context +// used in tests. +func addMetadataToContext(ctx context.Context, metadata *bankv1beta1.Metadata) context.Context { + if metadata == nil { + return ctx + } + + for _, m := range metadata.DenomUnits { + ctx = context.WithValue(ctx, mockCoinMetadataKey(m.Denom), metadata) + } + + return ctx +} + func TestMetadataQuerier(t *testing.T) { // Errors on nil metadata querier textual := valuerenderer.NewTextual(nil) @@ -66,10 +80,7 @@ func TestCoinJsonTestcases(t *testing.T) { for _, tc := range testcases { t.Run(tc.Text, func(t *testing.T) { if tc.Proto != nil { - ctx := context.WithValue(context.Background(), mockCoinMetadataKey(tc.Proto.Denom), tc.Metadata) - if tc.Metadata != nil { - ctx = context.WithValue(ctx, mockCoinMetadataKey(tc.Metadata.Display), tc.Metadata) - } + ctx := addMetadataToContext(context.Background(), tc.Metadata) screens, err := vr.Format(ctx, protoreflect.ValueOf(tc.Proto.ProtoReflect())) diff --git a/tx/textual/valuerenderer/coins.go b/tx/textual/valuerenderer/coins.go index 899fdc259c3b..2f22ee4cfe35 100644 --- a/tx/textual/valuerenderer/coins.go +++ b/tx/textual/valuerenderer/coins.go @@ -153,17 +153,21 @@ func (vr coinsValueRenderer) parseCoins(ctx context.Context, coinsStr string) ([ // a core Parse function for coins. func parseCoin(coinStr string, metadata *bankv1beta1.Metadata) (*basev1beta1.Coin, error) { coinArr := strings.Split(coinStr, " ") - amt1 := coinArr[0] + amt1 := coinArr[0] // Contains potentially some thousandSeparators coinDenom := coinArr[1] - if metadata == nil || metadata.Base == "" || coinArr[1] == metadata.Base { - dec, err := parseDec(amt1) - if err != nil { - return nil, err - } + amtDecStr, err := parseDec(amt1) + if err != nil { + return nil, err + } + amtDec, err := math.LegacyNewDecFromStr(amtDecStr) + if err != nil { + return nil, err + } + if metadata == nil || metadata.Base == "" || coinArr[1] == metadata.Base { return &basev1beta1.Coin{ - Amount: dec, + Amount: amtDecStr, Denom: coinDenom, }, nil } @@ -185,37 +189,24 @@ func parseCoin(coinStr string, metadata *bankv1beta1.Metadata) (*basev1beta1.Coi // If we didn't find either exponent, then we return early. if !foundCoinExp || !foundBaseExp { - amt, err := parseDec(amt1) - if err != nil { - return nil, err - } - return &basev1beta1.Coin{ - Amount: amt, + Amount: amtDecStr, Denom: baseDenom, }, nil } - // remove 1000 separators, (ex: 1'000'000 -> 1000000) - amt1 = strings.ReplaceAll(amt1, "'", "") - amt, err := math.LegacyNewDecFromStr(amt1) - if err != nil { - return nil, err - } - if coinExp > baseExp { - amt = amt.Mul(math.LegacyNewDec(10).Power(uint64(coinExp - baseExp))) + amtDec = amtDec.Mul(math.LegacyNewDec(10).Power(uint64(coinExp - baseExp))) } else { - amt = amt.Quo(math.LegacyNewDec(10).Power(uint64(baseExp - coinExp))) + amtDec = amtDec.Quo(math.LegacyNewDec(10).Power(uint64(baseExp - coinExp))) } - amtStr, err := parseDec(amt.String()) - if err != nil { - return nil, err + if !amtDec.TruncateDec().Equal(amtDec) { + return nil, fmt.Errorf("got non-integer coin amount %s", amtDec) } return &basev1beta1.Coin{ - Amount: amtStr, + Amount: amtDec.TruncateInt().String(), Denom: baseDenom, }, nil } diff --git a/tx/textual/valuerenderer/coins_test.go b/tx/textual/valuerenderer/coins_test.go index 264e5a27d848..b20a137b638e 100644 --- a/tx/textual/valuerenderer/coins_test.go +++ b/tx/textual/valuerenderer/coins_test.go @@ -32,10 +32,8 @@ func TestCoinsJsonTestcases(t *testing.T) { // Create a context.Context containing all coins metadata, to simulate // that they are in state. ctx := context.Background() - for _, v := range tc.Metadata { - ctx = context.WithValue(ctx, mockCoinMetadataKey(v.Base), v) - ctx = context.WithValue(ctx, mockCoinMetadataKey(v.Display), v) + ctx = addMetadataToContext(ctx, v) } listValue := NewGenericList(tc.Proto) @@ -86,10 +84,10 @@ func checkCoinsEqual(t *testing.T, l1, l2 protoreflect.List) { func checkCoinEqual(t *testing.T, coin, coin1 *basev1beta1.Coin) { require.Equal(t, coin1.Denom, coin.Denom) - v, err := math.LegacyNewDecFromStr(coin.Amount) - require.NoError(t, err) - v1, err := math.LegacyNewDecFromStr(coin1.Amount) - require.NoError(t, err) + v, ok := math.NewIntFromString(coin.Amount) + require.True(t, ok) + v1, ok := math.NewIntFromString(coin1.Amount) + require.True(t, ok) require.True(t, v.Equal(v1)) } diff --git a/tx/textual/valuerenderer/e2e_test.go b/tx/textual/valuerenderer/e2e_test.go new file mode 100644 index 000000000000..add6a78a46c4 --- /dev/null +++ b/tx/textual/valuerenderer/e2e_test.go @@ -0,0 +1,73 @@ +package valuerenderer_test + +import ( + "context" + "encoding/hex" + "encoding/json" + "os" + "testing" + + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/reflect/protoreflect" + + _ "cosmossdk.io/api/cosmos/auth/v1beta1" + _ "cosmossdk.io/api/cosmos/authz/v1beta1" + _ "cosmossdk.io/api/cosmos/crypto/ed25519" + _ "cosmossdk.io/api/cosmos/crypto/multisig" + _ "cosmossdk.io/api/cosmos/crypto/secp256k1" + _ "cosmossdk.io/api/cosmos/gov/v1" + "cosmossdk.io/tx/textual/internal/textualpb" + "cosmossdk.io/tx/textual/valuerenderer" +) + +type e2eJsonTest struct { + txJsonTest + Cbor string +} + +func TestE2EJsonTestcases(t *testing.T) { + raw, err := os.ReadFile("../internal/testdata/e2e.json") + require.NoError(t, err) + + var testcases []e2eJsonTest + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + t.Run(tc.Name, func(t *testing.T) { + _, bodyBz, _, authInfoBz, signerData := createTextualData(t, tc.Proto, tc.SignerData) + + tr := valuerenderer.NewTextual(mockCoinMetadataQuerier) + rend := valuerenderer.NewTxValueRenderer(&tr) + ctx := addMetadataToContext(context.Background(), tc.Metadata) + + data := &textualpb.TextualData{ + BodyBytes: bodyBz, + AuthInfoBytes: authInfoBz, + SignerData: &textualpb.SignerData{ + Address: signerData.Address, + ChainId: signerData.ChainId, + AccountNumber: signerData.AccountNumber, + Sequence: signerData.Sequence, + PubKey: signerData.PubKey, + }, + } + + // Make sure the screens match. + val := protoreflect.ValueOf(data.ProtoReflect()) + screens, err := rend.Format(ctx, val) + if tc.Error { + require.Error(t, err) + return + } + require.NoError(t, err) + require.Equal(t, tc.Screens, screens) + + // Make sure CBOR match. + signDoc, err := tr.GetSignBytes(ctx, bodyBz, authInfoBz, signerData) + require.NoError(t, err) + require.Equal(t, tc.Cbor, hex.EncodeToString(signDoc)) + + }) + } +} diff --git a/tx/textual/valuerenderer/enum.go b/tx/textual/valuerenderer/enum.go index 4cf46af0949c..e07f8ce97c9a 100644 --- a/tx/textual/valuerenderer/enum.go +++ b/tx/textual/valuerenderer/enum.go @@ -30,7 +30,7 @@ func (er enumValueRenderer) Format(_ context.Context, v protoreflect.Value) ([]S return nil, fmt.Errorf("cannot get enum %s variant of number %d", er.ed.FullName(), v.Enum()) } - return []Screen{{Text: string(evd.FullName())}}, nil + return []Screen{{Text: string(evd.Name())}}, nil } @@ -46,7 +46,7 @@ func (er enumValueRenderer) Parse(_ context.Context, screens []Screen) (protoref values := er.ed.Values() for i := 0; i < values.Len(); i++ { evd := values.Get(i) - if string(evd.FullName()) == formatted { + if string(evd.Name()) == formatted { return protoreflect.ValueOfEnum(evd.Number()), nil } } diff --git a/tx/textual/valuerenderer/message.go b/tx/textual/valuerenderer/message.go index d617403ed28e..01bf7589a025 100644 --- a/tx/textual/valuerenderer/message.go +++ b/tx/textual/valuerenderer/message.go @@ -235,14 +235,14 @@ func (mr *messageValueRenderer) Parse(ctx context.Context, screens []Screen) (pr err = r.ParseRepeated(ctx, subscreens, nf.List()) } else { err = mr.parseRepeated(ctx, subscreens, nf.List(), vr) + + //Skip List Terminator + idx++ } if err != nil { return nilValue, err } msg.Set(fd, nf) - - //Skip List Terminator - idx++ } else { val, err = vr.Parse(ctx, subscreens) if err != nil { @@ -252,10 +252,6 @@ func (mr *messageValueRenderer) Parse(ctx context.Context, screens []Screen) (pr } } - if idx > len(screens) { - return nilValue, errors.New("leftover screens") - } - return protoreflect.ValueOfMessage(msg), nil } diff --git a/tx/textual/valuerenderer/tx.go b/tx/textual/valuerenderer/tx.go new file mode 100644 index 000000000000..5305bc224312 --- /dev/null +++ b/tx/textual/valuerenderer/tx.go @@ -0,0 +1,341 @@ +package valuerenderer + +import ( + "bytes" + "context" + "crypto/sha256" + "encoding/binary" + "encoding/hex" + "fmt" + "regexp" + "strings" + + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/types/known/anypb" + + msg "cosmossdk.io/api/cosmos/msg/v1" + signingv1beta1 "cosmossdk.io/api/cosmos/tx/signing/v1beta1" + txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" + "cosmossdk.io/tx/textual/internal/textualpb" +) + +var ( + // msgRe is a regex matching the beginning of the TxBody msgs in the envelope. + msgRe = regexp.MustCompile("Message: ([0-9]+) Any") + // inverseMsgRe is a regex matching the textual output of the TxBody msgs + // header. + inverseMsgRe = regexp.MustCompile("This transaction has ([0-9]+) Messages?") +) + +type txValueRenderer struct { + tr *Textual +} + +// NewTxValueRenderer returns a ValueRenderer for the protobuf +// TextualData type. It follows the specification defined in ADR-050. +// The reason we create a renderer for TextualData (and not directly Tx) +// is that TextualData is a single place that contains all data needed +// to create the `[]Screen` SignDoc. +func NewTxValueRenderer(tr *Textual) ValueRenderer { + return txValueRenderer{ + tr: tr, + } +} + +// Format implements the ValueRenderer interface. +func (vr txValueRenderer) Format(ctx context.Context, v protoreflect.Value) ([]Screen, error) { + // Reify the reflected message as a proto Tx + msg := v.Message().Interface() + textualData, ok := msg.(*textualpb.TextualData) + if !ok { + return nil, fmt.Errorf("expected Tx, got %T", msg) + } + + txBody := &txv1beta1.TxBody{} + txAuthInfo := &txv1beta1.AuthInfo{} + err := proto.Unmarshal(textualData.BodyBytes, txBody) + if err != nil { + return nil, err + } + err = proto.Unmarshal(textualData.AuthInfoBytes, txAuthInfo) + if err != nil { + return nil, err + } + + // Create envelope here. We really need to make sure that all the non-Msg + // fields inside both TxBody and AuthInfo are flattened here. For example, + // if we decide to add new fields in either of those 2 structs, then we + // should add a new field here in Envelope. + envelope := &textualpb.Envelope{ + ChainId: textualData.SignerData.ChainId, + AccountNumber: textualData.SignerData.AccountNumber, + Sequence: textualData.SignerData.Sequence, + Address: textualData.SignerData.Address, + PublicKey: textualData.SignerData.PubKey, + Message: txBody.Messages, + Memo: txBody.Memo, + Fees: txAuthInfo.Fee.Amount, + FeePayer: txAuthInfo.Fee.Payer, + FeeGranter: txAuthInfo.Fee.Granter, + GasLimit: txAuthInfo.Fee.GasLimit, + TimeoutHeight: txBody.TimeoutHeight, + ExtensionOptions: txBody.ExtensionOptions, + NonCriticalExtensionOptions: txBody.NonCriticalExtensionOptions, + HashOfRawBytes: getHash(textualData.BodyBytes, textualData.AuthInfoBytes), + } + if txAuthInfo.Tip != nil { + envelope.Tip = txAuthInfo.Tip.Amount + envelope.Tipper = txAuthInfo.Tip.Tipper + } + // Find all other tx signers than the current signer. In the case where our + // Textual signer is one key of a multisig, then otherSigners will include + // the multisig pubkey. + otherSigners := []*txv1beta1.SignerInfo{} + for _, si := range txAuthInfo.SignerInfos { + if bytes.Equal(si.PublicKey.Value, textualData.SignerData.PubKey.Value) { + continue + } + + otherSigners = append(otherSigners, si) + } + envelope.OtherSigner = otherSigners + + mvr, err := vr.tr.GetMessageValueRenderer(envelope.ProtoReflect().Descriptor()) + if err != nil { + return nil, err + } + + screens, err := mvr.Format(ctx, protoreflect.ValueOf(envelope.ProtoReflect())) + if err != nil { + return nil, err + } + + // Since we're value-rendering the (internal) envelope message, we do some + // postprocessing. First, we remove first envelope header screen, and + // unindent 1 level. + + // Remove 1st screen + screens = screens[1:] + for i := range screens { + screens[i].Indent-- + } + + // Expert fields. + expert := map[string]struct{}{ + "Public key": {}, + "Fee payer": {}, + "Fee granter": {}, + "Gas limit": {}, + "Timeout height": {}, + "Other signer": {}, + "Extension options": {}, + "Non critical extension options": {}, + "Hash of raw bytes": {}, + } + + for i := range screens { + if screens[i].Indent == 0 { + // Do expert fields. + screenKV := strings.Split(screens[i].Text, ": ") + _, ok := expert[screenKV[0]] + if ok { + expertify(screens, i, screenKV[0]) + } + + // Replace: + // "Message: Any" + // with: + // "This transaction has Message" + matches := msgRe.FindStringSubmatch(screens[i].Text) + if len(matches) > 0 { + screens[i].Text = fmt.Sprintf("This transaction has %s Message", matches[1]) + if matches[1] != "1" { + screens[i].Text += "s" + } + } + } + } + + return screens, nil +} + +// expertify marks all screens starting from `fromIdx` as expert, and stops +// just before it finds the next screen with Indent==0 (unless it's a "End of" +// termination screen). It modifies screens in-place. +func expertify(screens []Screen, fromIdx int, fieldName string) { + for i := fromIdx; i < len(screens); i++ { + if i > fromIdx && + screens[i].Indent == 0 && + screens[i].Text != fmt.Sprintf("End of %s", fieldName) { + break + } + + screens[i].Expert = true + } +} + +// getHash gets the hash of raw bytes to be signed over: +// HEX(sha256(len(body_bytes) ++ body_bytes ++ len(auth_info_bytes) ++ auth_info_bytes)) +func getHash(bodyBz, authInfoBz []byte) string { + bodyLen, authInfoLen := make([]byte, 8), make([]byte, 8) + binary.BigEndian.PutUint64(bodyLen, uint64(len(bodyBz))) + binary.BigEndian.PutUint64(authInfoLen, uint64(len(authInfoBz))) + + b := make([]byte, 16+len(bodyBz)+len(authInfoBz)) + copy(b[:8], bodyLen) + copy(b[8:8+len(bodyBz)], bodyBz) + copy(b[8+len(bodyBz):16+len(bodyBz)], authInfoLen) + copy(b[16+len(bodyBz):], authInfoBz) + + h := sha256.Sum256(b) + + return hex.EncodeToString(h[:]) +} + +// Parse implements the ValueRenderer interface. +func (vr txValueRenderer) Parse(ctx context.Context, screens []Screen) (protoreflect.Value, error) { + // Process the screens to be parsable by a envelope message value renderer + parsable := make([]Screen, len(screens)+1) + parsable[0] = Screen{Text: "Envelope object"} + for i := range screens { + parsable[i+1].Indent = screens[i].Indent + 1 + + // Take same text, except that we weplace: + // "This transaction has Message" + // with: + // "Message: Any" + matches := inverseMsgRe.FindStringSubmatch(screens[i].Text) + if len(matches) > 0 { + parsable[i+1].Text = fmt.Sprintf("Message: %s Any", matches[1]) + } else { + parsable[i+1].Text = screens[i].Text + } + } + + mvr, err := vr.tr.GetMessageValueRenderer((&textualpb.Envelope{}).ProtoReflect().Descriptor()) + if err != nil { + return nilValue, err + } + + envelopeV, err := mvr.Parse(ctx, parsable) + if err != nil { + return nilValue, err + } + envelope := envelopeV.Message().Interface().(*textualpb.Envelope) + + txBody := &txv1beta1.TxBody{ + Messages: envelope.Message, + Memo: envelope.Memo, + TimeoutHeight: envelope.TimeoutHeight, + ExtensionOptions: envelope.ExtensionOptions, + NonCriticalExtensionOptions: envelope.NonCriticalExtensionOptions, + } + authInfo := &txv1beta1.AuthInfo{ + Fee: &txv1beta1.Fee{ + Amount: envelope.Fees, + GasLimit: envelope.GasLimit, + Payer: envelope.FeePayer, + Granter: envelope.FeeGranter, + }, + } + if envelope.Tip != nil { + authInfo.Tip = &txv1beta1.Tip{ + Amount: envelope.Tip, + Tipper: envelope.Tipper, + } + } + + // Figure out the signers in the correct order. + signers, err := getSigners(txBody, authInfo) + if err != nil { + return nilValue, err + } + + signerInfos := make([]*txv1beta1.SignerInfo, len(signers)) + for i, s := range signers { + if s == envelope.Address { + signerInfos[i] = &txv1beta1.SignerInfo{ + PublicKey: envelope.PublicKey, + ModeInfo: &txv1beta1.ModeInfo{ + Sum: &txv1beta1.ModeInfo_Single_{ + Single: &txv1beta1.ModeInfo_Single{ + Mode: signingv1beta1.SignMode_SIGN_MODE_TEXTUAL, + }, + }, + }, + Sequence: envelope.Sequence, + } + } else { + // We know that signerInfos is well ordered, so just pop from it. + signerInfos[i] = envelope.OtherSigner[0] + envelope.OtherSigner = envelope.OtherSigner[1:] + } + } + authInfo.SignerInfos = signerInfos + + // Note that we might not always get back the exact bodyBz and authInfoBz + // that was passed into, because protobuf is not deterministic. + // In tests, we don't check bytes equality, but protobuf object equality. + bodyBz, err := proto.Marshal(txBody) + if err != nil { + return nilValue, err + } + authInfoBz, err := proto.Marshal(authInfo) + if err != nil { + return nilValue, err + } + + tx := &textualpb.TextualData{ + BodyBytes: bodyBz, + AuthInfoBytes: authInfoBz, + SignerData: &textualpb.SignerData{ + Address: envelope.Address, + AccountNumber: envelope.AccountNumber, + ChainId: envelope.ChainId, + Sequence: envelope.Sequence, + PubKey: envelope.PublicKey, + }, + } + + return protoreflect.ValueOf(tx.ProtoReflect()), nil +} + +// getSigners gets the ordered signers of a transaction. It's mostly a +// copy-paste of `types/tx/types.go` GetSigners method, but uses the proto +// annotation `cosmos.msg.v1.signer`, instead of the sdk.Msg#GetSigners method. +func getSigners(body *txv1beta1.TxBody, authInfo *txv1beta1.AuthInfo) ([]string, error) { + var signers []string + seen := map[string]bool{} + + for _, msgAny := range body.Messages { + m, err := anypb.UnmarshalNew(msgAny, proto.UnmarshalOptions{}) + if err != nil { + return nil, err + } + + ext := proto.GetExtension(m.ProtoReflect().Descriptor().Options(), msg.E_Signer) + signerFields, ok := ext.([]string) + if !ok { + return nil, fmt.Errorf("expected []string, got %T", ext) + } + + for _, fieldName := range signerFields { + fd := m.ProtoReflect().Descriptor().Fields().ByName(protoreflect.Name(fieldName)) + addr := m.ProtoReflect().Get(fd).String() + if !seen[addr] { + signers = append(signers, addr) + seen[addr] = true + } + } + } + + // ensure any specified fee payer is included in the required signers (at the end) + feePayer := authInfo.Fee.Payer + if feePayer != "" && !seen[feePayer] { + signers = append(signers, feePayer) + seen[feePayer] = true + } + + return signers, nil +} diff --git a/tx/textual/valuerenderer/tx_test.go b/tx/textual/valuerenderer/tx_test.go new file mode 100644 index 000000000000..afe6ff345819 --- /dev/null +++ b/tx/textual/valuerenderer/tx_test.go @@ -0,0 +1,182 @@ +package valuerenderer_test + +import ( + "context" + "encoding/json" + "os" + "testing" + + "github.com/cosmos/cosmos-proto/any" + "github.com/google/go-cmp/cmp" + "github.com/stretchr/testify/require" + "google.golang.org/protobuf/encoding/protojson" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/reflect/protoreflect" + "google.golang.org/protobuf/testing/protocmp" + "google.golang.org/protobuf/types/known/anypb" + + _ "cosmossdk.io/api/cosmos/auth/v1beta1" + _ "cosmossdk.io/api/cosmos/authz/v1beta1" + bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" + _ "cosmossdk.io/api/cosmos/crypto/ed25519" + "cosmossdk.io/api/cosmos/crypto/multisig" + _ "cosmossdk.io/api/cosmos/crypto/secp256k1" + _ "cosmossdk.io/api/cosmos/gov/v1" + txv1beta1 "cosmossdk.io/api/cosmos/tx/v1beta1" + "cosmossdk.io/tx/signing" + "cosmossdk.io/tx/textual/internal/textualpb" + "cosmossdk.io/tx/textual/valuerenderer" +) + +// txJsonTestTx represents the type that in the JSON test +// cases `proto` field. The inner contents are protojson +// encoded, so we represent them as []byte here, and decode +// them inside the test. +type txJsonTestTx struct { + Body json.RawMessage + AuthInfo json.RawMessage `json:"auth_info"` +} + +type txJsonTest struct { + Name string + Proto txJsonTestTx + SignerData json.RawMessage `json:"signer_data"` + Metadata *bankv1beta1.Metadata + Error bool + Screens []valuerenderer.Screen +} + +func TestTxJsonTestcases(t *testing.T) { + raw, err := os.ReadFile("../internal/testdata/tx.json") + require.NoError(t, err) + + var testcases []txJsonTest + err = json.Unmarshal(raw, &testcases) + require.NoError(t, err) + + for _, tc := range testcases { + t.Run(tc.Name, func(t *testing.T) { + txBody, bodyBz, txAuthInfo, authInfoBz, signerData := createTextualData(t, tc.Proto, tc.SignerData) + + tr := valuerenderer.NewTextual(mockCoinMetadataQuerier) + rend := valuerenderer.NewTxValueRenderer(&tr) + ctx := addMetadataToContext(context.Background(), tc.Metadata) + + data := &textualpb.TextualData{ + BodyBytes: bodyBz, + AuthInfoBytes: authInfoBz, + SignerData: &textualpb.SignerData{ + Address: signerData.Address, + ChainId: signerData.ChainId, + AccountNumber: signerData.AccountNumber, + Sequence: signerData.Sequence, + PubKey: signerData.PubKey, + }, + } + + // Make sure the screens match. + val := protoreflect.ValueOf(data.ProtoReflect()) + screens, err := rend.Format(ctx, val) + if tc.Error { + require.Error(t, err) + return + } + require.NoError(t, err) + require.Equal(t, tc.Screens, screens) + + // Round trip. + parsedVal, err := rend.Parse(ctx, screens) + require.NoError(t, err) + + // We don't check that bodyBz and authInfoBz are equal, because + // they don't need to be. Instead, we check that the semantic + // proto objects are equal. + parsedTextualData := parsedVal.Message().Interface().(*textualpb.TextualData) + + parsedBody := &txv1beta1.TxBody{} + err = proto.Unmarshal(parsedTextualData.BodyBytes, parsedBody) + require.NoError(t, err) + diff := cmp.Diff(txBody, parsedBody, protocmp.Transform()) + require.Empty(t, diff) + + parsedAuthInfo := &txv1beta1.AuthInfo{} + err = proto.Unmarshal(parsedTextualData.AuthInfoBytes, parsedAuthInfo) + require.NoError(t, err) + // Remove the non-parsable fields, i.e. the hashed bytes + for i, si := range txAuthInfo.SignerInfos { + txAuthInfo.SignerInfos[i].PublicKey = removePkKeys(t, si.PublicKey) + } + diff = cmp.Diff(txAuthInfo, parsedAuthInfo, protocmp.Transform()) + require.Empty(t, diff) + + // Remove the non-parsable fields, i.e. the hashed public key + removePkKeys(t, signerData.PubKey) + diff = cmp.Diff( + signerData, + signerDataFromProto(parsedTextualData.SignerData), + protocmp.Transform(), + ) + require.Empty(t, diff) + }) + } +} + +// createTextualData creates a Textual data give then JSON +// test case. +func createTextualData(t *testing.T, jsonTx txJsonTestTx, jsonSignerData json.RawMessage) (*txv1beta1.TxBody, []byte, *txv1beta1.AuthInfo, []byte, signing.SignerData) { + body := &txv1beta1.TxBody{} + authInfo := &txv1beta1.AuthInfo{} + protoSignerData := &textualpb.SignerData{} + + // We unmarshal from protojson to the protobuf types. + err := protojson.Unmarshal(jsonTx.Body, body) + require.NoError(t, err) + err = protojson.Unmarshal(jsonTx.AuthInfo, authInfo) + require.NoError(t, err) + err = protojson.Unmarshal(jsonSignerData, protoSignerData) + require.NoError(t, err) + + // We marshal body and auth_info + bodyBz, err := proto.Marshal(body) + require.NoError(t, err) + authInfoBz, err := proto.Marshal(authInfo) + require.NoError(t, err) + + return body, bodyBz, authInfo, authInfoBz, signerDataFromProto(protoSignerData) +} + +// signerDataFromProto converts a protobuf SignerData (internal) to a +// signing.SignerData (external). +func signerDataFromProto(d *textualpb.SignerData) signing.SignerData { + return signing.SignerData{ + Address: d.Address, + ChainId: d.ChainId, + AccountNumber: d.AccountNumber, + Sequence: d.Sequence, + PubKey: d.PubKey, + } +} + +// removePkKeys takes a public key Any, decodes it, and recursively removes all +// the "key" fields (hashed by textual) inside it. +func removePkKeys(t *testing.T, pkAny *anypb.Any) *anypb.Any { + pk, err := anypb.UnmarshalNew(pkAny, proto.UnmarshalOptions{}) + require.NoError(t, err) + m := pk.ProtoReflect().Interface() + switch m := m.(type) { + case *multisig.LegacyAminoPubKey: + newAnys := make([]*anypb.Any, len(m.PublicKeys)) + for i, any := range m.PublicKeys { + newAnys[i] = removePkKeys(t, any) + } + + m.PublicKeys = newAnys + newMultisigAny, err := any.New(m) + require.NoError(t, err) + + return newMultisigAny + default: + pkAny.Value = nil + return pkAny + } +} diff --git a/tx/textual/valuerenderer/valuerenderer.go b/tx/textual/valuerenderer/valuerenderer.go index 6cbfab2934b2..6a9aeffb7837 100644 --- a/tx/textual/valuerenderer/valuerenderer.go +++ b/tx/textual/valuerenderer/valuerenderer.go @@ -1,6 +1,7 @@ package valuerenderer import ( + "bytes" "context" "fmt" @@ -12,6 +13,8 @@ import ( bankv1beta1 "cosmossdk.io/api/cosmos/bank/v1beta1" basev1beta1 "cosmossdk.io/api/cosmos/base/v1beta1" + "cosmossdk.io/tx/signing" + "cosmossdk.io/tx/textual/internal/textualpb" cosmos_proto "github.com/cosmos/cosmos-proto" ) @@ -61,12 +64,11 @@ func (r *Textual) GetFieldValueRenderer(fd protoreflect.FieldDescriptor) (ValueR } vr := r.scalars[scalar] - if vr == nil { - return nil, fmt.Errorf("got empty value renderer for scalar %s", scalar) + if vr != nil { + return vr(fd), nil } - - return vr(fd), nil } + return NewStringValueRenderer(), nil case fd.Kind() == protoreflect.BytesKind: @@ -125,6 +127,7 @@ func (r *Textual) init() { r.messages[(&durationpb.Duration{}).ProtoReflect().Descriptor().FullName()] = NewDurationValueRenderer() r.messages[(×tamppb.Timestamp{}).ProtoReflect().Descriptor().FullName()] = NewTimestampValueRenderer() r.messages[(&anypb.Any{}).ProtoReflect().Descriptor().FullName()] = NewAnyValueRenderer(r) + r.messages[(&textualpb.TextualData{}).ProtoReflect().Descriptor().FullName()] = NewTxValueRenderer(r) } } @@ -133,3 +136,36 @@ func (r *Textual) DefineScalar(scalar string, vr ValueRendererCreator) { r.init() r.scalars[scalar] = vr } + +// GetSignBytes returns the transaction sign bytes. +func (r *Textual) GetSignBytes(ctx context.Context, bodyBz, authInfoBz []byte, signerData signing.SignerData) ([]byte, error) { + data := &textualpb.TextualData{ + BodyBytes: bodyBz, + AuthInfoBytes: authInfoBz, + SignerData: &textualpb.SignerData{ + Address: signerData.Address, + ChainId: signerData.ChainId, + AccountNumber: signerData.AccountNumber, + Sequence: signerData.Sequence, + PubKey: signerData.PubKey, + }, + } + + vr, err := r.GetMessageValueRenderer(data.ProtoReflect().Descriptor()) + if err != nil { + return nil, err + } + + screens, err := vr.Format(ctx, protoreflect.ValueOf(data.ProtoReflect())) + if err != nil { + return nil, err + } + + var buf bytes.Buffer + err = encode(screens, &buf) + if err != nil { + return nil, err + } + + return buf.Bytes(), nil +}