From bf43b4899381fb2e9d3b1b406a1b03211b1ed3fc Mon Sep 17 00:00:00 2001 From: Dreamer <745124335@qq.com> Date: Thu, 3 Nov 2022 16:16:19 +0800 Subject: [PATCH] bump cosmos-sdk to v0.46.1 & fix some bugs (#318) --- .github/workflows/sims.yaml | 37 + .github/workflows/test.yml | 23 +- .github/workflows/wip.yml | 12 + CHANGELOG.md | 15 + Makefile | 48 +- README.md | 2 +- buf.work.yaml | 9 + contrib/devtools/Makefile | 2 +- go.mod | 150 +- go.sum | 845 ++++++----- modules/coinswap/client/rest/query.go | 51 - modules/coinswap/client/rest/rest.go | 63 - modules/coinswap/client/rest/tx.go | 215 --- .../{rest => testutil}/grpc_query_test.go | 9 +- modules/coinswap/handler.go | 35 - modules/coinswap/keeper/keeper.go | 327 +++- modules/coinswap/keeper/keeper_test.go | 210 ++- modules/coinswap/keeper/migrations.go | 14 +- modules/coinswap/keeper/msg_server.go | 58 +- modules/coinswap/keeper/pool.go | 7 + modules/coinswap/keeper/querier.go | 45 - modules/coinswap/keeper/querier_test.go | 63 - modules/coinswap/keeper/swap.go | 21 +- modules/coinswap/keeper/swap_test.go | 23 +- .../migrations/{v150 => v1}/migrate.go | 2 +- .../migrations/{v150 => v1}/migrate_test.go | 27 +- .../coinswap/migrations/{v150 => v1}/types.go | 2 +- .../migrations/{v152 => v2}/migrate.go | 5 +- modules/coinswap/migrations/v3/migrate.go | 56 + modules/coinswap/module.go | 33 +- modules/coinswap/simulation/operations.go | 396 ++++- modules/coinswap/simulation/params.go | 3 +- modules/coinswap/spec/01_state.md | 1 + modules/coinswap/spec/02_messages.md | 36 +- modules/coinswap/spec/03_events.md | 18 + modules/coinswap/spec/04_params.md | 11 +- modules/coinswap/spec/README.md | 2 + modules/coinswap/types/codec.go | 4 + modules/coinswap/types/coinswap.pb.go | 118 +- modules/coinswap/types/events.go | 20 +- modules/coinswap/types/msgs.go | 136 +- modules/coinswap/types/msgs_test.go | 201 ++- modules/coinswap/types/params.go | 41 +- modules/coinswap/types/querier.go | 13 - modules/coinswap/types/query.pb.gw.go | 4 +- modules/coinswap/types/tx.pb.go | 1309 +++++++++++++++-- modules/coinswap/types/utils.go | 2 +- modules/coinswap/types/validation.go | 41 +- modules/farm/client/cli/cli_test.go | 6 +- modules/farm/client/rest/rest.go | 12 - modules/farm/client/rest/tx.go | 11 - .../{rest => testutil}/grpc_query_test.go | 10 +- modules/farm/handler.go | 6 +- modules/farm/keeper/keeper.go | 5 +- modules/farm/keeper/keeper_test.go | 8 +- modules/farm/keeper/msg_server.go | 22 +- modules/farm/keeper/proposal_hook.go | 3 +- modules/farm/migarations/v152/migrate.go | 3 +- modules/farm/module.go | 3 +- modules/farm/simulation/operations.go | 129 +- modules/farm/types/codec.go | 4 +- modules/farm/types/expected_keeper.go | 7 +- modules/farm/types/farm.pb.go | 3 +- modules/farm/types/proposal.go | 9 +- modules/farm/types/query.pb.gw.go | 24 +- modules/htlc/client/cli/cli_test.go | 9 +- modules/htlc/client/rest/grpc_query_test.go | 103 -- modules/htlc/client/rest/query.go | 131 -- modules/htlc/client/rest/rest.go | 43 - modules/htlc/client/rest/tx.go | 86 -- .../htlc/client/testutil/grpc_query_test.go | 102 ++ modules/htlc/genesis_test.go | 16 +- modules/htlc/integration_test.go | 3 +- modules/htlc/keeper/asset_test.go | 8 +- modules/htlc/keeper/grpc_query_test.go | 9 +- modules/htlc/keeper/htlc_test.go | 12 +- modules/htlc/keeper/integration_test.go | 3 +- modules/htlc/keeper/keeper.go | 5 +- modules/htlc/keeper/params_test.go | 10 +- modules/htlc/module.go | 3 +- modules/htlc/simulation/operation.go | 12 +- modules/htlc/types/conmmon_test.go | 3 +- modules/htlc/types/genesis.pb.go | 7 +- modules/htlc/types/htlc.pb.go | 27 +- modules/htlc/types/params.go | 4 +- modules/htlc/types/query.pb.go | 49 +- modules/htlc/types/query.pb.gw.go | 24 +- modules/htlc/types/tx.pb.go | 20 +- modules/mt/client/cli/cli_test.go | 500 +++---- modules/mt/client/cli/tx.go | 2 +- modules/mt/client/testutil/grpc_query_test.go | 157 ++ modules/mt/client/testutil/test_helpers.go | 37 +- modules/mt/keeper/grpc_query_test.go | 1 - modules/mt/keeper/keeper.go | 5 +- modules/mt/simulation/genesis.go | 135 +- modules/mt/simulation/genesis_test.go | 39 + modules/mt/simulation/operations.go | 532 ++++--- modules/mt/types/common_test.go | 4 +- modules/mt/types/query.pb.gw.go | 39 +- modules/mt/types/tx.pb.go | 26 +- modules/nft/client/cli/cli_test.go | 11 +- modules/nft/client/cli/query.go | 2 +- modules/nft/client/cli/tx.go | 6 +- modules/nft/client/rest/query.go | 234 --- modules/nft/client/rest/rest.go | 71 - modules/nft/client/rest/tx.go | 181 --- .../{rest => testutil}/grpc_query_test.go | 15 +- modules/nft/genesis.go | 34 - modules/nft/handler.go | 47 - modules/nft/keeper/collection.go | 106 +- modules/nft/keeper/collection_test.go | 44 +- modules/nft/keeper/denom.go | 136 +- modules/nft/keeper/genesis.go | 49 + modules/nft/keeper/grpc_query.go | 151 +- modules/nft/keeper/grpc_query_test.go | 14 +- modules/nft/keeper/invariants.go | 19 +- modules/nft/keeper/keeper.go | 190 +-- modules/nft/keeper/keeper_test.go | 75 +- modules/nft/keeper/legacy_keeper.go | 83 +- modules/nft/keeper/migrations.go | 22 + modules/nft/keeper/msg_server.go | 61 +- modules/nft/keeper/nft.go | 222 ++- modules/nft/keeper/nft_test.go | 29 +- modules/nft/keeper/owners.go | 90 -- modules/nft/keeper/owners_test.go | 35 - modules/nft/keeper/pagination_test.go | 2 +- modules/nft/keeper/querier.go | 141 -- modules/nft/keeper/querier_test.go | 218 --- modules/nft/migrations/v2/expected_keeper.go | 27 + modules/nft/migrations/v2/keys.go | 64 + modules/nft/migrations/v2/store.go | 126 ++ modules/nft/migrations/v2/store_test.go | 153 ++ modules/nft/{ => module}/module.go | 45 +- modules/nft/simulation/decoder.go | 40 - modules/nft/simulation/genesis.go | 10 +- modules/nft/simulation/operations.go | 175 ++- modules/nft/types/codec.go | 28 - modules/nft/types/common_test.go | 4 +- modules/nft/types/denom.go | 26 - modules/nft/types/errors.go | 20 +- modules/nft/types/genesis.go | 5 + modules/nft/types/keys.go | 93 -- modules/nft/types/nft.go | 8 - modules/nft/types/nft.pb.go | 695 ++++++++- modules/nft/types/owners.go | 93 -- modules/nft/types/querier.go | 88 -- modules/nft/types/query.pb.go | 241 +-- modules/nft/types/query.pb.gw.go | 66 +- modules/nft/types/tx.pb.go | 50 +- modules/nft/types/validation.go | 7 + modules/oracle/client/cli/cli_test.go | 8 +- modules/oracle/client/rest/query.go | 112 -- modules/oracle/client/rest/rest.go | 58 - modules/oracle/client/rest/tx.go | 193 --- .../{rest => testutil}/grpc_query_test.go | 11 +- modules/oracle/keeper/keeper.go | 5 +- modules/oracle/keeper/keeper_test.go | 6 +- modules/oracle/keeper/pagination_test.go | 2 +- modules/oracle/module.go | 3 +- modules/oracle/simulation/operation.go | 14 +- modules/oracle/types/genesis.pb.go | 10 +- modules/oracle/types/oracle.pb.go | 12 +- modules/oracle/types/query.pb.go | 35 +- modules/oracle/types/query.pb.gw.go | 19 +- modules/oracle/types/tx.pb.go | 40 +- modules/random/client/cli/cli_test.go | 7 +- modules/random/client/rest/query.go | 110 -- modules/random/client/rest/rest.go | 30 - modules/random/client/rest/tx.go | 42 - .../{rest => testutil}/grpc_query_test.go | 11 +- modules/random/genesis_test.go | 2 +- modules/random/keeper/keeper.go | 5 +- modules/random/keeper/keeper_test.go | 4 +- modules/random/keeper/service.go | 13 +- modules/random/module.go | 3 +- modules/random/simulation/decoder_test.go | 2 +- modules/random/simulation/operations.go | 2 +- modules/random/types/genesis.pb.go | 12 +- modules/random/types/query.pb.go | 26 +- modules/random/types/query.pb.gw.go | 14 +- modules/random/types/random.pb.go | 10 +- modules/random/types/rng.go | 6 + modules/random/types/tx.pb.go | 13 +- modules/record/client/cli/cli_test.go | 5 +- modules/record/client/rest/query.go | 53 - modules/record/client/rest/rest.go | 28 - modules/record/client/rest/tx.go | 40 - .../{rest => testutil}/grpc_query_test.go | 11 +- modules/record/keeper/keeper.go | 5 +- modules/record/keeper/keeper_test.go | 2 +- modules/record/module.go | 3 +- modules/record/simulation/decoder_test.go | 2 +- modules/record/simulation/operations.go | 2 +- modules/record/types/genesis.pb.go | 5 +- modules/record/types/query.pb.go | 10 +- modules/record/types/query.pb.gw.go | 9 +- modules/record/types/record.pb.go | 10 +- modules/record/types/tx.pb.go | 10 +- modules/service/client/cli/cli_test.go | 11 +- modules/service/client/rest/query.go | 529 ------- modules/service/client/rest/rest.go | 139 -- modules/service/client/rest/tx.go | 601 -------- .../{rest => testutil}/grpc_query_test.go | 14 +- modules/service/client/utils/query.go | 2 +- modules/service/genesis.go | 18 +- modules/service/keeper/binding.go | 4 +- modules/service/keeper/fees.go | 8 +- modules/service/keeper/invocation.go | 2 +- modules/service/keeper/keeper.go | 5 +- modules/service/keeper/keeper_test.go | 6 +- modules/service/module.go | 3 +- modules/service/simulation/operations.go | 139 +- modules/service/types/genesis.pb.go | 9 +- modules/service/types/query.pb.go | 148 +- modules/service/types/query.pb.gw.go | 69 +- modules/service/types/service.pb.go | 60 +- modules/service/types/tx.pb.go | 185 +-- modules/token/client/cli/cli_test.go | 6 +- modules/token/client/rest/query.go | 184 --- modules/token/client/rest/rest.go | 61 - modules/token/client/rest/tx.go | 169 --- .../{rest => testutil}/grpc_query_test.go | 11 +- modules/token/genesis_test.go | 4 +- modules/token/handler_test.go | 17 +- modules/token/keeper/keeper.go | 14 +- modules/token/keeper/keeper_test.go | 7 +- modules/token/keeper/pagination_test.go | 2 +- modules/token/module.go | 3 +- modules/token/simulation/genesis.go | 2 +- modules/token/simulation/operations.go | 34 +- modules/token/simulation/params.go | 11 +- modules/token/types/genesis.pb.go | 5 +- modules/token/types/query.pb.go | 50 +- modules/token/types/query.pb.gw.go | 29 +- modules/token/types/token.pb.go | 10 +- modules/token/types/token_test.go | 3 +- modules/token/types/tx.pb.go | 53 +- proto/buf.gen.gogo.yaml | 8 + proto/buf.yaml | 7 + proto/coinswap/coinswap.proto | 10 +- proto/coinswap/tx.proto | 128 +- proto/farm/farm.proto | 27 +- proto/farm/tx.proto | 9 +- proto/htlc/genesis.proto | 12 +- proto/htlc/htlc.proto | 163 +- proto/htlc/query.proto | 70 +- proto/htlc/tx.proto | 47 +- proto/mt/genesis.proto | 10 +- proto/mt/query.proto | 130 +- proto/mt/tx.proto | 92 +- proto/nft/genesis.proto | 2 +- proto/nft/nft.proto | 82 +- proto/nft/query.proto | 128 +- proto/nft/tx.proto | 128 +- proto/oracle/genesis.proto | 8 +- proto/oracle/oracle.proto | 25 +- proto/oracle/query.proto | 74 +- proto/oracle/tx.proto | 84 +- proto/random/genesis.proto | 5 +- proto/random/query.proto | 39 +- proto/random/random.proto | 26 +- proto/random/tx.proto | 20 +- proto/record/genesis.proto | 2 +- proto/record/query.proto | 16 +- proto/record/record.proto | 18 +- proto/record/tx.proto | 14 +- proto/service/genesis.proto | 12 +- proto/service/query.proto | 271 ++-- proto/service/service.proto | 272 ++-- proto/service/tx.proto | 259 ++-- proto/token/genesis.proto | 8 +- proto/token/query.proto | 94 +- proto/token/token.proto | 50 +- proto/token/tx.proto | 71 +- scripts/protocgen.sh | 28 +- simapp/app.go | 120 +- simapp/export.go | 36 +- simapp/sim_bench_test.go | 126 ++ simapp/sim_test.go | 42 +- simapp/state.go | 8 +- simapp/test_helpers.go | 232 +-- 281 files changed, 9049 insertions(+), 9174 deletions(-) create mode 100644 .github/workflows/sims.yaml create mode 100644 .github/workflows/wip.yml create mode 100644 buf.work.yaml delete mode 100644 modules/coinswap/client/rest/query.go delete mode 100644 modules/coinswap/client/rest/rest.go delete mode 100644 modules/coinswap/client/rest/tx.go rename modules/coinswap/client/{rest => testutil}/grpc_query_test.go (99%) delete mode 100644 modules/coinswap/handler.go delete mode 100644 modules/coinswap/keeper/querier.go delete mode 100644 modules/coinswap/keeper/querier_test.go rename modules/coinswap/migrations/{v150 => v1}/migrate.go (99%) rename modules/coinswap/migrations/{v150 => v1}/migrate_test.go (81%) rename modules/coinswap/migrations/{v150 => v1}/types.go (98%) rename modules/coinswap/migrations/{v152 => v2}/migrate.go (91%) create mode 100644 modules/coinswap/migrations/v3/migrate.go delete mode 100644 modules/coinswap/types/querier.go delete mode 100644 modules/farm/client/rest/rest.go delete mode 100644 modules/farm/client/rest/tx.go rename modules/farm/client/{rest => testutil}/grpc_query_test.go (95%) delete mode 100644 modules/htlc/client/rest/grpc_query_test.go delete mode 100644 modules/htlc/client/rest/query.go delete mode 100644 modules/htlc/client/rest/rest.go delete mode 100644 modules/htlc/client/rest/tx.go create mode 100644 modules/htlc/client/testutil/grpc_query_test.go create mode 100644 modules/mt/client/testutil/grpc_query_test.go delete mode 100644 modules/mt/keeper/grpc_query_test.go create mode 100644 modules/mt/simulation/genesis_test.go delete mode 100644 modules/nft/client/rest/query.go delete mode 100644 modules/nft/client/rest/rest.go delete mode 100644 modules/nft/client/rest/tx.go rename modules/nft/client/{rest => testutil}/grpc_query_test.go (96%) delete mode 100644 modules/nft/genesis.go delete mode 100644 modules/nft/handler.go create mode 100644 modules/nft/keeper/genesis.go create mode 100644 modules/nft/keeper/migrations.go delete mode 100644 modules/nft/keeper/owners.go delete mode 100644 modules/nft/keeper/owners_test.go delete mode 100644 modules/nft/keeper/querier.go delete mode 100644 modules/nft/keeper/querier_test.go create mode 100644 modules/nft/migrations/v2/expected_keeper.go create mode 100644 modules/nft/migrations/v2/keys.go create mode 100644 modules/nft/migrations/v2/store.go create mode 100644 modules/nft/migrations/v2/store_test.go rename modules/nft/{ => module}/module.go (83%) delete mode 100644 modules/nft/simulation/decoder.go delete mode 100644 modules/nft/types/denom.go delete mode 100644 modules/nft/types/owners.go delete mode 100644 modules/nft/types/querier.go delete mode 100644 modules/oracle/client/rest/query.go delete mode 100644 modules/oracle/client/rest/rest.go delete mode 100644 modules/oracle/client/rest/tx.go rename modules/oracle/client/{rest => testutil}/grpc_query_test.go (97%) delete mode 100644 modules/random/client/rest/query.go delete mode 100644 modules/random/client/rest/rest.go delete mode 100644 modules/random/client/rest/tx.go rename modules/random/client/{rest => testutil}/grpc_query_test.go (97%) delete mode 100644 modules/record/client/rest/query.go delete mode 100644 modules/record/client/rest/rest.go delete mode 100644 modules/record/client/rest/tx.go rename modules/record/client/{rest => testutil}/grpc_query_test.go (93%) delete mode 100644 modules/service/client/rest/query.go delete mode 100644 modules/service/client/rest/rest.go delete mode 100644 modules/service/client/rest/tx.go rename modules/service/client/{rest => testutil}/grpc_query_test.go (98%) delete mode 100644 modules/token/client/rest/query.go delete mode 100644 modules/token/client/rest/rest.go delete mode 100644 modules/token/client/rest/tx.go rename modules/token/client/{rest => testutil}/grpc_query_test.go (95%) create mode 100644 proto/buf.gen.gogo.yaml create mode 100644 proto/buf.yaml create mode 100644 simapp/sim_bench_test.go diff --git a/.github/workflows/sims.yaml b/.github/workflows/sims.yaml new file mode 100644 index 00000000..89708559 --- /dev/null +++ b/.github/workflows/sims.yaml @@ -0,0 +1,37 @@ +name: Simulation Test +on: [pull_request] + +jobs: + test-sim-nondeterminism-fast: + name: Test AppStateDeterminism + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '^1.18' # The Go version to download (if necessary) and use. + - run: make test-sim-nondeterminism-fast + test-sim-import-export: + name: Test AppImportExport + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '^1.18' # The Go version to download (if necessary) and use. + - run: make test-sim-import-export + test-sim-after-import: + name: Test AppSimulationAfterImport + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 + with: + go-version: '^1.18' # The Go version to download (if necessary) and use. + - run: make test-sim-after-import \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb3a5e18..6bd6bc51 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,22 +7,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout source code - uses: actions/checkout@v1 - - name: Run unit tests - uses: cedrickring/golang-action/go1.16@1.7.0 - env: - GO111MODULE: "on" + uses: actions/checkout@v3 + - name: Setup go + uses: actions/setup-go@v3 with: - args: make test-unit - test-sim: - name: Test Simulations - runs-on: ubuntu-latest - steps: - - name: Checkout source code - uses: actions/checkout@v1 - - name: Run simulation tests - uses: cedrickring/golang-action/go1.16@1.7.0 - env: - GO111MODULE: "on" - with: - args: make test-sim-nondeterminism-fast + go-version: '^1.18' # The Go version to download (if necessary) and use. + - run: make test-unit \ No newline at end of file diff --git a/.github/workflows/wip.yml b/.github/workflows/wip.yml new file mode 100644 index 00000000..13157ae5 --- /dev/null +++ b/.github/workflows/wip.yml @@ -0,0 +1,12 @@ +name: WIP +on: + pull_request: + types: [opened, synchronize, reopened, edited] + +jobs: + wip: + runs-on: ubuntu-latest + steps: + - uses: wip/action@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 436e420f..9abb2229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,8 +37,23 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* [\#304](https://github.com/irisnet/irismod/pull/304) Fix nft module import error. +* [\#314](https://github.com/irisnet/irismod/pull/314) Fix `addLiquidity` panic error. + ### Improvements +* [\#305](https://github.com/irisnet/irismod/pull/305) Remove ibc-go from project. +* [\#306](https://github.com/irisnet/irismod/pull/306) Bump up cosmos-sdk to v0.46.1. +* [\#307](https://github.com/irisnet/irismod/pull/307) Refactor proto-gen with docker. +* [\#308](https://github.com/irisnet/irismod/pull/308) Coinswap module adds unilateral injection liquidity function. +* [\#309](https://github.com/irisnet/irismod/pull/309) Refactor nft with cosmos-sdk nft module. + +### API Breaking Changes + +* [\#309](https://github.com/irisnet/irismod/pull/309) GRPC method `Owner` rename to `NFTsOfOwner`, Remove deprecated `Queries` api + ## [v1.6.0] - 2022-08-08 ### Improvements diff --git a/Makefile b/Makefile index 3d4800f4..333639c7 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,13 @@ SIMAPP = ./simapp BINDIR ?= $(GOPATH)/bin +CURRENT_DIR = $(shell pwd) PACKAGES_SIMTEST=$(shell go list ./... | grep '/simulation') PACKAGES_UNITTEST=$(shell go list ./... | grep -v '/simulation' | grep -v '/cli_test') +DOCKER := $(shell which docker) +DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8 +PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git) ldflags = -X github.com/cosmos/cosmos-sdk/types.reDnmString=[a-zA-Z][a-zA-Z0-9/:]{2,127} @@ -35,10 +39,36 @@ clean: distclean: clean rm -rf vendor/ -proto-all: proto-tools proto-gen +############################################################################### +### Protobuf ### +############################################################################### + +protoVer=v0.7 +protoImageName=tendermintdev/sdk-proto-gen:$(protoVer) +containerProtoGen=$(PROJECT_NAME)-proto-gen-$(protoVer) +containerProtoGenAny=$(PROJECT_NAME)-proto-gen-any-$(protoVer) +containerProtoGenSwagger=$(PROJECT_NAME)-proto-gen-swagger-$(protoVer) +containerProtoFmt=$(PROJECT_NAME)-proto-fmt-$(protoVer) + +proto-all: proto-format proto-gen proto-gen: - @./scripts/protocgen.sh + @echo "Generating Protobuf files" + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then docker start -a $(containerProtoGen); else docker run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ + sh ./scripts/protocgen.sh; fi + +proto-swagger-gen: + @echo "Generating Protobuf Swagger" + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then docker start -a $(containerProtoGenSwagger); else docker run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(protoImageName) \ + sh ./scripts/protoc-swagger-gen.sh; fi + +proto-format: + @echo "Formatting Protobuf files" + @if docker ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then docker start -a $(containerProtoFmt); else docker run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace tendermintdev/docker-build-proto \ + find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi + +proto-lint: + @$(DOCKER_BUF) lint --error-format=json ######################################## ### Testing @@ -50,27 +80,21 @@ test-unit: test-sim-nondeterminism: @echo "Running non-determinism test..." - @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ + @cd ${CURRENT_DIR}/simapp && go test -mod=readonly -run TestAppStateDeterminism -Enabled=true \ -NumBlocks=100 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h test-sim-nondeterminism-fast: @echo "Running non-determinism test..." - @go test -mod=readonly $(SIMAPP) -run TestAppStateDeterminism -Enabled=true \ + @cd ${CURRENT_DIR}/simapp && go test -mod=readonly -run TestAppStateDeterminism -Enabled=true \ -NumBlocks=10 -BlockSize=200 -Commit=true -Period=0 -v -timeout 24h -test-sim-custom-genesis-fast: - @echo "Running custom genesis simulation..." - @echo "By default, $(shell pwd)/testdata/genesis.json will be used." - @go test -mod=readonly $(SIMAPP) -run TestFullAppSimulation -Genesis=$(shell pwd)/testdata/genesis.json \ - -Enabled=true -NumBlocks=100 -BlockSize=200 -Commit=true -Seed=99 -Period=5 -v -timeout 24h - test-sim-import-export: runsim @echo "Running application import/export simulation. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppImportExport + @cd ${CURRENT_DIR}/simapp && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppImportExport test-sim-after-import: runsim @echo "Running application simulation-after-import. This may take several minutes..." - @$(BINDIR)/runsim -Jobs=4 -SimAppPkg=$(SIMAPP) -ExitOnFail 50 5 TestAppSimulationAfterImport + @cd ${CURRENT_DIR}/simapp && $(BINDIR)/runsim -Jobs=4 -SimAppPkg=. -ExitOnFail 50 5 TestAppSimulationAfterImport test-sim-custom-genesis-multi-seed: runsim @echo "Running multi-seed custom genesis simulation..." diff --git a/README.md b/README.md index 87928d81..ff2db4ff 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,4 @@ IRISnet Modules **Note**: This repository is meant to house modules that are created outside of the [IRIS Hub](https://github.com/irisnet/irishub) repository. -**Note**: Requires [Go 1.14+](https://golang.org/dl/) +**Note**: Requires [Go 1.18+](https://golang.org/dl/) diff --git a/buf.work.yaml b/buf.work.yaml new file mode 100644 index 00000000..dcc4fb9c --- /dev/null +++ b/buf.work.yaml @@ -0,0 +1,9 @@ +# Generated by "buf config migrate-v1beta1". Edit as necessary, and +# remove this comment when you're finished. +# +# This workspace file points to the roots found in your +# previous "buf.yaml" configuration. +version: v1 +directories: + - proto + - third_party/proto \ No newline at end of file diff --git a/contrib/devtools/Makefile b/contrib/devtools/Makefile index 606fcb00..9f798ae6 100644 --- a/contrib/devtools/Makefile +++ b/contrib/devtools/Makefile @@ -129,7 +129,7 @@ buf-stamp: runsim: $(RUNSIM) $(RUNSIM): @echo "Installing runsim..." - @(cd /tmp && go get github.com/cosmos/tools/cmd/runsim@v1.0.0) + @go install github.com/cosmos/tools/cmd/runsim@v1.0.0 tools-clean: rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) diff --git a/go.mod b/go.mod index 553cd3b6..b6e9994f 100644 --- a/go.mod +++ b/go.mod @@ -1,110 +1,142 @@ -module github.com/irisnet/irismod +go 1.18 -go 1.17 +module github.com/irisnet/irismod require ( - github.com/cosmos/cosmos-sdk v0.45.1 + cosmossdk.io/math v1.0.0-beta.3 + github.com/cosmos/cosmos-sdk v0.46.1 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 github.com/rakyll/statik v0.1.7 github.com/regen-network/cosmos-proto v0.3.1 - github.com/spf13/cast v1.4.1 - github.com/spf13/cobra v1.3.0 + github.com/spf13/cast v1.5.0 + github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.7.0 - github.com/tendermint/tendermint v0.34.16 - github.com/tendermint/tm-db v0.6.6 - github.com/tendermint/tmlibs v0.9.0 + github.com/stretchr/testify v1.8.0 + github.com/tendermint/tendermint v0.34.21 + github.com/tendermint/tm-db v0.6.7 github.com/tidwall/gjson v1.14.0 - github.com/xeipuuv/gojsonschema v1.2.0 - google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb - google.golang.org/grpc v1.44.0 + google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b + google.golang.org/grpc v1.48.0 + google.golang.org/protobuf v1.28.0 gopkg.in/yaml.v2 v2.4.0 ) require ( - filippo.io/edwards25519 v1.0.0-beta.2 // indirect - github.com/99designs/keyring v1.1.6 // indirect + cloud.google.com/go v0.100.2 // indirect + cloud.google.com/go/compute v1.6.1 // indirect + cloud.google.com/go/iam v0.3.0 // indirect + cloud.google.com/go/storage v1.14.0 // indirect + cosmossdk.io/errors v1.0.0-beta.7 // indirect + github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d // indirect - github.com/DataDog/zstd v1.4.5 // indirect + github.com/armon/go-metrics v0.4.0 // indirect + github.com/aws/aws-sdk-go v1.40.45 // indirect + github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect + github.com/cenkalti/backoff/v4 v4.1.3 // indirect + github.com/cockroachdb/apd/v2 v2.0.2 // indirect + github.com/confio/ics23/go v0.7.0 // indirect + github.com/cosmos/cosmos-proto v1.0.0-alpha7 // indirect + github.com/cosmos/gorocksdb v1.2.0 // indirect + github.com/creachadair/taskgroup v0.3.2 // indirect + github.com/go-kit/log v0.2.1 // indirect + github.com/go-logfmt/logfmt v0.5.1 // indirect + github.com/golang/glog v1.0.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/googleapis/gax-go/v2 v2.4.0 // indirect + github.com/gtank/merlin v0.1.1 // indirect + github.com/gtank/ristretto255 v0.1.2 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-getter v1.6.1 // indirect + github.com/hashicorp/go-safetemp v1.0.0 // indirect + github.com/hashicorp/go-version v1.6.0 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/mattn/go-colorable v0.1.12 // indirect + github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect + github.com/mitchellh/go-testing-interface v1.0.0 // indirect + github.com/pelletier/go-toml/v2 v2.0.2 // indirect + github.com/spf13/viper v1.12.0 // indirect + github.com/ulikunitz/xz v0.5.8 // indirect + go.opencensus.io v0.23.0 // indirect + golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e // indirect + golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 // indirect + golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df // indirect + google.golang.org/api v0.81.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) + +require ( + filippo.io/edwards25519 v1.0.0-rc.1 // indirect + github.com/99designs/keyring v1.2.1 // indirect github.com/Workiva/go-datastructures v1.0.53 // indirect - github.com/armon/go-metrics v0.3.10 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/speakeasy v0.1.0 // indirect - github.com/btcsuite/btcd v0.22.0-beta // indirect + github.com/btcsuite/btcd v0.22.1 // indirect github.com/cespare/xxhash v1.1.0 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect - github.com/coinbase/rosetta-sdk-go v0.7.0 // indirect - github.com/confio/ics23/go v0.6.6 // indirect + github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect github.com/cosmos/btcutil v1.0.4 // indirect github.com/cosmos/go-bip39 v1.0.0 // indirect - github.com/cosmos/iavl v0.17.3 // indirect + github.com/cosmos/iavl v0.19.1 // indirect github.com/cosmos/ledger-cosmos-go v0.11.1 // indirect github.com/cosmos/ledger-go v0.9.2 // indirect - github.com/danieljoos/wincred v1.0.2 // indirect + github.com/danieljoos/wincred v1.1.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect - github.com/dgraph-io/badger/v2 v2.2007.2 // indirect - github.com/dgraph-io/ristretto v0.0.3 // indirect + github.com/dgraph-io/badger/v2 v2.2007.4 // indirect + github.com/dgraph-io/ristretto v0.1.0 // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/dustin/go-humanize v1.0.0 // indirect - github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b // indirect + github.com/dvsekhvalnov/jose2go v1.5.0 // indirect github.com/felixge/httpsnoop v1.0.1 // indirect - github.com/fsnotify/fsnotify v1.5.1 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/gin-gonic/gin v1.7.7 // indirect github.com/go-kit/kit v0.12.0 // indirect - github.com/go-kit/log v0.2.0 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/snappy v0.0.3 // indirect - github.com/google/btree v1.0.0 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/btree v1.0.1 // indirect github.com/google/orderedcode v0.0.1 // indirect github.com/gorilla/handlers v1.5.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect - github.com/gtank/merlin v0.1.1 // indirect - github.com/gtank/ristretto255 v0.1.2 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d // indirect github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 // indirect - github.com/improbable-eng/grpc-web v0.14.1 // indirect + github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect + github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect - github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect - github.com/klauspost/compress v1.13.6 // indirect - github.com/lib/pq v1.10.4 // indirect - github.com/libp2p/go-buffer-pool v0.0.2 // indirect - github.com/magiconair/properties v1.8.5 // indirect + github.com/klauspost/compress v1.15.9 // indirect + github.com/lib/pq v1.10.6 // indirect + github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/magiconair/properties v1.8.6 // indirect github.com/mattn/go-isatty v0.0.14 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect - github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect github.com/minio/highwayhash v1.0.2 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/mapstructure v1.4.3 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mtibben/percent v0.2.1 // indirect - github.com/pelletier/go-toml v1.9.4 // indirect + github.com/pelletier/go-toml v1.9.5 // indirect github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.12.1 // indirect + github.com/prometheus/client_golang v1.12.2 // indirect github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect + github.com/prometheus/common v0.34.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0 // indirect github.com/rs/cors v1.8.2 // indirect - github.com/rs/zerolog v1.23.0 // indirect + github.com/rs/zerolog v1.27.0 // indirect github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa // indirect - github.com/spf13/afero v1.6.0 // indirect + github.com/spf13/afero v1.8.2 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/viper v1.10.1 // indirect - github.com/subosito/gotenv v1.2.0 // indirect - github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca // indirect - github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c // indirect + github.com/subosito/gotenv v1.4.0 // indirect + github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect github.com/tendermint/btcd v0.1.1 // indirect github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 // indirect github.com/tendermint/go-amino v0.16.0 // indirect @@ -112,16 +144,16 @@ require ( github.com/tidwall/pretty v1.2.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect - github.com/zondax/hid v0.9.0 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 + github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 // indirect go.etcd.io/bbolt v1.3.6 // indirect - golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 // indirect - golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b // indirect - golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect - golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect + golang.org/x/net v0.0.0-20220726230323-06994584191e // indirect + golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 // indirect + golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect golang.org/x/text v0.3.7 // indirect - google.golang.org/protobuf v1.27.1 // indirect - gopkg.in/ini.v1 v1.66.2 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/ini.v1 v1.66.6 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect nhooyr.io/websocket v1.8.6 // indirect ) diff --git a/go.sum b/go.sum index 1be017c1..3b77dffa 100644 --- a/go.sum +++ b/go.sum @@ -1,12 +1,14 @@ -bazil.org/fuse v0.0.0-20200407214033-5883e5a4b512/go.mod h1:FbcW6z/2VytnFDhZfumh8Ss8zxHE6qpMP5sHTRe0EaM= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.43.0/go.mod h1:BOSR3VbTLkk6FDC/TcffxP4NF/FFBGA5ku+jvKOP7pg= cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.51.0/go.mod h1:hWtGJ6gnXH+KgDv+V0zFGDvpi07n3z8ZNj3T1RW0Gcw= cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= @@ -16,6 +18,7 @@ cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOY cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= +cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY= cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= @@ -26,18 +29,26 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.98.0/go.mod h1:ua6Ush4NALrHk5QXDWnjvZHN93OuF0HfuEPq9I1X0cM= cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= +cloud.google.com/go v0.100.2 h1:t9Iw5QH5v4XtlEQaCtUY7x6sCABps8sW0acw7e2WQ6Y= +cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/bigtable v1.2.0/go.mod h1:JcVAOl45lrTmQfLj7T6TxyMzIN/3FGGcFm+2xVAli2o= +cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= +cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= +cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= +cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= +cloud.google.com/go/compute v1.6.1 h1:2sMmt8prCn7DPaG4Pmh0N3Inmc8cT8ae5k1M6VJ9Wqc= +cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/firestore v1.6.1/go.mod h1:asNXNOzBdyVQmEU+ggO8UPodTkEVFW5Qx+rwHnAz+EY= +cloud.google.com/go/iam v0.3.0 h1:exkAomrVUuzx9kWFI1wm3KI0uoDeUFPB4kKGzx6x+Gc= +cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -47,61 +58,48 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +cloud.google.com/go/storage v1.14.0 h1:6RRlFMv1omScs6iq2hfE3IvgE+l6RfJPampq8UZc5TU= +cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= +collectd.org v0.3.0/go.mod h1:A/8DzQBkF6abtvrT2j/AU/4tiBgJWYyh0y/oB/4MlWE= +cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= +cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= +cosmossdk.io/math v1.0.0-beta.3 h1:TbZxSopz2LqjJ7aXYfn7nJSb8vNaBklW6BLpcei1qwM= +cosmossdk.io/math v1.0.0-beta.3/go.mod h1:3LYasri3Zna4XpbrTNdKsWmD5fHHkaNAod/mNT9XdE4= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -filippo.io/edwards25519 v1.0.0-beta.2 h1:/BZRNzm8N4K4eWfK28dL4yescorxtO7YG1yun8fy+pI= -filippo.io/edwards25519 v1.0.0-beta.2/go.mod h1:X+pm78QAUPtFLi1z9PYIlS/bdDnvbCOGKtZ+ACWEf7o= -github.com/99designs/keyring v1.1.6 h1:kVDC2uCgVwecxCk+9zoCt2uEL6dt+dfVzMvGgnVcIuM= -github.com/99designs/keyring v1.1.6/go.mod h1:16e0ds7LGQQcT59QqkTg72Hh5ShM51Byv5PEmW6uoRU= -github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= -github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= -github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= +filippo.io/edwards25519 v1.0.0-rc.1 h1:m0VOOB23frXZvAOK44usCgLWvtsxIoMCTBGJZlpmGfU= +filippo.io/edwards25519 v1.0.0-rc.1/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns= +git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw= +git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs= +github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4= +github.com/99designs/keyring v1.2.1 h1:tYLp1ULvO7i3fI5vE21ReQuj99QFSs7lGm0xWyJo87o= +github.com/99designs/keyring v1.2.1/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo= github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8= -github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.0.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg= github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4= -github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= +github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/DataDog/zstd v1.4.1/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ= -github.com/DataDog/zstd v1.4.5/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= -github.com/HdrHistogram/hdrhistogram-go v1.1.0/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= +github.com/DataDog/zstd v1.5.0/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= -github.com/Microsoft/go-winio v0.4.14/go.mod h1:qXqCSQ3Xa7+6tgxaGTIe4Kpcdsi+P8jBhyzoq1bpyYA= -github.com/Microsoft/go-winio v0.5.0/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= -github.com/Microsoft/go-winio v0.5.1 h1:aPJp2QD7OOrhO5tQXqQoGSJc+DjDtWTGLOmNyAm6FgY= -github.com/Microsoft/go-winio v0.5.1/go.mod h1:JPGBdM1cNvN/6ISo+n8V5iA4v8pBzdOpzfwIujj1a84= +github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= -github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo= github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VictoriaMetrics/fastcache v1.5.7/go.mod h1:ptDBkNMQI4RtmVo8VS/XwRY6RoTu1dAWCbrk+6WsEM8= +github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/VividCortex/gohistogram v1.0.0 h1:6+hBz+qvs0JOrrNhhmR7lFxo5sINxBCGXrdtl/UvroE= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= -github.com/Workiva/go-datastructures v1.0.52/go.mod h1:Z+F2Rca0qCsVYDS8z7bAGm8f3UkzuWYS/oBZz5a7VVA= github.com/Workiva/go-datastructures v1.0.53 h1:J6Y/52yX10Xc5JjXmGtWoSSxs3mZnGSaq37xZZh7Yig= github.com/Workiva/go-datastructures v1.0.53/go.mod h1:1yZL+zfsztete+ePzZz/Zb1/t5BnDuE2Ya2MMGhzP6A= github.com/Zilliqa/gozilliqa-sdk v1.2.1-0.20201201074141-dd0ecada1be6/go.mod h1:eSYp2T6f0apnuW8TzhV3f6Aff2SE8Dwio++U4ha4yEM= -github.com/adlio/schema v1.1.13/go.mod h1:L5Z7tw+7lRK1Fnpi/LT/ooCP1elkXn0krMWBQHUhEDE= -github.com/adlio/schema v1.2.3 h1:GfKThfEsjS9cCz7gaF8zdXv4cpTdUqdljkKGDTbJjys= -github.com/adlio/schema v1.2.3/go.mod h1:nD7ZWmMMbwU12Pqwg+qL0rTvHBrBXfNz+5UQxTfy38M= +github.com/adlio/schema v1.3.3 h1:oBJn8I02PyTB466pZO1UZEn1TV5XLlifBSyMrmHl/1I= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5/go.mod h1:SkGFH1ia65gfNATL8TAiHDNxPzPdmEL5uirI2Uyuz6c= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= @@ -111,44 +109,53 @@ github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRF github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= +github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apache/arrow/go/arrow v0.0.0-20191024131854-af6fa24be0db/go.mod h1:VTxUBvSJ3s3eHAg65PNgrsn5BtqCRPdmyXh6rAfdxN0= github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= -github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.3.9/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= -github.com/armon/go-metrics v0.3.10 h1:FR+drcQStOe+32sYyJYyZ7FIdgoGGBnwLl+flodp8Uo= -github.com/armon/go-metrics v0.3.10/go.mod h1:4O98XIr/9W0sxpJ8UaYkvjk10Iff7SnFrb4QAOwNTFc= +github.com/armon/go-metrics v0.4.0 h1:yCQqn7dwca4ITXb+CbubHmedzaQYHhNhrEXLYUeEe8Q= +github.com/armon/go-metrics v0.4.0/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A= github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= -github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= +github.com/aws/aws-sdk-go v1.40.45 h1:QN1nsY27ssD/JmW4s83qmSb+uL6DG4GmCDzjmJB4xUI= github.com/aws/aws-sdk-go v1.40.45/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/aws/aws-sdk-go-v2 v1.9.1/go.mod h1:cK/D0BBs0b/oWPIcX/Z/obahJK1TT7IPVjy53i/mX/4= -github.com/aws/aws-sdk-go-v2/service/cloudwatch v1.8.1/go.mod h1:CM+19rL1+4dFWnOQKwDc7H1KwXTz+h61oUSHyhV0b3o= -github.com/aws/smithy-go v1.8.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/aws/aws-sdk-go-v2 v1.2.0/go.mod h1:zEQs02YRBw1DjK0PoJv3ygDYOFTre1ejlJWl8FwAuQo= +github.com/aws/aws-sdk-go-v2/config v1.1.1/go.mod h1:0XsVy9lBI/BCXm+2Tuvt39YmdHwS5unDQmxZOYe8F5Y= +github.com/aws/aws-sdk-go-v2/credentials v1.1.1/go.mod h1:mM2iIjwl7LULWtS6JCACyInboHirisUUdkBPoTHMOUo= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.0.2/go.mod h1:3hGg3PpiEjHnrkrlasTfxFqUsZ2GCk/fMUn4CbKgSkM= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.0.2/go.mod h1:45MfaXZ0cNbeuT0KQ1XJylq8A6+OpVV2E5kvY/Kq+u8= +github.com/aws/aws-sdk-go-v2/service/route53 v1.1.1/go.mod h1:rLiOUrPLW/Er5kRcQ7NkwbjlijluLsrIbu/iyl35RO4= +github.com/aws/aws-sdk-go-v2/service/sso v1.1.1/go.mod h1:SuZJxklHxLAXgLTc1iFXbEWkXs7QRTQpCLGaKIprQW0= +github.com/aws/aws-sdk-go-v2/service/sts v1.1.1/go.mod h1:Wi0EBZwiz/K44YliU0EKxqTCJGUfYTWXrrBwkq736bM= +github.com/aws/smithy-go v1.1.0/go.mod h1:EzMw8dbp/YJL4A5/sbhGddag+NPT7q084agLbB9LgIw= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= -github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= -github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= +github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= +github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20190115013929-ed77733ec07d/go.mod h1:d3C0AkH6BRcvO8T0UEPu53cnw4IbV63x1bEjildYhO0= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= -github.com/btcsuite/btcd v0.21.0-beta/go.mod h1:ZSWyehm27aAuS9bvkATT+Xte3hjHZ+MRgMY/8NJ7K94= -github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo= -github.com/btcsuite/btcd v0.22.0-beta/go.mod h1:9n5ntfhhHQBIhUvlhDvD3Qg6fRUj4jkN0VB8L8svzOA= +github.com/btcsuite/btcd v0.21.0-beta.0.20201114000516-e9c7a5ac6401/go.mod h1:Sv4JPQ3/M+teHz9Bo5jBpkNcP0x6r7rdihlNL/7tTAs= +github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= +github.com/btcsuite/btcd v0.22.1/go.mod h1:wqgTSL29+50LRkmOVknEdmt8ZojIzhuWvgu/iptuN7Y= +github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA= github.com/btcsuite/btcutil v0.0.0-20180706230648-ab6388e0c60a/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= github.com/btcsuite/btcutil v0.0.0-20190207003914-4c204d697803/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg= @@ -163,30 +170,30 @@ github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku github.com/btcsuite/snappy-go v1.0.0/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc= github.com/btcsuite/websocket v0.0.0-20150119174127-31079b680792/go.mod h1:ghJtEyQwv5/p4Mg4C0fgbePVuGr935/5ddU9Z3TmDRY= github.com/btcsuite/winsvc v1.0.0/go.mod h1:jsenWakMcC0zFBFurPLEAyrnc/teJEM1O46fmI40EZs= +github.com/bwesterb/go-ristretto v1.2.0/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0= +github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34= github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ= -github.com/casbin/casbin/v2 v2.37.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg= github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/checkpoint-restore/go-criu/v5 v5.0.0/go.mod h1:cfwC0EG7HMUenopBsUf9d89JlCLQIfgVcNsNN0t6T2M= +github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/cilium/ebpf v0.6.2/go.mod h1:4tRaxcgiL706VnOzHOdBlY8IEAIdxINsQBcU4xJJXRs= github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/mxj v1.8.4/go.mod h1:BVjHeAH+rl9rs6f+QIpeRl0tfu10SXn1pUSa5PVGJng= github.com/clbanning/x2j v0.0.0-20191024224557-825249438eec/go.mod h1:jMjuTZXRI4dUb/I5gc9Hdhagfvm9+RyrPryS/auMzxE= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= +github.com/cloudflare/cloudflare-go v0.14.0/go.mod h1:EnwdgGMaFOruiPZRFSgn+TsQ3hQ7C/YWzIGLeu5c304= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= @@ -196,85 +203,95 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211130200136-a8f946100490/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cockroachdb/apd/v2 v2.0.2 h1:weh8u7Cneje73dDh+2tEVLUvyBc89iwepWCD8b8034E= +github.com/cockroachdb/apd/v2 v2.0.2/go.mod h1:DDxRlzC2lo3/vSlmSoS7JkqbbrARPuFOGr0B9pvN3Gw= github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:zn76sxSg3SzpJ0PPJaLDCu+Bu0Lg3sKTORVIj19EIF8= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= -github.com/coinbase/rosetta-sdk-go v0.7.0 h1:lmTO/JEpCvZgpbkOITL95rA80CPKb5CtMzLaqF2mCNg= -github.com/coinbase/rosetta-sdk-go v0.7.0/go.mod h1:7nD3oBPIiHqhRprqvMgPoGxe/nyq3yftRmpsy29coWE= -github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8= -github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= -github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ= -github.com/containerd/continuity v0.0.0-20190827140505-75bee3e2ccb6/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= -github.com/containerd/continuity v0.2.1 h1:/EeEo2EtN3umhbbgCveyjifoMYg0pS+nMMEemaYw634= -github.com/containerd/continuity v0.2.1/go.mod h1:wCYX+dRqZdImhGucXOqTQn05AhX6EUDaGEMUzTFFpLg= -github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coinbase/kryptology v1.8.0/go.mod h1:RYXOAPdzOGUe3qlSFkMGn58i3xUA8hmxYHksuq+8ciI= +github.com/coinbase/rosetta-sdk-go v0.7.9 h1:lqllBjMnazTjIqYrOGv8h8jxjg9+hJazIGZr9ZvoCcA= +github.com/coinbase/rosetta-sdk-go v0.7.9/go.mod h1:0/knutI7XGVqXmmH4OQD8OckFrbQ8yMsUZTG7FXCR2M= +github.com/confio/ics23/go v0.7.0 h1:00d2kukk7sPoHWL4zZBZwzxnpA2pec1NPdwbSokJ5w8= +github.com/confio/ics23/go v0.7.0/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg= +github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ= +github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI= +github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q= +github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0= +github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg= github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= -github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.45.1 h1:PY79YxPea5qlRLExRnzg8/rT1Scc8GGgRs22p7DX99Q= -github.com/cosmos/cosmos-sdk v0.45.1/go.mod h1:XXS/asyCqWNWkx2rW6pSuen+EVcpAFxq6khrhnZgHaQ= +github.com/cosmos/cosmos-proto v1.0.0-alpha7 h1:yqYUOHF2jopwZh4dVQp3xgqwftE5/2hkrwIV6vkUbO0= +github.com/cosmos/cosmos-proto v1.0.0-alpha7/go.mod h1:dosO4pSAbJF8zWCzCoTWP7nNsjcvSUBQmniFxDg5daw= +github.com/cosmos/cosmos-sdk v0.46.1 h1:7vUZXMyrmEb4xtBYpz1TobtrcnpgiZTi+tVjc0XWB4o= +github.com/cosmos/cosmos-sdk v0.46.1/go.mod h1:2+o8Qw8qnE02V+lQVZDJFQ8tri/hsiA5GmWaPERqVa0= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= -github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y= -github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w= +github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4Y= +github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= +github.com/cosmos/iavl v0.19.1 h1:3gaq9b6SjiB0KBTygRnAvEGml2pQlu1TH8uma5g63Ys= +github.com/cosmos/iavl v0.19.1/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ledger-cosmos-go v0.11.1 h1:9JIYsGnXP613pb2vPjFeMMjBI5lEDsEaF6oYorTy6J4= github.com/cosmos/ledger-cosmos-go v0.11.1/go.mod h1:J8//BsAGTo3OC/vDLjMRFLW6q0WAaXvHnVc7ZmE8iUY= github.com/cosmos/ledger-go v0.9.2 h1:Nnao/dLwaVTk1Q5U9THldpUMMXU94BOTWPddSmVB6pI= github.com/cosmos/ledger-go v0.9.2/go.mod h1:oZJ2hHAZROdlHiwTg4t7kP+GKIIkBT+o6c9QWFanOyI= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/creachadair/taskgroup v0.3.2 h1:zlfutDS+5XG40AOxcHDSThxKzns8Tnr9jnr6VqkYlkM= +github.com/creachadair/taskgroup v0.3.2/go.mod h1:wieWwecHVzsidg2CsUnFinW1faVN4+kq+TDlRJQ0Wbk= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/cyphar/filepath-securejoin v0.2.2/go.mod h1:FpkQEhXnPnOthhzymB7CGsFk2G9VLXONKD9G7QGMM+4= -github.com/danieljoos/wincred v1.0.2 h1:zf4bhty2iLuwgjgpraD2E9UbvO+fe54XXGJbOwe23fU= -github.com/danieljoos/wincred v1.0.2/go.mod h1:SnuYRW9lp1oJrZX/dXJqr0cPK5gYXqx3EJbmjhLdK9U= +github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= +github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0= +github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0= +github.com/dave/jennifer v1.2.0/go.mod h1:fIb+770HOpJ2fmN9EPPKOqm1vMGhB+TwXKMZhrIygKg= github.com/davecgh/go-spew v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= +github.com/deckarep/golang-set v1.8.0/go.mod h1:5nI87KwE7wgsBU1F4GKAw2Qod7p5kyS383rP6+o6qqo= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= +github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs= github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218= +github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M= +github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f h1:U5y3Y5UE0w7amNe7Z5G/twsBW0KEalRQXZzf8ufSh9I= github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f/go.mod h1:xH/i4TFMt8koVQZ6WFms69WAsDWr2XsYL3Hkl7jkoLE= -github.com/dgraph-io/badger/v2 v2.2007.2 h1:EjjK0KqwaFMlPin1ajhP943VPENHJdEz1KLIegjaI3k= -github.com/dgraph-io/badger/v2 v2.2007.2/go.mod h1:26P/7fbL4kUZVEVKLAKXkBXKOydDmM2p1e+NhhnBCAE= +github.com/dgraph-io/badger/v2 v2.2007.4 h1:TRWBQg8UrlUhaFdco01nO2uXwzKS7zd+HVdwV/GHc4o= +github.com/dgraph-io/badger/v2 v2.2007.4/go.mod h1:vSw/ax2qojzbN6eXHIx6KPKtCSHJN/Uz0X0VPruTIhk= github.com/dgraph-io/ristretto v0.0.3-0.20200630154024-f66de99634de/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= -github.com/dgraph-io/ristretto v0.0.3 h1:jh22xisGBjrEVnRZ1DVTpBVQm0Xndu8sMl0CWDzSIBI= github.com/dgraph-io/ristretto v0.0.3/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70dGTu2u+Ahh6E= +github.com/dgraph-io/ristretto v0.1.0 h1:Jv3CGQHp9OjuMBSne1485aDpUkTKEcUqF+jm/LuerPI= +github.com/dgraph-io/ristretto v0.1.0/go.mod h1:fux0lOrBhrVCJd3lcTHsIJhq1T2rokOu6v9Vcb3Q9ug= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/dgryski/go-bitstream v0.0.0-20180413035011-3522498ce2c8/go.mod h1:VMaSuZ+SZcx/wljOQKvp5srsbCiKDEb6K2wC4+PiBmQ= github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= +github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= -github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw= -github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/dop251/goja v0.0.0-20200721192441-a695b0cdd498/go.mod h1:Mw6PkjjMXWbTj+nnj4s3QPXq1jaT0s5pC0iFD4+BOAA= +github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk= +github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= -github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b h1:HBah4D48ypg3J7Np4N+HY/ZR76fx3HEUGxDU6Uk39oQ= -github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b/go.mod h1:7BvyPhdbLxMXIYTFPLsyJRFMsKmOZnQmzh6Gb+uquuM= -github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= +github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM= +github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU= github.com/eapache/go-resiliency v1.1.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= -github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= +github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts= github.com/edsrzf/mmap-go v1.0.0/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= github.com/envoyproxy/go-control-plane v0.6.9/go.mod h1:SBwIajubJHhxtWwsL9s8ss4safvEdbitLhGGK48rN6g= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -285,43 +302,38 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.1/go.mod h1:AY7fTTXNdv/aJ2O5jwpxAPOWUZ7hQAEvzN5Pf27BkQQ= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/envoyproxy/protoc-gen-validate v0.6.2/go.mod h1:2t7qjJNvHPx8IjnBOzl9E9/baC+qXE/TeeyBRzgJDws= -github.com/ethereum/go-ethereum v1.9.25/go.mod h1:vMkFiYLHI4tgPw4k2j4MHKoovchFE8plZ0M9VMk4/oM= -github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51 h1:0JZ+dUmQeA8IIVUMzysrX4/AKuQwWhV2dYQuPZdvdSQ= -github.com/facebookgo/ensure v0.0.0-20160127193407-b4ab57deab51/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64= +github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0= +github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0= github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A= -github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg= -github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870 h1:E2s37DuLxFhQDg5gKsWoLBOB0n+ZW8s599zru8FJ2/Y= -github.com/facebookgo/subset v0.0.0-20150612182917-8dac2c3c4870/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0= -github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/fatih/color v1.10.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= -github.com/fatih/color v1.12.0/go.mod h1:ELkj/draVOlAH/xkhN6mQ50Qd0MPOk5AAr3maGEBuJM= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ= github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= -github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= github.com/franela/goblin v0.0.0-20200105215937-c9ffbefa60db/go.mod h1:7dvUGVsVBjqR7JHJk0brhHOZYGmfBYOrK0ZhYMEtBr4= -github.com/franela/goblin v0.0.0-20210519012713-85d372ac71e2/go.mod h1:VzmDKDJVZI3aJmnRI9VjAn9nJ8qPPsN1fqzr9dqInIo= github.com/franela/goreq v0.0.0-20171204163338-bcd34c9993f8/go.mod h1:ZhphrRTfi2rbfLwlschooIH4+wKKDR4Pdxhh+TRoA20= -github.com/frankban/quicktest v1.11.3/go.mod h1:wRf/ReqHper53s+kmmSZizM8NamnL3IM0I9ntUbOk+k= +github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -github.com/fsnotify/fsnotify v1.5.1 h1:mZcQUHVQUQWoPXXtuf9yuEXKudkV2sx1E06UadKWpgI= -github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5Ai1i3InKU= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= +github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= +github.com/getkin/kin-openapi v0.61.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M= github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= +github.com/glycerine/go-unsnap-stream v0.0.0-20180323001048-9f0cb55181dd/go.mod h1:/20jfyN9Y5QPEAprSgKAUr+glWDY39ZiUEAYOEv5dsE= +github.com/glycerine/goconvey v0.0.0-20190410193231-58a59202ab31/go.mod h1:Ogl1Tioa0aV7gstGFO7KhffUsb9M4ydbEbbxpcEDc24= +github.com/go-chi/chi/v5 v5.0.0/go.mod h1:BBug9lr0cqtdAhsu6R4AAdvufI0/XBzAQSsUqJpoZOs= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -331,14 +343,17 @@ github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgO github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-kit/log v0.2.0 h1:7i2K3eKTos3Vc0enKCfnVcgHh2olr/MyfboYq7cAcFw= github.com/go-kit/log v0.2.0/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= +github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= @@ -347,12 +362,10 @@ github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+ github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI= github.com/go-playground/validator/v10 v10.4.1 h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE= github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= -github.com/go-sourcemap/sourcemap v2.1.2+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= +github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg= github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/go-zookeeper/zk v1.0.2/go.mod h1:nOB03cncLtlp4t+UAkGSV+9beXP/akpekBwL+UX1Qcw= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0= github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo= github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8= @@ -362,17 +375,21 @@ github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/E github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0= github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2/go.mod h1:bBOAhwG1umN6/6ZUMtDFBMQR8jRg9O75tm9K00oMsK4= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/gogo/gateway v1.1.0 h1:u0SuhL9+Il+UbjM9VIE3ntfRujKbvVpFvNB4HbjeVQ0= github.com/gogo/gateway v1.1.0/go.mod h1:S7rR8FRQyG3QFESeSv4l2WnsyzlCLG0CzBbUUo/mbic= github.com/gogo/googleapis v1.1.0/go.mod h1:gf4bu3Q80BeJ6H1S1vYPm8/ELATdvryBaNFGgqEef3s= -github.com/golang-jwt/jwt/v4 v4.0.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= +github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= @@ -404,13 +421,15 @@ github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/golangci/lint-1 v0.0.0-20181222135242-d2cdd8c08219/go.mod h1:/X8TswGSh1pIozq4ZwCfxS0WA5JGXguxk94ar/4c87Y= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/flatbuffers v1.11.0/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= @@ -422,15 +441,19 @@ github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf/go.mod h1:HP5RmnzzSNb993RKQDq4+1A4ia9nllfqcQFTQJedwGI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa h1:Q75Upo5UN4JbPFURXZ8nLKYUvF85dyFRop/vQ0Rv+64= github.com/google/gofuzz v1.1.1-0.20200604201612-c04b05f3adfa/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/martian/v3 v3.2.1 h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ= github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/orderedcode v0.0.1 h1:UzfcAexk9Vhv8+9pNOgRu41f16lHq725vPwnSeiG/Us= github.com/google/orderedcode v0.0.1/go.mod h1:iVyU4/qPKHY5h/wSd6rZZCDcLJNxiWO6dvsYES2Sb20= @@ -443,6 +466,7 @@ github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= @@ -452,12 +476,17 @@ github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm4 github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= +github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= +github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= +github.com/googleapis/gax-go/v2 v2.4.0 h1:dS9eYAjhrE2RjmzYw2XAPvcXfmcQLtFEQWn0CR82awk= +github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= +github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= github.com/gorilla/handlers v1.5.1 h1:9lRY6j8DEeeBT10CvO9hGW0gmky0BprnvDI5vfhUHH4= github.com/gorilla/handlers v1.5.1/go.mod h1:t8XrUpc4KVXb7HGyJ4/cEnwQiaxrX/hz1Zv/4g96P1Q= @@ -466,22 +495,17 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gotestyourself/gotestyourself v2.2.0+incompatible/go.mod h1:zZKM6oeNM8k+FRljX1mnzVYeS8wiGgQyvST1/GafPbY= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= -github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.2.2/go.mod h1:EaizFBKfUKtMIF5iaDEhniwNedqGo9FuLFzppDr3uwI= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= -github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= @@ -492,79 +516,81 @@ github.com/gtank/merlin v0.1.1 h1:eQ90iG7K9pOhtereWsmyRJ6RAwcP4tHTDBHXNg+u5is= github.com/gtank/merlin v0.1.1/go.mod h1:T86dnYJhcGOh5BjZFCJWTDeTK7XW8uE+E21Cy/bIQ+s= github.com/gtank/ristretto255 v0.1.2 h1:JEqUCPA1NvLq5DwYtuzigd7ss8fwbYay9fi4/5uMzcc= github.com/gtank/ristretto255 v0.1.2/go.mod h1:Ph5OpO6c7xKUGROZfWVLiJf9icMDwUeIvY4OmlYW69o= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoPndWW5VkKPlCE= -github.com/hashicorp/consul/api v1.10.1/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= -github.com/hashicorp/consul/api v1.11.0/go.mod h1:XjsvQN+RJGWI2TWy1/kqaE16HrR2J/FWgkYjdZQsX9M= -github.com/hashicorp/consul/api v1.12.0/go.mod h1:6pVBMo0ebnYdt2S3H87XhekM/HHrUoTD2XXb/VrZVy0= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.8.0/go.mod h1:GBvyrGALthsZObzUGsfgHZQDXjg4lOjagTIwIR1vPms= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v0.12.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= -github.com/hashicorp/go-hclog v1.0.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= +github.com/hashicorp/go-getter v1.6.1 h1:NASsgP4q6tL94WH6nJxKWj8As2H/2kop/bB1d8JMyRY= +github.com/hashicorp/go-getter v1.6.1/go.mod h1:IZCrswsZPeWv9IkVnLElzRU/gz/QPi6pZHn4tv6vbwA= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= +github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= +github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= -github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d h1:dg1dEPuWpEqDnvIw251EVy4zlP8gWbsGj4BsUKCRpYs= +github.com/hashicorp/golang-lru v0.5.5-0.20210104140557-80c98217689d/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.1/go.mod h1:4gW7WsVCke5TE7EPeYliwHlRUyBtfCwuFwuMg2DmyNY= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.2.2/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= -github.com/hashicorp/memberlist v0.3.0/go.mod h1:MS2lj3INKhZjWNqd3N0m3J+Jxf3DAOnAH9VT3Sh9MUE= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.9.5/go.mod h1:UWDWwZeL5cuWDJdl0C6wrvrUwEqtQ4ZKBKKENpqIUyk= -github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4= -github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87 h1:uUjLpLt6bVvZ72SQc/B4dXcPBw4Vgd7soowdRl52qEM= -github.com/hdevalence/ed25519consensus v0.0.0-20210204194344-59a8610d2b87/go.mod h1:XGsKKeXxeRr95aEOgipvluMPlgjr7dGlk9ZTWOjcUcg= -github.com/holiman/uint256 v1.1.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= +github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 h1:aSVUgRRRtOrZOC1fYmY9gV0e9z/Iu+xNVSASWjsuyGU= +github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3/go.mod h1:5PC6ZNPde8bBqU/ewGZig35+UIZtw9Ytxez8/q5ZyFE= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= +github.com/holiman/uint256 v1.2.0/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= -github.com/hudl/fargo v1.4.0/go.mod h1:9Ai6uvFy5fQNq6VPKtg+Ceq1+eTY4nKUlR2JElEOcDo= -github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc= +github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= -github.com/iancoleman/strcase v0.2.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/improbable-eng/grpc-web v0.14.1 h1:NrN4PY71A6tAz2sKDvC5JCauENWp0ykG8Oq1H3cpFvw= -github.com/improbable-eng/grpc-web v0.14.1/go.mod h1:zEjGHa8DAlkoOXmswrNvhUGEYQA9UI7DhrGeHR1DMGU= +github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ= +github.com/improbable-eng/grpc-web v0.15.0/go.mod h1:1sy9HKV4Jt9aEs9JSnkWlRJPuPtwNr0l57L4f878wP8= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= +github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY= +github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI= +github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/influxdata/influxdb1-client v0.0.0-20200827194710-b269163b24ab/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= -github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= +github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk= +github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE= +github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= +github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo= +github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8= +github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= +github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= +github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jedisct1/go-minisign v0.0.0-20190909160543-45766022959e/go.mod h1:G1CVv03EnqU1wYL2dFwXxW2An0az9JTl/ZsqXQeBlkU= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= -github.com/jhump/protoreflect v1.9.0 h1:npqHz788dryJiR/l6K/RUQAyh2SwV91+d1dnh4RjO9w= -github.com/jhump/protoreflect v1.9.0/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= +github.com/jhump/protoreflect v1.12.1-0.20220721211354-060cc04fc18b h1:izTof8BKh/nE1wrKOrloNA5q4odOarjf+Xpe+4qow98= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= +github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= @@ -581,100 +607,101 @@ github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnr github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jsternberg/zap-logfmt v1.0.0/go.mod h1:uvPs/4X51zdkcm5jXl5SYoN+4RK21K8mysFmDaM/h+o= github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM= -github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc= +github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0= +github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4= +github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= +github.com/klauspost/compress v1.11.2/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= github.com/klauspost/compress v1.11.7/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs= -github.com/klauspost/compress v1.13.4/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= -github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc= -github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.15.9 h1:wKRjX6JRtDdrE9qwa4b/Cip7ACOshUI4smpCQanqjSY= +github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/cpuid v0.0.0-20170728055534-ae7887de9fa5/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= +github.com/klauspost/crc32 v0.0.0-20161016154125-cb6bfca970f6/go.mod h1:+ZoRqAPRLkC4NPOvfYeR5KNOrY6TD+/sAC3HXPZgDYg= +github.com/klauspost/pgzip v1.0.2-0.20170402124221-0bf5dcad4ada/go.mod h1:Ch1tH69qFZu15pkjo5kYi6mth2Zzwzt50oCQKQE9RUs= github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= +github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg= +github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k= +github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8= github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lib/pq v1.10.4 h1:SO9z7FRPzA03QhHKJrH5BXA6HU1rS4V2nIVrrNC1iYk= -github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/libp2p/go-buffer-pool v0.0.2 h1:QNK2iAFa8gjAe1SPz6mHSMuCcjs+X1wlHzeOSqcmlfs= -github.com/libp2p/go-buffer-pool v0.0.2/go.mod h1:MvaB6xw5vOrDl8rYZGLFdKAuk/hRoRZd1Vi32+RXyFM= +github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= +github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= +github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= +github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lucasjones/reggen v0.0.0-20180717132126-cdb49ff09d77/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4= -github.com/lyft/protoc-gen-star v0.5.3/go.mod h1:V0xaHgaf5oCCqmcxYcWiDfTiKsZsRc87/1qhoTACD8w= github.com/lyft/protoc-gen-validate v0.0.13/go.mod h1:XbGvPuh87YZc5TdIa2/I4pLk0QoUACkjt2znoq26NVQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo= +github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/matryer/moq v0.0.0-20190312154309-6cfb0558e1bd/go.mod h1:9ELz6aaclSIGnZBoaSLZ3NAl1VTufbOrXBPvtcy6WiQ= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12 h1:jF+Du6AlPIjs2BiUiQlKOX0rt3SujHxPnksPKZbaA40= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.9/go.mod h1:YNRxwqDuOph6SZLI9vUUz6OYw3QyUt7WiY2yME+cCiQ= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-sqlite3 v1.14.9/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-sqlite3 v1.11.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= +github.com/mattn/go-tty v0.0.0-20180907095812-13ff1204f104/go.mod h1:XPvLUNfbS4fJH25nqRHfWLMa1ONC8Amw+mIA639KxkE= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 h1:I0XW9+e1XWDxdcEniV4rQAIOPUGDq67JSCiRCgGCZLI= +github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/miekg/dns v1.1.43/go.mod h1:+evo5L0630/F6ca/Z9+GAqzhjGyn8/c+TBaOyfEl0V4= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643 h1:hLDRPB66XQT/8+wG9WsDpiCvZf1yKO7sz7scAjSlBa0= github.com/mimoo/StrobeGo v0.0.0-20181016162300-f8f6d4d2b643/go.mod h1:43+3pMjjKimDBf5Kr4ZFNGbLql1zKkbImw+fZbw3geM= -github.com/minio/highwayhash v1.0.1/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/minio/highwayhash v1.0.2 h1:Aak5U0nElisjDCfPSG79Tgzkn2gl66NxOMspRrKnA/g= github.com/minio/highwayhash v1.0.2/go.mod h1:BQskDq+xkJ12lmlUUi7U0M5Swg3EWR+dLTk+kldvVxY= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.3.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.2/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.4.3 h1:OVowDSCllw/YjdLkam3/sm7wEtOy59d8ndGgCcyj8cs= github.com/mitchellh/mapstructure v1.4.3/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/moby/sys/mountinfo v0.4.1/go.mod h1:rEr8tzG/lsIZHBtN/JjGG+LMYx9eXgW2JI+6q0qou+A= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -682,7 +709,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mrunalp/fileutils v0.5.0/go.mod h1:M1WthSahJixYnrXQl/DFQuteStB1weuxD2QJNHXfbSQ= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/mschoch/smat v0.0.0-20160514031455-90eadee771ae/go.mod h1:qAyveg+e4CE+eKJXWVjKXM4ck2QobLqTDytGJbLLhJg= github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs= github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= @@ -693,89 +721,61 @@ github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= github.com/nats-io/jwt v0.3.0/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= github.com/nats-io/jwt v0.3.2/go.mod h1:/euKqTS1ZD+zzjYrY7pseZrTtWQSjujC7xjPc8wL6eU= -github.com/nats-io/jwt v1.2.2/go.mod h1:/xX356yQA6LuXI9xWW7mZNpxgF2mBmGecH+Fj34sP5Q= -github.com/nats-io/jwt/v2 v2.0.3/go.mod h1:VRP+deawSXyhNjXmxPCHskrR6Mq50BqpEI5SEcNiGlY= github.com/nats-io/nats-server/v2 v2.1.2/go.mod h1:Afk+wRZqkMQs/p45uXdrVLuab3gwv3Z8C4HTBu8GD/k= -github.com/nats-io/nats-server/v2 v2.5.0/go.mod h1:Kj86UtrXAL6LwYRA6H4RqzkHhK0Vcv2ZnKD5WbQ1t3g= github.com/nats-io/nats.go v1.9.1/go.mod h1:ZjDU1L/7fJ09jvUSRVBR2e7+RnLiiIQyqyzEE/Zbp4w= -github.com/nats-io/nats.go v1.12.1/go.mod h1:BPko4oXsySz4aSWeFgOHLZs3G4Jq4ZAyE6/zMCxRT6w= github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= github.com/nats-io/nkeys v0.1.3/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= -github.com/nats-io/nkeys v0.2.0/go.mod h1:XdZpAbhgyyODYqjTawOnIOI7VlbKSarI9Gfy1tqEu/s= -github.com/nats-io/nkeys v0.3.0/go.mod h1:gvUNGjVcM2IPr5rCsRsC6Wb3Hr2CQAm08dsxtV6A5y4= github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= -github.com/neilotoole/errgroup v0.1.5/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/neilotoole/errgroup v0.1.6/go.mod h1:Q2nLGf+594h0CLBs/Mbg6qOr7GtqDK7C2S41udRnToE= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= +github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= -github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= -github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/olekukonko/tablewriter v0.0.0-20170122224234-a0225b3f23b5/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= +github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA= github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= -github.com/onsi/ginkgo v1.16.2/go.mod h1:CObGmKUOKaSC0RjmoAK7tKyn4Azo5P2IWuoMnvwxz1E= -github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc= -github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0= github.com/onsi/gomega v1.4.1/go.mod h1:C1qb7wdrVGGVU+Z6iS04AVkA3Q65CEZX59MT0QO5uiA= github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= +github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE= github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= -github.com/onsi/gomega v1.13.0 h1:7lLHu94wT9Ij0o6EWWclhu0aOh32VxhkwEJvzuWPeak= -github.com/onsi/gomega v1.13.0/go.mod h1:lRk9szgn8TxENtWd0Tp4c3wjlRfMTMH27I+3Je41yGY= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= -github.com/opencontainers/go-digest v1.0.0-rc1/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= -github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= -github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= -github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= -github.com/opencontainers/runc v1.0.3 h1:1hbqejyQWCJBvtKAfdO0b1FmaEf2z/bxnjqbARass5k= -github.com/opencontainers/runc v1.0.3/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0= -github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0= -github.com/opencontainers/selinux v1.8.2/go.mod h1:MUIHuUEvKB1wtJjQdOyYRgOnLD2xAPP8dBsCoU0KuF8= +github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec= +github.com/opencontainers/runc v1.1.3 h1:vIXrkId+0/J2Ymu2m7VjGvbSlAId9XNRPhn2p4b+d8w= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.0.3-0.20180606204148-bd9c31933947/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxSfWAKL3wpBW7V8scJMt8N8gnaMCS9E/cA= github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= -github.com/openzipkin/zipkin-go v0.2.5/go.mod h1:KpXfKdgRDnnhsxw4pNIH9Md5lyFqKUa4YDFlwRYAMyE= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= -github.com/ory/dockertest v3.3.5+incompatible/go.mod h1:1vX4m9wsvi00u5bseYwXaSnhNrne+V0E6LAcBILJdPs= -github.com/otiai10/copy v1.6.0 h1:IinKAryFFuPONZ7cm6T6E2QX/vcJwSnlaA5lfoaXIiQ= -github.com/otiai10/copy v1.6.0/go.mod h1:XWfuS3CrI0R6IE0FbgHsEazaXO8G0LpMp9o8tos0x4E= -github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= -github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= -github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= -github.com/otiai10/mint v1.3.2/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= +github.com/paulbellamy/ratecounter v0.2.0/go.mod h1:Hfx1hDpSGoqxkVVpBi/IlYD7kChlfo5C6hzIHwPqfFE= github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pelletier/go-toml v1.9.4 h1:tjENF6MfZAg8e4ZmZTeWaWiT2vXtsoO6+iuOjFhECwM= -github.com/pelletier/go-toml v1.9.4/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8= +github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= +github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw= +github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI= github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac= -github.com/performancecopilot/speed/v4 v4.0.0/go.mod h1:qxrSyuDGrTOWfV+uKRFhfxw6h/4HXRGUiZiufxo49BM= +github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ= github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o= +github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU= github.com/pierrec/lz4 v1.0.2-0.20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= @@ -784,22 +784,21 @@ github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= +github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg= +github.com/pkg/term v0.0.0-20180730021639-bffc007b7fd5/go.mod h1:eCbImbZ95eXtAUIbLAuAVnBnwf83mjf6QIVH8SHYwqQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs= -github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.3.0/go.mod h1:hJaj2vgQTGQmVCsAACORcieXFeDPbaTKGT+JTgUa3og= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.8.0/go.mod h1:O9VU6huf47PktckDQfMTX0Y8tY0/7TSWwj+ITvv0TnM= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.1 h1:ZiaPsmm9uiBeaSMRznKsCDNtPCS0T3JVDGF+06gjBzk= github.com/prometheus/client_golang v1.12.1/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= +github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= @@ -809,30 +808,25 @@ github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.6.0/go.mod h1:eBmuwkDJBwy6iBfxCBob6t6dR6ENT/y+J+Zk0j9GMYc= github.com/prometheus/common v0.7.0/go.mod h1:DjGbpBbp5NYNiECxcL/VnbXCCaQpKd3tt26CguLLsqA= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.14.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.15.0/go.mod h1:U+gB1OBLb1lF3O42bTCL+FK18tX9Oar16Clt/msog/s= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.30.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.34.0 h1:RBmGO9d/FVjqHT0yUGQwBJhkwKV+wPCn7KGpvfab0uE= +github.com/prometheus/common v0.34.0/go.mod h1:gB3sOl7P0TvJabZpLY5uQMpUqRCPPCyRLCZYc7JZTNE= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.2.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.3.0/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rakyll/statik v0.1.7 h1:OF3QCZUuyPxuGEP7B4ypUa7sB/iHtqOTDYZXGM8KOdQ= github.com/rakyll/statik v0.1.7/go.mod h1:AlZONWzMtEnMs7W4e/1LURLiI49pIMmp6V9Unghqrcc= @@ -843,62 +837,54 @@ github.com/regen-network/cosmos-proto v0.3.1 h1:rV7iM4SSFAagvy8RiyhiACbWEGotmqzy github.com/regen-network/cosmos-proto v0.3.1/go.mod h1:jO0sVX6a1B36nmE8C9xBFXpNwWejXC7QqCOnH3O0+YM= github.com/regen-network/protobuf v1.3.3-alpha.regen.1 h1:OHEc+q5iIAXpqiqFKeLpu5NwTIkVXUs48vFMwzqpqY4= github.com/regen-network/protobuf v1.3.3-alpha.regen.1/go.mod h1:2DjTFR1HhMQhiWC5sZ4OhQ3+NtdbZ6oBDKQwq5Ou+FI= +github.com/retailnext/hllpp v1.0.1-0.20180308014038-101a6d2f8b52/go.mod h1:RDpi1RftBQPUCDRw6SmxeaREsAaRKnOclghuzp/WRzc= github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= +github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U= github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.23.0 h1:UskrK+saS9P9Y789yNNulYKdARjPZuS35B8gJF2x60g= -github.com/rs/zerolog v1.23.0/go.mod h1:6c7hFfxPOy7TacJc4Fcdi24/J0NKYGzjG8FWRI916Qo= +github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs= +github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sagikazarmark/crypt v0.3.0/go.mod h1:uD/D+6UF4SrIR1uGEv7bBNkNqLGqUr43MRiaGWX1Nig= -github.com/sagikazarmark/crypt v0.4.0/go.mod h1:ALv2SRj7GxYV4HO9elxH9nS6M9gW+xDNxqmyJ6RfDFM= github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4= github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/seccomp/libseccomp-golang v0.9.1/go.mod h1:GbW5+tmTXfcxTToHLXlScSlAvWlF4P2Ca7zGrPiEpWo= github.com/segmentio/fasthash v1.0.3/go.mod h1:waKX8l2N8yckOgmSsXJi7x1ZfdKZ4x7KRMzBtS3oedY= -github.com/shirou/gopsutil v2.20.5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= +github.com/segmentio/kafka-go v0.1.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= +github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfPOCvTvk+EJo= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= -github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= -github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/snikch/goodman v0.0.0-20171125024755-10e37e294daa/go.mod h1:oJyF+mSPHbB5mVY2iO9KV3pTt/QbIkGaO8gQ2WrDbP4= github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= github.com/sony/gobreaker v0.4.1/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/afero v1.3.3/go.mod h1:5KUK8ByomD5Ti5Artl0RtHeI5pTF7MIDuXL3yY520V4= -github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= +github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo= +github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo= github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA= -github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w= +github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU= github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ= github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/cobra v1.0.0/go.mod h1:/6GTrnGXV9HjY+aR4k0oJ5tcvakLuG6EuKReYlHNrgE= -github.com/spf13/cobra v1.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk= -github.com/spf13/cobra v1.3.0 h1:R7cSvGu+Vv+qX0gW5R/85dx2kmmJT5z5NM8ifdYjdn0= -github.com/spf13/cobra v1.3.0/go.mod h1:BrRVncBjOJa/eUcVVm9CE+oC6as8k+VYr4NY7WCi9V4= +github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU= +github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM= github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= @@ -907,84 +893,74 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/yZzE= -github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.7.1/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= -github.com/spf13/viper v1.10.0/go.mod h1:SoyBPwAtKDzypXNDFKN5kzH7ppppbGZtls1UpIy5AsM= -github.com/spf13/viper v1.10.1 h1:nuJZuYpG7gTj/XqiUwg8bA0cp1+M2mC3J4g5luUYBKk= -github.com/spf13/viper v1.10.1/go.mod h1:IGlFPqhNAPKRxohIzWpI5QEy4kuI7tcl5WvR+8qy1rU= +github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ= +github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= -github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= github.com/streadway/amqp v0.0.0-20190404075320-75d898a42a94/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= -github.com/streadway/amqp v1.0.0/go.mod h1:AZpEONHx3DKn8O/DFsRAY58/XVQiIPMTMB1SddzLXVw= github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= -github.com/streadway/handy v0.0.0-20200128134331-0f66f006fb2e/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0 h1:Hbg2NidpLE8veEBkEZTL3CvlkUIVzuU9jDplZO54c48= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= +github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635/go.mod h1:hkRG7XYTFWNJGYcbNJQlaLq0fg1yr4J4t/NcTQtrfww= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca h1:Ld/zXl5t4+D69SiV4JoN7kkfvJdOWlPpfxrzxpLMoUk= -github.com/syndtr/goleveldb v1.0.1-0.20200815110645-5c35d600f0ca/go.mod h1:u2MKkTVTVJWe5D1rCvame8WqhBd88EuIwODJZ1VHCPM= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c h1:g+WoO5jjkqGAzHWCjJB1zZfXPIAaDpzXIEJ0eS6B5Ok= -github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c/go.mod h1:ahpPrc7HpcfEWDQRZEmnXMzHY03mLDYMCxeDzy46i+8= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/subosito/gotenv v1.4.0 h1:yAzM1+SmVcz5R4tXGsNMu1jUl2aOJXoiWUCEwwnGrvs= +github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7vWWGaGo= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s= github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI= github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk= github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E= github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME= -github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0= -github.com/tendermint/tendermint v0.34.16 h1:J2h7SwKWEv/cPuby2gjFhY00L2nLCoJOVFZvDbVeA8Q= -github.com/tendermint/tendermint v0.34.16/go.mod h1:n0G22GynfeXTYbrn2IeLeB+oqsAe6R6jl4vZxZ1Y8F4= -github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw= -github.com/tendermint/tm-db v0.6.6 h1:EzhaOfR0bdKyATqcd5PNeyeq8r+V4bRPHBfyFdD9kGM= -github.com/tendermint/tm-db v0.6.6/go.mod h1:wP8d49A85B7/erz/r4YbKssKw6ylsO/hKtFk7E1aWZI= -github.com/tendermint/tmlibs v0.9.0 h1:3aU/D2v3aecqpODOuBXCfi950bHTefD5Pps5X3XuJDc= -github.com/tendermint/tmlibs v0.9.0/go.mod h1:4L0tAKpLTioy14VnmbXYTLIJN0pCMiehxDMdN6zZfM8= -github.com/tidwall/gjson v1.6.7/go.mod h1:zeFuBCIqD4sN/gmqBzZ4j7Jd6UcA2Fc56x7QFsv+8fI= +github.com/tendermint/tendermint v0.34.21 h1:UiGGnBFHVrZhoQVQ7EfwSOLuCtarqCSsRf8VrklqB7s= +github.com/tendermint/tendermint v0.34.21/go.mod h1:XDvfg6U7grcFTDx7VkzxnhazQ/bspGJAn4DZ6DcLLjQ= +github.com/tendermint/tm-db v0.6.7 h1:fE00Cbl0jayAoqlExN6oyQJ7fR/ZtoVOmvPJ//+shu8= +github.com/tendermint/tm-db v0.6.7/go.mod h1:byQDzFkZV1syXr/ReXS808NxA2xvyuuVgXOJ/088L6I= +github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= github.com/tidwall/gjson v1.14.0 h1:6aeJ0bzojgWLa82gDQHcx3S0Lr/O51I9bJ5nv6JFx5w= github.com/tidwall/gjson v1.14.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= -github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= -github.com/tidwall/pretty v1.0.2/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= -github.com/tidwall/sjson v1.1.4/go.mod h1:wXpKXu8CtDjKAZ+3DrKY5ROCorDFahq8l0tey/Lx1fg= +github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= +github.com/tinylib/msgp v1.0.2/go.mod h1:+d+yLhGm8mzTaHzB+wgMYrodPfmZrzkirds8fDWklFE= github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg= +github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= +github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= -github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ttacon/chalk v0.0.0-20160626202418-22c06c80ed31/go.mod h1:onvgF043R+lC5RZ8IT9rBXDaEDnpnw/Cl+HFiw+v/7Q= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/tv42/httpunix v0.0.0-20191220191345-2ba4b9c3382c/go.mod h1:hzIxponao9Kjc7aWznkXaL4U4TWaDSs8zcsY4Ka08nM= github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= github.com/tyler-smith/go-bip39 v1.0.2/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= -github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc= github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo= github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs= github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ulikunitz/xz v0.5.8 h1:ERv8V6GKqVi23rgu5cj9pVfVzJbOqAY2Ntl88O6c2nQ= +github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= -github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df/go.mod h1:JP3t17pCcGlemwknint6hfoeCVQrEMVwxRLRjXpq+BU= -github.com/vmihailenco/msgpack/v5 v5.1.4/go.mod h1:C5gboKD0TJPqWDTVTtrQNfRbiBwHZGo8UTqP/9/XvLI= -github.com/vmihailenco/tagparser v0.1.2/go.mod h1:OeAg3pn3UbLjkWt+rN9oFYB6u/cQgqMEUPoW2WPyhdI= -github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8= +github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= +github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/willf/bitset v1.1.3/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= @@ -992,6 +968,7 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1: github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -999,21 +976,13 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8= github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= -go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266 h1:O9XLFXGkVswDFmH9LaYpqu+r/AAFWqr0DL6V00KEVFg= +github.com/zondax/hid v0.9.1-0.20220302062450-5552068d2266/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= -go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ= go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738/go.mod h1:dnLIgRNXwCJa5e+c6mIZCrds/GIG4ncV9HhK5PX7jPg= -go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= -go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs= -go.etcd.io/etcd/client/v3 v3.5.0/go.mod h1:AIKXXVX/DQXtfTEqBryiLTUXwON+GuvO6Z7lLS/oTh0= go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.20.2/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= @@ -1022,23 +991,18 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0 h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M= go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/goleak v1.1.11-0.20210813005559-691160354723/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.7.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= +go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI= golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1048,30 +1012,27 @@ golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190909091759-094676da4a83/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200115085410-6d4e4cb37c7d/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210314154223-e6e6c4f2bb5b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210915214749-c084706c2272 h1:3erb+vDS8lU1sxfDHF4/hhWyaXnhIaO+7RgL4fDZORA= -golang.org/x/crypto v0.0.0-20210915214749-c084706c2272/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= +golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= +golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM= +golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190731235908-ec7cb31e5a56/go.mod h1:JhuoJpWY28nO4Vef9tZUw9qufEGTyX1+7lmHxV5q5G4= golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= @@ -1080,6 +1041,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA= +golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -1097,23 +1060,19 @@ golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPI golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mobile v0.0.0-20200801112145-973feb4309de/go.mod h1:skQtrUTUwhdJvXM/2KKJzY8pDgNr9I/FOMqDVRPBUS4= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191209134235-331c550502dd/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181011144130-49bb7cea24b1/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1125,14 +1084,12 @@ golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -1150,26 +1107,31 @@ golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200813134508-3edf25e44fcc/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210220033124-5f55cee0dc0d/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210917221730-978cfadd31cf/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b h1:MWaHNqZy3KTpuTMAGvv+Kw+ylsEpmyJZizz1dqxnu28= -golang.org/x/net v0.0.0-20211208012354-db4efeb81f4b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220520000938-2e3eb7b945c2/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/net v0.0.0-20220726230323-06994584191e h1:wOQNKh1uuDGRnmgF0jDxh7ctgGy/3P4rYWQRVJD4/Yg= +golang.org/x/net v0.0.0-20220726230323-06994584191e/go.mod h1:AaygXjzTFtRAg2ttMY5RMuhpJ3cNnI0XpyFJD1iQRSM= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1181,13 +1143,15 @@ golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5 h1:OSnWWcOd/CtWQC2cYSBgbTSJv3ciqd8r54ySIW2y3RE= +golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1199,6 +1163,7 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1217,30 +1182,24 @@ golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191115151921-52ab43148777/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191210023423-ac6580df4449/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191220142924-d4481acd189f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200107162124-548cf772de50/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1257,27 +1216,26 @@ golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200814200057-3d37ad5750ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200824131525-c12d262b63d8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200826173525-f9321e4c35a6/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200909081042-eff7692f9009/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210426230700-d19ff857e887/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -1286,21 +1244,32 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210903071746-97244b99971b/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220517195934-5e4e11fc645e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220727055044-e65921a090b8 h1:dyU22nBWzrmTQxtNrr4dzVOvaw35nUYE279vF9UmsI8= +golang.org/x/sys v0.0.0-20220727055044-e65921a090b8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc= +golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1315,8 +1284,8 @@ golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxb golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20200416051211-89c76fbcd5d1/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20201208040808-7e3f01d25324/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= @@ -1334,12 +1303,10 @@ golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgw golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= @@ -1348,7 +1315,7 @@ golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117012304-6edc0a871e69/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200108203644-89082a384178/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= @@ -1363,10 +1330,8 @@ golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWc golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= @@ -1375,9 +1340,9 @@ golang.org/x/tools v0.0.0-20201022035929-9cf592e881e9/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= @@ -1387,10 +1352,14 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df h1:5Pf6pFKu98ODmgnpvkJ3kFUOQGGLIzLIkbzUHp47618= +golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/gonum v0.0.0-20181121035319-3f7ecaa7e8ca/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.6.0/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU= +gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk= @@ -1415,7 +1384,6 @@ google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34q google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= @@ -1424,10 +1392,16 @@ google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6 google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.59.0/go.mod h1:sT2boj7M9YJxZzgeZqXogmhfmRWDtPzT31xkieUbuZU= google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.62.0/go.mod h1:dKmwPCydfsad4qCH08MSdgWjfHOyfpd4VtDGgRFdavw= google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= +google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= +google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= +google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= +google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= +google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= +google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= +google.golang.org/api v0.81.0 h1:o8WF5AvfidafWbFjsRyupxyEQJNUWxLZJCK5NXrxZZ8= +google.golang.org/api v0.81.0/go.mod h1:FA6Mb/bZxj706H2j+j2d6mHEEaHBmbbWnkfvmorOCko= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1435,6 +1409,7 @@ google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7 google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= @@ -1443,6 +1418,7 @@ google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190530194941-fb225487d101/go.mod h1:z3L6/3dTEVtUr6QSP8miRzeRqwQOioJ9I66odjN4I7s= +google.golang.org/genproto v0.0.0-20190716160619-c506a9f90610/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= @@ -1450,6 +1426,7 @@ google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvx google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200108215221-bd8f9a0ef82f/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= @@ -1472,12 +1449,13 @@ google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201119123407-9b1e624d6bc4/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= @@ -1497,17 +1475,27 @@ google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEc google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211028162531-8db9c33dc351/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211203200212-54befc351ae9/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw= -google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= +google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= +google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= +google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b h1:SfSkJugek6xm7lWywqth4r2iTrYLpD8lOj1nMIIhMNM= +google.golang.org/genproto v0.0.0-20220725144611-272f38e5d71b/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.19.1/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= @@ -1541,10 +1529,12 @@ google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnD google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.43.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.44.0 h1:weqSxi/TMs1SqFRMHCtBgXRs8k3X39QIDEZ0pRcttUg= google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w= +google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -1556,26 +1546,25 @@ google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2 google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U= gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= +gopkg.in/cheggaaa/pb.v1 v1.0.27/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= -gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/ini.v1 v1.66.6 h1:LATuAqN/shcYAOkv3wl2L4rkaKqkcgTBQjOyYDvcPKI= +gopkg.in/ini.v1 v1.66.6/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= @@ -1594,8 +1583,9 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= @@ -1605,12 +1595,17 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.1.3/go.mod h1:NgwopIslSNH47DimFoV78dnkksY2EFtX0ajyb3K/las= nhooyr.io/websocket v1.8.6 h1:s+C3xAMLwGmlI31Nyn/eAehUlZPwfYZu2JXM621Q5/k= nhooyr.io/websocket v1.8.6/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= +pgregory.net/rapid v0.4.7 h1:MTNRktPuv5FNqOO151TM9mDTa+XHcX6ypYeISDVD14g= +pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA= sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o= -sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU= diff --git a/modules/coinswap/client/rest/query.go b/modules/coinswap/client/rest/query.go deleted file mode 100644 index 13a69943..00000000 --- a/modules/coinswap/client/rest/query.go +++ /dev/null @@ -1,51 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/coinswap/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // query pool - r.HandleFunc(fmt.Sprintf("/%s/pools/{%s}", types.ModuleName, RestPoolID), queryPoolsHandlerFn(cliCtx)).Methods("GET") -} - -// HTTP request handler to query liquidity information. -func queryPoolsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - denom := vars[RestPoolID] - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryPoolParams{ - LptDenom: denom, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryPool) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/coinswap/client/rest/rest.go b/modules/coinswap/client/rest/rest.go deleted file mode 100644 index 45215575..00000000 --- a/modules/coinswap/client/rest/rest.go +++ /dev/null @@ -1,63 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// Rest variable names -// nolint -const ( - RestPoolID = "denom" -) - -// RegisterHandlers registers asset-related REST handlers to a router -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -// AddLiquidityReq defines the properties of a add liquidity request's body -type AddLiquidityReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ID string `json:"id" yaml:"id"` // the unique liquidity id - MaxToken string `json:"max_token" yaml:"max_token"` // token to be deposited as liquidity with an upper bound for its amount - ExactStandardAmt string `json:"exact_standard_amt" yaml:"exact_standard_amt"` // exact amount of standard token being add to the liquidity pool - MinLiquidity string `json:"min_liquidity" yaml:"min_liquidity"` // lower bound UNI sender is willing to accept for deposited coins - Deadline string `json:"deadline" yaml:"deadline"` // deadline duration, e.g. 10m - Sender string `json:"sender" yaml:"sender"` // msg sender -} - -// RemoveLiquidityReq defines the properties of a remove liquidity request's body -type RemoveLiquidityReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ID string `json:"id" yaml:"id"` // the unique liquidity id - MinToken string `json:"min_token" yaml:"min_token"` // coin to be withdrawn with a lower bound for its amount - WithdrawLiquidity string `json:"withdraw_liquidity" yaml:"withdraw_liquidity"` // amount of UNI to be burned to withdraw liquidity from a reserve pool - MinStandardAmt string `json:"min_standard_amt" yaml:"min_standard_amt"` // minimum amount of the native asset the sender is willing to accept - Deadline string `json:"deadline" yaml:"deadline"` // deadline duration, e.g. 10m - Sender string `json:"sender" yaml:"sender"` // msg sender -} - -// Input defines the properties of order's input -type Input struct { - Address string `json:"address" yaml:"address"` // address of input - Coin sdk.Coin `json:"coin" yaml:"coin"` // coins of input -} - -// Output defines the properties of order's output -type Output struct { - Address string `json:"address" yaml:"address"` // address of output - Coin sdk.Coin `json:"coin" yaml:"coin"` // coins of output -} - -// SwapOrderReq defines the properties of a swap request's body -type SwapOrderReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Input Input `json:"input" yaml:"input"` // the amount the sender is trading - Output Output `json:"output" yaml:"output"` // the amount the sender is receiving - Deadline string `json:"deadline" yaml:"deadline"` // deadline for the transaction to still be considered valid -} diff --git a/modules/coinswap/client/rest/tx.go b/modules/coinswap/client/rest/tx.go deleted file mode 100644 index 15beb2b9..00000000 --- a/modules/coinswap/client/rest/tx.go +++ /dev/null @@ -1,215 +0,0 @@ -package rest - -import ( - "context" - "fmt" - "net/http" - "time" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/coinswap/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - // add liquidity - r.HandleFunc(fmt.Sprintf("/coinswap/liquidities/{%s}/deposit", RestPoolID), addLiquidityHandlerFn(cliCtx)).Methods("POST") - // remove liquidity - r.HandleFunc(fmt.Sprintf("/coinswap/liquidities/{%s}/withdraw", RestPoolID), removeLiquidityHandlerFn(cliCtx)).Methods("POST") - // post a buy order - r.HandleFunc("/coinswap/liquidities/buy", swapOrderHandlerFn(cliCtx, true)).Methods("POST") - // post a sell order - r.HandleFunc("/coinswap/liquidities/sell", swapOrderHandlerFn(cliCtx, false)).Methods("POST") -} - -// HTTP request handler to add liquidity. -func addLiquidityHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - denom := vars[RestPoolID] - - if err := sdk.ValidateDenom(denom); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req AddLiquidityReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Sender); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - duration, e := time.ParseDuration(req.Deadline) - if e != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, e.Error()) - return - } - - status, e := cliCtx.Client.Status(context.Background()) - if e != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, e.Error()) - return - } - deadline := status.SyncInfo.LatestBlockTime.Add(duration) - - maxToken, ok := sdk.NewIntFromString(req.MaxToken) - if !ok || !maxToken.IsPositive() { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid max token amount: "+req.MaxToken) - return - } - - exactStandardAmt, ok := sdk.NewIntFromString(req.ExactStandardAmt) - if !ok { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid exact standard token amount: "+req.ExactStandardAmt) - return - } - - minLiquidity, ok := sdk.NewIntFromString(req.MinLiquidity) - if !ok { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid min liquidity amount: "+req.MinLiquidity) - return - } - - msg := types.NewMsgAddLiquidity(sdk.NewCoin(denom, maxToken), exactStandardAmt, minLiquidity, deadline.Unix(), req.Sender) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -// HTTP request handler to remove liquidity. -func removeLiquidityHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - lptDenom := vars[RestPoolID] - - if err := sdk.ValidateDenom(lptDenom); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req RemoveLiquidityReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Sender); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - duration, e := time.ParseDuration(req.Deadline) - if e != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, e.Error()) - return - } - - status, e := cliCtx.Client.Status(context.Background()) - if e != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, e.Error()) - return - } - deadline := status.SyncInfo.LatestBlockTime.Add(duration) - - minToken, ok := sdk.NewIntFromString(req.MinToken) - if !ok { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid min token amount: "+req.MinToken) - return - } - - minStandard, ok := sdk.NewIntFromString(req.MinStandardAmt) - if !ok { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid min iris amount: "+req.MinStandardAmt) - return - } - - liquidityAmt, ok := sdk.NewIntFromString(req.WithdrawLiquidity) - if !ok || !liquidityAmt.IsPositive() { - rest.WriteErrorResponse(w, http.StatusBadRequest, "invalid liquidity amount: "+req.WithdrawLiquidity) - return - } - - msg := types.NewMsgRemoveLiquidity( - minToken, sdk.NewCoin(lptDenom, liquidityAmt), minStandard, deadline.Unix(), req.Sender, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -// HTTP request handler to post order. -func swapOrderHandlerFn(cliCtx client.Context, isBuyOrder bool) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req SwapOrderReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - senderAddress, err := sdk.AccAddressFromBech32(req.Input.Address) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - recipientAddress, err := sdk.AccAddressFromBech32(req.Output.Address) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - duration, err := time.ParseDuration(req.Deadline) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - input := types.Input{Address: senderAddress.String(), Coin: req.Input.Coin} - output := types.Output{Address: recipientAddress.String(), Coin: req.Output.Coin} - - status, e := cliCtx.Client.Status(context.Background()) - if e != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, e.Error()) - return - } - deadline := status.SyncInfo.LatestBlockTime.Add(duration) - - msg := types.NewMsgSwapOrder(input, output, deadline.Unix(), isBuyOrder) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/coinswap/client/rest/grpc_query_test.go b/modules/coinswap/client/testutil/grpc_query_test.go similarity index 99% rename from modules/coinswap/client/rest/grpc_query_test.go rename to modules/coinswap/client/testutil/grpc_query_test.go index 114933af..85f53396 100644 --- a/modules/coinswap/client/rest/grpc_query_test.go +++ b/modules/coinswap/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "context" @@ -13,8 +13,8 @@ import ( clienttx "github.com/cosmos/cosmos-sdk/client/tx" codectype "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" "github.com/cosmos/cosmos-sdk/types/tx" "github.com/cosmos/cosmos-sdk/types/tx/signing" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" @@ -41,9 +41,10 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) sdk.SetCoinDenomRegex(func() string { diff --git a/modules/coinswap/handler.go b/modules/coinswap/handler.go deleted file mode 100644 index 15c8b4b1..00000000 --- a/modules/coinswap/handler.go +++ /dev/null @@ -1,35 +0,0 @@ -package coinswap - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/irisnet/irismod/modules/coinswap/keeper" - "github.com/irisnet/irismod/modules/coinswap/types" -) - -// NewHandler returns a handler for all "coinswap" type messages. -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgAddLiquidity: - res, err := msgServer.AddLiquidity(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgSwapOrder: - res, err := msgServer.SwapCoin(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgRemoveLiquidity: - res, err := msgServer.RemoveLiquidity(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized %s message type: %T", types.ModuleName, msg) - } - } -} diff --git a/modules/coinswap/keeper/keeper.go b/modules/coinswap/keeper/keeper.go index 2c120779..24296d99 100644 --- a/modules/coinswap/keeper/keeper.go +++ b/modules/coinswap/keeper/keeper.go @@ -2,13 +2,15 @@ package keeper import ( "fmt" + "math/big" "strconv" + sdkmath "cosmossdk.io/math" gogotypes "github.com/gogo/protobuf/types" - "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -19,7 +21,7 @@ import ( // Keeper of the coinswap store type Keeper struct { cdc codec.BinaryCodec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey bk types.BankKeeper ak types.AccountKeeper paramSpace paramstypes.Subspace @@ -33,7 +35,7 @@ type Keeper struct { // - sending to and from ModuleAccounts func NewKeeper( cdc codec.BinaryCodec, - key sdk.StoreKey, + key storetypes.StoreKey, paramSpace paramstypes.Subspace, bk types.BankKeeper, ak types.AccountKeeper, @@ -68,7 +70,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // Swap execute swap order in specified pool func (k Keeper) Swap(ctx sdk.Context, msg *types.MsgSwapOrder) error { - var amount sdk.Int + var amount sdkmath.Int var err error standardDenom := k.GetStandardDenom(ctx) @@ -108,18 +110,21 @@ func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity) (sdk.C return sdk.Coin{}, sdkerrors.Wrapf(types.ErrInvalidDenom, "MaxToken: %s should not be StandardDenom", msg.MaxToken.String()) } - var mintLiquidityAmt sdk.Int - var depositToken sdk.Coin - var standardCoin = sdk.NewCoin(standardDenom, msg.ExactStandardAmt) - poolId := types.GetPoolId(msg.MaxToken.Denom) - pool, exists := k.GetPool(ctx, poolId) + var ( + mintLiquidityAmt sdkmath.Int + depositToken sdk.Coin + standardCoin = sdk.NewCoin(standardDenom, msg.ExactStandardAmt) + ) sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return sdk.Coin{}, err } + poolID := types.GetPoolId(msg.MaxToken.Denom) + pool, exists := k.GetPool(ctx, poolID) + // calculate amount of UNI to be minted for sender // and coin amount to be deposited if !exists { @@ -130,54 +135,63 @@ func (k Keeper) AddLiquidity(ctx sdk.Context, msg *types.MsgAddLiquidity) (sdk.C mintLiquidityAmt = msg.ExactStandardAmt if mintLiquidityAmt.LT(msg.MinLiquidity) { - return sdk.Coin{}, sdkerrors.Wrap(types.ErrConstraintNotMet, fmt.Sprintf("liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLiquidityAmt.String())) + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrConstraintNotMet, "liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLiquidityAmt.String()) } depositToken = sdk.NewCoin(msg.MaxToken.Denom, msg.MaxToken.Amount) pool = k.CreatePool(ctx, msg.MaxToken.Denom) - } else { - balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) - if err != nil { - return sdk.Coin{}, err - } + return k.addLiquidity(ctx, sender, pool.EscrowAddress, standardCoin, depositToken, pool.LptDenom, mintLiquidityAmt) + } - standardReserveAmt := balances.AmountOf(standardDenom) - tokenReserveAmt := balances.AmountOf(msg.MaxToken.Denom) - liquidity := k.bk.GetSupply(ctx, pool.LptDenom).Amount + balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) + if err != nil { + return sdk.Coin{}, err + } - mintLiquidityAmt = (liquidity.Mul(msg.ExactStandardAmt)).Quo(standardReserveAmt) + //pool exist but has no balances,so do same operations as firist addLiquidity(but without creating pool) + if balances == nil || balances.IsZero() { + mintLiquidityAmt = msg.ExactStandardAmt if mintLiquidityAmt.LT(msg.MinLiquidity) { - return sdk.Coin{}, sdkerrors.Wrap(types.ErrConstraintNotMet, fmt.Sprintf("liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLiquidityAmt.String())) + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrConstraintNotMet, "liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLiquidityAmt.String()) } - depositAmt := (tokenReserveAmt.Mul(msg.ExactStandardAmt)).Quo(standardReserveAmt).AddRaw(1) - depositToken = sdk.NewCoin(msg.MaxToken.Denom, depositAmt) + depositToken = sdk.NewCoin(msg.MaxToken.Denom, msg.MaxToken.Amount) + return k.addLiquidity(ctx, sender, pool.EscrowAddress, standardCoin, depositToken, pool.LptDenom, mintLiquidityAmt) + } - if depositAmt.GT(msg.MaxToken.Amount) { - return sdk.Coin{}, sdkerrors.Wrap(types.ErrConstraintNotMet, fmt.Sprintf("token amount not met, user expected: no more than %s, actual: %s", msg.MaxToken.String(), depositToken.String())) - } + // add liquidity + standardReserveAmt := balances.AmountOf(standardDenom) + tokenReserveAmt := balances.AmountOf(msg.MaxToken.Denom) + liquidity := k.bk.GetSupply(ctx, pool.LptDenom).Amount + if standardReserveAmt.IsZero() || tokenReserveAmt.IsZero() || liquidity.IsZero() { + return sdk.Coin{}, + sdkerrors.Wrapf(types.ErrConstraintNotMet, "liquidity pool invalid") } - reservePoolAddress, err := sdk.AccAddressFromBech32(pool.EscrowAddress) - if err != nil { - return sdk.Coin{}, err + mintLiquidityAmt = (liquidity.Mul(msg.ExactStandardAmt)).Quo(standardReserveAmt) + if mintLiquidityAmt.LT(msg.MinLiquidity) { + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrConstraintNotMet, "liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLiquidityAmt.String()) } + depositAmt := (tokenReserveAmt.Mul(msg.ExactStandardAmt)).Quo(standardReserveAmt).AddRaw(1) + depositToken = sdk.NewCoin(msg.MaxToken.Denom, depositAmt) - ctx.EventManager().EmitEvent( - sdk.NewEvent( - types.EventTypeAddLiquidity, - sdk.NewAttribute(types.AttributeValueSender, msg.Sender), - sdk.NewAttribute(types.AttributeValueTokenPair, types.GetTokenPairByDenom(msg.MaxToken.Denom, standardDenom)), - ), - ) - return k.addLiquidity(ctx, sender, reservePoolAddress, standardCoin, depositToken, pool.LptDenom, mintLiquidityAmt) + if depositAmt.GT(msg.MaxToken.Amount) { + return sdk.Coin{}, + sdkerrors.Wrapf(types.ErrConstraintNotMet, "token amount not met, user expected: no more than %s, actual: %s", msg.MaxToken.String(), depositToken.String()) + } + return k.addLiquidity(ctx, sender, pool.EscrowAddress, standardCoin, depositToken, pool.LptDenom, mintLiquidityAmt) } func (k Keeper) addLiquidity(ctx sdk.Context, sender sdk.AccAddress, - reservePoolAddress sdk.AccAddress, + poolAddress string, standardCoin, token sdk.Coin, lptDenom string, - mintLiquidityAmt sdk.Int, + mintLiquidityAmt sdkmath.Int, ) (sdk.Coin, error) { + reservePoolAddress, err := sdk.AccAddressFromBech32(poolAddress) + if err != nil { + return sdk.Coin{}, err + } + depositedTokens := sdk.NewCoins(standardCoin, token) // transfer deposited token into coinswaps Account if err := k.bk.SendCoins(ctx, sender, reservePoolAddress, depositedTokens); err != nil { @@ -193,13 +207,116 @@ func (k Keeper) addLiquidity(ctx sdk.Context, return sdk.Coin{}, err } + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeAddLiquidity, + sdk.NewAttribute(types.AttributeValueSender, sender.String()), + sdk.NewAttribute(types.AttributeValueTokenPair, types.GetTokenPairByDenom(token.Denom, standardCoin.Denom)), + ), + ) return mintToken, nil } +// AddUnilateralLiquidity adds liquidity unilaterally to the specified pool +func (k Keeper) AddUnilateralLiquidity(ctx sdk.Context, msg *types.MsgAddUnilateralLiquidity) (sdk.Coin, error) { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdk.Coin{}, err + } + + poolID := types.GetPoolId(msg.CounterpartyDenom) + pool, exist := k.GetPool(ctx, poolID) + if !exist { + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrReservePoolNotExists, "liquidity pool: %s ", poolID) + } + + poolAddr, err := sdk.AccAddressFromBech32(pool.EscrowAddress) + if err != nil { + return sdk.Coin{}, err + } + + balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) + if err != nil { + return sdk.Coin{}, err + } + + if msg.ExactToken.Denom != msg.CounterpartyDenom && msg.ExactToken.Denom != k.GetStandardDenom(ctx) { + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrInvalidDenom, "liquidity pool %s has no %s", poolID, msg.ExactToken.Denom) + } + + if balances == nil || balances.IsZero() { + return sdk.Coin{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "When the liquidity is empty, can not add unilateral liquidity") + } + + // square = ( token_balance + ( 1- fee_unilateral ) * exact_token ) / token_balance * lpt_balance^2 + // 1 - fee_unilateral = numerator / denominator + tokenBalanceAmt := balances.AmountOf(msg.ExactToken.Denom) + lptBalanceAmt := k.bk.GetSupply(ctx, pool.LptDenom).Amount + exactTokenAmt := msg.ExactToken.Amount + + deltaFeeUnilateral := sdk.OneDec().Sub(k.GetParams(ctx).UnilateralLiquidityFee) + numerator := sdkmath.NewIntFromBigInt(deltaFeeUnilateral.BigInt()) + denominator := sdkmath.NewIntWithDecimal(1, sdk.Precision) + + square := denominator.Mul(tokenBalanceAmt).Add(numerator.Mul(exactTokenAmt)).Mul(lptBalanceAmt).Mul(lptBalanceAmt).Quo(denominator.Mul(tokenBalanceAmt)) + + // lpt = square^0.5 - lpt_balance + var squareBigInt = &big.Int{} + squareBigInt.Sqrt(square.BigInt()) + mintLptAmt := sdkmath.NewIntFromBigInt(squareBigInt).Sub(lptBalanceAmt) + + if mintLptAmt.LT(msg.MinLiquidity) { + return sdk.Coin{}, sdkerrors.Wrapf(types.ErrConstraintNotMet, "liquidity amount not met, user expected: no less than %s, actual: %s", msg.MinLiquidity.String(), mintLptAmt.String()) + } + + // event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeAddUnilateralLiquidity, + sdk.NewAttribute(types.AttributeValueSender, msg.Sender), + sdk.NewAttribute(types.AttributeValueTokenUnilateral, msg.ExactToken.Denom), + sdk.NewAttribute(types.AttributeValueLptDenom, pool.LptDenom), + ), + ) + + return k.addUnilateralLiquidity(ctx, sender, poolAddr, msg.ExactToken, pool.LptDenom, mintLptAmt) +} + +func (k Keeper) addUnilateralLiquidity(ctx sdk.Context, + sender sdk.AccAddress, + poolAddr sdk.AccAddress, + exactToken sdk.Coin, + lptDenom string, + mintLptAmt sdkmath.Int, +) (sdk.Coin, error) { + // add liquidity + exactCoins := sdk.NewCoins(exactToken) + if err := k.bk.SendCoins(ctx, sender, poolAddr, exactCoins); err != nil { + return sdk.Coin{}, err + } + + // mint and send lpt + mintLpt := sdk.NewCoin(lptDenom, mintLptAmt) + mintLpts := sdk.NewCoins(mintLpt) + if err := k.bk.MintCoins(ctx, types.ModuleName, mintLpts); err != nil { + return sdk.Coin{}, err + } + if err := k.bk.SendCoinsFromModuleToAccount(ctx, types.ModuleName, sender, mintLpts); err != nil { + return sdk.Coin{}, err + } + + return mintLpt, nil +} + // RemoveLiquidity removes liquidity from the specified pool func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) (sdk.Coins, error) { standardDenom := k.GetStandardDenom(ctx) + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return nil, err + } + pool, exists := k.GetPoolByLptDenom(ctx, msg.WithdrawLiquidity.Denom) if !exists { return nil, sdkerrors.Wrapf(types.ErrReservePoolNotExists, "liquidity pool token: %s", msg.WithdrawLiquidity.Denom) @@ -217,13 +334,13 @@ func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) tokenReserveAmt := balances.AmountOf(minTokenDenom) liquidityReserve := k.bk.GetSupply(ctx, lptDenom).Amount if standardReserveAmt.LT(msg.MinStandardAmt) { - return nil, sdkerrors.Wrap(types.ErrInsufficientFunds, fmt.Sprintf("insufficient %s funds, user expected: %s, actual: %s", standardDenom, msg.MinStandardAmt.String(), standardReserveAmt.String())) + return nil, sdkerrors.Wrapf(types.ErrInsufficientFunds, "insufficient %s funds, user expected: %s, actual: %s", standardDenom, msg.MinStandardAmt.String(), standardReserveAmt.String()) } if tokenReserveAmt.LT(msg.MinToken) { - return nil, sdkerrors.Wrap(types.ErrInsufficientFunds, fmt.Sprintf("insufficient %s funds, user expected: %s, actual: %s", minTokenDenom, msg.MinToken.String(), tokenReserveAmt.String())) + return nil, sdkerrors.Wrapf(types.ErrInsufficientFunds, "insufficient %s funds, user expected: %s, actual: %s", minTokenDenom, msg.MinToken.String(), tokenReserveAmt.String()) } if liquidityReserve.LT(msg.WithdrawLiquidity.Amount) { - return nil, sdkerrors.Wrap(types.ErrInsufficientFunds, fmt.Sprintf("insufficient %s funds, user expected: %s, actual: %s", lptDenom, msg.WithdrawLiquidity.Amount.String(), liquidityReserve.String())) + return nil, sdkerrors.Wrapf(types.ErrInsufficientFunds, "insufficient %s funds, user expected: %s, actual: %s", lptDenom, msg.WithdrawLiquidity.Amount.String(), liquidityReserve.String()) } // calculate amount of UNI to be burned for sender @@ -236,10 +353,10 @@ func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) deductUniCoin := msg.WithdrawLiquidity if irisWithdrawCoin.Amount.LT(msg.MinStandardAmt) { - return nil, sdkerrors.Wrap(types.ErrConstraintNotMet, fmt.Sprintf("iris amount not met, user expected: no less than %s, actual: %s", sdk.NewCoin(standardDenom, msg.MinStandardAmt).String(), irisWithdrawCoin.String())) + return nil, sdkerrors.Wrapf(types.ErrConstraintNotMet, "iris amount not met, user expected: no less than %s, actual: %s", sdk.NewCoin(standardDenom, msg.MinStandardAmt).String(), irisWithdrawCoin.String()) } if tokenWithdrawCoin.Amount.LT(msg.MinToken) { - return nil, sdkerrors.Wrap(types.ErrConstraintNotMet, fmt.Sprintf("token amount not met, user expected: no less than %s, actual: %s", sdk.NewCoin(minTokenDenom, msg.MinToken).String(), tokenWithdrawCoin.String())) + return nil, sdkerrors.Wrapf(types.ErrConstraintNotMet, "token amount not met, user expected: no less than %s, actual: %s", sdk.NewCoin(minTokenDenom, msg.MinToken).String(), tokenWithdrawCoin.String()) } ctx.EventManager().EmitEvent( @@ -250,11 +367,6 @@ func (k Keeper) RemoveLiquidity(ctx sdk.Context, msg *types.MsgRemoveLiquidity) ), ) - sender, err := sdk.AccAddressFromBech32(msg.Sender) - if err != nil { - return nil, err - } - poolAddr, err := sdk.AccAddressFromBech32(pool.EscrowAddress) if err != nil { return nil, err @@ -281,6 +393,125 @@ func (k Keeper) removeLiquidity(ctx sdk.Context, poolAddr, sender sdk.AccAddress return coins, k.bk.SendCoins(ctx, poolAddr, sender, coins) } +// RemoveUnilateralLiquidity removes liquidity unilaterally from the specified pool +func (k Keeper) RemoveUnilateralLiquidity(ctx sdk.Context, msg *types.MsgRemoveUnilateralLiquidity) (sdk.Coins, error) { + var targetTokenDenom string + + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return sdk.Coins{}, err + } + + poolID := types.GetPoolId(msg.CounterpartyDenom) + pool, exist := k.GetPool(ctx, poolID) + if !exist { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrReservePoolNotExists, "liquidity pool: %s ", poolID) + } + + poolAddr, err := sdk.AccAddressFromBech32(pool.EscrowAddress) + if err != nil { + return sdk.Coins{}, err + } + + balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) + if err != nil { + return sdk.Coins{}, err + } + + if msg.MinToken.Denom != msg.CounterpartyDenom && msg.MinToken.Denom != k.GetStandardDenom(ctx) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInvalidDenom, + "liquidity pool %s has no %s", poolID, msg.MinToken.Denom) + } + + lptDenom := pool.LptDenom + targetTokenDenom = msg.MinToken.Denom + + targetBalanceAmt := balances.AmountOf(targetTokenDenom) + lptBalanceAmt := k.bk.GetSupply(ctx, lptDenom).Amount + + if lptBalanceAmt.LT(msg.ExactLiquidity) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInsufficientFunds, + "insufficient %s funds, user expected: %s, actual: %s", + lptDenom, msg.ExactLiquidity.String(), lptBalanceAmt.String()) + } + + if lptBalanceAmt.Equal(msg.ExactLiquidity) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrConstraintNotMet, + "forbid to withdraw all liquidity unilaterally, should be less than: %s", lptBalanceAmt.String()) + } + + if targetBalanceAmt.LT(msg.MinToken.Amount) { + return sdk.Coins{}, sdkerrors.Wrapf(types.ErrInsufficientFunds, + "insufficient %s funds, user expected: %s, actual: %s", + targetTokenDenom, msg.MinToken.Amount.String(), targetBalanceAmt.String()) + } + + // Calculate Withdrawn Amount + // t_withdrawn = t_balance * delta_lpt / lpt_balance + // c_withdrawn = c_balance * delta_lpt / lpt_balance + // + // Calculate Swap Amount + // As `(t_balance - t_withdraw)(c_balance - c_withdraw) = (t_balance - t_withdraw - t_swap) * c_balance`, + // we get `t_swap = (t_balance - t_withdraw) * c_withdraw / c_balance` + // + // Simplify the formula: + // target_amt = t_balance * (2 * lpt_balance - delta_lpt) * delta_lpt / (lpt_balance^2) + // + // Deduce with fee + // target_amt' = target_amt * ( 1 - fee_unilateral) + // fee_unilateral = numerator / denominator + deltaFeeUnilateral := sdk.OneDec().Sub(k.GetParams(ctx).UnilateralLiquidityFee) + feeNumerator := sdkmath.NewIntFromBigInt(deltaFeeUnilateral.BigInt()) + feeDenominator := sdkmath.NewIntWithDecimal(1, sdk.Precision) + + targetTokenNumerator := lptBalanceAmt.Add(lptBalanceAmt).Sub(msg.ExactLiquidity). + Mul(msg.ExactLiquidity).Mul(targetBalanceAmt).Mul(feeNumerator) + targetTokenDenominator := lptBalanceAmt.Mul(lptBalanceAmt).Mul(feeDenominator) + + targetTokenAmtAfterFee := targetTokenNumerator.Quo(targetTokenDenominator) + + if targetTokenAmtAfterFee.LT(msg.MinToken.Amount) { + return nil, sdkerrors.Wrapf(types.ErrConstraintNotMet, + "token withdrawn amount not met, user expected: no less than %s, actual: %s", + msg.MinToken.String(), sdk.NewCoin(targetTokenDenom, targetTokenAmtAfterFee).String()) + } + + // event + ctx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeRemoveUnilateralLiquidity, + sdk.NewAttribute(types.AttributeValueSender, msg.Sender), + sdk.NewAttribute(types.AttributeValueTokenUnilateral, targetTokenDenom), + sdk.NewAttribute(types.AttributeValueLptDenom, pool.LptDenom), + ), + ) + + return k.removeUnilateralLiquidity(ctx, sender, poolAddr, lptDenom, targetTokenDenom, msg.ExactLiquidity, targetTokenAmtAfterFee) +} + +func (k Keeper) removeUnilateralLiquidity(ctx sdk.Context, + sender sdk.AccAddress, + poolAddr sdk.AccAddress, + lptDenom string, + targetTokenDenom string, + exactLiquidity sdkmath.Int, + targetTokenAmtAfterFee sdkmath.Int, +) (sdk.Coins, error) { + // send lpt and burn lpt + lptCoins := sdk.NewCoins(sdk.NewCoin(lptDenom, exactLiquidity)) + if err := k.bk.SendCoinsFromAccountToModule(ctx, sender, types.ModuleName, lptCoins); err != nil { + return nil, err + } + if err := k.bk.BurnCoins(ctx, types.ModuleName, lptCoins); err != nil { + return nil, err + } + + // send withdraw coins + coins := sdk.NewCoins(sdk.NewCoin(targetTokenDenom, targetTokenAmtAfterFee)) + + return coins, k.bk.SendCoins(ctx, poolAddr, sender, coins) +} + // GetParams gets the parameters for the coinswap module. func (k Keeper) GetParams(ctx sdk.Context) types.Params { var swapParams types.Params diff --git a/modules/coinswap/keeper/keeper_test.go b/modules/coinswap/keeper/keeper_test.go index 01153580..96b0b714 100644 --- a/modules/coinswap/keeper/keeper_test.go +++ b/modules/coinswap/keeper/keeper_test.go @@ -9,6 +9,7 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -39,7 +40,7 @@ type TestSuite struct { } func (suite *TestSuite) SetupTest() { - app := setupWithGenesisAccounts() + app := setupWithGenesisAccounts(suite.T()) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) queryHelper := baseapp.NewQueryServerTestHelper(ctx, app.InterfaceRegistry()) @@ -73,9 +74,9 @@ func (suite *TestSuite) TestParams() { } } -func setupWithGenesisAccounts() *simapp.SimApp { - amountInitStandard, _ := sdk.NewIntFromString("30000000000000000000") - amountInitBTC, _ := sdk.NewIntFromString("3000000000") +func setupWithGenesisAccounts(t *testing.T) *simapp.SimApp { + amountInitStandard, _ := sdkmath.NewIntFromString("30000000000000000000") + amountInitBTC, _ := sdkmath.NewIntFromString("3000000000") addrSender1 = sdk.AccAddress(tmhash.SumTruncated([]byte("addrSender1"))) addrSender2 = sdk.AccAddress(tmhash.SumTruncated([]byte("addrSender2"))) @@ -103,15 +104,15 @@ func setupWithGenesisAccounts() *simapp.SimApp { } genAccs := []authtypes.GenesisAccount{acc1, acc2} - app := simapp.SetupWithGenesisAccounts(genAccs, acc1Balances, acc2Balances) + app := simapp.SetupWithGenesisAccounts(t, genAccs, acc1Balances, acc2Balances) return app } func (suite *TestSuite) TestLiquidity() { - btcAmt, _ := sdk.NewIntFromString("100") - standardAmt, _ := sdk.NewIntFromString("10000000000000000000") + btcAmt, _ := sdkmath.NewIntFromString("100") + standardAmt, _ := sdkmath.NewIntFromString("10000000000000000000") depositCoin := sdk.NewCoin(denomBTC, btcAmt) - minReward := sdk.NewInt(1) + minReward := sdkmath.NewInt(1) deadline := time.Now().Add(1 * time.Minute) msg := types.NewMsgAddLiquidity(depositCoin, standardAmt, minReward, deadline.Unix(), addrSender1.String()) @@ -133,24 +134,24 @@ func (suite *TestSuite) TestLiquidity() { expCoins := sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 100), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(1, 19)), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), ) suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 2999999900), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(2, 19).Sub(sdk.NewIntFromUint64(5000))), - sdk.NewCoin(lptDenom, sdk.NewIntWithDecimal(1, 19)), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(2, 19).Sub(sdk.NewIntFromUint64(5000))), + sdk.NewCoin(lptDenom, sdkmath.NewIntWithDecimal(1, 19)), ) suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) // test add liquidity (pool exists) expLptDenom, _ := suite.app.CoinswapKeeper.GetLptDenomFromDenoms(suite.ctx, denomBTC, denomStandard) suite.Require().Equal(expLptDenom, lptDenom) - btcAmt, _ = sdk.NewIntFromString("201") - standardAmt, _ = sdk.NewIntFromString("20000000000000000000") + btcAmt, _ = sdkmath.NewIntFromString("201") + standardAmt, _ = sdkmath.NewIntFromString("20000000000000000000") depositCoin = sdk.NewCoin(denomBTC, btcAmt) - minReward = sdk.NewInt(1) + minReward = sdkmath.NewInt(1) deadline = time.Now().Add(1 * time.Minute) msg = types.NewMsgAddLiquidity(depositCoin, standardAmt, minReward, deadline.Unix(), addrSender2.String()) @@ -163,23 +164,23 @@ func (suite *TestSuite) TestLiquidity() { expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 301), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(3, 19)), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(3, 19)), ) suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 2999999799), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(1, 19)), - sdk.NewCoin(lptDenom, sdk.NewIntWithDecimal(2, 19)), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), + sdk.NewCoin(lptDenom, sdkmath.NewIntWithDecimal(2, 19)), ) suite.Equal(expCoins.Sort().String(), sender2Balances.Sort().String()) // Test remove liquidity (remove part) - withdraw, _ := sdk.NewIntFromString("10000000000000000000") + withdraw, _ := sdkmath.NewIntFromString("10000000000000000000") msgRemove := types.NewMsgRemoveLiquidity( - sdk.NewInt(1), + sdkmath.NewInt(1), sdk.NewCoin(lptDenom, withdraw), - sdk.NewInt(1), + sdkmath.NewInt(1), suite.ctx.BlockHeader().Time.Unix(), addrSender1.String(), ) @@ -193,22 +194,22 @@ func (suite *TestSuite) TestLiquidity() { expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 3000000000), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(3, 19).Sub(sdk.NewIntFromUint64(5000))), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(3, 19).Sub(sdk.NewIntFromUint64(5000))), ) suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 201), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(2, 19)), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(2, 19)), ) suite.Equal(expCoins.Sort().String(), reservePoolBalances.String()) // Test remove liquidity (remove all) - withdraw, _ = sdk.NewIntFromString("20000000000000000000") + withdraw, _ = sdkmath.NewIntFromString("20000000000000000000") msgRemove = types.NewMsgRemoveLiquidity( - sdk.NewInt(1), + sdkmath.NewInt(1), sdk.NewCoin(lptDenom, withdraw), - sdk.NewInt(1), + sdkmath.NewInt(1), suite.ctx.BlockHeader().Time.Unix(), addrSender2.String(), ) @@ -222,8 +223,165 @@ func (suite *TestSuite) TestLiquidity() { expCoins = sdk.NewCoins( sdk.NewInt64Coin(denomBTC, 3000000000), - sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(3, 19).Sub(sdk.NewIntFromUint64(5000))), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(3, 19).Sub(sdkmath.NewIntFromUint64(5000))), ) suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) suite.Equal("", reservePoolBalances.String()) } + +// TestLiquidity2 tests functionality of add liquidity unilaterally. +func (suite *TestSuite) TestLiquidity2() { + // 1. initial liquidity (create pool) + btcAmt, _ := sdkmath.NewIntFromString("100") // 10^2 + stdAmt, _ := sdkmath.NewIntFromString("10000000000000000000") // 10^19 + initMsg := types.NewMsgAddLiquidity( + sdk.NewCoin(denomBTC, btcAmt), + stdAmt, + sdkmath.NewInt(1), + time.Now().Add(1*time.Minute).Unix(), + addrSender1.String(), + ) + + _, err := suite.app.CoinswapKeeper.AddLiquidity(suite.ctx, initMsg) + suite.NoError(err) + + pool, exist := suite.app.CoinswapKeeper.GetPool(suite.ctx, types.GetPoolId(denomBTC)) + suite.Require().True(exist) + + poolAddr, err := sdk.AccAddressFromBech32(pool.EscrowAddress) + suite.Require().NoError(err) + + // 1.1 lptAmt + reservePoolBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, poolAddr) + sender1Balances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addrSender1) + suite.Equal("10000000000000000000", suite.app.BankKeeper.GetSupply(suite.ctx, pool.LptDenom).Amount.String()) + + // 1.2 poolBalances + expCoins := sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 100), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), + ) + suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) + + // 1.3 accountBalances + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 2999999900), // 3*10^9 - 100 + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(2, 19).Sub(sdk.NewIntFromUint64(5000))), // 2*10^19 - 5000 + sdk.NewCoin(pool.LptDenom, sdkmath.NewIntWithDecimal(1, 19)), // 10^19 + ) + suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) + + // 2. add liquidity unilaterally + + btcAmt, _ = sdkmath.NewIntFromString("100") + addMsg := types.NewMsgAddUnilateralLiquidity( + denomBTC, + sdk.NewCoin(denomBTC, btcAmt), + sdkmath.NewInt(1), + time.Now().Add(1*time.Minute).Unix(), + addrSender2.String(), + ) + + _, err = suite.app.CoinswapKeeper.AddUnilateralLiquidity(suite.ctx, addMsg) + suite.NoError(err) + + // 2.1 lptAmt + reservePoolBalances = suite.app.BankKeeper.GetAllBalances(suite.ctx, poolAddr) + sender2Balances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addrSender2) + suite.Equal("14135062787267695755", suite.app.BankKeeper.GetSupply(suite.ctx, pool.LptDenom).Amount.String()) // todo theoretical lpt ammount + + // 2.2 poolBalances + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 200), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), + ) + suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) + + // 2.3 accountBalances + lptAmt, _ := sdkmath.NewIntFromString("4135062787267695755") + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 2999999900), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(3, 19)), + sdk.NewCoin(pool.LptDenom, lptAmt), + ) + suite.Equal(expCoins.Sort().String(), sender2Balances.Sort().String()) +} + +// TestLiquidity3 tests functionality of remove liquidity unilaterally. +func (suite *TestSuite) TestLiquidity3() { + // 1. initial liquidity (create pool) + btcAmt, _ := sdkmath.NewIntFromString("100") // 10^2 + stdAmt, _ := sdkmath.NewIntFromString("10000000000000000000") // 10^19 + initMsg := types.NewMsgAddLiquidity( + sdk.NewCoin(denomBTC, btcAmt), + stdAmt, + sdkmath.NewInt(1), + time.Now().Add(1*time.Minute).Unix(), + addrSender1.String(), + ) + + _, err := suite.app.CoinswapKeeper.AddLiquidity(suite.ctx, initMsg) + suite.NoError(err) + + pool, exist := suite.app.CoinswapKeeper.GetPool(suite.ctx, types.GetPoolId(denomBTC)) + suite.Require().True(exist) + + poolAddr, err := sdk.AccAddressFromBech32(pool.EscrowAddress) + suite.Require().NoError(err) + + // 1.1 lptAmt + reservePoolBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, poolAddr) + sender1Balances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addrSender1) + suite.Equal("10000000000000000000", suite.app.BankKeeper.GetSupply(suite.ctx, pool.LptDenom).Amount.String()) + + // 1.2 poolBalances + expCoins := sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 100), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), + ) + suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) + + // 1.3 accountBalances + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 2999999900), // 3*10^9 - 100 + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(2, 19).Sub(sdk.NewIntFromUint64(5000))), // 2*10^19 - 5000 + sdk.NewCoin(pool.LptDenom, sdkmath.NewIntWithDecimal(1, 19)), // 10^19 + ) + suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) + + // 2. remove liquidity unilaterally + + btcAmt, _ = sdkmath.NewIntFromString("1") + removeMsg := types.NewMsgRemoveUnilateralLiquidity( + denomBTC, + sdk.NewCoin(denomBTC, btcAmt), // at least 1 + sdkmath.NewInt(5000000000000000000), // 5 * 10^18 + time.Now().Add(1*time.Minute).Unix(), + addrSender1.String(), + ) + + _, err = suite.app.CoinswapKeeper.RemoveUnilateralLiquidity(suite.ctx, removeMsg) + suite.NoError(err) + + // 2.1 lptAmt + reservePoolBalances = suite.app.BankKeeper.GetAllBalances(suite.ctx, poolAddr) + sender1Balances = suite.app.BankKeeper.GetAllBalances(suite.ctx, addrSender1) + suite.Equal("5000000000000000000", suite.app.BankKeeper.GetSupply(suite.ctx, pool.LptDenom).Amount.String()) + + // 2.2 poolBalances + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 26), + sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 19)), + ) + suite.Equal(expCoins.Sort().String(), reservePoolBalances.Sort().String()) + + // 2.3 accountBalances + lptAmt, _ := sdkmath.NewIntFromString("5000000000000000000") + irisAmt, _ := sdkmath.NewIntFromString("19999999999999995000") + expCoins = sdk.NewCoins( + sdk.NewInt64Coin(denomBTC, 2999999974), + sdk.NewCoin(denomStandard, irisAmt), + sdk.NewCoin(pool.LptDenom, lptAmt), + ) + suite.Equal(expCoins.Sort().String(), sender1Balances.Sort().String()) +} diff --git a/modules/coinswap/keeper/migrations.go b/modules/coinswap/keeper/migrations.go index 32d99b69..e33fe47c 100644 --- a/modules/coinswap/keeper/migrations.go +++ b/modules/coinswap/keeper/migrations.go @@ -2,9 +2,9 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" - - v150 "github.com/irisnet/irismod/modules/coinswap/migrations/v150" - v152 "github.com/irisnet/irismod/modules/coinswap/migrations/v152" + v1 "github.com/irisnet/irismod/modules/coinswap/migrations/v1" + v2 "github.com/irisnet/irismod/modules/coinswap/migrations/v2" + v3 "github.com/irisnet/irismod/modules/coinswap/migrations/v3" ) // Migrator is a struct for handling in-place store migrations. @@ -19,9 +19,13 @@ func NewMigrator(k Keeper) Migrator { // Migrate1to2 migrates from version 1 to 2. func (m Migrator) Migrate1to2(ctx sdk.Context) error { - return v150.Migrate(ctx, m.k, m.k.bk, m.k.ak) + return v1.Migrate(ctx, m.k, m.k.bk, m.k.ak) } func (m Migrator) Migrate2to3(ctx sdk.Context) error { - return v152.Migrate(ctx, m.k, m.k.paramSpace) + return v2.Migrate(ctx, m.k, m.k.paramSpace) +} + +func (m Migrator) Migrate3to4(ctx sdk.Context) error { + return v3.Migrate(ctx, m.k, m.k.paramSpace) } diff --git a/modules/coinswap/keeper/msg_server.go b/modules/coinswap/keeper/msg_server.go index 643575ba..3efcbfa7 100644 --- a/modules/coinswap/keeper/msg_server.go +++ b/modules/coinswap/keeper/msg_server.go @@ -47,6 +47,31 @@ func (m msgServer) AddLiquidity(goCtx context.Context, msg *types.MsgAddLiquidit }, nil } +func (m msgServer) AddUnilateralLiquidity(goCtx context.Context, msg *types.MsgAddUnilateralLiquidity) (*types.MsgAddUnilateralLiquidityResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // check that deadline has not passed + if ctx.BlockHeader().Time.After(time.Unix(msg.Deadline, 0)) { + return nil, sdkerrors.Wrap(types.ErrInvalidDeadline, "deadline has passed for MsgAddUnilateralLiquidity") + } + + mintToken, err := m.Keeper.AddUnilateralLiquidity(ctx, msg) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + ) + + return &types.MsgAddUnilateralLiquidityResponse{ + MintToken: &mintToken, + }, nil +} + func (m msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLiquidity) (*types.MsgRemoveLiquidityResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check that deadline has not passed @@ -66,9 +91,9 @@ func (m msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi ), ) - var coins = make([]*sdk.Coin, 0, withdrawCoins.Len()) + var coins = make([]sdk.Coin, 0, withdrawCoins.Len()) for _, coin := range withdrawCoins { - coins = append(coins, &coin) + coins = append(coins, coin) } return &types.MsgRemoveLiquidityResponse{ @@ -76,6 +101,35 @@ func (m msgServer) RemoveLiquidity(goCtx context.Context, msg *types.MsgRemoveLi }, nil } +func (m msgServer) RemoveUnilateralLiquidity(goCtx context.Context, msg *types.MsgRemoveUnilateralLiquidity) (*types.MsgRemoveUnilateralLiquidityResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + // check that deadline has not passed + if ctx.BlockHeader().Time.After(time.Unix(msg.Deadline, 0)) { + return nil, sdkerrors.Wrap(types.ErrInvalidDeadline, "deadline has passed for MsgRemoveLiquidity") + } + withdrawCoins, err := m.Keeper.RemoveUnilateralLiquidity(ctx, msg) + if err != nil { + return nil, err + } + + ctx.EventManager().EmitEvent( + sdk.NewEvent( + sdk.EventTypeMessage, + sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + ) + + var coins = make([]sdk.Coin, 0, withdrawCoins.Len()) + for _, coin := range withdrawCoins { + coins = append(coins, coin) + } + + return &types.MsgRemoveUnilateralLiquidityResponse{ + WithdrawCoins: coins, + }, nil +} + func (m msgServer) SwapCoin(goCtx context.Context, msg *types.MsgSwapOrder) (*types.MsgSwapCoinResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) // check that deadline has not passed diff --git a/modules/coinswap/keeper/pool.go b/modules/coinswap/keeper/pool.go index f6447115..307e84ec 100644 --- a/modules/coinswap/keeper/pool.go +++ b/modules/coinswap/keeper/pool.go @@ -66,6 +66,13 @@ func (k Keeper) GetPoolByLptDenom(ctx sdk.Context, lptDenom string) (types.Pool, return k.GetPool(ctx, poolId.Value) } +// GetPoolBySequenceId return the pool by unique identifier +func (k Keeper) GetPoolBySequenceId(ctx sdk.Context, poolId uint64) (types.Pool, bool) { + lptDenom := types.GetLptDenom(poolId) + + return k.GetPoolByLptDenom(ctx, lptDenom) +} + // GetPoolBalances return the liquidity pool by the specified anotherCoinDenom func (k Keeper) GetPoolBalances(ctx sdk.Context, escrowAddress string) (coins sdk.Coins, err error) { address, err := sdk.AccAddressFromBech32(escrowAddress) diff --git a/modules/coinswap/keeper/querier.go b/modules/coinswap/keeper/querier.go deleted file mode 100644 index 0493ddd8..00000000 --- a/modules/coinswap/keeper/querier.go +++ /dev/null @@ -1,45 +0,0 @@ -package keeper - -import ( - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/irisnet/irismod/modules/coinswap/types" -) - -// NewQuerier creates a querier for coinswap REST endpoints -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) { - switch path[0] { - case types.QueryPool: - return queryPool(ctx, req, k, legacyQuerierCdc) - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -// queryPool returns the total liquidity available for the provided denomination -// upon success or an error if the query fails. -func queryPool(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryPoolParams - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - c := sdk.WrapSDKContext(ctx) - response, err := k.LiquidityPool(c, &types.QueryLiquidityPoolRequest{LptDenom: params.LptDenom}) - if err != nil { - return nil, err - } - - bz, errRes := codec.MarshalJSONIndent(legacyQuerierCdc, response) - if errRes != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - return bz, nil -} diff --git a/modules/coinswap/keeper/querier_test.go b/modules/coinswap/keeper/querier_test.go deleted file mode 100644 index bd0da168..00000000 --- a/modules/coinswap/keeper/querier_test.go +++ /dev/null @@ -1,63 +0,0 @@ -package keeper_test - -import ( - "fmt" - "testing" - "time" - - "github.com/stretchr/testify/suite" - - abci "github.com/tendermint/tendermint/abci/types" - - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/irisnet/irismod/modules/coinswap/keeper" - "github.com/irisnet/irismod/modules/coinswap/types" -) - -func TestQuerierSuite(t *testing.T) { - suite.Run(t, new(TestSuite)) -} - -func (suite *TestSuite) TestNewQuerier() { - req := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - legacyAmino := suite.app.LegacyAmino() - - querier := keeper.NewQuerier(suite.app.CoinswapKeeper, legacyAmino) - res, err := querier(suite.ctx, []string{"other"}, req) - suite.Error(err) - suite.Nil(res) - - btcAmt, _ := sdk.NewIntFromString("100") - standardAmt, _ := sdk.NewIntFromString("10000000000000000000") - depositCoin := sdk.NewCoin(denomBTC, btcAmt) - minReward := sdk.NewInt(1) - deadline := time.Now().Add(1 * time.Minute) - msg := types.NewMsgAddLiquidity(depositCoin, standardAmt, minReward, deadline.Unix(), addrSender1.String()) - lptCoin, _ := suite.app.CoinswapKeeper.AddLiquidity(suite.ctx, msg) - - // test queryLiquidity - - bz, errRes := legacyAmino.MarshalJSON(types.QueryPoolParams{LptDenom: lptCoin.Denom}) - suite.NoError(errRes) - - req.Path = fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryPool) - req.Data = bz - - res, err = querier(suite.ctx, []string{types.QueryPool}, req) - suite.NoError(err) - - var response types.QueryLiquidityPoolResponse - errRes = suite.app.LegacyAmino().UnmarshalJSON(res, &response) - suite.NoError(errRes) - standard := sdk.NewCoin(denomStandard, standardAmt) - token := sdk.NewCoin(denomBTC, btcAmt) - liquidity := sdk.NewCoin(lptCoin.Denom, standardAmt) - suite.Equal(standard, response.Pool.Standard) - suite.Equal(token, response.Pool.Token) - suite.Equal(liquidity, response.Pool.Lpt) - suite.Equal(suite.app.CoinswapKeeper.GetParams(suite.ctx).Fee.String(), response.Pool.Fee) -} diff --git a/modules/coinswap/keeper/swap.go b/modules/coinswap/keeper/swap.go index 404a9c64..3507ad49 100644 --- a/modules/coinswap/keeper/swap.go +++ b/modules/coinswap/keeper/swap.go @@ -3,6 +3,7 @@ package keeper import ( "fmt" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -33,7 +34,7 @@ Calculate the amount of another token to be received based on the exact amount o @param soldTokenDenom : received token's denom @return : amount of the token that will be received */ -func (k Keeper) calculateWithExactInput(ctx sdk.Context, exactSoldCoin sdk.Coin, boughtTokenDenom string) (sdk.Int, error) { +func (k Keeper) calculateWithExactInput(ctx sdk.Context, exactSoldCoin sdk.Coin, boughtTokenDenom string) (sdkmath.Int, error) { lptDenom, err := k.GetLptDenomFromDenoms(ctx, exactSoldCoin.Denom, boughtTokenDenom) if err != nil { return sdk.ZeroInt(), err @@ -68,7 +69,7 @@ Sell exact amount of a token for buying another, one of them must be standard to @param receipt: address of the receiver @return: actual amount of the token to be bought */ -func (k Keeper) TradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error) { +func (k Keeper) TradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdkmath.Int, error) { boughtTokenAmt, err := k.calculateWithExactInput(ctx, input.Coin, output.Coin.Denom) if err != nil { return sdk.ZeroInt(), err @@ -103,7 +104,7 @@ Sell exact amount of a token for buying another, non of them are standard token @param receipt: address of the receiver @return: actual amount of the token to be bought */ -func (k Keeper) doubleTradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error) { +func (k Keeper) doubleTradeExactInputForOutput(ctx sdk.Context, input types.Input, output types.Output) (sdkmath.Int, error) { standardDenom := k.GetStandardDenom(ctx) standardAmount, err := k.calculateWithExactInput(ctx, input.Coin, standardDenom) if err != nil { @@ -147,7 +148,7 @@ Calculate the amount of the token to be paid based on the exact amount of the to @param soldTokenDenom @return: actual amount of the token to be paid */ -func (k Keeper) calculateWithExactOutput(ctx sdk.Context, exactBoughtCoin sdk.Coin, soldTokenDenom string) (sdk.Int, error) { +func (k Keeper) calculateWithExactOutput(ctx sdk.Context, exactBoughtCoin sdk.Coin, soldTokenDenom string) (sdkmath.Int, error) { lptDenom, err := k.GetLptDenomFromDenoms(ctx, exactBoughtCoin.Denom, soldTokenDenom) if err != nil { return sdk.ZeroInt(), err @@ -185,7 +186,7 @@ Buy exact amount of a token by specifying the max amount of another token, one o @param receipt : address of the receiver @return : actual amount of the token to be paid */ -func (k Keeper) TradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error) { +func (k Keeper) TradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdkmath.Int, error) { soldTokenAmt, err := k.calculateWithExactOutput(ctx, output.Coin, input.Coin.Denom) if err != nil { return sdk.ZeroInt(), err @@ -220,7 +221,7 @@ Buy exact amount of a token by specifying the max amount of another token, non o @param receipt : address of the receiver @return : actual amount of the token to be paid */ -func (k Keeper) doubleTradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdk.Int, error) { +func (k Keeper) doubleTradeInputForExactOutput(ctx sdk.Context, input types.Input, output types.Output) (sdkmath.Int, error) { standardDenom := k.GetStandardDenom(ctx) soldStandardAmount, err := k.calculateWithExactOutput(ctx, output.Coin, standardDenom) if err != nil { @@ -261,19 +262,19 @@ func (k Keeper) doubleTradeInputForExactOutput(ctx sdk.Context, input types.Inpu // GetInputPrice returns the amount of coins bought (calculated) given the input amount being sold (exact) // The fee is included in the input coins being bought // https://github.com/runtimeverification/verified-smart-contracts/blob/uniswap/uniswap/x-y-k.pdf -func GetInputPrice(inputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int { +func GetInputPrice(inputAmt, inputReserve, outputReserve sdkmath.Int, fee sdk.Dec) sdkmath.Int { deltaFee := sdk.OneDec().Sub(fee) inputAmtWithFee := inputAmt.Mul(sdk.NewIntFromBigInt(deltaFee.BigInt())) numerator := inputAmtWithFee.Mul(outputReserve) - denominator := inputReserve.Mul(sdk.NewIntWithDecimal(1, sdk.Precision)).Add(inputAmtWithFee) + denominator := inputReserve.Mul(sdkmath.NewIntWithDecimal(1, sdk.Precision)).Add(inputAmtWithFee) return numerator.Quo(denominator) } // GetOutputPrice returns the amount of coins sold (calculated) given the output amount being bought (exact) // The fee is included in the output coins being bought -func GetOutputPrice(outputAmt, inputReserve, outputReserve sdk.Int, fee sdk.Dec) sdk.Int { +func GetOutputPrice(outputAmt, inputReserve, outputReserve sdkmath.Int, fee sdk.Dec) sdkmath.Int { deltaFee := sdk.OneDec().Sub(fee) - numerator := inputReserve.Mul(outputAmt).Mul(sdk.NewIntWithDecimal(1, sdk.Precision)) + numerator := inputReserve.Mul(outputAmt).Mul(sdkmath.NewIntWithDecimal(1, sdk.Precision)) denominator := (outputReserve.Sub(outputAmt)).Mul(sdk.NewIntFromBigInt(deltaFee.BigInt())) return numerator.Quo(denominator).Add(sdk.OneInt()) } diff --git a/modules/coinswap/keeper/swap_test.go b/modules/coinswap/keeper/swap_test.go index 7c93c659..3d83c61c 100644 --- a/modules/coinswap/keeper/swap_test.go +++ b/modules/coinswap/keeper/swap_test.go @@ -6,6 +6,7 @@ import ( "testing" "time" + sdkmath "cosmossdk.io/math" "github.com/stretchr/testify/suite" sdk "github.com/cosmos/cosmos-sdk/types" @@ -19,14 +20,14 @@ func TestSwapSuite(t *testing.T) { } type Data struct { - delta sdk.Int - x sdk.Int - y sdk.Int + delta sdkmath.Int + x sdkmath.Int + y sdkmath.Int fee sdk.Dec } type SwapCase struct { data Data - expect sdk.Int + expect sdkmath.Int } func (suite *TestSuite) TestGetInputPrice() { @@ -312,7 +313,7 @@ func (suite *TestSuite) TestDoubleSwap() { } func createReservePool(suite *TestSuite, denom string) (sdk.AccAddress, sdk.AccAddress) { - amountInit, _ := sdk.NewIntFromString("100000000") + amountInit, _ := sdkmath.NewIntFromString("100000000") addrSender := sdk.AccAddress(getRandomString(20)) _ = suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addrSender) @@ -326,10 +327,10 @@ func createReservePool(suite *TestSuite, denom string) (sdk.AccAddress, sdk.AccA err = suite.app.BankKeeper.SendCoinsFromModuleToAccount(suite.ctx, types.ModuleName, addrSender, coins) suite.NoError(err) - depositAmt, _ := sdk.NewIntFromString("1000") + depositAmt, _ := sdkmath.NewIntFromString("1000") depositCoin := sdk.NewCoin(denom, depositAmt) - standardAmt, _ := sdk.NewIntFromString("1000") + standardAmt, _ := sdkmath.NewIntFromString("1000") minReward := sdk.NewInt(1) deadline := time.Now().Add(1 * time.Minute) msg := types.NewMsgAddLiquidity(depositCoin, standardAmt, minReward, deadline.Unix(), addrSender.String()) @@ -392,8 +393,8 @@ func (suite *TestSuite) TestTradeInputForExactOutput() { bought := sdk.NewCoins(outputCoin) sold := sdk.NewCoins(sdk.NewCoin(denomStandard, amt)) - pb := poolBalances.Add(sold...).Sub(bought) - sb := senderBlances.Add(bought...).Sub(sold) + pb := poolBalances.Add(sold...).Sub(bought...) + sb := senderBlances.Add(bought...).Sub(sold...) assertResult(suite, poolAddr, sender, pb, sb) @@ -426,8 +427,8 @@ func (suite *TestSuite) TestTradeExactInputForOutput() { sold := sdk.NewCoins(inputCoin) bought := sdk.NewCoins(sdk.NewCoin(denomBTC, amt)) - pb := poolBalances.Add(sold...).Sub(bought) - sb := senderBlances.Add(bought...).Sub(sold) + pb := poolBalances.Add(sold...).Sub(bought...) + sb := senderBlances.Add(bought...).Sub(sold...) assertResult(suite, poolAddr, sender, pb, sb) diff --git a/modules/coinswap/migrations/v150/migrate.go b/modules/coinswap/migrations/v1/migrate.go similarity index 99% rename from modules/coinswap/migrations/v150/migrate.go rename to modules/coinswap/migrations/v1/migrate.go index 0faa6f3c..58745427 100644 --- a/modules/coinswap/migrations/v150/migrate.go +++ b/modules/coinswap/migrations/v1/migrate.go @@ -1,4 +1,4 @@ -package v150 +package v1 import ( "strings" diff --git a/modules/coinswap/migrations/v150/migrate_test.go b/modules/coinswap/migrations/v1/migrate_test.go similarity index 81% rename from modules/coinswap/migrations/v150/migrate_test.go rename to modules/coinswap/migrations/v1/migrate_test.go index 34ad440b..21894365 100644 --- a/modules/coinswap/migrations/v150/migrate_test.go +++ b/modules/coinswap/migrations/v1/migrate_test.go @@ -1,4 +1,4 @@ -package v150_test +package v1_test import ( "testing" @@ -7,11 +7,12 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" - v150 "github.com/irisnet/irismod/modules/coinswap/migrations/v150" + v1 "github.com/irisnet/irismod/modules/coinswap/migrations/v1" coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types" "github.com/irisnet/irismod/simapp" ) @@ -27,8 +28,8 @@ const ( var ( addrSender1 = sdk.AccAddress(tmhash.SumTruncated([]byte("addrSender1"))) addrSender2 = sdk.AccAddress(tmhash.SumTruncated([]byte("addrSender2"))) - poolAddrBTC = v150.GetReservePoolAddr(denomLptBTC) - poolAddrETH = v150.GetReservePoolAddr(denomLptETH) + poolAddrBTC = v1.GetReservePoolAddr(denomLptBTC) + poolAddrETH = v1.GetReservePoolAddr(denomLptETH) ) type ( @@ -39,9 +40,9 @@ func TestMigrate(t *testing.T) { sdk.SetCoinDenomRegex(func() string { return `[a-zA-Z][a-zA-Z0-9/\-]{2,127}` }) - app, verify := setupWithGenesisAccounts() + app, verify := setupWithGenesisAccounts(t) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) - err := v150.Migrate(ctx, app.CoinswapKeeper, app.BankKeeper, app.AccountKeeper) + err := v1.Migrate(ctx, app.CoinswapKeeper, app.BankKeeper, app.AccountKeeper) assert.NoError(t, err) //app.BaseApp.Commit() @@ -50,12 +51,12 @@ func TestMigrate(t *testing.T) { app.CrisisKeeper.AssertInvariants(ctx) } -func setupWithGenesisAccounts() (*simapp.SimApp, verifyFunc) { - standardCoin := sdk.NewCoin(denomStandard, sdk.NewIntWithDecimal(1, 18)) - ethCoin := sdk.NewCoin(denomETH, sdk.NewIntWithDecimal(1, 18)) - btcCoin := sdk.NewCoin(denomBTC, sdk.NewIntWithDecimal(1, 18)) - lptBTCCoin := sdk.NewCoin(denomLptBTC, sdk.NewIntWithDecimal(1, 18)) - lptETHCoin := sdk.NewCoin(denomLptETH, sdk.NewIntWithDecimal(1, 18)) +func setupWithGenesisAccounts(t *testing.T) (*simapp.SimApp, verifyFunc) { + standardCoin := sdk.NewCoin(denomStandard, sdkmath.NewIntWithDecimal(1, 18)) + ethCoin := sdk.NewCoin(denomETH, sdkmath.NewIntWithDecimal(1, 18)) + btcCoin := sdk.NewCoin(denomBTC, sdkmath.NewIntWithDecimal(1, 18)) + lptBTCCoin := sdk.NewCoin(denomLptBTC, sdkmath.NewIntWithDecimal(1, 18)) + lptETHCoin := sdk.NewCoin(denomLptETH, sdkmath.NewIntWithDecimal(1, 18)) sender1Balances := banktypes.Balance{ Address: addrSender1.String(), @@ -106,7 +107,7 @@ func setupWithGenesisAccounts() (*simapp.SimApp, verifyFunc) { } genAccs := []authtypes.GenesisAccount{senderAcc1, senderAcc2, poolBTCAcc, poolETHAcc} - app := simapp.SetupWithGenesisAccounts(genAccs, sender1Balances, sender2Balances, poolBTCBalances, poolETHBalances) + app := simapp.SetupWithGenesisAccounts(t, genAccs, sender1Balances, sender2Balances, poolBTCBalances, poolETHBalances) verify := func(ctx sdk.Context, t *testing.T) { ethPoolId := coinswaptypes.GetPoolId(denomETH) diff --git a/modules/coinswap/migrations/v150/types.go b/modules/coinswap/migrations/v1/types.go similarity index 98% rename from modules/coinswap/migrations/v150/types.go rename to modules/coinswap/migrations/v1/types.go index 35207d04..caa706aa 100644 --- a/modules/coinswap/migrations/v150/types.go +++ b/modules/coinswap/migrations/v1/types.go @@ -1,4 +1,4 @@ -package v150 +package v1 import ( "fmt" diff --git a/modules/coinswap/migrations/v152/migrate.go b/modules/coinswap/migrations/v2/migrate.go similarity index 91% rename from modules/coinswap/migrations/v152/migrate.go rename to modules/coinswap/migrations/v2/migrate.go index 71c34f82..faadf533 100644 --- a/modules/coinswap/migrations/v152/migrate.go +++ b/modules/coinswap/migrations/v2/migrate.go @@ -1,6 +1,7 @@ -package v152 +package v2 import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -10,7 +11,7 @@ import ( // Parameter store keys var ( KeyFee = []byte("Fee") // fee key - DefaultPoolCreationFee = sdk.NewCoin("uiris", sdk.NewIntWithDecimal(5000, 6)) + DefaultPoolCreationFee = sdk.NewCoin("uiris", sdkmath.NewIntWithDecimal(5000, 6)) DefaultTaxRate = sdk.NewDecWithPrec(4, 1) ) diff --git a/modules/coinswap/migrations/v3/migrate.go b/modules/coinswap/migrations/v3/migrate.go new file mode 100644 index 00000000..64e3da96 --- /dev/null +++ b/modules/coinswap/migrations/v3/migrate.go @@ -0,0 +1,56 @@ +package v3 + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" + + "github.com/irisnet/irismod/modules/coinswap/types" +) + +var ( + KeyFee = []byte("Fee") + KeyPoolCreationFee = []byte("PoolCreationFee") + KeyTaxRate = []byte("TaxRate") + UnilateralLiquidityFee = sdk.NewDecWithPrec(2, 3) +) + +type ( + CoinswapKeeper interface { + GetParams(ctx sdk.Context) types.Params + SetParams(ctx sdk.Context, params types.Params) + } + + Params struct { + Fee sdk.Dec `protobuf:"bytes,1,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee"` + PoolCreationFee sdk.Coin `protobuf:"bytes,2,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee"` + TaxRate sdk.Dec `protobuf:"bytes,3,opt,name=tax_rate,json=taxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"tax_rate"` + } +) + +func Migrate(ctx sdk.Context, k CoinswapKeeper, paramSpace paramstypes.Subspace) error { + params := GetLegacyParams(ctx, paramSpace) + newParams := types.Params{ + Fee: params.Fee, + PoolCreationFee: params.PoolCreationFee, + TaxRate: params.TaxRate, + UnilateralLiquidityFee: UnilateralLiquidityFee, + } + k.SetParams(ctx, newParams) + return nil +} + +// GetLegacyParams gets the parameters for the coinswap module. +func GetLegacyParams(ctx sdk.Context, paramSpace paramstypes.Subspace) Params { + var swapParams Params + paramSpace.GetParamSet(ctx, &swapParams) + return swapParams +} + +// ParamSetPairs implements paramtypes.KeyValuePairs +func (p *Params) ParamSetPairs() paramstypes.ParamSetPairs { + return paramstypes.ParamSetPairs{ + paramstypes.NewParamSetPair(KeyFee, &p.Fee, nil), + paramstypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, nil), + paramstypes.NewParamSetPair(KeyTaxRate, &p.TaxRate, nil), + } +} diff --git a/modules/coinswap/module.go b/modules/coinswap/module.go index bc957990..bac93ed1 100644 --- a/modules/coinswap/module.go +++ b/modules/coinswap/module.go @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -19,7 +18,6 @@ import ( "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - "github.com/irisnet/irismod/modules/coinswap/client/rest" "github.com/irisnet/irismod/modules/coinswap/keeper" "github.com/irisnet/irismod/modules/coinswap/simulation" "github.com/irisnet/irismod/modules/coinswap/types" @@ -59,11 +57,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the coinswap module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the coinswap module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) @@ -115,11 +108,15 @@ func (am AppModule) RegisterServices(cfg module.Configurator) { m := keeper.NewMigrator(am.keeper) if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { - panic(err) + panic(fmt.Sprintf("failed to migrate nft from version 1 to 2: %v", err)) } if err := cfg.RegisterMigration(types.ModuleName, 2, m.Migrate2to3); err != nil { - panic(err) + panic(fmt.Sprintf("failed to migrate nft from version 2 to 4: %v", err)) + } + + if err := cfg.RegisterMigration(types.ModuleName, 3, m.Migrate3to4); err != nil { + panic(fmt.Sprintf("failed to migrate coinswap from version 3 to 4: %v", err)) } } @@ -128,15 +125,15 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} // Route returns the message routing key for the coinswap module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // QuerierRoute returns the coinswap module's querier route name. -func (AppModule) QuerierRoute() string { return types.RouterKey } +func (AppModule) QuerierRoute() string { return "" } // LegacyQuerierHandler returns the coinswap module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil } // InitGenesis performs genesis initialization for the coinswap module. It returns @@ -155,15 +152,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.Raw } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 3 } - -// BeginBlock performs a no-op. -func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock returns the end blocker for the coinswap module. It returns no validator updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} +func (AppModule) ConsensusVersion() uint64 { return 4 } // ____________________________________________________________________________ diff --git a/modules/coinswap/simulation/operations.go b/modules/coinswap/simulation/operations.go index 02e252f6..dcdedce1 100644 --- a/modules/coinswap/simulation/operations.go +++ b/modules/coinswap/simulation/operations.go @@ -1,11 +1,14 @@ package simulation import ( + "errors" "fmt" + "math/big" "math/rand" "strings" "time" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp/helpers" @@ -21,11 +24,14 @@ import ( // Simulation operation weights constants const ( - OpWeightMsgSwapOrder = "op_weight_msg_swap_order" - OpWeightMsgAddLiquidity = "op_weight_msg_add_liquidity" - OpWeightMsgRemoveLiquidity = "op_weight_msg_remove_liquidity" + OpWeightMsgSwapOrder = "op_weight_msg_swap_order" + OpWeightMsgAddLiquidity = "op_weight_msg_add_liquidity" + OpWeightMsgRemoveLiquidity = "op_weight_msg_remove_liquidity" + OpWeightMsgAddUnilateralLiquidity = "op_weight_msg_add_unilateral_liquidity" + OpWeightMsgRemoveUnilateralLiquidity = "op_weight_msg_remove_unilateral_liquidity" ) +// WeightedOperations returns all the operations from the module with their respective weights func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, @@ -34,9 +40,11 @@ func WeightedOperations( bk types.BankKeeper, ) simulation.WeightedOperations { var ( - weightSwap int - weightAdd int - weightRemove int + weightSwap int + weightAdd int + weightRemove int + weightAddUnilateral int + weightRemoveUnilateral int ) appParams.GetOrGenerate( @@ -60,6 +68,20 @@ func WeightedOperations( }, ) + appParams.GetOrGenerate( + cdc, OpWeightMsgAddUnilateralLiquidity, &weightAddUnilateral, nil, + func(_ *rand.Rand) { + weightAddUnilateral = 50 + }, + ) + + appParams.GetOrGenerate( + cdc, OpWeightMsgRemoveUnilateralLiquidity, &weightRemoveUnilateral, nil, + func(_ *rand.Rand) { + weightRemoveUnilateral = 50 + }, + ) + return simulation.WeightedOperations{ simulation.NewWeightedOperation( weightAdd, @@ -74,6 +96,14 @@ func WeightedOperations( weightRemove, SimulateMsgRemoveLiquidity(k, ak, bk), ), + simulation.NewWeightedOperation( + weightAddUnilateral, + SimulateMsgAddUnilateralLiquidity(k, ak, bk), + ), + simulation.NewWeightedOperation( + weightRemoveUnilateral, + SimulateMsgRemoveUnilateralLiquidity(k, ak, bk), + ), } } @@ -89,52 +119,37 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B var ( maxToken sdk.Coin - minLiquidity sdk.Int + minLiquidity sdkmath.Int ) standardDenom := k.GetStandardDenom(ctx) spendable := bk.SpendableCoins(ctx, account.GetAddress()) - exactStandardAmt := simtypes.RandomAmount(r, spendable.AmountOf(standardDenom)) - - if !exactStandardAmt.IsPositive() { + exactStandardAmt, err := simtypes.RandPositiveInt(r, spendable.AmountOf(standardDenom)) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "standardAmount should be positive"), nil, nil } - maxToken = RandomSpendableToken(r, spendable) + maxToken, err = randToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, nil + } + if maxToken.Denom == standardDenom { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "tokenDenom should not be standardDenom"), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "tokenDenom should not be standardDenom"), nil, nil } if strings.HasPrefix(maxToken.Denom, types.LptTokenPrefix) { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "tokenDenom should not be liquidity token"), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "tokenDenom should not be liquidity token"), nil, nil } if !maxToken.Amount.IsPositive() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "maxToken must is positive"), nil, err } - poolId := types.GetPoolId(maxToken.Denom) - pool, has := k.GetPool(ctx, poolId) - if has { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "pool not found"), nil, err - } - - reservePool, err := k.GetPoolBalances(ctx, pool.EscrowAddress) - - if err != nil { - minLiquidity = exactStandardAmt - } else { - standardReserveAmt := reservePool.AmountOf(standardDenom) - liquidity := bk.GetSupply(ctx, pool.LptDenom).Amount - minLiquidity = liquidity.Mul(exactStandardAmt).Quo(standardReserveAmt) - - if !maxToken.Amount.Sub(reservePool.AmountOf(maxToken.GetDenom()).Mul(exactStandardAmt).Quo(standardReserveAmt)).IsPositive() { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, err - } - - params := k.GetParams(ctx) - poolCreationFee := params.PoolCreationFee - + poolID := types.GetPoolId(maxToken.Denom) + pool, has := k.GetPool(ctx, poolID) + if !has { + poolCreationFee := k.GetParams(ctx).PoolCreationFee spendTotal := poolCreationFee.Amount if strings.EqualFold(poolCreationFee.Denom, standardDenom) { spendTotal = spendTotal.Add(exactStandardAmt) @@ -142,6 +157,20 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B if spendable.AmountOf(poolCreationFee.Denom).LT(spendTotal) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, err } + minLiquidity = exactStandardAmt + } else { + balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "pool address not found"), nil, err + } + + standardReserveAmt := balances.AmountOf(standardDenom) + liquidity := bk.GetSupply(ctx, pool.LptDenom).Amount + minLiquidity = liquidity.Mul(exactStandardAmt).Quo(standardReserveAmt) + + if !maxToken.Amount.Sub(balances.AmountOf(maxToken.Denom).Mul(exactStandardAmt).Quo(standardReserveAmt)).IsPositive() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "insufficient funds"), nil, err + } } deadline := randDeadline(r) @@ -154,7 +183,7 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B ) var fees sdk.Coins - coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(standardDenom, exactStandardAmt), maxToken)) + coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(standardDenom, exactStandardAmt), maxToken)...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coinsTemp) if err != nil { @@ -164,7 +193,8 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -179,7 +209,7 @@ func SimulateMsgAddLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.B return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -210,18 +240,17 @@ func SimulateMsgSwapOrder(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank } // sold coin - inputCoin = RandomSpendableToken(r, spendable) + inputCoin, err = randToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "insufficient funds"), nil, nil + } if strings.HasPrefix(inputCoin.Denom, types.LptTokenPrefix) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "inputCoin should not be liquidity token"), nil, err } - if !inputCoin.Amount.IsPositive() { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "inputCoin must is positive"), nil, err - } - - poolId := types.GetPoolId(inputCoin.Denom) - pool, has := k.GetPool(ctx, poolId) + poolID := types.GetPoolId(inputCoin.Denom) + pool, has := k.GetPool(ctx, poolID) if !has { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "inputCoin should exist in the pool"), nil, nil } @@ -239,17 +268,16 @@ func SimulateMsgSwapOrder(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank if coins.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "total supply is zero"), nil, err } - outputCoin = RandomTotalToken(r, coins) + outputCoin, err = randToken(r, coins) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "insufficient funds"), nil, nil + } if strings.HasPrefix(outputCoin.Denom, types.LptTokenPrefix) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "outputCoin should not be liquidity token"), nil, err } - if !outputCoin.Amount.IsPositive() { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "outputCoin must is positive"), nil, err - } - - poolId = types.GetPoolId(outputCoin.Denom) - pool, has = k.GetPool(ctx, poolId) + poolID = types.GetPoolId(outputCoin.Denom) + pool, has = k.GetPool(ctx, poolID) if !has { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "inputCoin should exist in the pool"), nil, nil } @@ -305,7 +333,7 @@ func SimulateMsgSwapOrder(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank ) var fees sdk.Coins - coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(inputCoin.Denom, inputCoin.Amount))) + coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(inputCoin.Denom, inputCoin.Amount))...) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coinsTemp) if err != nil { @@ -314,7 +342,8 @@ func SimulateMsgSwapOrder(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -329,7 +358,7 @@ func SimulateMsgSwapOrder(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -349,8 +378,8 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type standardDenom := k.GetStandardDenom(ctx) var ( - minToken sdk.Int - minStandardAmt sdk.Int + minToken sdkmath.Int + minStandardAmt sdkmath.Int withdrawLiquidity sdk.Coin ) @@ -359,8 +388,10 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSwapOrder, "spendable is zero"), nil, err } - token := RandomSpendableToken(r, spendable) - + token, err := randToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveLiquidity, "insufficient funds"), nil, nil + } if token.Denom == standardDenom { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveLiquidity, "tokenDenom should not be standardDenom"), nil, err } @@ -408,7 +439,9 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type ) var fees sdk.Coins - coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(pool.CounterpartyDenom, minToken), sdk.NewCoin(standardDenom, minStandardAmt))) + coinsTemp, hasNeg := spendable.SafeSub( + sdk.NewCoins(sdk.NewCoin(pool.CounterpartyDenom, minToken), sdk.NewCoin(standardDenom, minStandardAmt))..., + ) if !hasNeg { fees, err = simtypes.RandomFees(r, ctx, coinsTemp) if err != nil { @@ -418,7 +451,8 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -433,7 +467,7 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -442,14 +476,240 @@ func SimulateMsgRemoveLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk type } } -func RandomSpendableToken(r *rand.Rand, spendableCoin sdk.Coins) sdk.Coin { - token := spendableCoin[r.Intn(len(spendableCoin))] - return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount.QuoRaw(2))) +// SimulateMsgAddUnilateralLiquidity simulates the addition of unilateral liquidity +func SimulateMsgAddUnilateralLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainId string, + ) ( + opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, + ) { + // pick an account + simAccount, _ := simtypes.RandomAcc(r, accs) + account := ak.GetAccount(ctx, simAccount.Address) + + // pick a Coin from Coins + spendable := bk.SpendableCoins(ctx, account.GetAddress()) + exactToken, err := randToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddUnilateralLiquidity, "insufficient funds"), nil, nil + } + + if strings.HasPrefix(exactToken.Denom, types.LptTokenPrefix) { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddUnilateralLiquidity, "exact token shall not be lp token"), nil, nil + } + + // pick a pool + standardDenom := k.GetStandardDenom(ctx) + if exactToken.Denom == standardDenom { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "tokenDenom should not be standardDenom"), nil, err + } + + poolID := types.GetPoolId(exactToken.Denom) + pool, exist := k.GetPool(ctx, poolID) + if !exist { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "pool not found"), nil, err + } + + // minimum lpt amount + balances, _ := k.GetPoolBalances(ctx, pool.EscrowAddress) + + tokenBalanceAmt := balances.AmountOf(exactToken.Denom) + if !tokenBalanceAmt.IsPositive() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "exact token reserve amount is not enough"), nil, err + } + lptBalanceAmt := bk.GetSupply(ctx, pool.LptDenom).Amount + if !tokenBalanceAmt.IsPositive() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "lpt reserve amount is not enough"), nil, err + } + exactTokenAmt := exactToken.Amount + + deltaFeeUnilateral := sdk.OneDec().Sub(k.GetParams(ctx).UnilateralLiquidityFee) + numerator := sdkmath.NewIntFromBigInt(deltaFeeUnilateral.BigInt()) + denominator := sdkmath.NewIntWithDecimal(1, sdk.Precision) + + square := denominator.Mul(tokenBalanceAmt).Add(numerator.Mul(exactTokenAmt)).Mul(lptBalanceAmt).Mul(lptBalanceAmt).Quo(denominator.Mul(tokenBalanceAmt)) + if !square.IsPositive() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAddLiquidity, "fund is not enough"), nil, err + } + // lpt = square^0.5 - lpt_balance + var squareBigInt = &big.Int{} + squareBigInt.Sqrt(square.BigInt()) + mintLptAmt := sdkmath.NewIntFromBigInt(squareBigInt).Sub(lptBalanceAmt) + + deadline := randDeadline(r) + + msg := types.NewMsgAddUnilateralLiquidity( + exactToken.Denom, + exactToken, + mintLptAmt, + deadline, + account.GetAddress().String(), + ) + + // fee + var fees sdk.Coins + coinsTemp, isNeg := spendable.SafeSub(sdk.NewCoins(exactToken)...) + if !isNeg { + fees, err = simtypes.RandomFees(r, ctx, coinsTemp) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate fees"), nil, nil + } + } + + txGen := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txGen, + []sdk.Msg{msg}, + fees, + helpers.DefaultGenTxGas, + chainId, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + simAccount.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + } + + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err + } + + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } } -func RandomTotalToken(r *rand.Rand, coins sdk.Coins) sdk.Coin { - token := coins[r.Intn(len(coins))] - return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount)) +// SimulateMsgRemoveUnilateralLiquidity simulates the removal of unilateral liquidity +// TODO: formula need update +func SimulateMsgRemoveUnilateralLiquidity(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { + return func( + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainId string, + ) ( + opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, + ) { + // pick an account + simAccount, _ := simtypes.RandomAcc(r, accs) + account := ak.GetAccount(ctx, simAccount.Address) + + // balances of account + spendable := bk.SpendableCoins(ctx, account.GetAddress()) + if spendable.IsZero() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "spendable is zero"), nil, err + } + + // pick a target token + targetToken, err := randToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "insufficient funds"), nil, nil + } + + // pick a pool: if target token is iris, select the pool-1 + standardDenom := k.GetStandardDenom(ctx) + if targetToken.Denom == standardDenom { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "tokenDenom should not be standardDenom"), nil, err + } + + poolID := types.GetPoolId(targetToken.Denom) + pool, exist := k.GetPool(ctx, poolID) + if !exist { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "pool not found"), nil, err + } + + balances, err := k.GetPoolBalances(ctx, pool.EscrowAddress) + + lptDenom := pool.LptDenom + targetTokenDenom := targetToken.Denom + counterpartTokenDenom := pool.CounterpartyDenom + + if targetTokenDenom != pool.StandardDenom { + counterpartTokenDenom = pool.StandardDenom + } + + // withdrawn liquidity + exactLpt := sdk.NewCoin(lptDenom, simtypes.RandomAmount(r, targetToken.Amount)) + targetBalanceAmt := balances.AmountOf(targetTokenDenom) + counterpartBalanceAmt := balances.AmountOf(counterpartTokenDenom) + exactLptAmt := exactLpt.Amount + lptBalanceAmt := bk.GetSupply(ctx, lptDenom).Amount + + if !exactLpt.IsValid() || !exactLptAmt.IsPositive() { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "invalid exact liquidity"), nil, nil + } + if lptBalanceAmt.LT(exactLptAmt) { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "insufficient liquidity reserve"), nil, nil + } + + targetWithdrawnAmt := targetBalanceAmt.Mul(exactLptAmt).Quo(lptBalanceAmt) + counterpartWithdrawnAmt := counterpartBalanceAmt.Mul(exactLptAmt).Quo(lptBalanceAmt) + targetSwapAmt := targetBalanceAmt.Sub(targetWithdrawnAmt).Mul(counterpartWithdrawnAmt).Quo(counterpartBalanceAmt) + + deltaFeeUnilateral := sdk.OneDec().Sub(k.GetParams(ctx).UnilateralLiquidityFee) + numerator := sdkmath.NewIntFromBigInt(deltaFeeUnilateral.BigInt()) + denominator := sdkmath.NewIntWithDecimal(1, sdk.Precision) + targetTokenAmt := targetWithdrawnAmt.Add(targetSwapAmt).Mul(numerator).Quo(denominator) + + if targetBalanceAmt.LT(targetTokenAmt) { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRemoveUnilateralLiquidity, "insufficient target balance"), nil, nil + } + + deadline := randDeadline(r) + + msg := types.NewMsgRemoveUnilateralLiquidity( + targetToken.Denom, + sdk.NewCoin(targetTokenDenom, targetTokenAmt), + exactLptAmt, + deadline, + account.GetAddress().String(), + ) + + var fees sdk.Coins + // ??? + coinsTemp, hasNeg := spendable.SafeSub(sdk.NewCoins(sdk.NewCoin(lptDenom, exactLptAmt))...) + if !hasNeg { + fees, err = simtypes.RandomFees(r, ctx, coinsTemp) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate fees"), nil, nil + } + } + + txGen := simappparams.MakeTestEncodingConfig().TxConfig + + tx, err := helpers.GenSignedMockTx( + r, + txGen, + []sdk.Msg{msg}, + fees, + helpers.DefaultGenTxGas, + chainId, + []uint64{account.GetAccountNumber()}, + []uint64{account.GetSequence()}, + simAccount.PrivKey, + ) + + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + } + + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil + } + + return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil + } +} + +func randToken(r *rand.Rand, spendableCoin sdk.Coins) (sdk.Coin, error) { + if len(spendableCoin) == 0 { + return sdk.Coin{}, errors.New("insufficient funds") + } + token := spendableCoin[r.Intn(len(spendableCoin))] + randAmt, err := simtypes.RandPositiveInt(r, token.Amount.QuoRaw(2)) + if err != nil { + return sdk.Coin{}, errors.New("insufficient funds") + } + return sdk.NewCoin(token.Denom, randAmt), nil } func randDeadline(r *rand.Rand) int64 { diff --git a/modules/coinswap/simulation/params.go b/modules/coinswap/simulation/params.go index 22ec7b69..c756d900 100644 --- a/modules/coinswap/simulation/params.go +++ b/modules/coinswap/simulation/params.go @@ -1,6 +1,7 @@ package simulation import ( + "fmt" "math/rand" sdk "github.com/cosmos/cosmos-sdk/types" @@ -17,7 +18,7 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { simulation.NewSimParamChange( types.ModuleName, string(types.KeyFee), func(r *rand.Rand) string { - return sdk.NewDecWithPrec(r.Int63n(3), 3).String() // 0.1%~0.3% + return fmt.Sprintf("\"%s\"", sdk.NewDecWithPrec(r.Int63n(2)+1, 3).String()) // 0.1%~0.3% }, ), } diff --git a/modules/coinswap/spec/01_state.md b/modules/coinswap/spec/01_state.md index 0abf91d7..fb0d8bb5 100644 --- a/modules/coinswap/spec/01_state.md +++ b/modules/coinswap/spec/01_state.md @@ -13,5 +13,6 @@ type Params struct { Fee sdk.Dec PoolCreationFee types.Coin TaxRate sdk.Dec + UnilateralLiquidityFee sdk.Dec } ``` diff --git a/modules/coinswap/spec/02_messages.md b/modules/coinswap/spec/02_messages.md index b65df2e9..dc90d31a 100644 --- a/modules/coinswap/spec/02_messages.md +++ b/modules/coinswap/spec/02_messages.md @@ -39,13 +39,27 @@ The liquidity can be added using the `MsgAddLiquidity` message ```go type MsgAddLiquidity struct { MaxToken types.Coin - ExactStandardAmt sdk.Int - MinLiquidity sdk.Int + ExactStandardAmt sdkmath.Int + MinLiquidity sdkmath.Int Deadline int64 Sender string } ``` +## MsgAddUnilateralLiquidity + +The liquidity can be added unilaterally using the `MsgAddUnilateralLiquidity` message + +```go +type MsgAddUnilateralLiquidity struct { + CounterpartyDenom string + ExactToken types.Coin + MinLiquidity sdkmath.Int + Deadline int64 + Sender string +} +``` + ## MsgRemoveLiquidity The liquidity can be removed using the `MsgAddLiquidity` message @@ -53,9 +67,23 @@ The liquidity can be removed using the `MsgAddLiquidity` message ```go type MsgRemoveLiquidity struct { WithdrawLiquidity types.Coin - MinToken sdk.Int - MinStandardAmt sdk.Int + MinToken sdkmath.Int + MinStandardAmt sdkmath.Int Deadline int64 Sender string } ``` + +## MsgRemoveUnilateralLiquidity + +The liquidity can be removed unilaterally using the `MsgRemoveUnilateralLiquidity` message + +```go +type MsgRemoveUnilateralLiquidity struct { + CounterpartyDenom string + MinToken types.Coin + ExactLiquidity sdkmath.Int + Deadline int64 + Sender string +} +``` \ No newline at end of file diff --git a/modules/coinswap/spec/03_events.md b/modules/coinswap/spec/03_events.md index b0e2f206..c7327f01 100644 --- a/modules/coinswap/spec/03_events.md +++ b/modules/coinswap/spec/03_events.md @@ -27,6 +27,15 @@ order: 3 | message | module | coinswap | | message | sender | {senderAddress} | +### MsgAddUnilateralLiquidity + +| Type | Attribute Key | Attribute Value | +|:-------------------------|:-----------------|:------------------| +| add_unilateral_liquidity | sender | {senderAddress} | +| add_unilateral_liquidity | token_unilateral | {tokenUnilateral} | +| message | module | coinswap | +| message | sender | {senderAddress} | + ### MsgRemoveLiquidity | Type | Attribute Key | Attribute Value | @@ -35,3 +44,12 @@ order: 3 | remove_liquidity | token_pair | {tokenPair} | | message | module | coinswap | | message | sender | {senderAddress} | + +### MsgRemoveUnilateralLiquidity + +| Type | Attribute Key | Attribute Value | +|:----------------------------|:----------------|:-----------------| +| remove_unilateral_liquidity | sender | {senderAddress} | +| remove_unilateral_liquidity | token_unilateral| {tokenUnilateral}| +| message | module | coinswap | +| message | sender | {senderAddress} | diff --git a/modules/coinswap/spec/04_params.md b/modules/coinswap/spec/04_params.md index ac190894..9392ae26 100644 --- a/modules/coinswap/spec/04_params.md +++ b/modules/coinswap/spec/04_params.md @@ -6,8 +6,9 @@ order: 4 The coinswap module contains the following parameters: -| Key | Type | Example | -| :-------------- | :----------- | :--------- | -| Fee | string (dec) | "0.003" | -| PoolCreationFee | sdk.Coin | "5000iris" | -| TaxRate | string (dec) | "0.4" | +| Key | Type | Example | +|:-----------------------| :----------- |:-----------| +| Fee | string (dec) | "0.003" | +| PoolCreationFee | sdk.Coin | "5000iris" | +| TaxRate | string (dec) | "0.4" | +| UnilateralLiquidityFee | string (dec) | "0.002" | diff --git a/modules/coinswap/spec/README.md b/modules/coinswap/spec/README.md index f48220bf..726573af 100644 --- a/modules/coinswap/spec/README.md +++ b/modules/coinswap/spec/README.md @@ -18,7 +18,9 @@ This specification describes the coinswap module. 1. **[Messages](./02_messages.md)** - [Swap Order](./02_messages.md#msgswaporder) - [Add Liquidity](./02_messages.md#msgaddliquidity) + - [Add Unilateral Liquidity](./02_messages.md#msgaddunilateralliquidity) - [Remove Liquidity](./02_messages.md#msgremoveliquidity) + - [Remove Unilateral Liquidity](./02_messages.md#msgremoveunilateralliquidity) 1. **[Events](./03_events.md)** - [Handlers](03_events.md#handlers) 1. **[Parameters](04_params.md)** diff --git a/modules/coinswap/types/codec.go b/modules/coinswap/types/codec.go index 712cb612..c9593f06 100644 --- a/modules/coinswap/types/codec.go +++ b/modules/coinswap/types/codec.go @@ -23,6 +23,8 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgSwapOrder{}, "irismod/coinswap/MsgSwapOrder", nil) cdc.RegisterConcrete(&MsgAddLiquidity{}, "irismod/coinswap/MsgAddLiquidity", nil) cdc.RegisterConcrete(&MsgRemoveLiquidity{}, "irismod/coinswap/MsgRemoveLiquidity", nil) + cdc.RegisterConcrete(&MsgAddUnilateralLiquidity{}, "irismod/coinswap/MsgAddUnilateralLiquidity", nil) + cdc.RegisterConcrete(&MsgRemoveUnilateralLiquidity{}, "irismod/coinswap/MsgRemoveUnilateralLiquidity", nil) } func RegisterInterfaces(registry types.InterfaceRegistry) { @@ -30,6 +32,8 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { &MsgSwapOrder{}, &MsgAddLiquidity{}, &MsgRemoveLiquidity{}, + &MsgAddUnilateralLiquidity{}, + &MsgRemoveUnilateralLiquidity{}, ) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/modules/coinswap/types/coinswap.pb.go b/modules/coinswap/types/coinswap.pb.go index 97e44dcb..c97d262f 100644 --- a/modules/coinswap/types/coinswap.pb.go +++ b/modules/coinswap/types/coinswap.pb.go @@ -150,9 +150,10 @@ var xxx_messageInfo_Pool proto.InternalMessageInfo // Params defines token module's parameters type Params struct { - Fee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee"` - PoolCreationFee types.Coin `protobuf:"bytes,2,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee"` - TaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=tax_rate,json=taxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"tax_rate"` + Fee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,1,opt,name=fee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"fee"` + PoolCreationFee types.Coin `protobuf:"bytes,2,opt,name=pool_creation_fee,json=poolCreationFee,proto3" json:"pool_creation_fee"` + TaxRate github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,3,opt,name=tax_rate,json=taxRate,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"tax_rate"` + UnilateralLiquidityFee github_com_cosmos_cosmos_sdk_types.Dec `protobuf:"bytes,4,opt,name=unilateral_liquidity_fee,json=unilateralLiquidityFee,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Dec" json:"unilateral_liquidity_fee"` } func (m *Params) Reset() { *m = Params{} } @@ -197,36 +198,38 @@ func init() { func init() { proto.RegisterFile("coinswap/coinswap.proto", fileDescriptor_ac63172e3bfc925a) } var fileDescriptor_ac63172e3bfc925a = []byte{ - // 455 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0x31, 0x6f, 0xd3, 0x40, - 0x14, 0xc7, 0xed, 0x34, 0x4d, 0x93, 0x43, 0x04, 0x7a, 0x42, 0x22, 0x14, 0xc9, 0xa9, 0x22, 0x15, - 0x75, 0xa9, 0xad, 0xd0, 0x8d, 0x8d, 0xb6, 0x42, 0xaa, 0x18, 0x5a, 0x79, 0x00, 0x09, 0x06, 0xeb, - 0xe2, 0x7b, 0x04, 0x0b, 0xdb, 0xcf, 0xba, 0x7b, 0xa6, 0xed, 0x27, 0x60, 0x65, 0x64, 0xec, 0x47, - 0xe0, 0x63, 0x64, 0xec, 0x88, 0x18, 0x2a, 0x48, 0x16, 0x3e, 0x06, 0xba, 0x3b, 0x1b, 0x75, 0x42, - 0x30, 0x74, 0xca, 0xcb, 0xdf, 0xff, 0xf7, 0xfb, 0xdf, 0x3b, 0x3f, 0xb3, 0x87, 0x29, 0x66, 0xa5, - 0x3e, 0x13, 0x55, 0xd4, 0x16, 0x61, 0xa5, 0x90, 0x90, 0xdf, 0xcf, 0x54, 0xa6, 0x0b, 0x94, 0x61, - 0xab, 0x6f, 0x05, 0x29, 0xea, 0x02, 0x75, 0x34, 0x13, 0x1a, 0xa2, 0x8f, 0xd3, 0x19, 0x90, 0x98, - 0xda, 0x2e, 0xd7, 0xb1, 0xf5, 0x60, 0x8e, 0x73, 0xb4, 0x65, 0x64, 0x2a, 0xa7, 0x4e, 0x5e, 0xb1, - 0xf5, 0xe3, 0xb2, 0xaa, 0x89, 0x8f, 0xd8, 0x86, 0x90, 0x52, 0x81, 0xd6, 0x23, 0x7f, 0xdb, 0xdf, - 0x1d, 0xc4, 0xed, 0x5f, 0xbe, 0xcf, 0xba, 0x06, 0x33, 0xea, 0x6c, 0xfb, 0xbb, 0x77, 0x9e, 0x3e, - 0x0a, 0x5d, 0x4e, 0x68, 0x72, 0xc2, 0x26, 0x27, 0x3c, 0xc4, 0xac, 0x3c, 0xe8, 0x2e, 0xae, 0xc7, - 0x5e, 0x6c, 0xcd, 0x93, 0xd7, 0xac, 0x77, 0x52, 0xd3, 0x2d, 0x80, 0xbf, 0xfa, 0xac, 0x7b, 0x8a, - 0x98, 0xf3, 0x21, 0xeb, 0x64, 0xb2, 0x41, 0x76, 0x32, 0xc9, 0x77, 0xd8, 0x50, 0x93, 0x28, 0xa5, - 0x50, 0x32, 0x91, 0x50, 0x62, 0x61, 0xb9, 0x83, 0xf8, 0x6e, 0xab, 0x1e, 0x19, 0x91, 0xef, 0x31, - 0x9e, 0x62, 0x5d, 0x12, 0xa8, 0x4a, 0x28, 0xba, 0x68, 0xac, 0x6b, 0xd6, 0xba, 0x79, 0xf3, 0x89, - 0xb3, 0xef, 0xb0, 0x21, 0xe8, 0x54, 0xe1, 0x59, 0xd2, 0x0e, 0xd1, 0x75, 0x54, 0xa7, 0x3e, 0x6f, - 0x46, 0x79, 0xcc, 0x06, 0x79, 0x45, 0x0d, 0x6c, 0xdd, 0x3a, 0xfa, 0x79, 0x45, 0x96, 0x31, 0xf9, - 0xd4, 0x61, 0xbd, 0x53, 0xa1, 0x44, 0xa1, 0xf9, 0x5b, 0xb6, 0xf6, 0x0e, 0xc0, 0x9e, 0xfa, 0xaf, - 0x13, 0x87, 0x66, 0xe2, 0xef, 0xd7, 0xe3, 0x27, 0xf3, 0x8c, 0xde, 0xd7, 0xb3, 0x30, 0xc5, 0x22, - 0x6a, 0xde, 0xaf, 0xfb, 0xd9, 0xd3, 0xf2, 0x43, 0x44, 0x17, 0x15, 0xe8, 0xf0, 0x08, 0xd2, 0xd8, - 0x50, 0xf9, 0x4b, 0xb6, 0x59, 0x21, 0xe6, 0x49, 0xaa, 0x40, 0x50, 0x86, 0x65, 0x62, 0xa2, 0xfe, - 0xf1, 0x72, 0xef, 0x99, 0xce, 0xc3, 0xa6, 0xf1, 0x05, 0x00, 0x3f, 0x66, 0x7d, 0x12, 0xe7, 0x89, - 0x12, 0x04, 0xee, 0x76, 0xfe, 0xfb, 0x4c, 0x1b, 0x24, 0xce, 0x63, 0x41, 0xf0, 0xac, 0xff, 0xe5, - 0x72, 0xec, 0xfd, 0xba, 0x1c, 0xfb, 0x07, 0x27, 0x8b, 0x9f, 0x81, 0xb7, 0x58, 0x06, 0xfe, 0xd5, - 0x32, 0xf0, 0x7f, 0x2c, 0x03, 0xff, 0xf3, 0x2a, 0xf0, 0xae, 0x56, 0x81, 0xf7, 0x6d, 0x15, 0x78, - 0x6f, 0xa6, 0x37, 0xc0, 0x66, 0xbd, 0x4b, 0xa0, 0xa8, 0x59, 0xf3, 0xa8, 0x40, 0x59, 0xe7, 0xa0, - 0xff, 0x7c, 0x06, 0x2e, 0x67, 0xd6, 0xb3, 0x5b, 0xbc, 0xff, 0x3b, 0x00, 0x00, 0xff, 0xff, 0xa3, - 0x80, 0x9c, 0x58, 0x28, 0x03, 0x00, 0x00, + // 486 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x93, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0x86, 0xed, 0x34, 0x4d, 0x93, 0x45, 0x04, 0xba, 0x42, 0x10, 0x8a, 0xe4, 0x54, 0x91, 0x8a, + 0x7a, 0xa9, 0xad, 0xd0, 0x1b, 0x37, 0xda, 0xaa, 0x52, 0x05, 0x52, 0x2b, 0x1f, 0x40, 0x82, 0x83, + 0xb5, 0xf1, 0x0e, 0xe9, 0x0a, 0xdb, 0x63, 0x76, 0xc7, 0xb4, 0x79, 0x0b, 0x8e, 0x1c, 0xfb, 0x08, + 0x3c, 0x46, 0x8e, 0x3d, 0x22, 0x0e, 0x15, 0x24, 0x17, 0xae, 0xbc, 0x01, 0xf2, 0xda, 0x86, 0x9e, + 0x10, 0x20, 0x71, 0xf2, 0xfa, 0xf7, 0x3f, 0xdf, 0x3f, 0xb3, 0xd6, 0xb0, 0x7b, 0x31, 0xaa, 0xcc, + 0x9c, 0x89, 0x3c, 0x68, 0x0e, 0x7e, 0xae, 0x91, 0x90, 0xdf, 0x56, 0x5a, 0x99, 0x14, 0xa5, 0xdf, + 0xe8, 0x1b, 0x5e, 0x8c, 0x26, 0x45, 0x13, 0x4c, 0x84, 0x81, 0xe0, 0xdd, 0x78, 0x02, 0x24, 0xc6, + 0xb6, 0xaa, 0xaa, 0xd8, 0xb8, 0x33, 0xc5, 0x29, 0xda, 0x63, 0x50, 0x9e, 0x2a, 0x75, 0xf4, 0x9c, + 0xad, 0x1e, 0x65, 0x79, 0x41, 0x7c, 0xc0, 0xd6, 0x84, 0x94, 0x1a, 0x8c, 0x19, 0xb8, 0x9b, 0xee, + 0x76, 0x2f, 0x6c, 0x5e, 0xf9, 0x2e, 0x6b, 0x97, 0x98, 0x41, 0x6b, 0xd3, 0xdd, 0xbe, 0xf1, 0xe8, + 0xbe, 0x5f, 0xe5, 0xf8, 0x65, 0x8e, 0x5f, 0xe7, 0xf8, 0xfb, 0xa8, 0xb2, 0xbd, 0xf6, 0xfc, 0x6a, + 0xe8, 0x84, 0xd6, 0x3c, 0x7a, 0xc1, 0x3a, 0xc7, 0x05, 0xfd, 0x07, 0xf0, 0x47, 0x97, 0xb5, 0x4f, + 0x10, 0x13, 0xde, 0x67, 0x2d, 0x25, 0x6b, 0x64, 0x4b, 0x49, 0xbe, 0xc5, 0xfa, 0x86, 0x44, 0x26, + 0x85, 0x96, 0x91, 0x84, 0x0c, 0x53, 0xcb, 0xed, 0x85, 0x37, 0x1b, 0xf5, 0xa0, 0x14, 0xf9, 0x0e, + 0xe3, 0x31, 0x16, 0x19, 0x81, 0xce, 0x85, 0xa6, 0x59, 0x6d, 0x5d, 0xb1, 0xd6, 0xf5, 0xeb, 0x5f, + 0x2a, 0xfb, 0x16, 0xeb, 0x83, 0x89, 0x35, 0x9e, 0x45, 0xcd, 0x10, 0xed, 0x8a, 0x5a, 0xa9, 0x4f, + 0xea, 0x51, 0x1e, 0xb0, 0x5e, 0x92, 0x53, 0x0d, 0x5b, 0xb5, 0x8e, 0x6e, 0x92, 0x93, 0x65, 0x8c, + 0xbe, 0xb7, 0x58, 0xe7, 0x44, 0x68, 0x91, 0x1a, 0xfe, 0x8a, 0xad, 0xbc, 0x06, 0xb0, 0x5d, 0xff, + 0x76, 0x62, 0xbf, 0x9c, 0xf8, 0xf3, 0xd5, 0xf0, 0xe1, 0x54, 0xd1, 0x69, 0x31, 0xf1, 0x63, 0x4c, + 0x83, 0xfa, 0xff, 0x56, 0x8f, 0x1d, 0x23, 0xdf, 0x04, 0x34, 0xcb, 0xc1, 0xf8, 0x07, 0x10, 0x87, + 0x25, 0x95, 0x3f, 0x65, 0xeb, 0x39, 0x62, 0x12, 0xc5, 0x1a, 0x04, 0x29, 0xcc, 0xa2, 0x32, 0xea, + 0x0f, 0x2f, 0xf7, 0x56, 0x59, 0xb9, 0x5f, 0x17, 0x1e, 0x02, 0xf0, 0x23, 0xd6, 0x25, 0x71, 0x1e, + 0x69, 0x41, 0x50, 0xdd, 0xce, 0x5f, 0xf7, 0xb4, 0x46, 0xe2, 0x3c, 0x14, 0x04, 0xfc, 0x94, 0x0d, + 0x8a, 0x4c, 0x25, 0x82, 0x40, 0x8b, 0x24, 0x4a, 0xd4, 0xdb, 0x42, 0x49, 0x45, 0x33, 0xdb, 0x5e, + 0xfb, 0x9f, 0xd0, 0x77, 0x7f, 0xf1, 0x9e, 0x35, 0xb8, 0x43, 0x80, 0xc7, 0xdd, 0x0f, 0x17, 0x43, + 0xe7, 0xdb, 0xc5, 0xd0, 0xdd, 0x3b, 0x9e, 0x7f, 0xf5, 0x9c, 0xf9, 0xc2, 0x73, 0x2f, 0x17, 0x9e, + 0xfb, 0x65, 0xe1, 0xb9, 0xef, 0x97, 0x9e, 0x73, 0xb9, 0xf4, 0x9c, 0x4f, 0x4b, 0xcf, 0x79, 0x39, + 0xbe, 0x96, 0x53, 0x2e, 0x52, 0x06, 0x14, 0xd4, 0x0b, 0x15, 0xa4, 0x28, 0x8b, 0x04, 0xcc, 0xcf, + 0x85, 0xab, 0x62, 0x27, 0x1d, 0xbb, 0x2f, 0xbb, 0x3f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x5c, 0x39, + 0x5f, 0x2d, 0x92, 0x03, 0x00, 0x00, } func (this *Params) Equal(that interface{}) bool { @@ -257,6 +260,9 @@ func (this *Params) Equal(that interface{}) bool { if !this.TaxRate.Equal(that1.TaxRate) { return false } + if !this.UnilateralLiquidityFee.Equal(that1.UnilateralLiquidityFee) { + return false + } return true } func (m *Input) Marshal() (dAtA []byte, err error) { @@ -417,6 +423,16 @@ func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + { + size := m.UnilateralLiquidityFee.Size() + i -= size + if _, err := m.UnilateralLiquidityFee.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintCoinswap(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 { size := m.TaxRate.Size() i -= size @@ -532,6 +548,8 @@ func (m *Params) Size() (n int) { n += 1 + l + sovCoinswap(uint64(l)) l = m.TaxRate.Size() n += 1 + l + sovCoinswap(uint64(l)) + l = m.UnilateralLiquidityFee.Size() + n += 1 + l + sovCoinswap(uint64(l)) return n } @@ -1110,6 +1128,40 @@ func (m *Params) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UnilateralLiquidityFee", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowCoinswap + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthCoinswap + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthCoinswap + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.UnilateralLiquidityFee.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipCoinswap(dAtA[iNdEx:]) diff --git a/modules/coinswap/types/events.go b/modules/coinswap/types/events.go index 934335e2..1ec2aace 100644 --- a/modules/coinswap/types/events.go +++ b/modules/coinswap/types/events.go @@ -3,15 +3,19 @@ package types // coinswap module event types const ( - EventTypeSwap = "swap" - EventTypeAddLiquidity = "add_liquidity" - EventTypeRemoveLiquidity = "remove_liquidity" + EventTypeSwap = "swap" + EventTypeAddLiquidity = "add_liquidity" + EventTypeRemoveLiquidity = "remove_liquidity" + EventTypeAddUnilateralLiquidity = "add_unilateral_liquidity" + EventTypeRemoveUnilateralLiquidity = "remove_unilateral_liquidity" AttributeValueCategory = ModuleName - AttributeValueAmount = "amount" - AttributeValueSender = "sender" - AttributeValueRecipient = "recipient" - AttributeValueIsBuyOrder = "is_buy_order" - AttributeValueTokenPair = "token_pair" + AttributeValueAmount = "amount" + AttributeValueSender = "sender" + AttributeValueRecipient = "recipient" + AttributeValueIsBuyOrder = "is_buy_order" + AttributeValueTokenPair = "token_pair" + AttributeValueTokenUnilateral = "token_unilateral" + AttributeValueLptDenom = "lpt_denom" ) diff --git a/modules/coinswap/types/msgs.go b/modules/coinswap/types/msgs.go index 6452f8eb..eba05339 100644 --- a/modules/coinswap/types/msgs.go +++ b/modules/coinswap/types/msgs.go @@ -1,6 +1,7 @@ package types import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -8,7 +9,9 @@ import ( var ( _ sdk.Msg = &MsgSwapOrder{} _ sdk.Msg = &MsgAddLiquidity{} + _ sdk.Msg = &MsgAddUnilateralLiquidity{} _ sdk.Msg = &MsgRemoveLiquidity{} + _ sdk.Msg = &MsgRemoveUnilateralLiquidity{} ) const ( @@ -19,8 +22,12 @@ const ( // TypeMsgAddLiquidity defines the type of MsgAddLiquidity TypeMsgAddLiquidity = "add_liquidity" + // TypeMsgAddUnilateralLiquidity defines the type of MsgAddUnilateralLiquidity + TypeMsgAddUnilateralLiquidity = "add_unilateral_liquidity" // TypeMsgRemoveLiquidity defines the type of MsgRemoveLiquidity TypeMsgRemoveLiquidity = "remove_liquidity" + // TypeMsgRemoveUnilateralLiquidity defines the type of MsgRemoveUnilateralLiquidity + TypeMsgRemoveUnilateralLiquidity = "remove_unilateral_liquidity" // TypeMsgSwapOrder defines the type of MsgSwapOrder TypeMsgSwapOrder = "swap_order" ) @@ -94,8 +101,8 @@ func (msg MsgSwapOrder) GetSigners() []sdk.AccAddress { // NewMsgAddLiquidity creates a new MsgAddLiquidity object. func NewMsgAddLiquidity( maxToken sdk.Coin, - exactStandardAmt sdk.Int, - minLiquidity sdk.Int, + exactStandardAmt sdkmath.Int, + minLiquidity sdkmath.Int, deadline int64, sender string, ) *MsgAddLiquidity { @@ -116,7 +123,8 @@ func (msg MsgAddLiquidity) Type() string { return TypeMsgAddLiquidity } // ValidateBasic implements Msg. func (msg MsgAddLiquidity) ValidateBasic() error { - if err := ValidateMaxToken(msg.MaxToken); err != nil { + + if err := ValidateToken(msg.MaxToken); err != nil { return err } @@ -124,7 +132,7 @@ func (msg MsgAddLiquidity) ValidateBasic() error { return err } - if err := ValidateMinLiquidity(msg.MinLiquidity); err != nil { + if err := ValidateLiquidity(msg.MinLiquidity); err != nil { return err } @@ -152,15 +160,73 @@ func (msg MsgAddLiquidity) GetSigners() []sdk.AccAddress { return []sdk.AccAddress{from} } +/* --------------------------------------------------------------------------- */ +// MsgAddUnilateralLiquidity +/* --------------------------------------------------------------------------- */ +func NewMsgAddUnilateralLiquidity( + counterpartyDenom string, + exactToken sdk.Coin, + minLiquidity sdkmath.Int, + deadline int64, + sender string, +) *MsgAddUnilateralLiquidity { + return &MsgAddUnilateralLiquidity{ + CounterpartyDenom: counterpartyDenom, + ExactToken: exactToken, + MinLiquidity: minLiquidity, + Deadline: deadline, + Sender: sender, + } +} + +func (m MsgAddUnilateralLiquidity) Route() string { return RouterKey } + +func (m MsgAddUnilateralLiquidity) Type() string { return TypeMsgAddUnilateralLiquidity } + +func (m MsgAddUnilateralLiquidity) ValidateBasic() error { + if err := ValidateCounterpartyDenom(m.CounterpartyDenom); err != nil { + return err + } + + if err := ValidateToken(m.ExactToken); err != nil { + return err + } + + if err := ValidateLiquidity(m.MinLiquidity); err != nil { + return err + } + + if err := ValidateDeadline(m.Deadline); err != nil { + return err + } + + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} + +func (m MsgAddUnilateralLiquidity) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgAddUnilateralLiquidity) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} + /* --------------------------------------------------------------------------- */ // MsgRemoveLiquidity /* --------------------------------------------------------------------------- */ // NewMsgRemoveLiquidity creates a new MsgRemoveLiquidity object func NewMsgRemoveLiquidity( - minToken sdk.Int, + minToken sdkmath.Int, withdrawLiquidity sdk.Coin, - minStandardAmt sdk.Int, + minStandardAmt sdkmath.Int, deadline int64, sender string, ) *MsgRemoveLiquidity { @@ -216,3 +282,61 @@ func (msg MsgRemoveLiquidity) GetSigners() []sdk.AccAddress { } return []sdk.AccAddress{from} } + +/* --------------------------------------------------------------------------- */ +// MsgRemoveUnilateralLiquidity +/* --------------------------------------------------------------------------- */ +func NewMsgRemoveUnilateralLiquidity( + couterpartyDenom string, + minToken sdk.Coin, + exactLiquidity sdkmath.Int, + deadline int64, + sender string, +) *MsgRemoveUnilateralLiquidity { + return &MsgRemoveUnilateralLiquidity{ + CounterpartyDenom: couterpartyDenom, + MinToken: minToken, + ExactLiquidity: exactLiquidity, + Deadline: deadline, + Sender: sender, + } +} + +func (m MsgRemoveUnilateralLiquidity) Route() string { return RouterKey } + +func (m MsgRemoveUnilateralLiquidity) Type() string { return TypeMsgRemoveUnilateralLiquidity } + +func (m MsgRemoveUnilateralLiquidity) ValidateBasic() error { + if err := ValidateCounterpartyDenom(m.CounterpartyDenom); err != nil { + return err + } + + if err := ValidateToken(m.MinToken); err != nil { + return err + } + + if err := ValidateLiquidity(m.ExactLiquidity); err != nil { + return err + } + + if err := ValidateDeadline(m.Deadline); err != nil { + return err + } + + if _, err := sdk.AccAddressFromBech32(m.Sender); err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid sender address (%s)", err) + } + return nil +} + +func (m MsgRemoveUnilateralLiquidity) GetSignBytes() []byte { + return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&m)) +} + +func (m MsgRemoveUnilateralLiquidity) GetSigners() []sdk.AccAddress { + from, err := sdk.AccAddressFromBech32(m.Sender) + if err != nil { + panic(err) + } + return []sdk.AccAddress{from} +} diff --git a/modules/coinswap/types/msgs_test.go b/modules/coinswap/types/msgs_test.go index 5af750ff..8441f48a 100644 --- a/modules/coinswap/types/msgs_test.go +++ b/modules/coinswap/types/msgs_test.go @@ -3,6 +3,7 @@ package types import ( "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/tmhash" ) @@ -49,8 +50,8 @@ func TestMsgSwapOrder_ValidateBasic(t *testing.T) { func TestMsgAddLiquidity_ValidateBasic(t *testing.T) { type fields struct { MaxToken sdk.Coin - ExactStandardAmt sdk.Int - MinLiquidity sdk.Int + ExactStandardAmt sdkmath.Int + MinLiquidity sdkmath.Int Deadline int64 Sender string } @@ -145,8 +146,8 @@ func TestMsgAddLiquidity_ValidateBasic(t *testing.T) { func TestMsgRemoveLiquidity_ValidateBasic(t *testing.T) { type fields struct { WithdrawLiquidity sdk.Coin - MinToken sdk.Int - MinStandardAmt sdk.Int + MinToken sdkmath.Int + MinStandardAmt sdkmath.Int Deadline int64 Sender string } @@ -238,6 +239,198 @@ func TestMsgRemoveLiquidity_ValidateBasic(t *testing.T) { } } +func TestMsgAddUnilateralLiquidity_ValidateBasic(t *testing.T) { + type fields struct { + CounterpartyDenom string + ExactToken sdk.Coin + MinLiquidity sdkmath.Int + Deadline int64 + Sender string + } + tests := []struct { + name string + fields fields + wantErr bool + }{ + { + name: "invalid Counterparty Denom", + wantErr: true, + fields: fields{ + CounterpartyDenom: "", + ExactToken: buildCoin("stake", 1000), + MinLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid Exact Token Denom", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + ExactToken: buildCoin("131stake", 1000), + MinLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid Exact Token Amount", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + ExactToken: buildCoin("stake", -1000), + MinLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid MinLiquidity", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + ExactToken: buildCoin("stake", 1000), + MinLiquidity: sdk.NewInt(-100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid Deadline", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + ExactToken: buildCoin("stake", 1000), + MinLiquidity: sdk.NewInt(100), + Deadline: 0, + Sender: sender, + }, + }, + { + name: "invalid Sender", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + ExactToken: buildCoin("stake", 1000), + MinLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: "", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + msg := MsgAddUnilateralLiquidity{ + CounterpartyDenom: tt.fields.CounterpartyDenom, + ExactToken: tt.fields.ExactToken, + MinLiquidity: tt.fields.MinLiquidity, + Deadline: tt.fields.Deadline, + Sender: tt.fields.Sender, + } + if err := msg.ValidateBasic(); (err != nil) != tt.wantErr { + t.Errorf("MsgAddUnilateralLiquidity.ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + +func TestMsgRemoveUnilateralLiquidity_ValidateBasic(t *testing.T) { + type fields struct { + CounterpartyDenom string + MinToken sdk.Coin + ExactLiquidity sdkmath.Int + Deadline int64 + Sender string + } + tests := []struct { + name string + fields fields + wantErr bool + }{ + { + name: "invalid Counterparty Denom", + wantErr: true, + fields: fields{ + CounterpartyDenom: "", + MinToken: buildCoin("stake", 1000), + ExactLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid MinToken Denom", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + MinToken: buildCoin("", 1000), + ExactLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid MinToken Amount", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + MinToken: buildCoin("stake", -1000), + ExactLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid ExactLiquidity", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + MinToken: buildCoin("stake", -1000), + ExactLiquidity: sdk.NewInt(-100), + Deadline: 1611213344, + Sender: sender, + }, + }, + { + name: "invalid Deadline", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + MinToken: buildCoin("stake", 1000), + ExactLiquidity: sdk.NewInt(100), + Deadline: 0, + Sender: sender, + }, + }, + { + name: "invalid Sender", + wantErr: true, + fields: fields{ + CounterpartyDenom: "bnb", + MinToken: buildCoin("stake", 1000), + ExactLiquidity: sdk.NewInt(100), + Deadline: 1611213344, + Sender: "", + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + msg := MsgRemoveUnilateralLiquidity{ + CounterpartyDenom: tt.fields.CounterpartyDenom, + MinToken: tt.fields.MinToken, + ExactLiquidity: tt.fields.ExactLiquidity, + Deadline: tt.fields.Deadline, + Sender: tt.fields.Sender, + } + if err := msg.ValidateBasic(); (err != nil) != tt.wantErr { + t.Errorf("MsgRemoveLiquidity.ValidateBasic() error = %v, wantErr %v", err, tt.wantErr) + } + }) + } +} + func buildCoin(denom string, amt int64) sdk.Coin { return sdk.Coin{ Denom: denom, diff --git a/modules/coinswap/types/params.go b/modules/coinswap/types/params.go index 742c8926..f089605b 100644 --- a/modules/coinswap/types/params.go +++ b/modules/coinswap/types/params.go @@ -11,18 +11,20 @@ import ( // Parameter store keys var ( - KeyFee = []byte("Fee") // fee key - KeyPoolCreationFee = []byte("PoolCreationFee") // fee key - KeyTaxRate = []byte("TaxRate") // fee key - KeyStandardDenom = []byte("StandardDenom") // standard token denom key + KeyFee = []byte("Fee") // fee key + KeyPoolCreationFee = []byte("PoolCreationFee") // fee key + KeyTaxRate = []byte("TaxRate") // fee key + KeyStandardDenom = []byte("StandardDenom") // standard token denom key + KeyUnilateralLiquidityFee = []byte("UnilateralLiquidityFee") // fee key ) // NewParams is the coinswap params constructor -func NewParams(fee, taxRate sdk.Dec, poolCreationFee sdk.Coin) Params { +func NewParams(fee, taxRate, unilateralLiquidityFee sdk.Dec, poolCreationFee sdk.Coin) Params { return Params{ - Fee: fee, - TaxRate: taxRate, - PoolCreationFee: poolCreationFee, + Fee: fee, + TaxRate: taxRate, + PoolCreationFee: poolCreationFee, + UnilateralLiquidityFee: unilateralLiquidityFee, } } @@ -37,16 +39,19 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { paramtypes.NewParamSetPair(KeyFee, &p.Fee, validateFee), paramtypes.NewParamSetPair(KeyPoolCreationFee, &p.PoolCreationFee, validatePoolCreationFee), paramtypes.NewParamSetPair(KeyTaxRate, &p.TaxRate, validateTaxRate), + paramtypes.NewParamSetPair(KeyUnilateralLiquidityFee, &p.UnilateralLiquidityFee, validateUnilateraLiquiditylFee), } } // DefaultParams returns the default coinswap module parameters func DefaultParams() Params { fee := sdk.NewDecWithPrec(3, 3) + unilateralFee := sdk.NewDecWithPrec(2, 3) return Params{ - Fee: fee, - PoolCreationFee: sdk.NewInt64Coin(sdk.DefaultBondDenom, 5000), - TaxRate: sdk.NewDecWithPrec(4, 1), // 0.4 (40%) + Fee: fee, + PoolCreationFee: sdk.NewInt64Coin(sdk.DefaultBondDenom, 5000), + TaxRate: sdk.NewDecWithPrec(4, 1), // 0.4 (40%) + UnilateralLiquidityFee: unilateralFee, } } @@ -100,3 +105,17 @@ func validateTaxRate(i interface{}) error { } return nil } + +func validateUnilateraLiquiditylFee(i interface{}) error { + v, ok := i.(sdk.Dec) + if !ok { + return fmt.Errorf("invalid parameter type: %T", i) + } + + // unilateral fee should be in range of [0, 1) + if !v.GTE(sdk.ZeroDec()) || !v.LT(sdk.OneDec()) { + return fmt.Errorf("unilateral liquidity fee must be positive and less than 1: %s", v.String()) + } + + return nil +} diff --git a/modules/coinswap/types/querier.go b/modules/coinswap/types/querier.go deleted file mode 100644 index 501ed64c..00000000 --- a/modules/coinswap/types/querier.go +++ /dev/null @@ -1,13 +0,0 @@ -package types - -const ( - // QueryPool is the liquidity query endpoint supported by the coinswap querier - QueryPool = "pool" - // QueryPools is the liquidity query endpoint supported by the coinswap querier - QueryPools = "pools" -) - -// QueryPoolParams is the query parameters for 'custom/swap/liquidity' -type QueryPoolParams struct { - LptDenom string `json:"lpt-denom" yaml:"lpt-denom"` // same as uniDenom -} diff --git a/modules/coinswap/types/query.pb.gw.go b/modules/coinswap/types/query.pb.gw.go index e18f9413..6df51251 100644 --- a/modules/coinswap/types/query.pb.gw.go +++ b/modules/coinswap/types/query.pb.gw.go @@ -260,9 +260,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_LiquidityPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "coinswap", "pools", "lpt_denom"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_LiquidityPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "coinswap", "pools", "lpt_denom"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_LiquidityPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "coinswap", "pools"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_LiquidityPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "coinswap", "pools"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/coinswap/types/tx.pb.go b/modules/coinswap/types/tx.pb.go index c2f7b81c..c3eae04c 100644 --- a/modules/coinswap/types/tx.pb.go +++ b/modules/coinswap/types/tx.pb.go @@ -110,6 +110,87 @@ func (m *MsgAddLiquidityResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgAddLiquidityResponse proto.InternalMessageInfo +// MsgAddLiquidityUni defines a msg for adding liquidity unilaterally to a +// reserve pool +type MsgAddUnilateralLiquidity struct { + CounterpartyDenom string `protobuf:"bytes,1,opt,name=counterparty_denom,json=counterpartyDenom,proto3" json:"counterparty_denom,omitempty" yaml:"conuterparty_denom"` + ExactToken types.Coin `protobuf:"bytes,2,opt,name=exact_token,json=exactToken,proto3" json:"exact_token" yaml:"exact_token"` + MinLiquidity github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=min_liquidity,json=minLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"min_liquidity" yaml:"min_liquidity"` + Deadline int64 `protobuf:"varint,4,opt,name=deadline,proto3" json:"deadline,omitempty"` + Sender string `protobuf:"bytes,5,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (m *MsgAddUnilateralLiquidity) Reset() { *m = MsgAddUnilateralLiquidity{} } +func (m *MsgAddUnilateralLiquidity) String() string { return proto.CompactTextString(m) } +func (*MsgAddUnilateralLiquidity) ProtoMessage() {} +func (*MsgAddUnilateralLiquidity) Descriptor() ([]byte, []int) { + return fileDescriptor_f3a5860d70ca9b75, []int{2} +} +func (m *MsgAddUnilateralLiquidity) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddUnilateralLiquidity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddUnilateralLiquidity.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddUnilateralLiquidity) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddUnilateralLiquidity.Merge(m, src) +} +func (m *MsgAddUnilateralLiquidity) XXX_Size() int { + return m.Size() +} +func (m *MsgAddUnilateralLiquidity) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddUnilateralLiquidity.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddUnilateralLiquidity proto.InternalMessageInfo + +// MsgAddLiquidityUniResponse defines the Msg/AddLiquidityUni response type +type MsgAddUnilateralLiquidityResponse struct { + MintToken *types.Coin `protobuf:"bytes,1,opt,name=mint_token,json=mintToken,proto3" json:"mint_token,omitempty"` +} + +func (m *MsgAddUnilateralLiquidityResponse) Reset() { *m = MsgAddUnilateralLiquidityResponse{} } +func (m *MsgAddUnilateralLiquidityResponse) String() string { return proto.CompactTextString(m) } +func (*MsgAddUnilateralLiquidityResponse) ProtoMessage() {} +func (*MsgAddUnilateralLiquidityResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f3a5860d70ca9b75, []int{3} +} +func (m *MsgAddUnilateralLiquidityResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgAddUnilateralLiquidityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgAddUnilateralLiquidityResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgAddUnilateralLiquidityResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgAddUnilateralLiquidityResponse.Merge(m, src) +} +func (m *MsgAddUnilateralLiquidityResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgAddUnilateralLiquidityResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgAddUnilateralLiquidityResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgAddUnilateralLiquidityResponse proto.InternalMessageInfo + // MsgRemoveLiquidity defines a msg for removing liquidity from a reserve pool type MsgRemoveLiquidity struct { WithdrawLiquidity types.Coin `protobuf:"bytes,1,opt,name=withdraw_liquidity,json=withdrawLiquidity,proto3" json:"withdraw_liquidity" yaml:"withdraw_liquidity"` @@ -123,7 +204,7 @@ func (m *MsgRemoveLiquidity) Reset() { *m = MsgRemoveLiquidity{} } func (m *MsgRemoveLiquidity) String() string { return proto.CompactTextString(m) } func (*MsgRemoveLiquidity) ProtoMessage() {} func (*MsgRemoveLiquidity) Descriptor() ([]byte, []int) { - return fileDescriptor_f3a5860d70ca9b75, []int{2} + return fileDescriptor_f3a5860d70ca9b75, []int{4} } func (m *MsgRemoveLiquidity) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -154,14 +235,14 @@ var xxx_messageInfo_MsgRemoveLiquidity proto.InternalMessageInfo // MsgRemoveLiquidityResponse defines the Msg/RemoveLiquidity response type type MsgRemoveLiquidityResponse struct { - WithdrawCoins []*types.Coin `protobuf:"bytes,1,rep,name=withdraw_coins,json=withdrawCoins,proto3" json:"withdraw_coins,omitempty"` + WithdrawCoins []types.Coin `protobuf:"bytes,1,rep,name=withdraw_coins,json=withdrawCoins,proto3" json:"withdraw_coins"` } func (m *MsgRemoveLiquidityResponse) Reset() { *m = MsgRemoveLiquidityResponse{} } func (m *MsgRemoveLiquidityResponse) String() string { return proto.CompactTextString(m) } func (*MsgRemoveLiquidityResponse) ProtoMessage() {} func (*MsgRemoveLiquidityResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f3a5860d70ca9b75, []int{3} + return fileDescriptor_f3a5860d70ca9b75, []int{5} } func (m *MsgRemoveLiquidityResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -190,6 +271,88 @@ func (m *MsgRemoveLiquidityResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRemoveLiquidityResponse proto.InternalMessageInfo +// MsgRemoveUnilateralLiquidity defines a msg for removing liquidity +// unilaterally to a reserve pool +type MsgRemoveUnilateralLiquidity struct { + CounterpartyDenom string `protobuf:"bytes,1,opt,name=counterparty_denom,json=counterpartyDenom,proto3" json:"counterparty_denom,omitempty" yaml:"conuterparty_denom"` + MinToken types.Coin `protobuf:"bytes,2,opt,name=min_token,json=minToken,proto3" json:"min_token" yaml:"min_token"` + ExactLiquidity github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=exact_liquidity,json=exactLiquidity,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"exact_liquidity" yaml:"exact_liquidity"` + Deadline int64 `protobuf:"varint,4,opt,name=deadline,proto3" json:"deadline,omitempty"` + Sender string `protobuf:"bytes,5,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (m *MsgRemoveUnilateralLiquidity) Reset() { *m = MsgRemoveUnilateralLiquidity{} } +func (m *MsgRemoveUnilateralLiquidity) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveUnilateralLiquidity) ProtoMessage() {} +func (*MsgRemoveUnilateralLiquidity) Descriptor() ([]byte, []int) { + return fileDescriptor_f3a5860d70ca9b75, []int{6} +} +func (m *MsgRemoveUnilateralLiquidity) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveUnilateralLiquidity) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveUnilateralLiquidity.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveUnilateralLiquidity) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveUnilateralLiquidity.Merge(m, src) +} +func (m *MsgRemoveUnilateralLiquidity) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveUnilateralLiquidity) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveUnilateralLiquidity.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveUnilateralLiquidity proto.InternalMessageInfo + +// MsgRemoveUnilateralLiquidityResponse defines the Msg/RemoveLiquidity response +// type +type MsgRemoveUnilateralLiquidityResponse struct { + WithdrawCoins []types.Coin `protobuf:"bytes,1,rep,name=withdraw_coins,json=withdrawCoins,proto3" json:"withdraw_coins"` +} + +func (m *MsgRemoveUnilateralLiquidityResponse) Reset() { *m = MsgRemoveUnilateralLiquidityResponse{} } +func (m *MsgRemoveUnilateralLiquidityResponse) String() string { return proto.CompactTextString(m) } +func (*MsgRemoveUnilateralLiquidityResponse) ProtoMessage() {} +func (*MsgRemoveUnilateralLiquidityResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_f3a5860d70ca9b75, []int{7} +} +func (m *MsgRemoveUnilateralLiquidityResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgRemoveUnilateralLiquidityResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgRemoveUnilateralLiquidityResponse.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *MsgRemoveUnilateralLiquidityResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgRemoveUnilateralLiquidityResponse.Merge(m, src) +} +func (m *MsgRemoveUnilateralLiquidityResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgRemoveUnilateralLiquidityResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgRemoveUnilateralLiquidityResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgRemoveUnilateralLiquidityResponse proto.InternalMessageInfo + // MsgSwapOrder defines a msg for swap order type MsgSwapOrder struct { Input Input `protobuf:"bytes,1,opt,name=input,proto3" json:"input"` @@ -202,7 +365,7 @@ func (m *MsgSwapOrder) Reset() { *m = MsgSwapOrder{} } func (m *MsgSwapOrder) String() string { return proto.CompactTextString(m) } func (*MsgSwapOrder) ProtoMessage() {} func (*MsgSwapOrder) Descriptor() ([]byte, []int) { - return fileDescriptor_f3a5860d70ca9b75, []int{4} + return fileDescriptor_f3a5860d70ca9b75, []int{8} } func (m *MsgSwapOrder) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -239,7 +402,7 @@ func (m *MsgSwapCoinResponse) Reset() { *m = MsgSwapCoinResponse{} } func (m *MsgSwapCoinResponse) String() string { return proto.CompactTextString(m) } func (*MsgSwapCoinResponse) ProtoMessage() {} func (*MsgSwapCoinResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_f3a5860d70ca9b75, []int{5} + return fileDescriptor_f3a5860d70ca9b75, []int{9} } func (m *MsgSwapCoinResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -271,8 +434,12 @@ var xxx_messageInfo_MsgSwapCoinResponse proto.InternalMessageInfo func init() { proto.RegisterType((*MsgAddLiquidity)(nil), "irismod.coinswap.MsgAddLiquidity") proto.RegisterType((*MsgAddLiquidityResponse)(nil), "irismod.coinswap.MsgAddLiquidityResponse") + proto.RegisterType((*MsgAddUnilateralLiquidity)(nil), "irismod.coinswap.MsgAddUnilateralLiquidity") + proto.RegisterType((*MsgAddUnilateralLiquidityResponse)(nil), "irismod.coinswap.MsgAddUnilateralLiquidityResponse") proto.RegisterType((*MsgRemoveLiquidity)(nil), "irismod.coinswap.MsgRemoveLiquidity") proto.RegisterType((*MsgRemoveLiquidityResponse)(nil), "irismod.coinswap.MsgRemoveLiquidityResponse") + proto.RegisterType((*MsgRemoveUnilateralLiquidity)(nil), "irismod.coinswap.MsgRemoveUnilateralLiquidity") + proto.RegisterType((*MsgRemoveUnilateralLiquidityResponse)(nil), "irismod.coinswap.MsgRemoveUnilateralLiquidityResponse") proto.RegisterType((*MsgSwapOrder)(nil), "irismod.coinswap.MsgSwapOrder") proto.RegisterType((*MsgSwapCoinResponse)(nil), "irismod.coinswap.MsgSwapCoinResponse") } @@ -280,51 +447,63 @@ func init() { func init() { proto.RegisterFile("coinswap/tx.proto", fileDescriptor_f3a5860d70ca9b75) } var fileDescriptor_f3a5860d70ca9b75 = []byte{ - // 698 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x55, 0xcf, 0x6e, 0xd3, 0x30, - 0x18, 0x6f, 0xda, 0x6d, 0xea, 0x4c, 0xb7, 0x75, 0xd9, 0xa0, 0x59, 0x0e, 0x69, 0x17, 0x01, 0x1a, - 0x12, 0x24, 0xda, 0x26, 0x21, 0xe0, 0xc4, 0x82, 0x84, 0x34, 0x41, 0x35, 0xc8, 0x38, 0x21, 0x44, - 0x94, 0x36, 0x56, 0x66, 0xb5, 0xb6, 0x4b, 0xec, 0xac, 0xed, 0x33, 0x70, 0xe1, 0x05, 0x78, 0x9f, - 0x1d, 0x27, 0x4e, 0x88, 0x43, 0x05, 0xdb, 0x1b, 0xec, 0x05, 0x40, 0x4e, 0xdc, 0xf4, 0xdf, 0x60, - 0x1b, 0xa7, 0xd8, 0xdf, 0xff, 0xef, 0xf7, 0xfb, 0xbe, 0x18, 0xac, 0x36, 0x29, 0x22, 0xac, 0xeb, - 0x77, 0x6c, 0xde, 0xb3, 0x3a, 0x11, 0xe5, 0x54, 0x2d, 0xa3, 0x08, 0x31, 0x4c, 0x03, 0x6b, 0xa8, - 0xd2, 0x2b, 0x99, 0xd1, 0xf0, 0x90, 0x9a, 0xea, 0x46, 0x93, 0x32, 0x4c, 0x99, 0xdd, 0xf0, 0x19, - 0xb4, 0x8f, 0xb7, 0x1b, 0x90, 0xfb, 0xdb, 0x89, 0x8d, 0xd4, 0xaf, 0x87, 0x34, 0xa4, 0xc9, 0xd1, - 0x16, 0xa7, 0x54, 0x6a, 0xfe, 0xce, 0x83, 0x95, 0x3a, 0x0b, 0xf7, 0x82, 0xe0, 0x35, 0xfa, 0x14, - 0xa3, 0x00, 0xf1, 0xbe, 0xfa, 0x06, 0x2c, 0x62, 0xbf, 0xe7, 0x71, 0xda, 0x82, 0x44, 0x53, 0x6a, - 0xca, 0xd6, 0xad, 0x9d, 0x0d, 0x2b, 0x8d, 0x6e, 0x89, 0xe8, 0x96, 0x8c, 0x6e, 0xbd, 0xa0, 0x88, - 0x38, 0xda, 0xc9, 0xa0, 0x9a, 0xbb, 0x18, 0x54, 0xcb, 0x7d, 0x1f, 0xb7, 0x9f, 0x99, 0x99, 0xa7, - 0xe9, 0x16, 0xb1, 0xdf, 0x7b, 0x27, 0x8e, 0x6a, 0x1f, 0xa8, 0xb0, 0xe7, 0x37, 0xb9, 0xc7, 0xb8, - 0x4f, 0x02, 0x3f, 0x0a, 0x3c, 0x1f, 0x73, 0x2d, 0x5f, 0x53, 0xb6, 0x16, 0x9d, 0x57, 0xc2, 0xff, - 0xc7, 0xa0, 0x7a, 0x3f, 0x44, 0xfc, 0x28, 0x6e, 0x58, 0x4d, 0x8a, 0x6d, 0xd9, 0x4a, 0xfa, 0x79, - 0xc4, 0x82, 0x96, 0xcd, 0xfb, 0x1d, 0xc8, 0xac, 0x7d, 0xc2, 0x2f, 0x06, 0xd5, 0x8d, 0x34, 0xd3, - 0x6c, 0x44, 0xd3, 0x2d, 0x27, 0xc2, 0x43, 0x29, 0xdb, 0xc3, 0x5c, 0x6d, 0x81, 0x25, 0x8c, 0x88, - 0xd7, 0x1e, 0x76, 0xa7, 0x15, 0x92, 0xac, 0x2f, 0x6f, 0x9c, 0x75, 0x5d, 0xf6, 0x37, 0x1e, 0xcc, - 0x74, 0x4b, 0x18, 0x91, 0x11, 0x72, 0x3a, 0x28, 0x06, 0xd0, 0x0f, 0xda, 0x88, 0x40, 0x6d, 0xae, - 0xa6, 0x6c, 0x15, 0xdc, 0xec, 0xae, 0xde, 0x01, 0x0b, 0x0c, 0x92, 0x00, 0x46, 0xda, 0xbc, 0xa8, - 0xc0, 0x95, 0x37, 0xf3, 0x10, 0x54, 0xa6, 0x08, 0x70, 0x21, 0xeb, 0x50, 0xc2, 0xa0, 0xfa, 0x04, - 0x00, 0x8c, 0x08, 0xbf, 0x26, 0x13, 0xee, 0xa2, 0x30, 0x4e, 0x00, 0x37, 0x3f, 0x17, 0x80, 0x5a, - 0x67, 0xa1, 0x0b, 0x31, 0x3d, 0x86, 0xa3, 0xfa, 0x5a, 0x40, 0xed, 0x22, 0x7e, 0x14, 0x44, 0x7e, - 0x77, 0x0c, 0x91, 0x2b, 0x29, 0xde, 0x94, 0x14, 0x4b, 0xe0, 0x67, 0x43, 0x98, 0xee, 0xea, 0x50, - 0x38, 0x4a, 0xe6, 0x01, 0x51, 0x90, 0x2c, 0x3e, 0xe5, 0xda, 0xb9, 0x31, 0xea, 0xe5, 0x11, 0xea, - 0xd9, 0x54, 0x21, 0x92, 0x4e, 0x15, 0x03, 0x65, 0x21, 0x9f, 0x98, 0xa9, 0x94, 0xdd, 0xfd, 0x1b, - 0xe7, 0xa9, 0x8c, 0xf2, 0x4c, 0x4e, 0xd4, 0x32, 0x46, 0x64, 0x7c, 0x9e, 0xfe, 0x87, 0xe2, 0x8f, - 0x40, 0x9f, 0x25, 0x23, 0x63, 0xf9, 0x39, 0x58, 0xce, 0x10, 0x4d, 0x76, 0x5a, 0x53, 0x6a, 0x85, - 0x7f, 0x33, 0xbd, 0x34, 0x74, 0x10, 0x37, 0x66, 0x7e, 0x53, 0x40, 0xa9, 0xce, 0xc2, 0xc3, 0xae, - 0xdf, 0x39, 0x88, 0x02, 0x18, 0xa9, 0xbb, 0x60, 0x1e, 0x91, 0x4e, 0xcc, 0x25, 0xb5, 0x15, 0x6b, - 0xfa, 0x37, 0x62, 0xed, 0x0b, 0xb5, 0x33, 0x27, 0x70, 0x72, 0x53, 0x5b, 0xf5, 0x31, 0x58, 0xa0, - 0x31, 0x17, 0x5e, 0xf9, 0xc4, 0x4b, 0x9b, 0xf5, 0x3a, 0x48, 0xf4, 0xd2, 0x4d, 0x5a, 0x4f, 0x20, - 0x52, 0x98, 0x42, 0xe4, 0x29, 0x28, 0x21, 0xe6, 0x35, 0xe2, 0xbe, 0x47, 0x45, 0x61, 0x09, 0x62, - 0x45, 0xa7, 0x72, 0x31, 0xa8, 0xae, 0xa5, 0x80, 0x8f, 0x6b, 0x4d, 0x17, 0x20, 0xe6, 0xc4, 0xfd, - 0xa4, 0x07, 0xf3, 0x36, 0x58, 0x93, 0x3d, 0x25, 0x2d, 0x4b, 0xb4, 0x76, 0xbe, 0xe6, 0x41, 0xa1, - 0xce, 0x42, 0xf5, 0x03, 0x28, 0x4d, 0xfc, 0xb4, 0x36, 0x67, 0xab, 0x9d, 0x5a, 0x2b, 0xfd, 0xc1, - 0x95, 0x26, 0x19, 0x27, 0x10, 0xac, 0x4c, 0xef, 0xce, 0xdd, 0x4b, 0xbd, 0xa7, 0xac, 0xf4, 0x87, - 0xd7, 0xb1, 0xca, 0xd2, 0xbc, 0x05, 0xc5, 0x61, 0x83, 0xaa, 0x71, 0xa9, 0x67, 0xc6, 0xa9, 0x7e, - 0xef, 0xaf, 0xfa, 0x71, 0x7c, 0x9c, 0x83, 0x93, 0x5f, 0x46, 0xee, 0xe4, 0xcc, 0x50, 0x4e, 0xcf, - 0x0c, 0xe5, 0xe7, 0x99, 0xa1, 0x7c, 0x39, 0x37, 0x72, 0xa7, 0xe7, 0x46, 0xee, 0xfb, 0xb9, 0x91, - 0x7b, 0xbf, 0x3d, 0xb6, 0x10, 0x22, 0x1c, 0x81, 0xdc, 0x96, 0x61, 0x6d, 0x4c, 0x83, 0xb8, 0x0d, - 0x99, 0x3d, 0x7a, 0x85, 0xc4, 0x7e, 0x34, 0x16, 0x92, 0x87, 0x62, 0xf7, 0x4f, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x78, 0x31, 0x1c, 0x72, 0x9e, 0x06, 0x00, 0x00, + // 883 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x56, 0x41, 0x6f, 0xe3, 0x44, + 0x14, 0x8e, 0x93, 0x6e, 0xd5, 0xbc, 0xed, 0xb6, 0xe9, 0xec, 0xd2, 0xa4, 0x16, 0x38, 0xad, 0xb5, + 0xa0, 0x22, 0xc0, 0x56, 0xb7, 0xd2, 0x0a, 0xb8, 0x6d, 0x40, 0x2b, 0x2a, 0xb6, 0xea, 0xe2, 0x02, + 0x07, 0x04, 0x8a, 0x26, 0xf1, 0x28, 0x3b, 0x6a, 0x3c, 0x93, 0xf5, 0x8c, 0xb7, 0x0d, 0x57, 0x8e, + 0x5c, 0xf8, 0x07, 0xfc, 0x9d, 0x1e, 0x57, 0x9c, 0x10, 0x87, 0x08, 0x5a, 0xf1, 0x07, 0xfa, 0x07, + 0x40, 0x63, 0x4f, 0x6c, 0xc7, 0x49, 0xda, 0x0d, 0x2c, 0x12, 0x27, 0x8f, 0xdf, 0xbc, 0xf9, 0xde, + 0x7b, 0xdf, 0xf7, 0xe6, 0xd9, 0xb0, 0xd1, 0xe5, 0x94, 0x89, 0x53, 0x3c, 0x70, 0xe5, 0x99, 0x33, + 0x08, 0xb9, 0xe4, 0xa8, 0x46, 0x43, 0x2a, 0x02, 0xee, 0x3b, 0xe3, 0x2d, 0xb3, 0x9e, 0x3a, 0x8d, + 0x17, 0x89, 0xab, 0x69, 0x75, 0xb9, 0x08, 0xb8, 0x70, 0x3b, 0x58, 0x10, 0xf7, 0xc5, 0x5e, 0x87, + 0x48, 0xbc, 0x17, 0xfb, 0xe8, 0xfd, 0x7b, 0x3d, 0xde, 0xe3, 0xf1, 0xd2, 0x55, 0xab, 0xc4, 0x6a, + 0xff, 0x55, 0x86, 0xf5, 0x43, 0xd1, 0x7b, 0xe4, 0xfb, 0x4f, 0xe8, 0xf3, 0x88, 0xfa, 0x54, 0x0e, + 0xd1, 0x53, 0xa8, 0x06, 0xf8, 0xac, 0x2d, 0xf9, 0x09, 0x61, 0x0d, 0x63, 0xdb, 0xd8, 0xbd, 0xfd, + 0x60, 0xcb, 0x49, 0xd0, 0x1d, 0x85, 0xee, 0x68, 0x74, 0xe7, 0x13, 0x4e, 0x59, 0xab, 0x71, 0x3e, + 0x6a, 0x96, 0xae, 0x46, 0xcd, 0xda, 0x10, 0x07, 0xfd, 0x8f, 0xed, 0xf4, 0xa4, 0xed, 0xad, 0x04, + 0xf8, 0xec, 0x4b, 0xb5, 0x44, 0x43, 0x40, 0xe4, 0x0c, 0x77, 0x65, 0x5b, 0x48, 0xcc, 0x7c, 0x1c, + 0xfa, 0x6d, 0x1c, 0xc8, 0x46, 0x79, 0xdb, 0xd8, 0xad, 0xb6, 0x3e, 0x57, 0xe7, 0x7f, 0x1b, 0x35, + 0xdf, 0xe9, 0x51, 0xf9, 0x2c, 0xea, 0x38, 0x5d, 0x1e, 0xb8, 0xba, 0x94, 0xe4, 0xf1, 0x81, 0xf0, + 0x4f, 0x5c, 0x39, 0x1c, 0x10, 0xe1, 0x1c, 0x30, 0x79, 0x35, 0x6a, 0x6e, 0x25, 0x91, 0xa6, 0x11, + 0x6d, 0xaf, 0x16, 0x1b, 0x8f, 0xb5, 0xed, 0x51, 0x20, 0xd1, 0x09, 0xdc, 0x09, 0x28, 0x6b, 0xf7, + 0xc7, 0xd5, 0x35, 0x2a, 0x71, 0xd4, 0xc7, 0x0b, 0x47, 0xbd, 0xa7, 0xeb, 0xcb, 0x83, 0xd9, 0xde, + 0x6a, 0x40, 0x59, 0xc6, 0x9c, 0x09, 0x2b, 0x3e, 0xc1, 0x7e, 0x9f, 0x32, 0xd2, 0x58, 0xda, 0x36, + 0x76, 0x2b, 0x5e, 0xfa, 0x8e, 0x36, 0x61, 0x59, 0x10, 0xe6, 0x93, 0xb0, 0x71, 0x4b, 0x65, 0xe0, + 0xe9, 0x37, 0xfb, 0x18, 0xea, 0x05, 0x01, 0x3c, 0x22, 0x06, 0x9c, 0x09, 0x82, 0x3e, 0x04, 0x08, + 0x28, 0x93, 0xaf, 0xa8, 0x84, 0x57, 0x55, 0xce, 0x31, 0xe1, 0xf6, 0x45, 0x19, 0xb6, 0x12, 0xd4, + 0xaf, 0x18, 0xed, 0x63, 0x49, 0x42, 0xdc, 0xcf, 0xd2, 0x7c, 0x02, 0xa8, 0xcb, 0x23, 0x26, 0x49, + 0x38, 0xc0, 0xa1, 0x1c, 0xb6, 0x7d, 0xc2, 0x78, 0x10, 0xe3, 0x57, 0x5b, 0x6f, 0x65, 0x04, 0x77, + 0x39, 0x8b, 0x26, 0x7d, 0x6c, 0x6f, 0x23, 0x7f, 0xf0, 0x53, 0x65, 0x43, 0x5f, 0xc3, 0xed, 0x44, + 0x8a, 0x24, 0xcd, 0xf2, 0x4d, 0x0d, 0x63, 0xea, 0x86, 0x41, 0x79, 0x19, 0x75, 0xcb, 0x40, 0xfc, + 0x96, 0x34, 0xcd, 0xff, 0x5e, 0xb9, 0xef, 0x60, 0x67, 0x2e, 0xc7, 0xaf, 0x41, 0xc3, 0x1f, 0x2b, + 0x80, 0x0e, 0x45, 0xcf, 0x23, 0x01, 0x7f, 0x41, 0xb2, 0x4c, 0x4f, 0x00, 0x9d, 0x52, 0xf9, 0xcc, + 0x0f, 0xf1, 0x69, 0x8e, 0x9b, 0x1b, 0xaf, 0xe9, 0x8e, 0x66, 0x5d, 0x6b, 0x3b, 0x0d, 0x61, 0x7b, + 0x1b, 0x63, 0x63, 0x16, 0xac, 0x0d, 0x2a, 0xa1, 0x9c, 0xb2, 0xd5, 0x56, 0x6b, 0x61, 0xfe, 0x6b, + 0x19, 0xff, 0xe9, 0x64, 0xa0, 0x2c, 0x11, 0x59, 0x40, 0x4d, 0xd9, 0x27, 0xe6, 0x42, 0xa2, 0xf3, + 0xc1, 0xc2, 0x71, 0xea, 0x59, 0x9c, 0xc9, 0xa9, 0xb0, 0x16, 0x50, 0x96, 0x9f, 0x09, 0xff, 0x44, + 0x6c, 0x1f, 0xcc, 0x69, 0x31, 0x52, 0x95, 0x1f, 0xc3, 0x5a, 0xca, 0x68, 0x3c, 0x97, 0x1b, 0xc6, + 0x76, 0xe5, 0x7a, 0x41, 0x96, 0x54, 0x7d, 0xde, 0x9d, 0xf1, 0x31, 0x65, 0x13, 0xf6, 0x9f, 0x65, + 0x78, 0x33, 0x0d, 0xf3, 0xdf, 0x5f, 0xdd, 0xa7, 0x45, 0x79, 0x17, 0x9a, 0xf4, 0xb3, 0xf4, 0x7c, + 0x0e, 0xeb, 0xc9, 0x85, 0x2e, 0x5e, 0xdb, 0xcf, 0x16, 0x96, 0x73, 0x33, 0x3f, 0x1f, 0x72, 0x6d, + 0xba, 0x16, 0x5b, 0xfe, 0xdd, 0xd5, 0x65, 0x70, 0xff, 0x3a, 0x9a, 0x5f, 0xbb, 0xae, 0xbf, 0x18, + 0xb0, 0x7a, 0x28, 0x7a, 0xc7, 0xa7, 0x78, 0x70, 0x14, 0xfa, 0x24, 0x44, 0xfb, 0x70, 0x8b, 0xb2, + 0x41, 0x24, 0xf5, 0xc5, 0xad, 0x3b, 0xc5, 0x0f, 0xbd, 0x73, 0xa0, 0xb6, 0x35, 0x5a, 0xe2, 0x8b, + 0x1e, 0xc2, 0x32, 0x8f, 0xa4, 0x3a, 0x95, 0x68, 0xd5, 0x98, 0x3e, 0x75, 0x14, 0xef, 0xeb, 0x63, + 0xda, 0x7b, 0x82, 0xa1, 0x4a, 0x81, 0xa1, 0x8f, 0x60, 0x95, 0x8a, 0x76, 0x27, 0x1a, 0xb6, 0xb9, + 0x4a, 0x2c, 0x66, 0x70, 0xa5, 0x55, 0xbf, 0x1a, 0x35, 0xef, 0x26, 0xfc, 0xe7, 0x77, 0x6d, 0x0f, + 0xa8, 0x68, 0x45, 0xc3, 0xb8, 0x06, 0xfb, 0x0d, 0xb8, 0xab, 0x6b, 0x8a, 0x47, 0x97, 0xe6, 0xec, + 0xc1, 0xcf, 0x4b, 0x50, 0x39, 0x14, 0x3d, 0xf4, 0x2d, 0xac, 0x4e, 0xfc, 0x56, 0xec, 0x4c, 0x67, + 0x5b, 0xf8, 0xf0, 0x99, 0xef, 0xde, 0xe8, 0x92, 0x2a, 0xf3, 0x3d, 0x6c, 0xce, 0xf9, 0xba, 0xbd, + 0x37, 0x0f, 0x64, 0x86, 0xb3, 0xb9, 0xbf, 0x80, 0x73, 0x1a, 0x9b, 0xc0, 0x7a, 0x71, 0x2a, 0xdf, + 0x9f, 0x89, 0x53, 0xf0, 0x32, 0xdf, 0x7f, 0x15, 0xaf, 0x34, 0xcc, 0x0f, 0x06, 0x6c, 0xcd, 0x9f, + 0x04, 0xce, 0x35, 0x58, 0xb3, 0x2a, 0x7d, 0xb8, 0x98, 0x7f, 0x9a, 0xc5, 0x17, 0xb0, 0x32, 0x96, + 0x18, 0x59, 0x33, 0x31, 0xd2, 0xae, 0x36, 0xdf, 0x9e, 0xbb, 0x9f, 0xef, 0x90, 0xd6, 0xd1, 0xf9, + 0x1f, 0x56, 0xe9, 0xfc, 0xc2, 0x32, 0x5e, 0x5e, 0x58, 0xc6, 0xef, 0x17, 0x96, 0xf1, 0xd3, 0xa5, + 0x55, 0x7a, 0x79, 0x69, 0x95, 0x7e, 0xbd, 0xb4, 0x4a, 0xdf, 0xec, 0xe5, 0x26, 0x84, 0x82, 0x63, + 0x44, 0xba, 0x1a, 0xd6, 0x0d, 0xb8, 0x1f, 0xf5, 0x89, 0x70, 0xb3, 0x3f, 0x65, 0x35, 0x30, 0x3a, + 0xcb, 0xf1, 0xcf, 0xec, 0xfe, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x82, 0x02, 0x13, 0x56, 0x42, + 0x0b, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -339,11 +518,20 @@ const _ = grpc.SupportPackageIsVersion4 // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. type MsgClient interface { - // AddLiquidity defines a method for depositing some tokens to the liquidity pool + // AddLiquidity defines a method for depositing some tokens to the liquidity + // pool AddLiquidity(ctx context.Context, in *MsgAddLiquidity, opts ...grpc.CallOption) (*MsgAddLiquidityResponse, error) - // RemoveLiquidity defines a method for withdraw some tokens from the liquidity pool + // AddUnilateralLiquidity defines a method for depositing some tokens + // unilaterally to the liquidity pool + AddUnilateralLiquidity(ctx context.Context, in *MsgAddUnilateralLiquidity, opts ...grpc.CallOption) (*MsgAddUnilateralLiquidityResponse, error) + // RemoveLiquidity defines a method for withdraw some tokens from the + // liquidity pool RemoveLiquidity(ctx context.Context, in *MsgRemoveLiquidity, opts ...grpc.CallOption) (*MsgRemoveLiquidityResponse, error) - // SwapCoin defines a method for swapping a token with the other token from the liquidity pool + // RemoveUnilateralLiquidity defines a method for withdraw some tokens + // unilaterally from the liquidity pool + RemoveUnilateralLiquidity(ctx context.Context, in *MsgRemoveUnilateralLiquidity, opts ...grpc.CallOption) (*MsgRemoveUnilateralLiquidityResponse, error) + // SwapCoin defines a method for swapping a token with the other token from + // the liquidity pool SwapCoin(ctx context.Context, in *MsgSwapOrder, opts ...grpc.CallOption) (*MsgSwapCoinResponse, error) } @@ -364,6 +552,15 @@ func (c *msgClient) AddLiquidity(ctx context.Context, in *MsgAddLiquidity, opts return out, nil } +func (c *msgClient) AddUnilateralLiquidity(ctx context.Context, in *MsgAddUnilateralLiquidity, opts ...grpc.CallOption) (*MsgAddUnilateralLiquidityResponse, error) { + out := new(MsgAddUnilateralLiquidityResponse) + err := c.cc.Invoke(ctx, "/irismod.coinswap.Msg/AddUnilateralLiquidity", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) RemoveLiquidity(ctx context.Context, in *MsgRemoveLiquidity, opts ...grpc.CallOption) (*MsgRemoveLiquidityResponse, error) { out := new(MsgRemoveLiquidityResponse) err := c.cc.Invoke(ctx, "/irismod.coinswap.Msg/RemoveLiquidity", in, out, opts...) @@ -373,6 +570,15 @@ func (c *msgClient) RemoveLiquidity(ctx context.Context, in *MsgRemoveLiquidity, return out, nil } +func (c *msgClient) RemoveUnilateralLiquidity(ctx context.Context, in *MsgRemoveUnilateralLiquidity, opts ...grpc.CallOption) (*MsgRemoveUnilateralLiquidityResponse, error) { + out := new(MsgRemoveUnilateralLiquidityResponse) + err := c.cc.Invoke(ctx, "/irismod.coinswap.Msg/RemoveUnilateralLiquidity", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *msgClient) SwapCoin(ctx context.Context, in *MsgSwapOrder, opts ...grpc.CallOption) (*MsgSwapCoinResponse, error) { out := new(MsgSwapCoinResponse) err := c.cc.Invoke(ctx, "/irismod.coinswap.Msg/SwapCoin", in, out, opts...) @@ -384,11 +590,20 @@ func (c *msgClient) SwapCoin(ctx context.Context, in *MsgSwapOrder, opts ...grpc // MsgServer is the server API for Msg service. type MsgServer interface { - // AddLiquidity defines a method for depositing some tokens to the liquidity pool + // AddLiquidity defines a method for depositing some tokens to the liquidity + // pool AddLiquidity(context.Context, *MsgAddLiquidity) (*MsgAddLiquidityResponse, error) - // RemoveLiquidity defines a method for withdraw some tokens from the liquidity pool + // AddUnilateralLiquidity defines a method for depositing some tokens + // unilaterally to the liquidity pool + AddUnilateralLiquidity(context.Context, *MsgAddUnilateralLiquidity) (*MsgAddUnilateralLiquidityResponse, error) + // RemoveLiquidity defines a method for withdraw some tokens from the + // liquidity pool RemoveLiquidity(context.Context, *MsgRemoveLiquidity) (*MsgRemoveLiquidityResponse, error) - // SwapCoin defines a method for swapping a token with the other token from the liquidity pool + // RemoveUnilateralLiquidity defines a method for withdraw some tokens + // unilaterally from the liquidity pool + RemoveUnilateralLiquidity(context.Context, *MsgRemoveUnilateralLiquidity) (*MsgRemoveUnilateralLiquidityResponse, error) + // SwapCoin defines a method for swapping a token with the other token from + // the liquidity pool SwapCoin(context.Context, *MsgSwapOrder) (*MsgSwapCoinResponse, error) } @@ -399,9 +614,15 @@ type UnimplementedMsgServer struct { func (*UnimplementedMsgServer) AddLiquidity(ctx context.Context, req *MsgAddLiquidity) (*MsgAddLiquidityResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method AddLiquidity not implemented") } +func (*UnimplementedMsgServer) AddUnilateralLiquidity(ctx context.Context, req *MsgAddUnilateralLiquidity) (*MsgAddUnilateralLiquidityResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddUnilateralLiquidity not implemented") +} func (*UnimplementedMsgServer) RemoveLiquidity(ctx context.Context, req *MsgRemoveLiquidity) (*MsgRemoveLiquidityResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method RemoveLiquidity not implemented") } +func (*UnimplementedMsgServer) RemoveUnilateralLiquidity(ctx context.Context, req *MsgRemoveUnilateralLiquidity) (*MsgRemoveUnilateralLiquidityResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method RemoveUnilateralLiquidity not implemented") +} func (*UnimplementedMsgServer) SwapCoin(ctx context.Context, req *MsgSwapOrder) (*MsgSwapCoinResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method SwapCoin not implemented") } @@ -428,6 +649,24 @@ func _Msg_AddLiquidity_Handler(srv interface{}, ctx context.Context, dec func(in return interceptor(ctx, in, info, handler) } +func _Msg_AddUnilateralLiquidity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgAddUnilateralLiquidity) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).AddUnilateralLiquidity(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/irismod.coinswap.Msg/AddUnilateralLiquidity", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).AddUnilateralLiquidity(ctx, req.(*MsgAddUnilateralLiquidity)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_RemoveLiquidity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgRemoveLiquidity) if err := dec(in); err != nil { @@ -446,6 +685,24 @@ func _Msg_RemoveLiquidity_Handler(srv interface{}, ctx context.Context, dec func return interceptor(ctx, in, info, handler) } +func _Msg_RemoveUnilateralLiquidity_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgRemoveUnilateralLiquidity) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).RemoveUnilateralLiquidity(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/irismod.coinswap.Msg/RemoveUnilateralLiquidity", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).RemoveUnilateralLiquidity(ctx, req.(*MsgRemoveUnilateralLiquidity)) + } + return interceptor(ctx, in, info, handler) +} + func _Msg_SwapCoin_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(MsgSwapOrder) if err := dec(in); err != nil { @@ -472,10 +729,18 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "AddLiquidity", Handler: _Msg_AddLiquidity_Handler, }, + { + MethodName: "AddUnilateralLiquidity", + Handler: _Msg_AddUnilateralLiquidity_Handler, + }, { MethodName: "RemoveLiquidity", Handler: _Msg_RemoveLiquidity_Handler, }, + { + MethodName: "RemoveUnilateralLiquidity", + Handler: _Msg_RemoveUnilateralLiquidity_Handler, + }, { MethodName: "SwapCoin", Handler: _Msg_SwapCoin_Handler, @@ -585,6 +850,103 @@ func (m *MsgAddLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgAddUnilateralLiquidity) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddUnilateralLiquidity) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddUnilateralLiquidity) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x2a + } + if m.Deadline != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Deadline)) + i-- + dAtA[i] = 0x20 + } + { + size := m.MinLiquidity.Size() + i -= size + if _, err := m.MinLiquidity.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + { + size, err := m.ExactToken.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + if len(m.CounterpartyDenom) > 0 { + i -= len(m.CounterpartyDenom) + copy(dAtA[i:], m.CounterpartyDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgAddUnilateralLiquidityResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgAddUnilateralLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgAddUnilateralLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MintToken != nil { + { + size, err := m.MintToken.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *MsgRemoveLiquidity) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -687,7 +1049,7 @@ func (m *MsgRemoveLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, err return len(dAtA) - i, nil } -func (m *MsgSwapOrder) Marshal() (dAtA []byte, err error) { +func (m *MsgRemoveUnilateralLiquidity) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -697,43 +1059,40 @@ func (m *MsgSwapOrder) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *MsgSwapOrder) MarshalTo(dAtA []byte) (int, error) { +func (m *MsgRemoveUnilateralLiquidity) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *MsgSwapOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *MsgRemoveUnilateralLiquidity) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.IsBuyOrder { - i-- - if m.IsBuyOrder { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) i-- - dAtA[i] = 0x20 + dAtA[i] = 0x2a } if m.Deadline != 0 { i = encodeVarintTx(dAtA, i, uint64(m.Deadline)) i-- - dAtA[i] = 0x18 + dAtA[i] = 0x20 } { - size, err := m.Output.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { + size := m.ExactLiquidity.Size() + i -= size + if _, err := m.ExactLiquidity.MarshalTo(dAtA[i:]); err != nil { return 0, err } - i -= size i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0x1a { - size, err := m.Input.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.MinToken.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -741,10 +1100,112 @@ func (m *MsgSwapOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintTx(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - + dAtA[i] = 0x12 + if len(m.CounterpartyDenom) > 0 { + i -= len(m.CounterpartyDenom) + copy(dAtA[i:], m.CounterpartyDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.CounterpartyDenom))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgRemoveUnilateralLiquidityResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgRemoveUnilateralLiquidityResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgRemoveUnilateralLiquidityResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.WithdrawCoins) > 0 { + for iNdEx := len(m.WithdrawCoins) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.WithdrawCoins[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *MsgSwapOrder) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *MsgSwapOrder) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgSwapOrder) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsBuyOrder { + i-- + if m.IsBuyOrder { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.Deadline != 0 { + i = encodeVarintTx(dAtA, i, uint64(m.Deadline)) + i-- + dAtA[i] = 0x18 + } + { + size, err := m.Output.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + { + size, err := m.Input.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + return len(dAtA) - i, nil +} + func (m *MsgSwapCoinResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -814,6 +1275,43 @@ func (m *MsgAddLiquidityResponse) Size() (n int) { return n } +func (m *MsgAddUnilateralLiquidity) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CounterpartyDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.ExactToken.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.MinLiquidity.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Deadline != 0 { + n += 1 + sovTx(uint64(m.Deadline)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgAddUnilateralLiquidityResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MintToken != nil { + l = m.MintToken.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func (m *MsgRemoveLiquidity) Size() (n int) { if m == nil { return 0 @@ -851,6 +1349,45 @@ func (m *MsgRemoveLiquidityResponse) Size() (n int) { return n } +func (m *MsgRemoveUnilateralLiquidity) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.CounterpartyDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = m.MinToken.Size() + n += 1 + l + sovTx(uint64(l)) + l = m.ExactLiquidity.Size() + n += 1 + l + sovTx(uint64(l)) + if m.Deadline != 0 { + n += 1 + sovTx(uint64(m.Deadline)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgRemoveUnilateralLiquidityResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.WithdrawCoins) > 0 { + for _, e := range m.WithdrawCoins { + l = e.Size() + n += 1 + l + sovTx(uint64(l)) + } + } + return n +} + func (m *MsgSwapOrder) Size() (n int) { if m == nil { return 0 @@ -1173,7 +1710,7 @@ func (m *MsgAddLiquidityResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { +func (m *MsgAddUnilateralLiquidity) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1196,17 +1733,17 @@ func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveLiquidity: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddUnilateralLiquidity: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveLiquidity: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddUnilateralLiquidity: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WithdrawLiquidity", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyDenom", wireType) } - var msglen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1216,30 +1753,29 @@ func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if msglen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + msglen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.WithdrawLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } + m.CounterpartyDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinToken", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ExactToken", wireType) } - var stringLen uint64 + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowTx @@ -1249,29 +1785,28 @@ func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if msglen < 0 { return ErrInvalidLengthTx } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + msglen if postIndex < 0 { return ErrInvalidLengthTx } if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MinToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.ExactToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinStandardAmt", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MinLiquidity", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1299,7 +1834,7 @@ func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.MinStandardAmt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.MinLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1375,7 +1910,7 @@ func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgRemoveLiquidityResponse) Unmarshal(dAtA []byte) error { +func (m *MsgAddUnilateralLiquidityResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1398,10 +1933,582 @@ func (m *MsgRemoveLiquidityResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgRemoveLiquidityResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgAddUnilateralLiquidityResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgRemoveLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgAddUnilateralLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MintToken", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MintToken == nil { + m.MintToken = &types.Coin{} + } + if err := m.MintToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveLiquidity) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveLiquidity: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveLiquidity: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawLiquidity", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.WithdrawLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinToken", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStandardAmt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinStandardAmt.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deadline", wireType) + } + m.Deadline = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Deadline |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveLiquidityResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveLiquidityResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field WithdrawCoins", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.WithdrawCoins = append(m.WithdrawCoins, types.Coin{}) + if err := m.WithdrawCoins[len(m.WithdrawCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveUnilateralLiquidity) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveUnilateralLiquidity: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveUnilateralLiquidity: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CounterpartyDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.CounterpartyDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinToken", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.MinToken.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ExactLiquidity", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if err := m.ExactLiquidity.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Deadline", wireType) + } + m.Deadline = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Deadline |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgRemoveUnilateralLiquidityResponse) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: MsgRemoveUnilateralLiquidityResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgRemoveUnilateralLiquidityResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1433,7 +2540,7 @@ func (m *MsgRemoveLiquidityResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.WithdrawCoins = append(m.WithdrawCoins, &types.Coin{}) + m.WithdrawCoins = append(m.WithdrawCoins, types.Coin{}) if err := m.WithdrawCoins[len(m.WithdrawCoins)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } diff --git a/modules/coinswap/types/utils.go b/modules/coinswap/types/utils.go index 2a315f19..7037c070 100644 --- a/modules/coinswap/types/utils.go +++ b/modules/coinswap/types/utils.go @@ -20,7 +20,7 @@ func GetTokenPairByDenom(inputDenom, outputDenom string) string { return fmt.Sprintf("%s-%s", outputDenom, inputDenom) } -// GetPoolId returns the pool coin denom by specified sequence. +// GetPoolId returns the pool-id by counterpartyDenom. func GetPoolId(counterpartyDenom string) string { return fmt.Sprintf("pool-%s", counterpartyDenom) } diff --git a/modules/coinswap/types/validation.go b/modules/coinswap/types/validation.go index 2e604af4..5ec3d7f1 100644 --- a/modules/coinswap/types/validation.go +++ b/modules/coinswap/types/validation.go @@ -4,6 +4,7 @@ import ( fmt "fmt" "strings" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) @@ -60,24 +61,44 @@ func ValidateMaxToken(maxToken sdk.Coin) error { return nil } +// ValidateToken verifies whether the exact token is legal +func ValidateToken(exactToken sdk.Coin) error { + if !(exactToken.IsValid() && exactToken.IsPositive()) { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidCoins, "invalid exactToken (%s)", exactToken.String()) + } + + if strings.HasPrefix(exactToken.Denom, LptTokenPrefix) { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "token must be non-liquidity token") + } + return nil +} + +// ValidateCounterpartyDenom verifies whether the counterparty denom is legal +func ValidateCounterpartyDenom(counterpartydenom string) error { + if counterpartydenom == "" { + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "counterparty denom should not be empty") + } + return nil +} + // ValidateExactStandardAmt verifies whether the standard token amount is legal -func ValidateExactStandardAmt(standardAmt sdk.Int) error { +func ValidateExactStandardAmt(standardAmt sdkmath.Int) error { if !standardAmt.IsPositive() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "standard token amount must be positive") } return nil } -// ValidateMinLiquidity verifies whether the minimum liquidity is legal -func ValidateMinLiquidity(minLiquidity sdk.Int) error { +// ValidateLiquidity verifies whether the minimum liquidity is legal +func ValidateLiquidity(minLiquidity sdkmath.Int) error { if minLiquidity.IsNegative() { - return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "minimum liquidity can not be negative") + return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, "liquidity can not be negative") } return nil } // ValidateMinToken verifies whether the minimum token amount is legal -func ValidateMinToken(minToken sdk.Int) error { +func ValidateMinToken(minToken sdkmath.Int) error { if minToken.IsNegative() { return sdkerrors.Wrap(sdkerrors.ErrInvalidCoins, "minimum token amount can not be negative") } @@ -97,7 +118,7 @@ func ValidateWithdrawLiquidity(liquidity sdk.Coin) error { } // ValidateMinStandardAmt verifies whether the minimum standard amount is legal -func ValidateMinStandardAmt(minStandardAmt sdk.Int) error { +func ValidateMinStandardAmt(minStandardAmt sdkmath.Int) error { if minStandardAmt.IsNegative() { return sdkerrors.Wrap(sdkerrors.ErrInvalidRequest, fmt.Sprintf("minimum standard token amount %s can not be negative", minStandardAmt.String())) } @@ -111,3 +132,11 @@ func ValidateLptDenom(lptDenom string) error { } return nil } + +// ValidatePoolSequenceId returns nil if the pool id is valid +func ValidatePoolSequenceId(poolId uint64) error { + if poolId == 0 { + return sdkerrors.Wrap(ErrReservePoolNotExists, "pool-id is not valid") + } + return nil +} diff --git a/modules/farm/client/cli/cli_test.go b/modules/farm/client/cli/cli_test.go index 1731f7fd..6c89dcf4 100644 --- a/modules/farm/client/cli/cli_test.go +++ b/modules/farm/client/cli/cli_test.go @@ -31,10 +31,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg := simapp.NewConfig() cfg.NumValidators = 1 + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/farm/client/rest/rest.go b/modules/farm/client/rest/rest.go deleted file mode 100644 index 3eb7a8ec..00000000 --- a/modules/farm/client/rest/rest.go +++ /dev/null @@ -1,12 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" -) - -// RegisterHandlers defines routes that get registered by the main application -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerTxRoutes(cliCtx, r) -} diff --git a/modules/farm/client/rest/tx.go b/modules/farm/client/rest/tx.go deleted file mode 100644 index 46c6837a..00000000 --- a/modules/farm/client/rest/tx.go +++ /dev/null @@ -1,11 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - -} diff --git a/modules/farm/client/rest/grpc_query_test.go b/modules/farm/client/testutil/grpc_query_test.go similarity index 95% rename from modules/farm/client/rest/grpc_query_test.go rename to modules/farm/client/testutil/grpc_query_test.go index 443d67eb..37cd9698 100644 --- a/modules/farm/client/rest/grpc_query_test.go +++ b/modules/farm/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "fmt" @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" farmcli "github.com/irisnet/irismod/modules/farm/client/cli" "github.com/irisnet/irismod/modules/farm/client/testutil" @@ -33,9 +33,11 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/farm/handler.go b/modules/farm/handler.go index 4247886b..65b1b9f0 100644 --- a/modules/farm/handler.go +++ b/modules/farm/handler.go @@ -3,7 +3,7 @@ package farm import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/irisnet/irismod/modules/farm/keeper" "github.com/irisnet/irismod/modules/farm/types" @@ -45,8 +45,8 @@ func NewHandler(k keeper.Keeper) sdk.Handler { } } -func NewCommunityPoolCreateFarmProposalHandler(k keeper.Keeper) govtypes.Handler { - return func(ctx sdk.Context, content govtypes.Content) error { +func NewCommunityPoolCreateFarmProposalHandler(k keeper.Keeper) govv1beta1.Handler { + return func(ctx sdk.Context, content govv1beta1.Content) error { switch c := content.(type) { case *types.CommunityPoolCreateFarmProposal: return k.HandleCreateFarmProposal(ctx, c) diff --git a/modules/farm/keeper/keeper.go b/modules/farm/keeper/keeper.go index ec6ffda9..199c0a86 100644 --- a/modules/farm/keeper/keeper.go +++ b/modules/farm/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -15,7 +16,7 @@ import ( // Keeper of the farm store type Keeper struct { cdc codec.Codec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey paramSpace paramstypes.Subspace validateLPToken types.ValidateLPToken bk types.BankKeeper @@ -27,7 +28,7 @@ type Keeper struct { func NewKeeper( cdc codec.Codec, - storeKey sdk.StoreKey, + storeKey storetypes.StoreKey, bk types.BankKeeper, ak types.AccountKeeper, dk types.DistrKeeper, diff --git a/modules/farm/keeper/keeper_test.go b/modules/farm/keeper/keeper_test.go index 315efb60..1fbc921b 100644 --- a/modules/farm/keeper/keeper_test.go +++ b/modules/farm/keeper/keeper_test.go @@ -48,7 +48,7 @@ func TestKeeperTestSuite(t *testing.T) { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(isCheckTx) + app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{Height: 1}) suite.app = app @@ -111,8 +111,8 @@ func (suite *KeeperTestSuite) TestCreatePool() { //check balance expectedBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, testInitCoinAmt)). - Sub(sdk.NewCoins(suite.keeper.CreatePoolFee(ctx))). - Sub(testTotalReward) + Sub(sdk.NewCoins(suite.keeper.CreatePoolFee(ctx))...). + Sub(testTotalReward...) actualBal := suite.app.BankKeeper.GetAllBalances(ctx, testCreator) suite.Require().Equal(expectedBal, actualBal) } @@ -145,7 +145,7 @@ func (suite *KeeperTestSuite) TestDestroyPool() { //check balance expectedBal := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, testInitCoinAmt)). - Sub(sdk.NewCoins(suite.keeper.CreatePoolFee(ctx))) + Sub(sdk.NewCoins(suite.keeper.CreatePoolFee(ctx))...) actualBal := suite.app.BankKeeper.GetAllBalances(ctx, testCreator) suite.Require().Equal(expectedBal, actualBal) diff --git a/modules/farm/keeper/msg_server.go b/modules/farm/keeper/msg_server.go index db64a4b4..a4bf5839 100644 --- a/modules/farm/keeper/msg_server.go +++ b/modules/farm/keeper/msg_server.go @@ -4,8 +4,10 @@ import ( "context" "fmt" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/irisnet/irismod/modules/farm/types" ) @@ -121,14 +123,26 @@ func (m msgServer) CreatePoolWithCommunityPool(goCtx context.Context, return nil, err } + data, err := codectypes.NewAnyWithValue(&msg.Content) + if err != nil { + return nil, err + } + + msgs := []sdk.Msg{ + &govv1.MsgExecLegacyContent{ + Content: data, + Authority: m.gk.GetGovernanceAccount(ctx).GetAddress().String(), + }, + } + //create new proposal given a content - proposal, err := m.gk.SubmitProposal(ctx, &msg.Content) + proposal, err := m.gk.SubmitProposal(ctx, msgs, "") if err != nil { return nil, err } // adds a deposit of a specific depositor on a specific proposal - _, err = m.gk.AddDeposit(ctx, proposal.ProposalId, proposer, msg.InitialDeposit) + _, err = m.gk.AddDeposit(ctx, proposal.Id, proposer, msg.InitialDeposit) if err != nil { return nil, err } @@ -138,13 +152,13 @@ func (m msgServer) CreatePoolWithCommunityPool(goCtx context.Context, Proposer: msg.Proposer, FundApplied: msg.Content.FundApplied, FundSelfBond: msg.Content.FundSelfBond, - ProposalId: proposal.ProposalId, + ProposalId: proposal.Id, }) ctx.EventManager().EmitEvents(sdk.Events{ sdk.NewEvent( types.EventTypeCreatePoolWithCommunityPool, sdk.NewAttribute(types.AttributeValueCreator, msg.Proposer), - sdk.NewAttribute(types.AttributeValueProposal, fmt.Sprintf("%d", proposal.ProposalId)), + sdk.NewAttribute(types.AttributeValueProposal, fmt.Sprintf("%d", proposal.Id)), ), sdk.NewEvent( sdk.EventTypeMessage, diff --git a/modules/farm/keeper/proposal_hook.go b/modules/farm/keeper/proposal_hook.go index 33687034..0ec06f09 100644 --- a/modules/farm/keeper/proposal_hook.go +++ b/modules/farm/keeper/proposal_hook.go @@ -3,6 +3,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) var _ govtypes.GovHooks = GovHook{} @@ -38,7 +39,7 @@ func (h GovHook) AfterProposalVotingPeriodEnded(ctx sdk.Context, proposalID uint } //when the proposal is passed, the content of the proposal is executed by the gov module, which is not directly processed here - if proposal.Status == govtypes.StatusPassed { + if proposal.Status == v1.StatusPassed { h.k.deleteEscrowInfo(ctx, proposalID) return } diff --git a/modules/farm/migarations/v152/migrate.go b/modules/farm/migarations/v152/migrate.go index e08ea14c..535f0f90 100644 --- a/modules/farm/migarations/v152/migrate.go +++ b/modules/farm/migarations/v152/migrate.go @@ -1,6 +1,7 @@ package v152 import ( + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -10,7 +11,7 @@ import ( // Parameter store keys var ( - DefaultPoolCreationFee = sdk.NewCoin("uiris", sdk.NewIntWithDecimal(2000, 6)) + DefaultPoolCreationFee = sdk.NewCoin("uiris", sdkmath.NewIntWithDecimal(2000, 6)) DefaultTaxRate = sdk.NewDecWithPrec(4, 1) ) diff --git a/modules/farm/module.go b/modules/farm/module.go index a543cb2a..fbde2a12 100644 --- a/modules/farm/module.go +++ b/modules/farm/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/farm/client/cli" - "github.com/irisnet/irismod/modules/farm/client/rest" "github.com/irisnet/irismod/modules/farm/keeper" "github.com/irisnet/irismod/modules/farm/simulation" "github.com/irisnet/irismod/modules/farm/types" @@ -63,7 +62,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the farm module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the farm module. diff --git a/modules/farm/simulation/operations.go b/modules/farm/simulation/operations.go index b533f565..292e5ff9 100644 --- a/modules/farm/simulation/operations.go +++ b/modules/farm/simulation/operations.go @@ -1,6 +1,7 @@ package simulation import ( + "errors" "math/rand" "github.com/cosmos/cosmos-sdk/baseapp" @@ -117,27 +118,37 @@ func SimulateMsgCreatePool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "spendable is zero"), nil, nil } - _, hasNeg := spendable.SafeSub(sdk.NewCoins(k.CreatePoolFee(ctx))) + _, hasNeg := spendable.SafeSub(sdk.NewCoins(k.CreatePoolFee(ctx))...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "Insufficient funds"), nil, nil } - totalReward := GenTotalReward(r, spendable) - lpTokenDenom := GenLpToken(r, spendable) + totalReward, err := GenTotalReward(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "Insufficient funds"), nil, nil + } + + lpTokenDenom, err := GenLpToken(r, spendable) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "Insufficient funds"), nil, nil + } editable := GenDestructible(r) startHeight := GenStartHeight(r, ctx) - rewardPerBlock := GenRewardPerBlock(r, totalReward) + rewardPerBlock, err := GenRewardPerBlock(r, totalReward) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "Insufficient funds"), nil, nil + } - if rewardPerBlock.Amount.LT(sdk.ZeroInt()) { + if rewardPerBlock.Amount.LTE(sdk.ZeroInt()) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "rewardPerBlock less than zeroInt"), nil, nil } - if totalReward.Amount.LT(rewardPerBlock.Amount) { + if totalReward.Amount.LTE(rewardPerBlock.Amount) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "totalReward less than rewardPerBlock"), nil, nil } - balance, hasNeg := spendable.SafeSub(sdk.NewCoins(totalReward)) + balance, hasNeg := spendable.SafeSub(sdk.NewCoins(totalReward)...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreatePool, "Insufficient funds"), nil, nil @@ -159,7 +170,8 @@ func SimulateMsgCreatePool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -173,7 +185,7 @@ func SimulateMsgCreatePool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } keeper.RewardInvariant(k) @@ -218,7 +230,10 @@ func SimulateMsgAdjustPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } rules := k.GetRewardRules(ctx, farmPool.Id) - rewardPerBlock := GenRewardPerBlock(r, spendable[r.Intn(len(spendable))]) + rewardPerBlock, err := GenRewardPerBlock(r, spendable[r.Intn(len(spendable))]) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAdjustPool, "Insufficient funds"), nil, nil + } if rewardPerBlock.Amount.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAdjustPool, "insufficient funds"), nil, nil } @@ -227,13 +242,13 @@ func SimulateMsgAdjustPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAdjustPool, "invalid reward"), nil, nil } - amount := GenAppendReward(r, rules, spendable) - if amount.IsZero() { + amount, err := GenAppendReward(r, rules, spendable) + if err != nil || amount.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAdjustPool, "insufficient funds"), nil, nil } // Need to subtract the appendReward balance - balance, hasNeg := spendable.SafeSub(amount) + balance, hasNeg := spendable.SafeSub(amount...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgAdjustPool, "insufficient funds"), nil, nil } @@ -251,7 +266,8 @@ func SimulateMsgAdjustPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -265,7 +281,7 @@ func SimulateMsgAdjustPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -301,13 +317,13 @@ func SimulateMsgStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeep return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgStake, "spendable is zero"), nil, nil } - amount := GenStake(r, farmPool, spendable) - if amount.IsZero() { + amount, err := GenStake(r, farmPool, spendable) + if err != nil || amount.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgStake, "The sender does not have the specified lpToken"), nil, nil } // Need to subtract the stake balance - balance, hasNeg := spendable.SafeSub(sdk.Coins{amount}) + balance, hasNeg := spendable.SafeSub(sdk.Coins{amount}...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgStake, "Insufficient funds"), nil, nil } @@ -324,7 +340,8 @@ func SimulateMsgStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeep } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -338,7 +355,7 @@ func SimulateMsgStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeep return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -372,7 +389,10 @@ func SimulateMsgUnStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnstake, "spendable is zero"), nil, nil } - unStake := GenUnStake(r, farmPool, farmInfo) + unStake, err := GenUnStake(r, farmPool, farmInfo) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnstake, "Insufficient funds"), nil, nil + } if unStake.IsZero() { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUnstake, "the sender does not have the specified lpToken"), nil, nil } @@ -394,7 +414,8 @@ func SimulateMsgUnStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -408,7 +429,7 @@ func SimulateMsgUnStake(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -451,7 +472,8 @@ func SimulateMsgHarvest(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -465,7 +487,7 @@ func SimulateMsgHarvest(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -520,7 +542,8 @@ func SimulateMsgDestroyPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -534,7 +557,7 @@ func SimulateMsgDestroyPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -544,15 +567,23 @@ func SimulateMsgDestroyPool(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba } // GenTotalReward randomized totalReward -func GenTotalReward(r *rand.Rand, spendableCoin sdk.Coins) sdk.Coin { +func GenTotalReward(r *rand.Rand, spendableCoin sdk.Coins) (sdk.Coin, error) { token := spendableCoin[r.Intn(len(spendableCoin))] - return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount)) + amount, err := simtypes.RandPositiveInt(r, token.Amount) + if err != nil { + return sdk.Coin{}, err + } + return sdk.NewCoin(token.Denom, amount), nil } // GenLpToken randomized lpToken -func GenLpToken(r *rand.Rand, spendableCoin sdk.Coins) sdk.Coin { +func GenLpToken(r *rand.Rand, spendableCoin sdk.Coins) (sdk.Coin, error) { token := spendableCoin[r.Intn(len(spendableCoin))] - return sdk.NewCoin(token.Denom, simtypes.RandomAmount(r, token.Amount)) + amount, err := simtypes.RandPositiveInt(r, token.Amount) + if err != nil { + return sdk.Coin{}, err + } + return sdk.NewCoin(token.Denom, amount), nil } // GenStartHeight randomized startHeight @@ -562,8 +593,12 @@ func GenStartHeight(r *rand.Rand, ctx sdk.Context) int64 { } // GenRewardPerBlock randomized rewardPerBlock -func GenRewardPerBlock(r *rand.Rand, coin sdk.Coin) sdk.Coin { - return sdk.NewCoin(coin.Denom, simtypes.RandomAmount(r, coin.Amount)) +func GenRewardPerBlock(r *rand.Rand, coin sdk.Coin) (sdk.Coin, error) { + amount, err := simtypes.RandPositiveInt(r, coin.Amount) + if err != nil { + return sdk.Coin{}, err + } + return sdk.NewCoin(coin.Denom, amount), nil } // GenRewardRule randomized rewardRule @@ -572,29 +607,41 @@ func GenRewardRule(r *rand.Rand, rules types.RewardRules) types.RewardRule { } // GenAppendReward randomized appendReward -func GenAppendReward(r *rand.Rand, rules types.RewardRules, spendable sdk.Coins) sdk.Coins { +func GenAppendReward(r *rand.Rand, rules types.RewardRules, spendable sdk.Coins) (sdk.Coins, error) { rule := GenRewardRule(r, rules) for _, coin := range spendable { if coin.Denom == rule.Reward { - return sdk.Coins{sdk.NewCoin(coin.Denom, simtypes.RandomAmount(r, coin.Amount))} + amount, err := simtypes.RandPositiveInt(r, coin.Amount) + if err != nil { + return nil, err + } + return sdk.NewCoins(sdk.NewCoin(coin.Denom, amount)), nil } } - return sdk.Coins{} + return nil, errors.New("no spendable token") } // GenStake randomized stake -func GenStake(r *rand.Rand, pool types.FarmPool, spendable sdk.Coins) sdk.Coin { +func GenStake(r *rand.Rand, pool types.FarmPool, spendable sdk.Coins) (sdk.Coin, error) { for _, coin := range spendable { if coin.Denom == pool.TotalLptLocked.Denom { - return sdk.NewCoin(pool.TotalLptLocked.Denom, simtypes.RandomAmount(r, coin.Amount)) + amount, err := simtypes.RandPositiveInt(r, coin.Amount) + if err != nil { + return sdk.Coin{}, err + } + return sdk.NewCoin(pool.TotalLptLocked.Denom, amount), nil } } - return sdk.NewCoin(pool.TotalLptLocked.Denom, sdk.ZeroInt()) + return sdk.NewCoin(pool.TotalLptLocked.Denom, sdk.ZeroInt()), nil } // GenUnStake randomized unStake -func GenUnStake(r *rand.Rand, pool types.FarmPool, info types.FarmInfo) sdk.Coin { - return sdk.NewCoin(pool.TotalLptLocked.Denom, simtypes.RandomAmount(r, info.Locked)) +func GenUnStake(r *rand.Rand, pool types.FarmPool, info types.FarmInfo) (sdk.Coin, error) { + amount, err := simtypes.RandPositiveInt(r, info.Locked) + if err != nil { + return sdk.Coin{}, err + } + return sdk.NewCoin(pool.TotalLptLocked.Denom, amount), nil } // GenDestructible randomized editable diff --git a/modules/farm/types/codec.go b/modules/farm/types/codec.go index cc40b2d4..5dad9f30 100644 --- a/modules/farm/types/codec.go +++ b/modules/farm/types/codec.go @@ -8,7 +8,7 @@ import ( cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) var ( @@ -46,7 +46,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { ) registry.RegisterImplementations( - (*govtypes.Content)(nil), + (*govv1beta1.Content)(nil), &CommunityPoolCreateFarmProposal{}, ) diff --git a/modules/farm/types/expected_keeper.go b/modules/farm/types/expected_keeper.go index 03a2ed39..2ba971b8 100644 --- a/modules/farm/types/expected_keeper.go +++ b/modules/farm/types/expected_keeper.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" ) // BankKeeper defines the expected bank keeper (noalias) @@ -35,7 +35,8 @@ type DistrKeeper interface { // GovKeeper defines the expected gov keeper (noalias) type GovKeeper interface { - SubmitProposal(ctx sdk.Context, content govtypes.Content) (govtypes.Proposal, error) + SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadata string) (v1.Proposal, error) AddDeposit(ctx sdk.Context, proposalID uint64, depositorAddr sdk.AccAddress, depositAmount sdk.Coins) (bool, error) - GetProposal(ctx sdk.Context, proposalID uint64) (govtypes.Proposal, bool) + GetProposal(ctx sdk.Context, proposalID uint64) (v1.Proposal, bool) + GetGovernanceAccount(ctx sdk.Context) authtypes.ModuleAccountI } diff --git a/modules/farm/types/farm.pb.go b/modules/farm/types/farm.pb.go index 9e70b74c..78244d12 100644 --- a/modules/farm/types/farm.pb.go +++ b/modules/farm/types/farm.pb.go @@ -230,7 +230,8 @@ func (m *EscrowInfo) XXX_DiscardUnknown() { var xxx_messageInfo_EscrowInfo proto.InternalMessageInfo -// CommunityPoolCreateFarmProposal is a gov Content type for creating a farm pool with community pool +// CommunityPoolCreateFarmProposal is a gov Content type for creating a farm +// pool with community pool type CommunityPoolCreateFarmProposal struct { Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` diff --git a/modules/farm/types/proposal.go b/modules/farm/types/proposal.go index de0d2dfd..9eb56de2 100644 --- a/modules/farm/types/proposal.go +++ b/modules/farm/types/proposal.go @@ -4,7 +4,7 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" ) const ( @@ -12,11 +12,10 @@ const ( ) // Implements Proposal Interface -var _ govtypes.Content = &CommunityPoolCreateFarmProposal{} +var _ govv1beta1.Content = &CommunityPoolCreateFarmProposal{} func init() { - govtypes.RegisterProposalType(ProposalTypeCreateFarmPool) - govtypes.RegisterProposalTypeCodec(&CommunityPoolCreateFarmProposal{}, "irismod/CommunityPoolCreateFarmProposal") + govv1beta1.RegisterProposalType(ProposalTypeCreateFarmPool) } func (cfp *CommunityPoolCreateFarmProposal) GetTitle() string { return cfp.Title } @@ -25,7 +24,7 @@ func (cfp *CommunityPoolCreateFarmProposal) ProposalRoute() string { return Rou func (cfp *CommunityPoolCreateFarmProposal) ProposalType() string { return ProposalTypeCreateFarmPool } func (cfp *CommunityPoolCreateFarmProposal) ValidateBasic() error { // Validate gov base proposal - if err := govtypes.ValidateAbstract(cfp); err != nil { + if err := govv1beta1.ValidateAbstract(cfp); err != nil { return err } if err := ValidateDescription(cfp.PoolDescription); err != nil { diff --git a/modules/farm/types/query.pb.gw.go b/modules/farm/types/query.pb.gw.go index 9754786c..996e0164 100644 --- a/modules/farm/types/query.pb.gw.go +++ b/modules/farm/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join var ( filter_Query_FarmPools_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -214,12 +216,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_FarmPools_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -227,6 +231,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_FarmPools_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -240,6 +245,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_FarmPool_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -247,6 +254,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_FarmPool_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -260,6 +268,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Farmer_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -267,6 +277,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Farmer_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -280,6 +291,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -287,6 +300,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -422,13 +436,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_FarmPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "farm", "pools"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FarmPools_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "farm", "pools"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_FarmPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "farm", "pool", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FarmPool_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "farm", "pool", "id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Farmer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "farm", "farmers", "farmer"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Farmer_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "farm", "farmers", "farmer"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "farm", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "farm", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/htlc/client/cli/cli_test.go b/modules/htlc/client/cli/cli_test.go index 014819ef..2187345f 100644 --- a/modules/htlc/client/cli/cli_test.go +++ b/modules/htlc/client/cli/cli_test.go @@ -11,7 +11,6 @@ import ( "github.com/stretchr/testify/suite" tmbytes "github.com/tendermint/tendermint/libs/bytes" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" @@ -63,7 +62,7 @@ func cs(coins ...sdk.Coin) sdk.Coins { } func ts(minOffset int) uint64 { - return uint64(tmtime.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) + return uint64(time.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) } func (s *IntegrationTestSuite) SetupSuite() { @@ -75,10 +74,12 @@ func (s *IntegrationTestSuite) SetupSuite() { Deputy, _ = sdk.AccAddressFromBech32(DEPUTY_ADDR) cfg.GenesisState[htlctypes.ModuleName] = cfg.Codec.MustMarshalJSON(NewHTLTGenesis(Deputy)) + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/htlc/client/rest/grpc_query_test.go b/modules/htlc/client/rest/grpc_query_test.go deleted file mode 100644 index b23cc7c8..00000000 --- a/modules/htlc/client/rest/grpc_query_test.go +++ /dev/null @@ -1,103 +0,0 @@ -package rest_test - -// import ( -// "fmt" -// "testing" - -// "github.com/gogo/protobuf/proto" -// "github.com/stretchr/testify/suite" - -// "github.com/tendermint/tendermint/crypto" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil/network" -// sdk "github.com/cosmos/cosmos-sdk/types" -// "github.com/cosmos/cosmos-sdk/types/rest" - -// htlccli "github.com/irisnet/irismod/modules/htlc/client/cli" -// htlctestutil "github.com/irisnet/irismod/modules/htlc/client/testutil" -// htlctypes "github.com/irisnet/irismod/modules/htlc/types" -// "github.com/irisnet/irismod/simapp" -// ) - -// // TODO - -// type IntegrationTestSuite struct { -// suite.Suite - -// cfg network.Config -// network *network.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// cfg := simapp.NewConfig() -// cfg.NumValidators = 1 - -// s.cfg = cfg -// s.network = network.New(s.T(), cfg) - -// _, err := s.network.WaitForHeight(1) -// s.Require().NoError(err) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestHtlc() { -// val := s.network.Validators[0] - -// //------test GetCmdCreateHTLC()------------- -// baseURL := val.APIAddress -// from := val.Address -// to := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) -// amount := "1000" + sdk.DefaultBondDenom -// receiverOnOtherChain := "0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826" -// hashLock := "e8d4133e1a82c74e2746e78c19385706ea7958a0ca441a08dacfa10c48ce2561" -// timeLock := uint64(50) -// timestamp := uint64(1580000000) -// stateOpen := "HTLC_STATE_OPEN" - -// args := []string{ -// fmt.Sprintf("--%s=%s", htlccli.FlagTo, to), -// fmt.Sprintf("--%s=%s", htlccli.FlagAmount, amount), -// fmt.Sprintf("--%s=%s", htlccli.FlagReceiverOnOtherChain, receiverOnOtherChain), -// fmt.Sprintf("--%s=%s", htlccli.FlagHashLock, hashLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, timeLock), -// fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, timestamp), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType := proto.Message(&sdk.TxResponse{}) -// expectedCode := uint32(0) - -// bz, err := htlctestutil.CreateHTLCExec(val.ClientCtx, from.String(), args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp := respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// //------test GetCmdQueryHTLC()------------- -// url := fmt.Sprintf("%s/irismod/htlc/htlcs/%s", baseURL, hashLock) -// resp, err := rest.GetRequest(url) -// respType = proto.Message(&htlctypes.QueryHTLCResponse{}) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.JSONMarshaler.UnmarshalJSON(resp, respType)) -// htlcResp := respType.(*htlctypes.QueryHTLCResponse) -// s.Require().Equal(amount, htlcResp.Htlc.Amount.String()) -// s.Require().Equal(from.String(), htlcResp.Htlc.Sender) -// s.Require().Equal(to.String(), htlcResp.Htlc.To) -// s.Require().Equal(receiverOnOtherChain, htlcResp.Htlc.ReceiverOnOtherChain) -// s.Require().Equal(timestamp, htlcResp.Htlc.Timestamp) -// s.Require().Equal(stateOpen, htlcResp.Htlc.State.String()) -// } diff --git a/modules/htlc/client/rest/query.go b/modules/htlc/client/rest/query.go deleted file mode 100644 index bf249fc8..00000000 --- a/modules/htlc/client/rest/query.go +++ /dev/null @@ -1,131 +0,0 @@ -package rest - -import ( - "encoding/hex" - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/htlc/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // query an HTLC - r.HandleFunc(fmt.Sprintf("/%s/htlcs/{%s}", types.ModuleName, RestID), queryHTLCHandlerFn(cliCtx)).Methods("GET") - // query an asset supply - r.HandleFunc(fmt.Sprintf("/%s/supplies/{%s}", types.ModuleName, RestDenom), queryAssetSupplyHandlerFn(cliCtx)).Methods("GET") - // query all asset supplies - r.HandleFunc(fmt.Sprintf("/%s/supplies", types.ModuleName), queryAssetSuppliesHandlerFn(cliCtx)).Methods("GET") - // query the current HTLC parameter values - r.HandleFunc(fmt.Sprintf("/%s/params", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET") -} - -func queryHTLCHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - id, err := hex.DecodeString(vars[RestID]) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryHTLCParams{ - ID: id, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryHTLC) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryAssetSupplyHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryAssetSupplyParams{ - Denom: vars[RestDenom], - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAssetSupply) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryAssetSuppliesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAssetSupplies) - res, height, err := cliCtx.QueryWithData(route, nil) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters) - res, height, err := cliCtx.QueryWithData(route, nil) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/htlc/client/rest/rest.go b/modules/htlc/client/rest/rest.go deleted file mode 100644 index ac662bc5..00000000 --- a/modules/htlc/client/rest/rest.go +++ /dev/null @@ -1,43 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// Rest variable names -// nolint -const ( - RestID = "id" - RestDenom = "denom" -) - -// RegisterHandlers defines routes that get registered by the main application -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -// CreateHTLCReq defines the properties of an HTLC creation request's body. -type CreateHTLCReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Sender string `json:"sender" yaml:"sender"` - To string `json:"to" yaml:"to"` - ReceiverOnOtherChain string `json:"receiver_on_other_chain" yaml:"receiver_on_other_chain"` - SenderOnOtherChain string `json:"sender_on_other_chain" yaml:"sender_on_other_chain"` - Amount sdk.Coins `json:"amount" yaml:"amount"` - HashLock string `json:"hash_lock" yaml:"hash_lock"` - TimeLock uint64 `json:"time_lock" yaml:"time_lock"` - Timestamp uint64 `json:"timestamp" yaml:"timestamp"` - Transfer bool `json:"transfer" yaml:"transfer"` -} - -// ClaimHTLCReq defines the properties of an HTLC claim request's body. -type ClaimHTLCReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Sender string `json:"sender" yaml:"sender"` - Secret string `json:"secret" yaml:"secret"` -} diff --git a/modules/htlc/client/rest/tx.go b/modules/htlc/client/rest/tx.go deleted file mode 100644 index e5b43fd0..00000000 --- a/modules/htlc/client/rest/tx.go +++ /dev/null @@ -1,86 +0,0 @@ -package rest - -import ( - "encoding/hex" - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/htlc/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - // create an HTLC - r.HandleFunc("/htlc/htlcs", createHTLCHandlerFn(cliCtx)).Methods("POST") - // claim an HTLC - r.HandleFunc(fmt.Sprintf("/htlc/htlcs/{%s}/claim", RestID), claimHTLCHandlerFn(cliCtx)).Methods("POST") -} - -func createHTLCHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req CreateHTLCReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := hex.DecodeString(req.HashLock); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgCreateHTLC( - req.Sender, req.To, req.ReceiverOnOtherChain, req.SenderOnOtherChain, - req.Amount, req.HashLock, req.Timestamp, req.TimeLock, req.Transfer, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, &msg) - } -} - -func claimHTLCHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - if _, err := hex.DecodeString(vars[RestID]); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req ClaimHTLCReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := hex.DecodeString(req.Secret); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgClaimHTLC(req.Sender, vars[RestID], req.Secret) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, &msg) - } -} diff --git a/modules/htlc/client/testutil/grpc_query_test.go b/modules/htlc/client/testutil/grpc_query_test.go new file mode 100644 index 00000000..7b3e9b9f --- /dev/null +++ b/modules/htlc/client/testutil/grpc_query_test.go @@ -0,0 +1,102 @@ +package testutil_test + +import ( + "fmt" + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" + + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + + htlccli "github.com/irisnet/irismod/modules/htlc/client/cli" + htlctestutil "github.com/irisnet/irismod/modules/htlc/client/testutil" + "github.com/irisnet/irismod/simapp" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := simapp.NewConfig() + cfg.NumValidators = 1 + + s.cfg = cfg + + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) TestHtlc() { + val := s.network.Validators[0] + + //------test GetCmdCreateHTLC()------------- + //baseURL := val.APIAddress + from := val.Address + to := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) + amount := "1000" + sdk.DefaultBondDenom + receiverOnOtherChain := "0xcd2a3d9f938e13cd947ec05abc7fe734df8dd826" + hashLock := "e8d4133e1a82c74e2746e78c19385706ea7958a0ca441a08dacfa10c48ce2561" + timeLock := uint64(50) + timestamp := uint64(1580000000) + //stateOpen := "HTLC_STATE_OPEN" + + args := []string{ + fmt.Sprintf("--%s=%s", htlccli.FlagTo, to), + fmt.Sprintf("--%s=%s", htlccli.FlagAmount, amount), + fmt.Sprintf("--%s=%s", htlccli.FlagReceiverOnOtherChain, receiverOnOtherChain), + fmt.Sprintf("--%s=%s", htlccli.FlagHashLock, hashLock), + fmt.Sprintf("--%s=%d", htlccli.FlagTimeLock, timeLock), + fmt.Sprintf("--%s=%d", htlccli.FlagTimestamp, timestamp), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType := proto.Message(&sdk.TxResponse{}) + expectedCode := uint32(0) + + bz, err := htlctestutil.CreateHTLCExec(val.ClientCtx, from.String(), args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp := respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + //------test GetCmdQueryHTLC()------------- + //url := fmt.Sprintf("%s/irismod/htlc/htlcs/%s", baseURL, hashLock) + //resp, err := rest.GetRequest(url) + //respType = proto.Message(&htlctypes.QueryHTLCResponse{}) + //s.Require().NoError(err) + //s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + //htlcResp := respType.(*htlctypes.QueryHTLCResponse) + //s.Require().Equal(amount, htlcResp.Htlc.Amount.String()) + //s.Require().Equal(from.String(), htlcResp.Htlc.Sender) + //s.Require().Equal(to.String(), htlcResp.Htlc.To) + //s.Require().Equal(receiverOnOtherChain, htlcResp.Htlc.ReceiverOnOtherChain) + //s.Require().Equal(timestamp, htlcResp.Htlc.Timestamp) + //s.Require().Equal(stateOpen, htlcResp.Htlc.State.String()) +} diff --git a/modules/htlc/genesis_test.go b/modules/htlc/genesis_test.go index bf22bd62..38a529c3 100644 --- a/modules/htlc/genesis_test.go +++ b/modules/htlc/genesis_test.go @@ -2,11 +2,11 @@ package htlc_test import ( "testing" + "time" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,8 +27,8 @@ type GenesisTestSuite struct { } func (suite *GenesisTestSuite) SetupTest() { - app := simapp.Setup(false) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: tmtime.Now()}) + app := simapp.Setup(suite.T(), false) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.keeper = &app.HTLCKeeper @@ -353,14 +353,20 @@ func (suite *GenesisTestSuite) TestGenesisState() { if tc.expectPass { suite.NotPanics( func() { - simapp.SetupWithGenesisHTLC(tc.genState()) + simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(tc.genState()) + return state + }) }, tc.name, ) } else { suite.Panics( func() { - simapp.SetupWithGenesisHTLC(tc.genState()) + simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(tc.genState()) + return state + }) }, tc.name, ) diff --git a/modules/htlc/integration_test.go b/modules/htlc/integration_test.go index cce62361..0c9b336a 100644 --- a/modules/htlc/integration_test.go +++ b/modules/htlc/integration_test.go @@ -6,7 +6,6 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" - tmtime "github.com/tendermint/tendermint/types/time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -35,7 +34,7 @@ func cs(coins ...sdk.Coin) sdk.Coins { } func ts(minOffset int) uint64 { - return uint64(tmtime.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) + return uint64(time.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) } func NewHTLTGenesis(deputyAddress sdk.AccAddress) *types.GenesisState { diff --git a/modules/htlc/keeper/asset_test.go b/modules/htlc/keeper/asset_test.go index 2cd5d8af..0577059e 100644 --- a/modules/htlc/keeper/asset_test.go +++ b/modules/htlc/keeper/asset_test.go @@ -8,7 +8,6 @@ import ( "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -28,8 +27,11 @@ type AssetTestSuite struct { } func (suite *AssetTestSuite) SetupTest() { - app := simapp.SetupWithGenesisHTLC(NewHTLTGenesis(TestDeputy)) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: tmtime.Now()}) + app := simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(NewHTLTGenesis(TestDeputy)) + return state + }) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.keeper = &app.HTLCKeeper diff --git a/modules/htlc/keeper/grpc_query_test.go b/modules/htlc/keeper/grpc_query_test.go index 358b022f..387b2f9c 100644 --- a/modules/htlc/keeper/grpc_query_test.go +++ b/modules/htlc/keeper/grpc_query_test.go @@ -4,12 +4,12 @@ import ( gocontext "context" "encoding/hex" "testing" + "time" "github.com/stretchr/testify/suite" tmbytes "github.com/tendermint/tendermint/libs/bytes" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -35,9 +35,12 @@ type QueryTestSuite struct { } func (suite *QueryTestSuite) SetupTest() { - app := simapp.SetupWithGenesisHTLC(NewHTLTGenesis(TestDeputy)) + app := simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(NewHTLTGenesis(TestDeputy)) + return state + }) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: tmtime.Now()}) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.keeper = &app.HTLCKeeper suite.app = app diff --git a/modules/htlc/keeper/htlc_test.go b/modules/htlc/keeper/htlc_test.go index adf94d4b..a33198d2 100644 --- a/modules/htlc/keeper/htlc_test.go +++ b/modules/htlc/keeper/htlc_test.go @@ -8,7 +8,6 @@ import ( tmbytes "github.com/tendermint/tendermint/libs/bytes" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -46,8 +45,11 @@ func TestHTLCTestSuite(t *testing.T) { } func (suite *HTLCTestSuite) SetupTest() { - app := simapp.SetupWithGenesisHTLC(NewHTLTGenesis(TestDeputy)) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: tmtime.Now()}) + app := simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(NewHTLTGenesis(TestDeputy)) + return state + }) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.keeper = &app.HTLCKeeper @@ -92,7 +94,7 @@ func (suite *HTLCTestSuite) GenerateHTLCDetails() { } func (suite *HTLCTestSuite) TestCreateHTLC() { - currentTmTime := tmtime.Now() + currentTmTime := time.Now() type args struct { sender sdk.AccAddress receiver sdk.AccAddress @@ -478,7 +480,7 @@ func (suite *HTLCTestSuite) TestCreateHTLC() { func (suite *HTLCTestSuite) TestClaimHtlc() { suite.SetupTest() - currentTmTime := tmtime.Now() + currentTmTime := time.Now() invalidSecret, _ := GenerateRandomSecret() type args struct { amount sdk.Coins diff --git a/modules/htlc/keeper/integration_test.go b/modules/htlc/keeper/integration_test.go index c4ac40ec..fa126270 100644 --- a/modules/htlc/keeper/integration_test.go +++ b/modules/htlc/keeper/integration_test.go @@ -6,7 +6,6 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" - tmtime "github.com/tendermint/tendermint/types/time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,7 +32,7 @@ func cs(coins ...sdk.Coin) sdk.Coins { } func ts(minOffset int) uint64 { - return uint64(tmtime.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) + return uint64(time.Now().Add(time.Duration(minOffset) * time.Minute).Unix()) } func NewHTLTGenesis(deputyAddress sdk.AccAddress) *types.GenesisState { diff --git a/modules/htlc/keeper/keeper.go b/modules/htlc/keeper/keeper.go index 0e908dd0..4a76984f 100644 --- a/modules/htlc/keeper/keeper.go +++ b/modules/htlc/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -15,7 +16,7 @@ import ( // Keeper defines the HTLC keeper type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.Codec paramSpace paramstypes.Subspace accountKeeper types.AccountKeeper @@ -26,7 +27,7 @@ type Keeper struct { // NewKeeper creates a new HTLC Keeper instance func NewKeeper( cdc codec.Codec, - key sdk.StoreKey, + key storetypes.StoreKey, paramSpace paramstypes.Subspace, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, diff --git a/modules/htlc/keeper/params_test.go b/modules/htlc/keeper/params_test.go index 049a3a1e..c97c8203 100644 --- a/modules/htlc/keeper/params_test.go +++ b/modules/htlc/keeper/params_test.go @@ -3,11 +3,11 @@ package keeper_test import ( "errors" "testing" + "time" "github.com/stretchr/testify/suite" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - tmtime "github.com/tendermint/tendermint/types/time" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -27,13 +27,15 @@ type ParamsTestSuite struct { } func (suite *ParamsTestSuite) SetupTest() { - app := simapp.SetupWithGenesisHTLC(NewHTLTGenesis(TestDeputy)) - suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: tmtime.Now()}) + app := simapp.SetupWithGenesisStateFn(suite.T(), func(cdc codec.Codec, state simapp.GenesisState) simapp.GenesisState { + state[types.ModuleName] = cdc.MustMarshalJSON(NewHTLTGenesis(TestDeputy)) + return state + }) + suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Height: 1, Time: time.Now()}) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.keeper = &app.HTLCKeeper suite.app = app - } func TestParamsTestSuite(t *testing.T) { diff --git a/modules/htlc/module.go b/modules/htlc/module.go index e04db3ef..ca971160 100644 --- a/modules/htlc/module.go +++ b/modules/htlc/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/htlc/client/cli" - "github.com/irisnet/irismod/modules/htlc/client/rest" "github.com/irisnet/irismod/modules/htlc/keeper" "github.com/irisnet/irismod/modules/htlc/simulation" "github.com/irisnet/irismod/modules/htlc/types" @@ -62,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the HTLC module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the HTLC module. diff --git a/modules/htlc/simulation/operation.go b/modules/htlc/simulation/operation.go index 971f1277..ff32eb37 100644 --- a/modules/htlc/simulation/operation.go +++ b/modules/htlc/simulation/operation.go @@ -73,7 +73,7 @@ func SimulateMsgCreateHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } amount := simtypes.RandSubsetCoins(r, spendable) - balance, hasNeg := spendable.SafeSub(amount) + balance, hasNeg := spendable.SafeSub(amount...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCreateHTLC, "Insufficient funds"), nil, nil } @@ -104,7 +104,8 @@ func SimulateMsgCreateHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -118,7 +119,7 @@ func SimulateMsgCreateHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -161,7 +162,8 @@ func SimulateMsgClaimHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -175,7 +177,7 @@ func SimulateMsgClaimHtlc(k keeper.Keeper, ak types.AccountKeeper, bk types.Bank return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - _, _, err = app.Deliver(txGen.TxEncoder(), tx) + _, _, err = app.SimDeliver(txGen.TxEncoder(), tx) if err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } diff --git a/modules/htlc/types/conmmon_test.go b/modules/htlc/types/conmmon_test.go index 89ace1e9..8a3c1c4b 100644 --- a/modules/htlc/types/conmmon_test.go +++ b/modules/htlc/types/conmmon_test.go @@ -6,7 +6,6 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/secp256k1" - tmtime "github.com/tendermint/tendermint/types/time" sdk "github.com/cosmos/cosmos-sdk/types" @@ -37,7 +36,7 @@ func htlcs(count int) []types.HTLC { func htlc(index int) types.HTLC { expireOffset := uint64((index * 15) + 360) - timestamp := uint64(tmtime.Now().Add(time.Duration(index) * time.Minute).Unix()) + timestamp := uint64(time.Now().Add(time.Duration(index) * time.Minute).Unix()) randomSecret, _ := GenerateRandomSecret() randomHashLock := types.GetHashLock(randomSecret, timestamp) amount := cs(c("htltbnb", 50000)) diff --git a/modules/htlc/types/genesis.pb.go b/modules/htlc/types/genesis.pb.go index b08793bc..8876c519 100644 --- a/modules/htlc/types/genesis.pb.go +++ b/modules/htlc/types/genesis.pb.go @@ -8,7 +8,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/timestamp" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" @@ -408,10 +408,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/htlc/types/htlc.pb.go b/modules/htlc/types/htlc.pb.go index 94e162b3..8954f644 100644 --- a/modules/htlc/types/htlc.pb.go +++ b/modules/htlc/types/htlc.pb.go @@ -10,7 +10,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/duration" + _ "google.golang.org/protobuf/types/known/durationpb" io "io" math "math" math_bits "math/bits" @@ -1536,10 +1536,7 @@ func (m *HTLC) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthHtlc } if (iNdEx + skippy) > l { @@ -1754,10 +1751,7 @@ func (m *AssetSupply) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthHtlc } if (iNdEx + skippy) > l { @@ -1841,10 +1835,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthHtlc } if (iNdEx + skippy) > l { @@ -2151,10 +2142,7 @@ func (m *AssetParam) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthHtlc } if (iNdEx + skippy) > l { @@ -2325,10 +2313,7 @@ func (m *SupplyLimit) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthHtlc - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthHtlc } if (iNdEx + skippy) > l { diff --git a/modules/htlc/types/params.go b/modules/htlc/types/params.go index 1c5feff5..2dfc2da2 100644 --- a/modules/htlc/types/params.go +++ b/modules/htlc/types/params.go @@ -7,8 +7,6 @@ import ( "gopkg.in/yaml.v2" - tmtime "github.com/tendermint/tendermint/types/time" - sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) @@ -21,7 +19,7 @@ const ( var ( KeyAssetParams = []byte("AssetParams") // asset params key - DefaultPreviousBlockTime = tmtime.Canonical(time.Unix(1, 0)) + DefaultPreviousBlockTime = time.Now() ) // NewParams is the HTLC params constructor diff --git a/modules/htlc/types/query.pb.go b/modules/htlc/types/query.pb.go index 66a3ea8b..e53662e7 100644 --- a/modules/htlc/types/query.pb.go +++ b/modules/htlc/types/query.pb.go @@ -164,7 +164,8 @@ func (m *QueryAssetSupplyRequest) GetDenom() string { return "" } -// QueryAssetSupplyResponse is response type for the Query/AssetSupply RPC method +// QueryAssetSupplyResponse is response type for the Query/AssetSupply RPC +// method type QueryAssetSupplyResponse struct { AssetSupply *AssetSupply `protobuf:"bytes,1,opt,name=asset_supply,json=assetSupply,proto3" json:"asset_supply,omitempty" yaml:"asset_supply"` } @@ -209,7 +210,8 @@ func (m *QueryAssetSupplyResponse) GetAssetSupply() *AssetSupply { return nil } -// QueryAssetSuppliesRequest is request type for the Query/AssetSupplies RPC method +// QueryAssetSuppliesRequest is request type for the Query/AssetSupplies RPC +// method type QueryAssetSuppliesRequest struct { } @@ -246,7 +248,8 @@ func (m *QueryAssetSuppliesRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAssetSuppliesRequest proto.InternalMessageInfo -// QueryAssetSuppliesResponse is response type for the Query/AssetSupplies RPC method +// QueryAssetSuppliesResponse is response type for the Query/AssetSupplies RPC +// method type QueryAssetSuppliesResponse struct { AssetSupplies []AssetSupply `protobuf:"bytes,1,rep,name=asset_supplies,json=assetSupplies,proto3" json:"asset_supplies" yaml:"asset_supplies"` } @@ -1046,10 +1049,7 @@ func (m *QueryHTLCRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1135,10 +1135,7 @@ func (m *QueryHTLCResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1220,10 +1217,7 @@ func (m *QueryAssetSupplyRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1309,10 +1303,7 @@ func (m *QueryAssetSupplyResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1362,10 +1353,7 @@ func (m *QueryAssetSuppliesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1449,10 +1437,7 @@ func (m *QueryAssetSuppliesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1502,10 +1487,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1588,10 +1570,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/htlc/types/query.pb.gw.go b/modules/htlc/types/query.pb.gw.go index 12f42261..dfb2441c 100644 --- a/modules/htlc/types/query.pb.gw.go +++ b/modules/htlc/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_HTLC_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryHTLCRequest @@ -178,12 +180,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_HTLC_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -191,6 +195,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_HTLC_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -204,6 +209,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_AssetSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -211,6 +218,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_AssetSupply_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -224,6 +232,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_AssetSupplies_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -231,6 +241,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_AssetSupplies_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -244,6 +255,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -251,6 +264,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -386,13 +400,13 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_HTLC_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "htlc", "htlcs", "id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_HTLC_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "htlc", "htlcs", "id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_AssetSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "htlc", "supplies", "denom"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_AssetSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "htlc", "supplies", "denom"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_AssetSupplies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "htlc", "supplies"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_AssetSupplies_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "htlc", "supplies"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "htlc", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "htlc", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/htlc/types/tx.pb.go b/modules/htlc/types/tx.pb.go index 45ecce06..cb079eba 100644 --- a/modules/htlc/types/tx.pb.go +++ b/modules/htlc/types/tx.pb.go @@ -1023,10 +1023,7 @@ func (m *MsgCreateHTLC) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1108,10 +1105,7 @@ func (m *MsgCreateHTLCResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1257,10 +1251,7 @@ func (m *MsgClaimHTLC) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1310,10 +1301,7 @@ func (m *MsgClaimHTLCResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/modules/mt/client/cli/cli_test.go b/modules/mt/client/cli/cli_test.go index 9112ab14..608f9b38 100644 --- a/modules/mt/client/cli/cli_test.go +++ b/modules/mt/client/cli/cli_test.go @@ -1,258 +1,246 @@ package cli_test -// import ( -// "fmt" -// "testing" - -// "github.com/gogo/protobuf/proto" -// "github.com/stretchr/testify/suite" -// "github.com/tidwall/gjson" - -// "github.com/tendermint/tendermint/crypto" - -// "github.com/cosmos/cosmos-sdk/client/flags" -// "github.com/cosmos/cosmos-sdk/testutil/network" -// sdk "github.com/cosmos/cosmos-sdk/types" - -// mtcli "github.com/irisnet/irismod/modules/mt/client/cli" -// mttestutil "github.com/irisnet/irismod/modules/mt/client/testutil" -// mttypes "github.com/irisnet/irismod/modules/mt/types" -// "github.com/irisnet/irismod/simapp" -// ) - -// type IntegrationTestSuite struct { -// suite.Suite - -// cfg network.Config -// network *network.Network -// } - -// func (s *IntegrationTestSuite) SetupSuite() { -// s.T().Log("setting up integration test suite") - -// cfg := simapp.NewConfig() -// cfg.NumValidators = 2 - -// s.cfg = cfg -// s.network = network.New(s.T(), cfg) - -// _, err := s.network.WaitForHeight(1) -// s.Require().NoError(err) -// } - -// func (s *IntegrationTestSuite) TearDownSuite() { -// s.T().Log("tearing down integration test suite") -// s.network.Cleanup() -// } - -// func TestIntegrationTestSuite(t *testing.T) { -// suite.Run(t, new(IntegrationTestSuite)) -// } - -// func (s *IntegrationTestSuite) TestNft() { -// val := s.network.Validators[0] -// val2 := s.network.Validators[1] - -// // --------------------------------------------------------------------------- - -// from := val.Address -// data := "data" -// mtID := "kitty" -// //owner := "owner" -// denomName := "name" -// denom := "denom" - -// //------test GetCmdIssueDenom()------------- -// args := []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagName, denomName), -// fmt.Sprintf("--%s=%s", mtcli.FlagData, data), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType := proto.Message(&sdk.TxResponse{}) -// expectedCode := uint32(0) - -// bz, err := mttestutil.IssueDenomExec(val.ClientCtx, from.String(), denom, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp := respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// denomID := gjson.Get(txResp.RawLog, "0.events.0.attributes.0.value").String() - -// //------test GetCmdQueryDenom()------------- -// respType = proto.Message(&mttypes.Denom{}) -// bz, err = mttestutil.QueryDenomExec(val.ClientCtx, denomID) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// denomItem := respType.(*mttypes.Denom) -// s.Require().Equal(denomName, denomItem.Name) -// s.Require().Equal(data, denomItem.Data) - -// //------test GetCmdQueryDenoms()------------- -// respType = proto.Message(&mttypes.QueryDenomsResponse{}) -// bz, err = mttestutil.QueryDenomsExec(val.ClientCtx) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// denomsResp := respType.(*mttypes.QueryDenomsResponse) -// s.Require().Equal(1, len(denomsResp.Denoms)) -// s.Require().Equal(denomID, denomsResp.Denoms[0].Id) - -// //------test GetCmdMintMT()------------- -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagData, data), -// fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType = proto.Message(&sdk.TxResponse{}) - -// bz, err = mttestutil.MintMTExec(val.ClientCtx, from.String(), denomID, mtID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// //------test GetCmdQuerySupply()------------- -// // respType = proto.Message(&mttypes.QuerySupplyResponse{}) -// // bz, err = mttestutil.QuerySupplyExec(val.ClientCtx, denomID) -// // s.Require().NoError(err) -// // s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// // supplyResp := respType.(*mttypes.QuerySupplyResponse) -// // s.Require().Equal(uint64(1), supplyResp.Amount) - -// //------test GetCmdQueryMT()------------- -// respType = proto.Message(&mttypes.MT{}) -// bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// mtItem := respType.(*mttypes.MT) -// s.Require().Equal(mtID, mtItem.Id) -// s.Require().Equal(data, mtItem.Data) - -// //------test GetCmdEditMT()------------- -// newTokenDate := "newdata" -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagData, newTokenDate), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType = proto.Message(&sdk.TxResponse{}) - -// bz, err = mttestutil.EditMTExec(val.ClientCtx, from.String(), denomID, mtID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// respType = proto.Message(&mttypes.MT{}) -// bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// newNftItem := respType.(*mttypes.MT) -// s.Require().Equal(newTokenDate, newNftItem.Data) - -// //------test GetCmdTransferMT()------------- -// recipient := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) - -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagData, data), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType = proto.Message(&sdk.TxResponse{}) - -// bz, err = mttestutil.TransferMTExec(val.ClientCtx, from.String(), recipient.String(), denomID, mtID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// respType = proto.Message(&mttypes.MT{}) -// bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// mtItem = respType.(*mttypes.MT) -// s.Require().Equal(mtID, mtItem.Id) -// s.Require().Equal(data, mtItem.Data) - -// //------test GetCmdBurnMT()------------- -// newMTID := "dgsbl" -// args = []string{ -// fmt.Sprintf("--%s=%s", mtcli.FlagData, newTokenDate), -// fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), - -// fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// } - -// respType = proto.Message(&sdk.TxResponse{}) - -// bz, err = mttestutil.MintMTExec(val.ClientCtx, from.String(), denomID, newMTID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// // respType = proto.Message(&mttypes.QuerySupplyResponse{}) -// // bz, err = mttestutil.QuerySupplyExec(val.ClientCtx, denomID) -// // s.Require().NoError(err) -// // s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// // supplyResp = respType.(*mttypes.QuerySupplyResponse) -// // s.Require().Equal(uint64(2), supplyResp.Amount) - -// // args = []string{ -// // fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// // fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// // fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// // } -// respType = proto.Message(&sdk.TxResponse{}) -// bz, err = mttestutil.BurnMTExec(val.ClientCtx, from.String(), denomID, newMTID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val2.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// // respType = proto.Message(&mttypes.QuerySupplyResponse{}) -// // bz, err = mttestutil.QuerySupplyExec(val.ClientCtx, denomID) -// // s.Require().NoError(err) -// // s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// // supplyResp = respType.(*mttypes.QuerySupplyResponse) -// // s.Require().Equal(uint64(1), supplyResp.Amount) - -// // //------test GetCmdTransferDenom()------------- -// // args = []string{ -// // fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), -// // fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), -// // fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), -// // } - -// respType = proto.Message(&sdk.TxResponse{}) - -// bz, err = mttestutil.TransferDenomExec(val.ClientCtx, from.String(), val2.Address.String(), denomID, args...) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) -// txResp = respType.(*sdk.TxResponse) -// s.Require().Equal(expectedCode, txResp.Code) - -// respType = proto.Message(&mttypes.Denom{}) -// bz, err = mttestutil.QueryDenomExec(val.ClientCtx, denomID) -// s.Require().NoError(err) -// s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) -// denomItem2 := respType.(*mttypes.Denom) -// s.Require().Equal(val2.Address.String(), denomItem2.Owner) -// s.Require().Equal(denomName, denomItem2.Name) -// } +import ( + "fmt" + "testing" + + "github.com/gogo/protobuf/proto" + "github.com/stretchr/testify/suite" + "github.com/tidwall/gjson" + + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/testutil/network" + sdk "github.com/cosmos/cosmos-sdk/types" + + mtcli "github.com/irisnet/irismod/modules/mt/client/cli" + mttestutil "github.com/irisnet/irismod/modules/mt/client/testutil" + mttypes "github.com/irisnet/irismod/modules/mt/types" + "github.com/irisnet/irismod/simapp" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := simapp.NewConfig() + cfg.NumValidators = 2 + + s.cfg = cfg + + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) TestMT() { + val := s.network.Validators[0] + val2 := s.network.Validators[1] + + // --------------------------------------------------------------------------- + denomName := "name" + data := "data" + from := val.Address + mintAmt := "10" + transferAmt := "5" + burnAmt := "5" + + //------test GetCmdIssueDenom()------------- + args := []string{ + fmt.Sprintf("--%s=%s", mtcli.FlagName, denomName), + fmt.Sprintf("--%s=%s", mtcli.FlagData, data), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType := proto.Message(&sdk.TxResponse{}) + expectedCode := uint32(0) + + bz, err := mttestutil.IssueDenomExec(val.ClientCtx, from.String(), args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp := respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + denomID := gjson.Get(txResp.RawLog, "0.events.0.attributes.0.value").String() + + //------test GetCmdQueryDenom()------------- + respType = proto.Message(&mttypes.Denom{}) + bz, err = mttestutil.QueryDenomExec(val.ClientCtx, denomID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + denomItem := respType.(*mttypes.Denom) + s.Require().Equal(denomName, denomItem.Name) + s.Require().Equal([]byte(data), denomItem.Data) + + //------test GetCmdQueryDenoms()------------- + respType = proto.Message(&mttypes.QueryDenomsResponse{}) + bz, err = mttestutil.QueryDenomsExec(val.ClientCtx) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + denomsResp := respType.(*mttypes.QueryDenomsResponse) + s.Require().Equal(1, len(denomsResp.Denoms)) + s.Require().Equal(denomID, denomsResp.Denoms[0].Id) + + //------test GetCmdMintMT()------------- + args = []string{ + fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), + fmt.Sprintf("--%s=%s", mtcli.FlagAmount, mintAmt), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + + bz, err = mttestutil.MintMTExec(val.ClientCtx, from.String(), denomID, args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + respType = proto.Message(&mttypes.QueryMTsResponse{}) + bz, err = mttestutil.QueryMTsExec(val.ClientCtx, denomID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + mtsResp := respType.(*mttypes.QueryMTsResponse) + s.Require().Equal(1, len(mtsResp.Mts)) + + mtID := mtsResp.Mts[0].Id + + //------test GetCmdQueryMT()------------- + respType = proto.Message(&mttypes.MT{}) + bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + mtItem := respType.(*mttypes.MT) + s.Require().Equal(mtID, mtItem.Id) + + //-------test GetCmdQueryBalances()---------- + respType = proto.Message(&mttypes.QueryBalancesResponse{}) + bz, err = mttestutil.QueryBlancesExec(val.ClientCtx, from.String(), denomID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + balancesItem := respType.(*mttypes.QueryBalancesResponse) + s.Require().Equal(1, len(balancesItem.Balance)) + s.Require().Equal(uint64(10), balancesItem.Balance[0].Amount) + + //------test GetCmdEditMT()------------- + newTokenDate := "newdata" + args = []string{ + fmt.Sprintf("--%s=%s", mtcli.FlagData, newTokenDate), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + + bz, err = mttestutil.EditMTExec(val.ClientCtx, from.String(), denomID, mtID, args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + respType = proto.Message(&mttypes.MT{}) + bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + newMTItem := respType.(*mttypes.MT) + s.Require().Equal([]byte(newTokenDate), newMTItem.Data) + + //------test GetCmdTransferMT()------------- + recipient := sdk.AccAddress(crypto.AddressHash([]byte("dgsbl"))) + + args = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + + bz, err = mttestutil.TransferMTExec(val.ClientCtx, from.String(), recipient.String(), denomID, mtID, transferAmt, args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + respType = proto.Message(&mttypes.MT{}) + bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + mtItem = respType.(*mttypes.MT) + s.Require().Equal(mtID, mtItem.Id) + s.Require().Equal([]byte(newTokenDate), mtItem.Data) + + //------test GetCmdBurnMT()------------- + args = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + + bz, err = mttestutil.BurnMTExec(val.ClientCtx, from.String(), denomID, mtID, burnAmt, args...) + s.Require().NoError(err) + s.Require().NoError(val2.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + respType = proto.Message(&mttypes.MT{}) + bz, err = mttestutil.QueryMTExec(val.ClientCtx, denomID, mtID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + mtItem2 := respType.(*mttypes.MT) + s.Require().Equal(mtID, mtItem2.Id) + s.Require().Equal([]byte(newTokenDate), mtItem2.Data) + s.Require().Equal(uint64(5), mtItem2.Supply) + + //------test GetCmdTransferDenom()------------- + args = []string{ + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + + bz, err = mttestutil.TransferDenomExec(val.ClientCtx, from.String(), val2.Address.String(), denomID, args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + + respType = proto.Message(&mttypes.Denom{}) + bz, err = mttestutil.QueryDenomExec(val.ClientCtx, denomID) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) + denomItem2 := respType.(*mttypes.Denom) + s.Require().Equal(val2.Address.String(), denomItem2.Owner) + s.Require().Equal(denomName, denomItem2.Name) +} diff --git a/modules/mt/client/cli/tx.go b/modules/mt/client/cli/tx.go index 11ee0e5a..378d6d5d 100644 --- a/modules/mt/client/cli/tx.go +++ b/modules/mt/client/cli/tx.go @@ -38,7 +38,7 @@ func NewTxCmd() *cobra.Command { return txCmd } -// GetCmdIssueDenom is the CLI command for an IssueDenom transaction +// GetCmdIssueDenom is the CLI command for an SaveDenom transaction func GetCmdIssueDenom() *cobra.Command { cmd := &cobra.Command{ Use: "issue", diff --git a/modules/mt/client/testutil/grpc_query_test.go b/modules/mt/client/testutil/grpc_query_test.go new file mode 100644 index 00000000..52c23ec0 --- /dev/null +++ b/modules/mt/client/testutil/grpc_query_test.go @@ -0,0 +1,157 @@ +package testutil_test + +import ( + "fmt" + "github.com/cosmos/cosmos-sdk/testutil/rest" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/gogo/protobuf/proto" + mtcli "github.com/irisnet/irismod/modules/mt/client/cli" + mttestutil "github.com/irisnet/irismod/modules/mt/client/testutil" + mttypes "github.com/irisnet/irismod/modules/mt/types" + "github.com/tidwall/gjson" + + "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/irisnet/irismod/simapp" + "github.com/stretchr/testify/suite" +) + +type IntegrationTestSuite struct { + suite.Suite + + cfg network.Config + network *network.Network +} + +func (s *IntegrationTestSuite) SetupSuite() { + s.T().Log("setting up integration test suite") + + cfg := simapp.NewConfig() + cfg.NumValidators = 2 + + s.cfg = cfg + + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) + s.Require().NoError(err) +} + +func (s *IntegrationTestSuite) TearDownSuite() { + s.T().Log("tearing down integration test suite") + s.network.Cleanup() +} + +func TestIntegrationTestSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} + +func (s *IntegrationTestSuite) TestMT() { + denomName := "name" + data := "data" + mintAmt := "10" + mintAmtUint := uint64(10) + + denomID := "" + mtID := "" + + val := s.network.Validators[0] + from := val.Address + baseURL := val.APIAddress + + expectedCode := uint32(0) + + // Issue + args := []string{ + fmt.Sprintf("--%s=%s", mtcli.FlagName, denomName), + fmt.Sprintf("--%s=%s", mtcli.FlagData, data), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10))).String()), + } + + respType := proto.Message(&sdk.TxResponse{}) + bz, err := mttestutil.IssueDenomExec(val.ClientCtx, from.String(), args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp := respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + denomID = gjson.Get(txResp.RawLog, "0.events.0.attributes.0.value").String() + + // Mint + args = []string{ + fmt.Sprintf("--%s=%s", mtcli.FlagRecipient, from.String()), + fmt.Sprintf("--%s=%s", mtcli.FlagAmount, mintAmt), + + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(100))).String()), + } + + respType = proto.Message(&sdk.TxResponse{}) + bz, err = mttestutil.MintMTExec(val.ClientCtx, from.String(), denomID, args...) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType), bz.String()) + txResp = respType.(*sdk.TxResponse) + s.Require().Equal(expectedCode, txResp.Code) + mtID = gjson.Get(txResp.RawLog, "0.events.1.attributes.0.value").String() + + //Denom + respType = proto.Message(&mttypes.QueryDenomResponse{}) + url := fmt.Sprintf("%s/irismod/mt/denoms/%s", baseURL, denomID) + resp, err := rest.GetRequest(url) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + + denomItem := respType.(*mttypes.QueryDenomResponse) + s.Require().Equal(denomID, denomItem.Denom.Id) + s.Require().Equal([]byte(data), denomItem.Denom.Data) + s.Require().Equal(val.Address.String(), denomItem.Denom.Owner) + + //Denoms + respType = proto.Message(&mttypes.QueryDenomsResponse{}) + url = fmt.Sprintf("%s/irismod/mt/denoms", baseURL) + resp, err = rest.GetRequest(url) + + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + + denomsItem := respType.(*mttypes.QueryDenomsResponse) + s.Require().Equal(1, len(denomsItem.Denoms)) + s.Require().Equal(denomID, denomsItem.Denoms[0].Id) + + //MTSupply + respType = proto.Message(&mttypes.QueryMTSupplyResponse{}) + url = fmt.Sprintf("%s/irismod/mt/mts/%s/%s/supply", baseURL, denomID, mtID) + resp, err = rest.GetRequest(url) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + + mtSupplyItem := respType.(*mttypes.QueryMTSupplyResponse) + s.Require().Equal(mintAmtUint, mtSupplyItem.Amount) + + //MT + respType = proto.Message(&mttypes.QueryMTResponse{}) + url = fmt.Sprintf("%s/irismod/mt/mts/%s/%s", baseURL, denomID, mtID) + resp, err = rest.GetRequest(url) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + + mtItem := respType.(*mttypes.QueryMTResponse) + s.Require().Equal(mtID, mtItem.Mt.Id) + + //MTs + respType = proto.Message(&mttypes.QueryMTsResponse{}) + url = fmt.Sprintf("%s/irismod/mt/mts/%s", baseURL, denomID) + resp, err = rest.GetRequest(url) + s.Require().NoError(err) + s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) + + mtsItem := respType.(*mttypes.QueryMTsResponse) + s.Require().Equal(1, len(mtsItem.Mts)) +} diff --git a/modules/mt/client/testutil/test_helpers.go b/modules/mt/client/testutil/test_helpers.go index f6412569..57651e05 100644 --- a/modules/mt/client/testutil/test_helpers.go +++ b/modules/mt/client/testutil/test_helpers.go @@ -14,9 +14,8 @@ import ( ) // IssueDenomExec creates a redelegate message. -func IssueDenomExec(clientCtx client.Context, from string, denom string, extraArgs ...string) (testutil.BufferWriter, error) { +func IssueDenomExec(clientCtx client.Context, from string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ - denom, fmt.Sprintf("--%s=%s", flags.FlagFrom, from), } args = append(args, extraArgs...) @@ -24,10 +23,11 @@ func IssueDenomExec(clientCtx client.Context, from string, denom string, extraAr return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdIssueDenom(), args) } -func BurnMTExec(clientCtx client.Context, from string, denomID string, mtID string, extraArgs ...string) (testutil.BufferWriter, error) { +func BurnMTExec(clientCtx client.Context, from string, denomID string, mtID string, amount string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ denomID, mtID, + amount, fmt.Sprintf("--%s=%s", flags.FlagFrom, from), } args = append(args, extraArgs...) @@ -35,10 +35,9 @@ func BurnMTExec(clientCtx client.Context, from string, denomID string, mtID stri return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdBurnMT(), args) } -func MintMTExec(clientCtx client.Context, from string, denomID string, mtID string, extraArgs ...string) (testutil.BufferWriter, error) { +func MintMTExec(clientCtx client.Context, from string, denomID string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ denomID, - mtID, fmt.Sprintf("--%s=%s", flags.FlagFrom, from), } args = append(args, extraArgs...) @@ -57,12 +56,13 @@ func EditMTExec(clientCtx client.Context, from string, denomID string, mtID stri return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdEditMT(), args) } -func TransferMTExec(clientCtx client.Context, from string, recipient string, denomID string, mtID string, extraArgs ...string) (testutil.BufferWriter, error) { +func TransferMTExec(clientCtx client.Context, from string, recipient string, denomID string, mtID string, amount string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ + from, recipient, denomID, mtID, - fmt.Sprintf("--%s=%s", flags.FlagFrom, from), + amount, } args = append(args, extraArgs...) @@ -88,6 +88,16 @@ func QueryDenomsExec(clientCtx client.Context, extraArgs ...string) (testutil.Bu return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdQueryDenoms(), args) } +func QueryMTsExec(clientCtx client.Context, denomID string, extraArgs ...string) (testutil.BufferWriter, error) { + args := []string{ + denomID, + fmt.Sprintf("--%s=json", cli.OutputFlag), + } + args = append(args, extraArgs...) + + return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdQueryMTs(), args) +} + func QueryMTExec(clientCtx client.Context, denomID string, mtID string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ denomID, @@ -99,11 +109,22 @@ func QueryMTExec(clientCtx client.Context, denomID string, mtID string, extraArg return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdQueryMT(), args) } +func QueryBlancesExec(clientCtx client.Context, from string, denomID string, extraArgs ...string) (testutil.BufferWriter, error) { + args := []string{ + from, + denomID, + fmt.Sprintf("--%s=json", cli.OutputFlag), + } + args = append(args, extraArgs...) + + return clitestutil.ExecTestCLICmd(clientCtx, mtcli.GetCmdQueryBalances(), args) +} + func TransferDenomExec(clientCtx client.Context, from string, recipient string, denomID string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ + from, recipient, denomID, - fmt.Sprintf("--%s=%s", flags.FlagFrom, from), } args = append(args, extraArgs...) diff --git a/modules/mt/keeper/grpc_query_test.go b/modules/mt/keeper/grpc_query_test.go deleted file mode 100644 index 94292649..00000000 --- a/modules/mt/keeper/grpc_query_test.go +++ /dev/null @@ -1 +0,0 @@ -package keeper_test diff --git a/modules/mt/keeper/keeper.go b/modules/mt/keeper/keeper.go index ea18b740..9ee9893c 100644 --- a/modules/mt/keeper/keeper.go +++ b/modules/mt/keeper/keeper.go @@ -34,12 +34,12 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { // IssueDenom issues a denom according to the given params func (k Keeper) IssueDenom(ctx sdk.Context, - id, name string, sednder sdk.AccAddress, data []byte, + id, name string, sender sdk.AccAddress, data []byte, ) types.Denom { denom := types.Denom{ Id: id, Name: name, - Owner: sednder.String(), + Owner: sender.String(), Data: data, } @@ -84,7 +84,6 @@ func (k Keeper) MintMT(ctx sdk.Context, amount uint64, recipient sdk.AccAddress, ) error { - // increase MT supply if err := k.IncreaseMTSupply(ctx, denomID, mtID, amount); err != nil { return err diff --git a/modules/mt/simulation/genesis.go b/modules/mt/simulation/genesis.go index 9c5a5429..c6e1523c 100644 --- a/modules/mt/simulation/genesis.go +++ b/modules/mt/simulation/genesis.go @@ -3,51 +3,124 @@ package simulation import ( "encoding/json" "fmt" - "math/rand" - "strings" - "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" - - "github.com/irisnet/irismod/modules/mt/types" + mt "github.com/irisnet/irismod/modules/mt/types" + "math/rand" ) const ( - kitties = "kitties" - doggos = "doggos" + prefixDenomID = "denom:id:" + prefixDenomName = "denom:name:" + prefixMtID = "mt:id" + + lenMTs = 10 // MTs number under a denom + supply = uint64(10) // supply for each MT ) -// RandomizedGenState generates a random GenesisState for mt -func RandomizedGenState(simState *module.SimulationState) { - collections := types.NewCollections( - types.NewCollection( - types.Denom{ - Id: doggos, - Name: doggos, - }, - types.MTs{}, - ), - types.NewCollection( - types.Denom{ - Id: kitties, - Name: kitties, +// genMTs returns MTs for a denom +func genMTs(r *rand.Rand) []mt.MT { + mts := make([]mt.MT, lenMTs) + for i := 0; i < lenMTs; i++ { + mts[i] = mt.MT{ + Id: prefixMtID + simtypes.RandStringOfLength(r, 10), + Supply: supply, + Data: []byte(simtypes.RandStringOfLength(r, 10)), + } + } + return mts +} + +// genCollections returns a slice of mt collection +func genCollections(r *rand.Rand, accounts []simtypes.Account) []mt.Collection { + collections := make([]mt.Collection, len(accounts)) + for i := 0; i < len(accounts); i++ { + collections[i] = mt.Collection{ + Denom: &mt.Denom{ + Id: prefixDenomID + simtypes.RandStringOfLength(r, 10), + Name: prefixDenomName + simtypes.RandStringOfLength(r, 10), + Data: []byte(simtypes.RandStringOfLength(r, 10)), + Owner: accounts[i].Address.String(), }, - types.MTs{}), + Mts: genMTs(r), + } + } + return collections +} + +// genDenomBalances generates DenomBalances for each account. +// mts must belong to denomId. +func genDenomBalances(r *rand.Rand, denomId string, mts []mt.MT, accounts []simtypes.Account) []mt.DenomBalance { + denomBalances := make([]mt.DenomBalance, len(accounts)) + for i := 0; i < len(accounts); i++ { + balances := make([]mt.Balance, len(mts)) + + // amount evenly distributed and sum-up not exceeding the total supply + for j := 0; j < len(mts); j++ { + balances[j] = mt.Balance{ + MtId: mts[j].Id, + Amount: mts[j].Supply / uint64(len(accounts)), + } + } + + denomBalances[i] = mt.DenomBalance{ + DenomId: denomId, + Balances: balances, + } + } + + return denomBalances +} + +// genOwners returns a slice of mt owner +func genOwners(r *rand.Rand, collections []mt.Collection, accounts []simtypes.Account) []mt.Owner { + owners := make([]mt.Owner, len(accounts)) + for i := 0; i < len(accounts); i++ { + collection := collections[i] + owners[i] = mt.Owner{ + Address: accounts[i].Address.String(), + Denoms: genDenomBalances(r, collection.Denom.Id, collection.Mts, accounts), + } + } + + return owners +} + +// RandomizedGenState generates a random GenesisState for mt. +func RandomizedGenState(simState *module.SimulationState) { + var ( + collections []mt.Collection + owners []mt.Owner + accLen int = 10 ) - mtGenesis := types.NewGenesisState(collections, []types.Owner{}) + if len(simState.Accounts) < accLen { + accLen = len(simState.Accounts) + } + + accs := simState.Accounts[:accLen] + simState.AppParams.GetOrGenerate(simState.Cdc, "mt", &collections, simState.Rand, + func(r *rand.Rand) { + collections = genCollections(r, accs) + }, + ) + + simState.AppParams.GetOrGenerate(simState.Cdc, "mt", &owners, simState.Rand, + func(r *rand.Rand) { + owners = genOwners(r, collections, accs) + }, + ) + + mtGenesis := &mt.GenesisState{ + Collections: collections, + Owners: owners, + } bz, err := json.MarshalIndent(mtGenesis, "", " ") if err != nil { - panic(err) + fmt.Printf("Selected randomly generated %s parameters:\n%s\n", mt.ModuleName, bz) } - fmt.Printf("Selected randomly generated %s parameters:\n%s\n", types.ModuleName, bz) - simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(mtGenesis) -} + simState.GenState[mt.ModuleName] = simState.Cdc.MustMarshalJSON(mtGenesis) -func RandnMTID(r *rand.Rand, min, max int) string { - n := simtypes.RandIntBetween(r, min, max) - id := simtypes.RandStringOfLength(r, n) - return strings.ToLower(id) } diff --git a/modules/mt/simulation/genesis_test.go b/modules/mt/simulation/genesis_test.go new file mode 100644 index 00000000..8c9b163f --- /dev/null +++ b/modules/mt/simulation/genesis_test.go @@ -0,0 +1,39 @@ +package simulation + +import ( + "encoding/json" + mt "github.com/irisnet/irismod/modules/mt/types" + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + sdkmath "cosmossdk.io/math" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/types/module" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func TestRandomizedGenState(t *testing.T) { + app := simapp.Setup(t, false) + + s := rand.NewSource(1) + r := rand.New(s) + + simState := module.SimulationState{ + AppParams: make(simtypes.AppParams), + Cdc: app.AppCodec(), + Rand: r, + NumBonded: 3, + Accounts: simtypes.RandomAccounts(r, 3), + InitialStake: sdkmath.NewInt(1000), + GenState: make(map[string]json.RawMessage), + } + + RandomizedGenState(&simState) + var mtGenesis mt.GenesisState + simState.Cdc.MustUnmarshalJSON(simState.GenState[mt.ModuleName], &mtGenesis) + + require.Len(t, mtGenesis.Collections, len(simState.Accounts)) + require.Len(t, mtGenesis.Owners, len(simState.Accounts)) +} diff --git a/modules/mt/simulation/operations.go b/modules/mt/simulation/operations.go index 1384576d..71de1f78 100644 --- a/modules/mt/simulation/operations.go +++ b/modules/mt/simulation/operations.go @@ -1,9 +1,7 @@ package simulation import ( - "fmt" "math/rand" - "strings" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" @@ -12,9 +10,8 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" - "github.com/irisnet/irismod/modules/mt/keeper" - "github.com/irisnet/irismod/modules/mt/types" + mt "github.com/irisnet/irismod/modules/mt/types" ) // Simulation operation weights constants @@ -32,8 +29,8 @@ func WeightedOperations( appParams simtypes.AppParams, cdc codec.JSONCodec, k keeper.Keeper, - ak types.AccountKeeper, - bk types.BankKeeper, + ak mt.AccountKeeper, + bk mt.BankKeeper, ) simulation.WeightedOperations { var weightIssueDenom, weightMint, weightEdit, weightBurn, weightTransfer, weightTransferDenom int @@ -79,6 +76,10 @@ func WeightedOperations( ) return simulation.WeightedOperations{ + simulation.NewWeightedOperation( + weightTransfer, + SimulateMsgTransferMT(k, ak, bk), + ), simulation.NewWeightedOperation( weightIssueDenom, SimulateMsgIssueDenom(k, ak, bk), @@ -91,10 +92,6 @@ func WeightedOperations( weightEdit, SimulateMsgEditMT(k, ak, bk), ), - simulation.NewWeightedOperation( - weightTransfer, - SimulateMsgTransferMT(k, ak, bk), - ), simulation.NewWeightedOperation( weightBurn, SimulateMsgBurnMT(k, ak, bk), @@ -106,384 +103,459 @@ func WeightedOperations( } } -// SimulateMsgTransferMT simulates the transfer of an MT -func SimulateMsgTransferMT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgIssueDenom simulates issue an denom +func SimulateMsgIssueDenom(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, mtID := getRandomMTFromOwner(ctx, k, r) - if ownerAddr.Empty() { - err = fmt.Errorf("invalid account") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err - } - - recipientAccount, _ := simtypes.RandomAcc(r, accs) - msg := types.NewMsgTransferMT( - mtID, - denom, - ownerAddr.String(), // sender - recipientAccount.Address.String(), // recipient - 1, // TODO - ) - account := ak.GetAccount(ctx, ownerAddr) + sender, _ := simtypes.RandomAcc(r, accs) + denomName := simtypes.RandStringOfLength(r, 10) + denomData := simtypes.RandStringOfLength(r, 10) - ownerAccount, found := simtypes.FindAccount(accs, ownerAddr) - if !found { - err = fmt.Errorf("account %s not found", msg.Sender) - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + senderAcc := ak.GetAccount(ctx, sender.Address) + spendableCoins := bk.SpendableCoins(ctx, sender.Address) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeIssueDenom, err.Error()), nil, err } - spendable := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendable) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeIssueDenom, "spend limit is nil"), nil, nil } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + msg := &mt.MsgIssueDenom{ + Name: denomName, + Data: []byte(denomData), + Sender: sender.Address.String(), + } + + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - ownerAccount.PrivKey, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, + sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeIssueDenom, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -// SimulateMsgEditMT simulates an edit tokenData transaction -func SimulateMsgEditMT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgMintMT simulates mint an MT +func SimulateMsgMintMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, mtID := getRandomMTFromOwner(ctx, k, r) - if ownerAddr.Empty() { - err = fmt.Errorf("account invalid") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditMT, err.Error()), nil, err + collection, ok := randCollection(ctx, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, "not fetch a collection"), nil, nil } - msg := types.NewMsgEditMT( - mtID, - denom, - simtypes.RandStringOfLength(r, 10), // tokenData - ownerAddr.String(), - ) + mtr, denomID, ok := randMTWithCollection(ctx, collection, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, "not fetch an mt"), nil, nil + } - account := ak.GetAccount(ctx, ownerAddr) - spendable := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendable) + owner := collection.Denom.Owner + senderAddr, err := sdk.AccAddressFromBech32(owner) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditMT, err.Error()), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, err.Error()), nil, err } - ownerAccount, found := simtypes.FindAccount(accs, ownerAddr) - if !found { - err = fmt.Errorf("account %s not found", ownerAddr) - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditMT, err.Error()), nil, err + senderAcc := ak.GetAccount(ctx, senderAddr) + sender, ok := simtypes.FindAccount(accs, senderAcc.GetAddress()) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, "owner(sender) not found"), nil, err } + recipient, _ := simtypes.RandomAcc(r, accs) - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + spendableCoins := bk.SpendableCoins(ctx, sender.Address) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, err.Error()), nil, err + } + + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeMintMT, "spend limit is nil"), nil, nil + } + + msg := &mt.MsgMintMT{ + Id: mtr.Id, + DenomId: denomID, + Amount: uint64(simtypes.RandIntBetween(r, 1, 100)), + Data: nil, + Sender: sender.Address.String(), + Recipient: recipient.Address.String(), + } + + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - ownerAccount.PrivKey, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, + sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditMT, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -// SimulateMsgMintMT simulates a mint of an MT -func SimulateMsgMintMT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgEditMT simulates an edit tokenData transaction +func SimulateMsgEditMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - randomSender, _ := simtypes.RandomAcc(r, accs) - randomRecipient, _ := simtypes.RandomAcc(r, accs) - - // TODO refactor - msg := types.NewMsgMintMT( - RandnMTID(r, 1, 32), // mt ID - getRandomDenom(ctx, k, r), // denom - 1, - simtypes.RandStringOfLength(r, 10), // tokenData - randomSender.Address.String(), // sender - randomRecipient.Address.String(), // recipient - ) + data := simtypes.RandStringOfLength(r, 10) - account := ak.GetAccount(ctx, randomSender.Address) - spendable := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendable) + mtr, denomID, owner, ok := randMT(ctx, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "not fetch an mt"), nil, nil + } + ownerAddr := sdk.MustAccAddressFromBech32(owner) + senderAcc := ak.GetAccount(ctx, ownerAddr) + spendableCoins := bk.SpendableCoins(ctx, ownerAddr) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeMintMT, err.Error()), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, err.Error()), nil, err } - simAccount, found := simtypes.FindAccount(accs, randomSender.Address) - if !found { - err = fmt.Errorf("account %s not found", msg.Sender) - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeMintMT, err.Error()), nil, err + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "spend limit is nil"), nil, nil } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + amt := k.GetBalance(ctx, denomID, mtr.Id, ownerAddr) + if amt == 0 { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "sender doesn't have this mt"), nil, nil + } + + msg := &mt.MsgEditMT{ + Id: mtr.Id, + DenomId: denomID, + Data: []byte(data), + Sender: ownerAddr.String(), + } + + sender, ok := simtypes.FindAccount(accs, senderAcc.GetAddress()) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "owner(sender) not found"), nil, nil + } + + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - simAccount.PrivKey, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, + sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeEditMT, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeMintMT, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -// SimulateMsgBurnMT simulates a burn of an existing MT -func SimulateMsgBurnMT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgTransferMT simulates the transfer of an MT +func SimulateMsgTransferMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, - ) ( - opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, + ) (OperationMsg simtypes.OperationMsg, futureOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, mtID := getRandomMTFromOwner(ctx, k, r) - if ownerAddr.Empty() { - err = fmt.Errorf("invalid account") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeBurnMT, err.Error()), nil, err + + mtr, denomID, owner, ok := randMT(ctx, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "not fetch an mt"), nil, nil + } + + ownerAddr := sdk.MustAccAddressFromBech32(owner) + senderAcc := ak.GetAccount(ctx, ownerAddr) + sender, ok := simtypes.FindAccount(accs, senderAcc.GetAddress()) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "owner(sender) not found"), nil, nil } - // TODO - msg := types.NewMsgBurnMT(ownerAddr.String(), mtID, denom, 1) + recipient, _ := simtypes.RandomAcc(r, accs) + if sender.Address.Equals(recipient.Address) { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "sender and recipient are same"), nil, nil + } - account := ak.GetAccount(ctx, ownerAddr) - spendable := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendable) + spendableCoins := bk.SpendableCoins(ctx, sender.Address) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeBurnMT, err.Error()), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, err.Error()), nil, err + } + + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "spend limit is nil"), nil, nil + } + + amt := k.GetBalance(ctx, denomID, mtr.Id, sender.Address) + if amt <= 1 { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "sender doesn't have enough mt balances "), nil, nil } - simAccount, found := simtypes.FindAccount(accs, ownerAddr) - if !found { - err = fmt.Errorf("account %s not found", msg.Sender) - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeBurnMT, err.Error()), nil, err + amt = uint64(simtypes.RandIntBetween(r, 1, int(amt))) + msg := &mt.MsgTransferMT{ + Id: mtr.Id, + DenomId: denomID, + Amount: amt, + Sender: sender.Address.String(), + Recipient: recipient.Address.String(), } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - simAccount.PrivKey, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, + sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransfer, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditMT, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -// SimulateMsgTransferDenom simulates the transfer of an denom -func SimulateMsgTransferDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgBurnMT simulates a burn of an existing MT +func SimulateMsgBurnMT(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { + mtr, denomID, owner, ok := randMT(ctx, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, "not fetch an mt"), nil, nil + } - denomId := getRandomDenom(ctx, k, r) - denom, found := k.GetDenom(ctx, denomId) - if !found { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, err.Error()), nil, err + ownerAddr := sdk.MustAccAddressFromBech32(owner) + senderAcc := ak.GetAccount(ctx, ownerAddr) + sender, ok := simtypes.FindAccount(accs, senderAcc.GetAddress()) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, "not fetch an mt"), nil, nil } - creator, err := sdk.AccAddressFromBech32(denom.Owner) + spendableCoins := bk.SpendableCoins(ctx, sender.Address) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, err.Error()), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, err.Error()), nil, err } - account := ak.GetAccount(ctx, creator) - owner, found := simtypes.FindAccount(accs, account.GetAddress()) - if !found { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, "creator not found"), nil, nil + + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, "spend limit is nil"), nil, nil } - recipient, _ := simtypes.RandomAcc(r, accs) - msg := types.NewMsgTransferDenom( - denomId, - denom.Owner, - recipient.Address.String(), - ) + amt := k.GetBalance(ctx, denomID, mtr.Id, sender.Address) + if amt <= 1 { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, "sender doesn't have enough mt balances "), nil, nil + } - spendable := bk.SpendableCoins(ctx, owner.Address) - fees, err := simtypes.RandomFees(r, ctx, spendable) - if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, err.Error()), nil, err + amt = uint64(simtypes.RandIntBetween(r, 1, int(amt))) // unsafe conversion + msg := &mt.MsgBurnMT{ + Id: mtr.Id, + DenomId: denomID, + Amount: amt, + Sender: sender.Address.String(), } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, - owner.PrivKey, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, + sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeBurnMT, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -// SimulateMsgIssueDenom simulates issue an denom -func SimulateMsgIssueDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeeper) simtypes.Operation { +// SimulateMsgTransferDenom simulates the transfer of a Denom +func SimulateMsgTransferDenom(k keeper.Keeper, ak mt.AccountKeeper, bk mt.BankKeeper) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { + collection, ok := randCollection(ctx, r, k) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, "collection not found"), nil, err + } + owner := collection.Denom.Owner + senderAddr, err := sdk.AccAddressFromBech32(owner) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, err.Error()), nil, err + } - denomId := strings.ToLower(simtypes.RandStringOfLength(r, 10)) - denomName := strings.ToLower(simtypes.RandStringOfLength(r, 10)) - sender, _ := simtypes.RandomAcc(r, accs) - data := simtypes.RandStringOfLength(r, 20) - - denom, _ := k.GetDenom(ctx, denomId) - if denom.Size() != 0 { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, "denom exist"), nil, nil + senderAcc := ak.GetAccount(ctx, senderAddr) + sender, ok := simtypes.FindAccount(accs, senderAcc.GetAddress()) + if !ok { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, "owner(sender) not found"), nil, err } + recipient, _ := simtypes.RandomAcc(r, accs) - msg := types.NewMsgIssueDenom( - denomName, - data, - sender.Address.String(), - ) - account := ak.GetAccount(ctx, sender.Address) - spendable := bk.SpendableCoins(ctx, account.GetAddress()) - fees, err := simtypes.RandomFees(r, ctx, spendable) + spendableCoins := bk.SpendableCoins(ctx, sender.Address) + fees, err := simtypes.RandomFees(r, ctx, spendableCoins) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, err.Error()), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, err.Error()), nil, err + } + + spendLimit := spendableCoins.Sub(fees...) + if spendLimit == nil { + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, "spend limit is nil"), nil, nil } - txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( - txGen, + msg := &mt.MsgTransferDenom{ + Id: collection.Denom.Id, + Sender: sender.Address.String(), + Recipient: recipient.Address.String(), + } + + txCfg := simappparams.MakeTestEncodingConfig().TxConfig + tx, err := helpers.GenSignedMockTx( + r, + txCfg, []sdk.Msg{msg}, fees, helpers.DefaultGenTxGas, chainID, - []uint64{account.GetAccountNumber()}, - []uint64{account.GetSequence()}, + []uint64{senderAcc.GetAccountNumber()}, + []uint64{senderAcc.GetSequence()}, sender.PrivKey, ) if err != nil { - return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err + return simtypes.NoOpMsg(mt.ModuleName, mt.EventTypeTransferDenom, "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + _, _, err = app.SimDeliver(txCfg.TxEncoder(), tx) + if err != nil { + return simtypes.NoOpMsg(mt.ModuleName, sdk.MsgTypeURL(msg), "unable to deliver tx"), nil, err } return simtypes.NewOperationMsg(msg, true, "", nil), nil, nil } } -func getRandomMTFromOwner(ctx sdk.Context, k keeper.Keeper, r *rand.Rand) (address sdk.AccAddress, denomID, mtID string) { - //owners := k.GetOwners(ctx) - // - //ownersLen := len(owners) - //if ownersLen == 0 { - // return nil, "", "" - //} - // - //// get random owner - //i := r.Intn(ownersLen) - //owner := owners[i] - // - //idCollectionsLen := len(owner.IDCollections) - //if idCollectionsLen == 0 { - // return nil, "", "" - //} - // - //// get random collection from owner's balance - //i = r.Intn(idCollectionsLen) - //idCollection := owner.IDCollections[i] // mts IDs - //denomID = idCollection.DenomId - // - //idsLen := len(idCollection.TokenIds) - //if idsLen == 0 { - // return nil, "", "" - //} - // - //// get random mt from collection - //i = r.Intn(idsLen) - //mtID = idCollection.TokenIds[i] - // - //ownerAddress, _ := sdk.AccAddressFromBech32(owner.Address) - //return ownerAddress, denomID, mtID - //TODO - return nil, "", "" +// randCollection randomly returns a Collection +func randCollection(ctx sdk.Context, r *rand.Rand, k keeper.Keeper) (mt.Collection, bool) { + collection := mt.Collection{} + + denoms := k.GetDenoms(ctx) + if len(denoms) == 0 { + return collection, false + } + + denom := denoms[r.Intn(len(denoms))] + mts := k.GetMTs(ctx, denom.Id) + rmts := make([]mt.MT, len(mts)) + for i := 0; i < len(mts); i++ { + var ok bool + if rmts[i], ok = mts[i].(mt.MT); !ok { + return collection, false + } + } + + collection.Denom = &denom + collection.Mts = rmts + + return collection, true } -func getRandomDenom(ctx sdk.Context, k keeper.Keeper, r *rand.Rand) string { - var denoms = []string{kitties, doggos} - i := r.Intn(len(denoms)) - return denoms[i] +// randMT randomly returns an MT +func randMT(ctx sdk.Context, r *rand.Rand, k keeper.Keeper) (mt.MT, string, string, bool) { + collection, ok := randCollection(ctx, r, k) + if !ok { + return mt.MT{}, "", "", false + } + + mts := collection.Mts + if len(mts) == 0 { + return mt.MT{}, "", "", false + } + + idx := r.Intn(len(mts)) + + return mts[idx], collection.Denom.Id, collection.Denom.Owner, true } -func genRandomBool(r *rand.Rand) bool { - return r.Int()%2 == 0 +// randMTWithCollection randomly returns an MT but with collection specified. +func randMTWithCollection(ctx sdk.Context, collection mt.Collection, r *rand.Rand, k keeper.Keeper) (mt.MT, string, bool) { + if collection.Denom == nil || len(collection.Mts) == 0 { + return mt.MT{}, "", false + } + + idx := r.Intn(len(collection.Mts)) + return collection.Mts[idx], collection.Denom.Id, true } diff --git a/modules/mt/types/common_test.go b/modules/mt/types/common_test.go index 8d0bc3c7..2b6134ef 100644 --- a/modules/mt/types/common_test.go +++ b/modules/mt/types/common_test.go @@ -31,7 +31,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string buffer.WriteString(numString) //adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) bech := res.String() addresses = append(addresses, testAddr(buffer.String(), bech)) buffer.Reset() @@ -41,7 +41,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { // for incode address generation func testAddr(addr string, bech string) sdk.AccAddress { - res, err := sdk.AccAddressFromHex(addr) + res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { panic(err) } diff --git a/modules/mt/types/query.pb.gw.go b/modules/mt/types/query.pb.gw.go index c23b44a4..caabf5ba 100644 --- a/modules/mt/types/query.pb.gw.go +++ b/modules/mt/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join var ( filter_Query_Supply_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} @@ -456,12 +458,14 @@ func local_request_Query_Balances_0(ctx context.Context, marshaler runtime.Marsh // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Supply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -469,6 +473,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Supply_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -482,6 +487,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Denoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -489,6 +496,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Denoms_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -502,6 +510,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Denom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -509,6 +519,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Denom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -522,6 +533,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_MTSupply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -529,6 +542,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_MTSupply_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -542,6 +556,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_MTs_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -549,6 +565,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_MTs_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -562,6 +579,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_MT_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -569,6 +588,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_MT_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -582,6 +602,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Balances_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -589,6 +611,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Balances_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -784,19 +807,19 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"irismod", "mt", "denoms", "supply"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"irismod", "mt", "denoms", "supply"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "mt", "denoms"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "mt", "denoms"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Denom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "mt", "denoms", "denom_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Denom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "mt", "denoms", "denom_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_MTSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"irismod", "mt", "mts", "denom_id", "mt_id", "supply"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_MTSupply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"irismod", "mt", "mts", "denom_id", "mt_id", "supply"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_MTs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "mt", "mts", "denom_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_MTs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "mt", "mts", "denom_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_MT_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "mt", "mts", "denom_id", "mt_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_MT_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "mt", "mts", "denom_id", "mt_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Balances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "mt", "mts", "owner", "balances"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Balances_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "mt", "mts", "owner", "balances"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/mt/types/tx.pb.go b/modules/mt/types/tx.pb.go index fe744811..4631a428 100644 --- a/modules/mt/types/tx.pb.go +++ b/modules/mt/types/tx.pb.go @@ -7,15 +7,16 @@ import ( bytes "bytes" context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -69,7 +70,7 @@ func (m *MsgIssueDenom) XXX_DiscardUnknown() { var xxx_messageInfo_MsgIssueDenom proto.InternalMessageInfo -// MsgIssueDenomResponse defines the Msg/IssueDenom response type. +// MsgIssueDenomResponse defines the Msg/SaveDenom response type. type MsgIssueDenomResponse struct { } @@ -106,7 +107,8 @@ func (m *MsgIssueDenomResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgIssueDenomResponse proto.InternalMessageInfo -// MsgTransferDenom defines an SDK message for transferring an denom to recipient. +// MsgTransferDenom defines an SDK message for transferring an denom to +// recipient. type MsgTransferDenom struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` @@ -769,7 +771,8 @@ type MsgClient interface { IssueDenom(ctx context.Context, in *MsgIssueDenom, opts ...grpc.CallOption) (*MsgIssueDenomResponse, error) // TransferDenom defines a method for transferring a denom. TransferDenom(ctx context.Context, in *MsgTransferDenom, opts ...grpc.CallOption) (*MsgTransferDenomResponse, error) - // MintMT defines a method for creating a new MT or minting amounts of an existing MT + // MintMT defines a method for creating a new MT or minting amounts of an + // existing MT MintMT(ctx context.Context, in *MsgMintMT, opts ...grpc.CallOption) (*MsgMintMTResponse, error) // EditMT defines a method for editing an MT. EditMT(ctx context.Context, in *MsgEditMT, opts ...grpc.CallOption) (*MsgEditMTResponse, error) @@ -789,7 +792,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) IssueDenom(ctx context.Context, in *MsgIssueDenom, opts ...grpc.CallOption) (*MsgIssueDenomResponse, error) { out := new(MsgIssueDenomResponse) - err := c.cc.Invoke(ctx, "/irismod.mt.Msg/IssueDenom", in, out, opts...) + err := c.cc.Invoke(ctx, "/irismod.mt.Msg/SaveDenom", in, out, opts...) if err != nil { return nil, err } @@ -847,7 +850,8 @@ type MsgServer interface { IssueDenom(context.Context, *MsgIssueDenom) (*MsgIssueDenomResponse, error) // TransferDenom defines a method for transferring a denom. TransferDenom(context.Context, *MsgTransferDenom) (*MsgTransferDenomResponse, error) - // MintMT defines a method for creating a new MT or minting amounts of an existing MT + // MintMT defines a method for creating a new MT or minting amounts of an + // existing MT MintMT(context.Context, *MsgMintMT) (*MsgMintMTResponse, error) // EditMT defines a method for editing an MT. EditMT(context.Context, *MsgEditMT) (*MsgEditMTResponse, error) @@ -862,7 +866,7 @@ type UnimplementedMsgServer struct { } func (*UnimplementedMsgServer) IssueDenom(ctx context.Context, req *MsgIssueDenom) (*MsgIssueDenomResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method IssueDenom not implemented") + return nil, status.Errorf(codes.Unimplemented, "method SaveDenom not implemented") } func (*UnimplementedMsgServer) TransferDenom(ctx context.Context, req *MsgTransferDenom) (*MsgTransferDenomResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TransferDenom not implemented") @@ -894,7 +898,7 @@ func _Msg_IssueDenom_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.mt.Msg/IssueDenom", + FullMethod: "/irismod.mt.Msg/SaveDenom", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).IssueDenom(ctx, req.(*MsgIssueDenom)) @@ -997,7 +1001,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "IssueDenom", + MethodName: "SaveDenom", Handler: _Msg_IssueDenom_Handler, }, { diff --git a/modules/nft/client/cli/cli_test.go b/modules/nft/client/cli/cli_test.go index 9646fa4a..2cbdcf42 100644 --- a/modules/nft/client/cli/cli_test.go +++ b/modules/nft/client/cli/cli_test.go @@ -34,9 +34,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 2 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -166,11 +169,11 @@ func (s *IntegrationTestSuite) TestNft() { s.Require().Equal(from.String(), nftItem.Owner) //------test GetCmdQueryOwner()------------- - respType = proto.Message(&nfttypes.QueryOwnerResponse{}) + respType = proto.Message(&nfttypes.QueryNFTsOfOwnerResponse{}) bz, err = nfttestutil.QueryOwnerExec(val.ClientCtx, from.String()) s.Require().NoError(err) s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(bz.Bytes(), respType)) - ownerResp := respType.(*nfttypes.QueryOwnerResponse) + ownerResp := respType.(*nfttypes.QueryNFTsOfOwnerResponse) s.Require().Equal(from.String(), ownerResp.Owner.Address) s.Require().Equal(denom, ownerResp.Owner.IDCollections[0].DenomId) s.Require().Equal(tokenID, ownerResp.Owner.IDCollections[0].TokenIds[0]) diff --git a/modules/nft/client/cli/query.go b/modules/nft/client/cli/query.go index f2a44c22..d7627c73 100644 --- a/modules/nft/client/cli/query.go +++ b/modules/nft/client/cli/query.go @@ -102,7 +102,7 @@ func GetCmdQueryOwner() *cobra.Command { return err } queryClient := types.NewQueryClient(clientCtx) - resp, err := queryClient.Owner(context.Background(), &types.QueryOwnerRequest{ + resp, err := queryClient.NFTsOfOwner(context.Background(), &types.QueryNFTsOfOwnerRequest{ DenomId: denomID, Owner: args[0], Pagination: pageReq, diff --git a/modules/nft/client/cli/tx.go b/modules/nft/client/cli/tx.go index 70d7bd54..1e3a2c26 100644 --- a/modules/nft/client/cli/tx.go +++ b/modules/nft/client/cli/tx.go @@ -38,7 +38,7 @@ func NewTxCmd() *cobra.Command { return txCmd } -// GetCmdIssueDenom is the CLI command for an IssueDenom transaction +// GetCmdIssueDenom is the CLI command for an SaveDenom transaction func GetCmdIssueDenom() *cobra.Command { cmd := &cobra.Command{ Use: "issue [denom-id]", @@ -134,7 +134,7 @@ func GetCmdIssueDenom() *cobra.Command { return cmd } -// GetCmdMintNFT is the CLI command for a MintNFT transaction +// GetCmdMintNFT is the CLI command for a SaveNFT transaction func GetCmdMintNFT() *cobra.Command { cmd := &cobra.Command{ Use: "mint [denom-id] [nft-id]", @@ -332,7 +332,7 @@ func GetCmdTransferNFT() *cobra.Command { return cmd } -// GetCmdBurnNFT is the CLI command for sending a BurnNFT transaction +// GetCmdBurnNFT is the CLI command for sending a RemoveNFT transaction func GetCmdBurnNFT() *cobra.Command { cmd := &cobra.Command{ Use: "burn [denom-id] [nft-id]", diff --git a/modules/nft/client/rest/query.go b/modules/nft/client/rest/query.go deleted file mode 100644 index 01a7727e..00000000 --- a/modules/nft/client/rest/query.go +++ /dev/null @@ -1,234 +0,0 @@ -package rest - -import ( - "encoding/binary" - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/nft/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router, queryRoute string) { - // Get the total supply of a collection or owner - r.HandleFunc(fmt.Sprintf("/%s/collections/{%s}/supply", types.ModuleName, RestParamDenomID), querySupply(cliCtx, queryRoute)).Methods("GET") - // Get the collections of NFTs owned by an address - r.HandleFunc(fmt.Sprintf("/%s/owners/{%s}", types.ModuleName, RestParamOwner), queryOwner(cliCtx, queryRoute)).Methods("GET") - // Get all the NFTs from a given collection - r.HandleFunc(fmt.Sprintf("/%s/collections/{%s}", types.ModuleName, RestParamDenomID), queryCollection(cliCtx, queryRoute)).Methods("GET") - // Query all denoms - r.HandleFunc(fmt.Sprintf("/%s/denoms", types.ModuleName), queryDenoms(cliCtx, queryRoute)).Methods("GET") - // Query the denom - r.HandleFunc(fmt.Sprintf("/%s/denoms/{%s}", types.ModuleName, RestParamDenomID), queryDenom(cliCtx, queryRoute)).Methods("GET") - // Query a single NFT - r.HandleFunc(fmt.Sprintf("/%s/nfts/{%s}/{%s}", types.ModuleName, RestParamDenomID, RestParamTokenID), queryNFT(cliCtx, queryRoute)).Methods("GET") -} - -func querySupply(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - denomID := mux.Vars(r)[RestParamDenomID] - err := types.ValidateDenomID(denomID) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - var owner sdk.AccAddress - ownerStr := r.FormValue(RestParamOwner) - if len(ownerStr) > 0 { - owner, err = sdk.AccAddressFromBech32(ownerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - params := types.NewQuerySupplyParams(denomID, owner) - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QuerySupply), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - out := binary.LittleEndian.Uint64(res) - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, out) - } -} - -func queryOwner(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - ownerStr := mux.Vars(r)[RestParamOwner] - if len(ownerStr) == 0 { - rest.WriteErrorResponse(w, http.StatusBadRequest, "param owner should not be empty") - } - - address, err := sdk.AccAddressFromBech32(ownerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - denomID := r.FormValue(RestParamDenomID) - params := types.NewQueryOwnerParams(denomID, address) - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryOwner), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryCollection(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - denomID := mux.Vars(r)[RestParamDenomID] - if err := types.ValidateDenomID(denomID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - - params := types.NewQueryCollectionParams(denomID) - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryCollection), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryDenom(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - denomID := mux.Vars(r)[RestParamDenomID] - if err := types.ValidateDenomID(denomID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - - params := types.NewQueryDenomParams(denomID) - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDenom), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryDenoms(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryDenoms), nil, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryNFT(cliCtx client.Context, queryRoute string) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - denomID := vars[RestParamDenomID] - if err := types.ValidateDenomID(denomID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - - tokenID := vars[RestParamTokenID] - if err := types.ValidateTokenID(tokenID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - - params := types.NewQueryNFTParams(denomID, tokenID) - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", queryRoute, types.QueryNFT), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/nft/client/rest/rest.go b/modules/nft/client/rest/rest.go deleted file mode 100644 index 45d6f05c..00000000 --- a/modules/nft/client/rest/rest.go +++ /dev/null @@ -1,71 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// RegisterHandlers registers the NFT REST routes. -func RegisterHandlers(cliCtx client.Context, r *mux.Router, queryRoute string) { - registerQueryRoutes(cliCtx, r, queryRoute) - registerTxRoutes(cliCtx, r, queryRoute) -} - -const ( - RestParamDenomID = "denom-id" - RestParamTokenID = "token-id" - RestParamOwner = "owner" -) - -type issueDenomReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` - ID string `json:"id"` - Name string `json:"name"` - Schema string `json:"schema"` - Symbol string `json:"symbol"` - MintRestricted bool `json:"mint_restricted"` - UpdateRestricted bool `json:"update_restricted"` - Description string `json:"description"` - Uri string `json:"uri"` - UriHash string `json:"uri_hash"` - Data string `json:"data"` -} - -type mintNFTReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` - Recipient string `json:"recipient"` - DenomID string `json:"denom_id"` - ID string `json:"id"` - Name string `json:"name"` - URI string `json:"uri"` - UriHash string `json:"uri_hash"` - Data string `json:"data"` -} - -type editNFTReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` - Name string `json:"name"` - URI string `json:"uri"` - UriHash string `json:"uri_hash"` - Data string `json:"data"` -} - -type transferNFTReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` - Recipient string `json:"recipient"` - Name string `json:"name"` - URI string `json:"uri"` - UriHash string `json:"uri_hash"` - Data string `json:"data"` -} - -type burnNFTReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` -} diff --git a/modules/nft/client/rest/tx.go b/modules/nft/client/rest/tx.go deleted file mode 100644 index 2dc99d7a..00000000 --- a/modules/nft/client/rest/tx.go +++ /dev/null @@ -1,181 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/nft/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router, queryRoute string) { - // Issue a denom - r.HandleFunc("/nft/nfts/denoms/issue", issueDenomHandlerFn(cliCtx)).Methods("POST") - // Mint an NFT - r.HandleFunc("/nft/nfts/mint", mintNFTHandlerFn(cliCtx)).Methods("POST") - // Update an NFT - r.HandleFunc(fmt.Sprintf("/nft/nfts/{%s}/{%s}", RestParamDenomID, RestParamTokenID), editNFTHandlerFn(cliCtx)).Methods("PUT") - // Transfer an NFT to an address - r.HandleFunc(fmt.Sprintf("/nft/nfts/{%s}/{%s}/transfer", RestParamDenomID, RestParamTokenID), transferNFTHandlerFn(cliCtx)).Methods("POST") - // Burn an NFT - r.HandleFunc(fmt.Sprintf("/nft/nfts/{%s}/{%s}/burn", RestParamDenomID, RestParamTokenID), burnNFTHandlerFn(cliCtx)).Methods("POST") -} - -func issueDenomHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req issueDenomReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") - return - } - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - // create the message - msg := types.NewMsgIssueDenom(req.ID, req.Name, req.Schema, req.Owner, req.Symbol, - req.MintRestricted, req.UpdateRestricted, - req.Description, req.Uri, req.UriHash, req.Data, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func mintNFTHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req mintNFTReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") - return - } - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - if req.Recipient == "" { - req.Recipient = req.Owner - } - // create the message - msg := types.NewMsgMintNFT( - req.ID, - req.DenomID, - req.Name, - req.URI, - req.UriHash, - req.Data, - req.Owner, - req.Recipient, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func editNFTHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req editNFTReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") - return - } - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - vars := mux.Vars(r) - // create the message - msg := types.NewMsgEditNFT( - vars[RestParamTokenID], - vars[RestParamDenomID], - req.Name, - req.URI, - req.UriHash, - req.Data, req.Owner, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func transferNFTHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req transferNFTReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") - return - } - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - if _, err := sdk.AccAddressFromBech32(req.Recipient); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - vars := mux.Vars(r) - // create the message - msg := types.NewMsgTransferNFT( - vars[RestParamTokenID], - vars[RestParamDenomID], - req.Name, - req.URI, - req.UriHash, - req.Data, - req.Owner, - req.Recipient, - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func burnNFTHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req burnNFTReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - rest.WriteErrorResponse(w, http.StatusBadRequest, "failed to parse request") - return - } - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - vars := mux.Vars(r) - - // create the message - msg := types.NewMsgBurnNFT( - req.Owner, - vars[RestParamTokenID], - vars[RestParamDenomID], - ) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/nft/client/rest/grpc_query_test.go b/modules/nft/client/testutil/grpc_query_test.go similarity index 96% rename from modules/nft/client/rest/grpc_query_test.go rename to modules/nft/client/testutil/grpc_query_test.go index 706c3267..7c3df7d8 100644 --- a/modules/nft/client/rest/grpc_query_test.go +++ b/modules/nft/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "fmt" @@ -12,8 +12,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" nftcli "github.com/irisnet/irismod/modules/nft/client/cli" nfttestutil "github.com/irisnet/irismod/modules/nft/client/testutil" @@ -35,9 +35,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 2 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -173,10 +176,10 @@ func (s *IntegrationTestSuite) TestNft() { //------test GetCmdQueryOwner()------------- url = fmt.Sprintf("%s/irismod/nft/nfts?owner=%s", baseURL, from.String()) resp, err = rest.GetRequest(url) - respType = proto.Message(&nfttypes.QueryOwnerResponse{}) + respType = proto.Message(&nfttypes.QueryNFTsOfOwnerResponse{}) s.Require().NoError(err) s.Require().NoError(val.ClientCtx.Codec.UnmarshalJSON(resp, respType)) - ownerResp := respType.(*nfttypes.QueryOwnerResponse) + ownerResp := respType.(*nfttypes.QueryNFTsOfOwnerResponse) s.Require().Equal(from.String(), ownerResp.Owner.Address) s.Require().Equal(denom, ownerResp.Owner.IDCollections[0].DenomId) s.Require().Equal(tokenID, ownerResp.Owner.IDCollections[0].TokenIds[0]) diff --git a/modules/nft/genesis.go b/modules/nft/genesis.go deleted file mode 100644 index c4e50ff1..00000000 --- a/modules/nft/genesis.go +++ /dev/null @@ -1,34 +0,0 @@ -package nft - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/irisnet/irismod/modules/nft/keeper" - "github.com/irisnet/irismod/modules/nft/types" -) - -// InitGenesis stores the NFT genesis. -func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { - if err := types.ValidateGenesis(data); err != nil { - panic(err.Error()) - } - - for _, c := range data.Collections { - if err := k.SetDenom(ctx, c.Denom); err != nil { - panic(err) - } - if err := k.SetCollection(ctx, c); err != nil { - panic(err) - } - } -} - -// ExportGenesis returns a GenesisState for a given context and keeper. -func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { - return types.NewGenesisState(k.GetCollections(ctx)) -} - -// DefaultGenesisState returns a default genesis state -func DefaultGenesisState() *types.GenesisState { - return types.NewGenesisState([]types.Collection{}) -} diff --git a/modules/nft/handler.go b/modules/nft/handler.go deleted file mode 100644 index d5c9c408..00000000 --- a/modules/nft/handler.go +++ /dev/null @@ -1,47 +0,0 @@ -package nft - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/irisnet/irismod/modules/nft/keeper" - "github.com/irisnet/irismod/modules/nft/types" -) - -// NewHandler routes the messages to the handlers -func NewHandler(k keeper.Keeper) sdk.Handler { - msgServer := keeper.NewMsgServerImpl(k) - - return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { - ctx = ctx.WithEventManager(sdk.NewEventManager()) - - switch msg := msg.(type) { - case *types.MsgIssueDenom: - res, err := msgServer.IssueDenom(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgMintNFT: - res, err := msgServer.MintNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgTransferNFT: - res, err := msgServer.TransferNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgEditNFT: - res, err := msgServer.EditNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgBurnNFT: - res, err := msgServer.BurnNFT(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - case *types.MsgTransferDenom: - res, err := msgServer.TransferDenom(sdk.WrapSDKContext(ctx), msg) - return sdk.WrapServiceResult(ctx, res, err) - - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized nft message type: %T", msg) - } - } -} diff --git a/modules/nft/keeper/collection.go b/modules/nft/keeper/collection.go index 486e2e17..9736cc84 100644 --- a/modules/nft/keeper/collection.go +++ b/modules/nft/keeper/collection.go @@ -1,22 +1,15 @@ package keeper import ( - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/irisnet/irismod/modules/nft/exported" "github.com/irisnet/irismod/modules/nft/types" ) -// SetCollection saves all NFTs and returns an error if there already exists -func (k Keeper) SetCollection(ctx sdk.Context, collection types.Collection) error { +// SaveCollection saves all NFTs and returns an error if there already exists +func (k Keeper) SaveCollection(ctx sdk.Context, collection types.Collection) error { for _, nft := range collection.NFTs { - if err := k.MintNFT( + if err := k.SaveNFT( ctx, collection.Denom.Id, nft.GetID(), @@ -32,87 +25,30 @@ func (k Keeper) SetCollection(ctx sdk.Context, collection types.Collection) erro return nil } -// GetCollection returns the collection by the specified denom ID -func (k Keeper) GetCollection(ctx sdk.Context, denomID string) (types.Collection, error) { - denom, found := k.GetDenom(ctx, denomID) - if !found { - return types.Collection{}, sdkerrors.Wrapf(types.ErrInvalidDenom, "denomID %s not existed ", denomID) - } - - nfts := k.GetNFTs(ctx, denomID) - return types.NewCollection(denom, nfts), nil -} - -// GetPaginateCollection returns the collection by the specified denom ID -func (k Keeper) GetPaginateCollection(ctx sdk.Context, request *types.QueryCollectionRequest, denomID string) (types.Collection, *query.PageResponse, error) { - denom, found := k.GetDenom(ctx, denomID) - if !found { - return types.Collection{}, nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denomID %s not existed ", denomID) - } - var nfts []exported.NFT - store := ctx.KVStore(k.storeKey) - nftStore := prefix.NewStore(store, types.KeyNFT(denomID, "")) - pageRes, err := query.Paginate(nftStore, shapePageRequest(request.Pagination), func(key []byte, value []byte) error { - var baseNFT types.BaseNFT - k.cdc.MustUnmarshal(value, &baseNFT) - nfts = append(nfts, baseNFT) - return nil - }) - if err != nil { - return types.Collection{}, nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) - } - return types.NewCollection(denom, nfts), pageRes, nil -} - // GetCollections returns all the collections -func (k Keeper) GetCollections(ctx sdk.Context) (cs []types.Collection) { - for _, denom := range k.GetDenoms(ctx) { - nfts := k.GetNFTs(ctx, denom.Id) - cs = append(cs, types.NewCollection(denom, nfts)) - } - return cs -} +func (k Keeper) GetCollections(ctx sdk.Context) (cs []types.Collection, err error) { + for _, class := range k.nk.GetClasses(ctx) { + nfts, err := k.GetNFTs(ctx, class.Id) + if err != nil { + return nil, err + } -// GetDenomSupply returns the number of NFTs by the specified denom ID -func (k Keeper) GetTotalSupply(ctx sdk.Context, denomID string) uint64 { - store := ctx.KVStore(k.storeKey) - bz := store.Get(types.KeyCollection(denomID)) - if len(bz) == 0 { - return 0 - } - return types.MustUnMarshalSupply(k.cdc, bz) -} + denom, err := k.GetDenomInfo(ctx, class.Id) + if err != nil { + return nil, err + } -// GetTotalSupplyOfOwner returns the amount of NFTs by the specified conditions -func (k Keeper) GetTotalSupplyOfOwner(ctx sdk.Context, id string, owner sdk.AccAddress) (supply uint64) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyOwner(owner, id, "")) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - supply++ + cs = append(cs, types.NewCollection(*denom, nfts)) } - return supply + return cs, nil } -func (k Keeper) increaseSupply(ctx sdk.Context, denomID string) { - supply := k.GetTotalSupply(ctx, denomID) - supply++ - - store := ctx.KVStore(k.storeKey) - bz := types.MustMarshalSupply(k.cdc, supply) - store.Set(types.KeyCollection(denomID), bz) +// GetTotalSupply returns the number of NFTs by the specified denom ID +func (k Keeper) GetTotalSupply(ctx sdk.Context, denomID string) uint64 { + return k.nk.GetTotalSupply(ctx, denomID) } -func (k Keeper) decreaseSupply(ctx sdk.Context, denomID string) { - supply := k.GetTotalSupply(ctx, denomID) - supply-- - - store := ctx.KVStore(k.storeKey) - if supply == 0 { - store.Delete(types.KeyCollection(denomID)) - return - } - - bz := types.MustMarshalSupply(k.cdc, supply) - store.Set(types.KeyCollection(denomID), bz) +// GetBalance returns the amount of NFTs by the specified conditions +func (k Keeper) GetBalance(ctx sdk.Context, id string, owner sdk.AccAddress) (supply uint64) { + return k.nk.GetBalance(ctx, id, owner) } diff --git a/modules/nft/keeper/collection_test.go b/modules/nft/keeper/collection_test.go index de2ca5e0..3a3a1662 100644 --- a/modules/nft/keeper/collection_test.go +++ b/modules/nft/keeper/collection_test.go @@ -25,35 +25,17 @@ func (suite *KeeperSuite) TestSetCollection() { NFTs: []types.BaseNFT{nft2, nft}, } - err := suite.keeper.SetCollection(suite.ctx, collection2) + err := suite.keeper.SaveCollection(suite.ctx, collection2) suite.Nil(err) - collection2, err = suite.keeper.GetCollection(suite.ctx, denomID) - suite.NoError(err) - suite.Len(collection2.NFTs, 2) - - msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx) - suite.False(fail, msg) -} - -func (suite *KeeperSuite) TestGetCollection() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - // collection should exist - collection, err := suite.keeper.GetCollection(suite.ctx, denomID) - suite.NoError(err) - suite.NotEmpty(collection) - msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx) suite.False(fail, msg) } func (suite *KeeperSuite) TestGetCollections() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx) @@ -61,16 +43,16 @@ func (suite *KeeperSuite) TestGetCollections() { } func (suite *KeeperSuite) TestGetSupply() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - // MintNFT shouldn't fail when collection does not exist - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) + // SaveNFT shouldn't fail when collection does not exist + err = suite.keeper.SaveNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) suite.NoError(err) - // MintNFT shouldn't fail when collection does not exist - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) + // SaveNFT shouldn't fail when collection does not exist + err = suite.keeper.SaveNFT(suite.ctx, denomID2, tokenID, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) suite.NoError(err) supply := suite.keeper.GetTotalSupply(suite.ctx, denomID) @@ -79,10 +61,10 @@ func (suite *KeeperSuite) TestGetSupply() { supply = suite.keeper.GetTotalSupply(suite.ctx, denomID2) suite.Equal(uint64(1), supply) - supply = suite.keeper.GetTotalSupplyOfOwner(suite.ctx, denomID, address) + supply = suite.keeper.GetBalance(suite.ctx, denomID, address) suite.Equal(uint64(1), supply) - supply = suite.keeper.GetTotalSupplyOfOwner(suite.ctx, denomID, address2) + supply = suite.keeper.GetBalance(suite.ctx, denomID, address2) suite.Equal(uint64(1), supply) supply = suite.keeper.GetTotalSupply(suite.ctx, denomID) @@ -92,7 +74,7 @@ func (suite *KeeperSuite) TestGetSupply() { suite.Equal(uint64(1), supply) //burn nft - err = suite.keeper.BurnNFT(suite.ctx, denomID, tokenID, address) + err = suite.keeper.RemoveNFT(suite.ctx, denomID, tokenID, address) suite.NoError(err) supply = suite.keeper.GetTotalSupply(suite.ctx, denomID) @@ -102,7 +84,7 @@ func (suite *KeeperSuite) TestGetSupply() { suite.Equal(uint64(1), supply) //burn nft - err = suite.keeper.BurnNFT(suite.ctx, denomID, tokenID2, address2) + err = suite.keeper.RemoveNFT(suite.ctx, denomID, tokenID2, address2) suite.NoError(err) supply = suite.keeper.GetTotalSupply(suite.ctx, denomID) diff --git a/modules/nft/keeper/denom.go b/modules/nft/keeper/denom.go index 2a95dba5..cf9987c0 100644 --- a/modules/nft/keeper/denom.go +++ b/modules/nft/keeper/denom.go @@ -1,66 +1,118 @@ package keeper import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/nft" "github.com/irisnet/irismod/modules/nft/types" ) -// HasDenom returns whether the specified denom ID exists -func (k Keeper) HasDenomID(ctx sdk.Context, id string) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.KeyDenomID(id)) +// SaveDenom issues a denom according to the given params +func (k Keeper) SaveDenom(ctx sdk.Context, id, + name, + schema, + symbol string, + creator sdk.AccAddress, + mintRestricted, + updateRestricted bool, + description, + uri, + uriHash, + data string, +) error { + denomMetadata := &types.DenomMetadata{ + Creator: creator.String(), + Schema: schema, + MintRestricted: mintRestricted, + UpdateRestricted: updateRestricted, + Data: data, + } + metadata, err := codectypes.NewAnyWithValue(denomMetadata) + if err != nil { + return err + } + return k.nk.SaveClass(ctx, nft.Class{ + Id: id, + Name: name, + Symbol: symbol, + Description: description, + Uri: uri, + UriHash: uriHash, + Data: metadata, + }) } -// SetDenom is responsible for saving the definition of denom -func (k Keeper) SetDenom(ctx sdk.Context, denom types.Denom) error { - if k.HasDenomID(ctx, denom.Id) { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denomID %s has already exists", denom.Id) +// TransferDenomOwner transfers the ownership of the given denom to the new owner +func (k Keeper) TransferDenomOwner( + ctx sdk.Context, + denomID string, + srcOwner, + dstOwner sdk.AccAddress, +) error { + denom, err := k.GetDenomInfo(ctx, denomID) + if err != nil { + return err } - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&denom) - store.Set(types.KeyDenomID(denom.Id), bz) - store.Set(types.KeyDenomName(denom.Name), []byte(denom.Id)) - return nil -} + // authorize + if srcOwner.String() != denom.Creator { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to transfer denom %s", srcOwner.String(), denomID) + } -// GetDenom returns the denom by id -func (k Keeper) GetDenom(ctx sdk.Context, id string) (denom types.Denom, found bool) { - store := ctx.KVStore(k.storeKey) + denomMetadata := &types.DenomMetadata{ + Creator: dstOwner.String(), + Schema: denom.Schema, + MintRestricted: denom.MintRestricted, + UpdateRestricted: denom.UpdateRestricted, + Data: denom.Data, + } + data, err := codectypes.NewAnyWithValue(denomMetadata) + if err != nil { + return err + } + class := nft.Class{ + Id: denom.Id, + Name: denom.Name, + Symbol: denom.Symbol, + Data: data, - bz := store.Get(types.KeyDenomID(id)) - if len(bz) == 0 { - return denom, false + Description: denom.Description, + Uri: denom.Uri, + UriHash: denom.UriHash, } - k.cdc.MustUnmarshal(bz, &denom) - return denom, true + return k.nk.UpdateClass(ctx, class) } -// GetDenoms returns all the denoms -func (k Keeper) GetDenoms(ctx sdk.Context) (denoms []types.Denom) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyDenomID("")) - defer iterator.Close() - - for ; iterator.Valid(); iterator.Next() { - var denom types.Denom - k.cdc.MustUnmarshal(iterator.Value(), &denom) - denoms = append(denoms, denom) +// GetDenomInfo return the denom information +func (k Keeper) GetDenomInfo(ctx sdk.Context, denomID string) (*types.Denom, error) { + class, has := k.nk.GetClass(ctx, denomID) + if !has { + return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", denomID) } - return denoms -} -// UpdateDenom is responsible for updating the definition of denom -func (k Keeper) UpdateDenom(ctx sdk.Context, denom types.Denom) error { - if !k.HasDenomID(ctx, denom.Id) { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denomID %s not exists", denom.Id) + var denomMetadata types.DenomMetadata + if err := k.cdc.Unmarshal(class.Data.GetValue(), &denomMetadata); err != nil { + return nil, err } + return &types.Denom{ + Id: class.Id, + Name: class.Name, + Schema: denomMetadata.Schema, + Creator: denomMetadata.Creator, + Symbol: class.Symbol, + MintRestricted: denomMetadata.MintRestricted, + UpdateRestricted: denomMetadata.UpdateRestricted, + Description: class.Description, + Uri: class.Uri, + UriHash: class.UriHash, + Data: denomMetadata.Data, + }, nil +} - store := ctx.KVStore(k.storeKey) - bz := k.cdc.MustMarshal(&denom) - store.Set(types.KeyDenomID(denom.Id), bz) - return nil +// HasDenom determine whether denom exists +func (k Keeper) HasDenom(ctx sdk.Context, denomID string) bool { + return k.nk.HasClass(ctx, denomID) } diff --git a/modules/nft/keeper/genesis.go b/modules/nft/keeper/genesis.go new file mode 100644 index 00000000..8ca2f88a --- /dev/null +++ b/modules/nft/keeper/genesis.go @@ -0,0 +1,49 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/irisnet/irismod/modules/nft/types" +) + +// InitGenesis stores the NFT genesis. +func (k Keeper) InitGenesis(ctx sdk.Context, data types.GenesisState) { + if err := types.ValidateGenesis(data); err != nil { + panic(err.Error()) + } + + for _, c := range data.Collections { + creator, err := sdk.AccAddressFromBech32(c.Denom.Creator) + if err != nil { + panic(err) + } + if err := k.SaveDenom(ctx, + c.Denom.Id, + c.Denom.Name, + c.Denom.Schema, + c.Denom.Symbol, + creator, + c.Denom.MintRestricted, + c.Denom.UpdateRestricted, + c.Denom.Description, + c.Denom.Uri, + c.Denom.UriHash, + c.Denom.Data, + ); err != nil { + panic(err) + } + + if err := k.SaveCollection(ctx, c); err != nil { + panic(err) + } + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState { + collections, err := k.GetCollections(ctx) + if err != nil { + panic(err) + } + return types.NewGenesisState(collections) +} diff --git a/modules/nft/keeper/grpc_query.go b/modules/nft/keeper/grpc_query.go index cfc72995..dbcb8701 100644 --- a/modules/nft/keeper/grpc_query.go +++ b/modules/nft/keeper/grpc_query.go @@ -6,16 +6,16 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/cosmos/cosmos-sdk/store/prefix" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/cosmos/cosmos-sdk/types/query" + "github.com/cosmos/cosmos-sdk/x/nft" "github.com/irisnet/irismod/modules/nft/types" ) var _ types.QueryServer = Keeper{} +// Supply queries the total supply of a given denom or owner func (k Keeper) Supply(c context.Context, request *types.QuerySupplyRequest) (*types.QuerySupplyResponse, error) { ctx := sdk.UnwrapSDKContext(c) @@ -28,95 +28,140 @@ func (k Keeper) Supply(c context.Context, request *types.QuerySupplyRequest) (*t if err != nil { return nil, status.Errorf(codes.InvalidArgument, "invalid owner address %s", request.Owner) } - supply = k.GetTotalSupplyOfOwner(ctx, request.DenomId, owner) + supply = k.GetBalance(ctx, request.DenomId, owner) } return &types.QuerySupplyResponse{Amount: supply}, nil } -func (k Keeper) Owner(c context.Context, request *types.QueryOwnerRequest) (*types.QueryOwnerResponse, error) { - ctx := sdk.UnwrapSDKContext(c) +// NFTsOfOwner queries the NFTs of the specified owner +func (k Keeper) NFTsOfOwner(c context.Context, request *types.QueryNFTsOfOwnerRequest) (*types.QueryNFTsOfOwnerResponse, error) { + r := &nft.QueryNFTsRequest{ + ClassId: request.DenomId, + Owner: request.Owner, + Pagination: shapePageRequest(request.Pagination), + } - ownerAddress, err := sdk.AccAddressFromBech32(request.Owner) + result, err := k.nk.NFTs(c, r) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "invalid owner address %s", request.Owner) + return nil, err } - owner := types.Owner{ - Address: ownerAddress.String(), - IDCollections: types.IDCollections{}, - } - idsMap := make(map[string][]string) - store := ctx.KVStore(k.storeKey) - nftStore := prefix.NewStore(store, types.KeyOwner(ownerAddress, request.DenomId, "")) - pageRes, err := query.Paginate(nftStore, shapePageRequest(request.Pagination), func(key []byte, value []byte) error { - denomID := request.DenomId - tokenID := string(key) - if len(request.DenomId) == 0 { - denomID, tokenID, _ = types.SplitKeyDenom(key) - } - if ids, ok := idsMap[denomID]; ok { - idsMap[denomID] = append(ids, tokenID) - } else { - idsMap[denomID] = []string{tokenID} - owner.IDCollections = append( - owner.IDCollections, - types.IDCollection{DenomId: denomID}, - ) + var denomMap = make(map[string][]string) + var denoms []string + for _, token := range result.Nfts { + if denomMap[token.ClassId] == nil { + denomMap[token.ClassId] = []string{} + denoms = append(denoms, token.ClassId) } - return nil - }) - if err != nil { - return nil, err + denomMap[token.ClassId] = append(denomMap[token.ClassId], token.Id) } - for i := 0; i < len(owner.IDCollections); i++ { - owner.IDCollections[i].TokenIds = idsMap[owner.IDCollections[i].DenomId] + + var idc []types.IDCollection + for _, denomID := range denoms { + idc = append(idc, types.IDCollection{ + DenomId: denomID, + TokenIds: denomMap[denomID], + }) } - return &types.QueryOwnerResponse{Owner: &owner, Pagination: pageRes}, nil + + response := &types.QueryNFTsOfOwnerResponse{ + Owner: &types.Owner{ + Address: request.Owner, + IDCollections: idc, + }, + Pagination: result.Pagination, + } + + return response, nil } +// Collection queries the NFTs of the specified denom func (k Keeper) Collection(c context.Context, request *types.QueryCollectionRequest) (*types.QueryCollectionResponse, error) { ctx := sdk.UnwrapSDKContext(c) + denom, err := k.GetDenomInfo(ctx, request.DenomId) + if err != nil { + return nil, err + } - collection, pageRes, err := k.GetPaginateCollection(ctx, request, request.DenomId) + r := &nft.QueryNFTsRequest{ + ClassId: request.DenomId, + Pagination: shapePageRequest(request.Pagination), + } + + result, err := k.nk.NFTs(c, r) if err != nil { return nil, err } - return &types.QueryCollectionResponse{Collection: &collection, Pagination: pageRes}, nil + + var nfts []types.BaseNFT + for _, token := range result.Nfts { + owner := k.nk.GetOwner(ctx, request.DenomId, token.Id) + + var nftMetadata types.NFTMetadata + if err := k.cdc.Unmarshal(token.Data.GetValue(), &nftMetadata); err != nil { + return nil, err + } + + nfts = append(nfts, types.BaseNFT{ + Id: token.Id, + URI: token.Uri, + UriHash: token.UriHash, + Name: nftMetadata.Name, + Owner: owner.String(), + Data: nftMetadata.Data, + }) + } + + collection := &types.Collection{ + Denom: *denom, + NFTs: nfts, + } + + response := &types.QueryCollectionResponse{ + Collection: collection, + Pagination: result.Pagination, + } + + return response, nil } +// Denom queries the definition of a given denom func (k Keeper) Denom(c context.Context, request *types.QueryDenomRequest) (*types.QueryDenomResponse, error) { ctx := sdk.UnwrapSDKContext(c) - - denomObject, found := k.GetDenom(ctx, request.DenomId) - if !found { - return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", request.DenomId) + denom, err := k.GetDenomInfo(ctx, request.DenomId) + if err != nil { + return nil, err } - - return &types.QueryDenomResponse{Denom: &denomObject}, nil + return &types.QueryDenomResponse{Denom: denom}, nil } +// Denoms queries all the denoms func (k Keeper) Denoms(c context.Context, req *types.QueryDenomsRequest) (*types.QueryDenomsResponse, error) { ctx := sdk.UnwrapSDKContext(c) - var denoms []types.Denom - store := ctx.KVStore(k.storeKey) - denomStore := prefix.NewStore(store, types.KeyDenomID("")) - pageRes, err := query.Paginate(denomStore, shapePageRequest(req.Pagination), func(key []byte, value []byte) error { - var denom types.Denom - k.cdc.MustUnmarshal(value, &denom) - denoms = append(denoms, denom) - return nil + result, err := k.nk.Classes(c, &nft.QueryClassesRequest{ + Pagination: shapePageRequest(req.Pagination), }) if err != nil { - return nil, status.Errorf(codes.InvalidArgument, "paginate: %v", err) + return nil, err + } + + var denoms []types.Denom + for _, denom := range result.Classes { + denom, err := k.GetDenomInfo(ctx, denom.Id) + if err != nil { + return nil, err + } + denoms = append(denoms, *denom) } return &types.QueryDenomsResponse{ Denoms: denoms, - Pagination: pageRes, + Pagination: result.Pagination, }, nil } +// NFT queries the NFT for the given denom and token ID func (k Keeper) NFT(c context.Context, request *types.QueryNFTRequest) (*types.QueryNFTResponse, error) { ctx := sdk.UnwrapSDKContext(c) diff --git a/modules/nft/keeper/grpc_query_test.go b/modules/nft/keeper/grpc_query_test.go index f9bb549f..682b97ec 100644 --- a/modules/nft/keeper/grpc_query_test.go +++ b/modules/nft/keeper/grpc_query_test.go @@ -7,7 +7,7 @@ import ( ) func (suite *KeeperSuite) TestSupply() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) response, err := suite.queryClient.Supply(gocontext.Background(), &types.QuerySupplyRequest{ @@ -20,10 +20,10 @@ func (suite *KeeperSuite) TestSupply() { } func (suite *KeeperSuite) TestOwner() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - response, err := suite.queryClient.Owner(gocontext.Background(), &types.QueryOwnerRequest{ + response, err := suite.queryClient.NFTsOfOwner(gocontext.Background(), &types.QueryNFTsOfOwnerRequest{ DenomId: denomID, Owner: address.String(), }) @@ -34,7 +34,7 @@ func (suite *KeeperSuite) TestOwner() { } func (suite *KeeperSuite) TestCollection() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) response, err := suite.queryClient.Collection(gocontext.Background(), &types.QueryCollectionRequest{ @@ -48,7 +48,7 @@ func (suite *KeeperSuite) TestCollection() { } func (suite *KeeperSuite) TestDenom() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) response, err := suite.queryClient.Denom(gocontext.Background(), &types.QueryDenomRequest{ @@ -61,7 +61,7 @@ func (suite *KeeperSuite) TestDenom() { } func (suite *KeeperSuite) TestDenoms() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) response, err := suite.queryClient.Denoms(gocontext.Background(), &types.QueryDenomsRequest{}) @@ -72,7 +72,7 @@ func (suite *KeeperSuite) TestDenoms() { } func (suite *KeeperSuite) TestNFT() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) response, err := suite.queryClient.NFT(gocontext.Background(), &types.QueryNFTRequest{ diff --git a/modules/nft/keeper/invariants.go b/modules/nft/keeper/invariants.go index a00bda24..d63243b6 100644 --- a/modules/nft/keeper/invariants.go +++ b/modules/nft/keeper/invariants.go @@ -6,7 +6,6 @@ import ( "fmt" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/irisnet/irismod/modules/nft/types" ) @@ -15,13 +14,6 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) { ir.RegisterRoute(types.ModuleName, "supply", SupplyInvariant(k)) } -// AllInvariants runs all invariants of the NFT module. -func AllInvariants(k Keeper) sdk.Invariant { - return func(ctx sdk.Context) (string, bool) { - return SupplyInvariant(k)(ctx) - } -} - // SupplyInvariant checks that the total amount of NFTs on collections matches the total amount owned by addresses func SupplyInvariant(k Keeper) sdk.Invariant { return func(ctx sdk.Context) (string, bool) { @@ -29,10 +21,13 @@ func SupplyInvariant(k Keeper) sdk.Invariant { var msg string count := 0 - for _, owner := range k.GetOwners(ctx) { - for _, idCollection := range owner.IDCollections { - ownersCollectionsSupply[idCollection.DenomId] += uint64(idCollection.Supply()) - } + collections, err := k.GetCollections(ctx) + if err != nil { + panic(err) + } + + for _, collection := range collections { + ownersCollectionsSupply[collection.Denom.Id] = uint64(len(collection.NFTs)) } for denom, supply := range ownersCollectionsSupply { diff --git a/modules/nft/keeper/keeper.go b/modules/nft/keeper/keeper.go index 3bc5cb2f..6800a65a 100644 --- a/modules/nft/keeper/keeper.go +++ b/modules/nft/keeper/keeper.go @@ -8,7 +8,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/nft" + nftkeeper "github.com/cosmos/cosmos-sdk/x/nft/keeper" "github.com/irisnet/irismod/modules/nft/types" ) @@ -17,191 +18,28 @@ import ( type Keeper struct { storeKey storetypes.StoreKey // Unexposed key to access store from sdk.Context cdc codec.Codec + nk nftkeeper.Keeper } // NewKeeper creates a new instance of the NFT Keeper -func NewKeeper(cdc codec.Codec, storeKey storetypes.StoreKey) Keeper { +func NewKeeper(cdc codec.Codec, + storeKey storetypes.StoreKey, + ak nft.AccountKeeper, + bk nft.BankKeeper, +) Keeper { return Keeper{ storeKey: storeKey, cdc: cdc, + nk: nftkeeper.NewKeeper(storeKey, cdc, ak, bk), } } +// NFTkeeper returns a cosmos-sdk nftkeeper.Keeper. +func (k Keeper) NFTkeeper() nftkeeper.Keeper { + return k.nk +} + // Logger returns a module-specific logger. func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("irismod/%s", types.ModuleName)) } - -// IssueDenom issues a denom according to the given params -func (k Keeper) IssueDenom(ctx sdk.Context, - id, name, schema, symbol string, - creator sdk.AccAddress, - mintRestricted, updateRestricted bool, - description, uri, uriHash, data string, -) error { - return k.SetDenom(ctx, types.Denom{ - Id: id, - Name: name, - Schema: schema, - Creator: creator.String(), - Symbol: symbol, - MintRestricted: mintRestricted, - UpdateRestricted: updateRestricted, - Description: description, - Uri: uri, - UriHash: uriHash, - Data: data, - }) -} - -// MintNFT mints an NFT and manages the NFT's existence within Collections and Owners -func (k Keeper) MintNFT( - ctx sdk.Context, denomID, tokenID, tokenNm, - tokenURI, uriHash, tokenData string, owner sdk.AccAddress, -) error { - if k.HasNFT(ctx, denomID, tokenID) { - return sdkerrors.Wrapf(types.ErrNFTAlreadyExists, "NFT %s already exists in collection %s", tokenID, denomID) - } - - k.setNFT( - ctx, denomID, - types.NewBaseNFT( - tokenID, - tokenNm, - owner, - tokenURI, - uriHash, - tokenData, - ), - ) - k.setOwner(ctx, denomID, tokenID, owner) - k.increaseSupply(ctx, denomID) - - return nil -} - -// EditNFT updates an already existing NFT -func (k Keeper) EditNFT( - ctx sdk.Context, denomID, tokenID, tokenNm, - tokenURI, tokenURIHash, tokenData string, owner sdk.AccAddress, -) error { - denom, found := k.GetDenom(ctx, denomID) - if !found { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", denomID) - } - - if denom.UpdateRestricted { - // if true , nobody can update the NFT under this denom - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "nobody can update the NFT under this denom %s", denom.Id) - } - - // just the owner of NFT can edit - nft, err := k.Authorize(ctx, denomID, tokenID, owner) - if err != nil { - return err - } - - if types.Modified(tokenNm) { - nft.Name = tokenNm - } - - if types.Modified(tokenURI) { - nft.URI = tokenURI - } - - if types.Modified(tokenURIHash) { - nft.UriHash = tokenURIHash - } - - if types.Modified(tokenData) { - nft.Data = tokenData - } - - k.setNFT(ctx, denomID, nft) - - return nil -} - -// TransferOwner transfers the ownership of the given NFT to the new owner -func (k Keeper) TransferOwner( - ctx sdk.Context, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, - tokenData string, srcOwner, dstOwner sdk.AccAddress, -) error { - denom, found := k.GetDenom(ctx, denomID) - if !found { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", denomID) - } - - if denom.UpdateRestricted && (types.Modified(tokenNm) || - types.Modified(tokenURI) || - types.Modified(tokenData) || - types.Modified(tokenURIHash)) { - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "It is restricted to update NFT under this denom %s", denom.Id) - } - - nft, err := k.Authorize(ctx, denomID, tokenID, srcOwner) - if err != nil { - return err - } - - nft.Owner = dstOwner.String() - - if types.Modified(tokenNm) { - nft.Name = tokenNm - } - if types.Modified(tokenURI) { - nft.URI = tokenURI - } - if types.Modified(tokenURIHash) { - nft.UriHash = tokenURIHash - } - if types.Modified(tokenData) { - nft.Data = tokenData - } - - k.setNFT(ctx, denomID, nft) - k.swapOwner(ctx, denomID, tokenID, srcOwner, dstOwner) - return nil -} - -// BurnNFT deletes a specified NFT -func (k Keeper) BurnNFT(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) error { - if !k.HasDenomID(ctx, denomID) { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", denomID) - } - - nft, err := k.Authorize(ctx, denomID, tokenID, owner) - if err != nil { - return err - } - - k.deleteNFT(ctx, denomID, nft) - k.deleteOwner(ctx, denomID, tokenID, owner) - k.decreaseSupply(ctx, denomID) - - return nil -} - -// TransferDenomOwner transfers the ownership of the given denom to the new owner -func (k Keeper) TransferDenomOwner( - ctx sdk.Context, denomID string, srcOwner, dstOwner sdk.AccAddress, -) error { - denom, found := k.GetDenom(ctx, denomID) - if !found { - return sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", denomID) - } - - // authorize - if srcOwner.String() != denom.Creator { - return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to transfer denom %s", srcOwner.String(), denomID) - } - - denom.Creator = dstOwner.String() - - err := k.UpdateDenom(ctx, denom) - if err != nil { - return err - } - - return nil -} diff --git a/modules/nft/keeper/keeper_test.go b/modules/nft/keeper/keeper_test.go index 6352a5e0..2a8cae1e 100644 --- a/modules/nft/keeper/keeper_test.go +++ b/modules/nft/keeper/keeper_test.go @@ -68,7 +68,7 @@ type KeeperSuite struct { func (suite *KeeperSuite) SetupTest() { - app := simapp.Setup(isCheckTx) + app := simapp.Setup(suite.T(), isCheckTx) suite.app = app suite.legacyAmino = app.LegacyAmino() @@ -79,18 +79,19 @@ func (suite *KeeperSuite) SetupTest() { types.RegisterQueryServer(queryHelper, app.NFTKeeper) suite.queryClient = types.NewQueryClient(queryHelper) - err := suite.keeper.IssueDenom(suite.ctx, denomID, denomNm, schema, denomSymbol, address, false, false, denomDescription, denomUri, denomUriHash, denomData) + err := suite.keeper.SaveDenom(suite.ctx, denomID, denomNm, schema, denomSymbol, address, false, false, denomDescription, denomUri, denomUriHash, denomData) suite.NoError(err) - // MintNFT shouldn't fail when collection does not exist - err = suite.keeper.IssueDenom(suite.ctx, denomID2, denomNm2, schema, denomSymbol2, address, false, false, denomDescription, denomUri, denomUriHash, denomData) + // SaveNFT shouldn't fail when collection does not exist + err = suite.keeper.SaveDenom(suite.ctx, denomID2, denomNm2, schema, denomSymbol2, address, false, false, denomDescription, denomUri, denomUriHash, denomData) suite.NoError(err) - err = suite.keeper.IssueDenom(suite.ctx, denomID3, denomNm3, schema, denomSymbol3, address3, true, true, denomDescription, denomUri, denomUriHash, denomData) + err = suite.keeper.SaveDenom(suite.ctx, denomID3, denomNm3, schema, denomSymbol3, address3, true, true, denomDescription, denomUri, denomUriHash, denomData) suite.NoError(err) // collections should equal 3 - collections := suite.keeper.GetCollections(suite.ctx) + collections, err := suite.keeper.GetCollections(suite.ctx) + suite.NoError(err) suite.NotEmpty(collections) suite.Equal(len(collections), 3) } @@ -100,35 +101,35 @@ func TestKeeperSuite(t *testing.T) { } func (suite *KeeperSuite) TestMintNFT() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - // MintNFT shouldn't fail when collection exists - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection exists + err = suite.keeper.SaveNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) } func (suite *KeeperSuite) TestUpdateNFT() { - // EditNFT should fail when NFT doesn't exists - err := suite.keeper.EditNFT(suite.ctx, denomID, tokenID, tokenNm3, tokenURI, tokenURIHash, tokenData, address) + // UpdateNFT should fail when NFT doesn't exists + err := suite.keeper.UpdateNFT(suite.ctx, denomID, tokenID, tokenNm3, tokenURI, tokenURIHash, tokenData, address) suite.Error(err) - // MintNFT shouldn't fail when collection does not exist - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err = suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - // EditNFT should fail when NFT doesn't exists - err = suite.keeper.EditNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) + // UpdateNFT should fail when NFT doesn't exists + err = suite.keeper.UpdateNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) suite.Error(err) - // EditNFT shouldn't fail when NFT exists - err = suite.keeper.EditNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address) + // UpdateNFT shouldn't fail when NFT exists + err = suite.keeper.UpdateNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address) suite.NoError(err) - // EditNFT should fail when NFT failed to authorize - err = suite.keeper.EditNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address2) + // UpdateNFT should fail when NFT failed to authorize + err = suite.keeper.UpdateNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address2) suite.Error(err) // GetNFT should get the NFT with new tokenURI @@ -136,30 +137,30 @@ func (suite *KeeperSuite) TestUpdateNFT() { suite.NoError(err) suite.Equal(receivedNFT.GetURI(), tokenURI2) - // EditNFT shouldn't fail when NFT exists - err = suite.keeper.EditNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address2) + // UpdateNFT shouldn't fail when NFT exists + err = suite.keeper.UpdateNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI2, tokenURIHash2, tokenData, address2) suite.Error(err) - err = suite.keeper.MintNFT(suite.ctx, denomID3, denomID3, tokenID3, tokenURI, tokenURIHash, tokenData, address3) + err = suite.keeper.SaveNFT(suite.ctx, denomID3, denomID3, tokenID3, tokenURI, tokenURIHash, tokenData, address3) suite.NoError(err) - // EditNFT should fail if updateRestricted equal to true, nobody can update the NFT under this denom - err = suite.keeper.EditNFT(suite.ctx, denomID3, denomID3, tokenID3, tokenURI, tokenURIHash, tokenData, address3) + // UpdateNFT should fail if updateRestricted equal to true, nobody can update the NFT under this denom + err = suite.keeper.UpdateNFT(suite.ctx, denomID3, denomID3, tokenID3, tokenURI, tokenURIHash, tokenData, address3) suite.Error(err) } -func (suite *KeeperSuite) TestTransferOwner() { +func (suite *KeeperSuite) TestTransferOwnership() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) // invalid owner - err = suite.keeper.TransferOwner(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address2, address3) + err = suite.keeper.TransferOwnership(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address2, address3) suite.Error(err) // right - err = suite.keeper.TransferOwner(suite.ctx, denomID, tokenID, tokenNm2, tokenURI2, tokenURIHash2, tokenData, address, address2) + err = suite.keeper.TransferOwnership(suite.ctx, denomID, tokenID, tokenNm2, tokenURI2, tokenURIHash2, tokenData, address, address2) suite.NoError(err) nft, err := suite.keeper.GetNFT(suite.ctx, denomID, tokenID) @@ -177,19 +178,19 @@ func (suite *KeeperSuite) TestTransferDenom() { err = suite.keeper.TransferDenomOwner(suite.ctx, denomID, address, address3) suite.NoError(err) - denom, _ := suite.keeper.GetDenom(suite.ctx, denomID) + denom, _ := suite.keeper.GetDenomInfo(suite.ctx, denomID) // denom.Creator should equal to address3 after transfer suite.Equal(denom.Creator, address3.String()) } func (suite *KeeperSuite) TestBurnNFT() { - // MintNFT should not fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT should not fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - // BurnNFT should fail when NFT doesn't exist but collection does exist - err = suite.keeper.BurnNFT(suite.ctx, denomID, tokenID, address) + // RemoveNFT should fail when NFT doesn't exist but collection does exist + err = suite.keeper.RemoveNFT(suite.ctx, denomID, tokenID, address) suite.NoError(err) // NFT should no longer exist @@ -211,7 +212,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string buffer.WriteString(numString) //adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) bech := res.String() addresses = append(addresses, testAddr(buffer.String(), bech)) buffer.Reset() @@ -222,7 +223,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { // for incode address generation func testAddr(addr string, bech string) sdk.AccAddress { - res, err := sdk.AccAddressFromHex(addr) + res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { panic(err) } diff --git a/modules/nft/keeper/legacy_keeper.go b/modules/nft/keeper/legacy_keeper.go index 4399bab9..f130aa2b 100644 --- a/modules/nft/keeper/legacy_keeper.go +++ b/modules/nft/keeper/legacy_keeper.go @@ -15,27 +15,78 @@ func NewLegacyKeeper(nk Keeper) LegacyKeeper { return LegacyKeeper{nk} } -func (n LegacyKeeper) IssueDenom(ctx sdk.Context, - id, name, schema, symbol string, +func (n LegacyKeeper) IssueDenom( + ctx sdk.Context, + id, + name, + schema, + symbol string, creator sdk.AccAddress, - mintRestricted, updateRestricted bool) error { - return n.nk.IssueDenom(ctx, id, name, schema, symbol, creator, mintRestricted, updateRestricted, types.DoNotModify, types.DoNotModify, types.DoNotModify, types.DoNotModify) + mintRestricted, + updateRestricted bool, +) error { + return n.nk.SaveDenom( + ctx, + id, + name, + schema, + symbol, + creator, + mintRestricted, + updateRestricted, + types.DoNotModify, + types.DoNotModify, + types.DoNotModify, + types.DoNotModify, + ) } -func (n LegacyKeeper) MintNFT(ctx sdk.Context, - denomID, tokenID, tokenNm, tokenURI, tokenData string, - owner sdk.AccAddress) error { - return n.nk.MintNFT(ctx, denomID, tokenID, tokenNm, tokenURI, "", tokenData, owner) +func (n LegacyKeeper) MintNFT( + ctx sdk.Context, + denomID, + tokenID, + tokenNm, + tokenURI, + tokenData string, + owner sdk.AccAddress, +) error { + return n.nk.SaveNFT( + ctx, + denomID, + tokenID, + tokenNm, + tokenURI, + "", + tokenData, + owner, + ) } -func (n LegacyKeeper) TransferOwner(ctx sdk.Context, - denomID, tokenID, tokenNm, tokenURI, tokenData string, - srcOwner, dstOwner sdk.AccAddress) error { - return n.nk.TransferOwner(ctx, denomID, tokenID, tokenNm, tokenURI, types.DoNotModify, tokenData, srcOwner, dstOwner) +func (n LegacyKeeper) TransferOwner( + ctx sdk.Context, + denomID, + tokenID, + tokenNm, + tokenURI, + tokenData string, + srcOwner, + dstOwner sdk.AccAddress, +) error { + return n.nk.TransferOwnership( + ctx, + denomID, + tokenID, + tokenNm, + tokenURI, + types.DoNotModify, + tokenData, + srcOwner, + dstOwner, + ) } func (n LegacyKeeper) BurnNFT(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) error { - return n.nk.BurnNFT(ctx, denomID, tokenID, owner) + return n.nk.RemoveNFT(ctx, denomID, tokenID, owner) } func (n LegacyKeeper) GetNFT(ctx sdk.Context, denomID, tokenID string) (nft exported.NFT, err error) { @@ -43,5 +94,9 @@ func (n LegacyKeeper) GetNFT(ctx sdk.Context, denomID, tokenID string) (nft expo } func (n LegacyKeeper) GetDenom(ctx sdk.Context, id string) (denom types.Denom, found bool) { - return n.nk.GetDenom(ctx, id) + d, err := n.nk.GetDenomInfo(ctx, id) + if err != nil { + return denom, false + } + return *d, true } diff --git a/modules/nft/keeper/migrations.go b/modules/nft/keeper/migrations.go new file mode 100644 index 00000000..02b5f7bb --- /dev/null +++ b/modules/nft/keeper/migrations.go @@ -0,0 +1,22 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + + v2 "github.com/irisnet/irismod/modules/nft/migrations/v2" +) + +// Migrator is a struct for handling in-place store migrations. +type Migrator struct { + k Keeper +} + +// NewMigrator returns a new Migrator. +func NewMigrator(k Keeper) Migrator { + return Migrator{k: k} +} + +// Migrate1to2 migrates from version 1 to 2. +func (m Migrator) Migrate1to2(ctx sdk.Context) error { + return v2.Migrate(ctx, m.k.storeKey, m.k.cdc, m.k.Logger(ctx), m.k) +} diff --git a/modules/nft/keeper/msg_server.go b/modules/nft/keeper/msg_server.go index 3aa73c93..c5679261 100644 --- a/modules/nft/keeper/msg_server.go +++ b/modules/nft/keeper/msg_server.go @@ -9,29 +9,27 @@ import ( "github.com/irisnet/irismod/modules/nft/types" ) -type msgServer struct { - Keeper -} - -var _ types.MsgServer = msgServer{} - -// NewMsgServerImpl returns an implementation of the NFT MsgServer interface -// for the provided Keeper. -func NewMsgServerImpl(keeper Keeper) types.MsgServer { - return &msgServer{Keeper: keeper} -} +var _ types.MsgServer = Keeper{} // IssueDenom issue a new denom. -func (m msgServer) IssueDenom(goCtx context.Context, msg *types.MsgIssueDenom) (*types.MsgIssueDenomResponse, error) { +func (k Keeper) IssueDenom(goCtx context.Context, msg *types.MsgIssueDenom) (*types.MsgIssueDenomResponse, error) { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, err } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.Keeper.IssueDenom(ctx, msg.Id, msg.Name, msg.Schema, msg.Symbol, sender, - msg.MintRestricted, msg.UpdateRestricted, - msg.Description, msg.Uri, msg.UriHash, msg.Data, + if err := k.SaveDenom(ctx, msg.Id, + msg.Name, + msg.Schema, + msg.Symbol, + sender, + msg.MintRestricted, + msg.UpdateRestricted, + msg.Description, + msg.Uri, + msg.UriHash, + msg.Data, ); err != nil { return nil, err } @@ -53,7 +51,7 @@ func (m msgServer) IssueDenom(goCtx context.Context, msg *types.MsgIssueDenom) ( return &types.MsgIssueDenomResponse{}, nil } -func (m msgServer) MintNFT(goCtx context.Context, msg *types.MsgMintNFT) (*types.MsgMintNFTResponse, error) { +func (k Keeper) MintNFT(goCtx context.Context, msg *types.MsgMintNFT) (*types.MsgMintNFTResponse, error) { recipient, err := sdk.AccAddressFromBech32(msg.Recipient) if err != nil { return nil, err @@ -66,16 +64,18 @@ func (m msgServer) MintNFT(goCtx context.Context, msg *types.MsgMintNFT) (*types ctx := sdk.UnwrapSDKContext(goCtx) - denom, found := m.Keeper.GetDenom(ctx, msg.DenomId) - if !found { - return nil, sdkerrors.Wrapf(types.ErrInvalidDenom, "denom ID %s not exists", msg.DenomId) + denom, err := k.GetDenomInfo(ctx, msg.DenomId) + if err != nil { + return nil, err } if denom.MintRestricted && denom.Creator != sender.String() { - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is not allowed to mint NFT of denom %s", msg.Sender, msg.DenomId) + return nil, sdkerrors.Wrapf( + sdkerrors.ErrUnauthorized, "%s is not allowed to mint NFT of denom %s", sender, msg.DenomId) } - if err := m.Keeper.MintNFT(ctx, msg.DenomId, msg.Id, + if err := k.SaveNFT(ctx, msg.DenomId, + msg.Id, msg.Name, msg.URI, msg.UriHash, @@ -103,14 +103,15 @@ func (m msgServer) MintNFT(goCtx context.Context, msg *types.MsgMintNFT) (*types return &types.MsgMintNFTResponse{}, nil } -func (m msgServer) EditNFT(goCtx context.Context, msg *types.MsgEditNFT) (*types.MsgEditNFTResponse, error) { +func (k Keeper) EditNFT(goCtx context.Context, msg *types.MsgEditNFT) (*types.MsgEditNFTResponse, error) { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, err } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.Keeper.EditNFT(ctx, msg.DenomId, msg.Id, + if err := k.UpdateNFT(ctx, msg.DenomId, + msg.Id, msg.Name, msg.URI, msg.UriHash, @@ -138,7 +139,8 @@ func (m msgServer) EditNFT(goCtx context.Context, msg *types.MsgEditNFT) (*types return &types.MsgEditNFTResponse{}, nil } -func (m msgServer) TransferNFT(goCtx context.Context, msg *types.MsgTransferNFT) (*types.MsgTransferNFTResponse, error) { +func (k Keeper) TransferNFT(goCtx context.Context, + msg *types.MsgTransferNFT) (*types.MsgTransferNFTResponse, error) { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, err @@ -150,7 +152,8 @@ func (m msgServer) TransferNFT(goCtx context.Context, msg *types.MsgTransferNFT) } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.Keeper.TransferOwner(ctx, msg.DenomId, msg.Id, + if err := k.TransferOwnership(ctx, msg.DenomId, + msg.Id, msg.Name, msg.URI, msg.UriHash, @@ -179,14 +182,14 @@ func (m msgServer) TransferNFT(goCtx context.Context, msg *types.MsgTransferNFT) return &types.MsgTransferNFTResponse{}, nil } -func (m msgServer) BurnNFT(goCtx context.Context, msg *types.MsgBurnNFT) (*types.MsgBurnNFTResponse, error) { +func (k Keeper) BurnNFT(goCtx context.Context, msg *types.MsgBurnNFT) (*types.MsgBurnNFTResponse, error) { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, err } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.Keeper.BurnNFT(ctx, msg.DenomId, msg.Id, sender); err != nil { + if err := k.RemoveNFT(ctx, msg.DenomId, msg.Id, sender); err != nil { return nil, err } @@ -207,7 +210,7 @@ func (m msgServer) BurnNFT(goCtx context.Context, msg *types.MsgBurnNFT) (*types return &types.MsgBurnNFTResponse{}, nil } -func (m msgServer) TransferDenom(goCtx context.Context, msg *types.MsgTransferDenom) (*types.MsgTransferDenomResponse, error) { +func (k Keeper) TransferDenom(goCtx context.Context, msg *types.MsgTransferDenom) (*types.MsgTransferDenomResponse, error) { sender, err := sdk.AccAddressFromBech32(msg.Sender) if err != nil { return nil, err @@ -219,7 +222,7 @@ func (m msgServer) TransferDenom(goCtx context.Context, msg *types.MsgTransferDe } ctx := sdk.UnwrapSDKContext(goCtx) - if err := m.Keeper.TransferDenomOwner(ctx, msg.Id, sender, recipient); err != nil { + if err := k.TransferDenomOwner(ctx, msg.Id, sender, recipient); err != nil { return nil, err } diff --git a/modules/nft/keeper/nft.go b/modules/nft/keeper/nft.go index 7729c3f0..ccd84971 100644 --- a/modules/nft/keeper/nft.go +++ b/modules/nft/keeper/nft.go @@ -1,73 +1,215 @@ package keeper import ( + codectypes "github.com/cosmos/cosmos-sdk/codec/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/x/nft" "github.com/irisnet/irismod/modules/nft/exported" "github.com/irisnet/irismod/modules/nft/types" ) -// GetNFT gets the the specified NFT -func (k Keeper) GetNFT(ctx sdk.Context, denomID, tokenID string) (nft exported.NFT, err error) { - store := ctx.KVStore(k.storeKey) +// SaveNFT mints an NFT and manages the NFT's existence within Collections and Owners +func (k Keeper) SaveNFT(ctx sdk.Context, denomID, + tokenID, + tokenNm, + tokenURI, + tokenUriHash, + tokenData string, + receiver sdk.AccAddress, +) error { + nftMetadata := &types.NFTMetadata{ + Name: tokenNm, + Data: tokenData, + } + data, err := codectypes.NewAnyWithValue(nftMetadata) + if err != nil { + return err + } + return k.nk.Mint(ctx, nft.NFT{ + ClassId: denomID, + Id: tokenID, + Uri: tokenURI, + UriHash: tokenUriHash, + Data: data, + }, receiver) +} - bz := store.Get(types.KeyNFT(denomID, tokenID)) - if bz == nil { - return nil, sdkerrors.Wrapf(types.ErrUnknownNFT, "not found NFT: %s", tokenID) +// UpdateNFT updates an already existing NFT +func (k Keeper) UpdateNFT(ctx sdk.Context, denomID, + tokenID, + tokenNm, + tokenURI, + tokenURIHash, + tokenData string, + owner sdk.AccAddress, +) error { + denom, err := k.GetDenomInfo(ctx, denomID) + if err != nil { + return err } - var baseNFT types.BaseNFT - k.cdc.MustUnmarshal(bz, &baseNFT) + if denom.UpdateRestricted { + // if true , nobody can update the NFT under this denom + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "nobody can update the NFT under this denom %s", denomID) + } - return baseNFT, nil -} + // just the owner of NFT can edit + if err := k.Authorize(ctx, denomID, tokenID, owner); err != nil { + return err + } -// GetNFTs returns all NFTs by the specified denom ID -func (k Keeper) GetNFTs(ctx sdk.Context, denom string) (nfts []exported.NFT) { - store := ctx.KVStore(k.storeKey) + if !types.Modified(tokenURI) && + !types.Modified(tokenURIHash) && + !types.Modified(tokenNm) && + !types.Modified(tokenData) { + return nil + } - iterator := sdk.KVStorePrefixIterator(store, types.KeyNFT(denom, "")) - defer iterator.Close() - for ; iterator.Valid(); iterator.Next() { - var baseNFT types.BaseNFT - k.cdc.MustUnmarshal(iterator.Value(), &baseNFT) - nfts = append(nfts, baseNFT) + token, exist := k.nk.GetNFT(ctx, denomID, tokenID) + if !exist { + return sdkerrors.Wrapf(types.ErrUnknownNFT, "nft ID %s not exists", tokenID) } - return nfts + token.Uri = types.Modify(token.Uri, tokenURI) + token.UriHash = types.Modify(token.UriHash, tokenURIHash) + if types.Modified(tokenNm) || types.Modified(tokenData) { + var nftMetadata types.NFTMetadata + if err := k.cdc.Unmarshal(token.Data.GetValue(), &nftMetadata); err != nil { + return err + } + + nftMetadata.Name = types.Modify(nftMetadata.Name, tokenNm) + nftMetadata.Data = types.Modify(nftMetadata.Data, tokenData) + data, err := codectypes.NewAnyWithValue(&nftMetadata) + if err != nil { + return err + } + token.Data = data + } + return k.nk.Update(ctx, token) } -// Authorize checks if the sender is the owner of the given NFT -// Return the NFT if true, an error otherwise -func (k Keeper) Authorize(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) (types.BaseNFT, error) { - nft, err := k.GetNFT(ctx, denomID, tokenID) +// TransferOwnership transfers the ownership of the given NFT to the new owner +func (k Keeper) TransferOwnership(ctx sdk.Context, denomID, + tokenID, + tokenNm, + tokenURI, + tokenURIHash, + tokenData string, + srcOwner, + dstOwner sdk.AccAddress, +) error { + token, exist := k.nk.GetNFT(ctx, denomID, tokenID) + if !exist { + return sdkerrors.Wrapf(types.ErrInvalidTokenID, "nft ID %s not exists", tokenID) + } + + if err := k.Authorize(ctx, denomID, tokenID, srcOwner); err != nil { + return err + } + + denom, err := k.GetDenomInfo(ctx, denomID) if err != nil { - return types.BaseNFT{}, err + return err + } + + tokenChanged := types.Modified(tokenURI) || types.Modified(tokenURIHash) + tokenMetadataChanged := types.Modified(tokenNm) || types.Modified(tokenData) + + if denom.UpdateRestricted && (tokenChanged || tokenMetadataChanged) { + return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "It is restricted to update NFT under this denom %s", denom.Id) } - if !owner.Equals(nft.GetOwner()) { - return types.BaseNFT{}, sdkerrors.Wrap(types.ErrUnauthorized, owner.String()) + if !tokenChanged && !tokenMetadataChanged { + return k.nk.Transfer(ctx, denomID, tokenID, dstOwner) } - return nft.(types.BaseNFT), nil + token.Uri = types.Modify(token.Uri, tokenURI) + token.UriHash = types.Modify(token.UriHash, tokenURIHash) + if tokenMetadataChanged { + var nftMetadata types.NFTMetadata + if err := k.cdc.Unmarshal(token.Data.GetValue(), &nftMetadata); err != nil { + return err + } + + nftMetadata.Name = types.Modify(nftMetadata.Name, tokenNm) + nftMetadata.Data = types.Modify(nftMetadata.Data, tokenData) + data, err := codectypes.NewAnyWithValue(&nftMetadata) + if err != nil { + return err + } + token.Data = data + } + + if err := k.nk.Update(ctx, token); err != nil { + return err + } + return k.nk.Transfer(ctx, denomID, tokenID, dstOwner) } -// HasNFT checks if the specified NFT exists -func (k Keeper) HasNFT(ctx sdk.Context, denomID, tokenID string) bool { - store := ctx.KVStore(k.storeKey) - return store.Has(types.KeyNFT(denomID, tokenID)) +// RemoveNFT deletes a specified NFT +func (k Keeper) RemoveNFT(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) error { + if err := k.Authorize(ctx, denomID, tokenID, owner); err != nil { + return err + } + return k.nk.Burn(ctx, denomID, tokenID) } -func (k Keeper) setNFT(ctx sdk.Context, denomID string, nft types.BaseNFT) { - store := ctx.KVStore(k.storeKey) +// GetNFT gets the specified NFT +func (k Keeper) GetNFT(ctx sdk.Context, denomID, tokenID string) (nft exported.NFT, err error) { + token, exist := k.nk.GetNFT(ctx, denomID, tokenID) + if !exist { + return nil, sdkerrors.Wrapf(types.ErrUnknownNFT, "not found NFT: %s", denomID) + } - bz := k.cdc.MustMarshal(&nft) - store.Set(types.KeyNFT(denomID, nft.GetID()), bz) + var nftMetadata types.NFTMetadata + if err := k.cdc.Unmarshal(token.Data.GetValue(), &nftMetadata); err != nil { + return nil, err + } + + owner := k.nk.GetOwner(ctx, denomID, tokenID) + return types.BaseNFT{ + Id: token.Id, + Name: nftMetadata.Name, + URI: token.Uri, + Data: nftMetadata.Data, + Owner: owner.String(), + UriHash: token.UriHash, + }, nil } -// deleteNFT deletes an existing NFT from store -func (k Keeper) deleteNFT(ctx sdk.Context, denomID string, nft exported.NFT) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyNFT(denomID, nft.GetID())) +// GetNFTs returns all NFTs by the specified denom ID +func (k Keeper) GetNFTs(ctx sdk.Context, denom string) (nfts []exported.NFT, err error) { + tokens := k.nk.GetNFTsOfClass(ctx, denom) + for _, token := range tokens { + var nftMetadata types.NFTMetadata + if err := k.cdc.Unmarshal(token.Data.GetValue(), &nftMetadata); err != nil { + return nil, err + } + nfts = append(nfts, types.BaseNFT{ + Id: token.GetId(), + Name: nftMetadata.Name, + URI: token.GetUri(), + UriHash: token.GetUriHash(), + Data: nftMetadata.Data, + Owner: k.nk.GetOwner(ctx, denom, token.GetId()).String(), + }) + } + return nfts, nil +} + +// Authorize checks if the sender is the owner of the given NFT +// Return the NFT if true, an error otherwise +func (k Keeper) Authorize(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) error { + if !owner.Equals(k.nk.GetOwner(ctx, denomID, tokenID)) { + return sdkerrors.Wrap(types.ErrUnauthorized, owner.String()) + } + return nil +} + +// HasNFT checks if the specified NFT exists +func (k Keeper) HasNFT(ctx sdk.Context, denomID, tokenID string) bool { + return k.nk.HasNFT(ctx, denomID, tokenID) } diff --git a/modules/nft/keeper/nft_test.go b/modules/nft/keeper/nft_test.go index 07f67011..0b7a7536 100644 --- a/modules/nft/keeper/nft_test.go +++ b/modules/nft/keeper/nft_test.go @@ -5,8 +5,8 @@ import ( ) func (suite *KeeperSuite) TestGetNFT() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) // GetNFT should get the NFT @@ -16,8 +16,8 @@ func (suite *KeeperSuite) TestGetNFT() { suite.True(receivedNFT.GetOwner().Equals(address)) suite.Equal(receivedNFT.GetURI(), tokenURI) - // MintNFT shouldn't fail when collection exists - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection exists + err = suite.keeper.SaveNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) // GetNFT should get the NFT when collection exists @@ -32,30 +32,31 @@ func (suite *KeeperSuite) TestGetNFT() { } func (suite *KeeperSuite) TestGetNFTs() { - err := suite.keeper.MintNFT(suite.ctx, denomID2, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID2, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) + err = suite.keeper.SaveNFT(suite.ctx, denomID2, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address) + err = suite.keeper.SaveNFT(suite.ctx, denomID2, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address) + err = suite.keeper.SaveNFT(suite.ctx, denomID, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - nfts := suite.keeper.GetNFTs(suite.ctx, denomID2) + nfts, err := suite.keeper.GetNFTs(suite.ctx, denomID2) + suite.NoError(err) suite.Len(nfts, 3) } func (suite *KeeperSuite) TestAuthorize() { - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) - _, err = suite.keeper.Authorize(suite.ctx, denomID, tokenID, address2) + err = suite.keeper.Authorize(suite.ctx, denomID, tokenID, address2) suite.Error(err) - _, err = suite.keeper.Authorize(suite.ctx, denomID, tokenID, address) + err = suite.keeper.Authorize(suite.ctx, denomID, tokenID, address) suite.NoError(err) } @@ -64,8 +65,8 @@ func (suite *KeeperSuite) TestHasNFT() { isNFT := suite.keeper.HasNFT(suite.ctx, denomID, tokenID) suite.False(isNFT) - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) + // SaveNFT shouldn't fail when collection does not exist + err := suite.keeper.SaveNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) suite.NoError(err) // IsNFT should return true diff --git a/modules/nft/keeper/owners.go b/modules/nft/keeper/owners.go deleted file mode 100644 index 38a99205..00000000 --- a/modules/nft/keeper/owners.go +++ /dev/null @@ -1,90 +0,0 @@ -package keeper - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" - - "github.com/irisnet/irismod/modules/nft/types" -) - -// GetOwner gets all the ID collections owned by an address and denom ID -func (k Keeper) GetOwner(ctx sdk.Context, address sdk.AccAddress, denom string) types.Owner { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStorePrefixIterator(store, types.KeyOwner(address, denom, "")) - defer iterator.Close() - - owner := types.Owner{ - Address: address.String(), - IDCollections: types.IDCollections{}, - } - idsMap := make(map[string][]string) - - for ; iterator.Valid(); iterator.Next() { - _, denomID, tokenID, _ := types.SplitKeyOwner(iterator.Key()) - if ids, ok := idsMap[denomID]; ok { - idsMap[denomID] = append(ids, tokenID) - } else { - idsMap[denomID] = []string{tokenID} - owner.IDCollections = append( - owner.IDCollections, - types.IDCollection{DenomId: denomID}, - ) - } - } - - for i := 0; i < len(owner.IDCollections); i++ { - owner.IDCollections[i].TokenIds = idsMap[owner.IDCollections[i].DenomId] - } - - return owner -} - -// GetOwners gets all the ID collections -func (k Keeper) GetOwners(ctx sdk.Context) (owners types.Owners) { - store := ctx.KVStore(k.storeKey) - iterator := sdk.KVStoreReversePrefixIterator(store, types.KeyOwner(nil, "", "")) - defer iterator.Close() - - idcsMap := make(map[string]types.IDCollections) - for ; iterator.Valid(); iterator.Next() { - key := iterator.Key() - address, denom, id, _ := types.SplitKeyOwner(key) - if _, ok := idcsMap[address.String()]; !ok { - idcsMap[address.String()] = types.IDCollections{} - owners = append( - owners, - types.Owner{Address: address.String()}, - ) - } - idcs := idcsMap[address.String()] - idcs = idcs.Add(denom, id) - idcsMap[address.String()] = idcs - } - for i, owner := range owners { - owners[i].IDCollections = idcsMap[owner.Address] - } - - return owners -} - -func (k Keeper) deleteOwner(ctx sdk.Context, denomID, tokenID string, owner sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) - store.Delete(types.KeyOwner(owner, denomID, tokenID)) -} - -func (k Keeper) setOwner(ctx sdk.Context, - denomID, tokenID string, - owner sdk.AccAddress) { - store := ctx.KVStore(k.storeKey) - - bz := types.MustMarshalTokenID(k.cdc, tokenID) - store.Set(types.KeyOwner(owner, denomID, tokenID), bz) -} - -func (k Keeper) swapOwner(ctx sdk.Context, denomID, tokenID string, srcOwner, dstOwner sdk.AccAddress) { - - // delete old owner key - k.deleteOwner(ctx, denomID, tokenID, srcOwner) - - // set new owner key - k.setOwner(ctx, denomID, tokenID, dstOwner) -} diff --git a/modules/nft/keeper/owners_test.go b/modules/nft/keeper/owners_test.go deleted file mode 100644 index a57db0b0..00000000 --- a/modules/nft/keeper/owners_test.go +++ /dev/null @@ -1,35 +0,0 @@ -package keeper_test - -import ( - "github.com/irisnet/irismod/modules/nft/keeper" -) - -func (suite *KeeperSuite) TestGetOwners() { - - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address3) - suite.NoError(err) - - owners := suite.keeper.GetOwners(suite.ctx) - suite.Equal(3, len(owners)) - - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID2, tokenNm2, tokenURI, tokenURIHash, tokenData, address2) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID3, tokenNm3, tokenURI, tokenURIHash, tokenData, address3) - suite.NoError(err) - - owners = suite.keeper.GetOwners(suite.ctx) - suite.Equal(3, len(owners)) - - msg, fail := keeper.SupplyInvariant(suite.keeper)(suite.ctx) - suite.False(fail, msg) -} diff --git a/modules/nft/keeper/pagination_test.go b/modules/nft/keeper/pagination_test.go index 892fdf1f..5558257c 100644 --- a/modules/nft/keeper/pagination_test.go +++ b/modules/nft/keeper/pagination_test.go @@ -24,7 +24,7 @@ func TestShapePageRequest(t *testing.T) { CountTotal: true, Reverse: true, } - + res2 := ShapePageRequest(request) require.NotNil(t, res2) require.Equal(t, res2.Limit, defaultRequest.Limit) // limit == paginationDefaultLimit diff --git a/modules/nft/keeper/querier.go b/modules/nft/keeper/querier.go deleted file mode 100644 index 6b588530..00000000 --- a/modules/nft/keeper/querier.go +++ /dev/null @@ -1,141 +0,0 @@ -package keeper - -import ( - "encoding/binary" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/cosmos/cosmos-sdk/codec" - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - - "github.com/irisnet/irismod/modules/nft/types" -) - -// NewQuerier is the module level router for state queries -func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return func(ctx sdk.Context, path []string, req abci.RequestQuery) (res []byte, err error) { - switch path[0] { - case types.QuerySupply: - return querySupply(ctx, req, k, legacyQuerierCdc) - case types.QueryOwner: - return queryOwner(ctx, req, k, legacyQuerierCdc) - case types.QueryCollection: - return queryCollection(ctx, req, k, legacyQuerierCdc) - case types.QueryDenom: - return queryDenom(ctx, req, k, legacyQuerierCdc) - case types.QueryDenoms: - return queryDenoms(ctx, req, k, legacyQuerierCdc) - case types.QueryNFT: - return queryNFT(ctx, req, k, legacyQuerierCdc) - default: - return nil, sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown query path: %s", path[0]) - } - } -} - -func querySupply(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QuerySupplyParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - var supply uint64 - if params.Owner.Empty() && len(params.Denom) > 0 { - supply = k.GetTotalSupply(ctx, params.Denom) - } else { - supply = k.GetTotalSupplyOfOwner(ctx, params.Denom, params.Owner) - } - - bz := make([]byte, 8) - binary.LittleEndian.PutUint64(bz, supply) - return bz, nil -} - -func queryOwner(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryOwnerParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - owner := k.GetOwner(ctx, params.Owner, params.Denom) - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, owner) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryCollection(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryCollectionParams - - err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - collection, err := k.GetCollection(ctx, params.Denom) - if err != nil { - return nil, err - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, collection) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDenom(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryDenomParams - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - denom, _ := k.GetDenom(ctx, params.ID) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, denom) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryDenoms(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - denoms := k.GetDenoms(ctx) - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, denoms) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} - -func queryNFT(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) { - var params types.QueryNFTParams - - if err := legacyQuerierCdc.UnmarshalJSON(req.Data, ¶ms); err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error()) - } - - nft, err := k.GetNFT(ctx, params.Denom, params.TokenID) - if err != nil { - return nil, sdkerrors.Wrapf(types.ErrUnknownNFT, "invalid NFT %s from collection %s", params.TokenID, params.Denom) - } - - bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, nft) - if err != nil { - return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error()) - } - - return bz, nil -} diff --git a/modules/nft/keeper/querier_test.go b/modules/nft/keeper/querier_test.go deleted file mode 100644 index 39b5d907..00000000 --- a/modules/nft/keeper/querier_test.go +++ /dev/null @@ -1,218 +0,0 @@ -package keeper_test - -import ( - "encoding/binary" - - abci "github.com/tendermint/tendermint/abci/types" - - "github.com/irisnet/irismod/modules/nft/exported" - keep "github.com/irisnet/irismod/modules/nft/keeper" - "github.com/irisnet/irismod/modules/nft/types" -) - -func (suite *KeeperSuite) TestNewQuerier() { - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - _, err := querier(suite.ctx, []string{"foo", "bar"}, query) - suite.Error(err) -} - -func (suite *KeeperSuite) TestQuerySupply() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - query.Path = "/custom/nft/supply" - query.Data = []byte("?") - - res, err := querier(suite.ctx, []string{"supply"}, query) - suite.Error(err) - suite.Nil(res) - - queryCollectionParams := types.NewQuerySupplyParams(denomID2, nil) - bz, errRes := suite.legacyAmino.MarshalJSON(queryCollectionParams) - suite.Nil(errRes) - query.Data = bz - res, err = querier(suite.ctx, []string{"supply"}, query) - suite.NoError(err) - supplyResp := binary.LittleEndian.Uint64(res) - suite.Equal(0, int(supplyResp)) - - queryCollectionParams = types.NewQuerySupplyParams(denomID, nil) - bz, errRes = suite.legacyAmino.MarshalJSON(queryCollectionParams) - suite.Nil(errRes) - query.Data = bz - - res, err = querier(suite.ctx, []string{"supply"}, query) - suite.NoError(err) - suite.NotNil(res) - - supplyResp = binary.LittleEndian.Uint64(res) - suite.Equal(1, int(supplyResp)) -} - -func (suite *KeeperSuite) TestQueryCollection() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - - query.Path = "/custom/nft/collection" - - query.Data = []byte("?") - res, err := querier(suite.ctx, []string{"collection"}, query) - suite.Error(err) - suite.Nil(res) - - queryCollectionParams := types.NewQuerySupplyParams(denomID2, nil) - bz, errRes := suite.legacyAmino.MarshalJSON(queryCollectionParams) - suite.Nil(errRes) - - query.Data = bz - _, err = querier(suite.ctx, []string{"collection"}, query) - suite.NoError(err) - - queryCollectionParams = types.NewQuerySupplyParams(denomID, nil) - bz, errRes = suite.legacyAmino.MarshalJSON(queryCollectionParams) - suite.Nil(errRes) - - query.Data = bz - res, err = querier(suite.ctx, []string{"collection"}, query) - suite.NoError(err) - suite.NotNil(res) - - var collection types.Collection - types.ModuleCdc.MustUnmarshalJSON(res, &collection) - suite.Len(collection.NFTs, 1) -} - -func (suite *KeeperSuite) TestQueryOwner() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - query := abci.RequestQuery{ - Path: "/custom/nft/owner", - Data: []byte{}, - } - - query.Data = []byte("?") - _, err = querier(suite.ctx, []string{"owner"}, query) - suite.Error(err) - - // query the balance using no denomID so that all denoms will be returns - params := types.NewQuerySupplyParams("", address) - bz, err2 := suite.legacyAmino.MarshalJSON(params) - suite.Nil(err2) - query.Data = bz - - var out types.Owner - res, err := querier(suite.ctx, []string{"owner"}, query) - suite.NoError(err) - suite.NotNil(res) - - suite.legacyAmino.MustUnmarshalJSON(res, &out) - - // build the owner using both denoms - idCollection1 := types.NewIDCollection(denomID, []string{tokenID}) - idCollection2 := types.NewIDCollection(denomID2, []string{tokenID}) - owner := types.NewOwner(address, idCollection1, idCollection2) - - suite.EqualValues(out.String(), owner.String()) -} - -func (suite *KeeperSuite) TestQueryNFT() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - query.Path = "/custom/nft/nft" - var res []byte - - query.Data = []byte("?") - res, err = querier(suite.ctx, []string{"nft"}, query) - suite.Error(err) - suite.Nil(res) - - params := types.NewQueryNFTParams(denomID2, tokenID2) - bz, err2 := suite.legacyAmino.MarshalJSON(params) - suite.Nil(err2) - - query.Data = bz - res, err = querier(suite.ctx, []string{"nft"}, query) - suite.Error(err) - suite.Nil(res) - - params = types.NewQueryNFTParams(denomID, tokenID) - bz, err2 = suite.legacyAmino.MarshalJSON(params) - suite.Nil(err2) - - query.Data = bz - res, err = querier(suite.ctx, []string{"nft"}, query) - suite.NoError(err) - suite.NotNil(res) - - var out exported.NFT - suite.legacyAmino.MustUnmarshalJSON(res, &out) - - suite.Equal(out.GetID(), tokenID) - suite.Equal(out.GetURI(), tokenURI) - suite.Equal(out.GetOwner(), address) -} - -func (suite *KeeperSuite) TestQueryDenoms() { - // MintNFT shouldn't fail when collection does not exist - err := suite.keeper.MintNFT(suite.ctx, denomID, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - err = suite.keeper.MintNFT(suite.ctx, denomID2, tokenID, tokenNm, tokenURI, tokenURIHash, tokenData, address) - suite.NoError(err) - - querier := keep.NewQuerier(suite.keeper, suite.legacyAmino) - - query := abci.RequestQuery{ - Path: "", - Data: []byte{}, - } - var res []byte - query.Path = "/custom/nft/denoms" - - res, err = querier(suite.ctx, []string{"denoms"}, query) - suite.NoError(err) - suite.NotNil(res) - - denoms := []string{denomID, denomID2, denomID3} - - var out []types.Denom - suite.legacyAmino.MustUnmarshalJSON(res, &out) - - for key, denomInQuestion := range out { - suite.Equal(denomInQuestion.Id, denoms[key]) - } -} diff --git a/modules/nft/migrations/v2/expected_keeper.go b/modules/nft/migrations/v2/expected_keeper.go new file mode 100644 index 00000000..a4845c30 --- /dev/null +++ b/modules/nft/migrations/v2/expected_keeper.go @@ -0,0 +1,27 @@ +package v2 + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type NFTKeeper interface { + SaveDenom(ctx sdk.Context, id, + name, + schema, + symbol string, + creator sdk.AccAddress, + mintRestricted, + updateRestricted bool, + description, + uri, + uriHash, + data string, + ) error + + SaveNFT(ctx sdk.Context, denomID, + tokenID, + tokenNm, + tokenURI, + tokenUriHash, + tokenData string, + receiver sdk.AccAddress, + ) error +} diff --git a/modules/nft/migrations/v2/keys.go b/modules/nft/migrations/v2/keys.go new file mode 100644 index 00000000..88db65fc --- /dev/null +++ b/modules/nft/migrations/v2/keys.go @@ -0,0 +1,64 @@ +package v2 + +import sdk "github.com/cosmos/cosmos-sdk/types" + +var ( + PrefixNFT = []byte{0x01} + PrefixOwners = []byte{0x02} // key for a owner + PrefixCollection = []byte{0x03} // key for balance of NFTs held by the denom + PrefixDenom = []byte{0x04} // key for denom of the nft + PrefixDenomName = []byte{0x05} // key for denom name of the nft + + delimiter = []byte("/") +) + +// KeyDenom gets the storeKey by the denom id +func KeyDenom(id string) []byte { + key := append(PrefixDenom, delimiter...) + return append(key, []byte(id)...) +} + +// KeyDenomName gets the storeKey by the denom name +func KeyDenomName(name string) []byte { + key := append(PrefixDenomName, delimiter...) + return append(key, []byte(name)...) +} + +// KeyNFT gets the key of nft stored by an denom and id +func KeyNFT(denomID, tokenID string) []byte { + key := append(PrefixNFT, delimiter...) + if len(denomID) > 0 { + key = append(key, []byte(denomID)...) + key = append(key, delimiter...) + } + + if len(denomID) > 0 && len(tokenID) > 0 { + key = append(key, []byte(tokenID)...) + } + return key +} + +// KeyCollection gets the storeKey by the collection +func KeyCollection(denomID string) []byte { + key := append(PrefixCollection, delimiter...) + return append(key, []byte(denomID)...) +} + +// KeyOwner gets the key of a collection owned by an account address +func KeyOwner(address sdk.AccAddress, denomID, tokenID string) []byte { + key := append(PrefixOwners, delimiter...) + if address != nil { + key = append(key, []byte(address.String())...) + key = append(key, delimiter...) + } + + if address != nil && len(denomID) > 0 { + key = append(key, []byte(denomID)...) + key = append(key, delimiter...) + } + + if address != nil && len(denomID) > 0 && len(tokenID) > 0 { + key = append(key, []byte(tokenID)...) + } + return key +} diff --git a/modules/nft/migrations/v2/store.go b/modules/nft/migrations/v2/store.go new file mode 100644 index 00000000..b17218f0 --- /dev/null +++ b/modules/nft/migrations/v2/store.go @@ -0,0 +1,126 @@ +package v2 + +import ( + "time" + + "github.com/tendermint/tendermint/libs/log" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/irisnet/irismod/modules/nft/types" +) + +func Migrate(ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.Codec, + logger log.Logger, + k NFTKeeper, +) error { + logger.Info("migrate store data from version 1 to 2") + startTime := time.Now() + denoms, err := migrateDenoms(ctx, storeKey, cdc, k) + if err != nil { + return err + } + logger.Info("migrate denoms success", "denomNum", len(denoms)) + + if err := migrateTokens(ctx, storeKey, cdc, logger, denoms, k); err != nil { + return err + } + logger.Info("migrate store data success", "consume", time.Since(startTime).String()) + return nil +} + +func migrateDenoms(ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.Codec, + k NFTKeeper, +) (denoms []string, err error) { + store := ctx.KVStore(storeKey) + iterator := sdk.KVStorePrefixIterator(store, KeyDenom("")) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var denom types.Denom + cdc.MustUnmarshal(iterator.Value(), &denom) + + //delete unused key + store.Delete(KeyDenom(denom.Id)) + store.Delete(KeyDenomName(denom.Name)) + store.Delete(KeyCollection(denom.Id)) + + creator, err := sdk.AccAddressFromBech32(denom.Creator) + if err != nil { + return denoms, err + } + + if err := k.SaveDenom(ctx, denom.Id, + denom.Name, + denom.Schema, + denom.Symbol, + creator, + denom.MintRestricted, + denom.UpdateRestricted, + denom.Description, + denom.Uri, + denom.UriHash, + denom.Data, + ); err != nil { + return denoms, err + } + denoms = append(denoms, denom.Id) + + } + return denoms, nil +} + +func migrateTokens(ctx sdk.Context, + storeKey storetypes.StoreKey, + cdc codec.Codec, + logger log.Logger, + denoms []string, + k NFTKeeper, +) error { + store := ctx.KVStore(storeKey) + + var iterator sdk.Iterator + defer func() { + if iterator != nil { + _ = iterator.Close() + } + }() + + total := int64(0) + for _, denomID := range denoms { + iterator = sdk.KVStorePrefixIterator(store, KeyNFT(denomID, "")) + for ; iterator.Valid(); iterator.Next() { + var baseNFT types.BaseNFT + cdc.MustUnmarshal(iterator.Value(), &baseNFT) + + owner, err := sdk.AccAddressFromBech32(baseNFT.Owner) + if err != nil { + return err + } + + //delete unused key + store.Delete(KeyNFT(denomID, baseNFT.Id)) + store.Delete(KeyOwner(owner, denomID, baseNFT.Id)) + + if err := k.SaveNFT(ctx, denomID, + baseNFT.Id, + baseNFT.Name, + baseNFT.URI, + baseNFT.UriHash, + baseNFT.Data, + owner, + ); err != nil { + return err + } + total++ + } + } + logger.Info("migrate nft success", "nftNum", total) + return nil +} diff --git a/modules/nft/migrations/v2/store_test.go b/modules/nft/migrations/v2/store_test.go new file mode 100644 index 00000000..d91c0342 --- /dev/null +++ b/modules/nft/migrations/v2/store_test.go @@ -0,0 +1,153 @@ +package v2_test + +import ( + "fmt" + + gogotypes "github.com/gogo/protobuf/types" + + "math/rand" + "testing" + + "github.com/stretchr/testify/require" + + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + + "github.com/irisnet/irismod/modules/nft/keeper" + v2 "github.com/irisnet/irismod/modules/nft/migrations/v2" + "github.com/irisnet/irismod/modules/nft/types" + "github.com/irisnet/irismod/simapp" +) + +func TestMigrate(t *testing.T) { + app := simapp.Setup(t, false) + ctx := app.BaseApp.NewContext(false, tmproto.Header{}) + storeKey := app.GetKey(types.StoreKey) + cdc := app.AppCodec() + + collections := prepareData(ctx, storeKey, cdc) + require.NoError(t, v2.Migrate(ctx, storeKey, cdc, app.NFTKeeper.Logger(ctx), app.NFTKeeper)) + check(t, ctx, app.NFTKeeper, collections) + +} + +func prepareData(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec) (collection []types.Collection) { + addrs := simapp.CreateTestAddrs(10) + for i := 1; i <= 10; i++ { + denom := types.Denom{ + Id: fmt.Sprintf("denom%d", i), + Name: fmt.Sprintf("denomName%d", i), + Schema: fmt.Sprintf("denomSchema%d", i), + Creator: addrs[rand.Intn(len(addrs))].String(), + Symbol: fmt.Sprintf("denomSymbol%d", i), + MintRestricted: false, + UpdateRestricted: true, + Description: fmt.Sprintf("denomDescription%d", i), + Uri: fmt.Sprintf("denomUri%d", i), + UriHash: fmt.Sprintf("denomUriHash%d", i), + Data: fmt.Sprintf("denomData%d", i), + } + setDenom(ctx, storeKey, cdc, denom) + + var tokens []types.BaseNFT + for j := 1; j <= 100; j++ { + token := types.BaseNFT{ + Id: fmt.Sprintf("nft%d", j), + Name: fmt.Sprintf("nftName%d", j), + URI: fmt.Sprintf("nftURI%d", j), + Data: fmt.Sprintf("nftData%d", j), + Owner: addrs[rand.Intn(len(addrs))].String(), + UriHash: fmt.Sprintf("nftUriHash%d", j), + } + tokens = append(tokens, token) + mintNFT(ctx, storeKey, cdc, denom.Id, token) + } + collection = append(collection, types.Collection{ + Denom: denom, + NFTs: tokens, + }) + } + return +} + +func check(t *testing.T, ctx sdk.Context, k keeper.Keeper, collections []types.Collection) { + for _, collection := range collections { + denom := collection.Denom + d, err := k.GetDenomInfo(ctx, denom.Id) + require.NoError(t, err) + require.EqualValues(t, denom, *d) + + for _, token := range collection.NFTs { + nft, err := k.GetNFT(ctx, denom.Id, token.Id) + require.NoError(t, err) + require.EqualValues(t, token, nft) + } + } + keeper.SupplyInvariant(k) +} + +// SetDenom is responsible for saving the definition of denom +func setDenom(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denom types.Denom) { + store := ctx.KVStore(storeKey) + bz := cdc.MustMarshal(&denom) + store.Set(v2.KeyDenom(denom.Id), bz) + store.Set(v2.KeyDenomName(denom.Name), []byte(denom.Id)) +} + +// MintNFT mints an NFT and manages the NFT's existence within Collections and Owners +func mintNFT(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denomID string, baseToken types.BaseNFT) { + setNFT(ctx, storeKey, cdc, denomID, baseToken) + setOwner(ctx, storeKey, cdc, denomID, baseToken.Id, baseToken.Owner) + increaseSupply(ctx, storeKey, cdc, denomID) +} + +func setNFT(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denomID string, baseToken types.BaseNFT) { + store := ctx.KVStore(storeKey) + + bz := cdc.MustMarshal(&baseToken) + store.Set(v2.KeyNFT(denomID, baseToken.Id), bz) +} + +func setOwner(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denomID, tokenID, owner string) { + store := ctx.KVStore(storeKey) + bz := mustMarshalTokenID(cdc, tokenID) + ownerAddr := sdk.MustAccAddressFromBech32(owner) + store.Set(v2.KeyOwner(ownerAddr, denomID, tokenID), bz) +} + +func increaseSupply(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denomID string) { + supply := getTotalSupply(ctx, storeKey, cdc, denomID) + supply++ + + store := ctx.KVStore(storeKey) + bz := mustMarshalSupply(cdc, supply) + store.Set(v2.KeyCollection(denomID), bz) +} + +func getTotalSupply(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.Codec, denomID string) uint64 { + store := ctx.KVStore(storeKey) + bz := store.Get(v2.KeyCollection(denomID)) + if len(bz) == 0 { + return 0 + } + return mustUnMarshalSupply(cdc, bz) +} + +func mustMarshalSupply(cdc codec.Codec, supply uint64) []byte { + supplyWrap := gogotypes.UInt64Value{Value: supply} + return cdc.MustMarshal(&supplyWrap) +} + +func mustUnMarshalSupply(cdc codec.Codec, value []byte) uint64 { + var supplyWrap gogotypes.UInt64Value + cdc.MustUnmarshal(value, &supplyWrap) + return supplyWrap.Value +} + +func mustMarshalTokenID(cdc codec.Codec, tokenID string) []byte { + tokenIDWrap := gogotypes.StringValue{Value: tokenID} + return cdc.MustMarshal(&tokenIDWrap) +} diff --git a/modules/nft/module.go b/modules/nft/module/module.go similarity index 83% rename from modules/nft/module.go rename to modules/nft/module/module.go index 8adb3d5f..945ddb04 100644 --- a/modules/nft/module.go +++ b/modules/nft/module/module.go @@ -1,4 +1,4 @@ -package nft +package module import ( "context" @@ -6,7 +6,6 @@ import ( "fmt" "math/rand" - "github.com/gorilla/mux" "github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/spf13/cobra" @@ -18,6 +17,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + sdkbftsim "github.com/cosmos/cosmos-sdk/x/nft/simulation" "github.com/irisnet/irismod/modules/nft/client/cli" "github.com/irisnet/irismod/modules/nft/keeper" @@ -46,7 +46,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { // DefaultGenesis returns default genesis state as raw bytes for the NFT module. func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { - return cdc.MustMarshalJSON(DefaultGenesisState()) + return cdc.MustMarshalJSON(types.DefaultGenesisState()) } // ValidateGenesis performs genesis state validation for the NFT module. @@ -59,10 +59,6 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod return types.ValidateGenesis(data) } -// RegisterRESTRoutes registers the REST routes for the NFT module. -func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { -} - // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the NFT module. func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { _ = types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) @@ -109,24 +105,31 @@ func (AppModule) Name() string { return types.ModuleName } // RegisterServices registers module services. func (am AppModule) RegisterServices(cfg module.Configurator) { - types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + types.RegisterMsgServer(cfg.MsgServer(), am.keeper) types.RegisterQueryServer(cfg.QueryServer(), am.keeper) + + m := keeper.NewMigrator(am.keeper) + if err := cfg.RegisterMigration(types.ModuleName, 1, m.Migrate1to2); err != nil { + panic(fmt.Sprintf("failed to migrate nft from version 1 to 2: %v", err)) + } } // RegisterInvariants registers the NFT module invariants. -func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {} +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + keeper.RegisterInvariants(ir, am.keeper) +} // Route returns the message routing key for the NFT module. func (am AppModule) Route() sdk.Route { - return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) + return sdk.Route{} } // QuerierRoute returns the NFT module's querier route name. -func (AppModule) QuerierRoute() string { return types.RouterKey } +func (AppModule) QuerierRoute() string { return "" } // LegacyQuerierHandler returns the NFT module sdk.Querier. -func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier { - return keeper.NewQuerier(am.keeper, legacyQuerierCdc) +func (am AppModule) LegacyQuerierHandler(_ *codec.LegacyAmino) sdk.Querier { + return nil } // InitGenesis performs genesis initialization for the NFT module. It returns @@ -136,26 +139,18 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json. cdc.MustUnmarshalJSON(data, &genesisState) - InitGenesis(ctx, am.keeper, genesisState) + am.keeper.InitGenesis(ctx, genesisState) return []abci.ValidatorUpdate{} } // ExportGenesis returns the exported genesis state as raw bytes for the NFT module. func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { - gs := ExportGenesis(ctx, am.keeper) + gs := am.keeper.ExportGenesis(ctx) return cdc.MustMarshalJSON(gs) } // ConsensusVersion implements AppModule/ConsensusVersion. -func (AppModule) ConsensusVersion() uint64 { return 1 } - -// BeginBlock performs a no-op. -func (AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} - -// EndBlock returns the end blocker for the NFT module. It returns no validator updates. -func (AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { - return []abci.ValidatorUpdate{} -} +func (AppModule) ConsensusVersion() uint64 { return 2 } // ____________________________________________________________________________ @@ -178,7 +173,7 @@ func (AppModule) RandomizedParams(r *rand.Rand) []simtypes.ParamChange { // RegisterStoreDecoder registers a decoder for NFT module's types func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) { - sdr[types.StoreKey] = simulation.NewDecodeStore(am.cdc) + sdr[types.StoreKey] = sdkbftsim.NewDecodeStore(am.cdc) } // WeightedOperations returns the all the NFT module operations with their respective weights. diff --git a/modules/nft/simulation/decoder.go b/modules/nft/simulation/decoder.go deleted file mode 100644 index 2d0d56f6..00000000 --- a/modules/nft/simulation/decoder.go +++ /dev/null @@ -1,40 +0,0 @@ -package simulation - -import ( - "bytes" - "fmt" - - "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/types/kv" - - "github.com/irisnet/irismod/modules/nft/types" -) - -// DecodeStore unmarshals the KVPair's Value to the corresponding gov type -func NewDecodeStore(cdc codec.Codec) func(kvA, kvB kv.Pair) string { - return func(kvA, kvB kv.Pair) string { - switch { - case bytes.Equal(kvA.Key[:1], types.PrefixNFT): - var nftA, nftB types.BaseNFT - cdc.MustUnmarshal(kvA.Value, &nftA) - cdc.MustUnmarshal(kvB.Value, &nftB) - return fmt.Sprintf("%v\n%v", nftA, nftB) - case bytes.Equal(kvA.Key[:1], types.PrefixOwners): - idA := types.MustUnMarshalTokenID(cdc, kvA.Value) - idB := types.MustUnMarshalTokenID(cdc, kvB.Value) - return fmt.Sprintf("%v\n%v", idA, idB) - case bytes.Equal(kvA.Key[:1], types.PrefixCollection): - supplyA := types.MustUnMarshalSupply(cdc, kvA.Value) - supplyB := types.MustUnMarshalSupply(cdc, kvB.Value) - return fmt.Sprintf("%d\n%d", supplyA, supplyB) - case bytes.Equal(kvA.Key[:1], types.PrefixDenom): - var denomA, denomB types.Denom - cdc.MustUnmarshal(kvA.Value, &denomA) - cdc.MustUnmarshal(kvB.Value, &denomB) - return fmt.Sprintf("%v\n%v", denomA, denomB) - - default: - panic(fmt.Sprintf("invalid %s key prefix %X", types.ModuleName, kvA.Key[:1])) - } - } -} diff --git a/modules/nft/simulation/genesis.go b/modules/nft/simulation/genesis.go index 1565dd55..4e3fc7cb 100644 --- a/modules/nft/simulation/genesis.go +++ b/modules/nft/simulation/genesis.go @@ -3,8 +3,6 @@ package simulation import ( "encoding/json" "fmt" - "math/rand" - "strings" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" @@ -44,7 +42,7 @@ func RandomizedGenState(simState *module.SimulationState) { // 10% of accounts own an NFT if simState.Rand.Intn(100) < 10 { baseNFT := types.NewBaseNFT( - RandnNFTID(simState.Rand, types.MinDenomLen, types.MaxDenomLen), // id + genNFTID(simState.Rand, types.MinDenomLen, types.MaxDenomLen), // id simtypes.RandStringOfLength(simState.Rand, 10), acc.Address, simtypes.RandStringOfLength(simState.Rand, 45), // tokenURI @@ -73,9 +71,3 @@ func RandomizedGenState(simState *module.SimulationState) { simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(nftGenesis) } - -func RandnNFTID(r *rand.Rand, min, max int) string { - n := simtypes.RandIntBetween(r, min, max) - id := simtypes.RandStringOfLength(r, n) - return strings.ToLower(id) -} diff --git a/modules/nft/simulation/operations.go b/modules/nft/simulation/operations.go index 3e8389f3..de06cc17 100644 --- a/modules/nft/simulation/operations.go +++ b/modules/nft/simulation/operations.go @@ -113,10 +113,9 @@ func SimulateMsgTransferNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, nftID := getRandomNFTFromOwner(ctx, k, r) + ownerAddr, denom, nftID := randNFT(ctx, k, r, false, true) if ownerAddr.Empty() { - err = fmt.Errorf("invalid account") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, "empty account"), nil, err } recipientAccount, _ := simtypes.RandomAcc(r, accs) @@ -145,7 +144,8 @@ func SimulateMsgTransferNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -159,7 +159,7 @@ func SimulateMsgTransferNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.Ba return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err } @@ -174,10 +174,9 @@ func SimulateMsgEditNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, nftID := getRandomNFTFromOwner(ctx, k, r) + ownerAddr, denom, nftID := randNFT(ctx, k, r, false, true) if ownerAddr.Empty() { - err = fmt.Errorf("account invalid") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditNFT, err.Error()), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditNFT, "empty account"), nil, err } msg := types.NewMsgEditNFT( @@ -204,7 +203,8 @@ func SimulateMsgEditNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -218,7 +218,7 @@ func SimulateMsgEditNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditNFT, err.Error()), nil, err } @@ -237,8 +237,8 @@ func SimulateMsgMintNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe randomRecipient, _ := simtypes.RandomAcc(r, accs) msg := types.NewMsgMintNFT( - RandnNFTID(r, types.MinDenomLen, types.MaxDenomLen), // nft ID - getRandomDenom(ctx, k, r), // denom + genNFTID(r, types.MinDenomLen, types.MaxDenomLen), // nft ID + randDenom(ctx, k, r, true, false), // denom "", simtypes.RandStringOfLength(r, 45), // tokenURI simtypes.RandStringOfLength(r, 32), // uriHash @@ -261,7 +261,8 @@ func SimulateMsgMintNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -275,7 +276,7 @@ func SimulateMsgMintNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeMintNFT, err.Error()), nil, err } @@ -290,10 +291,9 @@ func SimulateMsgBurnNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe ) ( opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - ownerAddr, denom, nftID := getRandomNFTFromOwner(ctx, k, r) + ownerAddr, denom, nftID := randNFT(ctx, k, r, false, false) if ownerAddr.Empty() { - err = fmt.Errorf("invalid account") - return simtypes.NoOpMsg(types.ModuleName, types.EventTypeBurnNFT, err.Error()), nil, err + return simtypes.NoOpMsg(types.ModuleName, types.EventTypeBurnNFT, "empty account"), nil, err } msg := types.NewMsgBurnNFT(ownerAddr.String(), nftID, denom) @@ -312,7 +312,8 @@ func SimulateMsgBurnNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -326,7 +327,7 @@ func SimulateMsgBurnNFT(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeEditNFT, err.Error()), nil, err } @@ -342,9 +343,9 @@ func SimulateMsgTransferDenom(k keeper.Keeper, ak types.AccountKeeper, bk types. opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - denomId := getRandomDenom(ctx, k, r) - denom, found := k.GetDenom(ctx, denomId) - if !found { + denomID := randDenom(ctx, k, r, false, false) + denom, err := k.GetDenomInfo(ctx, denomID) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, err.Error()), nil, err } @@ -360,7 +361,7 @@ func SimulateMsgTransferDenom(k keeper.Keeper, ak types.AccountKeeper, bk types. recipient, _ := simtypes.RandomAcc(r, accs) msg := types.NewMsgTransferDenom( - denomId, + denomID, denom.Creator, recipient.Address.String(), ) @@ -372,7 +373,8 @@ func SimulateMsgTransferDenom(k keeper.Keeper, ak types.AccountKeeper, bk types. } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -386,7 +388,7 @@ func SimulateMsgTransferDenom(k keeper.Keeper, ak types.AccountKeeper, bk types. return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err } @@ -402,36 +404,24 @@ func SimulateMsgIssueDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban opMsg simtypes.OperationMsg, fOps []simtypes.FutureOperation, err error, ) { - denomId := strings.ToLower(simtypes.RandStringOfLength(r, 10)) - denomName := strings.ToLower(simtypes.RandStringOfLength(r, 10)) - symbol := simtypes.RandStringOfLength(r, 5) - sender, _ := simtypes.RandomAcc(r, accs) - mintRestricted := genRandomBool(r) - updateRestricted := genRandomBool(r) - description := simtypes.RandStringOfLength(r, 10) - uri := simtypes.RandStringOfLength(r, 10) - uriHash := simtypes.RandStringOfLength(r, 32) - data := simtypes.RandStringOfLength(r, 20) - - if err := types.ValidateDenomID(denomId); err != nil { - return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, "invalid denom"), nil, nil - } - - denom, _ := k.GetDenom(ctx, denomId) - if denom.Size() != 0 { + denomID := genDenomID(r) + if k.HasDenom(ctx, denomID) { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgTransferDenom, "denom exist"), nil, nil } + sender, _ := simtypes.RandomAcc(r, accs) msg := types.NewMsgIssueDenom( - denomId, - denomName, + denomID, + strings.ToLower(simtypes.RandStringOfLength(r, 10)), "Schema", sender.Address.String(), - symbol, - mintRestricted, - updateRestricted, - description, - uri, uriHash, data, + simtypes.RandStringOfLength(r, 5), + genRandomBool(r), + genRandomBool(r), + simtypes.RandStringOfLength(r, 10), + simtypes.RandStringOfLength(r, 10), + simtypes.RandStringOfLength(r, 32), + simtypes.RandStringOfLength(r, 20), ) account := ak.GetAccount(ctx, sender.Address) spendable := bk.SpendableCoins(ctx, account.GetAddress()) @@ -441,7 +431,8 @@ func SimulateMsgIssueDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -455,7 +446,7 @@ func SimulateMsgIssueDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeTransfer, err.Error()), nil, err } @@ -463,45 +454,77 @@ func SimulateMsgIssueDenom(k keeper.Keeper, ak types.AccountKeeper, bk types.Ban } } -func getRandomNFTFromOwner(ctx sdk.Context, k keeper.Keeper, r *rand.Rand) (address sdk.AccAddress, denomID, tokenID string) { - owners := k.GetOwners(ctx) +func randNFT(ctx sdk.Context, k keeper.Keeper, r *rand.Rand, mintable, editable bool) (sdk.AccAddress, string, string) { + var denoms = []string{kitties, doggos} + res, err := k.Denoms(sdk.UnwrapSDKContext(ctx), &types.QueryDenomsRequest{}) - ownersLen := len(owners) - if ownersLen == 0 { - return nil, "", "" + if err == nil { + for _, d := range res.Denoms { + if mintable && !d.MintRestricted { + denoms = append(denoms, d.Id) + } + + if editable && !d.UpdateRestricted { + denoms = append(denoms, d.Id) + } + } } - // get random owner - i := r.Intn(ownersLen) - owner := owners[i] + idx := r.Intn(len(denoms)) - idCollectionsLen := len(owner.IDCollections) - if idCollectionsLen == 0 { + rndDenomID := denoms[idx] + nfts, err := k.GetNFTs(ctx, rndDenomID) + if err != nil || len(nfts) == 0 { return nil, "", "" } // get random collection from owner's balance - i = r.Intn(idCollectionsLen) - idCollection := owner.IDCollections[i] // nfts IDs - denomID = idCollection.DenomId + token := nfts[r.Intn(len(nfts))] + return token.GetOwner(), rndDenomID, token.GetID() +} - idsLen := len(idCollection.TokenIds) - if idsLen == 0 { - return nil, "", "" - } +func genDenomID(r *rand.Rand) string { + len := simtypes.RandIntBetween(r, types.MinDenomLen, types.MaxDenomLen) + var denomID string + for { + denomID = strings.ToLower(simtypes.RandStringOfLength(r, len)) + if err := types.ValidateDenomID(denomID); err != nil { + continue + } - // get random nft from collection - i = r.Intn(idsLen) - tokenID = idCollection.TokenIds[i] + if err := types.ValidateKeywords(denomID); err != nil { + continue + } + break + } + return denomID +} - ownerAddress, _ := sdk.AccAddressFromBech32(owner.Address) - return ownerAddress, denomID, tokenID +func genNFTID(r *rand.Rand, min, max int) string { + n := simtypes.RandIntBetween(r, min, max) + id := simtypes.RandStringOfLength(r, n) + return strings.ToLower(id) } -func getRandomDenom(ctx sdk.Context, k keeper.Keeper, r *rand.Rand) string { +func randDenom(ctx sdk.Context, k keeper.Keeper, r *rand.Rand, mintable, editable bool) string { + res, err := k.Denoms(sdk.UnwrapSDKContext(ctx), &types.QueryDenomsRequest{}) var denoms = []string{kitties, doggos} - i := r.Intn(len(denoms)) - return denoms[i] + if err != nil { + i := r.Intn(len(denoms)) + return denoms[i] + } + + for _, d := range res.Denoms { + if mintable && !d.MintRestricted { + denoms = append(denoms, d.Id) + } + + if editable && !d.UpdateRestricted { + denoms = append(denoms, d.Id) + } + } + idx := r.Intn(len(denoms)) + return denoms[idx] } func genRandomBool(r *rand.Rand) bool { diff --git a/modules/nft/types/codec.go b/modules/nft/types/codec.go index 02b9eb82..e4bb624c 100644 --- a/modules/nft/types/codec.go +++ b/modules/nft/types/codec.go @@ -3,8 +3,6 @@ package types // DONTCOVER import ( - gogotypes "github.com/gogo/protobuf/types" - "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" @@ -56,29 +54,3 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } - -// return supply protobuf code -func MustMarshalSupply(cdc codec.Codec, supply uint64) []byte { - supplyWrap := gogotypes.UInt64Value{Value: supply} - return cdc.MustMarshal(&supplyWrap) -} - -// return th supply -func MustUnMarshalSupply(cdc codec.Codec, value []byte) uint64 { - var supplyWrap gogotypes.UInt64Value - cdc.MustUnmarshal(value, &supplyWrap) - return supplyWrap.Value -} - -// return the tokenID protobuf code -func MustMarshalTokenID(cdc codec.Codec, tokenID string) []byte { - tokenIDWrap := gogotypes.StringValue{Value: tokenID} - return cdc.MustMarshal(&tokenIDWrap) -} - -// return th tokenID -func MustUnMarshalTokenID(cdc codec.Codec, value []byte) string { - var tokenIDWrap gogotypes.StringValue - cdc.MustUnmarshal(value, &tokenIDWrap) - return tokenIDWrap.Value -} diff --git a/modules/nft/types/common_test.go b/modules/nft/types/common_test.go index debd6347..817a988e 100644 --- a/modules/nft/types/common_test.go +++ b/modules/nft/types/common_test.go @@ -31,7 +31,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string buffer.WriteString(numString) //adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) bech := res.String() addresses = append(addresses, testAddr(buffer.String(), bech)) buffer.Reset() @@ -41,7 +41,7 @@ func CreateTestAddrs(numAddrs int) []sdk.AccAddress { // for incode address generation func testAddr(addr string, bech string) sdk.AccAddress { - res, err := sdk.AccAddressFromHex(addr) + res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { panic(err) } diff --git a/modules/nft/types/denom.go b/modules/nft/types/denom.go deleted file mode 100644 index 3b6b0eea..00000000 --- a/modules/nft/types/denom.go +++ /dev/null @@ -1,26 +0,0 @@ -package types - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NewDenom return a new denom -func NewDenom( - id, name, schema, symbol, description, uri, uriHash, data string, - creator sdk.AccAddress, - mintRestricted, updateRestricted bool, -) Denom { - return Denom{ - Id: id, - Name: name, - Schema: schema, - Creator: creator.String(), - Symbol: symbol, - MintRestricted: mintRestricted, - UpdateRestricted: updateRestricted, - Description: description, - Uri: uri, - UriHash: uriHash, - Data: data, - } -} diff --git a/modules/nft/types/errors.go b/modules/nft/types/errors.go index a95c404c..e5f77082 100644 --- a/modules/nft/types/errors.go +++ b/modules/nft/types/errors.go @@ -5,14 +5,14 @@ import ( ) var ( - ErrInvalidCollection = sdkerrors.Register(ModuleName, 2, "invalid nft collection") - ErrUnknownCollection = sdkerrors.Register(ModuleName, 3, "unknown nft collection") - ErrInvalidNFT = sdkerrors.Register(ModuleName, 4, "invalid nft") - ErrNFTAlreadyExists = sdkerrors.Register(ModuleName, 5, "nft already exists") - ErrUnknownNFT = sdkerrors.Register(ModuleName, 6, "unknown nft") - ErrEmptyTokenData = sdkerrors.Register(ModuleName, 7, "nft data can't be empty") - ErrUnauthorized = sdkerrors.Register(ModuleName, 8, "unauthorized address") - ErrInvalidDenom = sdkerrors.Register(ModuleName, 9, "invalid denom") - ErrInvalidTokenID = sdkerrors.Register(ModuleName, 10, "invalid nft id") - ErrInvalidTokenURI = sdkerrors.Register(ModuleName, 11, "invalid nft uri") + ErrInvalidCollection = sdkerrors.Register(ModuleName, 9, "invalid nft collection") + ErrUnknownCollection = sdkerrors.Register(ModuleName, 10, "unknown nft collection") + ErrInvalidNFT = sdkerrors.Register(ModuleName, 11, "invalid nft") + ErrNFTAlreadyExists = sdkerrors.Register(ModuleName, 12, "nft already exists") + ErrUnknownNFT = sdkerrors.Register(ModuleName, 13, "unknown nft") + ErrEmptyTokenData = sdkerrors.Register(ModuleName, 14, "nft data can't be empty") + ErrUnauthorized = sdkerrors.Register(ModuleName, 15, "unauthorized address") + ErrInvalidDenom = sdkerrors.Register(ModuleName, 16, "invalid denom") + ErrInvalidTokenID = sdkerrors.Register(ModuleName, 17, "invalid nft id") + ErrInvalidTokenURI = sdkerrors.Register(ModuleName, 18, "invalid nft uri") ) diff --git a/modules/nft/types/genesis.go b/modules/nft/types/genesis.go index 6e71b336..d24a46c8 100644 --- a/modules/nft/types/genesis.go +++ b/modules/nft/types/genesis.go @@ -11,6 +11,11 @@ func NewGenesisState(collections []Collection) *GenesisState { } } +// DefaultGenesisState returns a default genesis state +func DefaultGenesisState() *GenesisState { + return NewGenesisState([]Collection{}) +} + // ValidateGenesis performs basic validation of nfts genesis data returning an // error for any failed validation criteria. func ValidateGenesis(data GenesisState) error { diff --git a/modules/nft/types/keys.go b/modules/nft/types/keys.go index 91f96278..d1b6fcda 100644 --- a/modules/nft/types/keys.go +++ b/modules/nft/types/keys.go @@ -1,12 +1,5 @@ package types -import ( - "bytes" - "errors" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - const ( // ModuleName is the name of the module ModuleName = "nft" @@ -20,89 +13,3 @@ const ( // RouterKey is the message route for the NFT module RouterKey = ModuleName ) - -var ( - PrefixNFT = []byte{0x01} - PrefixOwners = []byte{0x02} // key for a owner - PrefixCollection = []byte{0x03} // key for balance of NFTs held by the denom - PrefixDenom = []byte{0x04} // key for denom of the nft - PrefixDenomName = []byte{0x05} // key for denom name of the nft - - delimiter = []byte("/") -) - -// SplitKeyOwner return the address,denom,id from the key of stored owner -func SplitKeyOwner(key []byte) (address sdk.AccAddress, denomID, tokenID string, err error) { - key = key[len(PrefixOwners)+len(delimiter):] - keys := bytes.Split(key, delimiter) - if len(keys) != 3 { - return address, denomID, tokenID, errors.New("wrong KeyBalance") - } - - address, _ = sdk.AccAddressFromBech32(string(keys[0])) - denomID = string(keys[1]) - tokenID = string(keys[2]) - return -} - -func SplitKeyDenom(key []byte) (denomID, tokenID string, err error) { - keys := bytes.Split(key, delimiter) - if len(keys) != 2 { - return denomID, tokenID, errors.New("wrong KeyBalance") - } - - denomID = string(keys[0]) - tokenID = string(keys[1]) - return -} - -// KeyBalance gets the key of a collection owned by an account address -func KeyOwner(address sdk.AccAddress, denomID, tokenID string) []byte { - key := append(PrefixOwners, delimiter...) - if address != nil { - key = append(key, []byte(address.String())...) - key = append(key, delimiter...) - } - - if address != nil && len(denomID) > 0 { - key = append(key, []byte(denomID)...) - key = append(key, delimiter...) - } - - if address != nil && len(denomID) > 0 && len(tokenID) > 0 { - key = append(key, []byte(tokenID)...) - } - return key -} - -// KeyNFT gets the key of nft stored by an denom and id -func KeyNFT(denomID, tokenID string) []byte { - key := append(PrefixNFT, delimiter...) - if len(denomID) > 0 { - key = append(key, []byte(denomID)...) - key = append(key, delimiter...) - } - - if len(denomID) > 0 && len(tokenID) > 0 { - key = append(key, []byte(tokenID)...) - } - return key -} - -// KeyCollection gets the storeKey by the collection -func KeyCollection(denomID string) []byte { - key := append(PrefixCollection, delimiter...) - return append(key, []byte(denomID)...) -} - -// KeyDenom gets the storeKey by the denom id -func KeyDenomID(id string) []byte { - key := append(PrefixDenom, delimiter...) - return append(key, []byte(id)...) -} - -// KeyDenomName gets the storeKey by the denom name -func KeyDenomName(name string) []byte { - key := append(PrefixDenomName, delimiter...) - return append(key, []byte(name)...) -} diff --git a/modules/nft/types/nft.go b/modules/nft/types/nft.go index 17aa88c6..bf5457eb 100644 --- a/modules/nft/types/nft.go +++ b/modules/nft/types/nft.go @@ -56,11 +56,3 @@ func (bnft BaseNFT) GetData() string { // NFTs define a list of NFT type NFTs []exported.NFT - -// NewNFTs creates a new set of NFTs -func NewNFTs(nfts ...exported.NFT) NFTs { - if len(nfts) == 0 { - return NFTs{} - } - return NFTs(nfts) -} diff --git a/modules/nft/types/nft.pb.go b/modules/nft/types/nft.pb.go index 50e22c75..db8953af 100644 --- a/modules/nft/types/nft.pb.go +++ b/modules/nft/types/nft.pb.go @@ -66,6 +66,44 @@ func (m *BaseNFT) XXX_DiscardUnknown() { var xxx_messageInfo_BaseNFT proto.InternalMessageInfo +type NFTMetadata struct { + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Data string `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *NFTMetadata) Reset() { *m = NFTMetadata{} } +func (m *NFTMetadata) String() string { return proto.CompactTextString(m) } +func (*NFTMetadata) ProtoMessage() {} +func (*NFTMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_fe8ab7e15b7f0646, []int{1} +} +func (m *NFTMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NFTMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NFTMetadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *NFTMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_NFTMetadata.Merge(m, src) +} +func (m *NFTMetadata) XXX_Size() int { + return m.Size() +} +func (m *NFTMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_NFTMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_NFTMetadata proto.InternalMessageInfo + // Denom defines a type of NFT type Denom struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` @@ -85,7 +123,7 @@ func (m *Denom) Reset() { *m = Denom{} } func (m *Denom) String() string { return proto.CompactTextString(m) } func (*Denom) ProtoMessage() {} func (*Denom) Descriptor() ([]byte, []int) { - return fileDescriptor_fe8ab7e15b7f0646, []int{1} + return fileDescriptor_fe8ab7e15b7f0646, []int{2} } func (m *Denom) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -114,6 +152,47 @@ func (m *Denom) XXX_DiscardUnknown() { var xxx_messageInfo_Denom proto.InternalMessageInfo +type DenomMetadata struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + Schema string `protobuf:"bytes,2,opt,name=schema,proto3" json:"schema,omitempty"` + MintRestricted bool `protobuf:"varint,3,opt,name=mint_restricted,json=mintRestricted,proto3" json:"mint_restricted,omitempty"` + UpdateRestricted bool `protobuf:"varint,4,opt,name=update_restricted,json=updateRestricted,proto3" json:"update_restricted,omitempty"` + Data string `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *DenomMetadata) Reset() { *m = DenomMetadata{} } +func (m *DenomMetadata) String() string { return proto.CompactTextString(m) } +func (*DenomMetadata) ProtoMessage() {} +func (*DenomMetadata) Descriptor() ([]byte, []int) { + return fileDescriptor_fe8ab7e15b7f0646, []int{3} +} +func (m *DenomMetadata) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *DenomMetadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_DenomMetadata.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *DenomMetadata) XXX_Merge(src proto.Message) { + xxx_messageInfo_DenomMetadata.Merge(m, src) +} +func (m *DenomMetadata) XXX_Size() int { + return m.Size() +} +func (m *DenomMetadata) XXX_DiscardUnknown() { + xxx_messageInfo_DenomMetadata.DiscardUnknown(m) +} + +var xxx_messageInfo_DenomMetadata proto.InternalMessageInfo + // IDCollection defines a type of collection with specified ID type IDCollection struct { DenomId string `protobuf:"bytes,1,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty" yaml:"denom_id"` @@ -124,7 +203,7 @@ func (m *IDCollection) Reset() { *m = IDCollection{} } func (m *IDCollection) String() string { return proto.CompactTextString(m) } func (*IDCollection) ProtoMessage() {} func (*IDCollection) Descriptor() ([]byte, []int) { - return fileDescriptor_fe8ab7e15b7f0646, []int{2} + return fileDescriptor_fe8ab7e15b7f0646, []int{4} } func (m *IDCollection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -163,7 +242,7 @@ func (m *Owner) Reset() { *m = Owner{} } func (m *Owner) String() string { return proto.CompactTextString(m) } func (*Owner) ProtoMessage() {} func (*Owner) Descriptor() ([]byte, []int) { - return fileDescriptor_fe8ab7e15b7f0646, []int{3} + return fileDescriptor_fe8ab7e15b7f0646, []int{5} } func (m *Owner) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -202,7 +281,7 @@ func (m *Collection) Reset() { *m = Collection{} } func (m *Collection) String() string { return proto.CompactTextString(m) } func (*Collection) ProtoMessage() {} func (*Collection) Descriptor() ([]byte, []int) { - return fileDescriptor_fe8ab7e15b7f0646, []int{4} + return fileDescriptor_fe8ab7e15b7f0646, []int{6} } func (m *Collection) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -233,7 +312,9 @@ var xxx_messageInfo_Collection proto.InternalMessageInfo func init() { proto.RegisterType((*BaseNFT)(nil), "irismod.nft.BaseNFT") + proto.RegisterType((*NFTMetadata)(nil), "irismod.nft.NFTMetadata") proto.RegisterType((*Denom)(nil), "irismod.nft.Denom") + proto.RegisterType((*DenomMetadata)(nil), "irismod.nft.DenomMetadata") proto.RegisterType((*IDCollection)(nil), "irismod.nft.IDCollection") proto.RegisterType((*Owner)(nil), "irismod.nft.Owner") proto.RegisterType((*Collection)(nil), "irismod.nft.Collection") @@ -242,43 +323,47 @@ func init() { func init() { proto.RegisterFile("nft/nft.proto", fileDescriptor_fe8ab7e15b7f0646) } var fileDescriptor_fe8ab7e15b7f0646 = []byte{ - // 576 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x53, 0xbd, 0x8e, 0xd3, 0x4c, - 0x14, 0x8d, 0x13, 0x67, 0x9d, 0x5c, 0xef, 0xdf, 0x37, 0x5f, 0x84, 0x1c, 0x0a, 0x3b, 0xb2, 0x90, - 0x58, 0x09, 0x64, 0x8b, 0x45, 0xa2, 0xd8, 0xd2, 0xac, 0x56, 0x84, 0x62, 0x91, 0xac, 0xa5, 0xa1, - 0x89, 0x1c, 0xcf, 0x24, 0x19, 0x11, 0x7b, 0xa2, 0x99, 0xb1, 0x56, 0xe1, 0x25, 0x40, 0xe2, 0x05, - 0x78, 0x08, 0x1e, 0x22, 0xe5, 0x96, 0x54, 0x16, 0x24, 0x0d, 0x75, 0x9e, 0x00, 0x79, 0xec, 0x04, - 0xa7, 0xa3, 0xbb, 0xf7, 0xdc, 0xe3, 0x39, 0xc7, 0x67, 0xe6, 0xc2, 0x49, 0x3a, 0x91, 0x7e, 0x3a, - 0x91, 0xde, 0x82, 0x33, 0xc9, 0x90, 0x49, 0x39, 0x15, 0x09, 0xc3, 0x5e, 0x3a, 0x91, 0x8f, 0x7b, - 0x53, 0x36, 0x65, 0x0a, 0xf7, 0x8b, 0xaa, 0xa4, 0xb8, 0x5f, 0x35, 0x30, 0x82, 0x48, 0x90, 0xdb, - 0x9b, 0x3b, 0x74, 0x0a, 0x4d, 0x8a, 0x2d, 0x6d, 0xa0, 0x5d, 0x74, 0xc3, 0x26, 0xc5, 0x08, 0x81, - 0x9e, 0x46, 0x09, 0xb1, 0x9a, 0x0a, 0x51, 0x35, 0xea, 0x43, 0x2b, 0xe3, 0xd4, 0x6a, 0x15, 0x50, - 0x60, 0xac, 0x73, 0xa7, 0xf5, 0x3e, 0x1c, 0x86, 0x05, 0x56, 0xd0, 0x71, 0x24, 0x23, 0x4b, 0x2f, - 0xe9, 0x45, 0x8d, 0x7a, 0xd0, 0x66, 0xf7, 0x29, 0xe1, 0x56, 0x5b, 0x81, 0x65, 0x83, 0xfa, 0xd0, - 0xc9, 0x38, 0x1d, 0xcd, 0x22, 0x31, 0xb3, 0x8e, 0xd4, 0xc0, 0xc8, 0x38, 0x7d, 0x13, 0x89, 0xd9, - 0x95, 0xfe, 0xfb, 0x9b, 0xa3, 0xb9, 0xdf, 0x9b, 0xd0, 0xbe, 0x26, 0x29, 0x4b, 0xfe, 0xc9, 0xd3, - 0x23, 0x38, 0x12, 0xf1, 0x8c, 0x24, 0x51, 0x69, 0x2b, 0xac, 0x3a, 0x64, 0x81, 0x11, 0x73, 0x12, - 0x49, 0xc6, 0x2b, 0x4f, 0xbb, 0x56, 0x7d, 0xb1, 0x4c, 0xc6, 0x6c, 0x5e, 0xf9, 0xaa, 0x3a, 0xf4, - 0x14, 0xce, 0x12, 0x9a, 0xca, 0x11, 0x27, 0x42, 0x72, 0x1a, 0x4b, 0x82, 0x95, 0xbf, 0x4e, 0x78, - 0x5a, 0xc0, 0xe1, 0x1e, 0x45, 0xcf, 0xe0, 0xbf, 0x6c, 0x81, 0x23, 0x49, 0xea, 0x54, 0x43, 0x51, - 0xcf, 0xcb, 0x41, 0x8d, 0x3c, 0x00, 0x13, 0x13, 0x11, 0x73, 0xba, 0x90, 0x94, 0xa5, 0x56, 0x47, - 0x49, 0xd6, 0x21, 0x74, 0x5e, 0xa6, 0xda, 0x55, 0x13, 0x15, 0x66, 0x3d, 0x22, 0x38, 0x88, 0x68, - 0x9f, 0xb3, 0xf9, 0x37, 0xe7, 0x2a, 0xb6, 0x7b, 0x38, 0x1e, 0x5e, 0xbf, 0x66, 0xf3, 0x39, 0x89, - 0xd5, 0xb1, 0x1e, 0x74, 0x70, 0x91, 0xe2, 0x68, 0x17, 0x61, 0xf0, 0xff, 0x36, 0x77, 0xce, 0x96, - 0x51, 0x32, 0xbf, 0x72, 0x77, 0x13, 0x37, 0x34, 0x54, 0x39, 0xc4, 0xe8, 0x05, 0x74, 0x25, 0xfb, - 0x48, 0xd2, 0x11, 0xc5, 0xc2, 0x6a, 0x0e, 0x5a, 0x17, 0xdd, 0xa0, 0xb7, 0xcd, 0x9d, 0xf3, 0xf2, - 0x83, 0xfd, 0xc8, 0x0d, 0x3b, 0xaa, 0x1e, 0x62, 0x51, 0x09, 0x7f, 0xd6, 0xa0, 0xfd, 0x4e, 0x5d, - 0xad, 0x05, 0x46, 0x84, 0x31, 0x27, 0x42, 0x54, 0x97, 0xb6, 0x6b, 0xd1, 0x04, 0x4e, 0x29, 0x1e, - 0xc5, 0x7b, 0x77, 0xa5, 0x82, 0x79, 0xd9, 0xf7, 0x6a, 0xaf, 0xd4, 0xab, 0xfb, 0x0f, 0x9e, 0xac, - 0x72, 0xa7, 0xb1, 0xce, 0x9d, 0x93, 0x3a, 0x2a, 0xb6, 0xb9, 0x63, 0x96, 0x8e, 0x28, 0x8e, 0x85, - 0x1b, 0x9e, 0x50, 0x5c, 0x9b, 0x56, 0x8e, 0x3e, 0x01, 0x1c, 0x04, 0xd1, 0x56, 0xff, 0xa8, 0x3c, - 0x99, 0x97, 0xe8, 0x40, 0x52, 0x3d, 0xb4, 0x40, 0x2f, 0xb4, 0xc2, 0x92, 0x86, 0x5e, 0x81, 0x9e, - 0x4e, 0xe4, 0xce, 0x61, 0xef, 0x80, 0x5e, 0x6d, 0x4b, 0x70, 0x5c, 0x99, 0xd3, 0x6f, 0x6f, 0xee, - 0x44, 0xa8, 0xf8, 0xa5, 0x76, 0xf0, 0x76, 0xf5, 0xcb, 0x6e, 0xac, 0xd6, 0xb6, 0xf6, 0xb0, 0xb6, - 0xb5, 0x9f, 0x6b, 0x5b, 0xfb, 0xb2, 0xb1, 0x1b, 0x0f, 0x1b, 0xbb, 0xf1, 0x63, 0x63, 0x37, 0x3e, - 0x3c, 0x9f, 0x52, 0x39, 0xcb, 0xc6, 0x5e, 0xcc, 0x12, 0xbf, 0x38, 0x37, 0x25, 0xd2, 0xaf, 0xce, - 0xf7, 0x13, 0x86, 0xb3, 0x39, 0x11, 0xc5, 0x0a, 0xfb, 0x72, 0xb9, 0x20, 0x62, 0x7c, 0xa4, 0xd6, - 0xf4, 0xe5, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x64, 0x01, 0xda, 0xf2, 0xda, 0x03, 0x00, 0x00, + // 635 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0xc1, 0x6e, 0xd3, 0x4c, + 0x10, 0x8e, 0x1d, 0xa7, 0x4e, 0xc6, 0x4d, 0xdb, 0x7f, 0xff, 0x08, 0xb9, 0x1c, 0xec, 0x2a, 0x42, + 0xa2, 0x12, 0x28, 0x11, 0x45, 0xe2, 0x50, 0x6e, 0xa6, 0xaa, 0x08, 0x12, 0x45, 0xb2, 0xca, 0x85, + 0x4b, 0xb4, 0xf5, 0x6e, 0x9a, 0x15, 0xb1, 0x37, 0xda, 0xdd, 0xa8, 0x2a, 0x2f, 0x01, 0x12, 0x2f, + 0xc0, 0x2b, 0x20, 0xf1, 0x10, 0x3d, 0xf6, 0xc8, 0x29, 0x82, 0xf4, 0xc2, 0xb9, 0x4f, 0x80, 0xbc, + 0x6b, 0x07, 0x47, 0x01, 0xa9, 0xb7, 0x99, 0x6f, 0xbe, 0xdd, 0xf9, 0xe6, 0x1b, 0x7b, 0xa1, 0x9d, + 0x8d, 0x54, 0x3f, 0x1b, 0xa9, 0xde, 0x54, 0x70, 0xc5, 0x91, 0xc7, 0x04, 0x93, 0x29, 0x27, 0xbd, + 0x6c, 0xa4, 0xee, 0x77, 0xce, 0xf9, 0x39, 0xd7, 0x78, 0x3f, 0x8f, 0x0c, 0xa5, 0xfb, 0xd9, 0x02, + 0x37, 0xc2, 0x92, 0x9e, 0x1c, 0x9f, 0xa2, 0x2d, 0xb0, 0x19, 0xf1, 0xad, 0x3d, 0x6b, 0xbf, 0x15, + 0xdb, 0x8c, 0x20, 0x04, 0x4e, 0x86, 0x53, 0xea, 0xdb, 0x1a, 0xd1, 0x31, 0xda, 0x85, 0xfa, 0x4c, + 0x30, 0xbf, 0x9e, 0x43, 0x91, 0xbb, 0x98, 0x87, 0xf5, 0xb7, 0xf1, 0x20, 0xce, 0xb1, 0x9c, 0x4e, + 0xb0, 0xc2, 0xbe, 0x63, 0xe8, 0x79, 0x8c, 0x3a, 0xd0, 0xe0, 0x17, 0x19, 0x15, 0x7e, 0x43, 0x83, + 0x26, 0x41, 0xbb, 0xd0, 0x9c, 0x09, 0x36, 0x1c, 0x63, 0x39, 0xf6, 0x37, 0x74, 0xc1, 0x9d, 0x09, + 0xf6, 0x12, 0xcb, 0xf1, 0xa1, 0xf3, 0xeb, 0x4b, 0x68, 0x75, 0x9f, 0x83, 0x77, 0x72, 0x7c, 0xfa, + 0x9a, 0x2a, 0xac, 0x6f, 0x29, 0x85, 0x58, 0x15, 0x21, 0x65, 0x37, 0xfb, 0x4f, 0xb7, 0xe2, 0xf0, + 0x37, 0x1b, 0x1a, 0x47, 0x34, 0xe3, 0xe9, 0x9d, 0x06, 0xba, 0x07, 0x1b, 0x32, 0x19, 0xd3, 0x14, + 0x9b, 0x99, 0xe2, 0x22, 0x43, 0x3e, 0xb8, 0x89, 0xa0, 0x58, 0x71, 0x51, 0x0c, 0x54, 0xa6, 0xfa, + 0xc4, 0x65, 0x7a, 0xc6, 0x27, 0xc5, 0x50, 0x45, 0x86, 0x1e, 0xc2, 0x76, 0xca, 0x32, 0x35, 0x14, + 0x54, 0x2a, 0xc1, 0x12, 0x45, 0x89, 0x1e, 0xae, 0x19, 0x6f, 0xe5, 0x70, 0xbc, 0x44, 0xd1, 0x23, + 0xf8, 0x6f, 0x36, 0x25, 0x58, 0xd1, 0x2a, 0xd5, 0xd5, 0xd4, 0x1d, 0x53, 0xa8, 0x90, 0xf7, 0xc0, + 0x23, 0x54, 0x26, 0x82, 0x4d, 0x15, 0xe3, 0x99, 0xdf, 0xd4, 0x2d, 0xab, 0x10, 0xda, 0x31, 0x2b, + 0x69, 0xe9, 0x8a, 0xde, 0x44, 0xd5, 0x5f, 0x58, 0xf1, 0x77, 0x69, 0x9b, 0xb7, 0x66, 0xdb, 0x57, + 0x0b, 0xda, 0xda, 0xb6, 0xa5, 0xed, 0x15, 0x0b, 0xac, 0x75, 0x0b, 0x8c, 0x69, 0xf6, 0x8a, 0x69, + 0x7f, 0xb1, 0xa0, 0x7e, 0x77, 0x0b, 0x9c, 0x7f, 0x58, 0x50, 0x6a, 0x6e, 0xac, 0x69, 0xbe, 0x80, + 0xcd, 0xc1, 0xd1, 0x0b, 0x3e, 0x99, 0xd0, 0x44, 0x5b, 0xd1, 0x83, 0x26, 0xc9, 0x47, 0x18, 0x96, + 0x6b, 0x8f, 0xfe, 0xbf, 0x9d, 0x87, 0xdb, 0x97, 0x38, 0x9d, 0x1c, 0x76, 0xcb, 0x4a, 0x37, 0x76, + 0x75, 0x38, 0x20, 0xe8, 0x09, 0xb4, 0x14, 0x7f, 0x4f, 0xb3, 0x21, 0x23, 0xd2, 0xb7, 0xf7, 0xea, + 0xfb, 0xad, 0xa8, 0x73, 0x3b, 0x0f, 0x77, 0xcc, 0x81, 0x65, 0xa9, 0x1b, 0x37, 0x75, 0x3c, 0x20, + 0xb2, 0x68, 0xfc, 0xd1, 0x82, 0xc6, 0x1b, 0xfd, 0x2d, 0xfb, 0xe0, 0x62, 0x42, 0x04, 0x95, 0xb2, + 0x34, 0xa9, 0x48, 0xd1, 0x08, 0xb6, 0x18, 0x19, 0x26, 0x4b, 0x75, 0xa6, 0x83, 0x77, 0xb0, 0xdb, + 0xab, 0xfc, 0x96, 0xbd, 0xaa, 0xfe, 0xe8, 0xc1, 0xd5, 0x3c, 0xac, 0x2d, 0xe6, 0x61, 0xbb, 0x8a, + 0xca, 0xdb, 0x79, 0xe8, 0x19, 0x45, 0x8c, 0x24, 0xb2, 0x1b, 0xb7, 0x19, 0xa9, 0x54, 0x0b, 0x45, + 0x1f, 0x00, 0x56, 0x8c, 0x68, 0xe8, 0x19, 0xb5, 0x26, 0xef, 0x00, 0xad, 0xb4, 0xd4, 0x5b, 0x8e, + 0x9c, 0xbc, 0x57, 0x6c, 0x68, 0xe8, 0x19, 0x38, 0xd9, 0x48, 0x95, 0x0a, 0x3b, 0x2b, 0xf4, 0xe2, + 0x79, 0x88, 0x36, 0x0b, 0x71, 0xce, 0xc9, 0xf1, 0xa9, 0x8c, 0x35, 0xdf, 0xf4, 0x8e, 0x5e, 0x5d, + 0xfd, 0x0c, 0x6a, 0x57, 0x8b, 0xc0, 0xba, 0x5e, 0x04, 0xd6, 0x8f, 0x45, 0x60, 0x7d, 0xba, 0x09, + 0x6a, 0xd7, 0x37, 0x41, 0xed, 0xfb, 0x4d, 0x50, 0x7b, 0xf7, 0xf8, 0x9c, 0xa9, 0xf1, 0xec, 0xac, + 0x97, 0xf0, 0xb4, 0x9f, 0xdf, 0x9b, 0x51, 0xd5, 0x2f, 0xee, 0xef, 0xa7, 0x9c, 0xcc, 0x26, 0x54, + 0xe6, 0x6f, 0x56, 0x5f, 0x5d, 0x4e, 0xa9, 0x3c, 0xdb, 0xd0, 0xef, 0xd2, 0xd3, 0xdf, 0x01, 0x00, + 0x00, 0xff, 0xff, 0x4a, 0x49, 0x33, 0x49, 0xcb, 0x04, 0x00, 0x00, } func (this *BaseNFT) Equal(that interface{}) bool { @@ -320,6 +405,33 @@ func (this *BaseNFT) Equal(that interface{}) bool { } return true } +func (this *NFTMetadata) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*NFTMetadata) + if !ok { + that2, ok := that.(NFTMetadata) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Data != that1.Data { + return false + } + return true +} func (this *Denom) Equal(that interface{}) bool { if that == nil { return this == nil @@ -374,6 +486,42 @@ func (this *Denom) Equal(that interface{}) bool { } return true } +func (this *DenomMetadata) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*DenomMetadata) + if !ok { + that2, ok := that.(DenomMetadata) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Creator != that1.Creator { + return false + } + if this.Schema != that1.Schema { + return false + } + if this.MintRestricted != that1.MintRestricted { + return false + } + if this.UpdateRestricted != that1.UpdateRestricted { + return false + } + if this.Data != that1.Data { + return false + } + return true +} func (this *IDCollection) Equal(that interface{}) bool { if that == nil { return this == nil @@ -535,6 +683,43 @@ func (m *BaseNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *NFTMetadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *NFTMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NFTMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintNft(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x12 + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintNft(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *Denom) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -641,6 +826,70 @@ func (m *Denom) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *DenomMetadata) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *DenomMetadata) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *DenomMetadata) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintNft(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x2a + } + if m.UpdateRestricted { + i-- + if m.UpdateRestricted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x20 + } + if m.MintRestricted { + i-- + if m.MintRestricted { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } + if len(m.Schema) > 0 { + i -= len(m.Schema) + copy(dAtA[i:], m.Schema) + i = encodeVarintNft(dAtA, i, uint64(len(m.Schema))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintNft(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *IDCollection) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -815,6 +1064,23 @@ func (m *BaseNFT) Size() (n int) { return n } +func (m *NFTMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + return n +} + func (m *Denom) Size() (n int) { if m == nil { return 0 @@ -866,6 +1132,33 @@ func (m *Denom) Size() (n int) { return n } +func (m *DenomMetadata) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + l = len(m.Schema) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + if m.MintRestricted { + n += 2 + } + if m.UpdateRestricted { + n += 2 + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovNft(uint64(l)) + } + return n +} + func (m *IDCollection) Size() (n int) { if m == nil { return 0 @@ -1169,7 +1462,7 @@ func (m *BaseNFT) Unmarshal(dAtA []byte) error { } return nil } -func (m *Denom) Unmarshal(dAtA []byte) error { +func (m *NFTMetadata) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1192,15 +1485,15 @@ func (m *Denom) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Denom: wiretype end group for non-group") + return fmt.Errorf("proto: NFTMetadata: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Denom: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: NFTMetadata: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1228,11 +1521,11 @@ func (m *Denom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Id = string(dAtA[iNdEx:postIndex]) + m.Name = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1260,11 +1553,125 @@ func (m *Denom) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Name = string(dAtA[iNdEx:postIndex]) + m.Data = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + default: + iNdEx = preIndex + skippy, err := skipNft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *Denom) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Denom: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Denom: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1547,6 +1954,192 @@ func (m *Denom) Unmarshal(dAtA []byte) error { } return nil } +func (m *DenomMetadata) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: DenomMetadata: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: DenomMetadata: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Schema", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Schema = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MintRestricted", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.MintRestricted = bool(v != 0) + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field UpdateRestricted", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.UpdateRestricted = bool(v != 0) + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowNft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthNft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthNft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipNft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthNft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *IDCollection) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/modules/nft/types/owners.go b/modules/nft/types/owners.go deleted file mode 100644 index c8099a5d..00000000 --- a/modules/nft/types/owners.go +++ /dev/null @@ -1,93 +0,0 @@ -package types - -import ( - "bytes" - - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// NewIDCollection creates a new IDCollection instance -func NewIDCollection(denomID string, tokenIDs []string) IDCollection { - return IDCollection{ - DenomId: denomID, - TokenIds: tokenIDs, - } -} - -// Supply return the amount of the denom -func (idc IDCollection) Supply() int { - return len(idc.TokenIds) -} - -// AddID adds an tokenID to the idCollection -func (idc IDCollection) AddID(tokenID string) IDCollection { - idc.TokenIds = append(idc.TokenIds, tokenID) - return idc -} - -// ---------------------------------------------------------------------------- -// IDCollections is an array of ID Collections -type IDCollections []IDCollection - -// Add adds an ID to the idCollection -func (idcs IDCollections) Add(denomID, tokenID string) IDCollections { - for i, idc := range idcs { - if idc.DenomId == denomID { - idcs[i] = idc.AddID(tokenID) - return idcs - } - } - return append(idcs, IDCollection{ - DenomId: denomID, - TokenIds: []string{tokenID}, - }) -} - -// String follows stringer interface -func (idcs IDCollections) String() string { - if len(idcs) == 0 { - return "" - } - - var buf bytes.Buffer - for _, idCollection := range idcs { - if buf.Len() > 0 { - buf.WriteString("\n") - } - buf.WriteString(idCollection.String()) - } - return buf.String() -} - -// Owner of non fungible tokens -//type Owner struct { -// Address sdk.AccAddress `json:"address" yaml:"address"` -// IDCollections IDCollections `json:"id_collections" yaml:"id_collections"` -//} - -// NewOwner creates a new Owner -func NewOwner(owner sdk.AccAddress, idCollections ...IDCollection) Owner { - return Owner{ - Address: owner.String(), - IDCollections: idCollections, - } -} - -type Owners []Owner - -// NewOwner creates a new Owner -func NewOwners(owner ...Owner) Owners { - return append([]Owner{}, owner...) -} - -// String follows stringer interface -func (owners Owners) String() string { - var buf bytes.Buffer - for _, owner := range owners { - if buf.Len() > 0 { - buf.WriteString("\n") - } - buf.WriteString(owner.String()) - } - return buf.String() -} diff --git a/modules/nft/types/querier.go b/modules/nft/types/querier.go deleted file mode 100644 index 1e55626c..00000000 --- a/modules/nft/types/querier.go +++ /dev/null @@ -1,88 +0,0 @@ -package types - -// DONTCOVER - -import ( - sdk "github.com/cosmos/cosmos-sdk/types" -) - -// query endpoints supported by the NFT Querier -const ( - QuerySupply = "supply" - QueryOwner = "owner" - QueryCollection = "collection" - QueryDenoms = "denoms" - QueryDenom = "denom" - QueryNFT = "nft" -) - -// QuerySupplyParams defines the params for queries: -type QuerySupplyParams struct { - Denom string - Owner sdk.AccAddress -} - -// NewQuerySupplyParams creates a new instance of QuerySupplyParams -func NewQuerySupplyParams(denom string, owner sdk.AccAddress) QuerySupplyParams { - return QuerySupplyParams{ - Denom: denom, - Owner: owner, - } -} - -// Bytes exports the Denom as bytes -func (q QuerySupplyParams) Bytes() []byte { - return []byte(q.Denom) -} - -// QueryOwnerParams defines the params for queries: -type QueryOwnerParams struct { - Denom string - Owner sdk.AccAddress -} - -// NewQuerySupplyParams creates a new instance of QuerySupplyParams -func NewQueryOwnerParams(denom string, owner sdk.AccAddress) QueryOwnerParams { - return QueryOwnerParams{ - Denom: denom, - Owner: owner, - } -} - -// QuerySupplyParams defines the params for queries: -type QueryCollectionParams struct { - Denom string -} - -// NewQueryCollectionParams creates a new instance of QueryCollectionParams -func NewQueryCollectionParams(denom string) QueryCollectionParams { - return QueryCollectionParams{ - Denom: denom, - } -} - -// QueryDenomParams defines the params for queries: -type QueryDenomParams struct { - ID string -} - -// NewQueryDenomParams creates a new instance of QueryDenomParams -func NewQueryDenomParams(id string) QueryDenomParams { - return QueryDenomParams{ - ID: id, - } -} - -// QueryNFTParams params for query 'custom/nfts/nft' -type QueryNFTParams struct { - Denom string - TokenID string -} - -// NewQueryNFTParams creates a new instance of QueryNFTParams -func NewQueryNFTParams(denom, id string) QueryNFTParams { - return QueryNFTParams{ - Denom: denom, - TokenID: id, - } -} diff --git a/modules/nft/types/query.pb.go b/modules/nft/types/query.pb.go index 64b77ab8..3c8f197f 100644 --- a/modules/nft/types/query.pb.go +++ b/modules/nft/types/query.pb.go @@ -128,26 +128,27 @@ func (m *QuerySupplyResponse) GetAmount() uint64 { return 0 } -// QueryOwnerRequest is the request type for the Query/Owner RPC method -type QueryOwnerRequest struct { +// QueryNFTsOfOwnerRequest is the request type for the Query/NFTsOfOwner RPC +// method +type QueryNFTsOfOwnerRequest struct { DenomId string `protobuf:"bytes,1,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty" yaml:"denom_id"` Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty" yaml:"owner"` // pagination defines an optional pagination for the request. Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryOwnerRequest) Reset() { *m = QueryOwnerRequest{} } -func (m *QueryOwnerRequest) String() string { return proto.CompactTextString(m) } -func (*QueryOwnerRequest) ProtoMessage() {} -func (*QueryOwnerRequest) Descriptor() ([]byte, []int) { +func (m *QueryNFTsOfOwnerRequest) Reset() { *m = QueryNFTsOfOwnerRequest{} } +func (m *QueryNFTsOfOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNFTsOfOwnerRequest) ProtoMessage() {} +func (*QueryNFTsOfOwnerRequest) Descriptor() ([]byte, []int) { return fileDescriptor_ce02d034d3adf2e9, []int{2} } -func (m *QueryOwnerRequest) XXX_Unmarshal(b []byte) error { +func (m *QueryNFTsOfOwnerRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryNFTsOfOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOwnerRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryNFTsOfOwnerRequest.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -157,57 +158,58 @@ func (m *QueryOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *QueryOwnerRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOwnerRequest.Merge(m, src) +func (m *QueryNFTsOfOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTsOfOwnerRequest.Merge(m, src) } -func (m *QueryOwnerRequest) XXX_Size() int { +func (m *QueryNFTsOfOwnerRequest) XXX_Size() int { return m.Size() } -func (m *QueryOwnerRequest) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOwnerRequest.DiscardUnknown(m) +func (m *QueryNFTsOfOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTsOfOwnerRequest.DiscardUnknown(m) } -var xxx_messageInfo_QueryOwnerRequest proto.InternalMessageInfo +var xxx_messageInfo_QueryNFTsOfOwnerRequest proto.InternalMessageInfo -func (m *QueryOwnerRequest) GetDenomId() string { +func (m *QueryNFTsOfOwnerRequest) GetDenomId() string { if m != nil { return m.DenomId } return "" } -func (m *QueryOwnerRequest) GetOwner() string { +func (m *QueryNFTsOfOwnerRequest) GetOwner() string { if m != nil { return m.Owner } return "" } -func (m *QueryOwnerRequest) GetPagination() *query.PageRequest { +func (m *QueryNFTsOfOwnerRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination } return nil } -// QueryOwnerResponse is the response type for the Query/Owner RPC method -type QueryOwnerResponse struct { +// QueryNFTsOfOwnerResponse is the response type for the Query/NFTsOfOwner RPC +// method +type QueryNFTsOfOwnerResponse struct { Owner *Owner `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } -func (m *QueryOwnerResponse) Reset() { *m = QueryOwnerResponse{} } -func (m *QueryOwnerResponse) String() string { return proto.CompactTextString(m) } -func (*QueryOwnerResponse) ProtoMessage() {} -func (*QueryOwnerResponse) Descriptor() ([]byte, []int) { +func (m *QueryNFTsOfOwnerResponse) Reset() { *m = QueryNFTsOfOwnerResponse{} } +func (m *QueryNFTsOfOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNFTsOfOwnerResponse) ProtoMessage() {} +func (*QueryNFTsOfOwnerResponse) Descriptor() ([]byte, []int) { return fileDescriptor_ce02d034d3adf2e9, []int{3} } -func (m *QueryOwnerResponse) XXX_Unmarshal(b []byte) error { +func (m *QueryNFTsOfOwnerResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *QueryOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *QueryNFTsOfOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_QueryOwnerResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_QueryNFTsOfOwnerResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -217,33 +219,34 @@ func (m *QueryOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *QueryOwnerResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryOwnerResponse.Merge(m, src) +func (m *QueryNFTsOfOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTsOfOwnerResponse.Merge(m, src) } -func (m *QueryOwnerResponse) XXX_Size() int { +func (m *QueryNFTsOfOwnerResponse) XXX_Size() int { return m.Size() } -func (m *QueryOwnerResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryOwnerResponse.DiscardUnknown(m) +func (m *QueryNFTsOfOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTsOfOwnerResponse.DiscardUnknown(m) } -var xxx_messageInfo_QueryOwnerResponse proto.InternalMessageInfo +var xxx_messageInfo_QueryNFTsOfOwnerResponse proto.InternalMessageInfo -func (m *QueryOwnerResponse) GetOwner() *Owner { +func (m *QueryNFTsOfOwnerResponse) GetOwner() *Owner { if m != nil { return m.Owner } return nil } -func (m *QueryOwnerResponse) GetPagination() *query.PageResponse { +func (m *QueryNFTsOfOwnerResponse) GetPagination() *query.PageResponse { if m != nil { return m.Pagination } return nil } -// QueryCollectionRequest is the request type for the Query/Collection RPC method +// QueryCollectionRequest is the request type for the Query/Collection RPC +// method type QueryCollectionRequest struct { DenomId string `protobuf:"bytes,1,opt,name=denom_id,json=denomId,proto3" json:"denom_id,omitempty" yaml:"denom_id"` // pagination defines an optional pagination for the request. @@ -297,7 +300,8 @@ func (m *QueryCollectionRequest) GetPagination() *query.PageRequest { return nil } -// QueryCollectionResponse is the response type for the Query/Collection RPC method +// QueryCollectionResponse is the response type for the Query/Collection RPC +// method type QueryCollectionResponse struct { Collection *Collection `protobuf:"bytes,1,opt,name=collection,proto3" json:"collection,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -640,8 +644,8 @@ func (m *QueryNFTResponse) GetNFT() *BaseNFT { func init() { proto.RegisterType((*QuerySupplyRequest)(nil), "irismod.nft.QuerySupplyRequest") proto.RegisterType((*QuerySupplyResponse)(nil), "irismod.nft.QuerySupplyResponse") - proto.RegisterType((*QueryOwnerRequest)(nil), "irismod.nft.QueryOwnerRequest") - proto.RegisterType((*QueryOwnerResponse)(nil), "irismod.nft.QueryOwnerResponse") + proto.RegisterType((*QueryNFTsOfOwnerRequest)(nil), "irismod.nft.QueryNFTsOfOwnerRequest") + proto.RegisterType((*QueryNFTsOfOwnerResponse)(nil), "irismod.nft.QueryNFTsOfOwnerResponse") proto.RegisterType((*QueryCollectionRequest)(nil), "irismod.nft.QueryCollectionRequest") proto.RegisterType((*QueryCollectionResponse)(nil), "irismod.nft.QueryCollectionResponse") proto.RegisterType((*QueryDenomRequest)(nil), "irismod.nft.QueryDenomRequest") @@ -655,55 +659,56 @@ func init() { func init() { proto.RegisterFile("nft/query.proto", fileDescriptor_ce02d034d3adf2e9) } var fileDescriptor_ce02d034d3adf2e9 = []byte{ - // 768 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x41, 0x4f, 0x13, 0x41, - 0x18, 0xed, 0xb4, 0xb4, 0xe0, 0xa0, 0x01, 0xa6, 0x08, 0xb5, 0xe2, 0xb6, 0x59, 0x14, 0x10, 0x71, - 0x57, 0xf0, 0x60, 0xe2, 0xc1, 0x43, 0x31, 0x35, 0x5c, 0x50, 0x2b, 0x27, 0x62, 0x62, 0xb6, 0xed, - 0x74, 0xd9, 0xd8, 0x9d, 0x59, 0x3a, 0x53, 0x4d, 0x43, 0x88, 0x89, 0x31, 0xf1, 0x4a, 0xe2, 0xd1, - 0x9f, 0xe1, 0x6f, 0x30, 0xe1, 0x48, 0xe2, 0xc5, 0x53, 0x63, 0x8a, 0xbf, 0x80, 0x5f, 0x60, 0x76, - 0x66, 0x96, 0xee, 0xba, 0x2d, 0x9a, 0x86, 0xdb, 0xee, 0xce, 0x9b, 0xf7, 0xde, 0xbc, 0xef, 0xfb, - 0x26, 0x0b, 0xa7, 0x48, 0x83, 0x9b, 0xfb, 0x6d, 0xdc, 0xea, 0x18, 0x5e, 0x8b, 0x72, 0x8a, 0x26, - 0x9d, 0x96, 0xc3, 0x5c, 0x5a, 0x37, 0x48, 0x83, 0xe7, 0x67, 0x6d, 0x6a, 0x53, 0xf1, 0xdd, 0xf4, - 0x9f, 0x24, 0x24, 0xbf, 0x60, 0x53, 0x6a, 0x37, 0xb1, 0x69, 0x79, 0x8e, 0x69, 0x11, 0x42, 0xb9, - 0xc5, 0x1d, 0x4a, 0x98, 0x5a, 0xbd, 0xe6, 0x33, 0x92, 0x06, 0x57, 0xaf, 0xab, 0x35, 0xca, 0x5c, - 0xca, 0xcc, 0xaa, 0xc5, 0xb0, 0x14, 0x32, 0xdf, 0xad, 0x57, 0x31, 0xb7, 0xd6, 0x4d, 0xcf, 0xb2, - 0x1d, 0x22, 0xf6, 0x4a, 0xac, 0xbe, 0x0b, 0xd1, 0x4b, 0x1f, 0xf1, 0xaa, 0xed, 0x79, 0xcd, 0x4e, - 0x05, 0xef, 0xb7, 0x31, 0xe3, 0xc8, 0x80, 0x13, 0x75, 0x4c, 0xa8, 0xfb, 0xc6, 0xa9, 0xe7, 0x40, - 0x11, 0xac, 0x5c, 0x29, 0x65, 0xcf, 0xba, 0x85, 0xa9, 0x8e, 0xe5, 0x36, 0x1f, 0xeb, 0xc1, 0x8a, - 0x5e, 0x19, 0x17, 0x8f, 0x5b, 0x75, 0x34, 0x0b, 0xd3, 0xf4, 0x3d, 0xc1, 0xad, 0x5c, 0xd2, 0x07, - 0x57, 0xe4, 0x8b, 0x7e, 0x1f, 0x66, 0x23, 0xdc, 0xcc, 0xa3, 0x84, 0x61, 0x34, 0x07, 0x33, 0x96, - 0x4b, 0xdb, 0x84, 0x0b, 0xea, 0xb1, 0x8a, 0x7a, 0xd3, 0xbf, 0x01, 0x38, 0x23, 0xf0, 0xcf, 0xfd, - 0xdd, 0xa3, 0x5a, 0x59, 0x8a, 0x58, 0x29, 0x4d, 0x9f, 0x75, 0x0b, 0x57, 0x25, 0x58, 0x9a, 0x52, - 0xe6, 0x50, 0x19, 0xc2, 0x7e, 0x18, 0xb9, 0x54, 0x11, 0xac, 0x4c, 0x6e, 0x2c, 0x19, 0x32, 0x39, - 0xc3, 0x4f, 0xce, 0x90, 0x25, 0x52, 0xc9, 0x19, 0x2f, 0x2c, 0x1b, 0x2b, 0x4f, 0x95, 0xd0, 0x4e, - 0xfd, 0x33, 0x50, 0x09, 0x2a, 0xd7, 0xea, 0x90, 0x2b, 0x81, 0x0d, 0x20, 0x98, 0x91, 0x11, 0xaa, - 0xb1, 0x21, 0xa1, 0xca, 0xc8, 0xb3, 0x88, 0x91, 0xa4, 0x80, 0x2f, 0xff, 0xd3, 0x88, 0x94, 0x89, - 0x38, 0x39, 0x02, 0x70, 0x4e, 0x38, 0xd9, 0xa4, 0xcd, 0x26, 0xae, 0xf9, 0xdf, 0x46, 0x0d, 0xb1, - 0x3c, 0xc0, 0xd3, 0x28, 0xe1, 0x7c, 0x05, 0x70, 0x3e, 0x66, 0x49, 0x25, 0xf4, 0x08, 0xc2, 0xda, - 0xf9, 0x57, 0x15, 0xd3, 0x7c, 0x24, 0xa6, 0xd0, 0xa6, 0x10, 0xf4, 0xf2, 0x02, 0xdb, 0x54, 0xfd, - 0xf6, 0xd4, 0x3f, 0xf5, 0x88, 0x51, 0xe9, 0x4f, 0x54, 0xf9, 0x15, 0x49, 0xbf, 0xfc, 0x02, 0x30, - 0xb0, 0xfc, 0x12, 0x2a, 0x01, 0xfa, 0xeb, 0xf0, 0x7e, 0x16, 0xb8, 0x88, 0x16, 0x00, 0x8c, 0x5c, - 0x80, 0x23, 0xa0, 0x66, 0x30, 0xa0, 0x57, 0xfe, 0x1e, 0xc0, 0x8c, 0x90, 0x67, 0x39, 0x50, 0x4c, - 0x0d, 0x36, 0x58, 0x1a, 0x3b, 0xee, 0x16, 0x12, 0x15, 0x85, 0xbb, 0xbc, 0xd4, 0xf7, 0xe1, 0x94, - 0x70, 0xb4, 0x5d, 0xde, 0x19, 0xb5, 0x3d, 0x0d, 0x38, 0xc1, 0xe9, 0x5b, 0x4c, 0x7c, 0x7c, 0xf2, - 0x6f, 0x7c, 0xb0, 0xa2, 0x57, 0xc6, 0xc5, 0xe3, 0x56, 0x5d, 0xdf, 0x84, 0xd3, 0x7d, 0x49, 0x95, - 0x80, 0x09, 0x53, 0xa4, 0xc1, 0x55, 0xb4, 0xb3, 0x91, 0xe3, 0x97, 0x2c, 0x86, 0xb7, 0xcb, 0x3b, - 0xa5, 0xf1, 0x5e, 0xb7, 0x90, 0xf2, 0xf7, 0xf8, 0xc8, 0x8d, 0xef, 0x69, 0x98, 0x16, 0x2c, 0xe8, - 0x03, 0xcc, 0xc8, 0x2b, 0x0d, 0x15, 0x22, 0xfb, 0xe2, 0x17, 0x69, 0xbe, 0x38, 0x1c, 0x20, 0x7d, - 0xe8, 0x1b, 0x1f, 0x7f, 0xfc, 0xfe, 0x92, 0x5c, 0x43, 0xab, 0xa6, 0x42, 0xfa, 0x17, 0xb9, 0xd9, - 0x6f, 0x77, 0x66, 0x1e, 0x04, 0x09, 0x1c, 0x9a, 0x4c, 0xca, 0xd6, 0x60, 0x5a, 0x5c, 0x21, 0x48, - 0x8b, 0xd3, 0x87, 0x2f, 0xcf, 0x7c, 0x61, 0xe8, 0xba, 0x52, 0xbf, 0x21, 0xd4, 0xb3, 0x68, 0x26, - 0xa2, 0x4e, 0x1a, 0x9c, 0xa1, 0x4f, 0x00, 0xc2, 0xfe, 0x04, 0xa2, 0xc5, 0x38, 0x55, 0xec, 0x9e, - 0xc9, 0xdf, 0xbe, 0x18, 0xa4, 0x44, 0xef, 0x09, 0xd1, 0x3b, 0x68, 0xf1, 0x3f, 0x8e, 0x8c, 0x3c, - 0x98, 0x16, 0xed, 0x38, 0xe8, 0xac, 0xe1, 0xc1, 0x1d, 0x74, 0xd6, 0xc8, 0x4c, 0xea, 0x4b, 0x42, - 0xb6, 0x88, 0xb4, 0x88, 0xac, 0x6c, 0xef, 0xb0, 0xe2, 0x1e, 0xcc, 0xc8, 0x69, 0x41, 0xc3, 0x28, - 0xd9, 0x05, 0xe5, 0x8d, 0x0e, 0x9a, 0x7e, 0x53, 0x88, 0x5e, 0x47, 0xd9, 0x01, 0xa2, 0x88, 0x41, - 0xbf, 0xbd, 0xd0, 0x42, 0x9c, 0xa5, 0x3f, 0x1c, 0xf9, 0x5b, 0x43, 0x56, 0x95, 0x80, 0x29, 0x04, - 0xee, 0xa2, 0xe5, 0x58, 0x05, 0xc3, 0x8d, 0x73, 0x10, 0x4c, 0xc5, 0x61, 0xa9, 0x7c, 0xdc, 0xd3, - 0xc0, 0x49, 0x4f, 0x03, 0xbf, 0x7a, 0x1a, 0x38, 0x3a, 0xd5, 0x12, 0x27, 0xa7, 0x5a, 0xe2, 0xe7, - 0xa9, 0x96, 0xd8, 0x5d, 0xb3, 0x1d, 0xbe, 0xd7, 0xae, 0x1a, 0x35, 0xea, 0x0a, 0x32, 0x82, 0xf9, - 0x39, 0xa9, 0x4b, 0xeb, 0xed, 0x26, 0x66, 0x82, 0x9c, 0x77, 0x3c, 0xcc, 0xaa, 0x19, 0xf1, 0x03, - 0xf1, 0xf0, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x19, 0x80, 0xb5, 0xe7, 0xcf, 0x08, 0x00, 0x00, + // 772 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x56, 0x4f, 0x4f, 0x13, 0x41, + 0x1c, 0xed, 0xb4, 0xb4, 0xe0, 0xa0, 0x01, 0xa6, 0x08, 0xb5, 0xe2, 0xb6, 0x59, 0xfe, 0x8a, 0xb8, + 0x2b, 0x78, 0x30, 0xf1, 0xe0, 0xa1, 0x98, 0x1a, 0x2e, 0xa0, 0x95, 0x13, 0x31, 0x31, 0xdb, 0x76, + 0x5a, 0x1a, 0xbb, 0x33, 0x4b, 0x67, 0x56, 0xd3, 0x10, 0x62, 0x62, 0xbc, 0x9a, 0x90, 0x78, 0xf4, + 0x93, 0xf8, 0x0d, 0x38, 0x92, 0x78, 0xd0, 0x53, 0x63, 0x8a, 0x9f, 0x80, 0x4f, 0x60, 0x76, 0x66, + 0x96, 0xee, 0xba, 0x2d, 0x98, 0x86, 0xdb, 0xee, 0xce, 0x9b, 0xf7, 0xde, 0xbc, 0xdf, 0xfc, 0x7e, + 0x59, 0x38, 0x41, 0x6a, 0xdc, 0x3c, 0x70, 0x71, 0xab, 0x6d, 0x38, 0x2d, 0xca, 0x29, 0x1a, 0x6f, + 0xb4, 0x1a, 0xcc, 0xa6, 0x55, 0x83, 0xd4, 0x78, 0x76, 0xba, 0x4e, 0xeb, 0x54, 0x7c, 0x37, 0xbd, + 0x27, 0x09, 0xc9, 0xce, 0xd5, 0x29, 0xad, 0x37, 0xb1, 0x69, 0x39, 0x0d, 0xd3, 0x22, 0x84, 0x72, + 0x8b, 0x37, 0x28, 0x61, 0x6a, 0xf5, 0x96, 0xc7, 0x48, 0x6a, 0x5c, 0xbd, 0xae, 0x56, 0x28, 0xb3, + 0x29, 0x33, 0xcb, 0x16, 0xc3, 0x52, 0xc8, 0x7c, 0xbf, 0x5e, 0xc6, 0xdc, 0x5a, 0x37, 0x1d, 0xab, + 0xde, 0x20, 0x62, 0xaf, 0xc4, 0xea, 0x7b, 0x10, 0xbd, 0xf2, 0x10, 0xaf, 0x5d, 0xc7, 0x69, 0xb6, + 0x4b, 0xf8, 0xc0, 0xc5, 0x8c, 0x23, 0x03, 0x8e, 0x55, 0x31, 0xa1, 0xf6, 0xdb, 0x46, 0x35, 0x03, + 0xf2, 0x60, 0xe5, 0x46, 0x21, 0x7d, 0xde, 0xc9, 0x4d, 0xb4, 0x2d, 0xbb, 0xf9, 0x54, 0xf7, 0x57, + 0xf4, 0xd2, 0xa8, 0x78, 0xdc, 0xaa, 0xa2, 0x69, 0x98, 0xa4, 0x1f, 0x08, 0x6e, 0x65, 0xe2, 0x1e, + 0xb8, 0x24, 0x5f, 0xf4, 0x87, 0x30, 0x1d, 0xe2, 0x66, 0x0e, 0x25, 0x0c, 0xa3, 0x19, 0x98, 0xb2, + 0x6c, 0xea, 0x12, 0x2e, 0xa8, 0x47, 0x4a, 0xea, 0x4d, 0xff, 0x0e, 0xe0, 0xac, 0xc0, 0x6f, 0x17, + 0x77, 0xd9, 0x4e, 0x6d, 0xc7, 0xe3, 0x18, 0xd6, 0xd0, 0x52, 0xc8, 0x50, 0x61, 0xf2, 0xbc, 0x93, + 0xbb, 0x29, 0xc1, 0xd2, 0x9a, 0xb2, 0x88, 0x8a, 0x10, 0xf6, 0x22, 0xc9, 0x24, 0xf2, 0x60, 0x65, + 0x7c, 0x63, 0xc9, 0x90, 0xf9, 0x19, 0x5e, 0x7e, 0x86, 0x2c, 0x94, 0xca, 0xcf, 0x78, 0x69, 0xd5, + 0xb1, 0xf2, 0x54, 0x0a, 0xec, 0xd4, 0xbf, 0x00, 0x98, 0x89, 0x7a, 0x57, 0x07, 0x5e, 0xf1, 0xcd, + 0x00, 0xc1, 0x8f, 0x8c, 0x40, 0xbd, 0x0d, 0x09, 0x55, 0x76, 0x5e, 0x84, 0xec, 0xc4, 0x05, 0x7c, + 0xf9, 0x4a, 0x3b, 0x52, 0x26, 0xe4, 0xe7, 0x18, 0xc0, 0x19, 0xe1, 0x67, 0x93, 0x36, 0x9b, 0xb8, + 0xe2, 0x7d, 0x1b, 0x36, 0xca, 0x62, 0x1f, 0x4f, 0xc3, 0x44, 0xf4, 0xcd, 0x2f, 0x6f, 0xd0, 0x92, + 0x4a, 0xe8, 0x09, 0x84, 0x95, 0x8b, 0xaf, 0x2a, 0xa6, 0xd9, 0x50, 0x4c, 0x81, 0x4d, 0x01, 0xe8, + 0xf5, 0x05, 0xb6, 0x09, 0xa7, 0x84, 0xb9, 0xe7, 0xde, 0xa9, 0x87, 0x8c, 0x4a, 0x7f, 0xa6, 0x9a, + 0x49, 0x91, 0xf4, 0xca, 0x2f, 0x00, 0x7d, 0xcb, 0x2f, 0xa1, 0x12, 0xa0, 0xbf, 0x09, 0xee, 0x67, + 0xbe, 0x8b, 0x70, 0x01, 0xc0, 0xd0, 0x05, 0x38, 0x06, 0xaa, 0x1f, 0x7d, 0x7a, 0xe5, 0xef, 0x11, + 0x4c, 0x09, 0x79, 0x96, 0x01, 0xf9, 0x44, 0x7f, 0x83, 0x85, 0x91, 0x93, 0x4e, 0x2e, 0x56, 0x52, + 0xb8, 0xeb, 0x4b, 0xfd, 0x00, 0x4e, 0xf8, 0x5d, 0x33, 0xec, 0xf5, 0x34, 0xe0, 0x18, 0xa7, 0xef, + 0x30, 0xf1, 0xf0, 0xf1, 0x7f, 0xf1, 0xfe, 0x8a, 0x5e, 0x1a, 0x15, 0x8f, 0x5b, 0x55, 0x7d, 0x13, + 0x4e, 0xf6, 0x24, 0x55, 0x02, 0x26, 0x4c, 0x90, 0x1a, 0x57, 0xd1, 0x4e, 0x87, 0x8e, 0x5f, 0xb0, + 0x18, 0xde, 0x2e, 0xee, 0x16, 0x46, 0xbb, 0x9d, 0x5c, 0xc2, 0xdb, 0xe3, 0x21, 0x37, 0x7e, 0x26, + 0x61, 0x52, 0xb0, 0xa0, 0x8f, 0x30, 0x25, 0xc7, 0x1b, 0xca, 0x85, 0xf6, 0x45, 0x87, 0x6a, 0x36, + 0x3f, 0x18, 0x20, 0x7d, 0xe8, 0x1b, 0x9f, 0x7e, 0xfc, 0xf9, 0x1a, 0x5f, 0x43, 0xab, 0xa6, 0x42, + 0x7a, 0x43, 0xdd, 0xec, 0x5d, 0x77, 0x66, 0x1e, 0xfa, 0x09, 0x1c, 0x99, 0x4c, 0xca, 0xba, 0x70, + 0x3c, 0x30, 0x73, 0xd0, 0x42, 0x54, 0x24, 0x3a, 0x4e, 0xb3, 0x8b, 0x57, 0xa0, 0x94, 0x9f, 0x3b, + 0xc2, 0x4f, 0x1a, 0x4d, 0x85, 0xfc, 0x90, 0x1a, 0x67, 0xe8, 0x33, 0x80, 0xb0, 0xd7, 0x93, 0x68, + 0x3e, 0x4a, 0x18, 0x99, 0x3c, 0xd9, 0x85, 0xcb, 0x41, 0x4a, 0xf4, 0x81, 0x10, 0x5d, 0x44, 0xf3, + 0xff, 0x11, 0x02, 0x72, 0x60, 0x52, 0x5c, 0x50, 0xa4, 0x45, 0xb9, 0x83, 0xad, 0x9c, 0xcd, 0x0d, + 0x5c, 0x57, 0xb2, 0x4b, 0x42, 0x36, 0x8f, 0xb4, 0x90, 0xac, 0xbc, 0xf0, 0x41, 0xc5, 0x7d, 0x98, + 0x92, 0xfd, 0x83, 0x06, 0x51, 0xb2, 0x4b, 0x0a, 0x1e, 0x6e, 0x3d, 0xfd, 0xae, 0x10, 0xbd, 0x8d, + 0xd2, 0x7d, 0x44, 0x11, 0x83, 0xde, 0x85, 0x43, 0x73, 0x7d, 0x6b, 0xe5, 0x6b, 0xdc, 0x1b, 0xb0, + 0xaa, 0x04, 0x4c, 0x21, 0x70, 0x1f, 0x2d, 0x47, 0x2a, 0x18, 0xbc, 0x4a, 0x87, 0x7e, 0x9f, 0x1c, + 0x15, 0x8a, 0x27, 0x5d, 0x0d, 0x9c, 0x76, 0x35, 0xf0, 0xbb, 0xab, 0x81, 0xe3, 0x33, 0x2d, 0x76, + 0x7a, 0xa6, 0xc5, 0x7e, 0x9d, 0x69, 0xb1, 0xbd, 0xb5, 0x7a, 0x83, 0xef, 0xbb, 0x65, 0xa3, 0x42, + 0x6d, 0x41, 0x46, 0x30, 0xbf, 0x20, 0xb5, 0x69, 0xd5, 0x6d, 0x62, 0x26, 0xc8, 0x79, 0xdb, 0xc1, + 0xac, 0x9c, 0x12, 0xbf, 0x17, 0x8f, 0xff, 0x06, 0x00, 0x00, 0xff, 0xff, 0x30, 0x83, 0x65, 0x31, + 0xed, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -720,8 +725,8 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Supply queries the total supply of a given denom or owner Supply(ctx context.Context, in *QuerySupplyRequest, opts ...grpc.CallOption) (*QuerySupplyResponse, error) - // Owner queries the NFTs of the specified owner - Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) + // NFTsOfOwner queries the NFTs of the specified owner + NFTsOfOwner(ctx context.Context, in *QueryNFTsOfOwnerRequest, opts ...grpc.CallOption) (*QueryNFTsOfOwnerResponse, error) // Collection queries the NFTs of the specified denom Collection(ctx context.Context, in *QueryCollectionRequest, opts ...grpc.CallOption) (*QueryCollectionResponse, error) // Denom queries the definition of a given denom @@ -749,9 +754,9 @@ func (c *queryClient) Supply(ctx context.Context, in *QuerySupplyRequest, opts . return out, nil } -func (c *queryClient) Owner(ctx context.Context, in *QueryOwnerRequest, opts ...grpc.CallOption) (*QueryOwnerResponse, error) { - out := new(QueryOwnerResponse) - err := c.cc.Invoke(ctx, "/irismod.nft.Query/Owner", in, out, opts...) +func (c *queryClient) NFTsOfOwner(ctx context.Context, in *QueryNFTsOfOwnerRequest, opts ...grpc.CallOption) (*QueryNFTsOfOwnerResponse, error) { + out := new(QueryNFTsOfOwnerResponse) + err := c.cc.Invoke(ctx, "/irismod.nft.Query/NFTsOfOwner", in, out, opts...) if err != nil { return nil, err } @@ -798,8 +803,8 @@ func (c *queryClient) NFT(ctx context.Context, in *QueryNFTRequest, opts ...grpc type QueryServer interface { // Supply queries the total supply of a given denom or owner Supply(context.Context, *QuerySupplyRequest) (*QuerySupplyResponse, error) - // Owner queries the NFTs of the specified owner - Owner(context.Context, *QueryOwnerRequest) (*QueryOwnerResponse, error) + // NFTsOfOwner queries the NFTs of the specified owner + NFTsOfOwner(context.Context, *QueryNFTsOfOwnerRequest) (*QueryNFTsOfOwnerResponse, error) // Collection queries the NFTs of the specified denom Collection(context.Context, *QueryCollectionRequest) (*QueryCollectionResponse, error) // Denom queries the definition of a given denom @@ -817,8 +822,8 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Supply(ctx context.Context, req *QuerySupplyRequest) (*QuerySupplyResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Supply not implemented") } -func (*UnimplementedQueryServer) Owner(ctx context.Context, req *QueryOwnerRequest) (*QueryOwnerResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Owner not implemented") +func (*UnimplementedQueryServer) NFTsOfOwner(ctx context.Context, req *QueryNFTsOfOwnerRequest) (*QueryNFTsOfOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NFTsOfOwner not implemented") } func (*UnimplementedQueryServer) Collection(ctx context.Context, req *QueryCollectionRequest) (*QueryCollectionResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Collection not implemented") @@ -855,20 +860,20 @@ func _Query_Supply_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } -func _Query_Owner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryOwnerRequest) +func _Query_NFTsOfOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNFTsOfOwnerRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(QueryServer).Owner(ctx, in) + return srv.(QueryServer).NFTsOfOwner(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.nft.Query/Owner", + FullMethod: "/irismod.nft.Query/NFTsOfOwner", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Owner(ctx, req.(*QueryOwnerRequest)) + return srv.(QueryServer).NFTsOfOwner(ctx, req.(*QueryNFTsOfOwnerRequest)) } return interceptor(ctx, in, info, handler) } @@ -954,8 +959,8 @@ var _Query_serviceDesc = grpc.ServiceDesc{ Handler: _Query_Supply_Handler, }, { - MethodName: "Owner", - Handler: _Query_Owner_Handler, + MethodName: "NFTsOfOwner", + Handler: _Query_NFTsOfOwner_Handler, }, { MethodName: "Collection", @@ -1043,7 +1048,7 @@ func (m *QuerySupplyResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryOwnerRequest) Marshal() (dAtA []byte, err error) { +func (m *QueryNFTsOfOwnerRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1053,12 +1058,12 @@ func (m *QueryOwnerRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryOwnerRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryNFTsOfOwnerRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryNFTsOfOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1092,7 +1097,7 @@ func (m *QueryOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *QueryOwnerResponse) Marshal() (dAtA []byte, err error) { +func (m *QueryNFTsOfOwnerResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1102,12 +1107,12 @@ func (m *QueryOwnerResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *QueryOwnerResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *QueryNFTsOfOwnerResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *QueryNFTsOfOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1489,7 +1494,7 @@ func (m *QuerySupplyResponse) Size() (n int) { return n } -func (m *QueryOwnerRequest) Size() (n int) { +func (m *QueryNFTsOfOwnerRequest) Size() (n int) { if m == nil { return 0 } @@ -1510,7 +1515,7 @@ func (m *QueryOwnerRequest) Size() (n int) { return n } -func (m *QueryOwnerResponse) Size() (n int) { +func (m *QueryNFTsOfOwnerResponse) Size() (n int) { if m == nil { return 0 } @@ -1838,7 +1843,7 @@ func (m *QuerySupplyResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOwnerRequest) Unmarshal(dAtA []byte) error { +func (m *QueryNFTsOfOwnerRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1861,10 +1866,10 @@ func (m *QueryOwnerRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOwnerRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryNFTsOfOwnerRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryNFTsOfOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1988,7 +1993,7 @@ func (m *QueryOwnerRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryOwnerResponse) Unmarshal(dAtA []byte) error { +func (m *QueryNFTsOfOwnerResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2011,10 +2016,10 @@ func (m *QueryOwnerResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryOwnerResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryNFTsOfOwnerResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryNFTsOfOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/modules/nft/types/query.pb.gw.go b/modules/nft/types/query.pb.gw.go index 25368ef4..30ff7df3 100644 --- a/modules/nft/types/query.pb.gw.go +++ b/modules/nft/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join var ( filter_Query_Supply_0 = &utilities.DoubleArray{Encoding: map[string]int{"denom_id": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} @@ -104,37 +106,37 @@ func local_request_Query_Supply_0(ctx context.Context, marshaler runtime.Marshal } var ( - filter_Query_Owner_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_NFTsOfOwner_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_Query_Owner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOwnerRequest +func request_Query_NFTsOfOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTsOfOwnerRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Owner_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTsOfOwner_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := client.Owner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + msg, err := client.NFTsOfOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) return msg, metadata, err } -func local_request_Query_Owner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryOwnerRequest +func local_request_Query_NFTsOfOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTsOfOwnerRequest var metadata runtime.ServerMetadata if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_Owner_0); err != nil { + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_NFTsOfOwner_0); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } - msg, err := server.Owner(ctx, &protoReq) + msg, err := server.NFTsOfOwner(ctx, &protoReq) return msg, metadata, err } @@ -380,12 +382,14 @@ func local_request_Query_NFT_0(ctx context.Context, marshaler runtime.Marshaler, // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Supply_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -393,6 +397,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Supply_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -403,29 +408,34 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) - mux.Handle("GET", pattern_Query_Owner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_NFTsOfOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := local_request_Query_Owner_0(rctx, inboundMarshaler, server, req, pathParams) + resp, md, err := local_request_Query_NFTsOfOwner_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Owner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_NFTsOfOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) mux.Handle("GET", pattern_Query_Collection_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -433,6 +443,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Collection_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -446,6 +457,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Denom_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -453,6 +466,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Denom_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -466,6 +480,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Denoms_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -473,6 +489,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Denoms_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -486,6 +503,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_NFT_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -493,6 +512,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_NFT_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -564,7 +584,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) - mux.Handle("GET", pattern_Query_Owner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + mux.Handle("GET", pattern_Query_NFTsOfOwner_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) @@ -573,14 +593,14 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - resp, md, err := request_Query_Owner_0(rctx, inboundMarshaler, client, req, pathParams) + resp, md, err := request_Query_NFTsOfOwner_0(rctx, inboundMarshaler, client, req, pathParams) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) return } - forward_Query_Owner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + forward_Query_NFTsOfOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) }) @@ -668,23 +688,23 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "nft", "collections", "denom_id", "supply"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Supply_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "nft", "collections", "denom_id", "supply"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Owner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "nft", "nfts"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_NFTsOfOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "nft", "nfts"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Collection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "nft", "collections", "denom_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Collection_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "nft", "collections", "denom_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Denom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "nft", "denoms", "denom_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Denom_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "nft", "denoms", "denom_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "nft", "denoms"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Denoms_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "nft", "denoms"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_NFT_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "nft", "nfts", "denom_id", "token_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_NFT_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "nft", "nfts", "denom_id", "token_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( forward_Query_Supply_0 = runtime.ForwardResponseMessage - forward_Query_Owner_0 = runtime.ForwardResponseMessage + forward_Query_NFTsOfOwner_0 = runtime.ForwardResponseMessage forward_Query_Collection_0 = runtime.ForwardResponseMessage diff --git a/modules/nft/types/tx.pb.go b/modules/nft/types/tx.pb.go index 87688518..01772340 100644 --- a/modules/nft/types/tx.pb.go +++ b/modules/nft/types/tx.pb.go @@ -6,15 +6,16 @@ package types import ( context "context" fmt "fmt" + io "io" + math "math" + math_bits "math/bits" + _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" - io "io" - math "math" - math_bits "math/bits" ) // Reference imports to suppress errors if they are not otherwise used. @@ -76,7 +77,7 @@ func (m *MsgIssueDenom) XXX_DiscardUnknown() { var xxx_messageInfo_MsgIssueDenom proto.InternalMessageInfo -// MsgIssueDenomResponse defines the Msg/IssueDenom response type. +// MsgIssueDenomResponse defines the Msg/SaveDenom response type. type MsgIssueDenomResponse struct { } @@ -239,7 +240,7 @@ func (m *MsgEditNFT) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEditNFT proto.InternalMessageInfo -// MsgEditNFTResponse defines the Msg/EditNFT response type. +// MsgEditNFTResponse defines the Msg/UpdateNFT response type. type MsgEditNFTResponse struct { } @@ -321,7 +322,7 @@ func (m *MsgMintNFT) XXX_DiscardUnknown() { var xxx_messageInfo_MsgMintNFT proto.InternalMessageInfo -// MsgMintNFTResponse defines the Msg/MintNFT response type. +// MsgMintNFTResponse defines the Msg/SaveNFT response type. type MsgMintNFTResponse struct { } @@ -398,7 +399,7 @@ func (m *MsgBurnNFT) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBurnNFT proto.InternalMessageInfo -// MsgBurnNFTResponse defines the Msg/BurnNFT response type. +// MsgBurnNFTResponse defines the Msg/RemoveNFT response type. type MsgBurnNFTResponse struct { } @@ -435,7 +436,8 @@ func (m *MsgBurnNFTResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBurnNFTResponse proto.InternalMessageInfo -// MsgTransferDenom defines an SDK message for transferring an denom to recipient. +// MsgTransferDenom defines an SDK message for transferring an denom to +// recipient. type MsgTransferDenom struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` @@ -857,7 +859,7 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { func (c *msgClient) IssueDenom(ctx context.Context, in *MsgIssueDenom, opts ...grpc.CallOption) (*MsgIssueDenomResponse, error) { out := new(MsgIssueDenomResponse) - err := c.cc.Invoke(ctx, "/irismod.nft.Msg/IssueDenom", in, out, opts...) + err := c.cc.Invoke(ctx, "/irismod.nft.Msg/SaveDenom", in, out, opts...) if err != nil { return nil, err } @@ -866,7 +868,7 @@ func (c *msgClient) IssueDenom(ctx context.Context, in *MsgIssueDenom, opts ...g func (c *msgClient) MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.CallOption) (*MsgMintNFTResponse, error) { out := new(MsgMintNFTResponse) - err := c.cc.Invoke(ctx, "/irismod.nft.Msg/MintNFT", in, out, opts...) + err := c.cc.Invoke(ctx, "/irismod.nft.Msg/SaveNFT", in, out, opts...) if err != nil { return nil, err } @@ -875,7 +877,7 @@ func (c *msgClient) MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.Ca func (c *msgClient) EditNFT(ctx context.Context, in *MsgEditNFT, opts ...grpc.CallOption) (*MsgEditNFTResponse, error) { out := new(MsgEditNFTResponse) - err := c.cc.Invoke(ctx, "/irismod.nft.Msg/EditNFT", in, out, opts...) + err := c.cc.Invoke(ctx, "/irismod.nft.Msg/UpdateNFT", in, out, opts...) if err != nil { return nil, err } @@ -893,7 +895,7 @@ func (c *msgClient) TransferNFT(ctx context.Context, in *MsgTransferNFT, opts .. func (c *msgClient) BurnNFT(ctx context.Context, in *MsgBurnNFT, opts ...grpc.CallOption) (*MsgBurnNFTResponse, error) { out := new(MsgBurnNFTResponse) - err := c.cc.Invoke(ctx, "/irismod.nft.Msg/BurnNFT", in, out, opts...) + err := c.cc.Invoke(ctx, "/irismod.nft.Msg/RemoveNFT", in, out, opts...) if err != nil { return nil, err } @@ -930,19 +932,19 @@ type UnimplementedMsgServer struct { } func (*UnimplementedMsgServer) IssueDenom(ctx context.Context, req *MsgIssueDenom) (*MsgIssueDenomResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method IssueDenom not implemented") + return nil, status.Errorf(codes.Unimplemented, "method SaveDenom not implemented") } func (*UnimplementedMsgServer) MintNFT(ctx context.Context, req *MsgMintNFT) (*MsgMintNFTResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method MintNFT not implemented") + return nil, status.Errorf(codes.Unimplemented, "method SaveNFT not implemented") } func (*UnimplementedMsgServer) EditNFT(ctx context.Context, req *MsgEditNFT) (*MsgEditNFTResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method EditNFT not implemented") + return nil, status.Errorf(codes.Unimplemented, "method UpdateNFT not implemented") } func (*UnimplementedMsgServer) TransferNFT(ctx context.Context, req *MsgTransferNFT) (*MsgTransferNFTResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TransferNFT not implemented") } func (*UnimplementedMsgServer) BurnNFT(ctx context.Context, req *MsgBurnNFT) (*MsgBurnNFTResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method BurnNFT not implemented") + return nil, status.Errorf(codes.Unimplemented, "method RemoveNFT not implemented") } func (*UnimplementedMsgServer) TransferDenom(ctx context.Context, req *MsgTransferDenom) (*MsgTransferDenomResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TransferDenom not implemented") @@ -962,7 +964,7 @@ func _Msg_IssueDenom_Handler(srv interface{}, ctx context.Context, dec func(inte } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.nft.Msg/IssueDenom", + FullMethod: "/irismod.nft.Msg/SaveDenom", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).IssueDenom(ctx, req.(*MsgIssueDenom)) @@ -980,7 +982,7 @@ func _Msg_MintNFT_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.nft.Msg/MintNFT", + FullMethod: "/irismod.nft.Msg/SaveNFT", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).MintNFT(ctx, req.(*MsgMintNFT)) @@ -998,7 +1000,7 @@ func _Msg_EditNFT_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.nft.Msg/EditNFT", + FullMethod: "/irismod.nft.Msg/UpdateNFT", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).EditNFT(ctx, req.(*MsgEditNFT)) @@ -1034,7 +1036,7 @@ func _Msg_BurnNFT_Handler(srv interface{}, ctx context.Context, dec func(interfa } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: "/irismod.nft.Msg/BurnNFT", + FullMethod: "/irismod.nft.Msg/RemoveNFT", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { return srv.(MsgServer).BurnNFT(ctx, req.(*MsgBurnNFT)) @@ -1065,15 +1067,15 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ HandlerType: (*MsgServer)(nil), Methods: []grpc.MethodDesc{ { - MethodName: "IssueDenom", + MethodName: "SaveDenom", Handler: _Msg_IssueDenom_Handler, }, { - MethodName: "MintNFT", + MethodName: "SaveNFT", Handler: _Msg_MintNFT_Handler, }, { - MethodName: "EditNFT", + MethodName: "UpdateNFT", Handler: _Msg_EditNFT_Handler, }, { @@ -1081,7 +1083,7 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ Handler: _Msg_TransferNFT_Handler, }, { - MethodName: "BurnNFT", + MethodName: "RemoveNFT", Handler: _Msg_BurnNFT_Handler, }, { diff --git a/modules/nft/types/validation.go b/modules/nft/types/validation.go index b033bc80..f3022419 100644 --- a/modules/nft/types/validation.go +++ b/modules/nft/types/validation.go @@ -70,6 +70,13 @@ func Modified(target string) bool { return target != types.DoNotModify } +func Modify(origin, target string) string { + if target == types.DoNotModify { + return origin + } + return target +} + // ValidateKeywords checks if the given denomId begins with `DenomKeywords` func ValidateKeywords(denomId string) error { if regexpKeyword(denomId) { diff --git a/modules/oracle/client/cli/cli_test.go b/modules/oracle/client/cli/cli_test.go index db3c1aff..1d3f68eb 100644 --- a/modules/oracle/client/cli/cli_test.go +++ b/modules/oracle/client/cli/cli_test.go @@ -36,10 +36,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg := simapp.NewConfig() cfg.NumValidators = 1 + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -288,7 +290,7 @@ func (s *IntegrationTestSuite) TestOracle() { var requestsBz []byte for _, attribute := range event.Attributes { if string(attribute.Key) == servicetypes.AttributeKeyRequests { - requestsBz = attribute.GetValue() + requestsBz = []byte(attribute.GetValue()) found = true } } diff --git a/modules/oracle/client/rest/query.go b/modules/oracle/client/rest/query.go deleted file mode 100644 index 7ba35aac..00000000 --- a/modules/oracle/client/rest/query.go +++ /dev/null @@ -1,112 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - oracleClient "github.com/irisnet/irismod/modules/oracle/client" - "github.com/irisnet/irismod/modules/oracle/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // query a feed definition - r.HandleFunc(fmt.Sprintf("/%s/feeds/{%s}", types.ModuleName, FeedName), queryFeedHandlerFn(cliCtx)).Methods("GET") - // query a feed list by condition - r.HandleFunc(fmt.Sprintf("/%s/feeds", types.ModuleName), queryFeedsHandlerFn(cliCtx)).Methods("GET") - // query a feed value by feed name - r.HandleFunc(fmt.Sprintf("/%s/feeds/{%s}/values", types.ModuleName, FeedName), queryFeedValuesHandlerFn(cliCtx)).Methods("GET") -} - -func queryFeedHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - params := types.QueryFeedParams{ - FeedName: vars[FeedName], - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryFeed) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryFeedsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - params := types.QueryFeedsParams{ - State: oracleClient.GetUrlParam(r.URL, FeedState), - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryFeeds) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryFeedValuesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - params := types.QueryFeedValueParams{ - FeedName: vars[FeedName], - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryFeedValue) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/oracle/client/rest/rest.go b/modules/oracle/client/rest/rest.go deleted file mode 100644 index 04ecb8c6..00000000 --- a/modules/oracle/client/rest/rest.go +++ /dev/null @@ -1,58 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -const ( - FeedName = "feed-name" - FeedState = "state" -) - -// RegisterHandlers registers oracle REST handlers to a router -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -type createFeedReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - FeedName string `json:"feed_name"` - AggregateFunc string `json:"aggregate_func"` - ValueJsonPath string `json:"value_json_path"` - LatestHistory uint64 `json:"latest_history"` - Description string `json:"description"` - Creator string `json:"creator"` - ServiceName string `json:"service_name"` - Providers []string `json:"providers"` - Input string `json:"input"` - Timeout int64 `json:"timeout"` - ServiceFeeCap string `json:"service_fee_cap"` - RepeatedFrequency uint64 `json:"repeated_frequency"` - ResponseThreshold uint32 `json:"response_threshold"` -} - -type editFeedReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Description string `json:"description"` - LatestHistory uint64 `json:"latest_history"` - Creator string `json:"creator"` - Providers []string `json:"providers"` - Timeout int64 `json:"timeout"` - ServiceFeeCap string `json:"service_fee_cap"` - RepeatedFrequency uint64 `json:"repeated_frequency"` - ResponseThreshold uint32 `json:"response_threshold"` -} - -type startFeedReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Creator string `json:"creator"` -} - -type pauseFeedReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Creator string `json:"creator"` -} diff --git a/modules/oracle/client/rest/tx.go b/modules/oracle/client/rest/tx.go deleted file mode 100644 index 3d757e5c..00000000 --- a/modules/oracle/client/rest/tx.go +++ /dev/null @@ -1,193 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/oracle/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - // define a feed - r.HandleFunc("/oracle/feeds", createFeedHandlerFn(cliCtx)).Methods("POST") - // edit a feed - r.HandleFunc(fmt.Sprintf("/oracle/feeds/{%s}", FeedName), editFeedHandlerFn(cliCtx)).Methods("PUT") - // start a feed - r.HandleFunc(fmt.Sprintf("/oracle/feeds/{%s}/start", FeedName), startFeedHandlerFn(cliCtx)).Methods("POST") - // pause a feed - r.HandleFunc(fmt.Sprintf("/oracle/feeds/{%s}/pause", FeedName), pauseFeedHandlerFn(cliCtx)).Methods("POST") -} - -func createFeedHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req createFeedReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Creator); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - for _, addr := range req.Providers { - if _, err := sdk.AccAddressFromBech32(addr); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - serviceFeeCap, err := sdk.ParseCoinsNormalized(req.ServiceFeeCap) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := &types.MsgCreateFeed{ - FeedName: req.FeedName, - LatestHistory: req.LatestHistory, - Description: req.Description, - Creator: req.Creator, - ServiceName: req.ServiceName, - Providers: req.Providers, - Input: req.Input, - Timeout: req.Timeout, - ServiceFeeCap: serviceFeeCap, - RepeatedFrequency: req.RepeatedFrequency, - ResponseThreshold: req.ResponseThreshold, - AggregateFunc: req.AggregateFunc, - ValueJsonPath: req.ValueJsonPath, - } - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func editFeedHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req editFeedReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Creator); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - for _, addr := range req.Providers { - if _, err := sdk.AccAddressFromBech32(addr); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - serviceFeeCap, err := sdk.ParseCoinsNormalized(req.ServiceFeeCap) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - vars := mux.Vars(r) - msg := &types.MsgEditFeed{ - FeedName: vars[FeedName], - LatestHistory: req.LatestHistory, - Description: req.Description, - Providers: req.Providers, - Timeout: req.Timeout, - ServiceFeeCap: serviceFeeCap, - RepeatedFrequency: req.RepeatedFrequency, - ResponseThreshold: req.ResponseThreshold, - Creator: req.Creator, - } - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func startFeedHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req startFeedReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Creator); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - vars := mux.Vars(r) - msg := &types.MsgStartFeed{ - FeedName: vars[FeedName], - Creator: req.Creator, - } - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func pauseFeedHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req pauseFeedReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Creator); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - vars := mux.Vars(r) - msg := &types.MsgStartFeed{ - FeedName: vars[FeedName], - Creator: req.Creator, - } - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/oracle/client/rest/grpc_query_test.go b/modules/oracle/client/testutil/grpc_query_test.go similarity index 97% rename from modules/oracle/client/rest/grpc_query_test.go rename to modules/oracle/client/testutil/grpc_query_test.go index a35577af..006c5d51 100644 --- a/modules/oracle/client/rest/grpc_query_test.go +++ b/modules/oracle/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "fmt" @@ -9,8 +9,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" oraclecli "github.com/irisnet/irismod/modules/oracle/client/cli" oracletestutil "github.com/irisnet/irismod/modules/oracle/client/testutil" @@ -35,9 +35,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/oracle/keeper/keeper.go b/modules/oracle/keeper/keeper.go index afa994bc..1a772cd4 100644 --- a/modules/oracle/keeper/keeper.go +++ b/modules/oracle/keeper/keeper.go @@ -11,6 +11,7 @@ import ( tmbytes "github.com/tendermint/tendermint/libs/bytes" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -22,7 +23,7 @@ import ( // Keeper defines a struct for the oracle keeper type Keeper struct { cdc codec.Codec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey sk types.ServiceKeeper paramSpace paramtypes.Subspace } @@ -30,7 +31,7 @@ type Keeper struct { // NewKeeper returns an instance of the oracle Keeper func NewKeeper( cdc codec.Codec, - storeKey sdk.StoreKey, + storeKey storetypes.StoreKey, paramSpace paramtypes.Subspace, sk types.ServiceKeeper, ) Keeper { diff --git a/modules/oracle/keeper/keeper_test.go b/modules/oracle/keeper/keeper_test.go index 698ca54f..dfd0fcda 100644 --- a/modules/oracle/keeper/keeper_test.go +++ b/modules/oracle/keeper/keeper_test.go @@ -22,8 +22,8 @@ import ( ) var ( - testAddr1, _ = sdk.AccAddressFromHex(crypto.AddressHash([]byte("test1")).String()) - testAddr2, _ = sdk.AccAddressFromHex(crypto.AddressHash([]byte("test2")).String()) + testAddr1, _ = sdk.AccAddressFromHexUnsafe(crypto.AddressHash([]byte("test1")).String()) + testAddr2, _ = sdk.AccAddressFromHexUnsafe(crypto.AddressHash([]byte("test2")).String()) addrs = []string{testAddr1.String(), testAddr2.String()} @@ -47,7 +47,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) suite.cdc = app.LegacyAmino() suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/modules/oracle/keeper/pagination_test.go b/modules/oracle/keeper/pagination_test.go index 892fdf1f..5558257c 100644 --- a/modules/oracle/keeper/pagination_test.go +++ b/modules/oracle/keeper/pagination_test.go @@ -24,7 +24,7 @@ func TestShapePageRequest(t *testing.T) { CountTotal: true, Reverse: true, } - + res2 := ShapePageRequest(request) require.NotNil(t, res2) require.Equal(t, res2.Limit, defaultRequest.Limit) // limit == paginationDefaultLimit diff --git a/modules/oracle/module.go b/modules/oracle/module.go index 84b9869d..674b0222 100644 --- a/modules/oracle/module.go +++ b/modules/oracle/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/oracle/client/cli" - "github.com/irisnet/irismod/modules/oracle/client/rest" "github.com/irisnet/irismod/modules/oracle/keeper" "github.com/irisnet/irismod/modules/oracle/simulation" "github.com/irisnet/irismod/modules/oracle/types" @@ -62,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the oracle module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the oracle module. diff --git a/modules/oracle/simulation/operation.go b/modules/oracle/simulation/operation.go index 43e02968..fa8bc45d 100644 --- a/modules/oracle/simulation/operation.go +++ b/modules/oracle/simulation/operation.go @@ -143,7 +143,7 @@ func SimulateCreateFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, nil } - if _, _, err = app.Deliver(txConfig.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txConfig.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeCreateFeed, err.Error()), nil, nil } @@ -183,7 +183,8 @@ func SimulateStartFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -197,7 +198,7 @@ func SimulateStartFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -239,7 +240,8 @@ func SimulatePauseFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -253,7 +255,7 @@ func SimulatePauseFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -324,7 +326,7 @@ func SimulateEditFeed(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKeep return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, nil } - if _, _, err = app.Deliver(txConfig.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txConfig.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeCreateFeed, err.Error()), nil, nil } diff --git a/modules/oracle/types/genesis.pb.go b/modules/oracle/types/genesis.pb.go index 68570533..9324eb18 100644 --- a/modules/oracle/types/genesis.pb.go +++ b/modules/oracle/types/genesis.pb.go @@ -369,10 +369,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { @@ -508,10 +505,7 @@ func (m *FeedEntry) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/oracle/types/oracle.pb.go b/modules/oracle/types/oracle.pb.go index b933ac70..787ff04d 100644 --- a/modules/oracle/types/oracle.pb.go +++ b/modules/oracle/types/oracle.pb.go @@ -8,7 +8,7 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/timestamp" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" @@ -635,10 +635,7 @@ func (m *Feed) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthOracle - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthOracle } if (iNdEx + skippy) > l { @@ -753,10 +750,7 @@ func (m *FeedValue) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthOracle - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthOracle } if (iNdEx + skippy) > l { diff --git a/modules/oracle/types/query.pb.go b/modules/oracle/types/query.pb.go index 109e6c24..5c4e4719 100644 --- a/modules/oracle/types/query.pb.go +++ b/modules/oracle/types/query.pb.go @@ -1183,10 +1183,7 @@ func (m *QueryFeedRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1269,10 +1266,7 @@ func (m *QueryFeedResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1390,10 +1384,7 @@ func (m *QueryFeedsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1513,10 +1504,7 @@ func (m *QueryFeedsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1598,10 +1586,7 @@ func (m *QueryFeedValueRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1685,10 +1670,7 @@ func (m *QueryFeedValueResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1980,10 +1962,7 @@ func (m *FeedContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/oracle/types/query.pb.gw.go b/modules/oracle/types/query.pb.gw.go index 0ddd8666..0a172970 100644 --- a/modules/oracle/types/query.pb.gw.go +++ b/modules/oracle/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Feed_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryFeedRequest @@ -178,12 +180,14 @@ func local_request_Query_FeedValue_0(ctx context.Context, marshaler runtime.Mars // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Feed_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -191,6 +195,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Feed_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -204,6 +209,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Feeds_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -211,6 +218,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Feeds_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -224,6 +232,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_FeedValue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -231,6 +241,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_FeedValue_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -346,11 +357,11 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Feed_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "oracle", "feeds", "feed_name"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Feed_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "oracle", "feeds", "feed_name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Feeds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "oracle", "feeds"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Feeds_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "oracle", "feeds"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_FeedValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "oracle", "feeds", "feed_name", "values"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_FeedValue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "oracle", "feeds", "feed_name", "values"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/oracle/types/tx.pb.go b/modules/oracle/types/tx.pb.go index d6d275eb..19513bf3 100644 --- a/modules/oracle/types/tx.pb.go +++ b/modules/oracle/types/tx.pb.go @@ -1757,10 +1757,7 @@ func (m *MsgCreateFeed) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1810,10 +1807,7 @@ func (m *MsgCreateFeedResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1927,10 +1921,7 @@ func (m *MsgStartFeed) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1980,10 +1971,7 @@ func (m *MsgStartFeedResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2097,10 +2085,7 @@ func (m *MsgPauseFeed) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2150,10 +2135,7 @@ func (m *MsgPauseFeedResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2441,10 +2423,7 @@ func (m *MsgEditFeed) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2494,10 +2473,7 @@ func (m *MsgEditFeedResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/modules/random/client/cli/cli_test.go b/modules/random/client/cli/cli_test.go index 5c67d8f7..c09fd615 100644 --- a/modules/random/client/cli/cli_test.go +++ b/modules/random/client/cli/cli_test.go @@ -38,10 +38,11 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg := simapp.NewConfig() cfg.NumValidators = 1 + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -141,7 +142,7 @@ func (s *IntegrationTestSuite) TestRandom() { var requestsBz []byte for _, attribute := range event.Attributes { if string(attribute.Key) == servicetypes.AttributeKeyRequests { - requestsBz = attribute.GetValue() + requestsBz = []byte(attribute.GetValue()) found = true } } diff --git a/modules/random/client/rest/query.go b/modules/random/client/rest/query.go deleted file mode 100644 index ceb06f7d..00000000 --- a/modules/random/client/rest/query.go +++ /dev/null @@ -1,110 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - "strconv" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/random/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // query random by the request id - r.HandleFunc(fmt.Sprintf("/%s/randoms/{%s}", types.ModuleName, RestRequestID), queryRandomHandlerFn(cliCtx)).Methods("GET") - // query random request queue by an optional heigth - r.HandleFunc(fmt.Sprintf("/%s/queue", types.ModuleName), queryQueueHandlerFn(cliCtx)).Methods("GET") -} - -// HTTP request handler to query random by the request id. -func queryRandomHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - reqID := vars[RestRequestID] - if err := types.CheckReqID(reqID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryRandomParams{ - ReqID: reqID, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryRandom) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - var random types.Random - if err := cliCtx.Codec.UnmarshalJSON(res, &random); err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - - rest.PostProcessResponse(w, cliCtx, random) - } -} - -// HTTP request handler to query request queue by an optional heigth. -func queryQueueHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - genHeightStr := r.FormValue("gen-height") - - genHeight, err := strconv.ParseInt(genHeightStr, 10, 64) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - if genHeight < 0 { - rest.WriteErrorResponse(w, http.StatusBadRequest, "the generation height must not be less than 0") - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryRandomRequestQueueParams{ - Height: genHeight, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryRandomRequestQueue) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/random/client/rest/rest.go b/modules/random/client/rest/rest.go deleted file mode 100644 index 76a31996..00000000 --- a/modules/random/client/rest/rest.go +++ /dev/null @@ -1,30 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// Rest variable names -// nolint -const ( - RestRequestID = "request-id" -) - -// RegisterHandlers defines routes that get registered by the main application -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -// RequestRandomReq defines the properties of a request random request's body -type RequestRandomReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` // base req - Consumer string `json:"consumer"` // request address - BlockInterval uint64 `json:"block_interval"` // block interval - Oracle bool `json:"oracle"` // oracle method - ServiceFeeCap sdk.Coins `json:"service_fee_cap"` // service fee cap -} diff --git a/modules/random/client/rest/tx.go b/modules/random/client/rest/tx.go deleted file mode 100644 index a518ac46..00000000 --- a/modules/random/client/rest/tx.go +++ /dev/null @@ -1,42 +0,0 @@ -package rest - -import ( - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/random/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - // request rands - r.HandleFunc("/random/randoms", requestRandomHandlerFn(cliCtx)).Methods("POST") -} - -// HTTP request handler to request random -func requestRandomHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req RequestRandomReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - // create the MsgRequestRandom message - msg := types.NewMsgRequestRandom(req.Consumer, req.BlockInterval, req.Oracle, req.ServiceFeeCap) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/random/client/rest/grpc_query_test.go b/modules/random/client/testutil/grpc_query_test.go similarity index 97% rename from modules/random/client/rest/grpc_query_test.go rename to modules/random/client/testutil/grpc_query_test.go index d8799031..d9ec3942 100644 --- a/modules/random/client/rest/grpc_query_test.go +++ b/modules/random/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "context" @@ -13,8 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" randomcli "github.com/irisnet/irismod/modules/random/client/cli" randomtestutil "github.com/irisnet/irismod/modules/random/client/testutil" @@ -39,9 +39,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/random/genesis_test.go b/modules/random/genesis_test.go index 18954698..0a75138f 100644 --- a/modules/random/genesis_test.go +++ b/modules/random/genesis_test.go @@ -37,7 +37,7 @@ type GenesisTestSuite struct { } func (suite *GenesisTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/modules/random/keeper/keeper.go b/modules/random/keeper/keeper.go index 029d9d0d..4301f383 100644 --- a/modules/random/keeper/keeper.go +++ b/modules/random/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" @@ -15,13 +16,13 @@ import ( // Keeper defines the random module Keeper type Keeper struct { cdc codec.Codec - storeKey sdk.StoreKey + storeKey storetypes.StoreKey bankKeeper types.BankKeeper serviceKeeper types.ServiceKeeper } // NewKeeper returns a new random keeper -func NewKeeper(cdc codec.Codec, key sdk.StoreKey, bankKeeper types.BankKeeper, serviceKeeper types.ServiceKeeper) Keeper { +func NewKeeper(cdc codec.Codec, key storetypes.StoreKey, bankKeeper types.BankKeeper, serviceKeeper types.ServiceKeeper) Keeper { keeper := Keeper{ cdc: cdc, storeKey: key, diff --git a/modules/random/keeper/keeper_test.go b/modules/random/keeper/keeper_test.go index d25b3e46..e0882921 100644 --- a/modules/random/keeper/keeper_test.go +++ b/modules/random/keeper/keeper_test.go @@ -24,7 +24,7 @@ var ( testTxBytes = []byte("test_tx") testHeight = int64(10000) testBlockInterval = uint64(100) - testConsumer, _ = sdk.AccAddressFromHex(crypto.AddressHash([]byte("test_consumer")).String()) + testConsumer, _ = sdk.AccAddressFromHexUnsafe(crypto.AddressHash([]byte("test_consumer")).String()) testReqID = []byte("test_req_id") testRandomNumerator = int64(3) testRandomDenomiator = int64(4) @@ -40,7 +40,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) suite.app = app suite.cdc = app.LegacyAmino() diff --git a/modules/random/keeper/service.go b/modules/random/keeper/service.go index 4ec087f4..17e5bcf7 100644 --- a/modules/random/keeper/service.go +++ b/modules/random/keeper/service.go @@ -2,8 +2,6 @@ package keeper import ( "encoding/hex" - "math/rand" - "time" "github.com/tidwall/gjson" @@ -38,8 +36,15 @@ func (k Keeper) RequestService(ctx sdk.Context, consumer sdk.AccAddress, service return nil, sdkerrors.ErrInsufficientFee } - rand.Seed(time.Now().UnixNano()) - provider, _ := sdk.AccAddressFromBech32(bindings[rand.Intn(len(bindings))].Provider) + prng := types.MakePRNG( + ctx.BlockHeader().LastBlockId.Hash, + ctx.BlockHeader().Time.UnixNano(), + consumer, nil, true) + provider, err := sdk.AccAddressFromBech32(bindings[prng.Intn(len(bindings))].Provider) + if err != nil { + return nil, err + } + timeout := k.serviceKeeper.GetParams(ctx).MaxRequestTimeout return k.serviceKeeper.CreateRequestContext( diff --git a/modules/random/module.go b/modules/random/module.go index 984b1c35..63e613a6 100644 --- a/modules/random/module.go +++ b/modules/random/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/random/client/cli" - "github.com/irisnet/irismod/modules/random/client/rest" "github.com/irisnet/irismod/modules/random/keeper" "github.com/irisnet/irismod/modules/random/simulation" "github.com/irisnet/irismod/modules/random/types" @@ -62,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the random module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the random module. diff --git a/modules/random/simulation/decoder_test.go b/modules/random/simulation/decoder_test.go index 31b177db..f86d449f 100644 --- a/modules/random/simulation/decoder_test.go +++ b/modules/random/simulation/decoder_test.go @@ -17,7 +17,7 @@ import ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) request := types.NewRequest(50, sdk.AccAddress("consumer").String(), hex.EncodeToString([]byte("txHash")), false, nil, "") diff --git a/modules/random/simulation/operations.go b/modules/random/simulation/operations.go index 399bf553..816abeb3 100644 --- a/modules/random/simulation/operations.go +++ b/modules/random/simulation/operations.go @@ -56,7 +56,7 @@ func WeightedOperations(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txConfig.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txConfig.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } diff --git a/modules/random/types/genesis.pb.go b/modules/random/types/genesis.pb.go index 78d360d6..6e1e921a 100644 --- a/modules/random/types/genesis.pb.go +++ b/modules/random/types/genesis.pb.go @@ -425,7 +425,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > postIndex { @@ -442,10 +442,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { @@ -529,10 +526,7 @@ func (m *Requests) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/random/types/query.pb.go b/modules/random/types/query.pb.go index 8a5663e6..0dc286eb 100644 --- a/modules/random/types/query.pb.go +++ b/modules/random/types/query.pb.go @@ -119,7 +119,8 @@ func (m *QueryRandomResponse) GetRandom() *Random { return nil } -// QueryRandomRequestQueueRequest is request type for the Query/RandomRequestQueue RPC method +// QueryRandomRequestQueueRequest is request type for the +// Query/RandomRequestQueue RPC method type QueryRandomRequestQueueRequest struct { Height int64 `protobuf:"varint,1,opt,name=height,proto3" json:"height,omitempty"` } @@ -164,7 +165,8 @@ func (m *QueryRandomRequestQueueRequest) GetHeight() int64 { return 0 } -// QueryRandomRequestQueueResponse is response type for the Query/RandomRequestQueue RPC method +// QueryRandomRequestQueueResponse is response type for the +// Query/RandomRequestQueue RPC method type QueryRandomRequestQueueResponse struct { Requests []Request `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests"` } @@ -633,10 +635,7 @@ func (m *QueryRandomRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -722,10 +721,7 @@ func (m *QueryRandomResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -794,10 +790,7 @@ func (m *QueryRandomRequestQueueRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -881,10 +874,7 @@ func (m *QueryRandomRequestQueueResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/random/types/query.pb.gw.go b/modules/random/types/query.pb.gw.go index f9d8678a..569e80e6 100644 --- a/modules/random/types/query.pb.gw.go +++ b/modules/random/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Random_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRandomRequest @@ -124,12 +126,14 @@ func local_request_Query_RandomRequestQueue_0(ctx context.Context, marshaler run // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Random_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -137,6 +141,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Random_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -150,6 +155,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_RandomRequestQueue_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -157,6 +164,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_RandomRequestQueue_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -252,9 +260,9 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Random_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "random", "randoms", "req_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Random_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "random", "randoms", "req_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RandomRequestQueue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "random", "queue"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_RandomRequestQueue_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "random", "queue"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/random/types/random.pb.go b/modules/random/types/random.pb.go index 195f8f47..1d7f0cab 100644 --- a/modules/random/types/random.pb.go +++ b/modules/random/types/random.pb.go @@ -513,10 +513,7 @@ func (m *Random) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthRandom - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthRandom } if (iNdEx + skippy) > l { @@ -735,10 +732,7 @@ func (m *Request) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthRandom - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthRandom } if (iNdEx + skippy) > l { diff --git a/modules/random/types/rng.go b/modules/random/types/rng.go index 82fdae22..9e73ba6a 100644 --- a/modules/random/types/rng.go +++ b/modules/random/types/rng.go @@ -3,6 +3,7 @@ package types import ( "crypto/sha256" "math/big" + "math/rand" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -59,6 +60,11 @@ func (p PRNG) GetRand() *big.Rat { return random } +func (p PRNG) Intn(n int) int { + rnd := rand.New(rand.NewSource(p.GetRand().Denom().Int64())) + return rnd.Intn(n) +} + // SHA256 wraps sha256.Sum256 with result converted to slice func SHA256(data []byte) []byte { sum := sha256.Sum256(data) diff --git a/modules/random/types/tx.pb.go b/modules/random/types/tx.pb.go index fb801a55..cb370ed8 100644 --- a/modules/random/types/tx.pb.go +++ b/modules/random/types/tx.pb.go @@ -30,7 +30,8 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// MsgRequestRandom defines an sdk.Msg type that supports requesting a random number +// MsgRequestRandom defines an sdk.Msg type that supports requesting a random +// number type MsgRequestRandom struct { BlockInterval uint64 `protobuf:"varint,1,opt,name=block_interval,json=blockInterval,proto3" json:"block_interval,omitempty" yaml:"block_interval"` Consumer string `protobuf:"bytes,2,opt,name=consumer,proto3" json:"consumer,omitempty"` @@ -527,10 +528,7 @@ func (m *MsgRequestRandom) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -580,10 +578,7 @@ func (m *MsgRequestRandomResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/modules/record/client/cli/cli_test.go b/modules/record/client/cli/cli_test.go index 61fa26ec..e332b43e 100644 --- a/modules/record/client/cli/cli_test.go +++ b/modules/record/client/cli/cli_test.go @@ -31,10 +31,11 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg := simapp.NewConfig() cfg.NumValidators = 1 + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/record/client/rest/query.go b/modules/record/client/rest/query.go deleted file mode 100644 index 6ea8cde4..00000000 --- a/modules/record/client/rest/query.go +++ /dev/null @@ -1,53 +0,0 @@ -package rest - -import ( - "encoding/hex" - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/record/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - r.HandleFunc(fmt.Sprintf("/%s/records/{%s}", types.ModuleName, RestRecordID), queryRecordHandlerFn(cliCtx)).Methods("GET") -} - -func queryRecordHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - recordID, err := hex.DecodeString(vars[RestRecordID]) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryRecordParams{ - RecordID: recordID, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryRecord) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/record/client/rest/rest.go b/modules/record/client/rest/rest.go deleted file mode 100644 index 5cc86ec1..00000000 --- a/modules/record/client/rest/rest.go +++ /dev/null @@ -1,28 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/record/types" -) - -// Rest variable names -// nolint -const ( - RestRecordID = "record-id" -) - -// RegisterHandlers defines routes that get registered by the main application -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -type RecordCreateReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` // base req - Contents []types.Content `json:"contents" yaml:"contents"` - Creator string `json:"creator" yaml:"creator"` -} diff --git a/modules/record/client/rest/tx.go b/modules/record/client/rest/tx.go deleted file mode 100644 index 579b0120..00000000 --- a/modules/record/client/rest/tx.go +++ /dev/null @@ -1,40 +0,0 @@ -package rest - -import ( - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/record/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - r.HandleFunc("/record/records", recordPostHandlerFn(cliCtx)).Methods("POST") -} - -func recordPostHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req RecordCreateReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - msg := types.NewMsgCreateRecord(req.Contents, req.Creator) - - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/record/client/rest/grpc_query_test.go b/modules/record/client/testutil/grpc_query_test.go similarity index 93% rename from modules/record/client/rest/grpc_query_test.go rename to modules/record/client/testutil/grpc_query_test.go index 809af51c..8a140afb 100644 --- a/modules/record/client/rest/grpc_query_test.go +++ b/modules/record/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "fmt" @@ -10,8 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" recordcli "github.com/irisnet/irismod/modules/record/client/cli" recordtestutil "github.com/irisnet/irismod/modules/record/client/testutil" @@ -33,9 +33,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/record/keeper/keeper.go b/modules/record/keeper/keeper.go index 8d4a3ca7..6ad85ff5 100644 --- a/modules/record/keeper/keeper.go +++ b/modules/record/keeper/keeper.go @@ -10,6 +10,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/irisnet/irismod/modules/record/types" @@ -17,12 +18,12 @@ import ( // Keeper of the record store type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.Codec } // NewKeeper returns a record keeper -func NewKeeper(cdc codec.Codec, key sdk.StoreKey) Keeper { +func NewKeeper(cdc codec.Codec, key storetypes.StoreKey) Keeper { keeper := Keeper{ storeKey: key, cdc: cdc, diff --git a/modules/record/keeper/keeper_test.go b/modules/record/keeper/keeper_test.go index d69e9822..9c45fe25 100644 --- a/modules/record/keeper/keeper_test.go +++ b/modules/record/keeper/keeper_test.go @@ -29,7 +29,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(false) + app := simapp.Setup(suite.T(), false) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/modules/record/module.go b/modules/record/module.go index 6c06a7cc..7756c890 100644 --- a/modules/record/module.go +++ b/modules/record/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/record/client/cli" - "github.com/irisnet/irismod/modules/record/client/rest" "github.com/irisnet/irismod/modules/record/keeper" "github.com/irisnet/irismod/modules/record/simulation" "github.com/irisnet/irismod/modules/record/types" @@ -63,7 +62,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the record module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the record module. diff --git a/modules/record/simulation/decoder_test.go b/modules/record/simulation/decoder_test.go index 76b6b0bf..072f227c 100644 --- a/modules/record/simulation/decoder_test.go +++ b/modules/record/simulation/decoder_test.go @@ -22,7 +22,7 @@ var ( ) func TestDecodeStore(t *testing.T) { - cdc := simapp.MakeTestEncodingConfig().Marshaler + cdc := simapp.MakeTestEncodingConfig().Codec dec := simulation.NewDecodeStore(cdc) txHash := make([]byte, 32) diff --git a/modules/record/simulation/operations.go b/modules/record/simulation/operations.go index 8e958f31..e05cd52f 100644 --- a/modules/record/simulation/operations.go +++ b/modules/record/simulation/operations.go @@ -87,7 +87,7 @@ func SimulateCreateRecord(ak types.AccountKeeper, bk types.BankKeeper) simtypes. simAccount.PrivKey, ) - if _, _, err = app.Deliver(txConfig.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txConfig.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, types.EventTypeCreateRecord, err.Error()), nil, err } diff --git a/modules/record/types/genesis.pb.go b/modules/record/types/genesis.pb.go index f2a5e66d..0c555414 100644 --- a/modules/record/types/genesis.pb.go +++ b/modules/record/types/genesis.pb.go @@ -228,10 +228,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/record/types/query.pb.go b/modules/record/types/query.pb.go index afd9d175..2b3a3d97 100644 --- a/modules/record/types/query.pb.go +++ b/modules/record/types/query.pb.go @@ -404,10 +404,7 @@ func (m *QueryRecordRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -493,10 +490,7 @@ func (m *QueryRecordResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/record/types/query.pb.gw.go b/modules/record/types/query.pb.gw.go index 72b7989c..b40a7846 100644 --- a/modules/record/types/query.pb.gw.go +++ b/modules/record/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Record_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryRecordRequest @@ -88,12 +90,14 @@ func local_request_Query_Record_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Record_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -101,6 +105,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Record_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -176,7 +181,7 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Record_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "record", "records", "record_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Record_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "record", "records", "record_id"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/record/types/record.pb.go b/modules/record/types/record.pb.go index fc7f7fec..affd8b13 100644 --- a/modules/record/types/record.pb.go +++ b/modules/record/types/record.pb.go @@ -534,10 +534,7 @@ func (m *Content) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthRecord - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthRecord } if (iNdEx + skippy) > l { @@ -685,10 +682,7 @@ func (m *Record) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthRecord - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthRecord } if (iNdEx + skippy) > l { diff --git a/modules/record/types/tx.pb.go b/modules/record/types/tx.pb.go index 9d5ec687..2204c909 100644 --- a/modules/record/types/tx.pb.go +++ b/modules/record/types/tx.pb.go @@ -473,10 +473,7 @@ func (m *MsgCreateRecord) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -558,10 +555,7 @@ func (m *MsgCreateRecordResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/modules/service/client/cli/cli_test.go b/modules/service/client/cli/cli_test.go index 6275b2c6..a48c2584 100644 --- a/modules/service/client/cli/cli_test.go +++ b/modules/service/client/cli/cli_test.go @@ -49,10 +49,11 @@ func (s *IntegrationTestSuite) SetupSuite() { serviceGenesisState.Params.ComplaintRetrospect = time.Duration(time.Second) cfg.GenesisState[servicetypes.ModuleName] = cfg.Codec.MustMarshalJSON(&serviceGenesisState) + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -86,7 +87,9 @@ func (s *IntegrationTestSuite) TestService() { provider := author consumerInfo, _, _ := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - consumer := sdk.AccAddress(consumerInfo.GetPubKey().Address()) + pubKey, err := consumerInfo.GetPubKey() + s.Require().NoError(err) + consumer := sdk.AccAddress(pubKey.Address()) reqServiceFee := fmt.Sprintf("50%s", serviceDenom) reqInput := `{"header":{},"body":{}}` @@ -280,7 +283,7 @@ func (s *IntegrationTestSuite) TestService() { var requestsBz []byte for _, attribute := range event.Attributes { if string(attribute.Key) == types.AttributeKeyRequests { - requestsBz = attribute.GetValue() + requestsBz = []byte(attribute.GetValue()) } if string(attribute.Key) == types.AttributeKeyRequestContextID && string(attribute.GetValue()) == requestContextId { diff --git a/modules/service/client/rest/query.go b/modules/service/client/rest/query.go deleted file mode 100644 index 067c83fe..00000000 --- a/modules/service/client/rest/query.go +++ /dev/null @@ -1,529 +0,0 @@ -package rest - -import ( - "encoding/hex" - "fmt" - "net/http" - "strconv" - - "github.com/gorilla/mux" - - tmbytes "github.com/tendermint/tendermint/libs/bytes" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - serviceutils "github.com/irisnet/irismod/modules/service/client/utils" - "github.com/irisnet/irismod/modules/service/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // query a service definition - r.HandleFunc(fmt.Sprintf("/%s/definitions/{%s}", types.ModuleName, RestServiceName), queryDefinitionHandlerFn(cliCtx)).Methods("GET") - // query a service binding - r.HandleFunc(fmt.Sprintf("/%s/bindings/{%s}/{%s}", types.ModuleName, RestServiceName, RestProvider), queryBindingHandlerFn(cliCtx)).Methods("GET") - // query all bindings of a service definition with an optional owner - r.HandleFunc(fmt.Sprintf("/%s/bindings/{%s}", types.ModuleName, RestServiceName), queryBindingsHandlerFn(cliCtx)).Methods("GET") - // query the withdrawal address of an owner - r.HandleFunc(fmt.Sprintf("/%s/owners/{%s}/withdraw-address", types.ModuleName, RestOwner), queryWithdrawAddrHandlerFn(cliCtx)).Methods("GET") - // query a request by ID - r.HandleFunc(fmt.Sprintf("/%s/requests/{%s}", types.ModuleName, RestRequestID), queryRequestHandlerFn(cliCtx)).Methods("GET") - // query active requests by the service binding or request context ID - r.HandleFunc(fmt.Sprintf("/%s/requests/{%s}/{%s}", types.ModuleName, RestArg1, RestArg2), queryRequestsHandlerFn(cliCtx)).Methods("GET") - // query a response - r.HandleFunc(fmt.Sprintf("/%s/responses/{%s}", types.ModuleName, RestRequestID), queryResponseHandlerFn(cliCtx)).Methods("GET") - // query a request context - r.HandleFunc(fmt.Sprintf("/%s/contexts/{%s}", types.ModuleName, RestRequestContextID), queryRequestContextHandlerFn(cliCtx)).Methods("GET") - // query active responses by the request context ID and batch counter - r.HandleFunc(fmt.Sprintf("/%s/responses/{%s}/{%s}", types.ModuleName, RestRequestContextID, RestBatchCounter), queryResponsesHandlerFn(cliCtx)).Methods("GET") - // query the earned fees of a provider - r.HandleFunc(fmt.Sprintf("/%s/fees/{%s}", types.ModuleName, RestProvider), queryEarnedFeesHandlerFn(cliCtx)).Methods("GET") - // query the system schema by the schema name - r.HandleFunc(fmt.Sprintf("/%s/schemas/{%s}", types.ModuleName, RestSchemaName), querySchemaHandlerFn(cliCtx)).Methods("GET") - // query the current service parameter values - r.HandleFunc(fmt.Sprintf("/%s/params", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET") -} - -func queryDefinitionHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - - if err := types.ValidateServiceName(serviceName); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryDefinitionParams{ - ServiceName: serviceName, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryDefinition) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryBindingHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - providerStr := vars[RestProvider] - - if err := types.ValidateServiceName(serviceName); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - provider, err := sdk.AccAddressFromBech32(providerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryBindingParams{ - ServiceName: serviceName, - Provider: provider, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryBinding) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryBindingsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - ownerStr := r.FormValue("owner") - - if err := types.ValidateServiceName(serviceName); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var err error - var owner sdk.AccAddress - - if len(ownerStr) > 0 { - owner, err = sdk.AccAddressFromBech32(ownerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryBindingsParams{ - ServiceName: serviceName, - Owner: owner, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryBindings) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryWithdrawAddrHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - ownerStr := vars[RestOwner] - - owner, err := sdk.AccAddressFromBech32(ownerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryWithdrawAddressParams{ - Owner: owner, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryWithdrawAddress) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryRequestHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestIDStr := vars[RestRequestID] - - requestID, err := types.ConvertRequestID(requestIDStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryRequestParams{ - RequestID: requestID, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryRequest) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - var request types.Request - _ = cliCtx.LegacyAmino.UnmarshalJSON(res, &request) - if request.Empty() { - request, err = serviceutils.QueryRequestByTxQuery(cliCtx, types.RouterKey, params.RequestID) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - } - - if request.Empty() { - rest.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unknown request: %s", params.RequestID)) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryRequestsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - arg1 := vars[RestArg1] - arg2 := vars[RestArg2] - - queryByBinding := true - - provider, err := sdk.AccAddressFromBech32(arg2) - if err != nil { - queryByBinding = false - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - var res []types.Request - var height int64 - - if queryByBinding { - res, height, err = serviceutils.QueryRequestsByBinding(cliCtx, types.RouterKey, arg1, provider) - } else { - res, height, err = serviceutils.QueryRequestsByReqCtx(cliCtx, types.RouterKey, arg1, arg2) - } - - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryResponseHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestIDStr := vars[RestRequestID] - - requestID, err := types.ConvertRequestID(requestIDStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryResponseParams{ - RequestID: requestID, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryResponse) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - var response types.Response - _ = cliCtx.LegacyAmino.UnmarshalJSON(res, &response) - if response.Empty() { - response, err = serviceutils.QueryResponseByTxQuery(cliCtx, types.RouterKey, params.RequestID) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - } - - if response.Empty() { - rest.WriteErrorResponse(w, http.StatusInternalServerError, fmt.Sprintf("unknown request: %s", params.RequestID)) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, response) - } -} - -func queryRequestContextHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextIDStr := vars[RestRequestContextID] - - requestContextID, err := hex.DecodeString(requestContextIDStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryRequestContextRequest{ - RequestContextId: tmbytes.HexBytes(requestContextID).String(), - } - - requestContext, err := serviceutils.QueryRequestContext(cliCtx, types.RouterKey, params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - rest.PostProcessResponse(w, cliCtx, requestContext) - } -} - -func queryResponsesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextIDStr := vars[RestRequestContextID] - batchCounterStr := vars[RestBatchCounter] - - requestContextID, err := hex.DecodeString(requestContextIDStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - batchCounter, err := strconv.ParseUint(batchCounterStr, 10, 64) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryResponsesParams{ - RequestContextID: requestContextID, - BatchCounter: batchCounter, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryResponses) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func queryEarnedFeesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - providerStr := vars[RestProvider] - - provider, err := sdk.AccAddressFromBech32(providerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QueryEarnedFeesParams{ - Provider: provider, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QueryEarnedFees) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -func querySchemaHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - params := types.QuerySchemaParams{ - SchemaName: vars[RestSchemaName], - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - route := fmt.Sprintf("custom/%s/%s", types.RouterKey, types.QuerySchema) - res, height, err := cliCtx.QueryWithData(route, bz) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - var schema serviceutils.SchemaType - if err := cliCtx.LegacyAmino.UnmarshalJSON(res, &schema); err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, schema) - } -} - -func queryParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParameters) - res, height, err := cliCtx.QueryWithData(route, nil) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/service/client/rest/rest.go b/modules/service/client/rest/rest.go deleted file mode 100644 index 30b4814a..00000000 --- a/modules/service/client/rest/rest.go +++ /dev/null @@ -1,139 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// Rest variable names -// nolint -const ( - RestServiceName = "service-name" - RestRequestID = "request-id" - RestOwner = "owner" - RestProvider = "provider" - RestConsumer = "consumer" - RestRequestContextID = "request-context-id" - RestBatchCounter = "batch-counter" - RestArg1 = "arg1" - RestArg2 = "arg2" - RestSchemaName = "schema-name" -) - -// RegisterHandlers defines routes that get registered by the main application -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -// DefineServiceReq defines the properties of a define service request's body. -type DefineServiceReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Name string `json:"name" yaml:"name"` - Description string `json:"description" yaml:"description"` - Tags []string `json:"tags" yaml:"tags"` - Author string `json:"author" yaml:"author"` - AuthorDescription string `json:"author_description" yaml:"author_description"` - Schemas string `json:"schemas" yaml:"schemas"` -} - -// BindServiceReq defines the properties of a bind service request's body. -type BindServiceReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - ServiceName string `json:"service_name" yaml:"service_name"` - Provider string `json:"provider" yaml:"provider"` - Deposit string `json:"deposit" yaml:"deposit"` - Pricing string `json:"pricing" yaml:"pricing"` - QoS uint64 `json:"qos" yaml:"qos"` - Options string `json:"options" yaml:"options"` - Owner string `json:"owner" yaml:"owner"` -} - -// UpdateServiceBindingReq defines the properties of an update service binding request's body. -type UpdateServiceBindingReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Deposit string `json:"deposit" yaml:"deposit"` - Pricing string `json:"pricing" yaml:"pricing"` - QoS uint64 `json:"qos" yaml:"qos"` - Options string `json:"options" yaml:"options"` - Owner string `json:"owner" yaml:"owner"` -} - -// SetWithdrawAddrReq defines the properties of a set withdraw address request's body. -type SetWithdrawAddrReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - WithdrawAddress string `json:"withdraw_address" yaml:"withdraw_address"` -} - -// DisableServiceBindingReq defines the properties of a disable service binding request's body. -type DisableServiceBindingReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Owner string `json:"owner" yaml:"owner"` -} - -// EnableServiceBindingReq defines the properties of an enable service binding request's body. -type EnableServiceBindingReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Deposit string `json:"deposit" yaml:"deposit"` - Owner string `json:"owner" yaml:"owner"` -} - -// RefundServiceDepositReq defines the properties of a refund service deposit request's body. -type RefundServiceDepositReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Owner string `json:"owner" yaml:"owner"` -} - -type callServiceReq struct { - BaseReq rest.BaseReq `json:"base_req"` - ServiceName string `json:"service_name"` - Providers []string `json:"providers"` - Consumer string `json:"consumer"` - Input string `json:"input"` - ServiceFeeCap string `json:"service_fee_cap"` - Timeout int64 `json:"timeout"` - SuperMode bool `json:"super_mode"` - Repeated bool `json:"repeated"` - RepeatedFrequency uint64 `json:"repeated_frequency"` - RepeatedTotal int64 `json:"repeated_total"` -} - -type respondServiceReq struct { - BaseReq rest.BaseReq `json:"base_req"` - RequestID string `json:"request_id"` - Provider string `json:"provider"` - Result string `json:"result"` - Output string `json:"output"` -} - -type pauseRequestContextReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Consumer string `json:"consumer"` -} - -type startRequestContextReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Consumer string `json:"consumer"` -} - -type killRequestContextReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Consumer string `json:"consumer"` -} - -type updateRequestContextReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Providers []string `json:"providers"` - ServiceFeeCap string `json:"service_fee_cap"` - Timeout int64 `json:"timeout"` - RepeatedFrequency uint64 `json:"repeated_frequency"` - RepeatedTotal int64 `json:"repeated_total"` - Consumer string `json:"consumer"` -} - -type withdrawEarnedFeesReq struct { - BaseReq rest.BaseReq `json:"base_req" yaml:"base_req"` - Owner string `json:"owner" yaml:"owner"` -} diff --git a/modules/service/client/rest/tx.go b/modules/service/client/rest/tx.go deleted file mode 100644 index ea715952..00000000 --- a/modules/service/client/rest/tx.go +++ /dev/null @@ -1,601 +0,0 @@ -package rest - -import ( - "encoding/hex" - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/service/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - r.HandleFunc("/service/definitions", defineServiceHandlerFn(cliCtx)).Methods("POST") - r.HandleFunc("/service/bindings", bindServiceHandlerFn(cliCtx)).Methods("POST") - r.HandleFunc(fmt.Sprintf("/service/bindings/{%s}/{%s}", RestServiceName, RestProvider), updateServiceBindingHandlerFn(cliCtx)).Methods("PUT") - r.HandleFunc(fmt.Sprintf("/service/owners/{%s}/withdraw-address", RestOwner), setWithdrawAddrHandlerFn(cliCtx)).Methods("POST") - r.HandleFunc(fmt.Sprintf("/service/bindings/{%s}/{%s}/disable", RestServiceName, RestProvider), disableServiceBindingHandlerFn(cliCtx)).Methods("POST") - r.HandleFunc(fmt.Sprintf("/service/bindings/{%s}/{%s}/enable", RestServiceName, RestProvider), enableServiceBindingHandlerFn(cliCtx)).Methods("POST") - r.HandleFunc(fmt.Sprintf("/service/bindings/{%s}/{%s}/refund-deposit", RestServiceName, RestProvider), refundServiceDepositHandlerFn(cliCtx)).Methods("POST") - // initiate a service call - r.HandleFunc("/service/contexts", requestServiceHandlerFn(cliCtx)).Methods("POST") - // respond to a service request - r.HandleFunc("/service/responses", respondServiceHandlerFn(cliCtx)).Methods("POST") - // pause a request context - r.HandleFunc(fmt.Sprintf("/service/contexts/{%s}/pause", RestRequestContextID), pauseRequestContextHandlerFn(cliCtx)).Methods("POST") - // start a paused request context - r.HandleFunc(fmt.Sprintf("/service/contexts/{%s}/start", RestRequestContextID), startRequestContextHandlerFn(cliCtx)).Methods("POST") - // kill a request context - r.HandleFunc(fmt.Sprintf("/service/contexts/{%s}/kill", RestRequestContextID), killRequestContextHandlerFn(cliCtx)).Methods("POST") - // update a request context - r.HandleFunc(fmt.Sprintf("/service/contexts/{%s}", RestRequestContextID), updateRequestContextHandlerFn(cliCtx)).Methods("PUT") - // withdraw the earned fees of a provider - r.HandleFunc(fmt.Sprintf("/service/fees/{%s}/withdraw", RestProvider), withdrawEarnedFeesHandlerFn(cliCtx)).Methods("POST") -} - -func defineServiceHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req DefineServiceReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Author); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgDefineService(req.Name, req.Description, req.Tags, req.Author, req.AuthorDescription, req.Schemas) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func bindServiceHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req BindServiceReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - provider := req.Owner - if len(req.Provider) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - provider = req.Provider - } - - deposit, err := sdk.ParseCoinsNormalized(req.Deposit) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgBindService(req.ServiceName, provider, deposit, req.Pricing, req.QoS, req.Options, req.Owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - - } -} - -func updateServiceBindingHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - provider := vars[RestProvider] - - if _, err := sdk.AccAddressFromBech32(provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req UpdateServiceBindingReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - owner := provider - if len(req.Owner) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - owner = req.Owner - } - - var deposit sdk.Coins - var err error - if req.Deposit != "" { - deposit, err = sdk.ParseCoinsNormalized(req.Deposit) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - msg := types.NewMsgUpdateServiceBinding(serviceName, provider, deposit, req.Pricing, req.QoS, req.Options, owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - - } -} - -func setWithdrawAddrHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - owner := vars[RestOwner] - - if _, err := sdk.AccAddressFromBech32(owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req SetWithdrawAddrReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.WithdrawAddress); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgSetWithdrawAddress(owner, req.WithdrawAddress) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - - } -} - -func disableServiceBindingHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - provider := vars[RestProvider] - - if _, err := sdk.AccAddressFromBech32(provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req DisableServiceBindingReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - owner := provider - if len(req.Owner) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - owner = req.Owner - } - - msg := types.NewMsgDisableServiceBinding(serviceName, provider, owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func enableServiceBindingHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - provider := vars[RestProvider] - - if _, err := sdk.AccAddressFromBech32(provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req EnableServiceBindingReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - owner := provider - if len(req.Owner) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - owner = req.Owner - } - - var deposit sdk.Coins - var err error - if len(req.Deposit) != 0 { - deposit, err = sdk.ParseCoinsNormalized(req.Deposit) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - msg := types.NewMsgEnableServiceBinding(serviceName, provider, deposit, owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func refundServiceDepositHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - serviceName := vars[RestServiceName] - provider := vars[RestProvider] - - if _, err := sdk.AccAddressFromBech32(provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req RefundServiceDepositReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - owner := provider - if len(req.Owner) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - owner = req.Owner - } - - msg := types.NewMsgRefundServiceDeposit(serviceName, provider, owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func requestServiceHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req callServiceReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Consumer); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - serviceFeeCap, err := sdk.ParseCoinsNormalized(req.ServiceFeeCap) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - for _, p := range req.Providers { - if _, err := sdk.AccAddressFromBech32(p); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - msg := types.NewMsgCallService( - req.ServiceName, req.Providers, req.Consumer, req.Input, serviceFeeCap, - req.Timeout, req.Repeated, req.RepeatedFrequency, req.RepeatedTotal, - ) - if err = msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func respondServiceHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req respondServiceReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := types.ConvertRequestID(req.RequestID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - if _, err := sdk.AccAddressFromBech32(req.Provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgRespondService(req.RequestID, req.Provider, req.Result, req.Output) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func pauseRequestContextHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextID := vars[RestRequestContextID] - - if _, err := hex.DecodeString(requestContextID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req pauseRequestContextReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Consumer); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgPauseRequestContext(requestContextID, req.Consumer) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func startRequestContextHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextID := vars[RestRequestContextID] - - if _, err := hex.DecodeString(requestContextID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req startRequestContextReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Consumer); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgStartRequestContext(requestContextID, req.Consumer) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func killRequestContextHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextID := vars[RestRequestContextID] - - if _, err := hex.DecodeString(requestContextID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req killRequestContextReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Consumer); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - msg := types.NewMsgKillRequestContext(requestContextID, req.Consumer) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func updateRequestContextHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - requestContextID := vars[RestRequestContextID] - - if _, err := hex.DecodeString(requestContextID); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req updateRequestContextReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - if _, err := sdk.AccAddressFromBech32(req.Consumer); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var serviceFeeCap sdk.Coins - var err error - if len(req.ServiceFeeCap) != 0 { - serviceFeeCap, err = sdk.ParseCoinsNormalized(req.ServiceFeeCap) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - for _, p := range req.Providers { - if _, err := sdk.AccAddressFromBech32(p); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - msg := types.NewMsgUpdateRequestContext( - requestContextID, req.Providers, serviceFeeCap, req.Timeout, - req.RepeatedFrequency, req.RepeatedTotal, req.Consumer, - ) - if err = msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func withdrawEarnedFeesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - provider := vars[RestProvider] - - if _, err := sdk.AccAddressFromBech32(provider); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - var req withdrawEarnedFeesReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - req.BaseReq = req.BaseReq.Sanitize() - if !req.BaseReq.ValidateBasic(w) { - return - } - - owner := provider - if len(req.Owner) > 0 { - if _, err := sdk.AccAddressFromBech32(req.Owner); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - owner = req.Owner - } - - msg := types.NewMsgWithdrawEarnedFees(owner, provider) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/service/client/rest/grpc_query_test.go b/modules/service/client/testutil/grpc_query_test.go similarity index 98% rename from modules/service/client/rest/grpc_query_test.go rename to modules/service/client/testutil/grpc_query_test.go index 662e2971..f41cb606 100644 --- a/modules/service/client/rest/grpc_query_test.go +++ b/modules/service/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "context" @@ -7,7 +7,7 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/types/rest" + "github.com/cosmos/cosmos-sdk/testutil/rest" "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" @@ -48,9 +48,11 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.GenesisState[servicetypes.ModuleName] = cfg.Codec.MustMarshalJSON(&serviceGenesisState) s.cfg = cfg - s.network = network.New(s.T(), cfg) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } @@ -85,7 +87,9 @@ func (s *IntegrationTestSuite) TestService() { provider := author consumerInfo, _, _ := val.ClientCtx.Keyring.NewMnemonic("NewValidator", keyring.English, sdk.FullFundraiserPath, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - consumer := sdk.AccAddress(consumerInfo.GetPubKey().Address()) + + consumer, err := consumerInfo.GetAddress() + s.Require().NoError(err) reqServiceFee := fmt.Sprintf("50%s", serviceDenom) reqInput := `{"header":{},"body":{}}` diff --git a/modules/service/client/utils/query.go b/modules/service/client/utils/query.go index 6b572c5c..c5b0a5b7 100644 --- a/modules/service/client/utils/query.go +++ b/modules/service/client/utils/query.go @@ -151,7 +151,7 @@ func QueryRequestByTxQuery( var requestsBz []byte for _, attribute := range event.Attributes { if string(attribute.Key) == types.AttributeKeyRequests { - requestsBz = attribute.GetValue() + requestsBz = []byte(attribute.GetValue()) } if string(attribute.Key) == types.AttributeKeyRequestContextID && string(attribute.GetValue()) == contextID.String() { diff --git a/modules/service/genesis.go b/modules/service/genesis.go index 749f58d6..47ef9afb 100644 --- a/modules/service/genesis.go +++ b/modules/service/genesis.go @@ -3,6 +3,7 @@ package service import ( "encoding/hex" "fmt" + "sort" tmbytes "github.com/tendermint/tendermint/libs/bytes" @@ -30,15 +31,15 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, data types.GenesisState) { } } - for ownerAddressStr, withdrawAddress := range data.WithdrawAddresses { + for _, ownerAddressStr := range getSortedKeys(data.WithdrawAddresses) { ownerAddress, _ := sdk.AccAddressFromBech32(ownerAddressStr) - withdrawAddress, _ := sdk.AccAddressFromBech32(withdrawAddress) + withdrawAddress, _ := sdk.AccAddressFromBech32(data.WithdrawAddresses[ownerAddressStr]) k.SetWithdrawAddress(ctx, ownerAddress, withdrawAddress) } - for reqContextIDStr, requestContext := range data.RequestContexts { + for _, reqContextIDStr := range getSortedKeys(data.RequestContexts) { requestContextID, _ := hex.DecodeString(reqContextIDStr) - k.SetRequestContext(ctx, requestContextID, *requestContext) + k.SetRequestContext(ctx, requestContextID, *data.RequestContexts[reqContextIDStr]) } } @@ -107,3 +108,12 @@ func PrepForZeroHeightGenesis(ctx sdk.Context, k keeper.Keeper) { panic(fmt.Sprintf("failed to reset the request context state: %s", err)) } } + +func getSortedKeys[T string | *types.RequestContext](m map[string]T) []string { + keys := make([]string, 0, len(m)) + for k := range m { + keys = append(keys, k) + } + sort.Strings(keys) + return keys +} diff --git a/modules/service/keeper/binding.go b/modules/service/keeper/binding.go index c8085bce..e3d2e0cd 100644 --- a/modules/service/keeper/binding.go +++ b/modules/service/keeper/binding.go @@ -8,7 +8,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - v040 "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" + v042 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" "github.com/irisnet/irismod/modules/service/types" ) @@ -438,7 +438,7 @@ func (k Keeper) GetOwnerServiceBindings(ctx sdk.Context, owner sdk.AccAddress, s defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - bindingKey := iterator.Key()[v040.AddrLen+1:] + bindingKey := iterator.Key()[v042.AddrLen+1:] sepIndex := bytes.Index(bindingKey, types.Delimiter) serviceName := string(bindingKey[0:sepIndex]) provider := sdk.AccAddress(bindingKey[sepIndex+1:]) diff --git a/modules/service/keeper/fees.go b/modules/service/keeper/fees.go index bba6d6a7..e5d6d1a2 100644 --- a/modules/service/keeper/fees.go +++ b/modules/service/keeper/fees.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - v040 "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" + v042 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" "github.com/irisnet/irismod/modules/service/types" ) @@ -29,7 +29,7 @@ func (k Keeper) AddEarnedFee(ctx sdk.Context, provider sdk.AccAddress, fee sdk.C return err } - earnedFee, hasNeg := fee.SafeSub(taxCoins) + earnedFee, hasNeg := fee.SafeSub(taxCoins...) if hasNeg { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "%s is less than %s", fee, taxCoins) } @@ -145,7 +145,7 @@ func (k Keeper) WithdrawEarnedFees(ctx sdk.Context, owner, provider sdk.AccAddre if earnedFees.IsEqual(ownerEarnedFees) { k.DeleteOwnerEarnedFees(ctx, owner) } else { - k.SetOwnerEarnedFees(ctx, owner, ownerEarnedFees.Sub(earnedFees)) + k.SetOwnerEarnedFees(ctx, owner, ownerEarnedFees.Sub(earnedFees...)) } withdrawFees = earnedFees @@ -154,7 +154,7 @@ func (k Keeper) WithdrawEarnedFees(ctx sdk.Context, owner, provider sdk.AccAddre defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - provider := sdk.AccAddress(iterator.Key()[v040.AddrLen+1:]) + provider := sdk.AccAddress(iterator.Key()[v042.AddrLen+1:]) k.DeleteEarnedFees(ctx, provider) } diff --git a/modules/service/keeper/invocation.go b/modules/service/keeper/invocation.go index 21964792..1b85a8b8 100644 --- a/modules/service/keeper/invocation.go +++ b/modules/service/keeper/invocation.go @@ -1073,7 +1073,7 @@ func (k Keeper) Slash(ctx sdk.Context, requestID tmbytes.HexBytes) error { slashedAmt := sdk.NewDecFromInt(depositAmt).Mul(slashFraction).TruncateInt() slashedCoins := sdk.NewCoins(sdk.NewCoin(baseDenom, slashedAmt)) - deposit, hasNeg := binding.Deposit.SafeSub(slashedCoins) + deposit, hasNeg := binding.Deposit.SafeSub(slashedCoins...) if hasNeg { return sdkerrors.Wrapf(sdkerrors.ErrInsufficientFunds, "%s is less than %s", binding.Deposit.String(), slashedCoins.String()) } diff --git a/modules/service/keeper/keeper.go b/modules/service/keeper/keeper.go index 01ea5f33..a12cdc2e 100644 --- a/modules/service/keeper/keeper.go +++ b/modules/service/keeper/keeper.go @@ -6,6 +6,7 @@ import ( "github.com/tendermint/tendermint/libs/log" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -15,7 +16,7 @@ import ( // Keeper defines the service keeper type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.Codec accountKeeper types.AccountKeeper bankKeeper types.BankKeeper @@ -30,7 +31,7 @@ type Keeper struct { // NewKeeper creates a new service Keeper instance func NewKeeper( cdc codec.Codec, - key sdk.StoreKey, + key storetypes.StoreKey, accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, paramSpace paramstypes.Subspace, diff --git a/modules/service/keeper/keeper_test.go b/modules/service/keeper/keeper_test.go index 063cacf6..a6e0d984 100644 --- a/modules/service/keeper/keeper_test.go +++ b/modules/service/keeper/keeper_test.go @@ -9,7 +9,7 @@ import ( "github.com/stretchr/testify/suite" "github.com/tidwall/gjson" - v040 "github.com/cosmos/cosmos-sdk/x/auth/legacy/v040" + v042 "github.com/cosmos/cosmos-sdk/x/auth/migrations/v042" abci "github.com/tendermint/tendermint/abci/types" tmbytes "github.com/tendermint/tendermint/libs/bytes" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" @@ -86,7 +86,7 @@ func TestKeeperTestSuite(t *testing.T) { func (suite *KeeperTestSuite) SetupTest() { isCheckTx := false - app := simapp.Setup(isCheckTx) + app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) @@ -186,7 +186,7 @@ func (suite *KeeperTestSuite) TestBindService() { defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - suite.Equal(testProvider, sdk.AccAddress(iterator.Key()[v040.AddrLen+1:])) + suite.Equal(testProvider, sdk.AccAddress(iterator.Key()[v042.AddrLen+1:])) } // update binding diff --git a/modules/service/module.go b/modules/service/module.go index 852cc4e1..fe077a75 100644 --- a/modules/service/module.go +++ b/modules/service/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/service/client/cli" - "github.com/irisnet/irismod/modules/service/client/rest" "github.com/irisnet/irismod/modules/service/keeper" "github.com/irisnet/irismod/modules/service/simulation" "github.com/irisnet/irismod/modules/service/types" @@ -63,7 +62,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the service module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the service module. diff --git a/modules/service/simulation/operations.go b/modules/service/simulation/operations.go index 0f49c030..be5f5247 100644 --- a/modules/service/simulation/operations.go +++ b/modules/service/simulation/operations.go @@ -1,6 +1,7 @@ package simulation import ( + "errors" "fmt" "math/rand" @@ -157,10 +158,10 @@ func WeightedOperations( weightMsgDefineService, SimulateMsgDefineService(ak, bk, k), ), - simulation.NewWeightedOperation( - weightMsgBindService, - SimulateMsgBindService(ak, bk, k), - ), + // simulation.NewWeightedOperation( + // weightMsgBindService, + // SimulateMsgBindService(ak, bk, k), + // ), simulation.NewWeightedOperation( weightMsgUpdateServiceBinding, SimulateMsgUpdateServiceBinding(ak, bk, k), @@ -237,7 +238,8 @@ func SimulateMsgDefineService(ak types.AccountKeeper, bk types.BankKeeper, k kee } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -251,7 +253,7 @@ func SimulateMsgDefineService(ak types.AccountKeeper, bk types.BankKeeper, k kee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -265,8 +267,8 @@ func SimulateMsgBindService(ak types.AccountKeeper, bk types.BankKeeper, k keepe r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - def := GenServiceDefinition(r, k, ctx) - if def.Size() == 0 { + def, err := GenServiceDefinition(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBindService, "def not exsit"), nil, nil } @@ -297,6 +299,9 @@ func SimulateMsgBindService(ak types.AccountKeeper, bk types.BankKeeper, k keepe // random provider address provider, _ := simtypes.RandomAcc(r, accs) + if provider.Address == nil { + return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBindService, "service binding provider invalid"), nil, nil + } currentOwner, found := k.GetOwner(ctx, provider.Address) if found && !owner.Equals(currentOwner) { @@ -311,7 +316,7 @@ func SimulateMsgBindService(ak types.AccountKeeper, bk types.BankKeeper, k keepe options := "{}" msg := types.NewMsgBindService(def.Name, provider.Address.String(), deposit, pricing, qos, options, def.Author) - spendable, hasNeg := spendable.SafeSub(deposit) + spendable, hasNeg := spendable.SafeSub(deposit...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBindService, "Insufficient funds"), nil, nil } @@ -322,7 +327,8 @@ func SimulateMsgBindService(ak types.AccountKeeper, bk types.BankKeeper, k keepe } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -336,7 +342,7 @@ func SimulateMsgBindService(ak types.AccountKeeper, bk types.BankKeeper, k keepe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -350,8 +356,8 @@ func SimulateMsgUpdateServiceBinding(ak types.AccountKeeper, bk types.BankKeeper r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUpdateServiceBinding, "binding not exist"), nil, nil } owner, err := sdk.AccAddressFromBech32(binding.Owner) @@ -380,7 +386,7 @@ func SimulateMsgUpdateServiceBinding(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBindService, "invalid minimum deposit"), nil, nil } - spendable, hasNeg := spendable.SafeSub(deposit) + spendable, hasNeg := spendable.SafeSub(deposit...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUpdateServiceBinding, "Insufficient funds"), nil, nil } @@ -393,7 +399,8 @@ func SimulateMsgUpdateServiceBinding(ak types.AccountKeeper, bk types.BankKeeper } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -407,7 +414,7 @@ func SimulateMsgUpdateServiceBinding(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -423,8 +430,8 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper, withdrawalAccount, _ := simtypes.RandomAcc(r, accs) - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgSetWithdrawAddress, "binding not exist"), nil, nil } owner, err := sdk.AccAddressFromBech32(binding.Owner) @@ -447,7 +454,8 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper, } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -461,7 +469,7 @@ func SimulateMsgSetWithdrawAddress(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -475,8 +483,8 @@ func SimulateMsgDisableServiceBinding(ak types.AccountKeeper, bk types.BankKeepe r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgDisableServiceBinding, "binding not exist"), nil, nil } if !binding.Available { @@ -502,7 +510,8 @@ func SimulateMsgDisableServiceBinding(ak types.AccountKeeper, bk types.BankKeepe } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -516,7 +525,7 @@ func SimulateMsgDisableServiceBinding(ak types.AccountKeeper, bk types.BankKeepe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -530,8 +539,8 @@ func SimulateMsgEnableServiceBinding(ak types.AccountKeeper, bk types.BankKeeper r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgEnableServiceBinding, "binding not exist"), nil, nil } if binding.Available { @@ -559,7 +568,7 @@ func SimulateMsgEnableServiceBinding(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBindService, "invalid minimum deposit"), nil, nil } - spendable, hasNeg := spendable.SafeSub(deposit) + spendable, hasNeg := spendable.SafeSub(deposit...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgUpdateServiceBinding, "Insufficient funds"), nil, nil } @@ -572,7 +581,8 @@ func SimulateMsgEnableServiceBinding(ak types.AccountKeeper, bk types.BankKeeper } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -586,7 +596,7 @@ func SimulateMsgEnableServiceBinding(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -600,8 +610,8 @@ func SimulateMsgRefundServiceDeposit(ak types.AccountKeeper, bk types.BankKeeper r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - binding := GenServiceBindingDisabled(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBindingDisabled(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgRefundServiceDeposit, "binding not exist"), nil, nil } @@ -637,7 +647,8 @@ func SimulateMsgRefundServiceDeposit(ak types.AccountKeeper, bk types.BankKeeper } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -651,7 +662,7 @@ func SimulateMsgRefundServiceDeposit(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -666,8 +677,8 @@ func SimulateMsgCallService(ak types.AccountKeeper, bk types.BankKeeper, k keepe ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { simAccount, _ := simtypes.RandomAcc(r, accs) account := ak.GetAccount(ctx, simAccount.Address) - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCallService, "binding not exist"), nil, nil } definition, found := k.GetServiceDefinition(ctx, binding.ServiceName) @@ -693,7 +704,7 @@ func SimulateMsgCallService(ak types.AccountKeeper, bk types.BankKeeper, k keepe serviceFeeCap, timeout, repeated, repeatedFrequency, repeatedTotal) spendable := bk.SpendableCoins(ctx, account.GetAddress()) - spendable, hasNeg := spendable.SafeSub(serviceFeeCap) + spendable, hasNeg := spendable.SafeSub(serviceFeeCap...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCallService, "Insufficient funds"), nil, nil } @@ -719,7 +730,7 @@ func SimulateMsgCallService(ak types.AccountKeeper, bk types.BankKeeper, k keepe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txConfig.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txConfig.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -761,7 +772,8 @@ func SimulateMsgRespondService(ak types.AccountKeeper, bk types.BankKeeper, k ke } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -775,7 +787,7 @@ func SimulateMsgRespondService(ak types.AccountKeeper, bk types.BankKeeper, k ke return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -822,7 +834,8 @@ func SimulateMsgPauseRequestContext(ak types.AccountKeeper, bk types.BankKeeper, } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -836,7 +849,7 @@ func SimulateMsgPauseRequestContext(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -887,7 +900,8 @@ func SimulateMsgStartRequestContext(ak types.AccountKeeper, bk types.BankKeeper, } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -901,7 +915,7 @@ func SimulateMsgStartRequestContext(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -951,7 +965,8 @@ func SimulateMsgKillRequestContext(ak types.AccountKeeper, bk types.BankKeeper, } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -965,7 +980,7 @@ func SimulateMsgKillRequestContext(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -1020,7 +1035,7 @@ func SimulateMsgUpdateRequestContext(ak types.AccountKeeper, bk types.BankKeeper account := ak.GetAccount(ctx, acc.Address) spendable := bk.SpendableCoins(ctx, account.GetAddress()) - spendable, hasNeg := spendable.SafeSub(serviceFeeCap) + spendable, hasNeg := spendable.SafeSub(serviceFeeCap...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgCallService, "Insufficient funds"), nil, nil @@ -1032,7 +1047,8 @@ func SimulateMsgUpdateRequestContext(ak types.AccountKeeper, bk types.BankKeeper } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -1046,7 +1062,7 @@ func SimulateMsgUpdateRequestContext(ak types.AccountKeeper, bk types.BankKeeper return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -1060,8 +1076,8 @@ func SimulateMsgWithdrawEarnedFees(ak types.AccountKeeper, bk types.BankKeeper, r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { - binding := GenServiceBinding(r, k, ctx) - if binding.Size() == 0 { + binding, err := GenServiceBinding(r, k, ctx) + if err != nil { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgWithdrawEarnedFees, "binding not found"), nil, nil } @@ -1085,7 +1101,8 @@ func SimulateMsgWithdrawEarnedFees(ak types.AccountKeeper, bk types.BankKeeper, } txGen := cosmossimappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -1099,7 +1116,7 @@ func SimulateMsgWithdrawEarnedFees(ak types.AccountKeeper, bk types.BankKeeper, return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err := app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err := app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -1109,7 +1126,7 @@ func SimulateMsgWithdrawEarnedFees(ak types.AccountKeeper, bk types.BankKeeper, } // GenServiceDefinition randomized serviceDefinition -func GenServiceDefinition(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) types.ServiceDefinition { +func GenServiceDefinition(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) (types.ServiceDefinition, error) { var definitions []types.ServiceDefinition k.IterateServiceDefinitions( ctx, @@ -1119,13 +1136,13 @@ func GenServiceDefinition(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) types. }, ) if len(definitions) > 0 { - return definitions[r.Intn(len(definitions))] + return definitions[r.Intn(len(definitions))], nil } - return types.ServiceDefinition{} + return types.ServiceDefinition{}, errors.New("no service definition") } // GenServiceBinding randomized serviceBinding -func GenServiceBinding(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) types.ServiceBinding { +func GenServiceBinding(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) (types.ServiceBinding, error) { var bindings []types.ServiceBinding k.IterateServiceBindings( ctx, @@ -1135,13 +1152,13 @@ func GenServiceBinding(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) types.Ser }, ) if len(bindings) > 0 { - return bindings[r.Intn(len(bindings))] + return bindings[r.Intn(len(bindings))], nil } - return types.ServiceBinding{} + return types.ServiceBinding{}, errors.New("no service binding") } // GenServiceBindingDisabled randomized serviceBindingDisabled -func GenServiceBindingDisabled(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) types.ServiceBinding { +func GenServiceBindingDisabled(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) (types.ServiceBinding, error) { var bindings []types.ServiceBinding k.IterateServiceBindings( ctx, @@ -1154,9 +1171,9 @@ func GenServiceBindingDisabled(r *rand.Rand, k keeper.Keeper, ctx sdk.Context) t }, ) if len(bindings) > 0 { - return bindings[r.Intn(len(bindings))] + return bindings[r.Intn(len(bindings))], nil } - return types.ServiceBinding{} + return types.ServiceBinding{}, errors.New("no service binding") } // GenRequestContextId randomized requestContext diff --git a/modules/service/types/genesis.pb.go b/modules/service/types/genesis.pb.go index 54d6f4ab..51afc62c 100644 --- a/modules/service/types/genesis.pb.go +++ b/modules/service/types/genesis.pb.go @@ -552,7 +552,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > postIndex { @@ -681,7 +681,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > postIndex { @@ -698,10 +698,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/service/types/query.pb.go b/modules/service/types/query.pb.go index 4b27d3dd..e960f675 100644 --- a/modules/service/types/query.pb.go +++ b/modules/service/types/query.pb.go @@ -335,7 +335,8 @@ func (m *QueryBindingsResponse) GetPagination() *query.PageResponse { return nil } -// QueryWithdrawAddressRequest is request type for the Query/WithdrawAddress RPC method +// QueryWithdrawAddressRequest is request type for the Query/WithdrawAddress RPC +// method type QueryWithdrawAddressRequest struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` } @@ -380,7 +381,8 @@ func (m *QueryWithdrawAddressRequest) GetOwner() string { return "" } -// QueryWithdrawAddressResponse is response type for the Query/WithdrawAddress RPC method +// QueryWithdrawAddressResponse is response type for the Query/WithdrawAddress +// RPC method type QueryWithdrawAddressResponse struct { WithdrawAddress string `protobuf:"bytes,1,opt,name=withdraw_address,json=withdrawAddress,proto3" json:"withdraw_address,omitempty"` } @@ -425,7 +427,8 @@ func (m *QueryWithdrawAddressResponse) GetWithdrawAddress() string { return "" } -// QueryRequestContextRequest is request type for the Query/RequestContext RPC method +// QueryRequestContextRequest is request type for the Query/RequestContext RPC +// method type QueryRequestContextRequest struct { RequestContextId string `protobuf:"bytes,1,opt,name=request_context_id,json=requestContextId,proto3" json:"request_context_id,omitempty"` } @@ -470,7 +473,8 @@ func (m *QueryRequestContextRequest) GetRequestContextId() string { return "" } -// QueryRequestContextResponse is response type for the Query/RequestContext RPC method +// QueryRequestContextResponse is response type for the Query/RequestContext RPC +// method type QueryRequestContextResponse struct { RequestContext *RequestContext `protobuf:"bytes,1,opt,name=request_context,json=requestContext,proto3" json:"request_context,omitempty"` } @@ -719,7 +723,8 @@ func (m *QueryRequestsResponse) GetPagination() *query.PageResponse { return nil } -// QueryRequestsByReqCtxRequest is request type for the Query/RequestsByReqCtx RPC method +// QueryRequestsByReqCtxRequest is request type for the Query/RequestsByReqCtx +// RPC method type QueryRequestsByReqCtxRequest struct { RequestContextId string `protobuf:"bytes,1,opt,name=request_context_id,json=requestContextId,proto3" json:"request_context_id,omitempty"` BatchCounter uint64 `protobuf:"varint,2,opt,name=batch_counter,json=batchCounter,proto3" json:"batch_counter,omitempty"` @@ -780,7 +785,8 @@ func (m *QueryRequestsByReqCtxRequest) GetPagination() *query.PageRequest { return nil } -// QueryRequestsByReqCtxResponse is response type for the Query/RequestsByReqCtx RPC method +// QueryRequestsByReqCtxResponse is response type for the Query/RequestsByReqCtx +// RPC method type QueryRequestsByReqCtxResponse struct { Requests []*Request `protobuf:"bytes,1,rep,name=requests,proto3" json:"requests,omitempty"` Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` @@ -3418,10 +3424,7 @@ func (m *QueryDefinitionRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3507,10 +3510,7 @@ func (m *QueryDefinitionResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3624,10 +3624,7 @@ func (m *QueryBindingRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3713,10 +3710,7 @@ func (m *QueryBindingResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3866,10 +3860,7 @@ func (m *QueryBindingsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -3989,10 +3980,7 @@ func (m *QueryBindingsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4074,10 +4062,7 @@ func (m *QueryWithdrawAddressRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4159,10 +4144,7 @@ func (m *QueryWithdrawAddressResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4244,10 +4226,7 @@ func (m *QueryRequestContextRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4333,10 +4312,7 @@ func (m *QueryRequestContextResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4418,10 +4394,7 @@ func (m *QueryRequestRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4507,10 +4480,7 @@ func (m *QueryRequestResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4660,10 +4630,7 @@ func (m *QueryRequestsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4783,10 +4750,7 @@ func (m *QueryRequestsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -4923,10 +4887,7 @@ func (m *QueryRequestsByReqCtxRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5046,10 +5007,7 @@ func (m *QueryRequestsByReqCtxResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5131,10 +5089,7 @@ func (m *QueryResponseRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5220,10 +5175,7 @@ func (m *QueryResponseResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5360,10 +5312,7 @@ func (m *QueryResponsesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5483,10 +5432,7 @@ func (m *QueryResponsesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5568,10 +5514,7 @@ func (m *QueryEarnedFeesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5655,10 +5598,7 @@ func (m *QueryEarnedFeesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5740,10 +5680,7 @@ func (m *QuerySchemaRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5825,10 +5762,7 @@ func (m *QuerySchemaResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -5878,10 +5812,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -6000,10 +5931,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/service/types/query.pb.gw.go b/modules/service/types/query.pb.gw.go index 52b043e5..8f074691 100644 --- a/modules/service/types/query.pb.gw.go +++ b/modules/service/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Definition_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryDefinitionRequest @@ -860,12 +862,14 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Definition_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -873,6 +877,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Definition_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -886,6 +891,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Binding_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -893,6 +900,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Binding_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -906,6 +914,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Bindings_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -913,6 +923,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Bindings_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -926,6 +937,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_WithdrawAddress_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -933,6 +946,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_WithdrawAddress_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -946,6 +960,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_RequestContext_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -953,6 +969,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_RequestContext_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -966,6 +983,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Request_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -973,6 +992,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Request_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -986,6 +1006,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Requests_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -993,6 +1015,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Requests_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1006,6 +1029,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_RequestsByReqCtx_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1013,6 +1038,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_RequestsByReqCtx_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1026,6 +1052,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Response_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1033,6 +1061,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Response_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1046,6 +1075,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Responses_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1053,6 +1084,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Responses_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1066,6 +1098,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_EarnedFees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1073,6 +1107,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_EarnedFees_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1086,6 +1121,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Schema_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1093,6 +1130,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Schema_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1106,6 +1144,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -1113,6 +1153,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -1428,31 +1469,31 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Definition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "definitions", "service_name"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Definition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "definitions", "service_name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Binding_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "bindings", "service_name", "provider"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Binding_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "bindings", "service_name", "provider"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Bindings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "bindings", "service_name"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Bindings_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "bindings", "service_name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_WithdrawAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "service", "owners", "owner", "withdraw-address"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_WithdrawAddress_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "service", "owners", "owner", "withdraw-address"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RequestContext_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "contexts", "request_context_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_RequestContext_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "contexts", "request_context_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Request_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "requests", "request_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Request_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "requests", "request_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Requests_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "requests", "service_name", "provider"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Requests_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "requests", "service_name", "provider"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_RequestsByReqCtx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "requests", "request_context_id", "batch_counter"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_RequestsByReqCtx_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "requests", "request_context_id", "batch_counter"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Response_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "responses", "request_id"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Response_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "responses", "request_id"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Responses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "responses", "request_context_id", "batch_counter"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Responses_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"irismod", "service", "responses", "request_context_id", "batch_counter"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_EarnedFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "fees", "provider"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_EarnedFees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "fees", "provider"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Schema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "schemas", "schema_name"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Schema_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "service", "schemas", "schema_name"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "service", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "service", "params"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/service/types/service.pb.go b/modules/service/types/service.pb.go index 4e705650..cbcc5c5b 100644 --- a/modules/service/types/service.pb.go +++ b/modules/service/types/service.pb.go @@ -10,8 +10,8 @@ import ( _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - _ "github.com/golang/protobuf/ptypes/duration" - _ "github.com/golang/protobuf/ptypes/timestamp" + _ "google.golang.org/protobuf/types/known/durationpb" + _ "google.golang.org/protobuf/types/known/timestamppb" io "io" math "math" math_bits "math/bits" @@ -31,7 +31,8 @@ var _ = time.Kitchen // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -// RequestContextBatchState is a type alias that represents a request batch status as a byte +// RequestContextBatchState is a type alias that represents a request batch +// status as a byte type RequestContextBatchState int32 const ( @@ -55,7 +56,8 @@ func (RequestContextBatchState) EnumDescriptor() ([]byte, []int) { return fileDescriptor_e51e679f9ae460e2, []int{0} } -// RequestContextState is a type alias that represents a request status as a byte +// RequestContextState is a type alias that represents a request status as a +// byte type RequestContextState int32 const ( @@ -2110,10 +2112,7 @@ func (m *ServiceDefinition) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -2429,10 +2428,7 @@ func (m *ServiceBinding) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -2886,10 +2882,7 @@ func (m *RequestContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -3222,10 +3215,7 @@ func (m *Request) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -3430,10 +3420,7 @@ func (m *CompactRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -3662,10 +3649,7 @@ func (m *Response) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -3817,10 +3801,7 @@ func (m *Pricing) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -3970,10 +3951,7 @@ func (m *PromotionByTime) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -4076,10 +4054,7 @@ func (m *PromotionByVolume) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { @@ -4406,10 +4381,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthService - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthService } if (iNdEx + skippy) > l { diff --git a/modules/service/types/tx.pb.go b/modules/service/types/tx.pb.go index c61f8ed6..7ed4a601 100644 --- a/modules/service/types/tx.pb.go +++ b/modules/service/types/tx.pb.go @@ -191,7 +191,8 @@ func (m *MsgBindServiceResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgBindServiceResponse proto.InternalMessageInfo -// MsgUpdateServiceBinding defines an SDK message for updating an existing service binding +// MsgUpdateServiceBinding defines an SDK message for updating an existing +// service binding type MsgUpdateServiceBinding struct { ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty" yaml:"service_name"` Provider string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"` @@ -235,7 +236,8 @@ func (m *MsgUpdateServiceBinding) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateServiceBinding proto.InternalMessageInfo -// MsgUpdateServiceBindingResponse defines the Msg/UpdateServiceBinding response type +// MsgUpdateServiceBindingResponse defines the Msg/UpdateServiceBinding response +// type type MsgUpdateServiceBindingResponse struct { } @@ -272,7 +274,8 @@ func (m *MsgUpdateServiceBindingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateServiceBindingResponse proto.InternalMessageInfo -// MsgSetWithdrawAddress defines an SDK message to set the withdrawal address for a provider +// MsgSetWithdrawAddress defines an SDK message to set the withdrawal address +// for a provider type MsgSetWithdrawAddress struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` WithdrawAddress string `protobuf:"bytes,2,opt,name=withdraw_address,json=withdrawAddress,proto3" json:"withdraw_address,omitempty" yaml:"withdraw_address"` @@ -311,7 +314,8 @@ func (m *MsgSetWithdrawAddress) XXX_DiscardUnknown() { var xxx_messageInfo_MsgSetWithdrawAddress proto.InternalMessageInfo -// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type +// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response +// type type MsgSetWithdrawAddressResponse struct { } @@ -388,7 +392,8 @@ func (m *MsgDisableServiceBinding) XXX_DiscardUnknown() { var xxx_messageInfo_MsgDisableServiceBinding proto.InternalMessageInfo -// MsgDisableServiceBindingResponse defines the Msg/DisableServiceBinding response type +// MsgDisableServiceBindingResponse defines the Msg/DisableServiceBinding +// response type type MsgDisableServiceBindingResponse struct { } @@ -466,7 +471,8 @@ func (m *MsgEnableServiceBinding) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEnableServiceBinding proto.InternalMessageInfo -// MsgEnableServiceBindingResponse defines the Msg/EnableServiceBinding response type +// MsgEnableServiceBindingResponse defines the Msg/EnableServiceBinding response +// type type MsgEnableServiceBindingResponse struct { } @@ -503,7 +509,8 @@ func (m *MsgEnableServiceBindingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgEnableServiceBindingResponse proto.InternalMessageInfo -// MsgRefundServiceDeposit defines an SDK message to refund deposit from a service binding +// MsgRefundServiceDeposit defines an SDK message to refund deposit from a +// service binding type MsgRefundServiceDeposit struct { ServiceName string `protobuf:"bytes,1,opt,name=service_name,json=serviceName,proto3" json:"service_name,omitempty" yaml:"service_name"` Provider string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"` @@ -543,7 +550,8 @@ func (m *MsgRefundServiceDeposit) XXX_DiscardUnknown() { var xxx_messageInfo_MsgRefundServiceDeposit proto.InternalMessageInfo -// MsgRefundServiceDepositResponse defines the Msg/RefundServiceDeposit response type +// MsgRefundServiceDepositResponse defines the Msg/RefundServiceDeposit response +// type type MsgRefundServiceDepositResponse struct { } @@ -781,7 +789,8 @@ func (m *MsgPauseRequestContext) XXX_DiscardUnknown() { var xxx_messageInfo_MsgPauseRequestContext proto.InternalMessageInfo -// MsgPauseRequestContextResponse defines the Msg/PauseRequestContext response type +// MsgPauseRequestContextResponse defines the Msg/PauseRequestContext response +// type type MsgPauseRequestContextResponse struct { } @@ -857,7 +866,8 @@ func (m *MsgStartRequestContext) XXX_DiscardUnknown() { var xxx_messageInfo_MsgStartRequestContext proto.InternalMessageInfo -// MsgStartRequestContextResponse defines the Msg/StartRequestContext response type +// MsgStartRequestContextResponse defines the Msg/StartRequestContext response +// type type MsgStartRequestContextResponse struct { } @@ -933,7 +943,8 @@ func (m *MsgKillRequestContext) XXX_DiscardUnknown() { var xxx_messageInfo_MsgKillRequestContext proto.InternalMessageInfo -// MsgKillRequestContextResponse defines the Msg/KillRequestContext response type +// MsgKillRequestContextResponse defines the Msg/KillRequestContext response +// type type MsgKillRequestContextResponse struct { } @@ -970,7 +981,8 @@ func (m *MsgKillRequestContextResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgKillRequestContextResponse proto.InternalMessageInfo -// MsgUpdateRequestContext defines an SDK message to update a service request context +// MsgUpdateRequestContext defines an SDK message to update a service request +// context type MsgUpdateRequestContext struct { RequestContextId string `protobuf:"bytes,1,opt,name=request_context_id,json=requestContextId,proto3" json:"request_context_id,omitempty" yaml:"request_context_id"` Providers []string `protobuf:"bytes,2,rep,name=providers,proto3" json:"providers,omitempty"` @@ -1014,7 +1026,8 @@ func (m *MsgUpdateRequestContext) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateRequestContext proto.InternalMessageInfo -// MsgUpdateRequestContextResponse defines the Msg/UpdateRequestContext response type +// MsgUpdateRequestContextResponse defines the Msg/UpdateRequestContext response +// type type MsgUpdateRequestContextResponse struct { } @@ -1051,7 +1064,8 @@ func (m *MsgUpdateRequestContextResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateRequestContextResponse proto.InternalMessageInfo -// MsgWithdrawEarnedFees defines an SDK message to withdraw the fees earned by the provider or owner +// MsgWithdrawEarnedFees defines an SDK message to withdraw the fees earned by +// the provider or owner type MsgWithdrawEarnedFees struct { Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` Provider string `protobuf:"bytes,2,opt,name=provider,proto3" json:"provider,omitempty"` @@ -1090,7 +1104,8 @@ func (m *MsgWithdrawEarnedFees) XXX_DiscardUnknown() { var xxx_messageInfo_MsgWithdrawEarnedFees proto.InternalMessageInfo -// MsgWithdrawEarnedFeesResponse defines the Msg/WithdrawEarnedFees response type +// MsgWithdrawEarnedFeesResponse defines the Msg/WithdrawEarnedFees response +// type type MsgWithdrawEarnedFeesResponse struct { } @@ -3665,10 +3680,7 @@ func (m *MsgDefineService) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3718,10 +3730,7 @@ func (m *MsgDefineServiceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -3984,10 +3993,7 @@ func (m *MsgBindService) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4037,10 +4043,7 @@ func (m *MsgBindServiceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4303,10 +4306,7 @@ func (m *MsgUpdateServiceBinding) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4356,10 +4356,7 @@ func (m *MsgUpdateServiceBindingResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4473,10 +4470,7 @@ func (m *MsgSetWithdrawAddress) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4526,10 +4520,7 @@ func (m *MsgSetWithdrawAddressResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4675,10 +4666,7 @@ func (m *MsgDisableServiceBinding) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4728,10 +4716,7 @@ func (m *MsgDisableServiceBindingResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4911,10 +4896,7 @@ func (m *MsgEnableServiceBinding) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -4964,10 +4946,7 @@ func (m *MsgEnableServiceBindingResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5113,10 +5092,7 @@ func (m *MsgRefundServiceDeposit) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5166,10 +5142,7 @@ func (m *MsgRefundServiceDepositResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5458,10 +5431,7 @@ func (m *MsgCallService) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5543,10 +5513,7 @@ func (m *MsgCallServiceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5724,10 +5691,7 @@ func (m *MsgRespondService) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5777,10 +5741,7 @@ func (m *MsgRespondServiceResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5894,10 +5855,7 @@ func (m *MsgPauseRequestContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -5947,10 +5905,7 @@ func (m *MsgPauseRequestContextResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6064,10 +6019,7 @@ func (m *MsgStartRequestContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6117,10 +6069,7 @@ func (m *MsgStartRequestContextResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6234,10 +6183,7 @@ func (m *MsgKillRequestContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6287,10 +6233,7 @@ func (m *MsgKillRequestContextResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6527,10 +6470,7 @@ func (m *MsgUpdateRequestContext) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6580,10 +6520,7 @@ func (m *MsgUpdateRequestContextResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6697,10 +6634,7 @@ func (m *MsgWithdrawEarnedFees) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -6750,10 +6684,7 @@ func (m *MsgWithdrawEarnedFeesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/modules/token/client/cli/cli_test.go b/modules/token/client/cli/cli_test.go index 7c730d8f..2ce003cf 100644 --- a/modules/token/client/cli/cli_test.go +++ b/modules/token/client/cli/cli_test.go @@ -35,10 +35,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg := simapp.NewConfig() cfg.NumValidators = 1 + var err error s.cfg = cfg - s.network = network.New(s.T(), cfg) + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) - _, err := s.network.WaitForHeight(1) + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/token/client/rest/query.go b/modules/token/client/rest/query.go deleted file mode 100644 index 0b43c565..00000000 --- a/modules/token/client/rest/query.go +++ /dev/null @@ -1,184 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/token/types" -) - -func registerQueryRoutes(cliCtx client.Context, r *mux.Router) { - // Query the token by symbol or min unit - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}", types.ModuleName, RestParamDenom), queryTokenHandlerFn(cliCtx)).Methods("GET") - // Query tokens by owner - r.HandleFunc(fmt.Sprintf("/%s/tokens", types.ModuleName), queryTokensHandlerFn(cliCtx)).Methods("GET") - // Query token fees - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}/fees", types.ModuleName, RestParamSymbol), queryTokenFeesHandlerFn(cliCtx)).Methods("GET") - // Query token params - r.HandleFunc(fmt.Sprintf("/%s/params", types.ModuleName), queryTokenParamsHandlerFn(cliCtx)).Methods("GET") - // Query the total amount of all burned tokens - r.HandleFunc(fmt.Sprintf("/%s/total_burn", types.ModuleName), queryTotalBurnHandlerFn(cliCtx)).Methods("GET") -} - -// queryTokenHandlerFn is the HTTP request handler to query token -func queryTokenHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - params := types.QueryTokenParams{ - Denom: vars[RestParamDenom], - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryToken), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -// queryTokensHandlerFn is the HTTP request handler to query tokens -func queryTokensHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - ownerStr := r.FormValue(RestParamOwner) - - var err error - var owner sdk.AccAddress - - if len(ownerStr) > 0 { - owner, err = sdk.AccAddressFromBech32(ownerStr) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - } - - params := types.QueryTokensParams{ - Owner: owner, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTokens), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -// queryTokenFeesHandlerFn is the HTTP request handler to query token fees -func queryTokenFeesHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - symbol := vars[RestParamSymbol] - - if err := types.ValidateSymbol(symbol); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - params := types.QueryTokenFeesParams{ - Symbol: symbol, - } - - bz, err := cliCtx.LegacyAmino.MarshalJSON(params) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s/tokens", types.QuerierRoute, types.QueryFees), bz, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -// queryTokenParamsHandlerFn is the HTTP request handler to query token params -func queryTokenParamsHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryParams), nil, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} - -// queryTotalBurnHandlerFn is the HTTP request handler to query the total amount of all burn tokens -func queryTotalBurnHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - cliCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, cliCtx, r) - if !ok { - return - } - - res, height, err := cliCtx.QueryWithData( - fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryTotalBurn), nil, - ) - if err != nil { - rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error()) - return - } - - cliCtx = cliCtx.WithHeight(height) - rest.PostProcessResponse(w, cliCtx, res) - } -} diff --git a/modules/token/client/rest/rest.go b/modules/token/client/rest/rest.go deleted file mode 100644 index be00de15..00000000 --- a/modules/token/client/rest/rest.go +++ /dev/null @@ -1,61 +0,0 @@ -package rest - -import ( - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/types/rest" -) - -// Rest variable names -// nolint -const ( - RestParamDenom = "denom" - RestParamSymbol = "symbol" - RestParamOwner = "owner" -) - -// RegisterHandlers registers token-related REST handlers to a router -func RegisterHandlers(cliCtx client.Context, r *mux.Router) { - registerQueryRoutes(cliCtx, r) - registerTxRoutes(cliCtx, r) -} - -type issueTokenReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` // owner of the token - Symbol string `json:"symbol"` - Name string `json:"name"` - Scale uint32 `json:"scale"` - MinUnit string `json:"min_unit"` - InitialSupply uint64 `json:"initial_supply"` - MaxSupply uint64 `json:"max_supply"` - Mintable bool `json:"mintable"` -} - -type editTokenReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` // owner of the token - MaxSupply uint64 `json:"max_supply"` - Mintable string `json:"mintable"` // mintable of the token - Name string `json:"name"` -} - -type transferTokenOwnerReq struct { - BaseReq rest.BaseReq `json:"base_req"` - SrcOwner string `json:"src_owner"` // the current owner address of the token - DstOwner string `json:"dst_owner"` // the new owner -} - -type mintTokenReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Owner string `json:"owner"` // the current owner address of the token - To string `json:"to"` // address of minting token to - Amount uint64 `json:"amount"` // amount of minting token -} - -type burnTokenReq struct { - BaseReq rest.BaseReq `json:"base_req"` - Sender string `json:"owner"` // the current owner address of the token - Amount uint64 `json:"amount"` // amount of burning token -} diff --git a/modules/token/client/rest/tx.go b/modules/token/client/rest/tx.go deleted file mode 100644 index 93ddaa37..00000000 --- a/modules/token/client/rest/tx.go +++ /dev/null @@ -1,169 +0,0 @@ -package rest - -import ( - "fmt" - "net/http" - - "github.com/gorilla/mux" - - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/types/rest" - - "github.com/irisnet/irismod/modules/token/types" -) - -func registerTxRoutes(cliCtx client.Context, r *mux.Router) { - // issue a token - r.HandleFunc(fmt.Sprintf("/%s/tokens", types.ModuleName), issueTokenHandlerFn(cliCtx)).Methods("POST") - // edit a token - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}", types.ModuleName, RestParamSymbol), editTokenHandlerFn(cliCtx)).Methods("PUT") - // transfer owner - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}/transfer", types.ModuleName, RestParamSymbol), transferOwnerHandlerFn(cliCtx)).Methods("POST") - // mint token - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}/mint", types.ModuleName, RestParamSymbol), mintTokenHandlerFn(cliCtx)).Methods("POST") - // burn token - r.HandleFunc(fmt.Sprintf("/%s/tokens/{%s}/burn", types.ModuleName, RestParamSymbol), burnTokenHandlerFn(cliCtx)).Methods("POST") -} - -func issueTokenHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - var req issueTokenReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - // create the MsgIssueToken message - msg := &types.MsgIssueToken{ - Symbol: req.Symbol, - Name: req.Name, - Scale: req.Scale, - MinUnit: req.MinUnit, - InitialSupply: req.InitialSupply, - MaxSupply: req.MaxSupply, - Mintable: req.Mintable, - Owner: req.Owner, - } - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func editTokenHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - symbol := vars[RestParamSymbol] - - var req editTokenReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - mintable, err := types.ParseBool(req.Mintable) - if err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - // create the MsgEditToken message - msg := types.NewMsgEditToken(req.Name, symbol, req.MaxSupply, mintable, req.Owner) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func transferOwnerHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - symbol := vars[RestParamSymbol] - - var req transferTokenOwnerReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - // create the MsgTransferTokenOwner message - msg := types.NewMsgTransferTokenOwner(req.SrcOwner, req.DstOwner, symbol) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func mintTokenHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - symbol := vars[RestParamSymbol] - - var req mintTokenReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - // create the MsgMintToken message - msg := types.NewMsgMintToken(symbol, req.Owner, req.To, req.Amount) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} - -func burnTokenHandlerFn(cliCtx client.Context) http.HandlerFunc { - return func(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - symbol := vars[RestParamSymbol] - - var req burnTokenReq - if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) { - return - } - - baseReq := req.BaseReq.Sanitize() - if !baseReq.ValidateBasic(w) { - return - } - - // create the MsgMintToken message - msg := types.NewMsgBurnToken(symbol, req.Sender, req.Amount) - if err := msg.ValidateBasic(); err != nil { - rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error()) - return - } - - tx.WriteGeneratedTxResponse(cliCtx, w, req.BaseReq, msg) - } -} diff --git a/modules/token/client/rest/grpc_query_test.go b/modules/token/client/testutil/grpc_query_test.go similarity index 95% rename from modules/token/client/rest/grpc_query_test.go rename to modules/token/client/testutil/grpc_query_test.go index 9e844cf8..433d42b7 100644 --- a/modules/token/client/rest/grpc_query_test.go +++ b/modules/token/client/testutil/grpc_query_test.go @@ -1,4 +1,4 @@ -package rest_test +package testutil_test import ( "encoding/json" @@ -11,8 +11,8 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/testutil/network" + "github.com/cosmos/cosmos-sdk/testutil/rest" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/rest" tokencli "github.com/irisnet/irismod/modules/token/client/cli" tokentestutil "github.com/irisnet/irismod/modules/token/client/testutil" @@ -34,9 +34,12 @@ func (s *IntegrationTestSuite) SetupSuite() { cfg.NumValidators = 1 s.cfg = cfg - s.network = network.New(s.T(), cfg) - _, err := s.network.WaitForHeight(1) + var err error + s.network, err = network.New(s.T(), s.T().TempDir(), cfg) + s.Require().NoError(err) + + _, err = s.network.WaitForHeight(1) s.Require().NoError(err) } diff --git a/modules/token/genesis_test.go b/modules/token/genesis_test.go index 54e804c3..a0116117 100644 --- a/modules/token/genesis_test.go +++ b/modules/token/genesis_test.go @@ -16,7 +16,7 @@ import ( ) func TestExportGenesis(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) @@ -30,7 +30,7 @@ func TestExportGenesis(t *testing.T) { } func TestInitGenesis(t *testing.T) { - app := simapp.Setup(false) + app := simapp.Setup(t, false) ctx := app.BaseApp.NewContext(false, tmproto.Header{}) diff --git a/modules/token/handler_test.go b/modules/token/handler_test.go index 14be7524..db92f8b2 100644 --- a/modules/token/handler_test.go +++ b/modules/token/handler_test.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -26,7 +27,7 @@ var ( nativeToken = types.GetNativeToken() denom = nativeToken.Symbol owner = sdk.AccAddress(tmhash.SumTruncated([]byte("tokenTest"))) - initAmt = sdk.NewIntWithDecimal(100000000, int(6)) + initAmt = sdkmath.NewIntWithDecimal(100000000, int(6)) initCoin = sdk.Coins{sdk.NewCoin(denom, initAmt)} ) @@ -44,7 +45,7 @@ type HandlerSuite struct { } func (suite *HandlerSuite) SetupTest() { - app := simapp.Setup(isCheckTx) + app := simapp.Setup(suite.T(), isCheckTx) suite.cdc = codec.NewAminoCodec(app.LegacyAmino()) suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) @@ -68,7 +69,7 @@ func (suite *HandlerSuite) issueToken(token types.Token) { mintCoins := sdk.NewCoins( sdk.NewCoin( token.MinUnit, - sdk.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), + sdkmath.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), ), ) @@ -96,7 +97,7 @@ func (suite *HandlerSuite) TestIssueToken() { suite.Equal(nativeTokenAmt1.Sub(fee.Amount), nativeTokenAmt2) - mintTokenAmt := sdk.NewIntWithDecimal(int64(msg.InitialSupply), int(msg.Scale)) + mintTokenAmt := sdkmath.NewIntWithDecimal(int64(msg.InitialSupply), int(msg.Scale)) nativeTokenAmt3 := suite.bk.GetBalance(suite.ctx, owner, msg.MinUnit).Amount suite.Equal(nativeTokenAmt3, mintTokenAmt) @@ -107,7 +108,7 @@ func (suite *HandlerSuite) TestMintToken() { suite.issueToken(token) beginBtcAmt := suite.bk.GetBalance(suite.ctx, token.GetOwner(), token.MinUnit).Amount - suite.Equal(sdk.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), beginBtcAmt) + suite.Equal(sdkmath.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), beginBtcAmt) beginNativeAmt := suite.bk.GetBalance(suite.ctx, token.GetOwner(), denom).Amount @@ -119,7 +120,7 @@ func (suite *HandlerSuite) TestMintToken() { endBtcAmt := suite.bk.GetBalance(suite.ctx, token.GetOwner(), token.MinUnit).Amount - mintBtcAmt := sdk.NewIntWithDecimal(int64(msgMintToken.Amount), int(token.Scale)) + mintBtcAmt := sdkmath.NewIntWithDecimal(int64(msgMintToken.Amount), int(token.Scale)) suite.Equal(beginBtcAmt.Add(mintBtcAmt), endBtcAmt) fee, err := suite.keeper.GetTokenMintFee(suite.ctx, token.Symbol) @@ -135,7 +136,7 @@ func (suite *HandlerSuite) TestBurnToken() { suite.issueToken(token) beginBtcAmt := suite.bk.GetBalance(suite.ctx, token.GetOwner(), token.MinUnit).Amount - suite.Equal(sdk.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), beginBtcAmt) + suite.Equal(sdkmath.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), beginBtcAmt) h := tokenmodule.NewHandler(suite.keeper) @@ -144,7 +145,7 @@ func (suite *HandlerSuite) TestBurnToken() { suite.NoError(err) endBtcAmt := suite.bk.GetBalance(suite.ctx, token.GetOwner(), token.MinUnit).Amount - burnBtcAmt := sdk.NewIntWithDecimal(int64(msgBurnToken.Amount), int(token.Scale)) + burnBtcAmt := sdkmath.NewIntWithDecimal(int64(msgBurnToken.Amount), int(token.Scale)) suite.Equal(beginBtcAmt.Sub(burnBtcAmt), endBtcAmt) } diff --git a/modules/token/keeper/keeper.go b/modules/token/keeper/keeper.go index 93cd75f6..9e520e27 100644 --- a/modules/token/keeper/keeper.go +++ b/modules/token/keeper/keeper.go @@ -5,7 +5,9 @@ import ( "github.com/tendermint/tendermint/libs/log" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" paramstypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -14,7 +16,7 @@ import ( ) type Keeper struct { - storeKey sdk.StoreKey + storeKey storetypes.StoreKey cdc codec.Codec bankKeeper types.BankKeeper paramSpace paramstypes.Subspace @@ -24,7 +26,7 @@ type Keeper struct { func NewKeeper( cdc codec.Codec, - key sdk.StoreKey, + key storetypes.StoreKey, paramSpace paramstypes.Subspace, bankKeeper types.BankKeeper, blockedAddrs map[string]bool, @@ -71,7 +73,7 @@ func (k Keeper) IssueToken( return err } - precision := sdk.NewIntWithDecimal(1, int(token.Scale)) + precision := sdkmath.NewIntWithDecimal(1, int(token.Scale)) initialCoin := sdk.NewCoin( token.MinUnit, sdk.NewIntFromUint64(token.InitialSupply).Mul(precision), @@ -109,7 +111,7 @@ func (k Keeper) EditToken( if maxSupply > 0 { issuedAmt := k.getTokenSupply(ctx, token.MinUnit) - issuedMainUnitAmt := issuedAmt.Quo(sdk.NewIntWithDecimal(1, int(token.Scale))) + issuedMainUnitAmt := issuedAmt.Quo(sdkmath.NewIntWithDecimal(1, int(token.Scale))) if sdk.NewIntFromUint64(maxSupply).LT(issuedMainUnitAmt) { return sdkerrors.Wrapf(types.ErrInvalidMaxSupply, "max supply must not be less than %s", issuedMainUnitAmt) @@ -186,7 +188,7 @@ func (k Keeper) MintToken( } supply := k.getTokenSupply(ctx, token.MinUnit) - precision := sdk.NewIntWithDecimal(1, int(token.Scale)) + precision := sdkmath.NewIntWithDecimal(1, int(token.Scale)) mintableAmt := sdk.NewIntFromUint64(token.MaxSupply).Mul(precision).Sub(supply) mintableMainAmt := mintableAmt.Quo(precision).Uint64() @@ -226,7 +228,7 @@ func (k Keeper) BurnToken( return err } - precision := sdk.NewIntWithDecimal(1, int(token.Scale)) + precision := sdkmath.NewIntWithDecimal(1, int(token.Scale)) burnCoin := sdk.NewCoin(token.GetMinUnit(), sdk.NewIntFromUint64(amount).Mul(precision)) burnCoins := sdk.NewCoins(burnCoin) diff --git a/modules/token/keeper/keeper_test.go b/modules/token/keeper/keeper_test.go index 15b67614..c665a637 100644 --- a/modules/token/keeper/keeper_test.go +++ b/modules/token/keeper/keeper_test.go @@ -8,6 +8,7 @@ import ( "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" @@ -24,7 +25,7 @@ const ( var ( denom = types.GetNativeToken().Symbol owner = sdk.AccAddress(tmhash.SumTruncated([]byte("tokenTest"))) - initAmt = sdk.NewIntWithDecimal(100000000, int(6)) + initAmt = sdkmath.NewIntWithDecimal(100000000, int(6)) initCoin = sdk.Coins{sdk.NewCoin(denom, initAmt)} ) @@ -39,7 +40,7 @@ type KeeperTestSuite struct { } func (suite *KeeperTestSuite) SetupTest() { - app := simapp.Setup(isCheckTx) + app := simapp.Setup(suite.T(), isCheckTx) suite.legacyAmino = app.LegacyAmino() suite.ctx = app.BaseApp.NewContext(isCheckTx, tmproto.Header{}) @@ -72,7 +73,7 @@ func (suite *KeeperTestSuite) issueToken(token types.Token) { mintCoins := sdk.NewCoins( sdk.NewCoin( token.MinUnit, - sdk.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), + sdkmath.NewIntWithDecimal(int64(token.InitialSupply), int(token.Scale)), ), ) diff --git a/modules/token/keeper/pagination_test.go b/modules/token/keeper/pagination_test.go index 892fdf1f..5558257c 100644 --- a/modules/token/keeper/pagination_test.go +++ b/modules/token/keeper/pagination_test.go @@ -24,7 +24,7 @@ func TestShapePageRequest(t *testing.T) { CountTotal: true, Reverse: true, } - + res2 := ShapePageRequest(request) require.NotNil(t, res2) require.Equal(t, res2.Limit, defaultRequest.Limit) // limit == paginationDefaultLimit diff --git a/modules/token/module.go b/modules/token/module.go index 521cd25c..f42f8863 100644 --- a/modules/token/module.go +++ b/modules/token/module.go @@ -20,7 +20,6 @@ import ( simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/irisnet/irismod/modules/token/client/cli" - "github.com/irisnet/irismod/modules/token/client/rest" "github.com/irisnet/irismod/modules/token/keeper" "github.com/irisnet/irismod/modules/token/simulation" "github.com/irisnet/irismod/modules/token/types" @@ -62,7 +61,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config client.TxEncod // RegisterRESTRoutes registers the REST routes for the token module. func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { - rest.RegisterHandlers(clientCtx, rtr) + //rest.RegisterHandlers(clientCtx, rtr) } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the token module. diff --git a/modules/token/simulation/genesis.go b/modules/token/simulation/genesis.go index 99390ac3..f1f89cac 100644 --- a/modules/token/simulation/genesis.go +++ b/modules/token/simulation/genesis.go @@ -22,7 +22,7 @@ const ( // RandomDec randomized sdk.RandomDec func RandomDec(r *rand.Rand) sdk.Dec { - return sdk.NewDec(r.Int63()) + return sdk.NewDecWithPrec(r.Int63n(9)+1, 1) } // RandomInt randomized sdk.Int diff --git a/modules/token/simulation/operations.go b/modules/token/simulation/operations.go index 8fca99c9..c865d258 100644 --- a/modules/token/simulation/operations.go +++ b/modules/token/simulation/operations.go @@ -4,7 +4,6 @@ import ( "fmt" "math" "math/rand" - "regexp" "strings" "github.com/cosmos/cosmos-sdk/baseapp" @@ -125,7 +124,8 @@ func SimulateIssueToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -139,7 +139,7 @@ func SimulateIssueToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKe return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -175,7 +175,8 @@ func SimulateEditToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -189,7 +190,7 @@ func SimulateEditToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -224,7 +225,8 @@ func SimulateMintToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -238,7 +240,7 @@ func SimulateMintToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -279,7 +281,8 @@ func SimulateTransferTokenOwner(k keeper.Keeper, ak types.AccountKeeper, bk type } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -293,7 +296,7 @@ func SimulateTransferTokenOwner(k keeper.Keeper, ak types.AccountKeeper, bk type return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, err } @@ -323,7 +326,7 @@ func SimulateBurnToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee amount2 := simtypes.RandomAmount(r, sdk.NewIntFromUint64(math.MaxUint64)) - spendable, hasNeg := spendable.SafeSub(sdk.Coins{sdk.NewCoin(token.GetSymbol(), amount2)}) + spendable, hasNeg := spendable.SafeSub(sdk.Coins{sdk.NewCoin(token.GetSymbol(), amount2)}...) if hasNeg { return simtypes.NoOpMsg(types.ModuleName, types.TypeMsgBurnToken, "Insufficient funds"), nil, nil } @@ -341,7 +344,8 @@ func SimulateBurnToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee } txGen := simappparams.MakeTestEncodingConfig().TxConfig - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + r, txGen, []sdk.Msg{msg}, fees, @@ -355,7 +359,7 @@ func SimulateBurnToken(k keeper.Keeper, ak types.AccountKeeper, bk types.BankKee return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to generate mock tx"), nil, err } - if _, _, err = app.Deliver(txGen.TxEncoder(), tx); err != nil { + if _, _, err = app.SimDeliver(txGen.TxEncoder(), tx); err != nil { return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "unable to deliver tx"), nil, nil } @@ -454,15 +458,11 @@ loop: } func randToken(r *rand.Rand, accs []simtypes.Account) types.Token { - keywords := strings.Join([]string{"peg", "ibc", "swap", "htlt"}, "|") - regexpKeywordsFmt := fmt.Sprintf("^(%s).*", keywords) - regexpKeyword := regexp.MustCompile(regexpKeywordsFmt).MatchString - var symbol, minUint string for { symbol = randStringBetween(r, types.MinimumSymbolLen, types.MaximumSymbolLen) minUint = symbol - if !regexpKeyword(symbol) { + if err := types.ValidateSymbol(symbol); err == nil { break } } diff --git a/modules/token/simulation/params.go b/modules/token/simulation/params.go index 0bdd970f..8ebce13f 100644 --- a/modules/token/simulation/params.go +++ b/modules/token/simulation/params.go @@ -1,8 +1,11 @@ package simulation import ( + "encoding/json" + "fmt" "math/rand" + sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" "github.com/cosmos/cosmos-sdk/x/simulation" @@ -21,17 +24,19 @@ func ParamChanges(r *rand.Rand) []simtypes.ParamChange { return []simtypes.ParamChange{ simulation.NewSimParamChange(types.ModuleName, keyTokenTaxRate, func(r *rand.Rand) string { - return RandomDec(r).String() + return fmt.Sprintf("\"%s\"", RandomDec(r).String()) }, ), simulation.NewSimParamChange(types.ModuleName, keyIssueTokenBaseFee, func(r *rand.Rand) string { - return RandomInt(r).String() + fee := sdk.NewCoin(types.GetNativeToken().Symbol, RandomInt(r)) + bz, _ := json.Marshal(fee) + return string(bz) }, ), simulation.NewSimParamChange(types.ModuleName, keyMintTokenFeeRatio, func(r *rand.Rand) string { - return RandomDec(r).String() + return fmt.Sprintf("\"%s\"", RandomDec(r).String()) }, ), } diff --git a/modules/token/types/genesis.pb.go b/modules/token/types/genesis.pb.go index 2a70b45a..7de36937 100644 --- a/modules/token/types/genesis.pb.go +++ b/modules/token/types/genesis.pb.go @@ -350,10 +350,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthGenesis } if (iNdEx + skippy) > l { diff --git a/modules/token/types/query.pb.go b/modules/token/types/query.pb.go index d5d91dea..1f9c345c 100644 --- a/modules/token/types/query.pb.go +++ b/modules/token/types/query.pb.go @@ -1401,10 +1401,7 @@ func (m *QueryTokenRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1490,10 +1487,7 @@ func (m *QueryTokenResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1611,10 +1605,7 @@ func (m *QueryTokensRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1734,10 +1725,7 @@ func (m *QueryTokensResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1819,10 +1807,7 @@ func (m *QueryFeesRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -1958,10 +1943,7 @@ func (m *QueryFeesResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2011,10 +1993,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2133,10 +2112,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2186,10 +2162,7 @@ func (m *QueryTotalBurnRequest) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { @@ -2273,10 +2246,7 @@ func (m *QueryTotalBurnResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthQuery } if (iNdEx + skippy) > l { diff --git a/modules/token/types/query.pb.gw.go b/modules/token/types/query.pb.gw.go index 18e93428..79dee68d 100644 --- a/modules/token/types/query.pb.gw.go +++ b/modules/token/types/query.pb.gw.go @@ -20,6 +20,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" ) @@ -30,6 +31,7 @@ var _ status.Status var _ = runtime.String var _ = utilities.NewDoubleArray var _ = descriptor.ForMessage +var _ = metadata.Join func request_Query_Token_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryTokenRequest @@ -214,12 +216,14 @@ func local_request_Query_TotalBurn_0(ctx context.Context, marshaler runtime.Mars // RegisterQueryHandlerServer registers the http handlers for service Query to "mux". // UnaryRPC :call QueryServer directly. // StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. -// Note that using this registration option will cause many gRPC library features (such as grpc.SendHeader, etc) to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. +// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { mux.Handle("GET", pattern_Query_Token_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -227,6 +231,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Token_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -240,6 +245,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Tokens_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -247,6 +254,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Tokens_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -260,6 +268,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Fees_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -267,6 +277,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Fees_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -280,6 +291,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_Params_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -287,6 +300,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_Params_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -300,6 +314,8 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv mux.Handle("GET", pattern_Query_TotalBurn_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) if err != nil { @@ -307,6 +323,7 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv return } resp, md, err := local_request_Query_TotalBurn_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) ctx = runtime.NewServerMetadataContext(ctx, md) if err != nil { runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) @@ -462,15 +479,15 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie } var ( - pattern_Query_Token_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "token", "tokens", "denom"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Token_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"irismod", "token", "tokens", "denom"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Tokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "tokens"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Tokens_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "tokens"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Fees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "token", "tokens", "symbol", "fees"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Fees_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"irismod", "token", "tokens", "symbol", "fees"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "params"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_Params_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "params"}, "", runtime.AssumeColonVerbOpt(false))) - pattern_Query_TotalBurn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "total_burn"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TotalBurn_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"irismod", "token", "total_burn"}, "", runtime.AssumeColonVerbOpt(false))) ) var ( diff --git a/modules/token/types/token.pb.go b/modules/token/types/token.pb.go index 11507271..28b5bff7 100644 --- a/modules/token/types/token.pb.go +++ b/modules/token/types/token.pb.go @@ -621,10 +621,7 @@ func (m *Token) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthToken - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthToken } if (iNdEx + skippy) > l { @@ -775,10 +772,7 @@ func (m *Params) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthToken - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthToken } if (iNdEx + skippy) > l { diff --git a/modules/token/types/token_test.go b/modules/token/types/token_test.go index d60d2ac8..38da8b97 100644 --- a/modules/token/types/token_test.go +++ b/modules/token/types/token_test.go @@ -5,6 +5,7 @@ import ( "reflect" "testing" + sdkmath "cosmossdk.io/math" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -39,7 +40,7 @@ func TestToken_ToMinCoin(t *testing.T) { name: fmt.Sprintf("Main Coin to Min Coin,scale=%d", i), wantErr: false, args: args{coin: sdk.NewDecCoin(token.Symbol, sdk.NewInt(10))}, - want: sdk.NewCoin(token.MinUnit, sdk.NewIntWithDecimal(10, int(token.Scale))), + want: sdk.NewCoin(token.MinUnit, sdkmath.NewIntWithDecimal(10, int(token.Scale))), success: true, }, { diff --git a/modules/token/types/tx.pb.go b/modules/token/types/tx.pb.go index e3e8ecd1..eedece92 100644 --- a/modules/token/types/tx.pb.go +++ b/modules/token/types/tx.pb.go @@ -150,7 +150,8 @@ func (m *MsgTransferTokenOwner) XXX_DiscardUnknown() { var xxx_messageInfo_MsgTransferTokenOwner proto.InternalMessageInfo -// MsgTransferTokenOwnerResponse defines the Msg/TransferTokenOwner response type +// MsgTransferTokenOwnerResponse defines the Msg/TransferTokenOwner response +// type type MsgTransferTokenOwnerResponse struct { } @@ -1527,10 +1528,7 @@ func (m *MsgIssueToken) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1580,10 +1578,7 @@ func (m *MsgIssueTokenResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1729,10 +1724,7 @@ func (m *MsgTransferTokenOwner) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1782,10 +1774,7 @@ func (m *MsgTransferTokenOwnerResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -1982,10 +1971,7 @@ func (m *MsgEditToken) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2035,10 +2021,7 @@ func (m *MsgEditTokenResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2203,10 +2186,7 @@ func (m *MsgMintToken) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2256,10 +2236,7 @@ func (m *MsgMintTokenResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2392,10 +2369,7 @@ func (m *MsgBurnToken) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { @@ -2445,10 +2419,7 @@ func (m *MsgBurnTokenResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { - return ErrInvalidLengthTx - } - if (iNdEx + skippy) < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthTx } if (iNdEx + skippy) > l { diff --git a/proto/buf.gen.gogo.yaml b/proto/buf.gen.gogo.yaml new file mode 100644 index 00000000..855ea251 --- /dev/null +++ b/proto/buf.gen.gogo.yaml @@ -0,0 +1,8 @@ +version: v1 +plugins: + - name: gocosmos + out: .. + opt: plugins=grpc,Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types + - name: grpc-gateway + out: .. + opt: logtostderr=true,allow_colon_final_segments=true \ No newline at end of file diff --git a/proto/buf.yaml b/proto/buf.yaml new file mode 100644 index 00000000..9a6d727f --- /dev/null +++ b/proto/buf.yaml @@ -0,0 +1,7 @@ +version: v1 +lint: + use: + - DEFAULT +breaking: + use: + - FILE \ No newline at end of file diff --git a/proto/coinswap/coinswap.proto b/proto/coinswap/coinswap.proto index 76768630..6f557bdf 100644 --- a/proto/coinswap/coinswap.proto +++ b/proto/coinswap/coinswap.proto @@ -41,12 +41,16 @@ message Params { (gogoproto.nullable) = false ]; - cosmos.base.v1beta1.Coin pool_creation_fee = 2 [ + cosmos.base.v1beta1.Coin pool_creation_fee = 2 + [ (gogoproto.nullable) = false ]; + + string tax_rate = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - string tax_rate = 3 [ + string unilateral_liquidity_fee = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false + (gogoproto.nullable) = false ]; } diff --git a/proto/coinswap/tx.proto b/proto/coinswap/tx.proto index 095b80da..4a814ab4 100644 --- a/proto/coinswap/tx.proto +++ b/proto/coinswap/tx.proto @@ -10,50 +10,132 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the coinswap Msg service service Msg { - // AddLiquidity defines a method for depositing some tokens to the liquidity pool - rpc AddLiquidity(MsgAddLiquidity) returns (MsgAddLiquidityResponse); + // AddLiquidity defines a method for depositing some tokens to the liquidity + // pool + rpc AddLiquidity(MsgAddLiquidity) returns (MsgAddLiquidityResponse); - // RemoveLiquidity defines a method for withdraw some tokens from the liquidity pool - rpc RemoveLiquidity(MsgRemoveLiquidity) returns (MsgRemoveLiquidityResponse); + // AddUnilateralLiquidity defines a method for depositing some tokens + // unilaterally to the liquidity pool + rpc AddUnilateralLiquidity(MsgAddUnilateralLiquidity) + returns (MsgAddUnilateralLiquidityResponse); - // SwapCoin defines a method for swapping a token with the other token from the liquidity pool - rpc SwapCoin(MsgSwapOrder) returns (MsgSwapCoinResponse); + // RemoveLiquidity defines a method for withdraw some tokens from the + // liquidity pool + rpc RemoveLiquidity(MsgRemoveLiquidity) returns (MsgRemoveLiquidityResponse); + + // RemoveUnilateralLiquidity defines a method for withdraw some tokens + // unilaterally from the liquidity pool + rpc RemoveUnilateralLiquidity(MsgRemoveUnilateralLiquidity) + returns (MsgRemoveUnilateralLiquidityResponse); + + // SwapCoin defines a method for swapping a token with the other token from + // the liquidity pool + rpc SwapCoin(MsgSwapOrder) returns (MsgSwapCoinResponse); } // MsgAddLiquidity defines a msg for adding liquidity to a reserve pool message MsgAddLiquidity { - cosmos.base.v1beta1.Coin max_token = 1 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"max_token\"" ]; - string exact_standard_amt = 2 [ (gogoproto.moretags) = "yaml:\"exact_standard_amt\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string min_liquidity = 3 [ (gogoproto.moretags) = "yaml:\"min_liquidity\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - int64 deadline = 4; - string sender = 5; + cosmos.base.v1beta1.Coin max_token = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"max_token\"" + ]; + string exact_standard_amt = 2 [ + (gogoproto.moretags) = "yaml:\"exact_standard_amt\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string min_liquidity = 3 [ + (gogoproto.moretags) = "yaml:\"min_liquidity\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 deadline = 4; + string sender = 5; } // MsgAddLiquidityResponse defines the Msg/AddLiquidity response type -message MsgAddLiquidityResponse { - cosmos.base.v1beta1.Coin mint_token = 1; +message MsgAddLiquidityResponse { cosmos.base.v1beta1.Coin mint_token = 1; } + +// MsgAddLiquidityUni defines a msg for adding liquidity unilaterally to a +// reserve pool +message MsgAddUnilateralLiquidity { + string counterparty_denom = 1 + [ (gogoproto.moretags) = "yaml:\"conuterparty_denom\"" ]; + cosmos.base.v1beta1.Coin exact_token = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"exact_token\"" + ]; // exact amount of token + string min_liquidity = 3 [ + (gogoproto.moretags) = "yaml:\"min_liquidity\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 deadline = 4; + string sender = 5; +} + +// MsgAddLiquidityUniResponse defines the Msg/AddLiquidityUni response type +message MsgAddUnilateralLiquidityResponse { + cosmos.base.v1beta1.Coin mint_token = 1; } // MsgRemoveLiquidity defines a msg for removing liquidity from a reserve pool message MsgRemoveLiquidity { - cosmos.base.v1beta1.Coin withdraw_liquidity = 1 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"withdraw_liquidity\"" ]; - string min_token = 2 [ (gogoproto.moretags) = "yaml:\"min_token\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - string min_standard_amt = 3 [ (gogoproto.moretags) = "yaml:\"min_standard_amt\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; - int64 deadline = 4; - string sender = 5; + cosmos.base.v1beta1.Coin withdraw_liquidity = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"withdraw_liquidity\"" + ]; + string min_token = 2 [ + (gogoproto.moretags) = "yaml:\"min_token\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + string min_standard_amt = 3 [ + (gogoproto.moretags) = "yaml:\"min_standard_amt\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 deadline = 4; + string sender = 5; } // MsgRemoveLiquidityResponse defines the Msg/RemoveLiquidity response type message MsgRemoveLiquidityResponse { - repeated cosmos.base.v1beta1.Coin withdraw_coins = 1; + repeated cosmos.base.v1beta1.Coin withdraw_coins = 1 + [ (gogoproto.nullable) = false ]; +} + +// MsgRemoveUnilateralLiquidity defines a msg for removing liquidity +// unilaterally to a reserve pool +message MsgRemoveUnilateralLiquidity { + string counterparty_denom = 1 + [ (gogoproto.moretags) = "yaml:\"conuterparty_denom\"" ]; + cosmos.base.v1beta1.Coin min_token = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"min_token\"" + ]; // minimum amount of token + string exact_liquidity = 3 [ + (gogoproto.moretags) = "yaml:\"exact_liquidity\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; + int64 deadline = 4; + string sender = 5; +} + +// MsgRemoveUnilateralLiquidityResponse defines the Msg/RemoveLiquidity response +// type +message MsgRemoveUnilateralLiquidityResponse { + repeated cosmos.base.v1beta1.Coin withdraw_coins = 1 + [ (gogoproto.nullable) = false ]; } // MsgSwapOrder defines a msg for swap order message MsgSwapOrder { - Input input = 1 [ (gogoproto.nullable) = false ]; - Output output = 2 [ (gogoproto.nullable) = false ]; - int64 deadline = 3; - bool is_buy_order = 4 [ (gogoproto.moretags) = "yaml:\"is_buy_order\"" ]; + Input input = 1 [ (gogoproto.nullable) = false ]; + Output output = 2 [ (gogoproto.nullable) = false ]; + int64 deadline = 3; + bool is_buy_order = 4 [ (gogoproto.moretags) = "yaml:\"is_buy_order\"" ]; } // MsgSwapCoinResponse defines the Msg/SwapCoin response type diff --git a/proto/farm/farm.proto b/proto/farm/farm.proto index 2c5e9052..f3c47790 100644 --- a/proto/farm/farm.proto +++ b/proto/farm/farm.proto @@ -67,9 +67,9 @@ message Params { (gogoproto.nullable) = false ]; uint32 max_reward_categories = 2; - string tax_rate = 3 [ + string tax_rate = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", - (gogoproto.nullable) = false + (gogoproto.nullable) = false ]; } @@ -77,22 +77,27 @@ message EscrowInfo { option (gogoproto.equal) = true; string proposer = 1; - repeated cosmos.base.v1beta1.Coin fund_applied = 2 [(gogoproto.nullable) = false]; - repeated cosmos.base.v1beta1.Coin fund_self_bond = 3 [(gogoproto.nullable) = false]; - uint64 proposal_id = 4; + repeated cosmos.base.v1beta1.Coin fund_applied = 2 + [ (gogoproto.nullable) = false ]; + repeated cosmos.base.v1beta1.Coin fund_self_bond = 3 + [ (gogoproto.nullable) = false ]; + uint64 proposal_id = 4; } - -// CommunityPoolCreateFarmProposal is a gov Content type for creating a farm pool with community pool +// CommunityPoolCreateFarmProposal is a gov Content type for creating a farm +// pool with community pool message CommunityPoolCreateFarmProposal { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; option (gogoproto.goproto_stringer) = false; string title = 1; string description = 2; string pool_description = 3; string lpt_denom = 4; - repeated cosmos.base.v1beta1.Coin reward_per_block = 5 [(gogoproto.nullable) = false]; - repeated cosmos.base.v1beta1.Coin fund_applied = 6 [(gogoproto.nullable) = false]; - repeated cosmos.base.v1beta1.Coin fund_self_bond = 7 [(gogoproto.nullable) = false]; + repeated cosmos.base.v1beta1.Coin reward_per_block = 5 + [ (gogoproto.nullable) = false ]; + repeated cosmos.base.v1beta1.Coin fund_applied = 6 + [ (gogoproto.nullable) = false ]; + repeated cosmos.base.v1beta1.Coin fund_self_bond = 7 + [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/farm/tx.proto b/proto/farm/tx.proto index 6bfc0bf8..256e05c0 100644 --- a/proto/farm/tx.proto +++ b/proto/farm/tx.proto @@ -14,7 +14,8 @@ service Msg { rpc CreatePool(MsgCreatePool) returns (MsgCreatePoolResponse); // CreatePoolWithCommunityPool defines a method for creating a new farm pool - rpc CreatePoolWithCommunityPool(MsgCreatePoolWithCommunityPool) returns (MsgCreatePoolWithCommunityPoolResponse); + rpc CreatePoolWithCommunityPool(MsgCreatePoolWithCommunityPool) + returns (MsgCreatePoolWithCommunityPoolResponse); // DestroyPool defines a method for destroying a existed farm pool rpc DestroyPool(MsgDestroyPool) returns (MsgDestroyPoolResponse); @@ -54,11 +55,11 @@ message MsgCreatePool { message MsgCreatePoolWithCommunityPool { option (gogoproto.equal) = true; - CommunityPoolCreateFarmProposal content = 1 [(gogoproto.nullable) = false]; + CommunityPoolCreateFarmProposal content = 1 [ (gogoproto.nullable) = false ]; repeated cosmos.base.v1beta1.Coin initial_deposit = 2 [ - (gogoproto.nullable) = false, + (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"initial_deposit\"" + (gogoproto.moretags) = "yaml:\"initial_deposit\"" ]; string proposer = 3; } diff --git a/proto/htlc/genesis.proto b/proto/htlc/genesis.proto index acd63398..161d1b2f 100644 --- a/proto/htlc/genesis.proto +++ b/proto/htlc/genesis.proto @@ -9,8 +9,12 @@ option go_package = "github.com/irisnet/irismod/modules/htlc/types"; // GenesisState defines the HTLC module's genesis state message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - repeated HTLC htlcs = 2 [ (gogoproto.nullable) = false ]; - repeated AssetSupply supplies = 3 [ (gogoproto.nullable) = false ]; - google.protobuf.Timestamp previous_block_time = 4 [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true, (gogoproto.moretags) = "yaml:\"previous_block_time\"" ]; + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated HTLC htlcs = 2 [ (gogoproto.nullable) = false ]; + repeated AssetSupply supplies = 3 [ (gogoproto.nullable) = false ]; + google.protobuf.Timestamp previous_block_time = 4 [ + (gogoproto.nullable) = false, + (gogoproto.stdtime) = true, + (gogoproto.moretags) = "yaml:\"previous_block_time\"" + ]; } diff --git a/proto/htlc/htlc.proto b/proto/htlc/htlc.proto index b66610cf..db4f21dc 100644 --- a/proto/htlc/htlc.proto +++ b/proto/htlc/htlc.proto @@ -10,85 +10,140 @@ option (gogoproto.goproto_getters_all) = false; // HTLC defines the struct of an HTLC message HTLC { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string id = 1; - string sender = 2; - string to = 3; - string receiver_on_other_chain = 4 [ (gogoproto.moretags) = "yaml:\"receiver_on_other_chain\"" ]; - string sender_on_other_chain = 5 [ (gogoproto.moretags) = "yaml:\"sender_on_other_chain\"" ]; - repeated cosmos.base.v1beta1.Coin amount = 6 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string hash_lock = 7 [ (gogoproto.moretags) = "yaml:\"hash_lock\"" ]; - string secret = 8; - uint64 timestamp = 9; - uint64 expiration_height = 10 [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; - HTLCState state = 11; - uint64 closed_block = 12 [ (gogoproto.moretags) = "yaml:\"closed_block\"" ]; - bool transfer = 13; - SwapDirection direction = 14; + string id = 1; + string sender = 2; + string to = 3; + string receiver_on_other_chain = 4 + [ (gogoproto.moretags) = "yaml:\"receiver_on_other_chain\"" ]; + string sender_on_other_chain = 5 + [ (gogoproto.moretags) = "yaml:\"sender_on_other_chain\"" ]; + repeated cosmos.base.v1beta1.Coin amount = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string hash_lock = 7 [ (gogoproto.moretags) = "yaml:\"hash_lock\"" ]; + string secret = 8; + uint64 timestamp = 9; + uint64 expiration_height = 10 + [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; + HTLCState state = 11; + uint64 closed_block = 12 [ (gogoproto.moretags) = "yaml:\"closed_block\"" ]; + bool transfer = 13; + SwapDirection direction = 14; } // HTLCState defines the state of an HTLC enum HTLCState { - option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.goproto_enum_prefix) = false; - // HTLC_STATE_OPEN defines an open state. - HTLC_STATE_OPEN = 0 [ (gogoproto.enumvalue_customname) = "Open" ]; - // HTLC_STATE_COMPLETED defines a completed state. - HTLC_STATE_COMPLETED = 1 [ (gogoproto.enumvalue_customname) = "Completed" ]; - // HTLC_STATE_REFUNDED defines a refunded state. - HTLC_STATE_REFUNDED = 2 [ (gogoproto.enumvalue_customname) = "Refunded" ]; + // HTLC_STATE_OPEN defines an open state. + HTLC_STATE_OPEN = 0 [ (gogoproto.enumvalue_customname) = "Open" ]; + // HTLC_STATE_COMPLETED defines a completed state. + HTLC_STATE_COMPLETED = 1 [ (gogoproto.enumvalue_customname) = "Completed" ]; + // HTLC_STATE_REFUNDED defines a refunded state. + HTLC_STATE_REFUNDED = 2 [ (gogoproto.enumvalue_customname) = "Refunded" ]; } // SwapDirection defines the direction of an HTLT enum SwapDirection { - option (gogoproto.goproto_enum_prefix) = false; + option (gogoproto.goproto_enum_prefix) = false; - // NONE defines an htlt none direction. - NONE = 0 [ (gogoproto.enumvalue_customname) = "None" ]; - // INCOMING defines an htlt incoming direction. - INCOMING = 1 [ (gogoproto.enumvalue_customname) = "Incoming" ]; - // OUTGOING defines an htlt outgoing direction. - OUTGOING = 2 [ (gogoproto.enumvalue_customname) = "Outgoing" ]; + // NONE defines an htlt none direction. + NONE = 0 [ (gogoproto.enumvalue_customname) = "None" ]; + // INCOMING defines an htlt incoming direction. + INCOMING = 1 [ (gogoproto.enumvalue_customname) = "Incoming" ]; + // OUTGOING defines an htlt outgoing direction. + OUTGOING = 2 [ (gogoproto.enumvalue_customname) = "Outgoing" ]; } message AssetSupply { - cosmos.base.v1beta1.Coin incoming_supply = 1 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"incoming_supply\"" ]; - cosmos.base.v1beta1.Coin outgoing_supply = 2 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"assetoutgoing_supply_params\"" ]; - cosmos.base.v1beta1.Coin current_supply = 3 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"current_supply\"" ]; - cosmos.base.v1beta1.Coin time_limited_current_supply = 4 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"time_limited_current_supply\"" ]; - google.protobuf.Duration time_elapsed = 5 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"time_elapsed\"" ]; + cosmos.base.v1beta1.Coin incoming_supply = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"incoming_supply\"" + ]; + cosmos.base.v1beta1.Coin outgoing_supply = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"assetoutgoing_supply_params\"" + ]; + cosmos.base.v1beta1.Coin current_supply = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"current_supply\"" + ]; + cosmos.base.v1beta1.Coin time_limited_current_supply = 4 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"time_limited_current_supply\"" + ]; + google.protobuf.Duration time_elapsed = 5 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"time_elapsed\"" + ]; } // Params defines token module's parameters message Params { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; - repeated AssetParam asset_params = 1 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"asset_params\"" ]; + repeated AssetParam asset_params = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"asset_params\"" + ]; } message AssetParam { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; - string denom = 1; // name of the asset - SupplyLimit supply_limit = 2 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"supply_limit\"" ]; // asset supply limit - bool active = 3; // denotes if asset is available or paused - string deputy_address = 4 [ (gogoproto.moretags) = "yaml:\"deputy_address\"" ]; // the address of the relayer process - string fixed_fee = 5 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // the fixed fee charged by the relayer process for outgoing swaps - string min_swap_amount = 6 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // Minimum swap amount - string max_swap_amount = 7 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // Maximum swap amount - uint64 min_block_lock = 8 [ (gogoproto.moretags) = "yaml:\"min_block_lock\"" ]; // Minimum swap block lock - uint64 max_block_lock = 9 [ (gogoproto.moretags) = "yaml:\"max_block_lock\"" ]; // Maximum swap block lock + string denom = 1; // name of the asset + SupplyLimit supply_limit = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"supply_limit\"" + ]; // asset supply limit + bool active = 3; // denotes if asset is available or paused + string deputy_address = 4 + [ (gogoproto.moretags) = + "yaml:\"deputy_address\"" ]; // the address of the relayer process + string fixed_fee = 5 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // the fixed fee charged by the relayer process for outgoing swaps + string min_swap_amount = 6 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // Minimum swap amount + string max_swap_amount = 7 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // Maximum swap amount + uint64 min_block_lock = 8 + [ (gogoproto.moretags) = + "yaml:\"min_block_lock\"" ]; // Minimum swap block lock + uint64 max_block_lock = 9 + [ (gogoproto.moretags) = + "yaml:\"max_block_lock\"" ]; // Maximum swap block lock } message SupplyLimit { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; - string limit = 1 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // the absolute supply limit for an asset - bool time_limited = 2 [ (gogoproto.moretags) = "yaml:\"time_limited\"" ]; // boolean for if the supply is also limited by time - google.protobuf.Duration time_period = 3 [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"time_period\"" ]; // the duration for which the supply time limit applies - string time_based_limit = 4 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", (gogoproto.nullable) = false ]; // the supply limit for an asset for each time period + string limit = 1 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // the absolute supply limit for an asset + bool time_limited = 2 [ + (gogoproto.moretags) = "yaml:\"time_limited\"" + ]; // boolean for if the supply is also limited by time + google.protobuf.Duration time_period = 3 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"time_period\"" + ]; // the duration for which the supply time limit applies + string time_based_limit = 4 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", + (gogoproto.nullable) = false + ]; // the supply limit for an asset for each time period } \ No newline at end of file diff --git a/proto/htlc/query.proto b/proto/htlc/query.proto index 845ad5c7..b8f2ab78 100644 --- a/proto/htlc/query.proto +++ b/proto/htlc/query.proto @@ -9,61 +9,61 @@ option go_package = "github.com/irisnet/irismod/modules/htlc/types"; // Query provides defines the gRPC querier service service Query { - // HTLC queries the HTLC by the specified hash lock - rpc HTLC(QueryHTLCRequest) returns (QueryHTLCResponse) { - option (google.api.http).get = "/irismod/htlc/htlcs/{id}"; - } + // HTLC queries the HTLC by the specified hash lock + rpc HTLC(QueryHTLCRequest) returns (QueryHTLCResponse) { + option (google.api.http).get = "/irismod/htlc/htlcs/{id}"; + } - // AssetSupply queries the supply of an asset - rpc AssetSupply(QueryAssetSupplyRequest) returns (QueryAssetSupplyResponse) { - option (google.api.http).get = "/irismod/htlc/supplies/{denom}"; - } + // AssetSupply queries the supply of an asset + rpc AssetSupply(QueryAssetSupplyRequest) returns (QueryAssetSupplyResponse) { + option (google.api.http).get = "/irismod/htlc/supplies/{denom}"; + } - // AssetSupplies queries the supplies of all assets - rpc AssetSupplies(QueryAssetSuppliesRequest) returns (QueryAssetSuppliesResponse) { - option (google.api.http).get = "/irismod/htlc/supplies"; - } + // AssetSupplies queries the supplies of all assets + rpc AssetSupplies(QueryAssetSuppliesRequest) + returns (QueryAssetSuppliesResponse) { + option (google.api.http).get = "/irismod/htlc/supplies"; + } - // Params queries the htlc parameters - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/irismod/htlc/params"; - } + // Params queries the htlc parameters + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/irismod/htlc/params"; + } } // QueryHTLCRequest is the request type for the Query/HTLC RPC method -message QueryHTLCRequest { - string id = 1; -} +message QueryHTLCRequest { string id = 1; } // QueryBalanceResponse is the response type for the Query/HTLC RPC method -message QueryHTLCResponse { - HTLC htlc = 1; -} +message QueryHTLCResponse { HTLC htlc = 1; } // QueryAssetSupplyRequest is request type for the Query/AssetSupply RPC method -message QueryAssetSupplyRequest { - string denom = 1; -} +message QueryAssetSupplyRequest { string denom = 1; } -// QueryAssetSupplyResponse is response type for the Query/AssetSupply RPC method +// QueryAssetSupplyResponse is response type for the Query/AssetSupply RPC +// method message QueryAssetSupplyResponse { - AssetSupply asset_supply = 1 [ (gogoproto.moretags) = "yaml:\"asset_supply\"" ]; + AssetSupply asset_supply = 1 + [ (gogoproto.moretags) = "yaml:\"asset_supply\"" ]; } -// QueryAssetSuppliesRequest is request type for the Query/AssetSupplies RPC method -message QueryAssetSuppliesRequest { -} +// QueryAssetSuppliesRequest is request type for the Query/AssetSupplies RPC +// method +message QueryAssetSuppliesRequest {} -// QueryAssetSuppliesResponse is response type for the Query/AssetSupplies RPC method +// QueryAssetSuppliesResponse is response type for the Query/AssetSupplies RPC +// method message QueryAssetSuppliesResponse { - repeated AssetSupply asset_supplies = 1 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"asset_supplies\"" ]; + repeated AssetSupply asset_supplies = 1 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"asset_supplies\"" + ]; } // QueryParamsRequest is request type for the Query/Parameters RPC method -message QueryParamsRequest { -} +message QueryParamsRequest {} // QueryParamsResponse is response type for the Query/Parameters RPC method message QueryParamsResponse { - Params params = 1 [ (gogoproto.nullable) = false ]; + Params params = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/htlc/tx.proto b/proto/htlc/tx.proto index 9d1d0d3d..7b5dfccb 100644 --- a/proto/htlc/tx.proto +++ b/proto/htlc/tx.proto @@ -9,40 +9,43 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the HTLC Msg service service Msg { - // CreateHTLC defines a method for creating a HTLC - rpc CreateHTLC(MsgCreateHTLC) returns (MsgCreateHTLCResponse); + // CreateHTLC defines a method for creating a HTLC + rpc CreateHTLC(MsgCreateHTLC) returns (MsgCreateHTLCResponse); - // ClaimHTLC defines a method for claiming a HTLC - rpc ClaimHTLC(MsgClaimHTLC) returns (MsgClaimHTLCResponse); + // ClaimHTLC defines a method for claiming a HTLC + rpc ClaimHTLC(MsgClaimHTLC) returns (MsgClaimHTLCResponse); } // MsgCreateHTLC defines a message to create an HTLC message MsgCreateHTLC { - option (gogoproto.equal) = true; - - string sender = 1; - string to = 2; - string receiver_on_other_chain = 3 [ (gogoproto.moretags) = "yaml:\"receiver_on_other_chain\"" ]; - string sender_on_other_chain = 4 [ (gogoproto.moretags) = "yaml:\"sender_on_other_chain\"" ]; - repeated cosmos.base.v1beta1.Coin amount = 5 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string hash_lock = 6 [ (gogoproto.moretags) = "yaml:\"hash_lock\"" ]; - uint64 timestamp = 7; - uint64 time_lock = 8 [ (gogoproto.moretags) = "yaml:\"time_lock\"" ]; - bool transfer = 9; + option (gogoproto.equal) = true; + + string sender = 1; + string to = 2; + string receiver_on_other_chain = 3 + [ (gogoproto.moretags) = "yaml:\"receiver_on_other_chain\"" ]; + string sender_on_other_chain = 4 + [ (gogoproto.moretags) = "yaml:\"sender_on_other_chain\"" ]; + repeated cosmos.base.v1beta1.Coin amount = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string hash_lock = 6 [ (gogoproto.moretags) = "yaml:\"hash_lock\"" ]; + uint64 timestamp = 7; + uint64 time_lock = 8 [ (gogoproto.moretags) = "yaml:\"time_lock\"" ]; + bool transfer = 9; } // MsgCreateHTLCResponse defines the Msg/CreateHTLC response type -message MsgCreateHTLCResponse { - string id = 1; -} +message MsgCreateHTLCResponse { string id = 1; } // MsgClaimHTLC defines a message to claim an HTLC message MsgClaimHTLC { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string sender = 1; - string id = 2 [ (gogoproto.moretags) = "yaml:\"id\"" ]; - string secret = 3; + string sender = 1; + string id = 2 [ (gogoproto.moretags) = "yaml:\"id\"" ]; + string secret = 3; } // MsgClaimHTLCResponse defines the Msg/ClaimHTLC response type diff --git a/proto/mt/genesis.proto b/proto/mt/genesis.proto index 769af1ce..6c3f792b 100644 --- a/proto/mt/genesis.proto +++ b/proto/mt/genesis.proto @@ -8,8 +8,8 @@ option go_package = "github.com/irisnet/irismod/modules/mt/types"; // GenesisState defines the MT module's genesis state message GenesisState { - repeated Collection collections = 1 [(gogoproto.nullable) = false]; - repeated Owner owners = 2 [(gogoproto.nullable) = false]; + repeated Collection collections = 1 [ (gogoproto.nullable) = false ]; + repeated Owner owners = 2 [ (gogoproto.nullable) = false ]; } // Collection defines a type of collection @@ -17,7 +17,7 @@ message Collection { option (gogoproto.equal) = true; Denom denom = 1; - repeated MT mts = 2 [(gogoproto.nullable) = false]; + repeated MT mts = 2 [ (gogoproto.nullable) = false ]; } // Owner defines a type of account balances @@ -25,7 +25,7 @@ message Owner { option (gogoproto.equal) = true; string address = 1; - repeated DenomBalance denoms = 2 [(gogoproto.nullable) = false]; + repeated DenomBalance denoms = 2 [ (gogoproto.nullable) = false ]; } // DenomBalance defines a type of denom balances owned by an account @@ -33,5 +33,5 @@ message DenomBalance { option (gogoproto.equal) = true; string denom_id = 1; - repeated Balance balances = 2 [(gogoproto.nullable) = false]; + repeated Balance balances = 2 [ (gogoproto.nullable) = false ]; } diff --git a/proto/mt/query.proto b/proto/mt/query.proto index 2834902c..0dbdf880 100644 --- a/proto/mt/query.proto +++ b/proto/mt/query.proto @@ -10,120 +10,110 @@ option go_package = "github.com/irisnet/irismod/modules/mt/types"; // Query defines the gRPC querier service for MT module service Query { - // Supply queries the total supply of a given denom or owner - rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { - option (google.api.http).get = "/irismod/mt/denoms/supply"; - } - - // Denoms queries all the denoms - rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { - option (google.api.http).get = "/irismod/mt/denoms"; - } - - // Denom queries the definition of a given denom ID - rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) { - option (google.api.http).get = "/irismod/mt/denoms/{denom_id}"; - } - - // MTSupply queries the total supply of given denom and mt ID - rpc MTSupply(QueryMTSupplyRequest) returns (QueryMTSupplyResponse) { - option (google.api.http).get = "/irismod/mt/mts/{denom_id}/{mt_id}/supply"; - } - - // MTs queries all the MTs of a given denom ID - rpc MTs(QueryMTsRequest) returns (QueryMTsResponse) { - option (google.api.http).get = "/irismod/mt/mts/{denom_id}"; - } - - // MT queries the MT of the given denom and mt ID - rpc MT(QueryMTRequest) returns (QueryMTResponse) { - option (google.api.http).get = "/irismod/mt/mts/{denom_id}/{mt_id}"; - } - - // Balances queries the MT balances of a specified owner - rpc Balances(QueryBalancesRequest) returns (QueryBalancesResponse) { - option (google.api.http).get = "/irismod/mt/mts/{owner}/balances"; - } + // Supply queries the total supply of a given denom or owner + rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { + option (google.api.http).get = "/irismod/mt/denoms/supply"; + } + + // Denoms queries all the denoms + rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { + option (google.api.http).get = "/irismod/mt/denoms"; + } + + // Denom queries the definition of a given denom ID + rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) { + option (google.api.http).get = "/irismod/mt/denoms/{denom_id}"; + } + + // MTSupply queries the total supply of given denom and mt ID + rpc MTSupply(QueryMTSupplyRequest) returns (QueryMTSupplyResponse) { + option (google.api.http).get = "/irismod/mt/mts/{denom_id}/{mt_id}/supply"; + } + + // MTs queries all the MTs of a given denom ID + rpc MTs(QueryMTsRequest) returns (QueryMTsResponse) { + option (google.api.http).get = "/irismod/mt/mts/{denom_id}"; + } + + // MT queries the MT of the given denom and mt ID + rpc MT(QueryMTRequest) returns (QueryMTResponse) { + option (google.api.http).get = "/irismod/mt/mts/{denom_id}/{mt_id}"; + } + + // Balances queries the MT balances of a specified owner + rpc Balances(QueryBalancesRequest) returns (QueryBalancesResponse) { + option (google.api.http).get = "/irismod/mt/mts/{owner}/balances"; + } } // QuerySupplyRequest is the request type for the Query RPC method message QuerySupplyRequest { - string denom_id = 1; - string owner = 2; + string denom_id = 1; + string owner = 2; } // QuerySupplyResponse is the response type for the Query/Supply RPC method -message QuerySupplyResponse { - uint64 amount = 1; -} +message QuerySupplyResponse { uint64 amount = 1; } // QueryDenomsRequest is the request type for the Query/Denoms RPC method message QueryDenomsRequest { - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; } // QueryDenomsResponse is the response type for the Query/Denoms RPC method message QueryDenomsResponse { - repeated Denom denoms = 1 [(gogoproto.nullable) = false]; + repeated Denom denoms = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryDenomRequest is the request type for the Query/Denom RPC method -message QueryDenomRequest { - string denom_id = 1; -} +message QueryDenomRequest { string denom_id = 1; } // QueryDenomResponse is the response type for the Query/Denom RPC method -message QueryDenomResponse { - Denom denom = 1; -} +message QueryDenomResponse { Denom denom = 1; } message QueryMTSupplyRequest { - string denom_id = 1; - string mt_id = 2; + string denom_id = 1; + string mt_id = 2; } -message QueryMTSupplyResponse { - uint64 amount = 1; -} +message QueryMTSupplyResponse { uint64 amount = 1; } // QueryMTsRequest is the request type for the Query/MTs RPC method message QueryMTsRequest { - string denom_id = 1; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; + string denom_id = 1; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; } // QueryMTsResponse is the response type for the Query/MTs RPC method message QueryMTsResponse { - repeated MT mts = 1 [(gogoproto.nullable) = false]; + repeated MT mts = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryMTRequest is the request type for the Query/MT RPC method message QueryMTRequest { - string denom_id = 1; - string mt_id = 2; + string denom_id = 1; + string mt_id = 2; } // QueryMTResponse is the response type for the Query/MT RPC method -message QueryMTResponse { - MT mt = 1; -} +message QueryMTResponse { MT mt = 1; } // QueryBalancesRequest is the request type for the Query/Balances RPC method message QueryBalancesRequest { - string owner = 1; - string denom_id = 2; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string owner = 1; + string denom_id = 2; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 3; } // QueryBalancesResponse is the response type for the Query/Balances RPC method message QueryBalancesResponse { - repeated Balance balance = 1 [(gogoproto.nullable) = false]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated Balance balance = 1 [ (gogoproto.nullable) = false ]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/mt/tx.proto b/proto/mt/tx.proto index 92c94894..b6e8aab4 100644 --- a/proto/mt/tx.proto +++ b/proto/mt/tx.proto @@ -8,43 +8,45 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the mt Msg service. service Msg { - // IssueDenom defines a method for issuing a denom. - rpc IssueDenom(MsgIssueDenom) returns (MsgIssueDenomResponse); + // IssueDenom defines a method for issuing a denom. + rpc IssueDenom(MsgIssueDenom) returns (MsgIssueDenomResponse); - // TransferDenom defines a method for transferring a denom. - rpc TransferDenom(MsgTransferDenom) returns (MsgTransferDenomResponse); + // TransferDenom defines a method for transferring a denom. + rpc TransferDenom(MsgTransferDenom) returns (MsgTransferDenomResponse); - // MintMT defines a method for creating a new MT or minting amounts of an existing MT - rpc MintMT(MsgMintMT) returns (MsgMintMTResponse); + // MintMT defines a method for creating a new MT or minting amounts of an + // existing MT + rpc MintMT(MsgMintMT) returns (MsgMintMTResponse); - // EditMT defines a method for editing an MT. - rpc EditMT(MsgEditMT) returns (MsgEditMTResponse); + // EditMT defines a method for editing an MT. + rpc EditMT(MsgEditMT) returns (MsgEditMTResponse); - // TransferMT defines a method for transferring an MT. - rpc TransferMT(MsgTransferMT) returns (MsgTransferMTResponse); + // TransferMT defines a method for transferring an MT. + rpc TransferMT(MsgTransferMT) returns (MsgTransferMTResponse); - // BurnMT defines a method for burning an MT. - rpc BurnMT(MsgBurnMT) returns (MsgBurnMTResponse); + // BurnMT defines a method for burning an MT. + rpc BurnMT(MsgBurnMT) returns (MsgBurnMTResponse); } // MsgIssueDenom defines an SDK message for creating a new denom. message MsgIssueDenom { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string name = 1; - bytes data = 2; - string sender = 3; + string name = 1; + bytes data = 2; + string sender = 3; } // MsgIssueDenomResponse defines the Msg/IssueDenom response type. message MsgIssueDenomResponse {} -// MsgTransferDenom defines an SDK message for transferring an denom to recipient. +// MsgTransferDenom defines an SDK message for transferring an denom to +// recipient. message MsgTransferDenom { - option (gogoproto.equal) = true; - string id = 1; - string sender = 2; - string recipient = 3; + option (gogoproto.equal) = true; + string id = 1; + string sender = 2; + string recipient = 3; } // MsgTransferDenomResponse defines the Msg/TransferDenom response type. @@ -52,14 +54,14 @@ message MsgTransferDenomResponse {} // MsgMintMT defines an SDK message for creating a new MT. message MsgMintMT { - option (gogoproto.equal) = true; - - string id = 1; - string denom_id = 2; - uint64 amount = 3; - bytes data = 4; - string sender = 5; - string recipient = 6; + option (gogoproto.equal) = true; + + string id = 1; + string denom_id = 2; + uint64 amount = 3; + bytes data = 4; + string sender = 5; + string recipient = 6; } // MsgMintMTResponse defines the Msg/MintMT response type. @@ -67,12 +69,12 @@ message MsgMintMTResponse {} // MsgEditMT defines an SDK message for editing an MT. message MsgEditMT { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string id = 1; - string denom_id = 2; - bytes data = 3; - string sender = 4; + string id = 1; + string denom_id = 2; + bytes data = 3; + string sender = 4; } // MsgEditMTResponse defines the Msg/EditMT response type. @@ -80,13 +82,13 @@ message MsgEditMTResponse {} // MsgTransferMT defines an SDK message for transferring an MT to recipient. message MsgTransferMT { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string id = 1; - string denom_id = 2; - uint64 amount = 3; - string sender = 4; - string recipient = 5; + string id = 1; + string denom_id = 2; + uint64 amount = 3; + string sender = 4; + string recipient = 5; } // MsgTransferMTResponse defines the Msg/TransferMT response type. @@ -94,12 +96,12 @@ message MsgTransferMTResponse {} // MsgBurnMT defines an SDK message for burning an MT. message MsgBurnMT { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string id = 1; - string denom_id = 2; - uint64 amount = 3; - string sender = 4; + string id = 1; + string denom_id = 2; + uint64 amount = 3; + string sender = 4; } // MsgBurnMTResponse defines the Msg/BurnMT response type. diff --git a/proto/nft/genesis.proto b/proto/nft/genesis.proto index 5d115ee7..e566b107 100644 --- a/proto/nft/genesis.proto +++ b/proto/nft/genesis.proto @@ -8,5 +8,5 @@ option go_package = "github.com/irisnet/irismod/modules/nft/types"; // GenesisState defines the NFT module's genesis state message GenesisState { - repeated Collection collections = 1 [ (gogoproto.nullable) = false ]; + repeated Collection collections = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/nft/nft.proto b/proto/nft/nft.proto index 982900cf..c1163cce 100644 --- a/proto/nft/nft.proto +++ b/proto/nft/nft.proto @@ -8,53 +8,75 @@ option (gogoproto.goproto_getters_all) = false; // BaseNFT defines a non-fungible token message BaseNFT { - option (gogoproto.equal) = true; - - string id = 1; - string name = 2; - string uri = 3 [ (gogoproto.customname) = "URI" ]; - string data = 4; - string owner = 5; - string uri_hash = 6; + option (gogoproto.equal) = true; + + string id = 1; + string name = 2; + string uri = 3 [ (gogoproto.customname) = "URI" ]; + string data = 4; + string owner = 5; + string uri_hash = 6; +} + +message NFTMetadata { + option (gogoproto.equal) = true; + + string name = 1; + string data = 2; } // Denom defines a type of NFT message Denom { - option (gogoproto.equal) = true; - - string id = 1; - string name = 2; - string schema = 3; - string creator = 4; - string symbol = 5; - bool mint_restricted = 6 ; - bool update_restricted = 7 ; - string description = 8; - string uri = 9; - string uri_hash = 10; - string data = 11; + option (gogoproto.equal) = true; + + string id = 1; + string name = 2; + string schema = 3; + string creator = 4; + string symbol = 5; + bool mint_restricted = 6; + bool update_restricted = 7; + string description = 8; + string uri = 9; + string uri_hash = 10; + string data = 11; +} + +message DenomMetadata { + option (gogoproto.equal) = true; + + string creator = 1; + string schema = 2; + bool mint_restricted = 3; + bool update_restricted = 4; + string data = 5; } // IDCollection defines a type of collection with specified ID message IDCollection { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - repeated string token_ids = 2 [ (gogoproto.moretags) = "yaml:\"token_ids\"" ]; + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + repeated string token_ids = 2 [ (gogoproto.moretags) = "yaml:\"token_ids\"" ]; } // Owner defines a type of owner message Owner { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string address = 1; - repeated IDCollection id_collections = 2 [ (gogoproto.moretags) = "yaml:\"idcs\"", (gogoproto.customname) = "IDCollections", (gogoproto.nullable) = false ]; + string address = 1; + repeated IDCollection id_collections = 2 [ + (gogoproto.moretags) = "yaml:\"idcs\"", + (gogoproto.customname) = "IDCollections", + (gogoproto.nullable) = false + ]; } // Collection defines a type of collection message Collection { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - Denom denom = 1 [ (gogoproto.nullable) = false ]; - repeated BaseNFT nfts = 2 [ (gogoproto.customname) = "NFTs", (gogoproto.nullable) = false ]; + Denom denom = 1 [ (gogoproto.nullable) = false ]; + repeated BaseNFT nfts = 2 + [ (gogoproto.customname) = "NFTs", (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/nft/query.proto b/proto/nft/query.proto index 23c23e77..912d5d8b 100644 --- a/proto/nft/query.proto +++ b/proto/nft/query.proto @@ -10,105 +10,103 @@ option go_package = "github.com/irisnet/irismod/modules/nft/types"; // Query defines the gRPC querier service for NFT module service Query { - // Supply queries the total supply of a given denom or owner - rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { - option (google.api.http).get = "/irismod/nft/collections/{denom_id}/supply"; - } - - // Owner queries the NFTs of the specified owner - rpc Owner(QueryOwnerRequest) returns (QueryOwnerResponse) { - option (google.api.http).get = "/irismod/nft/nfts"; - } - - // Collection queries the NFTs of the specified denom - rpc Collection(QueryCollectionRequest) returns (QueryCollectionResponse) { - option (google.api.http).get = "/irismod/nft/collections/{denom_id}"; - } - - // Denom queries the definition of a given denom - rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) { - option (google.api.http).get = "/irismod/nft/denoms/{denom_id}"; - } - - // Denoms queries all the denoms - rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { - option (google.api.http).get = "/irismod/nft/denoms"; - } - - // NFT queries the NFT for the given denom and token ID - rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) { - option (google.api.http).get = "/irismod/nft/nfts/{denom_id}/{token_id}"; - } + // Supply queries the total supply of a given denom or owner + rpc Supply(QuerySupplyRequest) returns (QuerySupplyResponse) { + option (google.api.http).get = "/irismod/nft/collections/{denom_id}/supply"; + } + + // NFTsOfOwner queries the NFTs of the specified owner + rpc NFTsOfOwner(QueryNFTsOfOwnerRequest) returns (QueryNFTsOfOwnerResponse) { + option (google.api.http).get = "/irismod/nft/nfts"; + } + + // Collection queries the NFTs of the specified denom + rpc Collection(QueryCollectionRequest) returns (QueryCollectionResponse) { + option (google.api.http).get = "/irismod/nft/collections/{denom_id}"; + } + + // Denom queries the definition of a given denom + rpc Denom(QueryDenomRequest) returns (QueryDenomResponse) { + option (google.api.http).get = "/irismod/nft/denoms/{denom_id}"; + } + + // Denoms queries all the denoms + rpc Denoms(QueryDenomsRequest) returns (QueryDenomsResponse) { + option (google.api.http).get = "/irismod/nft/denoms"; + } + + // NFT queries the NFT for the given denom and token ID + rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) { + option (google.api.http).get = "/irismod/nft/nfts/{denom_id}/{token_id}"; + } } // QuerySupplyRequest is the request type for the Query/HTLC RPC method message QuerySupplyRequest { - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string owner = 2; + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string owner = 2; } // QuerySupplyResponse is the response type for the Query/Supply RPC method -message QuerySupplyResponse { - uint64 amount = 1; +message QuerySupplyResponse { uint64 amount = 1; } + +// QueryNFTsOfOwnerRequest is the request type for the Query/NFTsOfOwner RPC +// method +message QueryNFTsOfOwnerRequest { + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ]; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 3; } -// QueryOwnerRequest is the request type for the Query/Owner RPC method -message QueryOwnerRequest { - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string owner = 2 [ (gogoproto.moretags) = "yaml:\"owner\"" ]; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 3; +// QueryNFTsOfOwnerResponse is the response type for the Query/NFTsOfOwner RPC +// method +message QueryNFTsOfOwnerResponse { + Owner owner = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// QueryOwnerResponse is the response type for the Query/Owner RPC method -message QueryOwnerResponse { - Owner owner = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// QueryCollectionRequest is the request type for the Query/Collection RPC method +// QueryCollectionRequest is the request type for the Query/Collection RPC +// method message QueryCollectionRequest { - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; } -// QueryCollectionResponse is the response type for the Query/Collection RPC method +// QueryCollectionResponse is the response type for the Query/Collection RPC +// method message QueryCollectionResponse { - Collection collection = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + Collection collection = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryDenomRequest is the request type for the Query/Denom RPC method message QueryDenomRequest { - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; } // QueryDenomResponse is the response type for the Query/Denom RPC method -message QueryDenomResponse { - Denom denom = 1; -} +message QueryDenomResponse { Denom denom = 1; } // QueryDenomsRequest is the request type for the Query/Denoms RPC method message QueryDenomsRequest { - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; } // QueryDenomsResponse is the response type for the Query/Denoms RPC method message QueryDenomsResponse { - repeated Denom denoms = 1 [ (gogoproto.nullable) = false ]; + repeated Denom denoms = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryNFTRequest is the request type for the Query/NFT RPC method message QueryNFTRequest { - string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string token_id = 2 [ (gogoproto.moretags) = "yaml:\"token_id\"" ]; + string denom_id = 1 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string token_id = 2 [ (gogoproto.moretags) = "yaml:\"token_id\"" ]; } // QueryNFTResponse is the response type for the Query/NFT RPC method -message QueryNFTResponse { - BaseNFT nft = 1 [ (gogoproto.customname) = "NFT" ]; -} \ No newline at end of file +message QueryNFTResponse { BaseNFT nft = 1 [ (gogoproto.customname) = "NFT" ]; } \ No newline at end of file diff --git a/proto/nft/tx.proto b/proto/nft/tx.proto index d2d8f5b5..a4a49282 100644 --- a/proto/nft/tx.proto +++ b/proto/nft/tx.proto @@ -8,40 +8,40 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the nft Msg service. service Msg { - // IssueDenom defines a method for issue a denom. - rpc IssueDenom(MsgIssueDenom) returns (MsgIssueDenomResponse); + // IssueDenom defines a method for issue a denom. + rpc IssueDenom(MsgIssueDenom) returns (MsgIssueDenomResponse); - // MintNFT defines a method for mint a new nft - rpc MintNFT(MsgMintNFT) returns (MsgMintNFTResponse); + // MintNFT defines a method for mint a new nft + rpc MintNFT(MsgMintNFT) returns (MsgMintNFTResponse); - // RefundHTLC defines a method for editing a nft. - rpc EditNFT(MsgEditNFT) returns (MsgEditNFTResponse); + // RefundHTLC defines a method for editing a nft. + rpc EditNFT(MsgEditNFT) returns (MsgEditNFTResponse); - // TransferNFT defines a method for transferring a nft. - rpc TransferNFT(MsgTransferNFT) returns (MsgTransferNFTResponse); + // TransferNFT defines a method for transferring a nft. + rpc TransferNFT(MsgTransferNFT) returns (MsgTransferNFTResponse); - // BurnNFT defines a method for burning a nft. - rpc BurnNFT(MsgBurnNFT) returns (MsgBurnNFTResponse); + // BurnNFT defines a method for burning a nft. + rpc BurnNFT(MsgBurnNFT) returns (MsgBurnNFTResponse); - // TransferDenom defines a method for transferring a denom. - rpc TransferDenom(MsgTransferDenom) returns (MsgTransferDenomResponse); + // TransferDenom defines a method for transferring a denom. + rpc TransferDenom(MsgTransferDenom) returns (MsgTransferDenomResponse); } // MsgIssueDenom defines an SDK message for creating a new denom. message MsgIssueDenom { - option (gogoproto.equal) = true; - - string id = 1; - string name = 2; - string schema = 3; - string sender = 4; - string symbol = 5; - bool mint_restricted = 6 ; - bool update_restricted = 7 ; - string description = 8; - string uri = 9; - string uri_hash = 10; - string data = 11; + option (gogoproto.equal) = true; + + string id = 1; + string name = 2; + string schema = 3; + string sender = 4; + string symbol = 5; + bool mint_restricted = 6; + bool update_restricted = 7; + string description = 8; + string uri = 9; + string uri_hash = 10; + string data = 11; } // MsgIssueDenomResponse defines the Msg/IssueDenom response type. @@ -49,16 +49,16 @@ message MsgIssueDenomResponse {} // MsgTransferNFT defines an SDK message for transferring an NFT to recipient. message MsgTransferNFT { - option (gogoproto.equal) = true; - - string id = 1; - string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string name = 3; - string uri = 4 [ (gogoproto.customname) = "URI" ]; - string data = 5; - string sender = 6; - string recipient = 7; - string uri_hash = 8; + option (gogoproto.equal) = true; + + string id = 1; + string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string name = 3; + string uri = 4 [ (gogoproto.customname) = "URI" ]; + string data = 5; + string sender = 6; + string recipient = 7; + string uri_hash = 8; } // MsgTransferNFTResponse defines the Msg/TransferNFT response type. @@ -66,15 +66,15 @@ message MsgTransferNFTResponse {} // MsgEditNFT defines an SDK message for editing a nft. message MsgEditNFT { - option (gogoproto.equal) = true; - - string id = 1; - string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string name = 3; - string uri = 4 [ (gogoproto.customname) = "URI" ]; - string data = 5; - string sender = 6; - string uri_hash = 7; + option (gogoproto.equal) = true; + + string id = 1; + string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string name = 3; + string uri = 4 [ (gogoproto.customname) = "URI" ]; + string data = 5; + string sender = 6; + string uri_hash = 7; } // MsgEditNFTResponse defines the Msg/EditNFT response type. @@ -82,16 +82,16 @@ message MsgEditNFTResponse {} // MsgMintNFT defines an SDK message for creating a new NFT. message MsgMintNFT { - option (gogoproto.equal) = true; - - string id = 1; - string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string name = 3; - string uri = 4 [ (gogoproto.customname) = "URI" ]; - string data = 5; - string sender = 6; - string recipient = 7; - string uri_hash = 8; + option (gogoproto.equal) = true; + + string id = 1; + string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string name = 3; + string uri = 4 [ (gogoproto.customname) = "URI" ]; + string data = 5; + string sender = 6; + string recipient = 7; + string uri_hash = 8; } // MsgMintNFTResponse defines the Msg/MintNFT response type. @@ -99,23 +99,23 @@ message MsgMintNFTResponse {} // MsgBurnNFT defines an SDK message for burning a NFT. message MsgBurnNFT { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string id = 1; - string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; - string sender = 3; + string id = 1; + string denom_id = 2 [ (gogoproto.moretags) = "yaml:\"denom_id\"" ]; + string sender = 3; } // MsgBurnNFTResponse defines the Msg/BurnNFT response type. message MsgBurnNFTResponse {} - -// MsgTransferDenom defines an SDK message for transferring an denom to recipient. +// MsgTransferDenom defines an SDK message for transferring an denom to +// recipient. message MsgTransferDenom { - option (gogoproto.equal) = true; - string id = 1; - string sender = 2; - string recipient = 3; + option (gogoproto.equal) = true; + string id = 1; + string sender = 2; + string recipient = 3; } // MsgTransferDenomResponse defines the Msg/TransferDenom response type. diff --git a/proto/oracle/genesis.proto b/proto/oracle/genesis.proto index a8220600..60489921 100644 --- a/proto/oracle/genesis.proto +++ b/proto/oracle/genesis.proto @@ -9,11 +9,11 @@ option go_package = "github.com/irisnet/irismod/modules/oracle/types"; // GenesisState defines the oracle module's genesis state message GenesisState { - repeated FeedEntry entries = 1 [ (gogoproto.nullable) = false ]; + repeated FeedEntry entries = 1 [ (gogoproto.nullable) = false ]; } message FeedEntry { - Feed feed = 1 [ (gogoproto.nullable) = false ]; - irismod.service.RequestContextState state = 2; - repeated FeedValue values = 3 [ (gogoproto.nullable) = false ]; + Feed feed = 1 [ (gogoproto.nullable) = false ]; + irismod.service.RequestContextState state = 2; + repeated FeedValue values = 3 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/oracle/oracle.proto b/proto/oracle/oracle.proto index 0d840e2e..fb0a1211 100644 --- a/proto/oracle/oracle.proto +++ b/proto/oracle/oracle.proto @@ -8,17 +8,24 @@ option go_package = "github.com/irisnet/irismod/modules/oracle/types"; // Feed defines the feed standard message Feed { - string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; - string description = 2; - string aggregate_func = 3 [ (gogoproto.moretags) = "yaml:\"aggregate_func\"" ]; - string value_json_path = 4 [ (gogoproto.moretags) = "yaml:\"value_json_path\"" ]; - uint64 latest_history = 5 [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; - string request_context_id = 6 [ (gogoproto.customname) = "RequestContextID", (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - string creator = 7; + string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; + string description = 2; + string aggregate_func = 3 + [ (gogoproto.moretags) = "yaml:\"aggregate_func\"" ]; + string value_json_path = 4 + [ (gogoproto.moretags) = "yaml:\"value_json_path\"" ]; + uint64 latest_history = 5 + [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; + string request_context_id = 6 [ + (gogoproto.customname) = "RequestContextID", + (gogoproto.moretags) = "yaml:\"request_context_id\"" + ]; + string creator = 7; } // FeedValue defines the feed result standard message FeedValue { - string data = 1; - google.protobuf.Timestamp timestamp = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; + string data = 1; + google.protobuf.Timestamp timestamp = 2 + [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; } diff --git a/proto/oracle/query.proto b/proto/oracle/query.proto index fffa1bf0..b7ad432c 100644 --- a/proto/oracle/query.proto +++ b/proto/oracle/query.proto @@ -12,67 +12,69 @@ option go_package = "github.com/irisnet/irismod/modules/oracle/types"; // Query creates service with guardian as rpc service Query { - // Feed queries the feed - rpc Feed(QueryFeedRequest) returns (QueryFeedResponse) { - option (google.api.http).get = "/irismod/oracle/feeds/{feed_name}"; - } + // Feed queries the feed + rpc Feed(QueryFeedRequest) returns (QueryFeedResponse) { + option (google.api.http).get = "/irismod/oracle/feeds/{feed_name}"; + } - // Feeds queries the feed list - rpc Feeds(QueryFeedsRequest) returns (QueryFeedsResponse) { - option (google.api.http).get = "/irismod/oracle/feeds"; - } + // Feeds queries the feed list + rpc Feeds(QueryFeedsRequest) returns (QueryFeedsResponse) { + option (google.api.http).get = "/irismod/oracle/feeds"; + } - // FeedValue queries the feed value - rpc FeedValue(QueryFeedValueRequest) returns (QueryFeedValueResponse) { - option (google.api.http).get = "/irismod/oracle/feeds/{feed_name}/values"; - } + // FeedValue queries the feed value + rpc FeedValue(QueryFeedValueRequest) returns (QueryFeedValueResponse) { + option (google.api.http).get = "/irismod/oracle/feeds/{feed_name}/values"; + } } // QueryFeedRequest is request type for the Query/Feed RPC method -message QueryFeedRequest { - string feed_name = 1; -} +message QueryFeedRequest { string feed_name = 1; } // QueryFeedResponse is response type for the Query/Feed RPC method message QueryFeedResponse { - FeedContext feed = 1 [ (gogoproto.nullable) = false ]; + FeedContext feed = 1 [ (gogoproto.nullable) = false ]; } // QueryFeedsRequest is request type for the Query/Feeds RPC method message QueryFeedsRequest { - string state = 1; - // pagination defines an optional pagination for the request - cosmos.base.query.v1beta1.PageRequest pagination = 2; + string state = 1; + // pagination defines an optional pagination for the request + cosmos.base.query.v1beta1.PageRequest pagination = 2; } // QueryFeedsResponse is response type for the Query/Feeds RPC method message QueryFeedsResponse { - repeated FeedContext feeds = 1 [ (gogoproto.nullable) = false ]; - // pagination defines an optional pagination for the request - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated FeedContext feeds = 1 [ (gogoproto.nullable) = false ]; + // pagination defines an optional pagination for the request + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryFeedValueRequest is request type for the Query/FeedValue RPC method -message QueryFeedValueRequest { - string feed_name = 1; -} +message QueryFeedValueRequest { string feed_name = 1; } // QueryFeedValueResponse is response type for the Query/FeedValue RPC method message QueryFeedValueResponse { - repeated FeedValue feed_values = 1 [ (gogoproto.nullable) = false ]; + repeated FeedValue feed_values = 1 [ (gogoproto.nullable) = false ]; } // FeedContext defines the feed context struct message FeedContext { - option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_stringer) = false; - Feed feed = 1; - string service_name = 2 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - repeated string providers = 3; - string input = 4; - int64 timeout = 5; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 6 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - uint64 repeated_frequency = 7 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - uint32 response_threshold = 8 [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; - irismod.service.RequestContextState state = 9; + Feed feed = 1; + string service_name = 2 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + repeated string providers = 3; + string input = 4; + int64 timeout = 5; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + uint64 repeated_frequency = 7 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + uint32 response_threshold = 8 + [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; + irismod.service.RequestContextState state = 9; } diff --git a/proto/oracle/tx.proto b/proto/oracle/tx.proto index 1a0b5efb..a4024991 100644 --- a/proto/oracle/tx.proto +++ b/proto/oracle/tx.proto @@ -8,34 +8,43 @@ option go_package = "github.com/irisnet/irismod/modules/oracle/types"; // Msg defines the oracle Msg service service Msg { - // CreateFeed defines a method for creating a new feed - rpc CreateFeed(MsgCreateFeed) returns (MsgCreateFeedResponse); + // CreateFeed defines a method for creating a new feed + rpc CreateFeed(MsgCreateFeed) returns (MsgCreateFeedResponse); - // EditFeed defines a method for editing a feed - rpc EditFeed(MsgEditFeed) returns (MsgEditFeedResponse); + // EditFeed defines a method for editing a feed + rpc EditFeed(MsgEditFeed) returns (MsgEditFeedResponse); - // StartFeed defines a method for starting a feed - rpc StartFeed(MsgStartFeed) returns (MsgStartFeedResponse); + // StartFeed defines a method for starting a feed + rpc StartFeed(MsgStartFeed) returns (MsgStartFeedResponse); - // PauseFeed defines a method for pausing a feed - rpc PauseFeed(MsgPauseFeed) returns (MsgPauseFeedResponse); + // PauseFeed defines a method for pausing a feed + rpc PauseFeed(MsgPauseFeed) returns (MsgPauseFeedResponse); } // MsgCreateFeed defines an sdk.Msg type that supports creating a feed message MsgCreateFeed { - string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; - uint64 latest_history = 2 [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; - string description = 3; - string creator = 4; - string service_name = 5 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - repeated string providers = 6; - string input = 7; - int64 timeout = 8; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 9 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - uint64 repeated_frequency = 10 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - string aggregate_func = 11 [ (gogoproto.moretags) = "yaml:\"aggregate_func\"" ]; - string value_json_path = 12 [ (gogoproto.moretags) = "yaml:\"value_json_path\"" ]; - uint32 response_threshold = 13 [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; + string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; + uint64 latest_history = 2 + [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; + string description = 3; + string creator = 4; + string service_name = 5 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + repeated string providers = 6; + string input = 7; + int64 timeout = 8; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 9 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + uint64 repeated_frequency = 10 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + string aggregate_func = 11 + [ (gogoproto.moretags) = "yaml:\"aggregate_func\"" ]; + string value_json_path = 12 + [ (gogoproto.moretags) = "yaml:\"value_json_path\"" ]; + uint32 response_threshold = 13 + [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; } // MsgCreateFeedResponse defines the Msg/CreateFeed response type @@ -43,8 +52,8 @@ message MsgCreateFeedResponse {} // MsgPauseFeed defines an sdk.Msg type that supports stating a feed message MsgStartFeed { - string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; - string creator = 2; + string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; + string creator = 2; } // MsgStartFeedResponse defines the Msg/StartFeed response type @@ -52,8 +61,8 @@ message MsgStartFeedResponse {} // MsgPauseFeed defines an sdk.Msg type that supports pausing a feed message MsgPauseFeed { - string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; - string creator = 2; + string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; + string creator = 2; } // MsgPauseFeedResponse defines the Msg/PauseFeed response type @@ -61,15 +70,22 @@ message MsgPauseFeedResponse {} // MsgEditFeed defines an sdk.Msg type that supports editing a feed message MsgEditFeed { - string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; - string description = 2; - uint64 latest_history = 3 [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; - repeated string providers = 4; - int64 timeout = 5; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 6 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - uint64 repeated_frequency = 7 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - uint32 response_threshold = 8 [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; - string creator = 9; + string feed_name = 1 [ (gogoproto.moretags) = "yaml:\"feed_name\"" ]; + string description = 2; + uint64 latest_history = 3 + [ (gogoproto.moretags) = "yaml:\"latest_history\"" ]; + repeated string providers = 4; + int64 timeout = 5; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + uint64 repeated_frequency = 7 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + uint32 response_threshold = 8 + [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; + string creator = 9; } // MsgEditFeedResponse defines the Msg/EditFeed response type diff --git a/proto/random/genesis.proto b/proto/random/genesis.proto index aebcf913..34ea521f 100644 --- a/proto/random/genesis.proto +++ b/proto/random/genesis.proto @@ -8,10 +8,11 @@ option go_package = "github.com/irisnet/irismod/modules/random/types"; // GenesisState defines the random module's genesis state message GenesisState { - map pending_random_requests = 1 [ (gogoproto.nullable) = false ]; + map pending_random_requests = 1 + [ (gogoproto.nullable) = false ]; } // Requests defines the random requests message Requests { - repeated Request requests = 1 [ (gogoproto.nullable) = false ]; + repeated Request requests = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/random/query.proto b/proto/random/query.proto index 2feaa199..a04d7d8d 100644 --- a/proto/random/query.proto +++ b/proto/random/query.proto @@ -9,33 +9,30 @@ option go_package = "github.com/irisnet/irismod/modules/random/types"; // Query creates service with guardian as rpc service Query { - // Random queries the random result - rpc Random(QueryRandomRequest) returns (QueryRandomResponse) { - option (google.api.http).get = "/irismod/random/randoms/{req_id}"; - } - - // RandomRequestQueue queries the random request queue - rpc RandomRequestQueue(QueryRandomRequestQueueRequest) returns (QueryRandomRequestQueueResponse) { - option (google.api.http).get = "/irismod/random/queue"; - } + // Random queries the random result + rpc Random(QueryRandomRequest) returns (QueryRandomResponse) { + option (google.api.http).get = "/irismod/random/randoms/{req_id}"; + } + + // RandomRequestQueue queries the random request queue + rpc RandomRequestQueue(QueryRandomRequestQueueRequest) + returns (QueryRandomRequestQueueResponse) { + option (google.api.http).get = "/irismod/random/queue"; + } } // QueryRandomRequest is request type for the Query/Random RPC method -message QueryRandomRequest { - string req_id = 1; -} +message QueryRandomRequest { string req_id = 1; } // QueryParametersResponse is response type for the Query/Random RPC method -message QueryRandomResponse { - Random random = 1; -} +message QueryRandomResponse { Random random = 1; } -// QueryRandomRequestQueueRequest is request type for the Query/RandomRequestQueue RPC method -message QueryRandomRequestQueueRequest { - int64 height = 1; -} +// QueryRandomRequestQueueRequest is request type for the +// Query/RandomRequestQueue RPC method +message QueryRandomRequestQueueRequest { int64 height = 1; } -// QueryRandomRequestQueueResponse is response type for the Query/RandomRequestQueue RPC method +// QueryRandomRequestQueueResponse is response type for the +// Query/RandomRequestQueue RPC method message QueryRandomRequestQueueResponse { - repeated Request requests = 1 [ (gogoproto.nullable) = false ]; + repeated Request requests = 1 [ (gogoproto.nullable) = false ]; } \ No newline at end of file diff --git a/proto/random/random.proto b/proto/random/random.proto index 72bca684..0d156bcf 100644 --- a/proto/random/random.proto +++ b/proto/random/random.proto @@ -8,17 +8,25 @@ option go_package = "github.com/irisnet/irismod/modules/random/types"; // Random defines the feed standard message Random { - string request_tx_hash = 1 [ (gogoproto.moretags) = "yaml:\"request_tx_hash\"" ]; - int64 height = 2; - string value = 3; + string request_tx_hash = 1 + [ (gogoproto.moretags) = "yaml:\"request_tx_hash\"" ]; + int64 height = 2; + string value = 3; } // Request defines the random request standard message Request { - int64 height = 1; - string consumer = 2; - string tx_hash = 3 [ (gogoproto.moretags) = "yaml:\"tx_hash\"" ]; - bool oracle = 4; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - string service_context_id = 6 [ (gogoproto.customname) = "ServiceContextID", (gogoproto.moretags) = "yaml:\"service_context_id\"" ]; + int64 height = 1; + string consumer = 2; + string tx_hash = 3 [ (gogoproto.moretags) = "yaml:\"tx_hash\"" ]; + bool oracle = 4; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + string service_context_id = 6 [ + (gogoproto.customname) = "ServiceContextID", + (gogoproto.moretags) = "yaml:\"service_context_id\"" + ]; } diff --git a/proto/random/tx.proto b/proto/random/tx.proto index aedb7de9..98520c9b 100644 --- a/proto/random/tx.proto +++ b/proto/random/tx.proto @@ -8,16 +8,22 @@ option go_package = "github.com/irisnet/irismod/modules/random/types"; // Msg defines the oracle Msg service service Msg { - // RequestRandom defines a method for requesting a new random number - rpc RequestRandom(MsgRequestRandom) returns (MsgRequestRandomResponse); + // RequestRandom defines a method for requesting a new random number + rpc RequestRandom(MsgRequestRandom) returns (MsgRequestRandomResponse); } -// MsgRequestRandom defines an sdk.Msg type that supports requesting a random number +// MsgRequestRandom defines an sdk.Msg type that supports requesting a random +// number message MsgRequestRandom { - uint64 block_interval = 1 [ (gogoproto.moretags) = "yaml:\"block_interval\"" ]; - string consumer = 2; - bool oracle = 3; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 4 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; + uint64 block_interval = 1 + [ (gogoproto.moretags) = "yaml:\"block_interval\"" ]; + string consumer = 2; + bool oracle = 3; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; } // MsgRequestRandomResponse defines the Msg/RequestRandom response type diff --git a/proto/record/genesis.proto b/proto/record/genesis.proto index 0d3c7ceb..1d2905a4 100644 --- a/proto/record/genesis.proto +++ b/proto/record/genesis.proto @@ -8,5 +8,5 @@ option go_package = "github.com/irisnet/irismod/modules/record/types"; // GenesisState defines the record module's genesis state message GenesisState { - repeated Record records = 1 [ (gogoproto.nullable) = false ]; + repeated Record records = 1 [ (gogoproto.nullable) = false ]; } diff --git a/proto/record/query.proto b/proto/record/query.proto index 6d88a8d2..f05c061a 100644 --- a/proto/record/query.proto +++ b/proto/record/query.proto @@ -8,18 +8,14 @@ option go_package = "github.com/irisnet/irismod/modules/record/types"; // Query defines the gRPC querier service for record module service Query { - // Record queries the record by the given record ID - rpc Record(QueryRecordRequest) returns (QueryRecordResponse) { - option (google.api.http).get = "/irismod/record/records/{record_id}"; - } + // Record queries the record by the given record ID + rpc Record(QueryRecordRequest) returns (QueryRecordResponse) { + option (google.api.http).get = "/irismod/record/records/{record_id}"; + } } // QueryRecordRequest is the request type for the Query/Record RPC method -message QueryRecordRequest { - string record_id = 1; -} +message QueryRecordRequest { string record_id = 1; } // QueryRecordResponse is the response type for the Query/Record RPC method -message QueryRecordResponse { - record.Record record = 1; -} +message QueryRecordResponse { record.Record record = 1; } diff --git a/proto/record/record.proto b/proto/record/record.proto index 9f36d388..217c174f 100644 --- a/proto/record/record.proto +++ b/proto/record/record.proto @@ -8,19 +8,19 @@ option (gogoproto.goproto_getters_all) = false; // Content defines the detailed information for a record message Content { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string digest = 1; - string digest_algo = 2 [ (gogoproto.moretags) = "yaml:\"digest_algo\"" ]; - string uri = 3 [ (gogoproto.customname) = "URI" ]; - string meta = 4; + string digest = 1; + string digest_algo = 2 [ (gogoproto.moretags) = "yaml:\"digest_algo\"" ]; + string uri = 3 [ (gogoproto.customname) = "URI" ]; + string meta = 4; } // Record defines the record standard message Record { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - string tx_hash = 1 [ (gogoproto.moretags) = "yaml:\"tx_hash\"" ]; - repeated Content contents = 2 [ (gogoproto.nullable) = false ]; - string creator = 3; + string tx_hash = 1 [ (gogoproto.moretags) = "yaml:\"tx_hash\"" ]; + repeated Content contents = 2 [ (gogoproto.nullable) = false ]; + string creator = 3; } diff --git a/proto/record/tx.proto b/proto/record/tx.proto index d6482e0d..1e212f67 100644 --- a/proto/record/tx.proto +++ b/proto/record/tx.proto @@ -9,19 +9,17 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the oracle Msg service service Msg { - // CreateRecord defines a method for creating a new record - rpc CreateRecord(MsgCreateRecord) returns (MsgCreateRecordResponse); + // CreateRecord defines a method for creating a new record + rpc CreateRecord(MsgCreateRecord) returns (MsgCreateRecordResponse); } // MsgCreateRecord defines an SDK message for creating a new record message MsgCreateRecord { - option (gogoproto.equal) = true; + option (gogoproto.equal) = true; - repeated Content contents = 1 [ (gogoproto.nullable) = false ]; - string creator = 2; + repeated Content contents = 1 [ (gogoproto.nullable) = false ]; + string creator = 2; } // MsgCreateRecordResponse defines the Msg/CreateRecord response type -message MsgCreateRecordResponse { - string id = 1; -} \ No newline at end of file +message MsgCreateRecordResponse { string id = 1; } \ No newline at end of file diff --git a/proto/service/genesis.proto b/proto/service/genesis.proto index b7640505..9cc401c0 100644 --- a/proto/service/genesis.proto +++ b/proto/service/genesis.proto @@ -8,9 +8,11 @@ option go_package = "github.com/irisnet/irismod/modules/service/types"; // GenesisState defines the service module's genesis state message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - repeated ServiceDefinition definitions = 2 [ (gogoproto.nullable) = false ]; - repeated ServiceBinding bindings = 3 [ (gogoproto.nullable) = false ]; - map withdraw_addresses = 4 [ (gogoproto.moretags) = "yaml:\"withdraw_addresses\"" ]; - map request_contexts = 5 [ (gogoproto.moretags) = "yaml:\"request_contexts\"" ]; + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated ServiceDefinition definitions = 2 [ (gogoproto.nullable) = false ]; + repeated ServiceBinding bindings = 3 [ (gogoproto.nullable) = false ]; + map withdraw_addresses = 4 + [ (gogoproto.moretags) = "yaml:\"withdraw_addresses\"" ]; + map request_contexts = 5 + [ (gogoproto.moretags) = "yaml:\"request_contexts\"" ]; } \ No newline at end of file diff --git a/proto/service/query.proto b/proto/service/query.proto index 249b14ff..ea59bbe5 100644 --- a/proto/service/query.proto +++ b/proto/service/query.proto @@ -11,213 +11,204 @@ option go_package = "github.com/irisnet/irismod/modules/service/types"; // Query creates service with iservice as rpc service Query { - // Definition returns service definition - rpc Definition(QueryDefinitionRequest) returns (QueryDefinitionResponse) { - option (google.api.http).get = "/irismod/service/definitions/{service_name}"; - } - - // Binding returns service Binding with service name and provider - rpc Binding(QueryBindingRequest) returns (QueryBindingResponse) { - option (google.api.http).get = "/irismod/service/bindings/{service_name}/{provider}"; - } - - // Bindings returns all service Bindings with service name and owner - rpc Bindings(QueryBindingsRequest) returns (QueryBindingsResponse) { - option (google.api.http).get = "/irismod/service/bindings/{service_name}"; - } - - // WithdrawAddress returns the withdraw address of the binding owner - rpc WithdrawAddress(QueryWithdrawAddressRequest) returns (QueryWithdrawAddressResponse) { - option (google.api.http).get = "/irismod/service/owners/{owner}/withdraw-address"; - } - - // RequestContext returns the request context - rpc RequestContext(QueryRequestContextRequest) returns (QueryRequestContextResponse) { - option (google.api.http).get = "/irismod/service/contexts/{request_context_id}"; - } - - // Request returns the request - rpc Request(QueryRequestRequest) returns (QueryRequestResponse) { - option (google.api.http).get = "/irismod/service/requests/{request_id}"; - } - - // Request returns all requests of one service with provider - rpc Requests(QueryRequestsRequest) returns (QueryRequestsResponse) { - option (google.api.http).get = "/irismod/service/requests/{service_name}/{provider}"; - } - - // RequestsByReqCtx returns all requests of one service call batch - rpc RequestsByReqCtx(QueryRequestsByReqCtxRequest) returns (QueryRequestsByReqCtxResponse) { - option (google.api.http).get = "/irismod/service/requests/{request_context_id}/{batch_counter}"; - } - - // Response returns the response of request - rpc Response(QueryResponseRequest) returns (QueryResponseResponse) { - option (google.api.http).get = "/irismod/service/responses/{request_id}"; - } - - // Responses returns all responses of one service call batch - rpc Responses(QueryResponsesRequest) returns (QueryResponsesResponse) { - option (google.api.http).get = "/irismod/service/responses/{request_context_id}/{batch_counter}"; - } - - // EarnedFees returns the earned service fee of one provider - rpc EarnedFees(QueryEarnedFeesRequest) returns (QueryEarnedFeesResponse) { - option (google.api.http).get = "/irismod/service/fees/{provider}"; - } - - // Schema returns the schema - rpc Schema(QuerySchemaRequest) returns (QuerySchemaResponse) { - option (google.api.http).get = "/irismod/service/schemas/{schema_name}"; - } - - // Params queries the service parameters - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/irismod/service/params"; - } + // Definition returns service definition + rpc Definition(QueryDefinitionRequest) returns (QueryDefinitionResponse) { + option (google.api.http).get = + "/irismod/service/definitions/{service_name}"; + } + + // Binding returns service Binding with service name and provider + rpc Binding(QueryBindingRequest) returns (QueryBindingResponse) { + option (google.api.http).get = + "/irismod/service/bindings/{service_name}/{provider}"; + } + + // Bindings returns all service Bindings with service name and owner + rpc Bindings(QueryBindingsRequest) returns (QueryBindingsResponse) { + option (google.api.http).get = "/irismod/service/bindings/{service_name}"; + } + + // WithdrawAddress returns the withdraw address of the binding owner + rpc WithdrawAddress(QueryWithdrawAddressRequest) + returns (QueryWithdrawAddressResponse) { + option (google.api.http).get = + "/irismod/service/owners/{owner}/withdraw-address"; + } + + // RequestContext returns the request context + rpc RequestContext(QueryRequestContextRequest) + returns (QueryRequestContextResponse) { + option (google.api.http).get = + "/irismod/service/contexts/{request_context_id}"; + } + + // Request returns the request + rpc Request(QueryRequestRequest) returns (QueryRequestResponse) { + option (google.api.http).get = "/irismod/service/requests/{request_id}"; + } + + // Request returns all requests of one service with provider + rpc Requests(QueryRequestsRequest) returns (QueryRequestsResponse) { + option (google.api.http).get = + "/irismod/service/requests/{service_name}/{provider}"; + } + + // RequestsByReqCtx returns all requests of one service call batch + rpc RequestsByReqCtx(QueryRequestsByReqCtxRequest) + returns (QueryRequestsByReqCtxResponse) { + option (google.api.http).get = + "/irismod/service/requests/{request_context_id}/{batch_counter}"; + } + + // Response returns the response of request + rpc Response(QueryResponseRequest) returns (QueryResponseResponse) { + option (google.api.http).get = "/irismod/service/responses/{request_id}"; + } + + // Responses returns all responses of one service call batch + rpc Responses(QueryResponsesRequest) returns (QueryResponsesResponse) { + option (google.api.http).get = + "/irismod/service/responses/{request_context_id}/{batch_counter}"; + } + + // EarnedFees returns the earned service fee of one provider + rpc EarnedFees(QueryEarnedFeesRequest) returns (QueryEarnedFeesResponse) { + option (google.api.http).get = "/irismod/service/fees/{provider}"; + } + + // Schema returns the schema + rpc Schema(QuerySchemaRequest) returns (QuerySchemaResponse) { + option (google.api.http).get = "/irismod/service/schemas/{schema_name}"; + } + + // Params queries the service parameters + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/irismod/service/params"; + } } // QueryDefinitionRequest is request type for the Query/Definition RPC method -message QueryDefinitionRequest { - string service_name = 1; -} +message QueryDefinitionRequest { string service_name = 1; } // QueryDefinitionResponse is response type for the Query/Definition RPC method -message QueryDefinitionResponse { - ServiceDefinition service_definition = 1; -} +message QueryDefinitionResponse { ServiceDefinition service_definition = 1; } // QueryBindingRequest is request type for the Query/Binding RPC method message QueryBindingRequest { - string service_name = 1; - string provider = 2; + string service_name = 1; + string provider = 2; } // QueryDefinitionResponse is response type for the Query/Binding RPC method -message QueryBindingResponse { - ServiceBinding service_binding = 1; -} +message QueryBindingResponse { ServiceBinding service_binding = 1; } // QueryBindingsRequest is request type for the Query/Bindings RPC method message QueryBindingsRequest { - string service_name = 1; - string owner = 2; - // pagination defines an optional pagination for the request - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string service_name = 1; + string owner = 2; + // pagination defines an optional pagination for the request + cosmos.base.query.v1beta1.PageRequest pagination = 3; } // QueryDefinitionsResponse is response type for the Query/Bindings RPC method message QueryBindingsResponse { - repeated ServiceBinding service_bindings = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated ServiceBinding service_bindings = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// QueryWithdrawAddressRequest is request type for the Query/WithdrawAddress RPC method -message QueryWithdrawAddressRequest { - string owner = 1; -} +// QueryWithdrawAddressRequest is request type for the Query/WithdrawAddress RPC +// method +message QueryWithdrawAddressRequest { string owner = 1; } -// QueryWithdrawAddressResponse is response type for the Query/WithdrawAddress RPC method -message QueryWithdrawAddressResponse { - string withdraw_address = 1; -} +// QueryWithdrawAddressResponse is response type for the Query/WithdrawAddress +// RPC method +message QueryWithdrawAddressResponse { string withdraw_address = 1; } -// QueryRequestContextRequest is request type for the Query/RequestContext RPC method -message QueryRequestContextRequest { - string request_context_id = 1; -} +// QueryRequestContextRequest is request type for the Query/RequestContext RPC +// method +message QueryRequestContextRequest { string request_context_id = 1; } -// QueryRequestContextResponse is response type for the Query/RequestContext RPC method -message QueryRequestContextResponse { - RequestContext request_context = 1; -} +// QueryRequestContextResponse is response type for the Query/RequestContext RPC +// method +message QueryRequestContextResponse { RequestContext request_context = 1; } // QueryRequestRequest is request type for the Query/Request RPC method -message QueryRequestRequest { - string request_id = 1; -} +message QueryRequestRequest { string request_id = 1; } // QueryRequestResponse is response type for the Query/Request RPC method -message QueryRequestResponse { - Request request = 1; -} +message QueryRequestResponse { Request request = 1; } // QueryRequestsRequest is request type for the Query/Requests RPC method message QueryRequestsRequest { - string service_name = 1; - string provider = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string service_name = 1; + string provider = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } // QueryRequestsResponse is response type for the Query/Requests RPC method message QueryRequestsResponse { - repeated Request requests = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated Request requests = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } -// QueryRequestsByReqCtxRequest is request type for the Query/RequestsByReqCtx RPC method +// QueryRequestsByReqCtxRequest is request type for the Query/RequestsByReqCtx +// RPC method message QueryRequestsByReqCtxRequest { - string request_context_id = 1; - uint64 batch_counter = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string request_context_id = 1; + uint64 batch_counter = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } -// QueryRequestsByReqCtxResponse is response type for the Query/RequestsByReqCtx RPC method +// QueryRequestsByReqCtxResponse is response type for the Query/RequestsByReqCtx +// RPC method message QueryRequestsByReqCtxResponse { - repeated Request requests = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated Request requests = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryResponseRequest is request type for the Query/Response RPC method -message QueryResponseRequest { - string request_id = 1; -} +message QueryResponseRequest { string request_id = 1; } // QueryResponseResponse is response type for the Query/Response RPC method -message QueryResponseResponse { - Response response = 1; -} +message QueryResponseResponse { Response response = 1; } // QueryResponsesRequest is request type for the Query/Responses RPC method message QueryResponsesRequest { - string request_context_id = 1; - uint64 batch_counter = 2; - cosmos.base.query.v1beta1.PageRequest pagination = 3; + string request_context_id = 1; + uint64 batch_counter = 2; + cosmos.base.query.v1beta1.PageRequest pagination = 3; } // QueryResponsesResponse is response type for the Query/Responses RPC method message QueryResponsesResponse { - repeated Response responses = 1; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + repeated Response responses = 1; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryEarnedFeesRequest is request type for the Query/EarnedFees RPC method -message QueryEarnedFeesRequest { - string provider = 1; -} +message QueryEarnedFeesRequest { string provider = 1; } // QueryEarnedFeesResponse is response type for the Query/EarnedFees RPC method message QueryEarnedFeesResponse { - repeated cosmos.base.v1beta1.Coin fees = 1 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee\"" ]; + repeated cosmos.base.v1beta1.Coin fees = 1 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee\"" + ]; } // QuerySchemaRequest is request type for the Query/Schema RPC method -message QuerySchemaRequest { - string schema_name = 1; -} +message QuerySchemaRequest { string schema_name = 1; } // QuerySchemaResponse is response type for the Query/Schema RPC method -message QuerySchemaResponse { - string schema = 1; -} +message QuerySchemaResponse { string schema = 1; } // QueryParametersRequest is request type for the Query/Parameters RPC method -message QueryParamsRequest { -} +message QueryParamsRequest {} // QueryParametersResponse is response type for the Query/Parameters RPC method message QueryParamsResponse { - service.Params params = 1 [ (gogoproto.nullable) = false ]; + service.Params params = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse res = 2; + cosmos.base.query.v1beta1.PageResponse res = 2; } diff --git a/proto/service/service.proto b/proto/service/service.proto index f227ff12..2f45b9fb 100644 --- a/proto/service/service.proto +++ b/proto/service/service.proto @@ -11,141 +11,223 @@ option (gogoproto.goproto_getters_all) = false; // ServiceDefinition defines a standard for service definition message ServiceDefinition { - string name = 1; - string description = 2; - repeated string tags = 3; - string author = 4; - string author_description = 5 [ (gogoproto.moretags) = "yaml:\"author_description\"" ]; - string schemas = 6; + string name = 1; + string description = 2; + repeated string tags = 3; + string author = 4; + string author_description = 5 + [ (gogoproto.moretags) = "yaml:\"author_description\"" ]; + string schemas = 6; } // ServiceBinding defines a standard for service binding message ServiceBinding { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - repeated cosmos.base.v1beta1.Coin deposit = 3 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string pricing = 4; - uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; - string options = 6; - bool available = 7; - google.protobuf.Timestamp disabled_time = 8 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"disabled_time\"" ]; - string owner = 9; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + repeated cosmos.base.v1beta1.Coin deposit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string pricing = 4; + uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; + string options = 6; + bool available = 7; + google.protobuf.Timestamp disabled_time = 8 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"disabled_time\"" + ]; + string owner = 9; } // RequestContext defines a standard for request context message RequestContext { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - repeated string providers = 2; - string consumer = 3; - string input = 4; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - string module_name = 6 [ (gogoproto.moretags) = "yaml:\"module_name\"" ]; - int64 timeout = 7; - bool repeated = 8; - uint64 repeated_frequency = 9 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - int64 repeated_total = 10 [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; - uint64 batch_counter = 11 [ (gogoproto.moretags) = "yaml:\"batch_counter\"" ]; - uint32 batch_request_count = 12 [ (gogoproto.moretags) = "yaml:\"batch_request_count\"" ]; - uint32 batch_response_count = 13 [ (gogoproto.moretags) = "yaml:\"batch_response_count\"" ]; - uint32 batch_response_threshold = 14 [ (gogoproto.moretags) = "yaml:\"batch_response_threshold\"" ]; - uint32 response_threshold = 15 [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; - RequestContextBatchState batch_state = 16 [ (gogoproto.moretags) = "yaml:\"batch_state\"" ]; - RequestContextState state = 17; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + repeated string providers = 2; + string consumer = 3; + string input = 4; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + string module_name = 6 [ (gogoproto.moretags) = "yaml:\"module_name\"" ]; + int64 timeout = 7; + bool repeated = 8; + uint64 repeated_frequency = 9 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + int64 repeated_total = 10 + [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; + uint64 batch_counter = 11 [ (gogoproto.moretags) = "yaml:\"batch_counter\"" ]; + uint32 batch_request_count = 12 + [ (gogoproto.moretags) = "yaml:\"batch_request_count\"" ]; + uint32 batch_response_count = 13 + [ (gogoproto.moretags) = "yaml:\"batch_response_count\"" ]; + uint32 batch_response_threshold = 14 + [ (gogoproto.moretags) = "yaml:\"batch_response_threshold\"" ]; + uint32 response_threshold = 15 + [ (gogoproto.moretags) = "yaml:\"response_threshold\"" ]; + RequestContextBatchState batch_state = 16 + [ (gogoproto.moretags) = "yaml:\"batch_state\"" ]; + RequestContextState state = 17; } // Request defines a standard for request message Request { - string id = 1; - string service_name = 2 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 3; - string consumer = 4; - string input = 5; - repeated cosmos.base.v1beta1.Coin service_fee = 6 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee\"" ]; - int64 request_height = 7 [ (gogoproto.moretags) = "yaml:\"request_height\"" ]; - int64 expiration_height = 8 [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; - string request_context_id = 9 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - uint64 request_context_batch_counter = 10 [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; + string id = 1; + string service_name = 2 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 3; + string consumer = 4; + string input = 5; + repeated cosmos.base.v1beta1.Coin service_fee = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee\"" + ]; + int64 request_height = 7 [ (gogoproto.moretags) = "yaml:\"request_height\"" ]; + int64 expiration_height = 8 + [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; + string request_context_id = 9 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + uint64 request_context_batch_counter = 10 + [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; } // CompactRequest defines a standard for compact request message CompactRequest { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - uint64 request_context_batch_counter = 2 [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; - string provider = 3; - repeated cosmos.base.v1beta1.Coin service_fee = 4 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee\"" ]; - int64 request_height = 5 [ (gogoproto.moretags) = "yaml:\"request_height\"" ]; - int64 expiration_height = 6 [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + uint64 request_context_batch_counter = 2 + [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; + string provider = 3; + repeated cosmos.base.v1beta1.Coin service_fee = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee\"" + ]; + int64 request_height = 5 [ (gogoproto.moretags) = "yaml:\"request_height\"" ]; + int64 expiration_height = 6 + [ (gogoproto.moretags) = "yaml:\"expiration_height\"" ]; } // Response defines a standard for response message Response { - string provider = 1; - string consumer = 2; - string result = 3; - string output = 4; - string request_context_id = 5 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - uint64 request_context_batch_counter = 6 [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; + string provider = 1; + string consumer = 2; + string result = 3; + string output = 4; + string request_context_id = 5 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + uint64 request_context_batch_counter = 6 + [ (gogoproto.moretags) = "yaml:\"request_context_batch_counter\"" ]; } // Pricing defines a standard for service pricing message Pricing { - repeated cosmos.base.v1beta1.Coin price = 6 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - repeated PromotionByTime promotions_by_time = 2 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"promotions_by_time\"" ]; - repeated PromotionByVolume promotions_by_volume = 3 [ (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"promotions_by_volume\"" ]; + repeated cosmos.base.v1beta1.Coin price = 6 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + repeated PromotionByTime promotions_by_time = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"promotions_by_time\"" + ]; + repeated PromotionByVolume promotions_by_volume = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"promotions_by_volume\"" + ]; } // PromotionByTime defines a standard for service promotion by time message PromotionByTime { - google.protobuf.Timestamp start_time = 1 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"start_time\"" ]; - google.protobuf.Timestamp end_time = 2 [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false, (gogoproto.moretags) = "yaml:\"end_time\"" ]; - string discount = 3 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + google.protobuf.Timestamp start_time = 1 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"start_time\"" + ]; + google.protobuf.Timestamp end_time = 2 [ + (gogoproto.stdtime) = true, + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"end_time\"" + ]; + string discount = 3 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } // PromotionByVolume defines a standard for service promotion by volume message PromotionByVolume { - uint64 volume = 1; - string discount = 2 [ (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + uint64 volume = 1; + string discount = 2 [ + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } -// RequestContextBatchState is a type alias that represents a request batch status as a byte +// RequestContextBatchState is a type alias that represents a request batch +// status as a byte enum RequestContextBatchState { - option (gogoproto.enum_stringer) = true; - option (gogoproto.goproto_enum_stringer) = false; - option (gogoproto.goproto_enum_prefix) = false; - - // BATCH_RUNNING defines the running batch status. - BATCH_RUNNING = 0 [ (gogoproto.enumvalue_customname) = "BATCHRUNNING" ]; - // BATCH_COMPLETED defines the completed batch status. - BATCH_COMPLETED = 1 [ (gogoproto.enumvalue_customname) = "BATCHCOMPLETED" ]; + option (gogoproto.enum_stringer) = true; + option (gogoproto.goproto_enum_stringer) = false; + option (gogoproto.goproto_enum_prefix) = false; + + // BATCH_RUNNING defines the running batch status. + BATCH_RUNNING = 0 [ (gogoproto.enumvalue_customname) = "BATCHRUNNING" ]; + // BATCH_COMPLETED defines the completed batch status. + BATCH_COMPLETED = 1 [ (gogoproto.enumvalue_customname) = "BATCHCOMPLETED" ]; } -// RequestContextState is a type alias that represents a request status as a byte +// RequestContextState is a type alias that represents a request status as a +// byte enum RequestContextState { - option (gogoproto.enum_stringer) = true; - option (gogoproto.goproto_enum_stringer) = false; - option (gogoproto.goproto_enum_prefix) = false; - - // RUNNING defines the running request context status - RUNNING = 0 [ (gogoproto.enumvalue_customname) = "RUNNING" ]; - // PAUSED defines the paused request context status - PAUSED = 1 [ (gogoproto.enumvalue_customname) = "PAUSED" ]; - // COMPLETED defines the completed request context status - COMPLETED = 2 [ (gogoproto.enumvalue_customname) = "COMPLETED" ]; + option (gogoproto.enum_stringer) = true; + option (gogoproto.goproto_enum_stringer) = false; + option (gogoproto.goproto_enum_prefix) = false; + + // RUNNING defines the running request context status + RUNNING = 0 [ (gogoproto.enumvalue_customname) = "RUNNING" ]; + // PAUSED defines the paused request context status + PAUSED = 1 [ (gogoproto.enumvalue_customname) = "PAUSED" ]; + // COMPLETED defines the completed request context status + COMPLETED = 2 [ (gogoproto.enumvalue_customname) = "COMPLETED" ]; } // Params defines service module's parameters message Params { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - int64 max_request_timeout = 1 [(gogoproto.moretags) = "yaml:\"max_request_timeout\""]; - int64 min_deposit_multiple = 2 [(gogoproto.moretags) = "yaml:\"min_deposit_multiple\""]; - repeated cosmos.base.v1beta1.Coin min_deposit = 3 [(gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins"]; - string service_fee_tax = 4 [(gogoproto.moretags) = "yaml:\"service_fee_tax\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - string slash_fraction = 5 [(gogoproto.moretags) = "yaml:\"slash_fraction\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false]; - google.protobuf.Duration complaint_retrospect = 6 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"complaint_retrospect\""]; - google.protobuf.Duration arbitration_time_limit = 7 [(gogoproto.nullable) = false, (gogoproto.stdduration) = true, (gogoproto.moretags) = "yaml:\"arbitration_time_limit\""]; - uint64 tx_size_limit = 8 [(gogoproto.moretags) = "yaml:\"tx_size_limit\""]; - string base_denom = 9 [(gogoproto.moretags) = "yaml:\"base_denom\""]; - bool restricted_service_fee_denom = 10 [(gogoproto.moretags) = "yaml:\"restricted_service_fee_denom\""]; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + int64 max_request_timeout = 1 + [ (gogoproto.moretags) = "yaml:\"max_request_timeout\"" ]; + int64 min_deposit_multiple = 2 + [ (gogoproto.moretags) = "yaml:\"min_deposit_multiple\"" ]; + repeated cosmos.base.v1beta1.Coin min_deposit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string service_fee_tax = 4 [ + (gogoproto.moretags) = "yaml:\"service_fee_tax\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + string slash_fraction = 5 [ + (gogoproto.moretags) = "yaml:\"slash_fraction\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + google.protobuf.Duration complaint_retrospect = 6 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"complaint_retrospect\"" + ]; + google.protobuf.Duration arbitration_time_limit = 7 [ + (gogoproto.nullable) = false, + (gogoproto.stdduration) = true, + (gogoproto.moretags) = "yaml:\"arbitration_time_limit\"" + ]; + uint64 tx_size_limit = 8 [ (gogoproto.moretags) = "yaml:\"tx_size_limit\"" ]; + string base_denom = 9 [ (gogoproto.moretags) = "yaml:\"base_denom\"" ]; + bool restricted_service_fee_denom = 10 + [ (gogoproto.moretags) = "yaml:\"restricted_service_fee_denom\"" ]; } diff --git a/proto/service/tx.proto b/proto/service/tx.proto index 2949a818..d06c9eaf 100644 --- a/proto/service/tx.proto +++ b/proto/service/tx.proto @@ -9,57 +9,68 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the oracle Msg service service Msg { - // DefineService defines a method for define a new service - rpc DefineService(MsgDefineService) returns (MsgDefineServiceResponse); + // DefineService defines a method for define a new service + rpc DefineService(MsgDefineService) returns (MsgDefineServiceResponse); - // BindService defines a method for bind a server - rpc BindService(MsgBindService) returns (MsgBindServiceResponse); + // BindService defines a method for bind a server + rpc BindService(MsgBindService) returns (MsgBindServiceResponse); - // UpdateServiceBinding defines a method for update a service binding - rpc UpdateServiceBinding(MsgUpdateServiceBinding) returns (MsgUpdateServiceBindingResponse); + // UpdateServiceBinding defines a method for update a service binding + rpc UpdateServiceBinding(MsgUpdateServiceBinding) + returns (MsgUpdateServiceBindingResponse); - // SetWithdrawAddress defines a method for setting a withdraw address - rpc SetWithdrawAddress(MsgSetWithdrawAddress) returns (MsgSetWithdrawAddressResponse); + // SetWithdrawAddress defines a method for setting a withdraw address + rpc SetWithdrawAddress(MsgSetWithdrawAddress) + returns (MsgSetWithdrawAddressResponse); - // EnableServiceBinding defines a method for enabling a service binding - rpc EnableServiceBinding(MsgEnableServiceBinding) returns (MsgEnableServiceBindingResponse); + // EnableServiceBinding defines a method for enabling a service binding + rpc EnableServiceBinding(MsgEnableServiceBinding) + returns (MsgEnableServiceBindingResponse); - // DisableServiceBinding defines a method for disabling a service binding - rpc DisableServiceBinding(MsgDisableServiceBinding) returns (MsgDisableServiceBindingResponse); + // DisableServiceBinding defines a method for disabling a service binding + rpc DisableServiceBinding(MsgDisableServiceBinding) + returns (MsgDisableServiceBindingResponse); - // RefundServiceDeposit defines a method for refunding a fee - rpc RefundServiceDeposit(MsgRefundServiceDeposit) returns (MsgRefundServiceDepositResponse); + // RefundServiceDeposit defines a method for refunding a fee + rpc RefundServiceDeposit(MsgRefundServiceDeposit) + returns (MsgRefundServiceDepositResponse); - // CallService defines a method for calling a service - rpc CallService(MsgCallService) returns (MsgCallServiceResponse); + // CallService defines a method for calling a service + rpc CallService(MsgCallService) returns (MsgCallServiceResponse); - // RespondService defines a method for responding a service - rpc RespondService(MsgRespondService) returns (MsgRespondServiceResponse); + // RespondService defines a method for responding a service + rpc RespondService(MsgRespondService) returns (MsgRespondServiceResponse); - // PauseRequestContext defines a method for pausing a service call - rpc PauseRequestContext(MsgPauseRequestContext) returns (MsgPauseRequestContextResponse); + // PauseRequestContext defines a method for pausing a service call + rpc PauseRequestContext(MsgPauseRequestContext) + returns (MsgPauseRequestContextResponse); - // StartRequestContext defines a method for starting a service call - rpc StartRequestContext(MsgStartRequestContext) returns (MsgStartRequestContextResponse); + // StartRequestContext defines a method for starting a service call + rpc StartRequestContext(MsgStartRequestContext) + returns (MsgStartRequestContextResponse); - // KillRequestContext defines a method for killing a service call - rpc KillRequestContext(MsgKillRequestContext) returns (MsgKillRequestContextResponse); + // KillRequestContext defines a method for killing a service call + rpc KillRequestContext(MsgKillRequestContext) + returns (MsgKillRequestContextResponse); - // UpdateRequestContext defines a method for updating a service call - rpc UpdateRequestContext(MsgUpdateRequestContext) returns (MsgUpdateRequestContextResponse); + // UpdateRequestContext defines a method for updating a service call + rpc UpdateRequestContext(MsgUpdateRequestContext) + returns (MsgUpdateRequestContextResponse); - // WithdrawEarnedFees defines a method for Withdrawing a earned fees - rpc WithdrawEarnedFees(MsgWithdrawEarnedFees) returns (MsgWithdrawEarnedFeesResponse); + // WithdrawEarnedFees defines a method for Withdrawing a earned fees + rpc WithdrawEarnedFees(MsgWithdrawEarnedFees) + returns (MsgWithdrawEarnedFeesResponse); } // MsgDefineService defines an SDK message for defining a new service message MsgDefineService { - string name = 1; - string description = 2; - repeated string tags = 3; - string author = 4; - string author_description = 5 [ (gogoproto.moretags) = "yaml:\"author_description\"" ]; - string schemas = 6; + string name = 1; + string description = 2; + repeated string tags = 3; + string author = 4; + string author_description = 5 + [ (gogoproto.moretags) = "yaml:\"author_description\"" ]; + string schemas = 6; } // MsgDefineServiceResponse defines the Msg/DefineService response type @@ -67,96 +78,120 @@ message MsgDefineServiceResponse {} // MsgBindService defines an SDK message for binding to an existing service message MsgBindService { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - repeated cosmos.base.v1beta1.Coin deposit = 3 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string pricing = 4; - uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; - string options = 6; - string owner = 7; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + repeated cosmos.base.v1beta1.Coin deposit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string pricing = 4; + uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; + string options = 6; + string owner = 7; } // MsgBindServiceResponse defines the Msg/BindService response type message MsgBindServiceResponse {} -// MsgUpdateServiceBinding defines an SDK message for updating an existing service binding +// MsgUpdateServiceBinding defines an SDK message for updating an existing +// service binding message MsgUpdateServiceBinding { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - repeated cosmos.base.v1beta1.Coin deposit = 3 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string pricing = 4; - uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; - string options = 6; - string owner = 7; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + repeated cosmos.base.v1beta1.Coin deposit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string pricing = 4; + uint64 qos = 5 [ (gogoproto.customname) = "QoS" ]; + string options = 6; + string owner = 7; } -// MsgUpdateServiceBindingResponse defines the Msg/UpdateServiceBinding response type +// MsgUpdateServiceBindingResponse defines the Msg/UpdateServiceBinding response +// type message MsgUpdateServiceBindingResponse {} -// MsgSetWithdrawAddress defines an SDK message to set the withdrawal address for a provider +// MsgSetWithdrawAddress defines an SDK message to set the withdrawal address +// for a provider message MsgSetWithdrawAddress { - string owner = 1; - string withdraw_address = 2 [ (gogoproto.moretags) = "yaml:\"withdraw_address\"" ]; + string owner = 1; + string withdraw_address = 2 + [ (gogoproto.moretags) = "yaml:\"withdraw_address\"" ]; } -// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type +// MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response +// type message MsgSetWithdrawAddressResponse {} // MsgDisableServiceBinding defines an SDK message to disable a service binding message MsgDisableServiceBinding { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - string owner = 3; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + string owner = 3; } -// MsgDisableServiceBindingResponse defines the Msg/DisableServiceBinding response type +// MsgDisableServiceBindingResponse defines the Msg/DisableServiceBinding +// response type message MsgDisableServiceBindingResponse {} // MsgEnableServiceBinding defines an SDK message to enable a service binding message MsgEnableServiceBinding { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - repeated cosmos.base.v1beta1.Coin deposit = 3 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" ]; - string owner = 4; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + repeated cosmos.base.v1beta1.Coin deposit = 3 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins" + ]; + string owner = 4; } -// MsgEnableServiceBindingResponse defines the Msg/EnableServiceBinding response type +// MsgEnableServiceBindingResponse defines the Msg/EnableServiceBinding response +// type message MsgEnableServiceBindingResponse {} -// MsgRefundServiceDeposit defines an SDK message to refund deposit from a service binding +// MsgRefundServiceDeposit defines an SDK message to refund deposit from a +// service binding message MsgRefundServiceDeposit { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - string provider = 2; - string owner = 3; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + string provider = 2; + string owner = 3; } -// MsgRefundServiceDepositResponse defines the Msg/RefundServiceDeposit response type +// MsgRefundServiceDepositResponse defines the Msg/RefundServiceDeposit response +// type message MsgRefundServiceDepositResponse {} // MsgCallService defines an SDK message to initiate a service request context message MsgCallService { - string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; - repeated string providers = 2; - string consumer = 3; - string input = 4; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - int64 timeout = 6; - bool repeated = 7; - uint64 repeated_frequency = 8 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - int64 repeated_total = 9 [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; + string service_name = 1 [ (gogoproto.moretags) = "yaml:\"service_name\"" ]; + repeated string providers = 2; + string consumer = 3; + string input = 4; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 5 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + int64 timeout = 6; + bool repeated = 7; + uint64 repeated_frequency = 8 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + int64 repeated_total = 9 [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; } // MsgCallServiceResponse defines the Msg/CallService response type message MsgCallServiceResponse { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; } // MsgRespondService defines an SDK message to respond a service request message MsgRespondService { - string request_id = 1 [ (gogoproto.moretags) = "yaml:\"request_id\"" ]; - string provider = 2; - string result = 3; - string output = 4; + string request_id = 1 [ (gogoproto.moretags) = "yaml:\"request_id\"" ]; + string provider = 2; + string result = 3; + string output = 4; } // MsgRespondServiceResponse defines the Msg/RespondService response type @@ -164,50 +199,66 @@ message MsgRespondServiceResponse {} // MsgPauseRequestContext defines an SDK message to pause a service request message MsgPauseRequestContext { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - string consumer = 2; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + string consumer = 2; } -// MsgPauseRequestContextResponse defines the Msg/PauseRequestContext response type +// MsgPauseRequestContextResponse defines the Msg/PauseRequestContext response +// type message MsgPauseRequestContextResponse {} // MsgStartRequestContext defines an SDK message to resume a service request message MsgStartRequestContext { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - string consumer = 2; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + string consumer = 2; } -// MsgStartRequestContextResponse defines the Msg/StartRequestContext response type +// MsgStartRequestContextResponse defines the Msg/StartRequestContext response +// type message MsgStartRequestContextResponse {} // MsgKillRequestContext defines an SDK message to terminate a service request message MsgKillRequestContext { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - string consumer = 2; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + string consumer = 2; } -// MsgKillRequestContextResponse defines the Msg/KillRequestContext response type +// MsgKillRequestContextResponse defines the Msg/KillRequestContext response +// type message MsgKillRequestContextResponse {} -// MsgUpdateRequestContext defines an SDK message to update a service request context +// MsgUpdateRequestContext defines an SDK message to update a service request +// context message MsgUpdateRequestContext { - string request_context_id = 1 [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; - repeated string providers = 2; - string consumer = 3; - repeated cosmos.base.v1beta1.Coin service_fee_cap = 4 [ (gogoproto.nullable) = false, (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", (gogoproto.moretags) = "yaml:\"service_fee_cap\"" ]; - int64 timeout = 5; - uint64 repeated_frequency = 6 [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; - int64 repeated_total = 7 [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; + string request_context_id = 1 + [ (gogoproto.moretags) = "yaml:\"request_context_id\"" ]; + repeated string providers = 2; + string consumer = 3; + repeated cosmos.base.v1beta1.Coin service_fee_cap = 4 [ + (gogoproto.nullable) = false, + (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", + (gogoproto.moretags) = "yaml:\"service_fee_cap\"" + ]; + int64 timeout = 5; + uint64 repeated_frequency = 6 + [ (gogoproto.moretags) = "yaml:\"repeated_frequency\"" ]; + int64 repeated_total = 7 [ (gogoproto.moretags) = "yaml:\"repeated_total\"" ]; } -// MsgUpdateRequestContextResponse defines the Msg/UpdateRequestContext response type +// MsgUpdateRequestContextResponse defines the Msg/UpdateRequestContext response +// type message MsgUpdateRequestContextResponse {} -// MsgWithdrawEarnedFees defines an SDK message to withdraw the fees earned by the provider or owner +// MsgWithdrawEarnedFees defines an SDK message to withdraw the fees earned by +// the provider or owner message MsgWithdrawEarnedFees { - string owner = 1; - string provider = 2; + string owner = 1; + string provider = 2; } -// MsgWithdrawEarnedFeesResponse defines the Msg/WithdrawEarnedFees response type +// MsgWithdrawEarnedFeesResponse defines the Msg/WithdrawEarnedFees response +// type message MsgWithdrawEarnedFeesResponse {} \ No newline at end of file diff --git a/proto/token/genesis.proto b/proto/token/genesis.proto index 6e78192e..d0b52606 100644 --- a/proto/token/genesis.proto +++ b/proto/token/genesis.proto @@ -9,8 +9,8 @@ option go_package = "github.com/irisnet/irismod/modules/token/types"; // GenesisState defines the token module's genesis state message GenesisState { - Params params = 1 [ (gogoproto.nullable) = false ]; - repeated Token tokens = 2 [ (gogoproto.nullable) = false ]; - repeated cosmos.base.v1beta1.Coin burned_coins = 3 - [ (gogoproto.nullable) = false ]; + Params params = 1 [ (gogoproto.nullable) = false ]; + repeated Token tokens = 2 [ (gogoproto.nullable) = false ]; + repeated cosmos.base.v1beta1.Coin burned_coins = 3 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/token/query.proto b/proto/token/query.proto index b29c9589..8b085838 100644 --- a/proto/token/query.proto +++ b/proto/token/query.proto @@ -13,72 +13,68 @@ option go_package = "github.com/irisnet/irismod/modules/token/types"; // Query creates service with token as RPC service Query { - // Token returns token with token name - rpc Token(QueryTokenRequest) returns (QueryTokenResponse) { - option (google.api.http).get = "/irismod/token/tokens/{denom}"; - } - // Tokens returns the token list - rpc Tokens(QueryTokensRequest) returns (QueryTokensResponse) { - option (google.api.http).get = "/irismod/token/tokens"; - } - // Fees returns the fees to issue or mint a token - rpc Fees(QueryFeesRequest) returns (QueryFeesResponse) { - option (google.api.http).get = "/irismod/token/tokens/{symbol}/fees"; - } - // Params queries the token parameters - rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { - option (google.api.http).get = "/irismod/token/params"; - } - // TotalBurn queries all the burnt coins - rpc TotalBurn(QueryTotalBurnRequest) returns (QueryTotalBurnResponse) { - option (google.api.http).get = "/irismod/token/total_burn"; - } + // Token returns token with token name + rpc Token(QueryTokenRequest) returns (QueryTokenResponse) { + option (google.api.http).get = "/irismod/token/tokens/{denom}"; + } + // Tokens returns the token list + rpc Tokens(QueryTokensRequest) returns (QueryTokensResponse) { + option (google.api.http).get = "/irismod/token/tokens"; + } + // Fees returns the fees to issue or mint a token + rpc Fees(QueryFeesRequest) returns (QueryFeesResponse) { + option (google.api.http).get = "/irismod/token/tokens/{symbol}/fees"; + } + // Params queries the token parameters + rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { + option (google.api.http).get = "/irismod/token/params"; + } + // TotalBurn queries all the burnt coins + rpc TotalBurn(QueryTotalBurnRequest) returns (QueryTotalBurnResponse) { + option (google.api.http).get = "/irismod/token/total_burn"; + } } // QueryTokenRequest is request type for the Query/Token RPC method -message QueryTokenRequest { - string denom = 1; -} +message QueryTokenRequest { string denom = 1; } // QueryTokenResponse is response type for the Query/Token RPC method message QueryTokenResponse { - google.protobuf.Any Token = 1 - [ (cosmos_proto.accepts_interface) = "ContentI" ]; + google.protobuf.Any Token = 1 + [ (cosmos_proto.accepts_interface) = "ContentI" ]; } // QueryTokensRequest is request type for the Query/Tokens RPC method message QueryTokensRequest { - string owner = 1; - // pagination defines an optional pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 2; + string owner = 1; + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 2; } // QueryTokensResponse is response type for the Query/Tokens RPC method message QueryTokensResponse { - repeated google.protobuf.Any Tokens = 1 - [ (cosmos_proto.accepts_interface) = "ContentI" ]; + repeated google.protobuf.Any Tokens = 1 + [ (cosmos_proto.accepts_interface) = "ContentI" ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; + cosmos.base.query.v1beta1.PageResponse pagination = 2; } // QueryFeesRequest is request type for the Query/Fees RPC method -message QueryFeesRequest { - string symbol = 1; -} +message QueryFeesRequest { string symbol = 1; } // QueryFeesResponse is response type for the Query/Fees RPC method message QueryFeesResponse { - bool exist = 1; - cosmos.base.v1beta1.Coin issue_fee = 2 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"issue_fee\"", - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" - ]; - cosmos.base.v1beta1.Coin mint_fee = 3 [ - (gogoproto.nullable) = false, - (gogoproto.moretags) = "yaml:\"mint_fee\"", - (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" - ]; + bool exist = 1; + cosmos.base.v1beta1.Coin issue_fee = 2 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"issue_fee\"", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; + cosmos.base.v1beta1.Coin mint_fee = 3 [ + (gogoproto.nullable) = false, + (gogoproto.moretags) = "yaml:\"mint_fee\"", + (gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.Coin" + ]; } // QueryParametersRequest is request type for the Query/Parameters RPC method @@ -86,9 +82,9 @@ message QueryParamsRequest {} // QueryParametersResponse is response type for the Query/Parameters RPC method message QueryParamsResponse { - token.Params params = 1 [ (gogoproto.nullable) = false ]; + token.Params params = 1 [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse res = 2; + cosmos.base.query.v1beta1.PageResponse res = 2; } // QueryTokenRequest is request type for the Query/TotalBurn RPC method @@ -96,6 +92,6 @@ message QueryTotalBurnRequest {} // QueryTotalBurnResponse is response type for the Query/TotalBurn RPC method message QueryTotalBurnResponse { - repeated cosmos.base.v1beta1.Coin burned_coins = 1 - [ (gogoproto.nullable) = false ]; + repeated cosmos.base.v1beta1.Coin burned_coins = 1 + [ (gogoproto.nullable) = false ]; } diff --git a/proto/token/token.proto b/proto/token/token.proto index 67a95f62..5c4b714b 100644 --- a/proto/token/token.proto +++ b/proto/token/token.proto @@ -9,27 +9,39 @@ option (gogoproto.goproto_getters_all) = false; // Token defines a standard for the fungible token message Token { - option (gogoproto.goproto_stringer) = false; - option (gogoproto.goproto_getters) = false; - - string symbol = 1; - string name = 2; - uint32 scale = 3; - string min_unit = 4 [ (gogoproto.moretags) = "yaml:\"min_unit\"" ]; - uint64 initial_supply = 5 [ (gogoproto.moretags) = "yaml:\"initial_supply\"" ]; - uint64 max_supply = 6 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; - bool mintable = 7; - string owner = 8; + option (gogoproto.goproto_stringer) = false; + option (gogoproto.goproto_getters) = false; + + string symbol = 1; + string name = 2; + uint32 scale = 3; + string min_unit = 4 [ (gogoproto.moretags) = "yaml:\"min_unit\"" ]; + uint64 initial_supply = 5 + [ (gogoproto.moretags) = "yaml:\"initial_supply\"" ]; + uint64 max_supply = 6 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; + bool mintable = 7; + string owner = 8; } // Params defines token module's parameters message Params { - option (gogoproto.equal) = true; - option (gogoproto.goproto_stringer) = false; - - string token_tax_rate = 1 [ (gogoproto.moretags) = "yaml:\"token_tax_rate\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; - - cosmos.base.v1beta1.Coin issue_token_base_fee = 2 [ (gogoproto.moretags) = "yaml:\"issue_token_base_fee\"", (gogoproto.nullable) = false ]; - - string mint_token_fee_ratio = 3 [ (gogoproto.moretags) = "yaml:\"mint_token_fee_ratio\"", (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", (gogoproto.nullable) = false ]; + option (gogoproto.equal) = true; + option (gogoproto.goproto_stringer) = false; + + string token_tax_rate = 1 [ + (gogoproto.moretags) = "yaml:\"token_tax_rate\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; + + cosmos.base.v1beta1.Coin issue_token_base_fee = 2 [ + (gogoproto.moretags) = "yaml:\"issue_token_base_fee\"", + (gogoproto.nullable) = false + ]; + + string mint_token_fee_ratio = 3 [ + (gogoproto.moretags) = "yaml:\"mint_token_fee_ratio\"", + (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Dec", + (gogoproto.nullable) = false + ]; } diff --git a/proto/token/tx.proto b/proto/token/tx.proto index 1768fb6d..38068d9c 100644 --- a/proto/token/tx.proto +++ b/proto/token/tx.proto @@ -8,32 +8,34 @@ option (gogoproto.goproto_getters_all) = false; // Msg defines the oracle Msg service service Msg { - // IssueToken defines a method for issuing a new token - rpc IssueToken(MsgIssueToken) returns (MsgIssueTokenResponse); + // IssueToken defines a method for issuing a new token + rpc IssueToken(MsgIssueToken) returns (MsgIssueTokenResponse); - // EditToken defines a method for editing a token - rpc EditToken(MsgEditToken) returns (MsgEditTokenResponse); + // EditToken defines a method for editing a token + rpc EditToken(MsgEditToken) returns (MsgEditTokenResponse); - // MintToken defines a method for minting some tokens - rpc MintToken(MsgMintToken) returns (MsgMintTokenResponse); + // MintToken defines a method for minting some tokens + rpc MintToken(MsgMintToken) returns (MsgMintTokenResponse); - // BurnToken defines a method for burning some tokens - rpc BurnToken(MsgBurnToken) returns (MsgBurnTokenResponse); + // BurnToken defines a method for burning some tokens + rpc BurnToken(MsgBurnToken) returns (MsgBurnTokenResponse); - // TransferTokenOwner defines a method for minting some tokens - rpc TransferTokenOwner(MsgTransferTokenOwner) returns (MsgTransferTokenOwnerResponse); + // TransferTokenOwner defines a method for minting some tokens + rpc TransferTokenOwner(MsgTransferTokenOwner) + returns (MsgTransferTokenOwnerResponse); } // MsgIssueToken defines an SDK message for issuing a new token message MsgIssueToken { - string symbol = 1; - string name = 2; - uint32 scale = 3; - string min_unit = 4 [ (gogoproto.moretags) = "yaml:\"min_unit\"" ]; - uint64 initial_supply = 5 [ (gogoproto.moretags) = "yaml:\"initial_supply\"" ]; - uint64 max_supply = 6 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; - bool mintable = 7; - string owner = 8; + string symbol = 1; + string name = 2; + uint32 scale = 3; + string min_unit = 4 [ (gogoproto.moretags) = "yaml:\"min_unit\"" ]; + uint64 initial_supply = 5 + [ (gogoproto.moretags) = "yaml:\"initial_supply\"" ]; + uint64 max_supply = 6 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; + bool mintable = 7; + string owner = 8; } // MsgIssueTokenResponse defines the Msg/IssueToken response type @@ -41,21 +43,22 @@ message MsgIssueTokenResponse {} // MsgTransferTokenOwner defines an SDK message for transferring the token owner message MsgTransferTokenOwner { - string src_owner = 1 [ (gogoproto.moretags) = "yaml:\"src_owner\"" ]; - string dst_owner = 2 [ (gogoproto.moretags) = "yaml:\"dst_owner\"" ]; - string symbol = 3; + string src_owner = 1 [ (gogoproto.moretags) = "yaml:\"src_owner\"" ]; + string dst_owner = 2 [ (gogoproto.moretags) = "yaml:\"dst_owner\"" ]; + string symbol = 3; } -// MsgTransferTokenOwnerResponse defines the Msg/TransferTokenOwner response type +// MsgTransferTokenOwnerResponse defines the Msg/TransferTokenOwner response +// type message MsgTransferTokenOwnerResponse {} // MsgEditToken defines an SDK message for editing a new token message MsgEditToken { - string symbol = 1; - string name = 2; - uint64 max_supply = 3 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; - string mintable = 4 [ (gogoproto.casttype) = "Bool" ]; - string owner = 5; + string symbol = 1; + string name = 2; + uint64 max_supply = 3 [ (gogoproto.moretags) = "yaml:\"max_supply\"" ]; + string mintable = 4 [ (gogoproto.casttype) = "Bool" ]; + string owner = 5; } // MsgEditTokenResponse defines the Msg/EditToken response type @@ -63,10 +66,10 @@ message MsgEditTokenResponse {} // MsgMintToken defines an SDK message for minting a new token message MsgMintToken { - string symbol = 1; - uint64 amount = 2; - string to = 3; - string owner = 4; + string symbol = 1; + uint64 amount = 2; + string to = 3; + string owner = 4; } // MsgMintTokenResponse defines the Msg/MintToken response type @@ -74,9 +77,9 @@ message MsgMintTokenResponse {} // MsgBurnToken defines an SDK message for burning some tokens message MsgBurnToken { - string symbol = 1; - uint64 amount = 2; - string sender = 3; + string symbol = 1; + uint64 amount = 2; + string sender = 3; } // MsgBurnTokenResponse defines the Msg/BurnToken response type diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index c016b535..071b05bc 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -2,24 +2,20 @@ set -eo pipefail -proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) +echo "Generating gogo proto code" +cd proto +proto_dirs=$(find ./ -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) for dir in $proto_dirs; do - protoc \ - -I "proto" \ - -I "third_party/proto" \ - --gocosmos_out=plugins=interfacetype+grpc,\ -Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ - $(find "${dir}" -maxdepth 1 -name '*.proto') - - # command to generate gRPC gateway (*.pb.gw.go in respective modules) files - protoc \ - -I "proto" \ - -I "third_party/proto" \ - --grpc-gateway_out=logtostderr=true:. \ - $(find "${dir}" -maxdepth 1 -name '*.proto') - + # shellcheck disable=SC2044 + for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do + if grep "option go_package" $file &> /dev/null ; then + buf generate --template buf.gen.gogo.yaml $file + fi + done done +cd .. + # move proto files to the right places cp -r github.com/irisnet/irismod/* ./ -rm -rf github.com +rm -rf github.com \ No newline at end of file diff --git a/simapp/app.go b/simapp/app.go index 030ef35f..c63d0c3e 100644 --- a/simapp/app.go +++ b/simapp/app.go @@ -19,7 +19,6 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/grpc/tmservice" - "github.com/cosmos/cosmos-sdk/client/rpc" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/server/api" @@ -27,13 +26,13 @@ import ( servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/version" "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" - authrest "github.com/cosmos/cosmos-sdk/x/auth/client/rest" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" @@ -62,8 +61,11 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/gov" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" govkeeper "github.com/cosmos/cosmos-sdk/x/gov/keeper" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" + govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/mint" mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" @@ -92,8 +94,11 @@ import ( "github.com/irisnet/irismod/modules/htlc" htlckeeper "github.com/irisnet/irismod/modules/htlc/keeper" htlctypes "github.com/irisnet/irismod/modules/htlc/types" - "github.com/irisnet/irismod/modules/nft" + "github.com/irisnet/irismod/modules/mt" + mtkeeper "github.com/irisnet/irismod/modules/mt/keeper" + mttypes "github.com/irisnet/irismod/modules/mt/types" nftkeeper "github.com/irisnet/irismod/modules/nft/keeper" + nft "github.com/irisnet/irismod/modules/nft/module" nfttypes "github.com/irisnet/irismod/modules/nft/types" "github.com/irisnet/irismod/modules/oracle" oracleKeeper "github.com/irisnet/irismod/modules/oracle/keeper" @@ -133,10 +138,12 @@ var ( mint.AppModuleBasic{}, distr.AppModuleBasic{}, gov.NewAppModuleBasic( - paramsclient.ProposalHandler, - distrclient.ProposalHandler, - upgradeclient.ProposalHandler, - upgradeclient.CancelProposalHandler, + []govclient.ProposalHandler{ + paramsclient.ProposalHandler, + distrclient.ProposalHandler, + upgradeclient.LegacyProposalHandler, + upgradeclient.LegacyCancelProposalHandler, + }, ), params.AppModuleBasic{}, crisis.AppModuleBasic{}, @@ -149,6 +156,7 @@ var ( token.AppModuleBasic{}, record.AppModuleBasic{}, nft.AppModuleBasic{}, + mt.AppModuleBasic{}, htlc.AppModuleBasic{}, coinswap.AppModuleBasic{}, service.AppModuleBasic{}, @@ -174,6 +182,8 @@ var ( farmtypes.ModuleName: {authtypes.Burner}, farmtypes.RewardCollector: nil, farmtypes.EscrowCollector: nil, + nfttypes.ModuleName: nil, + mttypes.ModuleName: nil, } ) @@ -194,9 +204,9 @@ type SimApp struct { invCheckPeriod uint // keys to access the substores - keys map[string]*sdk.KVStoreKey - tkeys map[string]*sdk.TransientStoreKey - memKeys map[string]*sdk.MemoryStoreKey + keys map[string]*storetypes.KVStoreKey + tkeys map[string]*storetypes.TransientStoreKey + memKeys map[string]*storetypes.MemoryStoreKey // keepers AccountKeeper authkeeper.AccountKeeper @@ -214,13 +224,10 @@ type SimApp struct { FeeGrantKeeper feegrantkeeper.Keeper // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedIBCMockKeeper capabilitykeeper.ScopedKeeper - TokenKeeper tokenkeeper.Keeper RecordKeeper recordkeeper.Keeper NFTKeeper nftkeeper.Keeper + MTKeeper mtkeeper.Keeper HTLCKeeper htlckeeper.Keeper CoinswapKeeper coinswapkeeper.Keeper ServiceKeeper servicekeeper.Keeper @@ -255,7 +262,7 @@ func NewSimApp( ) *SimApp { // TODO: Remove cdc in favor of appCodec once all modules are migrated. - appCodec := encodingConfig.Marshaler + appCodec := encodingConfig.Codec legacyAmino := encodingConfig.Amino interfaceRegistry := encodingConfig.InterfaceRegistry @@ -270,7 +277,7 @@ func NewSimApp( govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey, feegrant.StoreKey, evidencetypes.StoreKey, capabilitytypes.StoreKey, tokentypes.StoreKey, - nfttypes.StoreKey, htlctypes.StoreKey, recordtypes.StoreKey, + nfttypes.StoreKey, mttypes.StoreKey, htlctypes.StoreKey, recordtypes.StoreKey, coinswaptypes.StoreKey, servicetypes.StoreKey, oracletypes.StoreKey, randomtypes.StoreKey, farmtypes.StoreKey, ) @@ -291,14 +298,14 @@ func NewSimApp( app.ParamsKeeper = initParamsKeeper(appCodec, legacyAmino, keys[paramstypes.StoreKey], tkeys[paramstypes.TStoreKey]) // set the BaseApp's parameter store - bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramskeeper.ConsensusParamsKeyTable())) + bApp.SetParamStore(app.ParamsKeeper.Subspace(baseapp.Paramspace).WithKeyTable(paramstypes.ConsensusParamsKeyTable())) // add capability keeper and ScopeToModule for ibc module app.CapabilityKeeper = capabilitykeeper.NewKeeper(appCodec, keys[capabilitytypes.StoreKey], memKeys[capabilitytypes.MemStoreKey]) // add keepers app.AccountKeeper = authkeeper.NewAccountKeeper( - appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, + appCodec, keys[authtypes.StoreKey], app.GetSubspace(authtypes.ModuleName), authtypes.ProtoBaseAccount, maccPerms, sdk.Bech32MainPrefix, ) app.BankKeeper = bankkeeper.NewBaseKeeper( appCodec, keys[banktypes.StoreKey], app.AccountKeeper, app.GetSubspace(banktypes.ModuleName), app.ModuleAccountAddrs(), @@ -312,7 +319,7 @@ func NewSimApp( ) app.DistrKeeper = distrkeeper.NewKeeper( appCodec, keys[distrtypes.StoreKey], app.GetSubspace(distrtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(), + &stakingKeeper, authtypes.FeeCollectorName, ) app.SlashingKeeper = slashingkeeper.NewKeeper( appCodec, keys[slashingtypes.StoreKey], &stakingKeeper, app.GetSubspace(slashingtypes.ModuleName), @@ -321,7 +328,8 @@ func NewSimApp( app.GetSubspace(crisistypes.ModuleName), invCheckPeriod, app.BankKeeper, authtypes.FeeCollectorName, ) app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper) - app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp) + // set the governance module account as the authority for conducting upgrades + app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String()) // register the staking hooks // NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks @@ -346,7 +354,17 @@ func NewSimApp( ) app.RecordKeeper = recordkeeper.NewKeeper(appCodec, keys[recordtypes.StoreKey]) - app.NFTKeeper = nftkeeper.NewKeeper(appCodec, keys[nfttypes.StoreKey]) + app.NFTKeeper = nftkeeper.NewKeeper( + appCodec, + keys[nfttypes.StoreKey], + app.AccountKeeper, + app.BankKeeper, + ) + + app.MTKeeper = mtkeeper.NewKeeper( + appCodec, + keys[mttypes.StoreKey], + ) app.HTLCKeeper = htlckeeper.NewKeeper( appCodec, @@ -395,17 +413,18 @@ func NewSimApp( ) // register the proposal types - govRouter := govtypes.NewRouter() - govRouter.AddRoute(govtypes.RouterKey, govtypes.ProposalHandler). + govRouter := govv1beta1.NewRouter() + govRouter.AddRoute(govtypes.RouterKey, govv1beta1.ProposalHandler). AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)). AddRoute(distrtypes.RouterKey, distr.NewCommunityPoolSpendProposalHandler(app.DistrKeeper)). AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(farmtypes.RouterKey, farm.NewCommunityPoolCreateFarmProposalHandler(app.FarmKeeper)) + govConfig := govtypes.DefaultConfig() govHooks := govtypes.NewMultiGovHooks(farmkeeper.NewGovHook(app.FarmKeeper)) app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, - &stakingKeeper, govRouter, + &stakingKeeper, govRouter, app.MsgServiceRouter(), govConfig, ) app.GovKeeper.SetHooks(govHooks) @@ -431,7 +450,7 @@ func NewSimApp( crisis.NewAppModule(&app.CrisisKeeper, skipGenesisInvariants), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), @@ -441,6 +460,7 @@ func NewSimApp( token.NewAppModule(appCodec, app.TokenKeeper, app.AccountKeeper, app.BankKeeper), record.NewAppModule(appCodec, app.RecordKeeper, app.AccountKeeper, app.BankKeeper), nft.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper), + mt.NewAppModule(appCodec, app.MTKeeper, app.AccountKeeper, app.BankKeeper), htlc.NewAppModule(appCodec, app.HTLCKeeper, app.AccountKeeper, app.BankKeeper), coinswap.NewAppModule(appCodec, app.CoinswapKeeper, app.AccountKeeper, app.BankKeeper), service.NewAppModule(appCodec, app.ServiceKeeper, app.AccountKeeper, app.BankKeeper), @@ -460,7 +480,8 @@ func NewSimApp( genutiltypes.ModuleName, evidencetypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, tokentypes.ModuleName, - nfttypes.ModuleName, htlctypes.ModuleName, recordtypes.ModuleName, + nfttypes.ModuleName, mttypes.ModuleName, + htlctypes.ModuleName, recordtypes.ModuleName, coinswaptypes.ModuleName, servicetypes.ModuleName, oracletypes.ModuleName, randomtypes.ModuleName, farmtypes.ModuleName, feegrant.ModuleName, ) @@ -471,7 +492,8 @@ func NewSimApp( genutiltypes.ModuleName, evidencetypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, tokentypes.ModuleName, - nfttypes.ModuleName, htlctypes.ModuleName, recordtypes.ModuleName, + nfttypes.ModuleName, mttypes.ModuleName, + htlctypes.ModuleName, recordtypes.ModuleName, coinswaptypes.ModuleName, servicetypes.ModuleName, oracletypes.ModuleName, randomtypes.ModuleName, farmtypes.ModuleName, feegrant.ModuleName, ) @@ -484,13 +506,14 @@ func NewSimApp( app.mm.SetOrderInitGenesis( capabilitytypes.ModuleName, authtypes.ModuleName, banktypes.ModuleName, distrtypes.ModuleName, stakingtypes.ModuleName, slashingtypes.ModuleName, - govtypes.ModuleName, minttypes.ModuleName, crisistypes.ModuleName, + govtypes.ModuleName, minttypes.ModuleName, genutiltypes.ModuleName, evidencetypes.ModuleName, feegrant.ModuleName, paramstypes.ModuleName, upgradetypes.ModuleName, vestingtypes.ModuleName, tokentypes.ModuleName, - nfttypes.ModuleName, htlctypes.ModuleName, recordtypes.ModuleName, + nfttypes.ModuleName, mttypes.ModuleName, + htlctypes.ModuleName, recordtypes.ModuleName, coinswaptypes.ModuleName, servicetypes.ModuleName, oracletypes.ModuleName, - randomtypes.ModuleName, farmtypes.ModuleName, feegrant.ModuleName, + randomtypes.ModuleName, farmtypes.ModuleName, feegrant.ModuleName, crisistypes.ModuleName, ) app.mm.RegisterInvariants(&app.CrisisKeeper) @@ -509,19 +532,20 @@ func NewSimApp( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts), bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper), feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry), - mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper), + mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, nil), staking.NewAppModule(appCodec, app.StakingKeeper, app.AccountKeeper, app.BankKeeper), distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), slashing.NewAppModule(appCodec, app.SlashingKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper), token.NewAppModule(appCodec, app.TokenKeeper, app.AccountKeeper, app.BankKeeper), record.NewAppModule(appCodec, app.RecordKeeper, app.AccountKeeper, app.BankKeeper), nft.NewAppModule(appCodec, app.NFTKeeper, app.AccountKeeper, app.BankKeeper), - htlc.NewAppModule(appCodec, app.HTLCKeeper, app.AccountKeeper, app.BankKeeper), + mt.NewAppModule(appCodec, app.MTKeeper, app.AccountKeeper, app.BankKeeper), + //htlc.NewAppModule(appCodec, app.HTLCKeeper, app.AccountKeeper, app.BankKeeper), //coinswap.NewAppModule(appCodec, app.CoinswapKeeper, app.AccountKeeper, app.BankKeeper), - service.NewAppModule(appCodec, app.ServiceKeeper, app.AccountKeeper, app.BankKeeper), - oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), - random.NewAppModule(appCodec, app.RandomKeeper, app.AccountKeeper, app.BankKeeper), - farm.NewAppModule(appCodec, app.FarmKeeper, app.AccountKeeper, app.BankKeeper), + //service.NewAppModule(appCodec, app.ServiceKeeper, app.AccountKeeper, app.BankKeeper), + //oracle.NewAppModule(appCodec, app.OracleKeeper, app.AccountKeeper, app.BankKeeper), + //random.NewAppModule(appCodec, app.RandomKeeper, app.AccountKeeper, app.BankKeeper), + //farm.NewAppModule(appCodec, app.FarmKeeper, app.AccountKeeper, app.BankKeeper), ) app.sm.RegisterStoreDecoders() @@ -554,6 +578,7 @@ func NewSimApp( tmos.Exit(err.Error()) } } + return app } @@ -628,21 +653,21 @@ func (app *SimApp) InterfaceRegistry() types.InterfaceRegistry { // GetKey returns the KVStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *SimApp) GetKey(storeKey string) *sdk.KVStoreKey { +func (app *SimApp) GetKey(storeKey string) *storetypes.KVStoreKey { return app.keys[storeKey] } // GetTKey returns the TransientStoreKey for the provided store key. // // NOTE: This is solely to be used for testing purposes. -func (app *SimApp) GetTKey(storeKey string) *sdk.TransientStoreKey { +func (app *SimApp) GetTKey(storeKey string) *storetypes.TransientStoreKey { return app.tkeys[storeKey] } // GetMemKey returns the MemStoreKey for the provided mem key. // // NOTE: This is solely used for testing purposes. -func (app *SimApp) GetMemKey(storeKey string) *sdk.MemoryStoreKey { +func (app *SimApp) GetMemKey(storeKey string) *storetypes.MemoryStoreKey { return app.memKeys[storeKey] } @@ -663,16 +688,12 @@ func (app *SimApp) SimulationManager() *module.SimulationManager { // API server. func (app *SimApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) { clientCtx := apiSvr.ClientCtx - rpc.RegisterRoutes(clientCtx, apiSvr.Router) - // Register legacy tx routes. - authrest.RegisterTxRoutes(clientCtx, apiSvr.Router) // Register new tx routes from grpc-gateway. authtx.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // Register new tendermint queries routes from grpc-gateway. tmservice.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) - // Register legacy and grpc-gateway routes for all modules. - ModuleBasics.RegisterRESTRoutes(clientCtx, apiSvr.Router) + // Register grpc-gateway routes for all modules. ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily @@ -688,7 +709,12 @@ func (app *SimApp) RegisterTxService(clientCtx client.Context) { // RegisterTendermintService implements the Application.RegisterTendermintService method. func (app *SimApp) RegisterTendermintService(clientCtx client.Context) { - tmservice.RegisterTendermintService(app.BaseApp.GRPCQueryRouter(), clientCtx, app.interfaceRegistry) + tmservice.RegisterTendermintService( + clientCtx, + app.BaseApp.GRPCQueryRouter(), + app.interfaceRegistry, + app.Query, + ) } // RegisterSwaggerAPI registers swagger route with API Server @@ -712,7 +738,7 @@ func GetMaccPerms() map[string][]string { } // initParamsKeeper init params keeper and its subspaces -func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey sdk.StoreKey) paramskeeper.Keeper { +func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key, tkey storetypes.StoreKey) paramskeeper.Keeper { paramsKeeper := paramskeeper.NewKeeper(appCodec, legacyAmino, key, tkey) paramsKeeper.Subspace(authtypes.ModuleName) @@ -721,7 +747,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(minttypes.ModuleName) paramsKeeper.Subspace(distrtypes.ModuleName) paramsKeeper.Subspace(slashingtypes.ModuleName) - paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govtypes.ParamKeyTable()) + paramsKeeper.Subspace(govtypes.ModuleName).WithKeyTable(govv1.ParamKeyTable()) paramsKeeper.Subspace(crisistypes.ModuleName) paramsKeeper.Subspace(tokentypes.ModuleName) paramsKeeper.Subspace(recordtypes.ModuleName) diff --git a/simapp/export.go b/simapp/export.go index 8d09e333..bcbe0c69 100644 --- a/simapp/export.go +++ b/simapp/export.go @@ -2,8 +2,13 @@ package simapp import ( "encoding/json" + "fmt" "log" + "github.com/irisnet/irismod/modules/htlc" + "github.com/irisnet/irismod/modules/oracle" + "github.com/irisnet/irismod/modules/random" + "github.com/irisnet/irismod/modules/service" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" @@ -84,10 +89,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] panic(err) } - delAddr, err := sdk.AccAddressFromBech32(delegation.DelegatorAddress) - if err != nil { - panic(err) - } + delAddr := sdk.MustAccAddressFromBech32(delegation.DelegatorAddress) + _, _ = app.DistrKeeper.WithdrawDelegationRewards(ctx, delAddr, valAddr) } @@ -109,7 +112,9 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] feePool.CommunityPool = feePool.CommunityPool.Add(scraps...) app.DistrKeeper.SetFeePool(ctx, feePool) - app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()) + if err := app.DistrKeeper.Hooks().AfterValidatorCreated(ctx, val.GetOperator()); err != nil { + panic(err) + } return false }) @@ -119,12 +124,17 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] if err != nil { panic(err) } - delAddr, err := sdk.AccAddressFromBech32(del.DelegatorAddress) - if err != nil { - panic(err) + delAddr := sdk.MustAccAddressFromBech32(del.DelegatorAddress) + + if err := app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr); err != nil { + // never called as BeforeDelegationCreated always returns nil + panic(fmt.Errorf("error while incrementing period: %w", err)) + } + + if err := app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr); err != nil { + // never called as AfterDelegationModified always returns nil + panic(fmt.Errorf("error while creating a new delegation period record: %w", err)) } - app.DistrKeeper.Hooks().BeforeDelegationCreated(ctx, delAddr, valAddr) - app.DistrKeeper.Hooks().AfterDelegationModified(ctx, delAddr, valAddr) } // reset context height @@ -152,7 +162,7 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] // Iterate through validators by power descending, reset bond heights, and // update bond intra-tx counters. - store := ctx.KVStore(app.keys[stakingtypes.StoreKey]) + store := ctx.KVStore(app.GetKey(stakingtypes.StoreKey)) iter := sdk.KVStoreReversePrefixIterator(store, stakingtypes.ValidatorsKey) counter := int16(0) @@ -190,4 +200,8 @@ func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs [] return false }, ) + htlc.PrepForZeroHeightGenesis(ctx, app.HTLCKeeper) + random.PrepForZeroHeightGenesis(ctx, app.RandomKeeper) + oracle.PrepForZeroHeightGenesis(ctx, app.OracleKeeper) + service.PrepForZeroHeightGenesis(ctx, app.ServiceKeeper) } diff --git a/simapp/sim_bench_test.go b/simapp/sim_bench_test.go new file mode 100644 index 00000000..7838e26d --- /dev/null +++ b/simapp/sim_bench_test.go @@ -0,0 +1,126 @@ +package simapp + +import ( + "fmt" + "os" + "testing" + + "github.com/stretchr/testify/require" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + + sdksimapp "github.com/cosmos/cosmos-sdk/simapp" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Profile with: +// /usr/local/go/bin/go test -benchmem -run=^$ cosmossdk.io/simapp -bench ^BenchmarkFullAppSimulation$ -Commit=true -cpuprofile cpu.out +func BenchmarkFullAppSimulation(b *testing.B) { + b.ReportAllocs() + config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("goleveldb-app-sim", "Simulation") + if err != nil { + b.Fatalf("simulation setup failed: %s", err.Error()) + } + + if skip { + b.Skip("skipping benchmark application simulation") + } + + defer func() { + require.NoError(b, db.Close()) + require.NoError(b, os.RemoveAll(dir)) + }() + + app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, sdksimapp.FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt()) + + // run randomized simulation + _, simParams, simErr := simulation.SimulateFromSeed( + b, + os.Stdout, + app.BaseApp, + AppStateFn(app.AppCodec(), app.SimulationManager()), + simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 + sdksimapp.SimulationOperations(app, app.AppCodec(), config), + app.ModuleAccountAddrs(), + config, + app.AppCodec(), + ) + + // export state and simParams before the simulation error is checked + if err = sdksimapp.CheckExportSimulation(app, config, simParams); err != nil { + b.Fatal(err) + } + + if simErr != nil { + b.Fatal(simErr) + } + + if config.Commit { + sdksimapp.PrintStats(db) + } +} + +func BenchmarkInvariants(b *testing.B) { + b.ReportAllocs() + config, db, dir, logger, skip, err := sdksimapp.SetupSimulation("leveldb-app-invariant-bench", "Simulation") + if err != nil { + b.Fatalf("simulation setup failed: %s", err.Error()) + } + + if skip { + b.Skip("skipping benchmark application simulation") + } + + config.AllInvariants = false + + defer func() { + require.NoError(b, db.Close()) + require.NoError(b, os.RemoveAll(dir)) + }() + + app := NewSimApp(logger, db, nil, true, map[int64]bool{}, DefaultNodeHome, sdksimapp.FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, interBlockCacheOpt()) + + // run randomized simulation + _, simParams, simErr := simulation.SimulateFromSeed( + b, + os.Stdout, + app.BaseApp, + AppStateFn(app.AppCodec(), app.SimulationManager()), + simtypes.RandomAccounts, // Replace with own random account function if using keys other than secp256k1 + sdksimapp.SimulationOperations(app, app.AppCodec(), config), + app.ModuleAccountAddrs(), + config, + app.AppCodec(), + ) + + // export state and simParams before the simulation error is checked + if err = sdksimapp.CheckExportSimulation(app, config, simParams); err != nil { + b.Fatal(err) + } + + if simErr != nil { + b.Fatal(simErr) + } + + if config.Commit { + sdksimapp.PrintStats(db) + } + + ctx := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight() + 1}) + + // 3. Benchmark each invariant separately + // + // NOTE: We use the crisis keeper as it has all the invariants registered with + // their respective metadata which makes it useful for testing/benchmarking. + for _, cr := range app.CrisisKeeper.Routes() { + cr := cr + b.Run(fmt.Sprintf("%s/%s", cr.ModuleName, cr.Route), func(b *testing.B) { + if res, stop := cr.Invar(ctx); stop { + b.Fatalf( + "broken invariant at block %d of %d\n%s", + ctx.BlockHeight()-1, config.NumBlocks, res, + ) + } + }) + } +} diff --git a/simapp/sim_test.go b/simapp/sim_test.go index 2fbccc18..4073bd14 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -6,6 +6,8 @@ import ( "fmt" "math/rand" "os" + "runtime/debug" + "strings" "testing" "github.com/stretchr/testify/require" @@ -17,10 +19,10 @@ import ( "github.com/cosmos/cosmos-sdk/baseapp" sdksimapp "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types" distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types" @@ -34,10 +36,10 @@ import ( coinswaptypes "github.com/irisnet/irismod/modules/coinswap/types" htlctypes "github.com/irisnet/irismod/modules/htlc/types" + mttypes "github.com/irisnet/irismod/modules/mt/types" nfttypes "github.com/irisnet/irismod/modules/nft/types" oracletypes "github.com/irisnet/irismod/modules/oracle/types" randomtypes "github.com/irisnet/irismod/modules/random/types" - recordtypes "github.com/irisnet/irismod/modules/record/types" servicetypes "github.com/irisnet/irismod/modules/service/types" tokentypes "github.com/irisnet/irismod/modules/token/types" "github.com/irisnet/irismod/simapp/helpers" @@ -49,8 +51,8 @@ func init() { } type StoreKeysPrefixes struct { - A sdk.StoreKey - B sdk.StoreKey + A storetypes.StoreKey + B storetypes.StoreKey Prefixes [][]byte } @@ -112,7 +114,7 @@ func TestAppImportExport(t *testing.T) { require.NoError(t, err, "simulation setup failed") defer func() { - db.Close() + require.NoError(t, db.Close()) require.NoError(t, os.RemoveAll(dir)) }() @@ -163,6 +165,17 @@ func TestAppImportExport(t *testing.T) { err = json.Unmarshal(exported.AppState, &genesisState) require.NoError(t, err) + defer func() { + if r := recover(); r != nil { + err := fmt.Sprintf("%v", r) + if !strings.Contains(err, "validator set is empty after InitGenesis") { + panic(r) + } + logger.Info("Skipping simulation as all validators have been unbonded") + logger.Info("err", err, "stacktrace", string(debug.Stack())) + } + }() + ctxA := app.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) ctxB := newApp.NewContext(true, tmproto.Header{Height: app.LastBlockHeight()}) newApp.mm.InitGenesis(ctxB, app.AppCodec(), genesisState) @@ -185,17 +198,18 @@ func TestAppImportExport(t *testing.T) { {app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}}, {app.keys[evidencetypes.StoreKey], newApp.keys[evidencetypes.StoreKey], [][]byte{}}, {app.keys[capabilitytypes.StoreKey], newApp.keys[capabilitytypes.StoreKey], [][]byte{}}, - {app.keys[authzkeeper.StoreKey], newApp.keys[authzkeeper.StoreKey], [][]byte{}}, // check irismod module {app.keys[tokentypes.StoreKey], newApp.keys[tokentypes.StoreKey], [][]byte{}}, - {app.keys[recordtypes.StoreKey], newApp.keys[recordtypes.StoreKey], [][]byte{recordtypes.IntraTxCounterKey}}, - {app.keys[nfttypes.StoreKey], newApp.keys[nfttypes.StoreKey], [][]byte{}}, - {app.keys[htlctypes.StoreKey], newApp.keys[htlctypes.StoreKey], [][]byte{}}, - {app.keys[coinswaptypes.StoreKey], newApp.keys[coinswaptypes.StoreKey], [][]byte{}}, - {app.keys[servicetypes.StoreKey], newApp.keys[servicetypes.StoreKey], [][]byte{}}, {app.keys[oracletypes.StoreKey], newApp.keys[oracletypes.StoreKey], [][]byte{}}, + //mt.Supply is InitSupply, can be not equal to TotalSupply + {app.keys[mttypes.StoreKey], newApp.keys[mttypes.StoreKey], [][]byte{mttypes.PrefixMT}}, + {app.keys[nfttypes.StoreKey], newApp.keys[nfttypes.StoreKey], [][]byte{{0x05}}}, + {app.keys[servicetypes.StoreKey], newApp.keys[servicetypes.StoreKey], [][]byte{servicetypes.InternalCounterKey}}, {app.keys[randomtypes.StoreKey], newApp.keys[randomtypes.StoreKey], [][]byte{randomtypes.RandomKey}}, + //{app.keys[recordtypes.StoreKey], newApp.keys[recordtypes.StoreKey], [][]byte{recordtypes.IntraTxCounterKey}}, + {app.keys[htlctypes.StoreKey], newApp.keys[htlctypes.StoreKey], [][]byte{}}, + {app.keys[coinswaptypes.StoreKey], newApp.keys[coinswaptypes.StoreKey], [][]byte{}}, } for _, skp := range storeKeysPrefixes { @@ -206,7 +220,10 @@ func TestAppImportExport(t *testing.T) { require.Equal(t, len(failedKVAs), len(failedKVBs), "unequal sets of key-values to compare") fmt.Printf("compared %d different key/value pairs between %s and %s\n", len(failedKVAs), skp.A, skp.B) - require.Equal(t, len(failedKVAs), 0, sdksimapp.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) + for _, kv := range failedKVAs { + fmt.Printf("storeKey: %s,\n failedKVBs: %v,\n ", skp.A.Name(), kv.Key) + } + require.Equal(t, 0, len(failedKVAs), sdksimapp.GetSimulationLog(skp.A.Name(), app.SimulationManager().StoreDecoders, failedKVAs, failedKVBs)) } } @@ -270,6 +287,7 @@ func TestAppSimulationAfterImport(t *testing.T) { newApp := NewSimApp(log.NewNopLogger(), newDB, nil, true, map[int64]bool{}, DefaultNodeHome, sdksimapp.FlagPeriodValue, MakeTestEncodingConfig(), EmptyAppOptions{}, fauxMerkleModeOpt) require.Equal(t, "SimApp", newApp.Name()) + fmt.Println("exported AppState:\n", string(exported.AppState)) newApp.InitChain(abci.RequestInitChain{ AppStateBytes: exported.AppState, }) diff --git a/simapp/state.go b/simapp/state.go index f566c764..10a3ce02 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -11,6 +11,7 @@ import ( tmjson "github.com/tendermint/tendermint/libs/json" tmtypes "github.com/tendermint/tendermint/types" + sdkmath "cosmossdk.io/math" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdksimapp "github.com/cosmos/cosmos-sdk/simapp" @@ -151,10 +152,13 @@ func AppStateRandomizedFn( // generate a random amount of initial stake coins and a random initial // number of bonded accounts - var initialStake, numInitiallyBonded int64 + var ( + numInitiallyBonded int64 + initialStake sdkmath.Int + ) appParams.GetOrGenerate( cdc, simappparams.StakePerAccount, &initialStake, r, - func(r *rand.Rand) { initialStake = r.Int63n(1e12) }, + func(r *rand.Rand) { initialStake = sdkmath.NewInt(r.Int63n(1e12)) }, ) appParams.GetOrGenerate( cdc, simappparams.InitiallyBondedValidators, &numInitiallyBonded, r, diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 62bf2f6a..ee0cfb9f 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -5,31 +5,31 @@ import ( "encoding/hex" "encoding/json" "fmt" + "math/rand" "strconv" "testing" "time" - "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" - abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" dbm "github.com/tendermint/tm-db" - "github.com/tendermint/tmlibs/cli" bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" servertypes "github.com/cosmos/cosmos-sdk/server/types" "github.com/cosmos/cosmos-sdk/simapp/helpers" - storetypes "github.com/cosmos/cosmos-sdk/store/types" "github.com/cosmos/cosmos-sdk/testutil" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/cosmos/cosmos-sdk/testutil/mock" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/errors" @@ -40,8 +40,6 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" minttypes "github.com/cosmos/cosmos-sdk/x/mint/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" - - htlctypes "github.com/irisnet/irismod/modules/htlc/types" ) // DefaultConsensusParams defines the default Tendermint consensus params used in @@ -68,60 +66,59 @@ func setup(withGenesis bool, invCheckPeriod uint) (*SimApp, GenesisState) { encCdc := MakeTestEncodingConfig() app := NewSimApp(log.NewNopLogger(), db, nil, true, map[int64]bool{}, DefaultNodeHome, invCheckPeriod, encCdc, EmptyAppOptions{}) if withGenesis { - return app, NewDefaultGenesisState(encCdc.Marshaler) + return app, NewDefaultGenesisState(encCdc.Codec) } return app, GenesisState{} } // Setup initializes a new SimApp. A Nop logger is set in SimApp. -func Setup(isCheckTx bool) *SimApp { - app, genesisState := setup(!isCheckTx, 5) - if !isCheckTx { - // init chain must be called to stop deliverState from being nil - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - panic(err) - } - - // Initialize the chain - app.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) - } +func Setup(t *testing.T, isCheckTx bool) *SimApp { + t.Helper() - return app -} + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + require.NoError(t, err) -func SetupWithGenesisHTLC(htlcGenesis *htlctypes.GenesisState) *SimApp { - app, genesisState := setup(true, 5) - genesisState[htlctypes.ModuleName] = app.AppCodec().MustMarshalJSON(htlcGenesis) + // create validator set with single validator + validator := tmtypes.NewValidator(pubKey, 1) + valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) - // init chain must be called to stop deliverState from being nil - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - panic(err) + // generate genesis account + senderPrivKey := secp256k1.GenPrivKey() + acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), } - // Initialize the chain - app.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) + app := SetupWithGenesisValSet(t, valSet, []authtypes.GenesisAccount{acc}, balance) return app } -func SetupWithModuleGenesis(module string, o proto.Message) *SimApp { +func SetupWithGenesisStateFn(t *testing.T, merge func(cdc codec.Codec, state GenesisState) GenesisState) *SimApp { app, genesisState := setup(true, 5) - genesisState[module] = app.AppCodec().MustMarshalJSON(o) + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + require.NoError(t, err) + + // create validator set with single validator + validator := tmtypes.NewValidator(pubKey, 1) + valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) + + // generate genesis account + senderPrivKey := secp256k1.GenPrivKey() + acc := authtypes.NewBaseAccount(senderPrivKey.PubKey().Address().Bytes(), senderPrivKey.PubKey(), 0, 0) + balance := banktypes.Balance{ + Address: acc.GetAddress().String(), + Coins: sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000000000000))), + } + genesisState = genesisStateWithValSet(t, app, genesisState, valSet, []authtypes.GenesisAccount{acc}, balance) + + if merge != nil { + genesisState = merge(app.appCodec, genesisState) + } // init chain must be called to stop deliverState from being nil stateBytes, err := json.MarshalIndent(genesisState, "", " ") if err != nil { @@ -136,14 +133,21 @@ func SetupWithModuleGenesis(module string, o proto.Message) *SimApp { AppStateBytes: stateBytes, }, ) - + // commit genesis changes + app.Commit() + app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{ + Height: app.LastBlockHeight() + 1, + AppHash: app.LastCommitID().Hash, + ValidatorsHash: valSet.Hash(), + NextValidatorsHash: valSet.Hash(), + }}) return app } func NewConfig() network.Config { cfg := network.DefaultConfig() - encCfg := MakeTestEncodingConfig() - cfg.Codec = encCfg.Marshaler + encCfg := MakeTestEncodingConfig() // redundant + cfg.Codec = encCfg.Codec cfg.TxConfig = encCfg.TxConfig cfg.LegacyAmino = encCfg.Amino cfg.InterfaceRegistry = encCfg.InterfaceRegistry @@ -156,17 +160,15 @@ func SimAppConstructor(val network.Validator) servertypes.Application { return NewSimApp( val.Ctx.Logger, dbm.NewMemDB(), nil, true, make(map[int64]bool), val.Ctx.Config.RootDir, 0, MakeTestEncodingConfig(), EmptyAppOptions{}, - bam.SetPruning(storetypes.NewPruningOptionsFromString(val.AppConfig.Pruning)), bam.SetMinGasPrices(val.AppConfig.MinGasPrices), ) } -// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts -// that also act as delegators. For simplicity, each validator is bonded with a delegation -// of one consensus engine unit (10^6) in the default token of the simapp from first genesis -// account. A Nop logger is set in SimApp. -func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp { - app, genesisState := setup(true, 5) +func genesisStateWithValSet(t *testing.T, + app *SimApp, genesisState GenesisState, + valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, + balances ...banktypes.Balance, +) GenesisState { // set genesis accounts authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) @@ -174,7 +176,7 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs validators := make([]stakingtypes.Validator, 0, len(valSet.Validators)) delegations := make([]stakingtypes.Delegation, 0, len(valSet.Validators)) - bondAmt := sdk.NewInt(1000000) + bondAmt := sdk.DefaultPowerReduction for _, val := range valSet.Validators { pk, err := cryptocodec.FromTmPubKeyInterface(val.PubKey) @@ -204,8 +206,13 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs totalSupply := sdk.NewCoins() for _, b := range balances { - // add genesis acc tokens and delegated tokens to total supply - totalSupply = totalSupply.Add(b.Coins.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt))...) + // add genesis acc tokens to total supply + totalSupply = totalSupply.Add(b.Coins...) + } + + for range delegations { + // add delegated tokens to total supply + totalSupply = totalSupply.Add(sdk.NewCoin(sdk.DefaultBondDenom, bondAmt)) } // add bonded amount to bonded pool module account @@ -218,6 +225,19 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}) genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) + return genesisState +} + +// SetupWithGenesisValSet initializes a new SimApp with a validator set and genesis accounts +// that also act as delegators. For simplicity, each validator is bonded with a delegation +// of one consensus engine unit (10^6) in the default token of the simapp from first genesis +// account. A Nop logger is set in SimApp. +func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp { + t.Helper() + + app, genesisState := setup(true, 5) + genesisState = genesisStateWithValSet(t, app, genesisState, valSet, genAccs, balances...) + stateBytes, err := json.MarshalIndent(genesisState, "", " ") require.NoError(t, err) @@ -244,36 +264,18 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs // SetupWithGenesisAccounts initializes a new SimApp with the provided genesis // accounts and possible balances. -func SetupWithGenesisAccounts(genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp { - app, genesisState := setup(true, 0) - authGenesis := authtypes.NewGenesisState(authtypes.DefaultParams(), genAccs) - genesisState[authtypes.ModuleName] = app.AppCodec().MustMarshalJSON(authGenesis) - - totalSupply := sdk.NewCoins() - for _, b := range balances { - totalSupply = totalSupply.Add(b.Coins...) - } - - bankGenesis := banktypes.NewGenesisState(banktypes.DefaultGenesisState().Params, balances, totalSupply, []banktypes.Metadata{}) - genesisState[banktypes.ModuleName] = app.AppCodec().MustMarshalJSON(bankGenesis) - - stateBytes, err := json.MarshalIndent(genesisState, "", " ") - if err != nil { - panic(err) - } +func SetupWithGenesisAccounts(t *testing.T, genAccs []authtypes.GenesisAccount, balances ...banktypes.Balance) *SimApp { + t.Helper() - app.InitChain( - abci.RequestInitChain{ - Validators: []abci.ValidatorUpdate{}, - ConsensusParams: DefaultConsensusParams, - AppStateBytes: stateBytes, - }, - ) + privVal := mock.NewPV() + pubKey, err := privVal.GetPubKey() + require.NoError(t, err) - app.Commit() - app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: app.LastBlockHeight() + 1}}) + // create validator set with single validator + validator := tmtypes.NewValidator(pubKey, 1) + valSet := tmtypes.NewValidatorSet([]*tmtypes.Validator{validator}) - return app + return SetupWithGenesisValSet(t, valSet, genAccs, balances...) } type GenerateAccountStrategy func(int) []sdk.AccAddress @@ -289,6 +291,48 @@ func createRandomAccounts(accNum int) []sdk.AccAddress { return testAddrs } +// CreateTestAddrs creates test addresses +func CreateTestAddrs(numAddrs int) []sdk.AccAddress { + var addresses []sdk.AccAddress + var buffer bytes.Buffer + + // start at 100 so we can make up to 999 test addresses with valid test addresses + for i := 100; i < (numAddrs + 100); i++ { + numString := strconv.Itoa(i) + buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") //base address string + + buffer.WriteString(numString) //adding on final two digits to make addresses unique + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) + bech := res.String() + addresses = append(addresses, testAddr(buffer.String(), bech)) + buffer.Reset() + } + + return addresses +} + +// for incode address generation +func testAddr(addr string, bech string) sdk.AccAddress { + res, err := sdk.AccAddressFromHexUnsafe(addr) + if err != nil { + panic(err) + } + bechexpected := res.String() + if bech != bechexpected { + panic("Bech encoding doesn't match reference") + } + + bechres, err := sdk.AccAddressFromBech32(bech) + if err != nil { + panic(err) + } + if !bytes.Equal(bechres, res) { + panic("Bech decode and hex decode don't match") + } + + return res +} + // createIncrementalAccounts is a strategy used by addTestAddrs() in order to generated addresses in ascending order. func createIncrementalAccounts(accNum int) []sdk.AccAddress { var addresses []sdk.AccAddress @@ -300,7 +344,7 @@ func createIncrementalAccounts(accNum int) []sdk.AccAddress { buffer.WriteString("A58856F0FD53BF058B4909A21AEC019107BA6") // base address string buffer.WriteString(numString) // adding on final two digits to make addresses unique - res, _ := sdk.AccAddressFromHex(buffer.String()) + res, _ := sdk.AccAddressFromHexUnsafe(buffer.String()) bech := res.String() addr, _ := TestAddr(buffer.String(), bech) @@ -326,7 +370,7 @@ func AddTestAddrs(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sd return addTestAddrs(app, ctx, accNum, accAmt, createRandomAccounts) } -// AddTestAddrs constructs and returns accNum amount of accounts with an +// AddTestAddrsIncremental constructs and returns accNum amount of accounts with an // initial balance of accAmt in random order func AddTestAddrsIncremental(app *SimApp, ctx sdk.Context, accNum int, accAmt sdk.Int) []sdk.AccAddress { return addTestAddrs(app, ctx, accNum, accAmt, createIncrementalAccounts) @@ -368,7 +412,7 @@ func ConvertAddrsToValAddrs(addrs []sdk.AccAddress) []sdk.ValAddress { } func TestAddr(addr string, bech string) (sdk.AccAddress, error) { - res, err := sdk.AccAddressFromHex(addr) + res, err := sdk.AccAddressFromHexUnsafe(addr) if err != nil { return nil, err } @@ -403,7 +447,8 @@ func SignCheckDeliver( chainID string, accNums, accSeqs []uint64, expSimPass, expPass bool, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - tx, err := helpers.GenTx( + tx, err := helpers.GenSignedMockTx( + rand.New(rand.NewSource(time.Now().UnixNano())), txCfg, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -430,7 +475,7 @@ func SignCheckDeliver( // Simulate a sending a transaction and committing a block app.BeginBlock(abci.RequestBeginBlock{Header: header}) - gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx) + gInfo, res, err := app.SimDeliver(txCfg.TxEncoder(), tx) if expPass { require.NoError(t, err) @@ -453,7 +498,8 @@ func GenSequenceOfTxs(txGen client.TxConfig, msgs []sdk.Msg, accNums []uint64, i txs := make([]sdk.Tx, numToGenerate) var err error for i := 0; i < numToGenerate; i++ { - txs[i], err = helpers.GenTx( + txs[i], err = helpers.GenSignedMockTx( + rand.New(rand.NewSource(time.Now().UnixNano())), txGen, msgs, sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, @@ -546,7 +592,7 @@ func FundModuleAccount(bankKeeper bankkeeper.Keeper, ctx sdk.Context, recipientM func QueryBalancesExec(clientCtx client.Context, address string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ address, - fmt.Sprintf("--%s=json", cli.OutputFlag), + fmt.Sprintf("--%s=json", "output"), } args = append(args, extraArgs...) @@ -557,7 +603,7 @@ func QueryBalanceExec(clientCtx client.Context, address string, denom string, ex args := []string{ address, fmt.Sprintf("--%s=%s", bankcli.FlagDenom, denom), - fmt.Sprintf("--%s=json", cli.OutputFlag), + fmt.Sprintf("--%s=json", "output"), } args = append(args, extraArgs...) @@ -567,7 +613,7 @@ func QueryBalanceExec(clientCtx client.Context, address string, denom string, ex func QueryAccountExec(clientCtx client.Context, address string, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ address, - fmt.Sprintf("--%s=json", cli.OutputFlag), + fmt.Sprintf("--%s=json", "output"), } args = append(args, extraArgs...)