diff --git a/PENDING.md b/PENDING.md index 490fd171fa9e..44056c28d03f 100644 --- a/PENDING.md +++ b/PENDING.md @@ -40,6 +40,7 @@ FEATURES * [\#3069](https://github.com/cosmos/cosmos-sdk/pull/3069) Add a custom memo on transactions * [\#3027](https://github.com/cosmos/cosmos-sdk/issues/3027) Implement `/gov/proposals/{proposalID}/proposer` to query for a proposal's proposer. + * [\#3284](https://github.com/cosmos/cosmos-sdk/issues/3284) Implement generation of txs without account. * Gaia CLI (`gaiacli`) * \#2399 Implement `params` command to query slashing parameters. diff --git a/client/lcd/lcd_test.go b/client/lcd/lcd_test.go index bb099711fd4a..70eaca286f77 100644 --- a/client/lcd/lcd_test.go +++ b/client/lcd/lcd_test.go @@ -262,7 +262,7 @@ func TestCoinSendGenerateSignAndBroadcast(t *testing.T) { payload := authrest.SignBody{ Tx: msg, BaseReq: utils.NewBaseReq( - name1, pw, "", viper.GetString(client.FlagChainID), "", "", accnum, sequence, nil, false, false, + name1, pw, sdk.AccAddress{}, "", viper.GetString(client.FlagChainID), "", "", accnum, sequence, nil, false, false, ), } json, err := cdc.MarshalJSON(payload) @@ -399,8 +399,17 @@ func TestBonding(t *testing.T) { acc := getAccount(t, port, addr) initialBalance := acc.GetCoins() + var resultTx ctypes.ResultBroadcastTxCommit + var tx auth.StdTx + // generate bond TX + body := doDelegate(t, port, name1, pw, addr, operAddrs[0], 60, fees, true) + err := cdc.UnmarshalJSON([]byte(body), &tx) + require.Nil(t, err) + // create bond TX - resultTx := doDelegate(t, port, name1, pw, addr, operAddrs[0], 60, fees) + body = doDelegate(t, port, name1, pw, addr, operAddrs[0], 60, fees, false) + err = cdc.UnmarshalJSON([]byte(body), &resultTx) + require.Nil(t, err) tests.WaitForHeight(resultTx.Height+1, port) require.Equal(t, uint32(0), resultTx.CheckTx.Code) @@ -441,8 +450,15 @@ func TestBonding(t *testing.T) { bondedValidator := getDelegatorValidator(t, port, addr, operAddrs[0]) require.Equal(t, operAddrs[0], bondedValidator.OperatorAddr) + // generate unbond TX + body = doBeginUnbonding(t, port, name1, pw, addr, operAddrs[0], 60, fees, true) + err = cdc.UnmarshalJSON([]byte(body), &tx) + require.Nil(t, err) + // testing unbonding - resultTx = doBeginUnbonding(t, port, name1, pw, addr, operAddrs[0], 30, fees) + body = doBeginUnbonding(t, port, name1, pw, addr, operAddrs[0], 30, fees, false) + err = cdc.UnmarshalJSON([]byte(body), &resultTx) + require.Nil(t, err) tests.WaitForHeight(resultTx.Height+1, port) require.Equal(t, uint32(0), resultTx.CheckTx.Code) @@ -470,8 +486,15 @@ func TestBonding(t *testing.T) { unbonding := getUndelegation(t, port, addr, operAddrs[0]) require.Equal(t, int64(30), unbonding.Balance.Amount.Int64()) + // generate redelegation TX + body = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], 30, fees, true) + err = cdc.UnmarshalJSON([]byte(body), &tx) + require.Nil(t, err) + // test redelegation - resultTx = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], 30, fees) + body = doBeginRedelegation(t, port, name1, pw, addr, operAddrs[0], operAddrs[1], 30, fees, false) + err = cdc.UnmarshalJSON([]byte(body), &resultTx) + require.Nil(t, err) tests.WaitForHeight(resultTx.Height+1, port) require.Equal(t, uint32(0), resultTx.CheckTx.Code) @@ -678,7 +701,9 @@ func TestVote(t *testing.T) { require.Equal(t, sdk.ZeroDec(), tally.Yes, "tally should be 0 as the address is not bonded") // create bond TX - resultTx = doDelegate(t, port, name1, pw, addr, operAddrs[0], 60, fees) + body := doDelegate(t, port, name1, pw, addr, operAddrs[0], 60, fees, false) + err := cdc.UnmarshalJSON([]byte(body), &resultTx) + require.Nil(t, err) tests.WaitForHeight(resultTx.Height+1, port) // verify balance diff --git a/client/lcd/swagger-ui/swagger.yaml b/client/lcd/swagger-ui/swagger.yaml index a52f80c8be8d..5771387f44b5 100644 --- a/client/lcd/swagger-ui/swagger.yaml +++ b/client/lcd/swagger-ui/swagger.yaml @@ -1,28 +1,28 @@ --- -swagger: '2.0' +swagger: "2.0" info: version: "3.0" title: Gaia-Lite for Cosmos description: A REST interface for state queries, transaction generation, signing, and broadcast. tags: -- name: ICS0 - description: Tendermint APIs, such as query blocks, transactions and validatorset -- name: ICS1 - description: Key management APIs -- name: ICS20 - description: Create, sign and broadcast transactions -- name: ICS21 - description: Stake module APIs -- name: ICS22 - description: Governance module APIs -- name: ICS23 - description: Slashing module APIs -- name: ICS24 - description: WIP - Fee distribution module APIs -- name: version - description: Query app version + - name: ICS0 + description: Tendermint APIs, such as query blocks, transactions and validatorset + - name: ICS1 + description: Key management APIs + - name: ICS20 + description: Create, sign and broadcast transactions + - name: ICS21 + description: Stake module APIs + - name: ICS22 + description: Governance module APIs + - name: ICS23 + description: Slashing module APIs + - name: ICS24 + description: WIP - Fee distribution module APIs + - name: version + description: Query app version schemes: -- https + - https host: fabo.interblock.io:1317 securityDefinitions: kms: @@ -32,7 +32,7 @@ paths: get: summary: Version of Gaia-lite tags: - - version + - version description: Get the version of gaia-lite running locally to compare against expected responses: 200: @@ -41,7 +41,7 @@ paths: get: summary: Version of the connected node tags: - - version + - version description: Get the version of the SDK running on the connected node to compare against expected responses: 200: @@ -53,9 +53,9 @@ paths: description: Information about the connected node summary: The properties of the connected node tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json responses: 200: description: Node status @@ -90,7 +90,7 @@ paths: get: summary: Syncing state of node tags: - - ICS0 + - ICS0 description: Get if the node is currently syning with other nodes responses: 200: @@ -101,9 +101,9 @@ paths: get: summary: Get the latest block tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json responses: 200: description: The latest block @@ -115,15 +115,15 @@ paths: get: summary: Get a block at a certain height tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json parameters: - - in: path - name: height - description: Block height - required: true - type: number + - in: path + name: height + description: Block height + required: true + type: number responses: 200: description: The block at a specific height @@ -139,9 +139,9 @@ paths: get: summary: Get the latest validator set tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json responses: 200: description: The validator set at the latest block height @@ -160,15 +160,15 @@ paths: get: summary: Get a validator set a certain height tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json parameters: - - in: path - name: height - description: Block height - required: true - type: number + - in: path + name: height + description: Block height + required: true + type: number responses: 200: description: The validator set at a specific block height @@ -191,15 +191,15 @@ paths: get: summary: Get a Tx by hash tags: - - ICS0 + - ICS0 produces: - - application/json + - application/json parameters: - - in: path - name: hash - description: Tx hash - required: true - type: string + - in: path + name: hash + description: Tx hash + required: true + type: string responses: 200: description: Tx with the provided hash @@ -210,25 +210,25 @@ paths: /txs: get: tags: - - ICS0 + - ICS0 summary: Search transactions description: Search transactions by tag(s). produces: - - application/json + - application/json parameters: - - in: query - name: tag - type: string - description: "transaction tags such as 'action=submit-proposal' and 'proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc' which results in the following endpoint: 'GET /txs?action=submit-proposal&proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'" - required: true - - in: query - name: page - description: Pagination page - type: integer - - in: query - name: size - description: Pagination size - type: integer + - in: query + name: tag + type: string + description: "transaction tags such as 'action=submit-proposal' and 'proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc' which results in the following endpoint: 'GET /txs?action=submit-proposal&proposer=cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'" + required: true + - in: query + name: page + description: Pagination page + type: integer + - in: query + name: size + description: Pagination size + type: integer responses: 200: description: All txs matching the provided tags @@ -242,26 +242,26 @@ paths: description: Internal Server Error post: tags: - - ICS0 + - ICS0 summary: broadcast Tx description: broadcast tx with tendermint rpc consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: body - name: txBroadcast - description: Build a StdTx transaction and serilize it to a byte array with amino, then the `"tx"` field in the post body will be the base64 encoding of the byte array. The supported return types includes `"block"`(return after tx commit), `"sync"`(return afer CheckTx) and `"async"`(return right away). - required: true - schema: - type: object - properties: - tx: - type: string - return: - type: string - example: block + - in: body + name: txBroadcast + description: Build a StdTx transaction and serilize it to a byte array with amino, then the `"tx"` field in the post body will be the base64 encoding of the byte array. The supported return types includes `"block"`(return after tx commit), `"sync"`(return afer CheckTx) and `"async"`(return right away). + required: true + schema: + type: object + properties: + tx: + type: string + return: + type: string + example: block responses: 200: description: Broadcast tx result @@ -272,28 +272,28 @@ paths: /tx/sign: post: tags: - - ICS20 + - ICS20 summary: Sign a Tx description: Sign a Tx providing locally stored account and according password consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: body - name: sendToken - description: sign tx - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - tx: - $ref: "#/definitions/StdTx" - append_sig: - type: boolean - example: true + - in: body + name: sendToken + description: sign tx + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + tx: + $ref: "#/definitions/StdTx" + append_sig: + type: boolean + example: true responses: 200: description: The signed Tx @@ -308,23 +308,23 @@ paths: /tx/broadcast: post: tags: - - ICS20 + - ICS20 summary: Send a signed Tx description: Send a signed Tx to a Gaiad full node consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: body - name: txBroadcast - description: broadcast tx - required: true - schema: - type: object - properties: - tx: - $ref: "#/definitions/StdTx" + - in: body + name: txBroadcast + description: broadcast tx + required: true + schema: + type: object + properties: + tx: + $ref: "#/definitions/StdTx" responses: 202: description: Tx was send and will probably be added to the next block @@ -338,15 +338,15 @@ paths: get: summary: Get the account balances tags: - - ICS20 + - ICS20 produces: - - application/json + - application/json parameters: - - in: path - name: address - description: Account address in bech32 format - required: true - type: string + - in: path + name: address + description: Account address in bech32 format + required: true + type: string responses: 200: description: Account balances @@ -363,30 +363,30 @@ paths: summary: Send coins (build -> sign -> send) description: Send coins (build -> sign -> send) tags: - - ICS20 + - ICS20 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: path - name: address - description: Account address in bech32 format - required: true - type: string - - in: body - name: account - description: The password of the account to remove from the KMS - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - amount: - type: array - items: - $ref: "#/definitions/Coin" + - in: path + name: address + description: Account address in bech32 format + required: true + type: string + - in: body + name: account + description: The password of the account to remove from the KMS + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + amount: + type: array + items: + $ref: "#/definitions/Coin" responses: 202: description: Tx was send and will probably be added to the next block @@ -402,43 +402,43 @@ paths: get: summary: List of accounts stored locally tags: - - ICS1 + - ICS1 produces: - - application/json + - application/json responses: 200: description: Array of accounts schema: type: array items: - $ref: '#/definitions/KeyOutput' + $ref: "#/definitions/KeyOutput" 500: description: Server internal error post: summary: Create a new account locally tags: - - ICS1 + - ICS1 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: body - name: account - description: The account to create - schema: - type: object - required: - - name - - password - - seed - properties: - name: - type: string - password: - type: string - seed: - type: string + - in: body + name: account + description: The account to create + schema: + type: object + required: + - name + - password + - seed + properties: + name: + type: string + password: + type: string + seed: + type: string responses: 200: description: Returns account information of the created key @@ -454,7 +454,7 @@ paths: get: summary: Create a new seed to create a new account with tags: - - ICS1 + - ICS1 responses: 200: description: 24 word Seed @@ -465,30 +465,30 @@ paths: post: summary: Recover a account from a seed tags: - - ICS1 + - ICS1 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: path - name: name - description: Account name - required: true - type: string - - in: body - name: pwdAndSeed - description: Provide password and seed to recover a key - schema: - type: object - required: - - password - - seed - properties: - password: - type: string - seed: - type: string + - in: path + name: name + description: Account name + required: true + type: string + - in: body + name: pwdAndSeed + description: Provide password and seed to recover a key + schema: + type: object + required: + - password + - seed + properties: + password: + type: string + seed: + type: string responses: 200: description: Returns account information of the recovered key @@ -502,17 +502,17 @@ paths: description: Server internal error /keys/{name}: parameters: - - in: path - name: name - description: Account name - required: true - type: string + - in: path + name: name + description: Account name + required: true + type: string get: summary: Get a certain locally stored account tags: - - ICS1 + - ICS1 produces: - - application/json + - application/json responses: 200: description: Locally stored account @@ -523,23 +523,23 @@ paths: put: summary: Update the password for this account in the KMS tags: - - ICS1 + - ICS1 consumes: - - application/json + - application/json parameters: - - in: body - name: account - description: The new and old password - schema: - type: object - required: - - new_password - - old_password - properties: - new_password: - type: string - old_password: - type: string + - in: body + name: account + description: The new and old password + schema: + type: object + required: + - new_password + - old_password + properties: + new_password: + type: string + old_password: + type: string responses: 200: description: Updated password @@ -550,20 +550,20 @@ paths: delete: summary: Remove an account tags: - - ICS1 + - ICS1 consumes: - - application/json + - application/json parameters: - - in: body - name: account - description: The password of the account to remove from the KMS - schema: - type: object - required: - - password - properties: - password: - type: string + - in: body + name: account + description: The password of the account to remove from the KMS + schema: + type: object + required: + - password + properties: + password: + type: string responses: 200: description: Removed account @@ -575,15 +575,15 @@ paths: get: summary: Get the account information on blockchain tags: - - ICS1 + - ICS1 produces: - - application/json + - application/json parameters: - - in: path - name: address - description: Account address - required: true - type: string + - in: path + name: address + description: Account address + required: true + type: string responses: 200: description: Account information on the blockchain @@ -613,17 +613,17 @@ paths: description: Server internel error /staking/delegators/{delegatorAddr}/delegations: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Get all delegations from a delegator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -638,26 +638,26 @@ paths: post: summary: Submit delegation parameters: - - in: body - name: delegation - description: The password of the account to remove from the KMS - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_addr: - $ref: "#/definitions/Address" - validator_addr: - $ref: "#/definitions/ValidatorAddress" - delegation: - $ref: "#/definitions/Coin" + - in: body + name: delegation + description: The password of the account to remove from the KMS + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + delegator_addr: + $ref: "#/definitions/Address" + validator_addr: + $ref: "#/definitions/ValidatorAddress" + delegation: + $ref: "#/definitions/Coin" tags: - - ICS21 + - ICS21 consumes: - - application/json + - application/json produces: - - application/json + - application/json responses: 200: description: OK @@ -671,22 +671,22 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/delegations/{validatorAddr}: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Query the current delegation between a delegator and a validator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -698,17 +698,17 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/unbonding_delegations: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Get all unbonding delegations from a delegator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -723,37 +723,37 @@ paths: post: summary: Submit an unbonding delegation parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: delegation - description: The password of the account to remove from the KMS - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_addr: - $ref: "#/definitions/Address" - validator_addr: - $ref: "#/definitions/ValidatorAddress" - shares: - type: string - example: "100" - tags: - - ICS21 + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: delegation + description: The password of the account to remove from the KMS + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + delegator_addr: + $ref: "#/definitions/Address" + validator_addr: + $ref: "#/definitions/ValidatorAddress" + shares: + type: string + example: "100" + tags: + - ICS21 consumes: - - application/json + - application/json produces: - - application/json + - application/json responses: 200: description: OK @@ -767,22 +767,22 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Query all unbonding delegations between a delegator and a validator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -796,27 +796,27 @@ paths: description: Internal Server Error /staking/redelegations: parameters: - - in: query - name: delegator - description: Bech32 AccAddress of Delegator - required: false - type: string - - in: query - name: validator_from - description: Bech32 ValAddress of SrcValidator - required: false - type: string - - in: query - name: validator_to - description: Bech32 ValAddress of DstValidator - required: false - type: string + - in: query + name: delegator + description: Bech32 AccAddress of Delegator + required: false + type: string + - in: query + name: validator_from + description: Bech32 ValAddress of SrcValidator + required: false + type: string + - in: query + name: validator_to + description: Bech32 ValAddress of DstValidator + required: false + type: string get: summary: Get all redelegations (filter by query params) tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -828,41 +828,41 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/redelegations: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string post: summary: Submit a redelegation parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: delegation - description: The password of the account to remove from the KMS - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - delegator_addr: - $ref: "#/definitions/Address" - validator_src_addr: - $ref: "#/definitions/ValidatorAddress" - validator_dst_addr: - $ref: "#/definitions/ValidatorAddress" - shares: - type: string - example: "100" + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: delegation + description: The password of the account to remove from the KMS + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + delegator_addr: + $ref: "#/definitions/Address" + validator_src_addr: + $ref: "#/definitions/ValidatorAddress" + validator_dst_addr: + $ref: "#/definitions/ValidatorAddress" + shares: + type: string + example: "100" tags: - ICS21 consumes: @@ -882,17 +882,17 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/validators: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Query all validators that a delegator is bonded to tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -906,22 +906,22 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/validators/{validatorAddr}: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - - in: path - name: validatorAddr - description: Bech32 ValAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string + - in: path + name: validatorAddr + description: Bech32 ValAddress of Delegator + required: true + type: string get: summary: Query a validator that a delegator is bonded to tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -933,17 +933,17 @@ paths: description: Internal Server Error /staking/delegators/{delegatorAddr}/txs: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Get all staking txs (i.e msgs) from a delegator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -961,9 +961,9 @@ paths: get: summary: Get all validator candidates tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -975,17 +975,17 @@ paths: description: Internal Server Error /staking/validators/{validatorAddr}: parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Query the information from a single validator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -997,17 +997,17 @@ paths: description: Internal Server Error /staking/validators/{validatorAddr}/delegations: parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Get all delegations from a validator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -1021,17 +1021,17 @@ paths: description: Internal Server Error /staking/validators/{validatorAddr}/unbonding_delegations: parameters: - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Get all unbonding delegations from a validator tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -1047,9 +1047,9 @@ paths: get: summary: Get the current state of the staking pool tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -1074,9 +1074,9 @@ paths: get: summary: Get the current staking parameter values tags: - - ICS21 + - ICS21 produces: - - application/json + - application/json responses: 200: description: OK @@ -1104,15 +1104,15 @@ paths: summary: Get sign info of given validator description: Get sign info of given validator produces: - - application/json + - application/json tags: - - ICS23 + - ICS23 parameters: - - type: string - description: Bech32 validator public key - name: validatorPubKey - required: true - in: path + - type: string + description: Bech32 validator public key + name: validatorPubKey + required: true + in: path responses: 200: description: OK @@ -1138,26 +1138,26 @@ paths: summary: Unjail a jailed validator description: Send transaction to unjail a jailed validator consumes: - - application/json + - application/json produces: - - application/json + - application/json tags: - - ICS23 + - ICS23 parameters: - - type: string - description: Bech32 validator address - name: validatorAddr - required: true - in: path - - description: '' - name: UnjailBody - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" + - type: string + description: Bech32 validator address + name: validatorAddr + required: true + in: path + - description: "" + name: UnjailBody + in: body + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" responses: 200: description: OK @@ -1173,9 +1173,9 @@ paths: get: summary: Get the current slashing parameters tags: - - ICS23 + - ICS23 produces: - - application/json + - application/json responses: 200: description: OK @@ -1203,34 +1203,34 @@ paths: summary: Submit a proposal description: Send transaction to submit a proposal consumes: - - application/json + - application/json produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - description: valid value of `"proposal_type"` can be `"text"`, `"parameter_change"`, `"software_upgrade"` - name: post_proposal_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - title: - type: string - description: - type: string - proposal_type: - type: string - example: "text" - proposer: - $ref: "#/definitions/Address" - initial_deposit: - type: array - items: - $ref: "#/definitions/Coin" + - description: valid value of `"proposal_type"` can be `"text"`, `"parameter_change"`, `"software_upgrade"` + name: post_proposal_body + in: body + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + title: + type: string + description: + type: string + proposal_type: + type: string + example: "text" + proposer: + $ref: "#/definitions/Address" + initial_deposit: + type: array + items: + $ref: "#/definitions/Coin" responses: 200: description: OK @@ -1246,25 +1246,25 @@ paths: summary: Query proposals description: Query proposals information with parameters produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - in: query - name: voter - description: voter address - required: false - type: string - - in: query - name: depositor - description: depositor address - required: false - type: string - - in: query - name: status - description: proposal status, valid values can be `"deposit_period"`, `"voting_period"`, `"passed"`, `"rejected"` - required: false - type: string + - in: query + name: voter + description: voter address + required: false + type: string + - in: query + name: depositor + description: depositor address + required: false + type: string + - in: query + name: status + description: proposal status, valid values can be `"deposit_period"`, `"voting_period"`, `"passed"`, `"rejected"` + required: false + type: string responses: 200: description: OK @@ -1281,14 +1281,14 @@ paths: summary: Query a proposal description: Query a proposal by id produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - name: proposalId - required: true - in: path + - type: string + name: proposalId + required: true + in: path responses: 200: description: OK @@ -1303,14 +1303,14 @@ paths: summary: Query proposer description: Query for the proposer for a proposal produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - name: proposalId - required: true - in: path + - type: string + name: proposalId + required: true + in: path responses: 200: description: OK @@ -1325,14 +1325,14 @@ paths: summary: Query deposits description: Query deposits by proposalId produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - name: proposalId - required: true - in: path + - type: string + name: proposalId + required: true + in: path responses: 200: description: OK @@ -1348,32 +1348,32 @@ paths: summary: Deposit tokens to a proposal description: Send transaction to deposit tokens to a proposal consumes: - - application/json + - application/json produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - - description: '' - name: post_deposit_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - depositor: - $ref: "#/definitions/Address" - amount: - type: array - items: - $ref: "#/definitions/Coin" + - type: string + description: proposal id + name: proposalId + required: true + in: path + - description: "" + name: post_deposit_body + in: body + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + depositor: + $ref: "#/definitions/Address" + amount: + type: array + items: + $ref: "#/definitions/Coin" responses: 200: description: OK @@ -1390,20 +1390,20 @@ paths: summary: Query deposit description: Query deposit by proposalId and depositor address produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - - type: string - description: Bech32 depositor address - name: depositor - required: true - in: path + - type: string + description: proposal id + name: proposalId + required: true + in: path + - type: string + description: Bech32 depositor address + name: depositor + required: true + in: path responses: 200: description: OK @@ -1420,15 +1420,15 @@ paths: summary: Query voters description: Query voters information by proposalId produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path + - type: string + description: proposal id + name: proposalId + required: true + in: path responses: 200: description: OK @@ -1444,31 +1444,31 @@ paths: summary: Vote a proposal description: Send transaction to vote a proposal consumes: - - application/json + - application/json produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - - description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"` - name: post_vote_body - in: body - required: true - schema: - type: object - properties: - base_req: - $ref: "#/definitions/BaseReq" - voter: - $ref: "#/definitions/Address" - option: - type: string - example: "yes" + - type: string + description: proposal id + name: proposalId + required: true + in: path + - description: valid value of `"option"` field can be `"yes"`, `"no"`, `"no_with_veto"` and `"abstain"` + name: post_vote_body + in: body + required: true + schema: + type: object + properties: + base_req: + $ref: "#/definitions/BaseReq" + voter: + $ref: "#/definitions/Address" + option: + type: string + example: "yes" responses: 200: description: OK @@ -1485,20 +1485,20 @@ paths: summary: Query vote description: Query vote information by proposal Id and voter address produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path - - type: string - description: Bech32 voter address - name: voter - required: true - in: path + - type: string + description: proposal id + name: proposalId + required: true + in: path + - type: string + description: Bech32 voter address + name: voter + required: true + in: path responses: 200: description: OK @@ -1515,15 +1515,15 @@ paths: summary: Get a proposal's tally result at the current time description: Gets a proposal's tally result at the current time. If the proposal is pending deposits (i.e status 'DepositPeriod') it returns an empty tally result. produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 parameters: - - type: string - description: proposal id - name: proposalId - required: true - in: path + - type: string + description: proposal id + name: proposalId + required: true + in: path responses: 200: description: OK @@ -1538,9 +1538,9 @@ paths: summary: Query governance deposit parameters description: Query governance deposit parameters. The max_deposit_period units are in nanoseconds. produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 responses: 200: description: OK @@ -1565,9 +1565,9 @@ paths: summary: Query governance tally parameters description: Query governance tally parameters produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 responses: 200: description: OK @@ -1593,9 +1593,9 @@ paths: summary: Query governance voting parameters description: Query governance voting parameters. The voting_period units are in nanoseconds. produces: - - application/json + - application/json tags: - - ICS22 + - ICS22 responses: 200: description: OK @@ -1612,18 +1612,18 @@ paths: description: Internal Server Error /distribution/delegators/{delegatorAddr}/rewards: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Get the total rewards balance from all delegations description: Get the sum of all the rewards earned by delegations by a single delegator produces: - - application/json + - application/json tags: - - ICS24 + - ICS24 responses: 200: description: OK @@ -1639,28 +1639,28 @@ paths: summary: Withdraw all the delegator's delegation rewards description: Withdraw all the delegator's delegation rewards tags: - - ICS24 + - ICS24 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: Withdraw request body + schema: + properties: + base_req: + $ref: "#/definitions/BaseReq" responses: 200: description: OK @@ -1674,23 +1674,23 @@ paths: description: Internal Server Error /distribution/delegators/{delegatorAddr}/rewards/{validatorAddr}: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - - in: path - name: validatorAddr - description: Bech32 OperatorAddress of validator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string + - in: path + name: validatorAddr + description: Bech32 OperatorAddress of validator + required: true + type: string get: summary: Query a delegation reward description: Query a single delegation reward by a delegator tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1706,28 +1706,28 @@ paths: summary: Withdraw a delegation reward description: Withdraw a delegator's delegation reward from a single validator tags: - - ICS24 + - ICS24 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: Withdraw request body + schema: + properties: + base_req: + $ref: "#/definitions/BaseReq" responses: 200: description: OK @@ -1741,18 +1741,18 @@ paths: description: Internal Server Error /distribution/delegators/{delegatorAddr}/withdraw_address: parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string + - in: path + name: delegatorAddr + description: Bech32 AccAddress of Delegator + required: true + type: string get: summary: Get the rewards withdrawal address description: Get the delegations' rewards withdrawal address. This is the address in which the user will receive the reward funds tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1766,30 +1766,30 @@ paths: summary: Replace the rewards withdrawal address description: Replace the delegations' rewards withdrawal address for a new one. tags: - - ICS24 + - ICS24 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" - withdraw_address: - $ref: "#/definitions/Address" + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: Withdraw request body + schema: + properties: + base_req: + $ref: "#/definitions/BaseReq" + withdraw_address: + $ref: "#/definitions/Address" responses: 200: description: OK @@ -1812,9 +1812,9 @@ paths: summary: Validator distribution information description: Query the distribution information of a single validator tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1835,9 +1835,9 @@ paths: summary: Commission and self-delegation rewards of a single a validator description: Query the commission and self-delegation rewards of a validator. tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1853,28 +1853,28 @@ paths: summary: Withdraw the validator's rewards description: Withdraw the validator's self-delegation and commissions rewards tags: - - ICS24 + - ICS24 consumes: - - application/json + - application/json produces: - - application/json + - application/json parameters: - - in: query - name: simulate - description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it - required: false - type: boolean - - in: query - name: generate_only - description: if true, build an unsigned transaction and write it back - required: false - type: boolean - - in: body - name: Withdraw request body - schema: - properties: - base_req: - $ref: "#/definitions/BaseReq" + - in: query + name: simulate + description: if true, ignore the gas field and perform a simulation of a transaction, but don't broadcast it + required: false + type: boolean + - in: query + name: generate_only + description: if true, build an unsigned transaction and write it back + required: false + type: boolean + - in: body + name: Withdraw request body + schema: + properties: + base_req: + $ref: "#/definitions/BaseReq" responses: 200: description: OK @@ -1890,9 +1890,9 @@ paths: get: summary: Fee distribution parameters tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1910,9 +1910,9 @@ paths: get: summary: Fee distribution pool tags: - - ICS24 + - ICS24 produces: - - application/json + - application/json responses: 200: description: OK @@ -1948,8 +1948,8 @@ definitions: gas_wanted: 10000 info: info tags: - - '' - - '' + - "" + - "" DeliverTxResult: type: object properties: @@ -1977,8 +1977,8 @@ definitions: gas_wanted: 10000 info: info tags: - - '' - - '' + - "" + - "" BroadcastTxCommitResult: type: object properties: @@ -2123,7 +2123,7 @@ definitions: example: 1 time: type: string - example: '2017-12-30T05:53:09.287+01:00' + example: "2017-12-30T05:53:09.287+01:00" num_txs: type: number example: 0 @@ -2186,7 +2186,7 @@ definitions: example: "0" timestamp: type: string - example: '2017-12-30T05:53:09.287+01:00' + example: "2017-12-30T05:53:09.287+01:00" type: type: number example: 2 @@ -2194,7 +2194,7 @@ definitions: $ref: "#/definitions/BlockID" signature: type: string - example: '7uTC74QlknqYWEwg7Vn6M8Om7FuZ0EO4bjvuj6rwH1mTUJrRuMMZvAAqT9VjNgP0RA/TDp6u/92AqrZfXJSpBQ==' + example: "7uTC74QlknqYWEwg7Vn6M8Om7FuZ0EO4bjvuj6rwH1mTUJrRuMMZvAAqT9VjNgP0RA/TDp6u/92AqrZfXJSpBQ==" BlockQuery: type: object properties: @@ -2216,6 +2216,10 @@ definitions: password: type: string example: "12345678" + from: + type: string + example: "cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc" + description: Optional sender address to generate a transaction without signing it (i.e generate_only=true) memo: type: string example: "Sent via Cosmos Voyager 🚀" @@ -2241,6 +2245,7 @@ definitions: generate_only: type: boolean example: false + description: Create a JSON transaction that can be signed client side instead of actually signing and broadcasting simulate: type: boolean example: true @@ -2248,7 +2253,7 @@ definitions: type: object properties: address: - $ref: '#/definitions/ValidatorAddress' + $ref: "#/definitions/ValidatorAddress" pub_key: type: string example: cosmosvalconspub1zcjduepq7sjfglw7ra4mjxpw4ph7dtdhdheh7nz8dfgl6t8u2n5szuuql9mqsrwquu @@ -2272,7 +2277,7 @@ definitions: proposal_status: type: string final_tally_result: - $ref: "#/definitions/TallyResult" + $ref: "#/definitions/TallyResult" submit_time: type: string total_deposit: @@ -2327,7 +2332,7 @@ definitions: type: object properties: operator_address: - $ref: '#/definitions/ValidatorAddress' + $ref: "#/definitions/ValidatorAddress" consensus_pubkey: type: string example: cosmosvalconspub1zcjduepq7sjfglw7ra4mjxpw4ph7dtdhdheh7nz8dfgl6t8u2n5szuuql9mqsrwquu @@ -2352,31 +2357,31 @@ definitions: type: string bond_height: type: string - example: '0' + example: "0" bond_intra_tx_counter: type: integer example: 0 unbonding_height: type: string - example: '0' + example: "0" unbonding_time: type: string - example: '1970-01-01T00:00:00Z' + example: "1970-01-01T00:00:00Z" commission: type: object properties: rate: type: string - example: '0' + example: "0" max_rate: type: string - example: '0' + example: "0" max_change_rate: type: string - example: '0' + example: "0" update_time: type: string - example: '1970-01-01T00:00:00Z' + example: "1970-01-01T00:00:00Z" Delegation: type: object properties: @@ -2430,13 +2435,13 @@ definitions: community_pool: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" val_accum: - $ref: '#/definitions/TotalAccum' + $ref: "#/definitions/TotalAccum" val_pool: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" TotalAccum: type: object properties: @@ -2448,16 +2453,16 @@ definitions: type: object properties: operator_addr: - $ref: '#/definitions/ValidatorAddress' + $ref: "#/definitions/ValidatorAddress" fee_pool_withdrawal_height: type: integer del_accum: - $ref: '#/definitions/TotalAccum' + $ref: "#/definitions/TotalAccum" del_pool: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" val_commission: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" diff --git a/client/lcd/test_helpers.go b/client/lcd/test_helpers.go index 428989ffdd83..974f54fa82eb 100644 --- a/client/lcd/test_helpers.go +++ b/client/lcd/test_helpers.go @@ -647,7 +647,7 @@ func doSign(t *testing.T, port, name, password, chainID string, accnum, sequence payload := authrest.SignBody{ Tx: msg, BaseReq: utils.NewBaseReq( - name, password, "", chainID, "", "", accnum, sequence, nil, false, false, + name, password, sdk.AccAddress{}, "", chainID, "", "", accnum, sequence, nil, false, false, ), } json, err := cdc.MarshalJSON(payload) @@ -703,7 +703,7 @@ func doTransferWithGas(t *testing.T, port, seed, name, memo, password string, ad sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, memo, chainID, gas, + baseReq := utils.NewBaseReq(name, password, addr, memo, chainID, gas, fmt.Sprintf("%f", gasAdjustment), accnum, sequence, fees, generateOnly, simulate, ) @@ -731,12 +731,12 @@ type sendReq struct { // POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doDelegate(t *testing.T, port, name, password string, - delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { + delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins, generateOnly bool) string { acc := getAccount(t, port, delAddr) accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, delAddr, "", chainID, "", "", accnum, sequence, fees, generateOnly, false) msg := msgDelegationsInput{ BaseReq: baseReq, DelegatorAddr: delAddr, @@ -748,11 +748,7 @@ func doDelegate(t *testing.T, port, name, password string, res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/delegations", delAddr.String()), req) require.Equal(t, http.StatusOK, res.StatusCode, body) - var result ctypes.ResultBroadcastTxCommit - err = cdc.UnmarshalJSON([]byte(body), &result) - require.Nil(t, err) - - return result + return body } type msgDelegationsInput struct { @@ -764,13 +760,13 @@ type msgDelegationsInput struct { // POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doBeginUnbonding(t *testing.T, port, name, password string, - delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { + delAddr sdk.AccAddress, valAddr sdk.ValAddress, amount int64, fees sdk.Coins, generateOnly bool) string { acc := getAccount(t, port, delAddr) accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, delAddr, "", chainID, "", "", accnum, sequence, fees, generateOnly, false) msg := msgBeginUnbondingInput{ BaseReq: baseReq, DelegatorAddr: delAddr, @@ -783,11 +779,7 @@ func doBeginUnbonding(t *testing.T, port, name, password string, res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/unbonding_delegations", delAddr), req) require.Equal(t, http.StatusOK, res.StatusCode, body) - var result ctypes.ResultBroadcastTxCommit - err = cdc.UnmarshalJSON([]byte(body), &result) - require.Nil(t, err) - - return result + return body } type msgBeginUnbondingInput struct { @@ -799,14 +791,14 @@ type msgBeginUnbondingInput struct { // POST /staking/delegators/{delegatorAddr}/delegations Submit delegation func doBeginRedelegation(t *testing.T, port, name, password string, - delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount int64, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { + delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, amount int64, fees sdk.Coins, generateOnly bool) string { acc := getAccount(t, port, delAddr) accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, delAddr, "", chainID, "", "", accnum, sequence, fees, generateOnly, false) msg := msgBeginRedelegateInput{ BaseReq: baseReq, @@ -821,11 +813,7 @@ func doBeginRedelegation(t *testing.T, port, name, password string, res, body := Request(t, port, "POST", fmt.Sprintf("/staking/delegators/%s/redelegations", delAddr), req) require.Equal(t, http.StatusOK, res.StatusCode, body) - var result ctypes.ResultBroadcastTxCommit - err = cdc.UnmarshalJSON([]byte(body), &result) - require.Nil(t, err) - - return result + return body } type msgBeginRedelegateInput struct { @@ -1032,7 +1020,7 @@ func doSubmitProposal(t *testing.T, port, seed, name, password string, proposerA accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, sdk.AccAddress{}, "", chainID, "", "", accnum, sequence, fees, false, false) pr := postProposalReq{ Title: "Test", @@ -1128,7 +1116,7 @@ func doDeposit(t *testing.T, port, seed, name, password string, proposerAddr sdk accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, sdk.AccAddress{}, "", chainID, "", "", accnum, sequence, fees, false, false) dr := depositReq{ Depositor: proposerAddr, @@ -1182,7 +1170,7 @@ func doVote(t *testing.T, port, seed, name, password string, proposerAddr sdk.Ac accnum := acc.GetAccountNumber() sequence := acc.GetSequence() chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", accnum, sequence, fees, false, false) + baseReq := utils.NewBaseReq(name, password, sdk.AccAddress{}, "", chainID, "", "", accnum, sequence, fees, false, false) vr := voteReq{ Voter: proposerAddr, @@ -1314,7 +1302,7 @@ func getSigningInfo(t *testing.T, port string, validatorPubKey string) slashing. func doUnjail(t *testing.T, port, seed, name, password string, valAddr sdk.ValAddress, fees sdk.Coins) (resultTx ctypes.ResultBroadcastTxCommit) { chainID := viper.GetString(client.FlagChainID) - baseReq := utils.NewBaseReq(name, password, "", chainID, "", "", 1, 1, fees, false, false) + baseReq := utils.NewBaseReq(name, password, sdk.AccAddress{}, "", chainID, "", "", 1, 1, fees, false, false) ur := unjailReq{ BaseReq: baseReq, diff --git a/client/utils/rest.go b/client/utils/rest.go index 09663291e55b..25f03dfb7200 100644 --- a/client/utils/rest.go +++ b/client/utils/rest.go @@ -101,27 +101,29 @@ func WriteGenerateStdTxResponse(w http.ResponseWriter, cdc *codec.Codec, txBldr // BaseReq defines a structure that can be embedded in other request structures // that all share common "base" fields. type BaseReq struct { - Name string `json:"name"` - Password string `json:"password"` - Memo string `json:"memo"` - ChainID string `json:"chain_id"` - AccountNumber uint64 `json:"account_number"` - Sequence uint64 `json:"sequence"` - Fees sdk.Coins `json:"fees"` - Gas string `json:"gas"` - GasAdjustment string `json:"gas_adjustment"` - GenerateOnly bool `json:"generate_only"` - Simulate bool `json:"simulate"` + Name string `json:"name"` + Password string `json:"password"` + From sdk.AccAddress `json:"from"` // optional for generate only requests + Memo string `json:"memo"` + ChainID string `json:"chain_id"` + AccountNumber uint64 `json:"account_number"` + Sequence uint64 `json:"sequence"` + Fees sdk.Coins `json:"fees"` + Gas string `json:"gas"` + GasAdjustment string `json:"gas_adjustment"` + GenerateOnly bool `json:"generate_only"` + Simulate bool `json:"simulate"` } // NewBaseReq creates a new basic request instance and sanitizes its values func NewBaseReq( - name, password, memo, chainID string, gas, gasAdjustment string, + name, password string, from sdk.AccAddress, memo, chainID string, gas, gasAdjustment string, accNumber, seq uint64, fees sdk.Coins, genOnly, simulate bool) BaseReq { return BaseReq{ Name: strings.TrimSpace(name), Password: password, + From: from, Memo: strings.TrimSpace(memo), ChainID: strings.TrimSpace(chainID), Fees: fees, @@ -137,7 +139,7 @@ func NewBaseReq( // Sanitize performs basic sanitization on a BaseReq object. func (br BaseReq) Sanitize() BaseReq { newBr := NewBaseReq( - br.Name, br.Password, br.Memo, br.ChainID, br.Gas, br.GasAdjustment, + br.Name, br.Password, br.From, br.Memo, br.ChainID, br.Gas, br.GasAdjustment, br.AccountNumber, br.Sequence, br.Fees, br.GenerateOnly, br.Simulate, ) return newBr @@ -160,7 +162,7 @@ func (br BaseReq) ValidateBasic(w http.ResponseWriter) bool { return false } } - if len(br.Name) == 0 { + if !br.GenerateOnly && len(br.Name) == 0 { WriteErrorResponse(w, http.StatusUnauthorized, "name required but not specified") return false } diff --git a/x/bank/client/rest/sendtx.go b/x/bank/client/rest/sendtx.go index d73d7e61e3cb..446c86b69af2 100644 --- a/x/bank/client/rest/sendtx.go +++ b/x/bank/client/rest/sendtx.go @@ -54,13 +54,20 @@ func SendRequestHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context.CLIC return } - info, err := kb.Get(req.BaseReq.Name) - if err != nil { - utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return + var from sdk.AccAddress + if req.BaseReq.GenerateOnly { + from = req.BaseReq.From + } else { + info, err := kb.Get(req.BaseReq.Name) + if err != nil { + utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + from = sdk.AccAddress(info.GetPubKey().Address()) } - msg := client.CreateMsg(sdk.AccAddress(info.GetPubKey().Address()), to, req.Amount) + msg := client.CreateMsg(from, to, req.Amount) utils.CompleteAndBroadcastTxREST(w, r, cliCtx, req.BaseReq, []sdk.Msg{msg}, cdc) } } diff --git a/x/staking/client/rest/tx.go b/x/staking/client/rest/tx.go index 26e7c9ea210c..142dbed5b19d 100644 --- a/x/staking/client/rest/tx.go +++ b/x/staking/client/rest/tx.go @@ -68,13 +68,20 @@ func postDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx context. return } - info, err := kb.Get(req.BaseReq.Name) - if err != nil { - utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) - return + var from sdk.AccAddress + if req.BaseReq.GenerateOnly { + from = req.BaseReq.From + } else { + info, err := kb.Get(req.BaseReq.Name) + if err != nil { + utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + from = sdk.AccAddress(info.GetPubKey().Address()) } - if !bytes.Equal(info.GetPubKey().Address(), req.DelegatorAddr) { + if !bytes.Equal(from.Bytes(), req.DelegatorAddr) { utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own delegator address") return } @@ -105,13 +112,20 @@ func postRedelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx contex return } - info, err := kb.Get(req.BaseReq.Name) - if err != nil { - utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) - return + var from sdk.AccAddress + if req.BaseReq.GenerateOnly { + from = req.BaseReq.From + } else { + info, err := kb.Get(req.BaseReq.Name) + if err != nil { + utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + from = sdk.AccAddress(info.GetPubKey().Address()) } - if !bytes.Equal(info.GetPubKey().Address(), req.DelegatorAddr) { + if !bytes.Equal(from.Bytes(), req.DelegatorAddr) { utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own delegator address") return } @@ -142,13 +156,20 @@ func postUnbondingDelegationsHandlerFn(cdc *codec.Codec, kb keys.Keybase, cliCtx return } - info, err := kb.Get(req.BaseReq.Name) - if err != nil { - utils.WriteErrorResponse(w, http.StatusUnauthorized, err.Error()) - return + var from sdk.AccAddress + if req.BaseReq.GenerateOnly { + from = req.BaseReq.From + } else { + info, err := kb.Get(req.BaseReq.Name) + if err != nil { + utils.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) + return + } + + from = sdk.AccAddress(info.GetPubKey().Address()) } - if !bytes.Equal(info.GetPubKey().Address(), req.DelegatorAddr) { + if !bytes.Equal(from.Bytes(), req.DelegatorAddr) { utils.WriteErrorResponse(w, http.StatusUnauthorized, "Must use own delegator address") return }