From fd39cea7a5509c5c79cb92b088392db9f1ab6a93 Mon Sep 17 00:00:00 2001 From: JM Date: Wed, 1 Apr 2020 13:17:02 -0400 Subject: [PATCH] CDP rest api automating testing (#401) * adding script to start the chain * fixed val rewards test * fix outstanding rewards test * fixed rewards * hooks skeleton * adding test file and hooks * Add Savings Rate (#365) * fix: ensure cdp module accounts created at gensis * feat: add savings rate * chore: update alias * fix: update default test param values * chore: update spec for savings rate * fix: add distribution time to genesis state * fix: iterate over accounts using callback function * feat: use seprate mod account for savings rate * fix: remove mod account coins from total supply * address review comments * fix: genesis function initialization * fix: update alias * add comment about maintaining module account list * feat: add genesis example * R4R: bep3 module upgrades (#388) * bep3 module scaffold from cosmos/scaffold * Populated types, keeper with HTLT msgs, module params, and scaffolding for keys, and genesis * added KavaHTLT struct, UpdateHTLT struct, resolved compilation errors * refactored kavaHTLT struct <-> msgs * Implemented params, refactored UpdateKavaHTLT to UpdateKHTLT interface * Updated keeper with byTimeIndex methods * HTLT creation flow * adjustments in prep for repo config updates * App moudle updated for bep3, MsgCreateHTLT tested, HTLT keeper methods tested * Updated bep3 params to match spec * tests for MsgRefundHTLT, MsgDepositHTLT, MsgClaimHTLT * AddHtlt cli cmd, queryHtlts cmd, added conversion funcs for binance -> cosmos types, refactored MsgCreateHTLT from binance.AccAddress to sdk.AccAddress * working edits related to bep3-deputy compatibility * removed binance-chain go sdk dependency * updated msg ValidateBasic() return to sdk.Error type * implement MsgCalculateSwapID * added MsgCalculateSwapID test, updated randomNumberHash type to []byte * removed binance type conversions * msg codec registration * clean /types directory * CLI cmds:create htlt, query htlt * update keeper logic * handle MsgCreateHTLT * implement htlt type, msg types * implement global chain types * update querier * added go-ethereum to go mod * refactor QuerySwap to QueryHTLT * update HTLTMsg to MsgCreateHTLT * implemented htlt deposit * add token transfer to MsgCreateHTLT * implement refund, claim client txs * add refund/claim cmds to tx cmd * commiting go.sum for build * implemented keeper claim logic * add RandomNumberHash to create-htlt event * implement refund keeper logic * AddHTLT updated to CreateHTLT * added params keeper * updated params to single chain, added sample genesis file * implemented htlt keeper param checks * removed go-ethereum dependency * updated go.sum * housekeeping on keeper tests * updated cli tx cmds * ran go.tidy * remove links from module readme * updated coin construction in tests * added expectedIncome checks in ValidateBasic() * made ValidateAsset() more robust * update param format for tests * added basic HTLTByTime index * implement abci, fix expectedIncome validation * byTime index updated to blocks, added swap ID & expiration block to htlt * added not-expired check to HTLT claims * cross-chain mint/burn logic, htlt string type refactored to []byte * fix bnb_deputy_address param * remove abci panic * cmn.HexBytes, byTime index iteration update, claim-mint logic update * update genesis example * general codebase cleaning * renamed HTLT to AtomicSwap * staging for PR * updated naming conventions * refactor + revisions * removed code related to deposits & swap block index * added timestamp validation comment * post-refactor housekeeping * post refactor housekeeping (keeper) * remove GenesisAtomicSwap type * refactor asset supply logic * BeginBlocker expires swaps automatically * param asset.limit type updated to sdk.Int * remove claimed swaps from block index * fix DefaultDeputyAddress * removed BaseSwap * revisions * total genesis coins * updated tx examples * timestamp to unix * add past timestamp limit * update random number byte encoding * add recipient_other_chain to AtomicSwap * add TODO for timestamp arg parsing * generate secure random numbers * update tx cli * keeper tests * add bnb token * bep3 params test set up, test CreateAtomicSwap * swap table tests * Revert "bep3 params test set up, test CreateAtomicSwap" This reverts commits containing tests. * use tmtime.Now() * updates on the hooks working * now creates a transaction and sends to the chain via rest api successfully * small fix - now works * 34 tests now passing successfully * Kava distribution module (#387) * wip: kavadist module structure * feat: implement minting logic * wip: sketch module * wip: module level code * wip: bug fixes * wip: add tests * wip: resolve todos and tidy * fix: remove unused file * address review comments * fix print statement error * instructions on how to run the tests * changing function names when to run the hooks * adding instructions on how to setup and run the dredd tests * removing large error output file * removing binary file * removing more output logging files * creating a vote on a proposal to send to the blockchain * adding instructions on how to setup chain * adding function to get account number and sequence number * adding send msg to blockchain method * posting vote tx to blockchain - successfully prepares and sends vote to endpoint but endpoint returns 'inactive proposal with id' * successfully depositing 600 stake to a proposal * successfully depositing onto a proposal and then voting on it * got another governance test working now after submitting a vote to the blockchain * updating instructions on how to run * fixed another voting test * fixed deposits test * fixed another gov test * fix print line * fix circle ci build issue with println * improving instructions on how to build and run the hooks and dredd tests * improving instructions on how to build and run the hooks and dredd tests * finally fixed param change governance proposal test * trying to unskip tests wip * fixed gov/proposals test * fixed another test * fixed a slashing test * fixed another redelegation test * fixed another unbonding delegation test * fixed more staking tests * fixed another staking test * fixed another test * fixed more tests. 50 now passing, 15 failing * fix: update genesis for guide (#394) * fixed mislabeled variable * managed to fix unjail test * fixed bank acct transfers test * add kava_dist to sample genesis file (#396) * change certain types from number to string to match the output, typo fix * another typo fix * fixed delegation test * finally figured out and fixed the latest blocks types mismatch - fixed the test * fixed staking delegators validators test * removed and noted unimplemented tests from yaml file. fixed blocks height test * fixed transcations test * adding functionality to send transfer of coins to blockchain, and to send delegations * updating the yaml to line up with a valid message format * added delegation method * adding test results showing 57 are now passing and only 5 failing * remove test yaml file from pull req * testing file updates * adding test memo * added undelegation hook method - fixed unbonding delegation test * fixed the get tx from hash test * adding not if you encounter validator set is different errors how to fix. 59 tests now passsing, 3 failing * adding test results showing 59 passing, 3 failing * finally fixed encode test - 60 tests now passing only 2 failing * adding test results 60 passing 1 failing * more test updates * finally fixed decode test - 61 tests now passing only 1 failing * test results 61 tests passing 1 failing * remove dead code * all 62 tests are now passingga swagger.yaml 0 failing * used for testing and generating transactions and testing hooks * updating run instructions * more instructions updates * updating the test file * adding note on reading from a file * refactoring code and cleanup * refactoring getting the keybase * code cleanup for address, keyname methods, remove unused code * more code cleanup around addresses * updating the instructions on how to run the dredd tests * adding comment * R4R: BEP3 module test suite (#395) * refactor secure rng * refactor common tests, implement keeper tests * implement asset tests * implement params, querier tests * implement keeper swap tests * refactor import naming conventions * implement core types tests * improve keeper swap tests * implement genesis types test * implement params test + revisions * implement duplicate swap test * implement duplicate swap ID test * adding additional requirements to the go.mod dependency file * remove hardcoded home directory, read using os golang library * increase timeout in example run script * remove hardcoded home directory * reordering commands to get rid of errors if key directory is deleted * changing to use temporary directory * updating dredd timeout time * finally managed to get the script wroking using a temporary directory instead of the default * adding notes and comments * changing to use a temp directory instead of default directory * remove un-needed file * rename debugging tools folder * adding instructions to install dredd and npm * Update swagger-ui/startchain.sh Send output to dev null not to console Co-Authored-By: Kevin Davis * Update swagger-ui/startchain.sh Send output to dev null not to console Co-Authored-By: Kevin Davis * adding new version of test.go to setup the chain * adding todo to update instructions for new workflow * updating script to start and setup the chain * updating the transaction hash test * update the start chain script to setup the chain correctly * add the script to stop the chain and the rest server * updated the instructions for the new workflow so that all the tests pass the first time * updated the instructions on how to run the tests * update instructions for printing logs or not * updating the startchain script to add messages when starting the rest server and preparing transactions * adding print messages when stop chain is completed * updating test results to just include test output and not the debug log statements * cleaning up the messages that are printed to the user * moving files to their own directory * build go test file and remove previous binary * move instructions * updating instructions now that test file is auto built * building, running dredd tests, propagating error code, shut down blockchain all in one script * fix object type to array type for block latests * cleaning up the script * rename script as it now does all the setup, test running, shutdown, and cleanup * update instructions for new workflow * adding a shell script to call from the makefile * adding a make command to build and run all the dredd tests * update instructions to run using make * updated code review comment * minor update to instructions * update remove file command so doesn't print an error if the file has already been deleted * renaming folder and test * adjust code comment * removing example test results * updating instructions to remove reference to the test results * remove old hooks file * remove obsolete code comment * remove swagger file, will change references to the other one * remove shell script, will now use the one called from make instead * renaming as underscore messes up go build * clean up script, fix return code issues * cleanup output file * fix object to array issue * add comments to explain functionality * use variables for kvd home and kvcli home, check for errors * change the kvcli home directory. need to take this from command line * take kvcli from command line parameter to golang file * take kvcli directory from command line parameter * do not shut down the blockchain, use new swagger file * initial fixes to get yaml to pass the dredd validator * first test results - 19 passing, 66 failing * R4R: BEP3 additional features + module test suite (#397) * update and reorder errors * implement swap deletion block delay * add swap deletion block delay, set up tests * add secure random number gen * implement AtomicSwapLongtermStorage index * fix syntax error * abci test updates * implement handler test * implement core genesis tests * update asset supply logic * implement functional asset supply * pretty print atomic swaps * requested revisions * fix test suite post merge * implement and integrate asset supply tests * update import genesis, add storage duration param * implement swap deletion ABCI test * go mod tidy * remove duplicated interface assertion * add new bep3 param to contrib genesis file * remove btc from supported assets * revisions: LongtermStorageDuration param * revisions: suite ctx, fix genesis, update contrib * implement AssetSupply type, store key, keeper * integrate supply and swaps; genesis, tests * remove legacy comments * requested revisions * update alias * Swagger Rest Automating Testing With Dredd (#390) * swagger testing and mods * fixed a test * fixed withdraw address * adding script to start the chain * fixed val rewards test * fix outstanding rewards test * fixed rewards * hooks skeleton * adding test file and hooks * updates on the hooks working * now creates a transaction and sends to the chain via rest api successfully * small fix - now works * 34 tests now passing successfully * fix print statement error * instructions on how to run the tests * changing function names when to run the hooks * adding instructions on how to setup and run the dredd tests * removing large error output file * removing binary file * removing more output logging files * creating a vote on a proposal to send to the blockchain * adding instructions on how to setup chain * adding function to get account number and sequence number * adding send msg to blockchain method * posting vote tx to blockchain - successfully prepares and sends vote to endpoint but endpoint returns 'inactive proposal with id' * successfully depositing 600 stake to a proposal * successfully depositing onto a proposal and then voting on it * got another governance test working now after submitting a vote to the blockchain * updating instructions on how to run * fixed another voting test * fixed deposits test * fixed another gov test * fix print line * fix circle ci build issue with println * improving instructions on how to build and run the hooks and dredd tests * improving instructions on how to build and run the hooks and dredd tests * finally fixed param change governance proposal test * trying to unskip tests wip * fixed gov/proposals test * fixed another test * fixed a slashing test * fixed another redelegation test * fixed another unbonding delegation test * fixed more staking tests * fixed another staking test * fixed another test * fixed more tests. 50 now passing, 15 failing * fixed mislabeled variable * managed to fix unjail test * fixed bank acct transfers test * change certain types from number to string to match the output, typo fix * another typo fix * fixed delegation test * finally figured out and fixed the latest blocks types mismatch - fixed the test * fixed staking delegators validators test * removed and noted unimplemented tests from yaml file. fixed blocks height test * fixed transcations test * adding functionality to send transfer of coins to blockchain, and to send delegations * updating the yaml to line up with a valid message format * added delegation method * adding test results showing 57 are now passing and only 5 failing * remove test yaml file from pull req * testing file updates * adding test memo * added undelegation hook method - fixed unbonding delegation test * fixed the get tx from hash test * adding not if you encounter validator set is different errors how to fix. 59 tests now passsing, 3 failing * adding test results showing 59 passing, 3 failing * finally fixed encode test - 60 tests now passing only 2 failing * adding test results 60 passing 1 failing * more test updates * finally fixed decode test - 61 tests now passing only 1 failing * test results 61 tests passing 1 failing * remove dead code * all 62 tests are now passingga swagger.yaml 0 failing * used for testing and generating transactions and testing hooks * updating run instructions * more instructions updates * updating the test file * adding note on reading from a file * refactoring code and cleanup * refactoring getting the keybase * code cleanup for address, keyname methods, remove unused code * more code cleanup around addresses * updating the instructions on how to run the dredd tests * adding comment * adding additional requirements to the go.mod dependency file * remove hardcoded home directory, read using os golang library * increase timeout in example run script * remove hardcoded home directory * reordering commands to get rid of errors if key directory is deleted * changing to use temporary directory * updating dredd timeout time * finally managed to get the script wroking using a temporary directory instead of the default * adding notes and comments * changing to use a temp directory instead of default directory * remove un-needed file * rename debugging tools folder * adding instructions to install dredd and npm * Update swagger-ui/startchain.sh Send output to dev null not to console Co-Authored-By: Kevin Davis * Update swagger-ui/startchain.sh Send output to dev null not to console Co-Authored-By: Kevin Davis * adding new version of test.go to setup the chain * adding todo to update instructions for new workflow * updating script to start and setup the chain * updating the transaction hash test * update the start chain script to setup the chain correctly * add the script to stop the chain and the rest server * updated the instructions for the new workflow so that all the tests pass the first time * updated the instructions on how to run the tests * update instructions for printing logs or not * updating the startchain script to add messages when starting the rest server and preparing transactions * adding print messages when stop chain is completed * updating test results to just include test output and not the debug log statements * cleaning up the messages that are printed to the user * moving files to their own directory * build go test file and remove previous binary * move instructions * updating instructions now that test file is auto built * building, running dredd tests, propagating error code, shut down blockchain all in one script * fix object type to array type for block latests * cleaning up the script * rename script as it now does all the setup, test running, shutdown, and cleanup * update instructions for new workflow * adding a shell script to call from the makefile * adding a make command to build and run all the dredd tests * update instructions to run using make * updated code review comment * minor update to instructions * update remove file command so doesn't print an error if the file has already been deleted * renaming folder and test * adjust code comment * removing example test results * updating instructions to remove reference to the test results * remove old hooks file * remove obsolete code comment * remove swagger file, will change references to the other one * remove shell script, will now use the one called from make instead * renaming as underscore messes up go build * clean up script, fix return code issues * cleanup output file * fix object to array issue * add comments to explain functionality * use variables for kvd home and kvcli home, check for errors * change the kvcli home directory. need to take this from command line * take kvcli from command line parameter to golang file * take kvcli directory from command line parameter Co-authored-by: John Maheswaran Co-authored-by: Kevin Davis * remove test results * fix merge conflict * fix more merge conflicts * keeping track of number of passing tests, currently 19 passing, 66 failing * fix /supply/total test * fix /minting/annual-provisions test * fix inflation test * fix community pool test * fix distribution test * fix another validator operator test * fix two more tests * fix a rewards test * fix outstanding rewards test * fixed ~7 more tests * fixed another test * fixed another test * fixed another test * fixed bech32 encoding issue and two more tests * fixed another address issue test * fixed another test * fixed two more tests * another test fix * fix param change test * fix gov proposal test * fixed another gov issue * fixed unjail test * fixed slashing test * fixed another few tests * another fix * another fix * another fix * another fix * several more fixes * another test fixed... * more fixes * another fix, 61 now passing, 21 failing * another fix * multiple more fixes * another fix... * 70 tests now passing, 12 failing. Failing tests are CDPs, auction, and pricefeed tests * R4R: Update BEP3 rest endpoints + format example requests (#402) * update and reorder errors * implement swap deletion block delay * add swap deletion block delay, set up tests * add secure random number gen * implement AtomicSwapLongtermStorage index * fix syntax error * abci test updates * implement handler test * implement core genesis tests * update asset supply logic * implement functional asset supply * pretty print atomic swaps * requested revisions * fix test suite post merge * implement and integrate asset supply tests * update import genesis, add storage duration param * implement swap deletion ABCI test * go mod tidy * remove duplicated interface assertion * add new bep3 param to contrib genesis file * remove btc from supported assets * revisions: LongtermStorageDuration param * revisions: suite ctx, fix genesis, update contrib * implement AssetSupply type, store key, keeper * integrate supply and swaps; genesis, tests * remove legacy comments * requested revisions * update alias * rest queries * implement BEP3 REST txs * draft rest server readme + example json files * tested all swap rest examples * implement query swaps rest endpoint * use the cdp and pricefeed genesis file * changes to several addresses and denominations in several tests * adding script to start without rebuilding the genesis file * comment out file copy that was causing script to fail * fix a pricefeed test * adding a new test genesis file for use in the dredd tests * fixed another pricefeed test * fixed oracle test * fixed pricefeed markets * fixed oracles issue * fixed two cdp tests * feat: update genesis examples * fix: use post instead of put (#405) * finally fixed a timestamp format issue for put pricefeed test * update contrib structure (#403) * used for testing * update chain name * adding xrp to vlad in genesis * updaing to set xrp and pricefeed and cdp params in genesis file * changes to create cdp method * some minor changes * finally successfully creating the cdp * all the pure cdp tests are now passing, so overall 79 passing, 3 failing (3 auction tests) * fix to kill the blockchain when done and shutting down * uncomment to run all functions * minor changes * fix on tx test * adding method to update price of xrp to hopefully trigger auction * adding btc to the vlad wallet, keep blockchain running * create btc cdp and update price to trigger auction * fixed an auction test - 80 tests now passing, 2 failing * fix auction bid test, 81 now passing only 1 failing * fixes to the script to setup chain and run all tests * adding code review note * setup and send all messages to blockchain * add note to readme how to run the dredd tests * kill the kava if it is already running * ALL 82 TESTS NOW PASSINGga swagger-ui/testnet-4000/swagger-testnet-4000.yamlga swagger-ui/testnet-4000/swagger-testnet-4000.yaml 0 FAILING * remove unused genesis file as we now create it on the fly from the run all tests script * remove old file * fixed jq issue - 81 tests now passing. one is failing for some reason - taking a look * fixed pricefeed - all 82 tests now passing zero failing * Update README.md Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * remove old file * Update rest_test/run_all_tests_from_make.sh Co-Authored-By: Kevin Davis * fix setup test Co-authored-by: John Maheswaran Co-authored-by: Kevin Davis Co-authored-by: Denali Marsh Co-authored-by: Kevin Davis Co-authored-by: Federico Kunze <31522760+fedekunze@users.noreply.github.com> --- README.md | 2 +- contrib/testnet-4000/README.md | 8 + rest_test/run_all_tests_from_make.sh | 45 +- rest_test/setup/setuptest.go | 135 ++- .../testnet-4000/swagger-testnet-4000.yaml | 884 ++++++++++++------ 5 files changed, 736 insertions(+), 338 deletions(-) diff --git a/README.md b/README.md index 4fc13f33..d481e32b 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ -Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the [comsos-sdk](https://github.com/cosmos/cosmos-sdk). +Reference implementation of Kava, a blockchain for cross-chain DeFi. Built using the [cosmos-sdk](https://github.com/cosmos/cosmos-sdk). ## Mainnet diff --git a/contrib/testnet-4000/README.md b/contrib/testnet-4000/README.md index ce377e67..b1e45544 100644 --- a/contrib/testnet-4000/README.md +++ b/contrib/testnet-4000/README.md @@ -60,3 +60,11 @@ Congratulations, you've just posted a current market price on Kava using the res ## Governance proposals Example governance proposals are located in `/proposal_examples`. + +## Dredd automated REST API testing + +To run the dredd tests to hit the endpoints and test the api run the following command from the `kava` folder: + +```bash + make test_dredd +``` \ No newline at end of file diff --git a/rest_test/run_all_tests_from_make.sh b/rest_test/run_all_tests_from_make.sh index 1b0ca862..d1e01f50 100755 --- a/rest_test/run_all_tests_from_make.sh +++ b/rest_test/run_all_tests_from_make.sh @@ -1,40 +1,37 @@ #! /bin/bash + +# kill kava if it is already running +pgrep kvd | xargs kill +pgrep kvcli | xargs kill + # TODO import from development environment in envkey password="password" validatorMnemonic="equip town gesture square tomorrow volume nephew minute witness beef rich gadget actress egg sing secret pole winter alarm law today check violin uncover" - # address: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c # address: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 - faucet="chief access utility giant burger winner jar false naive mobile often perfect advice village love enroll embark bacon under flock harbor render father since" - # address: kava1ls82zzghsx0exkpr52m8vht5jqs3un0ceysshz # address: kavavaloper1ls82zzghsx0exkpr52m8vht5jqs3un0c5j2c04 - # variables for home directories for kvd and kvcli kvdHome=/tmp/kvdHome kvcliHome=/tmp/kvcliHome - +genesis=$kvdHome/config/genesis.json +swaggerFile=swagger-ui/testnet-4000/swagger-testnet-4000.yaml # Remove any existing data directory rm -rf $kvdHome rm -rf $kvcliHome - # make the directories mkdir /tmp/kvdHome mkdir /tmp/kvcliHome - # create validator key printf "$password\n$validatorMnemonic\n" | kvcli keys add vlad --recover --home $kvcliHome # create faucet key printf "$password\n$faucet\n" | kvcli --home $kvcliHome keys add faucet --recover --home $kvcliHome - # function used to show that it is still loading showLoading() { mypid=$! loadingText=$1 - echo -ne "$loadingText\r" - while kill -0 $mypid 2>/dev/null; do echo -ne "$loadingText.\r" sleep 0.5 @@ -46,32 +43,33 @@ showLoading() { echo -ne "$loadingText\r" sleep 0.5 done - echo "$loadingText...finished" } - # Create new data directory { kvd --home $kvdHome init --chain-id=testing vlad # doesn't need to be the same as the validator } > /dev/null 2>&1 kvcli --home $kvcliHome config chain-id testing # or set trust-node true - # add validator account to genesis -kvd --home $kvdHome add-genesis-account $(kvcli --home $kvcliHome keys show vlad -a) 10000000000000stake +kvd --home $kvdHome add-genesis-account $(kvcli --home $kvcliHome keys show vlad -a) 10000000000000stake,1000000000000xrp,100000000000btc # add faucet account to genesis kvd --home $kvdHome add-genesis-account $(kvcli --home $kvcliHome keys show faucet -a) 10000000000000stake,1000000000000xrp,100000000000btc - # Create a delegation tx for the validator and add to genesis printf "$password\n" | kvd --home $kvdHome gentx --name vlad --home-client $kvcliHome { kvd --home $kvdHome collect-gentxs } > /dev/null 2>&1 - +# set blocktime to ~1s +jq '.app_state.mint.params.blocks_per_year = "31540000"' $genesis > $genesis.tmp && mv $genesis.tmp $genesis +# update pricefeed information +jq '.app_state.pricefeed.params.markets += [{"active": true, "base_asset": "xrp", "market_id": "xrp:usd", "oracles": ["kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c"], "quote_asset": "usd"}, {"active": true, "base_asset": "btc", "market_id": "btc:usd", "oracles": ["kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c"], "quote_asset": "usd"}]' $genesis > $genesis.tmp && mv $genesis.tmp $genesis +jq '.app_state.pricefeed.posted_prices += [{"expiry": "2050-01-01T00:00:00Z", "market_id": "btc:usd", "oracle_address": "kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c", "price": "8700.0"}, {"expiry": "2050-01-01T00:00:00Z", "market_id": "xrp:usd", "oracle_address": "kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c", "price": "0.25"}]' $genesis > $genesis.tmp && mv $genesis.tmp $genesis +# now update cdp params +jq '.app_state.cdp.params = { "circuit_breaker": false, "collateral_params": [ { "auction_size": "10000000000", "conversion_factor": "8", "debt_limit": [ { "amount": "1000000000", "denom": "usdx" } ], "denom": "btc", "liquidation_penalty": "0.05", "liquidation_ratio": "1.5", "market_id": "btc:usd", "prefix": 0, "stability_fee": "1.0000000007829977" }, { "auction_size": "100000000", "conversion_factor": "6", "debt_limit": [ { "amount": "10000000", "denom": "usdx" } ], "denom": "xrp", "liquidation_penalty": "0.1", "liquidation_ratio": "2.0", "market_id": "xrp:usd", "prefix": 1, "stability_fee": "1.0000000007829977"} ], "debt_auction_threshold": "9000000", "debt_params": [ { "conversion_factor": "6", "debt_floor": "10000000", "debt_limit": [ { "amount": "2000000000000", "denom": "usdx" } ], "denom": "usdx", "reference_asset": "usd", "savings_rate": "0.95" } ], "global_debt_limit": [ { "amount": "2000000000000", "denom": "usdx" } ], "surplus_auction_threshold": "9000000", "savings_distribution_frequency": "120000000000" }' $genesis > $genesis.tmp && mv $genesis.tmp $genesis # start the blockchain in the background, wait until it starts making blocks { kvd start --home $kvdHome & kvdPid="$!" } > /dev/null 2>&1 - printf "\n" sleep 10 & showLoading "Starting rest server, please wait" # start the rest server. Use ./stopchain.sh to stop both rest server and the blockchain @@ -81,30 +79,24 @@ kvcli rest-server --laddr tcp://127.0.0.1:1317 --chain-id=testing --home $kvcliH printf "\n" sleep 10 & showLoading "Preparing blockchain setup transactions, please wait" printf "\n" - # build the go setup test file rm -f rest_test/setuptest go build rest_test/setup/setuptest.go & showLoading "Building go test file, please wait" - # run the go code to send transactions to the chain and set it up correctly ./setuptest $kvcliHome & showLoading "Sending messages to blockchain" printf "\n" printf "Blockchain setup completed" printf "\n\n" - ############################ # Now run the dredd tests ############################ - -dredd swagger-ui/swagger.yaml localhost:1317 2>&1 | tee output & showLoading "Running dredd tests" - +dredd $swaggerFile localhost:1317 2>&1 | tee output & showLoading "Running dredd tests" ######################################################## -# Now run the check the return code from the dredd command. +# Now run the check the return code from the dredd command. # If 0 then all test passed OK, otherwise some failed and propagate the error ######################################################## - # check that the error code was zero -if [ $? -eq 0 ] +if [ $? -eq 0 ] then # check that all the tests passed (ie zero failing) if [[ $(cat output | grep "0 failing") ]] @@ -122,7 +114,6 @@ then fi fi fi - # otherwise return an error code and redirect stderr to stdout so user sees the error output echo "Failure" >&2 rm setuptest & showLoading "Cleaning up go binary" diff --git a/rest_test/setup/setuptest.go b/rest_test/setup/setuptest.go index 9d66f390..dc52be9f 100644 --- a/rest_test/setup/setuptest.go +++ b/rest_test/setup/setuptest.go @@ -6,6 +6,7 @@ import ( "io/ioutil" "net/http" "os" + "time" "github.com/cosmos/cosmos-sdk/client/keys" crkeys "github.com/cosmos/cosmos-sdk/crypto/keys" @@ -20,7 +21,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/staking" "github.com/kava-labs/kava/app" + "github.com/kava-labs/kava/x/cdp" + "github.com/kava-labs/kava/x/pricefeed" "github.com/tendermint/go-amino" + tmtime "github.com/tendermint/tendermint/types/time" ) func init() { @@ -31,6 +35,14 @@ func init() { } func main() { + if len(os.Args) < 2 { + fmt.Printf("Please include the kvcli home directory as a command line argument\n") + fmt.Printf("For example: ./setuptest /tmp/kvcliHome\n") + fmt.Printf("Exiting...goodbye!\n") + return + } + + // setup messages send to blockchain so it is in the correct state for testing sendProposal() sendDeposit() sendVote() @@ -46,6 +58,122 @@ func main() { sendCoins() + // create an XRP cdp and send to blockchain + sendXrpCdp() + + // create a BTC cdp and send to blockchain + sendBtcCdp() + + // reduce the price of BTC to trigger an auction + sendMsgPostPrice() +} + +// lower the price of xrp to trigger an auction +func sendMsgPostPrice() { + // get the address + address := getTestAddress() + // get the keyname and password + keyname, password := getKeynameAndPassword() + + addr, err := sdk.AccAddressFromBech32(address) // validator address + if err != nil { + panic(err) + } + + price, err := sdk.NewDecFromStr("1") + if err != nil { + panic(err) + } + // set the expiry time + expiry := tmtime.Now().Add(time.Second * 100000) + + // create a cdp message to send to the blockchain + // from, assetcode, price, expiry + msg := pricefeed.NewMsgPostPrice( + addr, + "btc:usd", + price, + expiry, + ) + + // helper methods for transactions + cdc := app.MakeCodec() // make codec for the app + + // get the keybase + keybase := getKeybase() + + // cast to the generic msg type + msgToSend := []sdk.Msg{msg} + + // send the message to the blockchain + sendMsgToBlockchain(cdc, address, keyname, password, msgToSend, keybase) + +} + +func sendBtcCdp() { + // get the address + address := getTestAddress() + // get the keyname and password + keyname, password := getKeynameAndPassword() + + addr, err := sdk.AccAddressFromBech32(address) // validator address + if err != nil { + panic(err) + } + + // create a cdp message to send to the blockchain + // sender, collateral, principal + msg := cdp.NewMsgCreateCDP( + addr, + sdk.NewCoins(sdk.NewInt64Coin("btc", 200000000)), + sdk.NewCoins(sdk.NewInt64Coin("usdx", 10000000)), + ) + + // helper methods for transactions + cdc := app.MakeCodec() // make codec for the app + + // get the keybase + keybase := getKeybase() + + // cast to the generic msg type + msgToSend := []sdk.Msg{msg} + + // send the message to the blockchain + sendMsgToBlockchain(cdc, address, keyname, password, msgToSend, keybase) + +} + +func sendXrpCdp() { + // get the address + address := getTestAddress() + // get the keyname and password + keyname, password := getKeynameAndPassword() + + addr, err := sdk.AccAddressFromBech32(address) // validator address + if err != nil { + panic(err) + } + + // create a cdp message to send to the blockchain + // sender, collateral, principal + msg := cdp.NewMsgCreateCDP( + addr, + sdk.NewCoins(sdk.NewInt64Coin("xrp", 200000000)), + sdk.NewCoins(sdk.NewInt64Coin("usdx", 10000000)), + ) + + // helper methods for transactions + cdc := app.MakeCodec() // make codec for the app + + // get the keybase + keybase := getKeybase() + + // cast to the generic msg type + msgToSend := []sdk.Msg{msg} + + // send the message to the blockchain + sendMsgToBlockchain(cdc, address, keyname, password, msgToSend, keybase) + } func sendProposal() { @@ -274,9 +402,9 @@ func sendMsgToBlockchain(cdc *amino.Codec, address string, keyname string, txBldr := auth.NewTxBuilderFromCLI(). WithTxEncoder(authclient.GetTxEncoder(cdc)).WithChainID("testing"). WithKeybase(keybase).WithAccountNumber(accountNumber). - WithSequence(sequenceNumber) + WithSequence(sequenceNumber).WithGas(500000) - // build and sign the transaction + // build and sign the transaction // this is the *Amino* encoded version of the transaction // fmt.Printf("%+v", txBldr.Keybase()) txBytes, err := txBldr.BuildAndSign("vlad", "password", msg) @@ -296,6 +424,9 @@ func sendMsgToBlockchain(cdc *amino.Codec, address string, keyname string, Mode: "block", }, ) + + fmt.Printf("%s", bytes.NewBuffer(jsonBytes)) + if err != nil { panic(err) } diff --git a/swagger-ui/testnet-4000/swagger-testnet-4000.yaml b/swagger-ui/testnet-4000/swagger-testnet-4000.yaml index 78954f36..bf369a13 100644 --- a/swagger-ui/testnet-4000/swagger-testnet-4000.yaml +++ b/swagger-ui/testnet-4000/swagger-testnet-4000.yaml @@ -237,12 +237,12 @@ description: Tx hash required: true type: string - x-example: BCBE20E8D46758B96AE5883B792858296AC06E51435490FBDCAE25A72B3CC76B + x-example: 4B2C3449FF2647BD51B54C32761FE4EBE7AE024BBE2A9898972A69BEB82D97C2 responses: 200: description: Tx with the provided hash schema: - $ref: '#/definitions/TxQuery' + $ref: "#/definitions/TxQuery" 500: description: Internal Server Error /txs: @@ -258,12 +258,12 @@ name: message.action type: string description: "transaction events such as 'message.action=send' which results in the following endpoint: 'GET /txs?message.action=send'. note that each module documents its own events. look for xx_events.md in the corresponding cosmos-sdk/docs/spec directory" - x-example: 'send' + x-example: "send" - in: query name: message.sender type: string - description: "transaction tags with sender: 'GET /txs?message.action=send&message.sender=kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv'" - x-example: 'kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv' + description: "transaction tags with sender: 'GET /txs?message.action=send&message.sender=kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9'" + x-example: "kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9" - in: query name: page description: Page number @@ -274,11 +274,16 @@ description: Maximum number of items per page type: integer x-example: 1 + - in: query + name: txheight # this should actually be tx.height but dredd doesn't handle periods in get parameter names so no period allows the test to pass + description: Transaction height + type: integer + x-example: 1 responses: 200: description: All txs matching the provided events schema: - $ref: '#/definitions/PaginatedQueryTxs' + $ref: "#/definitions/PaginatedQueryTxs" 400: description: Invalid search events 500: @@ -301,15 +306,15 @@ type: object properties: tx: - $ref: '#/definitions/StdTx' + $ref: "#/definitions/PostStdTx" mode: type: string - example: sync + example: block responses: 200: description: Tx broadcasting result schema: - $ref: '#/definitions/BroadcastTxCommitResult' + $ref: "#/definitions/BroadcastTxCommitResult" 500: description: Internal Server Error /txs/encode: @@ -323,15 +328,13 @@ produces: - application/json parameters: - - in: body - name: tx - description: The tx to encode + - description: "" + name: EncodeBody + in: body required: true schema: type: object - properties: - tx: - $ref: '#/definitions/StdTx' + $ref: "#/definitions/EncodeTx" responses: 200: description: The tx was successfully decoded and re-encoded @@ -342,7 +345,7 @@ type: string example: The base64-encoded Amino-serialized bytes for the tx 400: - description: The tx was malformated + description: The tx was malformatted 500: description: Server internal error /txs/decode: @@ -365,12 +368,12 @@ properties: tx: type: string - example: SvBiXe4KPqijYZoKFFHEzJ8c2HPAfv2EFUcIhx0yPagwEhTy0vPA+GGhCEslKXa4Af0uB+mfShoMCgVzdGFrZRIDMTAwEgQQwJoM + example: ogEoKBapCjyoo2GaChRKWendsRagTF1ACC1nxzjVxW3xJBIU/A6hCReBn5NYI6K2dl10kCEeTfgaCgoFc3Rha2USATESEAoKCgVzdGFrZRIBMRDAmgwaQhJAdlC1HbNw+ux6lRrK3mNdmaH62NE3ThD8SswlDcnhFex7pKSNhaxE4m6TgDhosoK6EyU0LnOZKutXKECNSvO+WCIIdGVzdG1lbW8= responses: 200: description: The tx was successfully decoded schema: - $ref: '#/definitions/StdTx' + $ref: "#/definitions/StdTx" 400: description: The tx was malformated 500: @@ -426,7 +429,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -472,7 +475,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -518,7 +521,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -562,7 +565,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -642,7 +645,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -674,9 +677,15 @@ 200: description: All CDPs with the input collateral denom schema: - type: array - items: - $ref: '#/definitions/CdpResponse' + type: object + properties: + height: + type: string + result: + type: array + x-nullable: true + items: + $ref: '#/definitions/CdpResponse' 500: description: Server internal error /cdp/cdps/ratio/{denom}/{ratio}: @@ -698,14 +707,20 @@ description: Collateralization ratio required: true type: string - x-example: 2.0 + x-example: "2.0" responses: 200: description: All CDPs with the input collateral denom and collateralization ratio less than the input ratio schema: - type: array - items: - $ref: '#/definitions/CdpResponse' + type: object + properties: + height: + type: string + result: + type: array + x-nullable: true + items: + $ref: '#/definitions/CdpResponse' 500: description: Server internal error /cdp/cdps/cdp/deposits/{owner}/{denom}: @@ -721,7 +736,7 @@ description: Owner address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: denom description: Collateral denom @@ -732,9 +747,14 @@ 200: description: Deposits associated with the cdp schema: - type: array - items: - $ref: '#/definitions/CdpDepositResponse' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/CdpDepositResponse' 500: description: Server internal error /auction/auctions/{id}/bids: @@ -752,7 +772,16 @@ description: Auction id required: true type: string - x-example: 1 + x-example: "1" + - in: body + name: Auction bid request body + schema: + properties: + base_req: + $ref: '#/definitions/BaseReq' + amount: + $ref: '#/definitions/CoinBid' + responses: 200: description: The transaction was successfully generated @@ -788,9 +817,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/AuctionResponse' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/AuctionResponse' 500: description: Internal Server Error /auction/auctions/{id}: @@ -807,7 +841,7 @@ description: Auction id required: true type: string - x-example: 2 + x-example: "1" responses: 200: description: OK @@ -818,7 +852,7 @@ 500: description: Internal Server Error /pricefeed/postprice: - put: + post: summary: Generate post price transaction consumes: - application/json @@ -844,7 +878,7 @@ example: '0.298464000000000007' expiry: type: string - example: '2020-02-12T23:20:00Z' + example: '158551630291' responses: 200: description: The transaction was successfully generated @@ -879,9 +913,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Market' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Market' 500: description: Internal Server Error /pricefeed/oracles/{market_id}: @@ -902,9 +941,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Address' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Address' 500: description: Internal Server Error /pricefeed/rawprices/{market_id}: @@ -925,9 +969,15 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/PostedPrice' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/PostedPrice' + 500: description: Internal Server Error /pricefeed/price/{market_id}: @@ -948,7 +998,7 @@ 200: description: OK schema: - $ref: '#/definitions/Prices' + $ref: '#/definitions/Price' 500: description: Internal Server Error /bank/balances/{address}: @@ -964,16 +1014,21 @@ description: Account address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c responses: 200: description: Account balances schema: - type: array - items: - $ref: '#/definitions/Coin' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/Coin" 500: description: Server internal error + /bank/accounts/{address}/transfers: post: summary: Send coins from one account to another @@ -989,7 +1044,7 @@ description: Account address in bech32 format required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 - in: body name: account description: The sender and tx information @@ -998,16 +1053,16 @@ type: object properties: base_req: - $ref: '#/definitions/BaseReq' + $ref: "#/definitions/BaseReq" amount: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" responses: - 202: + 200: description: Tx was successfully generated schema: - $ref: '#/definitions/StdTx' + $ref: "#/definitions/StdTx" 400: description: Invalid request 500: @@ -1025,7 +1080,7 @@ description: Account address required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 responses: 200: description: Account information on the blockchain @@ -1044,13 +1099,13 @@ coins: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" public_key: - $ref: '#/definitions/PublicKey' + $ref: "#/definitions/PublicKey" sequence: type: string 500: - description: Server internel error + description: Server internal error /staking/delegators/{delegatorAddr}/delegations: parameters: - in: path @@ -1058,7 +1113,7 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 get: summary: Get all delegations from a delegator tags: @@ -1069,47 +1124,55 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Delegation' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/Delegation" 400: description: Invalid delegator address 500: description: Internal Server Error - 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_address: - $ref: '#/definitions/Address' - validator_address: - $ref: '#/definitions/ValidatorAddress' - delegation: - $ref: '#/definitions/Coin' - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: '#/definitions/BroadcastTxCommitResult' - 400: - description: Invalid delegator address or delegation request body - 401: - description: Key password is wrong - 500: - description: Internal Server Error + + # THE BELOW ENDPOINT IS NOT IMPLEMENTED IN COSMOS, SEE: + # https://github.com/cosmos/cosmos-sdk/blob/18de630d0ae1887113e266982b51c2bf1f662edb/x/staking/client/rest/query.go + + # 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_address: + # $ref: "#/definitions/Address" + # validator_address: + # $ref: "#/definitions/ValidatorAddress" + # delegation: + # $ref: "#/definitions/Coin" + # tags: + # - Staking + # consumes: + # - application/json + # produces: + # - application/json + # responses: + # 200: + # description: OK + # schema: + # $ref: "#/definitions/BroadcastTxCommitResult" + # 400: + # description: Invalid delegator address or delegation request body + # 401: + # description: Key password is wrong + # 500: + # description: Internal Server Error /staking/delegators/{delegatorAddr}/delegations/{validatorAddr}: parameters: - in: path @@ -1117,13 +1180,13 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: validatorAddr description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Query the current delegation between a delegator and a validator tags: @@ -1134,7 +1197,7 @@ 200: description: OK schema: - $ref: '#/definitions/Delegation' + $ref: "#/definitions/Delegation" 400: description: Invalid delegator address or validator address 500: @@ -1146,7 +1209,7 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 get: summary: Get all unbonding delegations from a delegator tags: @@ -1157,48 +1220,57 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/UnbondingDelegation' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/UnbondingDelegation" + 400: description: Invalid delegator address 500: description: Internal Server Error - post: - summary: Submit an unbonding 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_address: - $ref: '#/definitions/Address' - validator_address: - $ref: '#/definitions/ValidatorAddress' - shares: - type: string - example: '100' - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: OK - schema: - $ref: '#/definitions/BroadcastTxCommitResult' - 400: - description: Invalid delegator address or unbonding delegation request body - 401: - description: Key password is wrong - 500: - description: Internal Server Error + + # THE BELOW ENDPOINT IS NOT IMPLEMENTED IN COSMOS, SEE: + # https://github.com/cosmos/cosmos-sdk/blob/18de630d0ae1887113e266982b51c2bf1f662edb/x/staking/client/rest/query.go + + # post: + # summary: Submit an unbonding 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_address: + # $ref: "#/definitions/Address" + # validator_address: + # $ref: "#/definitions/ValidatorAddress" + # shares: + # type: string + # example: "100" + # tags: + # - Staking + # consumes: + # - application/json + # produces: + # - application/json + # responses: + # 200: + # description: OK + # schema: + # $ref: "#/definitions/BroadcastTxCommitResult" + # 400: + # description: Invalid delegator address or unbonding delegation request body + # 401: + # description: Key password is wrong + # 500: + # description: Internal Server Error /staking/delegators/{delegatorAddr}/unbonding_delegations/{validatorAddr}: parameters: - in: path @@ -1206,13 +1278,13 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: validatorAddr description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Query all unbonding delegations between a delegator and a validator tags: @@ -1223,7 +1295,7 @@ 200: description: OK schema: - $ref: '#/definitions/UnbondingDelegationPair' + $ref: "#/definitions/UnbondingDelegationPair" 400: description: Invalid delegator address or validator address 500: @@ -1254,55 +1326,63 @@ responses: 200: description: OK - schema: - type: array - items: - $ref: '#/definitions/Redelegation' - 500: - description: Internal Server Error - /staking/delegators/{delegatorAddr}/redelegations: - parameters: - - in: path - name: delegatorAddr - description: Bech32 AccAddress of Delegator - required: true - type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv - post: - summary: Submit a redelegation - parameters: - - in: body - name: delegation - description: The sender and tx information schema: type: object properties: - base_req: - $ref: '#/definitions/BaseReq' - delegator_address: - $ref: '#/definitions/Address' - validator_src_addressess: - $ref: '#/definitions/ValidatorAddress' - validator_dst_address: - $ref: '#/definitions/ValidatorAddress' - shares: + height: type: string - example: '100' - tags: - - Staking - consumes: - - application/json - produces: - - application/json - responses: - 200: - description: Tx was successfully generated - schema: - $ref: '#/definitions/StdTx' - 400: - description: Invalid delegator address or redelegation request body + result: + items: + $ref: "#/definitions/Redelegation" 500: description: Internal Server Error + + # THE BELOW ENDPOINT IS NOT IMPLEMENTED IN COSMOS, SEE: + # https://github.com/cosmos/cosmos-sdk/blob/18de630d0ae1887113e266982b51c2bf1f662edb/x/staking/client/rest/query.go + + # /staking/delegators/{delegatorAddr}/redelegations: + # parameters: + # - in: path + # name: delegatorAddr + # description: Bech32 AccAddress of Delegator + # required: true + # type: string + # x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c + # post: + # summary: Submit a redelegation + # parameters: + # - in: body + # name: delegation + # description: The sender and tx information + # schema: + # type: object + # properties: + # base_req: + # $ref: "#/definitions/BaseReq" + # delegator_address: + # $ref: "#/definitions/Address" + # validator_src_addresses: + # $ref: "#/definitions/ValidatorAddress" + # validator_dst_address: + # $ref: "#/definitions/ValidatorAddress" + # shares: + # type: string + # example: "100" + # tags: + # - Staking + # consumes: + # - application/json + # produces: + # - application/json + # responses: + # 200: + # description: Tx was successfully generated + # schema: + # $ref: "#/definitions/StdTx" + # 400: + # description: Invalid delegator address or redelegation request body + # 500: + # description: Internal Server Error /staking/delegators/{delegatorAddr}/validators: parameters: - in: path @@ -1310,7 +1390,7 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 get: summary: Query all validators that a delegator is bonded to tags: @@ -1321,9 +1401,13 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Validator' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/Validator" 400: description: Invalid delegator address 500: @@ -1335,13 +1419,13 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: validatorAddr description: Bech32 ValAddress of Delegator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Query a validator that a delegator is bonded to tags: @@ -1352,7 +1436,7 @@ 200: description: OK schema: - $ref: '#/definitions/Validator' + $ref: "#/definitions/Validator" 400: description: Invalid delegator address or validator address 500: @@ -1384,9 +1468,13 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Validator' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/Validator" 500: description: Internal Server Error /staking/validators/{validatorAddr}: @@ -1396,7 +1484,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Query the information from a single validator tags: @@ -1419,7 +1507,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1q53rwutgpzx7szcrgzqguxyccjpzt9j44jzrtj get: summary: Get all delegations from a validator tags: @@ -1430,9 +1518,13 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Delegation' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/Delegation" 400: description: Invalid validator address 500: @@ -1444,7 +1536,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1q53rwutgpzx7szcrgzqguxyccjpzt9j44jzrtj get: summary: Get all unbonding delegations from a validator tags: @@ -1455,9 +1547,13 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/UnbondingDelegation' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/UnbondingDelegation" 400: description: Invalid validator address 500: @@ -1568,9 +1664,14 @@ 200: description: OK schema: - type: array items: - $ref: '#/definitions/SigningInfo' + type: object + properties: + height: + type: string + result: + items: + $ref: "#/definitions/SigningInfo" 400: description: Invalid validator public key for one of the validators 500: @@ -1591,8 +1692,8 @@ name: validatorAddr required: true in: path - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l - - description: '' + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 + - description: "" name: UnjailBody in: body required: true @@ -1600,12 +1701,12 @@ type: object properties: base_req: - $ref: '#/definitions/StdTx' + $ref: "#/definitions/BaseReq" responses: 200: description: Tx was successfully generated schema: - $ref: '#/definitions/BroadcastTxCommitResult' + $ref: "#/definitions/BroadcastTxCommitResult" 400: description: Invalid validator address or base_req 500: @@ -1658,25 +1759,34 @@ type: object properties: base_req: - $ref: '#/definitions/BaseReq' + $ref: "#/definitions/BaseReq" title: type: string + example: Test_title description: type: string + example: my_test_description proposal_type: type: string - example: 'text' + example: "text" proposer: - $ref: '#/definitions/Address' + $ref: "#/definitions/Address" initial_deposit: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" responses: 200: description: Tx was successfully generated schema: - $ref: '#/definitions/StdTx' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: "#/definitions/TextProposal" 400: description: Invalid proposal body 500: @@ -1706,11 +1816,16 @@ type: string responses: 200: - description: OK + description: Tx was successfully generated schema: - type: array - items: - $ref: '#/definitions/TextProposal' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: "#/definitions/TextProposal" 400: description: Invalid query parameters 500: @@ -1734,23 +1849,23 @@ type: object properties: base_req: - $ref: '#/definitions/BaseReq' + $ref: "#/definitions/BaseReq" title: type: string - x-example: 'Param Change' + example: Param_Change description: type: string - x-example: 'Update max validators' + example: Update_max_validators proposer: - $ref: '#/definitions/Address' + $ref: "#/definitions/Address" deposit: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" changes: type: array items: - $ref: '#/definitions/ParamChange' + $ref: "#/definitions/ParamChange" responses: 200: description: The transaction was successfully generated @@ -1824,9 +1939,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Deposit' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Deposit' 400: description: Invalid proposal id 500: @@ -1887,13 +2007,13 @@ name: proposalId required: true in: path - x-example: '2' + x-example: "2" - type: string description: Bech32 depositor address name: depositor required: true in: path - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c responses: 200: description: OK @@ -1924,9 +2044,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Vote' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Vote' 400: description: Invalid proposal id 500: @@ -1992,7 +2117,7 @@ name: voter required: true in: path - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c responses: 200: description: OK @@ -2112,7 +2237,7 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava167w96tdvmazakdwkw2u57227eduula2cy572lf + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c 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 @@ -2124,7 +2249,12 @@ 200: description: OK schema: - $ref: '#/definitions/DelegatorTotalRewards' + type: object + properties: + height: + type: string + result: + $ref: '#/definitions/DelegatorTotalRewards' 400: description: Invalid delegator address 500: @@ -2163,13 +2293,13 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava16xyempempp92x9hyzz9wrgf94r6j9h5f06pxxv + x-example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c - in: path name: validatorAddr description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Query a delegation reward description: Query a single delegation reward by a delegator @@ -2181,9 +2311,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Coin' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: "#/definitions/Coin" 400: description: Invalid delegator address 500: @@ -2222,7 +2357,7 @@ description: Bech32 AccAddress of Delegator required: true type: string - x-example: kava167w96tdvmazakdwkw2u57227eduula2cy572lf + x-example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 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 @@ -2234,7 +2369,12 @@ 200: description: OK schema: - $ref: '#/definitions/Address' + type: object + properties: + height: + type: string + result: + $ref: "#/definitions/Address" 400: description: Invalid delegator address 500: @@ -2275,7 +2415,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Validator distribution information description: Query the distribution information of a single validator @@ -2299,7 +2439,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Fee distribution outstanding rewards of a single validator tags: @@ -2310,9 +2450,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Coin' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Coin' 500: description: Internal Server Error /distribution/validators/{validatorAddr}/rewards: @@ -2322,7 +2467,7 @@ description: Bech32 OperatorAddress of validator required: true type: string - x-example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + x-example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 get: summary: Commission and self-delegation rewards of a single validator description: Query the commission and self-delegation rewards of validator. @@ -2332,11 +2477,16 @@ - application/json responses: 200: - description: OK + description: OK schema: - type: array - items: - $ref: '#/definitions/Coin' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: '#/definitions/Coin' 400: description: Invalid validator address 500: @@ -2379,9 +2529,14 @@ 200: description: OK schema: - type: array - items: - $ref: '#/definitions/Coin' + type: object + properties: + height: + type: string + result: + type: array + items: + $ref: "#/definitions/Coin" 500: description: Internal Server Error /distribution/parameters: @@ -2441,7 +2596,7 @@ 200: description: OK schema: - type: string + $ref: "#/definitions/StandardResponse" 500: description: Internal Server Error /minting/annual-provisions: @@ -2455,7 +2610,7 @@ 200: description: OK schema: - type: string + $ref: "#/definitions/StandardResponse" 500: description: Internal Server Error /supply/total: @@ -2490,7 +2645,7 @@ 200: description: OK schema: - type: string + $ref: "#/definitions/StandardResponse" 400: description: Invalid coin denomination 500: @@ -2564,7 +2719,7 @@ hash: $ref: '#/definitions/Hash' height: - type: integer + type: string KVPair: type: object properties: @@ -2574,26 +2729,31 @@ type: string Msg: type: object - required: - - from properties: type: type: string - example: 'string' + example: "cosmos-sdk/MsgSend" value: type: object properties: - from: + from_address: type: string - example: kava1mzqz3jfs9nzfp6v7qp647rv0afxlu2csl0txmq + example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c + to_address: + type: string + example: kava1ls82zzghsx0exkpr52m8vht5jqs3un0ceysshz + amount: + type: array + items: + $ref: "#/definitions/Coin" Address: type: string description: bech32 encoded address - example: kava1depk54cuajgkzea6zpgkq36tnjwdzv4afc3d27 + example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c ValidatorAddress: type: string description: bech32 encoded address - example: kavavaloper16xyempempp92x9hyzz9wrgf94r6j9h5f2w4n2l + example: kavavaloper1ffv7nhd3z6sych2qpqkk03ec6hzkmufyz4scd0 Coin: type: object properties: @@ -2608,7 +2768,7 @@ properties: denom: type: string - example: bnb + example: "xrp" amount: type: string example: '10000000000' @@ -2617,10 +2777,19 @@ properties: denom: type: string - example: usdx + example: "usdx" amount: type: string example: '10000000' + CoinBid: + type: object + properties: + denom: + type: string + example: "usdx" + amount: + type: string + example: '100000000' Hash: type: string example: EE5F3404034C524501629B56E0DDC38FAD651F04 @@ -2646,8 +2815,8 @@ type: string example: 'D085138D913993919295FF4B0A9107F1F2CDE0D37A87CE0644E217CBF3B49656' height: - type: number - example: 368 + type: string + example: "368" tx: $ref: '#/definitions/StdTx' result: @@ -2669,20 +2838,20 @@ type: object properties: total_count: - type: number - example: 1 + type: string + example: "1" count: - type: number - example: 1 + type: string + example: "1" page_number: - type: number - example: 1 + type: string + example: "1" page_total: - type: number - example: 1 + type: string + example: "1" limit: - type: number - example: 30 + type: string + example: "30" txs: type: array items: @@ -2693,16 +2862,17 @@ msg: type: array items: - $ref: '#/definitions/Msg' + $ref: "#/definitions/Msg" fee: type: object properties: gas: type: string + example: "200000" amount: type: array items: - $ref: '#/definitions/Coin' + $ref: "#/definitions/Coin" memo: type: string signatures: @@ -2718,8 +2888,8 @@ type: object properties: total: - type: number - example: 0 + type: string + example: "0" hash: $ref: '#/definitions/Hash' BlockHeader: @@ -2727,21 +2897,21 @@ properties: chain_id: type: string - example: kavahub-2 + example: testing height: - type: number - example: 1 + type: string + example: "1" time: type: string example: '2017-12-30T05:53:09.287+01:00' num_txs: - type: number - example: 0 + type: string + example: "0" last_block_id: $ref: '#/definitions/BlockID' total_txs: - type: number - example: 35 + type: string + example: "35" last_commit_hash: $ref: '#/definitions/Hash' data_hash: @@ -2779,9 +2949,10 @@ items: type: string evidence: - type: array - items: - type: string + type: object + # type: array + # items: + # type: string last_commit: type: object properties: @@ -2789,6 +2960,7 @@ $ref: '#/definitions/BlockID' precommits: type: array + x-nullable: true items: type: object properties: @@ -2851,20 +3023,20 @@ properties: from: type: string - example: 'kava1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc' + example: 'kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c' description: Sender address or Keybase name to generate a transaction memo: type: string example: 'Sent via Cosmos Voyager 🚀' chain_id: type: string - example: 'kava-1' + example: 'testing' account_number: type: string example: '0' sequence: type: string - example: '1' + example: '5' gas: type: string example: '200000' @@ -2877,7 +3049,7 @@ $ref: '#/definitions/Coin' simulate: type: boolean - example: false + example: true description: Estimate gas for a transaction (cannot be used in conjunction with generate_only) TendermintValidator: type: object @@ -2901,7 +3073,7 @@ example: 1 owner: type: string - example: kava1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc + example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 collateral: $ref: '#/definitions/CoinCollateral' principal: @@ -2924,9 +3096,11 @@ example: 1 depositor: type: string - example: kava1g9ahr6xhht5rmqven628nklxluzyv8z9jqjcmc + example: kava1q53rwutgpzx7szcrgzqguxyccjpzt9j4cyctn9 amount: - $ref: '#/definitions/CoinCollateral' + type: array + items: + $ref: '#/definitions/CoinCollateral' PricefeedParameters: type: object properties: @@ -2957,7 +3131,7 @@ example: '0.298758999999999997' expiry: type: string - example: '2020-02-12T23:10:00Z' + example: '2021-02-12T23:10:00Z' Market: type: object properties: @@ -2972,6 +3146,7 @@ example: 'usd' oracles: type: array + x-nullable: true items: $ref: '#/definitions/Address' active: @@ -3307,3 +3482,96 @@ type: array items: $ref: '#/definitions/Coin' + StandardResponse: + type: object + properties: + height: + type: string + result: + type: string + PostStdTx: + type: object + properties: + msg: + type: array + items: + $ref: "#/definitions/PostMsg" + fee: + type: object + properties: + gas: + type: string + example: "200000" + amount: + type: array + items: + $ref: "#/definitions/PostCoin2" + memo: + type: string + example: "" + signatures: + type: array + items: + $ref: "#/definitions/PostSignature" + + PostMsg: + type: object + properties: + type: + type: string + example: "cosmos-sdk/MsgSend" + value: + type: object + properties: + from_address: + type: string + example: kava1ffv7nhd3z6sych2qpqkk03ec6hzkmufy0r2s4c + to_address: + type: string + example: kava1ls82zzghsx0exkpr52m8vht5jqs3un0ceysshz + amount: + type: array + items: + $ref: "#/definitions/PostCoin1" + PostCoin1: + type: object + properties: + denom: + type: string + example: stake + amount: + type: string + example: "2000000" + PostCoin2: + type: object + properties: + denom: + type: string + example: stake + amount: + type: string + example: "2000" + PostSignature: + type: object + properties: + signature: + type: string + example: "KzBeQp/2+47oiqc16BImnOYidSAesZ3kgR3S8Fy+baFlvDlDv7goU/+rm4c7+woudNte3uZAG0CuUeHsF+Ld8Q==" + pubkey: + type: object + properties: + type: + type: string + example: "tendermint/PubKeySecp256k1" + value: + type: string + example: "AmWAim83Qp+kIcj3RT7i327b3l0EHwzCrGVGXusb70B7" + EncodeTx: + type: object + properties: + type: + type: string + example: "cosmos-sdk/StdTx" + value: + type: object + $ref: "#/definitions/StdTx"