Add swagger-ui for ICS0 and ICS20
This commit is contained in:
parent
46e268efe2
commit
6e8b8e47ee
|
@ -11,10 +11,11 @@ tags:
|
||||||
description: Create and sign a send tx
|
description: Create and sign a send tx
|
||||||
- name: version
|
- name: version
|
||||||
description: Information about the app version
|
description: Information about the app version
|
||||||
|
schemes:
|
||||||
|
- https
|
||||||
securityDefinitions:
|
securityDefinitions:
|
||||||
kms:
|
kms:
|
||||||
type: basic
|
type: basic
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
/version:
|
/version:
|
||||||
get:
|
get:
|
||||||
|
@ -48,15 +49,15 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
pub_key:
|
id:
|
||||||
$ref: '#/definitions/PubKey'
|
type: string
|
||||||
moniker:
|
moniker:
|
||||||
type: string
|
type: string
|
||||||
example: 159.89.198.221
|
example: validator-name
|
||||||
network:
|
network:
|
||||||
type: string
|
type: string
|
||||||
example: gaia-2
|
example: gaia-2
|
||||||
remote_addr:
|
channels:
|
||||||
type: string
|
type: string
|
||||||
listen_addr:
|
listen_addr:
|
||||||
type: string
|
type: string
|
||||||
|
@ -90,25 +91,25 @@ paths:
|
||||||
200:
|
200:
|
||||||
description: The latest block
|
description: The latest block
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Block"
|
$ref: "#/definitions/QueryBlock"
|
||||||
/blocks/{height}:
|
/blocks/{height}:
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: height
|
|
||||||
description: Block height
|
|
||||||
required: true
|
|
||||||
type: number
|
|
||||||
get:
|
get:
|
||||||
summary: Get a block at a certain height
|
summary: Get a block at a certain height
|
||||||
tags:
|
tags:
|
||||||
- ICS0
|
- ICS0
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: height
|
||||||
|
description: Block height
|
||||||
|
required: true
|
||||||
|
type: number
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: The block at a specific height
|
description: The block at a specific height
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Block"
|
$ref: "#/definitions/QueryBlock"
|
||||||
404:
|
404:
|
||||||
description: Block at height is not available
|
description: Block at height is not available
|
||||||
/validatorsets/latest:
|
/validatorsets/latest:
|
||||||
|
@ -131,18 +132,18 @@ paths:
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Validator"
|
$ref: "#/definitions/Validator"
|
||||||
/validatorsets/{height}:
|
/validatorsets/{height}:
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: height
|
|
||||||
description: Block height
|
|
||||||
required: true
|
|
||||||
type: number
|
|
||||||
get:
|
get:
|
||||||
summary: Get a validator set a certain height
|
summary: Get a validator set a certain height
|
||||||
tags:
|
tags:
|
||||||
- ICS0
|
- ICS0
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: height
|
||||||
|
description: Block height
|
||||||
|
required: true
|
||||||
|
type: number
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: The validator set at a specific block height
|
description: The validator set at a specific block height
|
||||||
|
@ -158,58 +159,51 @@ paths:
|
||||||
404:
|
404:
|
||||||
description: Block at height not available
|
description: Block at height not available
|
||||||
/txs/{hash}:
|
/txs/{hash}:
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: hash
|
|
||||||
description: Tx hash
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
get:
|
get:
|
||||||
summary: Get a Tx by hash
|
summary: Get a Tx by hash
|
||||||
tags:
|
tags:
|
||||||
- ICS0
|
- ICS0
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- in: path
|
||||||
|
name: hash
|
||||||
|
description: Tx hash
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Tx with the provided hash
|
description: Tx with the provided hash
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/Tx"
|
$ref: "#/definitions/TxQuery"
|
||||||
404:
|
404:
|
||||||
description: Tx not available for provided hash
|
description: Tx not available for provided hash
|
||||||
/txs/search:
|
/txs/search:
|
||||||
parameters:
|
|
||||||
- in: query
|
|
||||||
name: tag
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
example: "coin.sender=EE5F3404034C524501629B56E0DDC38FAD651F04"
|
|
||||||
required: true
|
|
||||||
- in: query
|
|
||||||
name: page
|
|
||||||
description: Pagination page
|
|
||||||
schema:
|
|
||||||
type: number
|
|
||||||
default: 0
|
|
||||||
- in: query
|
|
||||||
name: size
|
|
||||||
description: Pagination size
|
|
||||||
schema:
|
|
||||||
type: number
|
|
||||||
default: 50
|
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
- ICS0
|
- ICS0
|
||||||
summary: Query Tx
|
summary: Query Tx
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: tag
|
||||||
|
type: string
|
||||||
|
description: "transaction tag, for instance: sender=`'cosmos1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc'`"
|
||||||
|
required: true
|
||||||
|
- in: query
|
||||||
|
name: page
|
||||||
|
description: Pagination page
|
||||||
|
type: integer
|
||||||
|
- in: query
|
||||||
|
name: size
|
||||||
|
description: Pagination size
|
||||||
|
type: integer
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: All Tx matching the provided tags
|
description: All Tx matching the provided tags
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
schema:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Tx"
|
$ref: "#/definitions/TxQuery"
|
||||||
404:
|
404:
|
||||||
description: Pagination is out of bounds
|
description: Pagination is out of bounds
|
||||||
/txs:
|
/txs:
|
||||||
|
@ -217,91 +211,107 @@ paths:
|
||||||
tags:
|
tags:
|
||||||
- ICS0
|
- ICS0
|
||||||
summary: broadcast Tx
|
summary: broadcast Tx
|
||||||
|
description: broadcast tx
|
||||||
|
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.
|
||||||
|
required: true
|
||||||
|
schema:
|
||||||
|
$ref: "#/definitions/TendertmintTx"
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Broadcast tx result
|
description: Broadcast tx result
|
||||||
content:
|
/tx/sign:
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Tx"
|
|
||||||
/txs/sign:
|
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- ICS20
|
- ICS20
|
||||||
summary: Sign a Tx
|
summary: Sign a Tx
|
||||||
description: Sign a Tx providing locally stored account and according password
|
description: Sign a Tx providing locally stored account and according password
|
||||||
security:
|
parameters:
|
||||||
- sign: []
|
- in: body
|
||||||
requestBody:
|
name: sendToken
|
||||||
content:
|
description: sign tx
|
||||||
application/json:
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/TxBuild"
|
$ref: "#/definitions/TxSign"
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: The signed Tx
|
description: The signed Tx
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/TxSigned"
|
$ref: "#/definitions/StdTx"
|
||||||
401:
|
401:
|
||||||
description: Account name and/or password where wrong
|
description: Account name and/or password where wrong
|
||||||
/txs/broadcast:
|
/tx/broadcast:
|
||||||
post:
|
post:
|
||||||
tags:
|
tags:
|
||||||
- ICS20
|
- ICS20
|
||||||
summary: Send signed Tx
|
summary: Send signed Tx
|
||||||
requestBody:
|
description: Sign a Tx providing locally stored account and according password
|
||||||
content:
|
consumes:
|
||||||
application/json:
|
- application/json
|
||||||
|
parameters:
|
||||||
|
- in: body
|
||||||
|
name: txBroadcast
|
||||||
|
description: broadcast tx
|
||||||
|
required: true
|
||||||
schema:
|
schema:
|
||||||
$ref: "#/definitions/TxSigned"
|
$ref: "#/definitions/TxBroadcast"
|
||||||
responses:
|
responses:
|
||||||
202:
|
202:
|
||||||
description: Tx was send and will probably be added to the next block
|
description: Tx was send and will probably be added to the next block
|
||||||
400:
|
400:
|
||||||
description: The Tx was malformated
|
description: The Tx was malformated
|
||||||
/bank/balances/{address}:
|
/bank/balances/{address}:
|
||||||
parameters:
|
|
||||||
- in: path
|
|
||||||
name: address
|
|
||||||
description: Account address in bech32 format
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
get:
|
get:
|
||||||
summary: Get the account balances
|
summary: Get the account balances
|
||||||
tags:
|
tags:
|
||||||
- ICS20
|
- ICS20
|
||||||
produces:
|
produces:
|
||||||
- application/json
|
- application/json
|
||||||
responses:
|
|
||||||
200:
|
|
||||||
description: Account balances
|
|
||||||
schema:
|
|
||||||
$ref: "#/definitions/Balance"
|
|
||||||
204:
|
|
||||||
description: There is no data for the requested account. This is not a 404 as the account might exist, just does not hold data.
|
|
||||||
/bank/accounts/{address}/transfers:
|
|
||||||
parameters:
|
parameters:
|
||||||
- in: path
|
- in: path
|
||||||
name: address
|
name: address
|
||||||
description: Account address in bech32 format
|
description: Account address in bech32 format
|
||||||
required: true
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Account balances
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Coin"
|
||||||
|
204:
|
||||||
|
description: There is no data for the requested account. This is not a 404 as the account might exist, just does not hold data.
|
||||||
|
/bank/accounts/{address}/transfers:
|
||||||
post:
|
post:
|
||||||
summary: Send coins (build -> sign -> send)
|
summary: Send coins (build -> sign -> send)
|
||||||
|
description: Send coins (build -> sign -> send)
|
||||||
tags:
|
tags:
|
||||||
- ICS20
|
- ICS20
|
||||||
security:
|
|
||||||
- kms: []
|
|
||||||
consumes:
|
consumes:
|
||||||
- application/json
|
- application/json
|
||||||
parameters:
|
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: string
|
||||||
|
- in: query
|
||||||
|
name: generate_only
|
||||||
|
description: if true, build an unsigned transaction and write it back
|
||||||
|
required: false
|
||||||
|
type: string
|
||||||
|
- in: path
|
||||||
|
name: address
|
||||||
|
description: Account address in bech32 format
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
- in: body
|
- in: body
|
||||||
name: account
|
name: account
|
||||||
description: The password of the account to remove from the KMS
|
description: The password of the account to remove from the KMS
|
||||||
|
required: true
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -312,11 +322,15 @@ paths:
|
||||||
amount:
|
amount:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Coins"
|
$ref: "#/definitions/Coin"
|
||||||
chain_id:
|
chain_id:
|
||||||
type: string
|
type: string
|
||||||
squence:
|
squence:
|
||||||
type: number
|
type: string
|
||||||
|
gas:
|
||||||
|
type: string
|
||||||
|
fee:
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
202:
|
202:
|
||||||
description: Tx was send and will probably be added to the next block
|
description: Tx was send and will probably be added to the next block
|
||||||
|
@ -324,23 +338,46 @@ paths:
|
||||||
description: The Tx was malformated
|
description: The Tx was malformated
|
||||||
|
|
||||||
definitions:
|
definitions:
|
||||||
|
KVPair:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
key:
|
||||||
|
type: string
|
||||||
|
value:
|
||||||
|
type: string
|
||||||
|
Fee:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
gas:
|
||||||
|
type: string
|
||||||
|
amount:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Coin"
|
||||||
|
Msg:
|
||||||
|
type: string
|
||||||
Address:
|
Address:
|
||||||
type: string
|
type: string
|
||||||
description: bech32 encoded addres
|
description: bech32 encoded addres
|
||||||
example: cosmos:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
example: cosmoszgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
||||||
ValidatorAddress:
|
ValidatorAddress:
|
||||||
type: string
|
type: string
|
||||||
description: bech32 encoded addres
|
description: bech32 encoded addres
|
||||||
example: cosmosvaloper:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
example: cosmosvaloper:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
||||||
PubKey:
|
PubKey:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
type:
|
||||||
type: string
|
type: string
|
||||||
description: bech32 encoded public key
|
example: "tendermint/PubKeySecp256k1"
|
||||||
example: cosmospub:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
value:
|
||||||
|
type: string
|
||||||
|
example: "Avz04VhtKJh8ACCVzlI8aTosGy0ikFXKIVHQ3jKMrosH"
|
||||||
ValidatorPubKey:
|
ValidatorPubKey:
|
||||||
type: string
|
type: string
|
||||||
description: bech32 encoded public key
|
description: bech32 encoded public key
|
||||||
example: cosmosvalconspub:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
example: cosmosvalconspub:zgnkwr7eyyv643dllwfpdwensmgdtz89yu73zq
|
||||||
Coins:
|
Coin:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
denom:
|
denom:
|
||||||
|
@ -352,96 +389,90 @@ definitions:
|
||||||
Hash:
|
Hash:
|
||||||
type: string
|
type: string
|
||||||
example: EE5F3404034C524501629B56E0DDC38FAD651F04
|
example: EE5F3404034C524501629B56E0DDC38FAD651F04
|
||||||
Tx:
|
Result:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
type:
|
log:
|
||||||
type: string
|
type: string
|
||||||
enum:
|
gas_wanted:
|
||||||
- stake/delegate
|
|
||||||
data:
|
|
||||||
type: object
|
|
||||||
TxChain:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
type: string
|
type: string
|
||||||
default: chain/tx
|
example: "0"
|
||||||
data:
|
gas_used:
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
chain_id:
|
|
||||||
type: string
|
type: string
|
||||||
example: gaia-2
|
example: "0"
|
||||||
expires_at:
|
tags:
|
||||||
type: number
|
|
||||||
example: 0
|
|
||||||
tx:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
default: nonce
|
|
||||||
data:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
sequence:
|
|
||||||
type: number
|
|
||||||
example: 0
|
|
||||||
signers:
|
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
|
$ref: "#/definitions/KVPair"
|
||||||
|
TxQuery:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
chain:
|
hash:
|
||||||
type: string
|
type: string
|
||||||
example: ''
|
height:
|
||||||
app:
|
type: number
|
||||||
type: string
|
|
||||||
default: sigs
|
|
||||||
addr:
|
|
||||||
$ref: "#/definitions/Address"
|
|
||||||
tx:
|
tx:
|
||||||
$ref: "#/definitions/Tx"
|
$ref: "#/definitions/StdTx"
|
||||||
TxBuild:
|
result:
|
||||||
type: object
|
$ref: "#/definitions/Result"
|
||||||
properties:
|
TendertmintTx:
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
default: sigs/one
|
|
||||||
data:
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
tx:
|
tx:
|
||||||
$ref: "#/definitions/Tx"
|
type: string
|
||||||
|
return:
|
||||||
|
type: string
|
||||||
|
example: block
|
||||||
|
TxBroadcast:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
tx:
|
||||||
|
$ref: "#/definitions/StdTx"
|
||||||
|
TxSign:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
tx:
|
||||||
|
$ref: "#/definitions/StdTx"
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
password:
|
||||||
|
type: string
|
||||||
|
chain_id:
|
||||||
|
type: string
|
||||||
|
account_number:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
sequence:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
append_sig:
|
||||||
|
type: boolean
|
||||||
|
example: true
|
||||||
|
StdTx:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
msg:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: "#/definitions/Msg"
|
||||||
|
fee:
|
||||||
|
$ref: "#/definitions/Fee"
|
||||||
|
memo:
|
||||||
|
type: string
|
||||||
signature:
|
signature:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
Sig:
|
|
||||||
type: string
|
|
||||||
default: ''
|
|
||||||
Pubkey:
|
|
||||||
type: string
|
|
||||||
default: ''
|
|
||||||
TxSigned:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
type:
|
|
||||||
type: string
|
|
||||||
default: sigs/one
|
|
||||||
data:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
tx:
|
|
||||||
$ref: "#/definitions/Tx"
|
|
||||||
signature:
|
signature:
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
Sig:
|
|
||||||
type: string
|
type: string
|
||||||
example: 81B11E717789600CC192B26F452A983DF13B985EE75ABD9DD9E68D7BA007A958
|
example: MEUCIQD02fsDPra8MtbRsyB1w7bqTM55Wu138zQbFcWx4+CFyAIge5WNPfKIuvzBZ69MyqHsqD8S1IwiEp+iUb6VSdtlpgY=
|
||||||
Pubkey:
|
pub_key:
|
||||||
$ref: "#/definitions/PubKey"
|
$ref: "#/definitions/PubKey"
|
||||||
|
account_number:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
sequence:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
Account:
|
Account:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -452,20 +483,6 @@ definitions:
|
||||||
$ref: "#/definitions/Address"
|
$ref: "#/definitions/Address"
|
||||||
pub_key:
|
pub_key:
|
||||||
$ref: "#/definitions/PubKey"
|
$ref: "#/definitions/PubKey"
|
||||||
Balance:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
height:
|
|
||||||
type: number
|
|
||||||
example: 123456
|
|
||||||
coins:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: "#/definitions/Coins"
|
|
||||||
credit:
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
type: object
|
|
||||||
BlockID:
|
BlockID:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -479,10 +496,7 @@ definitions:
|
||||||
example: 0
|
example: 0
|
||||||
hash:
|
hash:
|
||||||
$ref: "#/definitions/Hash"
|
$ref: "#/definitions/Hash"
|
||||||
Block:
|
BlockHeader:
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
header:
|
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
chain_id:
|
chain_id:
|
||||||
|
@ -516,23 +530,65 @@ definitions:
|
||||||
$ref: "#/definitions/Hash"
|
$ref: "#/definitions/Hash"
|
||||||
evidence_hash:
|
evidence_hash:
|
||||||
$ref: "#/definitions/Hash"
|
$ref: "#/definitions/Hash"
|
||||||
|
Block:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
header:
|
||||||
|
$ref: "#/definitions/BlockHeader"
|
||||||
txs:
|
txs:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
$ref: "#/definitions/Tx"
|
type: string
|
||||||
evidence:
|
evidence:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: object
|
type: string
|
||||||
last_commit:
|
last_commit:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
blockID:
|
block_id:
|
||||||
$ref: "#/definitions/BlockID"
|
$ref: "#/definitions/BlockID"
|
||||||
precommits:
|
precommits:
|
||||||
type: array
|
type: array
|
||||||
items:
|
items:
|
||||||
type: object
|
type: object
|
||||||
|
properties:
|
||||||
|
validator_address:
|
||||||
|
type: string
|
||||||
|
validator_index:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
height:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
round:
|
||||||
|
type: string
|
||||||
|
example: "0"
|
||||||
|
timestamp:
|
||||||
|
type: string
|
||||||
|
example: '2017-12-30T05:53:09.287+01:00'
|
||||||
|
type:
|
||||||
|
type: number
|
||||||
|
example: 2
|
||||||
|
block_id:
|
||||||
|
$ref: "#/definitions/BlockID"
|
||||||
|
signature:
|
||||||
|
type: string
|
||||||
|
example: '7uTC74QlknqYWEwg7Vn6M8Om7FuZ0EO4bjvuj6rwH1mTUJrRuMMZvAAqT9VjNgP0RA/TDp6u/92AqrZfXJSpBQ=='
|
||||||
|
BlockMeta:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
header:
|
||||||
|
$ref: "#/definitions/BlockHeader"
|
||||||
|
block_id:
|
||||||
|
$ref: "#/definitions/BlockID"
|
||||||
|
QueryBlock:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
block_meta:
|
||||||
|
$ref: "#/definitions/BlockMeta"
|
||||||
|
block:
|
||||||
|
$ref: "#/definitions/Block"
|
||||||
Validator:
|
Validator:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
|
@ -546,5 +602,3 @@ definitions:
|
||||||
accum:
|
accum:
|
||||||
type: number
|
type: number
|
||||||
example: 1000
|
example: 1000
|
||||||
schemes:
|
|
||||||
- https
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ const (
|
||||||
|
|
||||||
// BroadcastBody Tx Broadcast Body
|
// BroadcastBody Tx Broadcast Body
|
||||||
type BroadcastBody struct {
|
type BroadcastBody struct {
|
||||||
TxBytes string `json:"tx"`
|
TxBytes []byte `json:"tx"`
|
||||||
Return string `json:"return"`
|
Return string `json:"return"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ func BroadcastTxRequest(cliCtx context.CLIContext, cdc *codec.Codec) http.Handle
|
||||||
var output []byte
|
var output []byte
|
||||||
switch m.Return {
|
switch m.Return {
|
||||||
case flagBlock:
|
case flagBlock:
|
||||||
res, err := cliCtx.BroadcastTx([]byte(m.TxBytes))
|
res, err := cliCtx.BroadcastTx(m.TxBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -53,7 +53,7 @@ func BroadcastTxRequest(cliCtx context.CLIContext, cdc *codec.Codec) http.Handle
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case flagSync:
|
case flagSync:
|
||||||
res, err := cliCtx.BroadcastTxSync([]byte(m.TxBytes))
|
res, err := cliCtx.BroadcastTxSync(m.TxBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -64,7 +64,7 @@ func BroadcastTxRequest(cliCtx context.CLIContext, cdc *codec.Codec) http.Handle
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
case flagAsync:
|
case flagAsync:
|
||||||
res, err := cliCtx.BroadcastTxAsync([]byte(m.TxBytes))
|
res, err := cliCtx.BroadcastTxAsync(m.TxBytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
return
|
return
|
||||||
|
|
|
@ -20,6 +20,10 @@ func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, cdc *codec.Codec,
|
||||||
"/accounts/{address}",
|
"/accounts/{address}",
|
||||||
QueryAccountRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx),
|
QueryAccountRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx),
|
||||||
).Methods("GET")
|
).Methods("GET")
|
||||||
|
r.HandleFunc(
|
||||||
|
"/bank/balances/{address}",
|
||||||
|
QueryBalancesRequestHandlerFn(storeName, cdc, authcmd.GetAccountDecoder(cdc), cliCtx),
|
||||||
|
).Methods("GET")
|
||||||
r.HandleFunc(
|
r.HandleFunc(
|
||||||
"/tx/sign",
|
"/tx/sign",
|
||||||
SignTxRequestHandlerFn(cdc, cliCtx),
|
SignTxRequestHandlerFn(cdc, cliCtx),
|
||||||
|
@ -70,3 +74,48 @@ func QueryAccountRequestHandlerFn(
|
||||||
w.Write(output)
|
w.Write(output)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// query accountREST Handler
|
||||||
|
func QueryBalancesRequestHandlerFn(
|
||||||
|
storeName string, cdc *codec.Codec,
|
||||||
|
decoder auth.AccountDecoder, cliCtx context.CLIContext,
|
||||||
|
) http.HandlerFunc {
|
||||||
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
bech32addr := vars["address"]
|
||||||
|
|
||||||
|
addr, err := sdk.AccAddressFromBech32(bech32addr)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
res, err := cliCtx.QueryStore(auth.AddressStoreKey(addr), storeName)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't query account. Error: %s", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// the query will return empty if there is no data for this account
|
||||||
|
if len(res) == 0 {
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// decode the value
|
||||||
|
account, err := decoder(res)
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't parse query result. Result: %s. Error: %s", res, err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// print out whole account
|
||||||
|
output, err := cdc.MarshalJSON(account.GetCoins())
|
||||||
|
if err != nil {
|
||||||
|
utils.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("couldn't marshall query result. Error: %s", err.Error()))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(output)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue