diff --git a/.dockerignore b/.dockerignore index a1e4b36e518..ec94acf103e 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,7 +4,6 @@ docs/ networks/ proto/ scripts/ -tests/ tools/ .github/ .git/ diff --git a/.github/workflows/auto-update-upgrade.yml b/.github/workflows/auto-update-upgrade.yml new file mode 100644 index 00000000000..aee6de935b8 --- /dev/null +++ b/.github/workflows/auto-update-upgrade.yml @@ -0,0 +1,38 @@ +# When new major release is created this workflow will be triggered and will do 3 things: +# 1) it will create a directory with an empty upgrade handler in app/upgrades folder +# 2) will increase an E2E_UPGRADE_VERSION variable in Makefile +# 3) create a pull request with these changes to main + +name: On Release Auto Upgrade + +on: + release: + types: [published] + +jobs: + post_release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.3.4 + + - name: Run version script + run: bash ./scripts/check_release.sh ${{ github.event.release.tag_name }} + + - name: Run post release script + if: env.MAJOR == 1 # 1 means vX of existing upgrade handler is smaller than A in tag vA.B.C + run: bash ./scripts/empty_upgrade_handler_gen.sh + + - name: Create PR + if: env.MAJOR == 1 + uses: peter-evans/create-pull-request@v4 + with: + base: ${{ github.event.repository.default_branch }} + body: | + Update report + - Created a new empty upgrade handler + - Increased E2E_UPGRADE_VERSION in Makefile by 1 + labels: | + T:auto + C:e2e + C:app-wiring \ No newline at end of file diff --git a/.github/workflows/contracts.yml b/.github/workflows/contracts.yml index 5a376ee9173..63031881121 100644 --- a/.github/workflows/contracts.yml +++ b/.github/workflows/contracts.yml @@ -12,11 +12,11 @@ on: jobs: test: - name: Test Suite + name: Test Cosmwasm Contracts runs-on: ubuntu-latest strategy: matrix: - contract: [{workdir: ./x/ibc-rate-limit/, output: testdata/rate_limiter.wasm, build: artifacts/rate_limiter-x86_64.wasm, name: rate_limiter}] + contract: [{workdir: ./x/ibc-rate-limit/, output: bytecode/rate_limiter.wasm, build: artifacts/rate_limiter-x86_64.wasm, name: rate_limiter}] steps: - name: Checkout sources @@ -82,8 +82,42 @@ jobs: path: ${{ matrix.contract.workdir }}${{ matrix.contract.build }} retention-days: 1 -# - name: Check Test Data -# working-directory: ${{ matrix.contract.workdir }} -# if: ${{ matrix.contract.output != null }} -# run: > -# diff ${{ matrix.contract.output }} ${{ matrix.contract.build }} + - name: Check Test Data + working-directory: ${{ matrix.contract.workdir }} + if: ${{ matrix.contract.output != null }} + run: > + diff ${{ matrix.contract.output }} ${{ matrix.contract.build }} + + + lints: + name: Cosmwasm Lints + runs-on: ubuntu-latest + strategy: + matrix: + workdir: [./x/ibc-rate-limit] + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + - uses: technote-space/get-diff-action@v6.0.1 + with: + PATTERNS: | + **/**.rs + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + components: rustfmt, clippy + + - name: Format + working-directory: ${{ matrix.workdir }} + run: > + cargo fmt --all -- --check + + - name: run cargo clippy + working-directory: ${{ matrix.workdir }} + run: > + cargo clippy -- -D warnings + diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 4baa5ff168e..2debe754e0b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -54,9 +54,4 @@ jobs: # within `super-linter`. fetch-depth: 0 - name: Run documentation linter - uses: github/super-linter@v4 - env: - VALIDATE_ALL_CODEBASE: false - VALIDATE_MARKDOWN: true - DEFAULT_BRANCH: main - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: make mdlint diff --git a/.gitignore b/.gitignore index 713ac5a1033..ff99e2886b4 100644 --- a/.gitignore +++ b/.gitignore @@ -230,3 +230,7 @@ Cargo.lock .beaker blocks.db **/blocks.db* + +# Ignore e2e test artifacts (which clould leak information if commited) +.ash_history +.bash_history \ No newline at end of file diff --git a/.markdownlint.yml b/.markdownlint.yml index 926e6625649..cbe0c3ceea8 100644 --- a/.markdownlint.yml +++ b/.markdownlint.yml @@ -12,8 +12,6 @@ MD042: true MD048: true MD051: true # MD004: false -# # Can't disable MD007 :/ -# MD007: false # MD009: false # MD010: # code_blocks: false diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..9f235a7f43a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,30 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "E2E: (make test-e2e-short)", + "type": "go", + "request": "launch", + "mode": "test", + "program": "${workspaceFolder}/tests/e2e", + "args": [ + "-test.timeout", + "30m", + "-test.run", + "IntegrationTestSuite", + "-test.v" + ], + "buildFlags": "-tags e2e", + "env": { + "OSMOSIS_E2E": "True", + "OSMOSIS_E2E_SKIP_IBC": "true", + "OSMOSIS_E2E_SKIP_UPGRADE": "true", + "OSMOSIS_E2E_SKIP_CLEANUP": "true", + "OSMOSIS_E2E_SKIP_STATE_SYNC": "true", + "OSMOSIS_E2E_UPGRADE_VERSION": "v13", + "OSMOSIS_E2E_DEBUG_LOG": "true", + }, + "preLaunchTask": "e2e-setup" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000000..ab56522001c --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,12 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "e2e-setup", + "type": "shell", + "command": "make e2e-setup" + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index 5d4a5261e1d..4b37cbbcb7a 100644 --- a/Makefile +++ b/Makefile @@ -224,7 +224,7 @@ run-querygen: ############################################################################### PACKAGES_UNIT=$(shell go list ./... | grep -E -v 'tests/simulator|e2e') -PACKAGES_E2E=$(shell go list -tags e2e ./... | grep '/e2e') +PACKAGES_E2E=$(shell go list ./... | grep '/e2e') PACKAGES_SIM=$(shell go list ./... | grep '/tests/simulator') TEST_PACKAGES=./... @@ -261,25 +261,25 @@ test-sim-bench: # In that case, run `make e2e-remove-resources` # manually. # Utilizes Go cache. -test-e2e: e2e-setup test-e2e-ci +test-e2e: OSMOSIS_E2E=True e2e-setup test-e2e-ci # test-e2e-ci runs a full e2e test suite # does not do any validation about the state of the Docker environment # As a result, avoid using this locally. test-e2e-ci: - @VERSION=$(VERSION) OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) # test-e2e-debug runs a full e2e test suite but does # not attempt to delete Docker resources at the end. test-e2e-debug: e2e-setup - @VERSION=$(VERSION) OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 # test-e2e-short runs the e2e test with only short tests. # Does not delete any of the containers after running. # Deletes any existing containers before running. # Does not use Go cache. test-e2e-short: e2e-setup - @VERSION=$(VERSION) OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_SKIP_UPGRADE=True OSMOSIS_E2E_SKIP_IBC=True OSMOSIS_E2E_SKIP_STATE_SYNC=True OSMOSIS_E2E_SKIP_CLEANUP=True go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_SKIP_UPGRADE=True OSMOSIS_E2E_SKIP_IBC=True OSMOSIS_E2E_SKIP_STATE_SYNC=True OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 test-mutation: @bash scripts/mutation-test.sh $(MODULES) @@ -296,10 +296,10 @@ docker-build-debug: @DOCKER_BUILDKIT=1 docker tag osmosis:${COMMIT} osmosis:debug docker-build-e2e-init-chain: - @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-chain:debug --build-arg E2E_SCRIPT_NAME=chain --platform=linux/x86_64 -f tests/e2e/initialization/init.Dockerfile . docker-build-e2e-init-node: - @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node -f tests/e2e/initialization/init.Dockerfile . + @DOCKER_BUILDKIT=1 docker build -t osmosis-e2e-init-node:debug --build-arg E2E_SCRIPT_NAME=node --platform=linux/x86_64 -f tests/e2e/initialization/init.Dockerfile . e2e-setup: e2e-check-image-sha e2e-remove-resources @echo Finished e2e environment setup, ready to start the test diff --git a/app/app.go b/app/app.go index 747d777355d..b5d3f67ef1b 100644 --- a/app/app.go +++ b/app/app.go @@ -267,6 +267,8 @@ func NewOsmosisApp( app.IBCKeeper, ), ) + // Uncomment to enable postHandlers: + // app.SetPostHandler(NewTxPostHandler()) app.SetEndBlocker(app.EndBlocker) // Register snapshot extensions to enable state-sync for wasm. diff --git a/app/apptesting/events.go b/app/apptesting/events.go index 7d0a4d4dfdd..cdfae502886 100644 --- a/app/apptesting/events.go +++ b/app/apptesting/events.go @@ -21,11 +21,17 @@ func (s *KeeperTestHelper) AssertEventEmitted(ctx sdk.Context, eventTypeExpected func (s *KeeperTestHelper) FindEvent(events []sdk.Event, name string) sdk.Event { index := slices.IndexFunc(events, func(e sdk.Event) bool { return e.Type == name }) + if index == -1 { + return sdk.Event{} + } return events[index] } func (s *KeeperTestHelper) ExtractAttributes(event sdk.Event) map[string]string { attrs := make(map[string]string) + if event.Attributes == nil { + return attrs + } for _, a := range event.Attributes { attrs[string(a.Key)] = string(a.Value) } diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index bfd324ad0c8..3504f42dcce 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -2,6 +2,7 @@ package keepers import ( "github.com/CosmWasm/wasmd/x/wasm" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" @@ -33,6 +34,9 @@ import ( upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper" upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" + ibcratelimit "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit" + ibcratelimittypes "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + icahost "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host" icahostkeeper "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/keeper" icahosttypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types" @@ -115,12 +119,14 @@ type AppKeepers struct { SuperfluidKeeper *superfluidkeeper.Keeper GovKeeper *govkeeper.Keeper WasmKeeper *wasm.Keeper + ContractKeeper *wasmkeeper.PermissionedKeeper TokenFactoryKeeper *tokenfactorykeeper.Keeper SwapRouterKeeper *swaprouter.Keeper ConcentratedLiquidityKeeper *concentratedliquidity.Keeper // IBC modules // transfer module - TransferModule transfer.AppModule + TransferModule transfer.AppModule + RateLimitingICS4Wrapper *ibcratelimit.ICS4Wrapper // keys to access the substores keys map[string]*sdk.KVStoreKey @@ -202,12 +208,24 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.ScopedIBCKeeper, ) + // ChannelKeeper wrapper for rate limiting SendPacket(). The wasmKeeper needs to be added after it's created + rateLimitingParams := appKeepers.GetSubspace(ibcratelimittypes.ModuleName) + rateLimitingParams = rateLimitingParams.WithKeyTable(ibcratelimittypes.ParamKeyTable()) + rateLimitingICS4Wrapper := ibcratelimit.NewICS4Middleware( + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.AccountKeeper, + nil, + appKeepers.BankKeeper, + rateLimitingParams, + ) + appKeepers.RateLimitingICS4Wrapper = &rateLimitingICS4Wrapper + // Create Transfer Keepers transferKeeper := ibctransferkeeper.NewKeeper( appCodec, appKeepers.keys[ibctransfertypes.StoreKey], appKeepers.GetSubspace(ibctransfertypes.ModuleName), - appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.RateLimitingICS4Wrapper, // The ICS4Wrapper is replaced by the rateLimitingICS4Wrapper instead of the channel appKeepers.IBCKeeper.ChannelKeeper, &appKeepers.IBCKeeper.PortKeeper, appKeepers.AccountKeeper, @@ -218,6 +236,9 @@ func (appKeepers *AppKeepers) InitNormalKeepers( appKeepers.TransferModule = transfer.NewAppModule(*appKeepers.TransferKeeper) transferIBCModule := transfer.NewIBCModule(*appKeepers.TransferKeeper) + // RateLimiting IBC Middleware + rateLimitingTransferModule := ibcratelimit.NewIBCModule(transferIBCModule, appKeepers.RateLimitingICS4Wrapper) + icaHostKeeper := icahostkeeper.NewKeeper( appCodec, appKeepers.keys[icahosttypes.StoreKey], appKeepers.GetSubspace(icahosttypes.SubModuleName), @@ -233,7 +254,8 @@ func (appKeepers *AppKeepers) InitNormalKeepers( // Create static IBC router, add transfer route, then set and seal it ibcRouter := porttypes.NewRouter() ibcRouter.AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(ibctransfertypes.ModuleName, transferIBCModule) + // The transferIBC module is replaced by rateLimitingTransferModule + AddRoute(ibctransfertypes.ModuleName, &rateLimitingTransferModule) // Note: the sealing is done after creating wasmd and wiring that up // create evidence keeper with router @@ -360,6 +382,9 @@ func (appKeepers *AppKeepers) InitNormalKeepers( wasmOpts..., ) appKeepers.WasmKeeper = &wasmKeeper + // Update the ICS4Wrapper with the proper contractKeeper + appKeepers.ContractKeeper = wasmkeeper.NewDefaultPermissionKeeper(appKeepers.WasmKeeper) + appKeepers.RateLimitingICS4Wrapper.ContractKeeper = appKeepers.ContractKeeper // wire up x/wasm to IBC ibcRouter.AddRoute(wasm.ModuleName, wasm.NewIBCHandler(appKeepers.WasmKeeper, appKeepers.IBCKeeper.ChannelKeeper)) @@ -455,6 +480,7 @@ func (appKeepers *AppKeepers) initParamsKeeper(appCodec codec.BinaryCodec, legac paramsKeeper.Subspace(tokenfactorytypes.ModuleName) paramsKeeper.Subspace(twaptypes.ModuleName) paramsKeeper.Subspace(swaproutertypes.ModuleName) + paramsKeeper.Subspace(ibcratelimittypes.ModuleName) return paramsKeeper } diff --git a/app/tx_post_handler.go b/app/tx_post_handler.go new file mode 100644 index 00000000000..2141a3d8484 --- /dev/null +++ b/app/tx_post_handler.go @@ -0,0 +1,9 @@ +package app + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func NewTxPostHandler() sdk.AnteHandler { + panic("not implemented") +} diff --git a/chain.schema.json b/chain.schema.json index e367fa009d5..e9a399008ee 100644 --- a/chain.schema.json +++ b/chain.schema.json @@ -2,13 +2,13 @@ "$schema": "http://json-schema.org/draft-07/schema#", "codebase":{ "git_repo": "https://github.com/osmosis-labs/osmosis", - "recommended_version": "12.2.0", + "recommended_version": "v12.2.0", "compatible_versions": [ - "12.2.0" + "v12.2.0" ], "binaries": { - "linux/amd64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.1.0/osmosisd-12.1.0-linux-amd64?checksum=sha256:44433f93946338b8cb167d9030ebbcfe924294d95d745026ada5dbe8f50d5010", - "linux/arm64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.1.0/osmosisd-12.1.0-linux-arm64?checksum=sha256:ef2c3d60156be5481534ecb33f9d94d73afa38a1b016e7e1c6d3fe10e3e69b3a" + "linux/amd64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.2.0/osmosisd-12.2.0-linux-amd64?checksum=sha256:b4a0296b142b1a535f3116021d39660868a83fc66b290ab0891b06211f86fd31", + "linux/arm64": "https://github.com/osmosis-labs/osmosis/releases/download/v12.2.0/osmosisd-12.2.0-linux-arm64?checksum=sha256:84717e741b61ef3616fef403aae42067614e58a0208347cd642f6d03240b7778" }, "cosmos_sdk_version": "0.45", "tendermint_version": "0.34", diff --git a/go.mod b/go.mod index e47d61587d1..b130f45de8c 100644 --- a/go.mod +++ b/go.mod @@ -15,13 +15,13 @@ require ( github.com/golangci/golangci-lint v1.50.1 github.com/gorilla/mux v1.8.0 github.com/grpc-ecosystem/grpc-gateway v1.16.0 - github.com/mattn/go-sqlite3 v1.14.15 + github.com/mattn/go-sqlite3 v1.14.16 github.com/ory/dockertest/v3 v3.9.1 github.com/osmosis-labs/go-mutesting v0.0.0-20220811235203-65a53b4ea8e3 github.com/pkg/errors v0.9.1 github.com/rakyll/statik v0.1.7 github.com/spf13/cast v1.5.0 - github.com/spf13/cobra v1.6.0 + github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.13.0 github.com/stretchr/testify v1.8.1 @@ -281,7 +281,7 @@ require ( golang.org/x/term v0.1.0 // indirect golang.org/x/text v0.4.0 // indirect golang.org/x/tools v0.2.0 // indirect - google.golang.org/protobuf v1.28.1 + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/yaml.v3 v3.0.1 diff --git a/go.sum b/go.sum index 11450d9682f..47644893d17 100644 --- a/go.sum +++ b/go.sum @@ -765,8 +765,8 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg= github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -github.com/mattn/go-sqlite3 v1.14.15 h1:vfoHhTN1af61xCRSWzFIWzx2YskyMTwHLrExkBOjvxI= -github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= +github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y= +github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/mattn/goveralls v0.0.3/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= 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= @@ -1078,8 +1078,8 @@ github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155 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.1.1/go.mod h1:WnodtKOvamDL/PwE2M4iKs8aMDBZ5Q5klgD3qfVJQMI= -github.com/spf13/cobra v1.6.0 h1:42a0n6jwCot1pUmomAp4T7DeMD+20LFv4Q54pxLf2LI= -github.com/spf13/cobra v1.6.0/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= +github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA= +github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY= 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= diff --git a/osmomath/decimal.go b/osmomath/decimal.go index 38172998876..2bb9e0134c0 100644 --- a/osmomath/decimal.go +++ b/osmomath/decimal.go @@ -43,6 +43,13 @@ var ( oneInt = big.NewInt(1) tenInt = big.NewInt(10) + // log_2(e) + // From: https://www.wolframalpha.com/input?i=log_2%28e%29+with+37+digits + logOfEbase2 = MustNewDecFromStr("1.442695040888963407359924681001892137") + + // log_2(1.0001) + // From: https://www.wolframalpha.com/input?i=log_2%281.0001%29+to+33+digits + tickLogOf2 = MustNewDecFromStr("0.000144262291094554178391070900057480") // initialized in init() since requires // precision to be defined. twoBigDec BigDec @@ -917,3 +924,38 @@ func (x BigDec) LogBase2() BigDec { return y } + +// Natural logarithm of x. +// Formula: ln(x) = log_2(x) / log_2(e) +func (x BigDec) Ln() BigDec { + log2x := x.LogBase2() + + y := log2x.Quo(logOfEbase2) + + return y +} + +// log_1.0001(x) "tick" base logarithm +// Formula: log_1.0001(b) = log_2(b) / log_2(1.0001) +func (x BigDec) TickLog() BigDec { + log2x := x.LogBase2() + + y := log2x.Quo(tickLogOf2) + + return y +} + +// log_a(x) custom base logarithm +// Formula: log_a(b) = log_2(b) / log_2(a) +func (x BigDec) CustomBaseLog(base BigDec) BigDec { + if base.LTE(ZeroDec()) || base.Equal(OneDec()) { + panic(fmt.Sprintf("log is not defined at base <= 0 or base == 1, base given (%s)", base)) + } + + log2x_argument := x.LogBase2() + log2x_base := base.LogBase2() + + y := log2x_argument.Quo(log2x_base) + + return y +} diff --git a/osmomath/decimal_test.go b/osmomath/decimal_test.go index cabf1409c87..11732ac29e6 100644 --- a/osmomath/decimal_test.go +++ b/osmomath/decimal_test.go @@ -739,3 +739,282 @@ func (s *decimalTestSuite) TestLog2() { }) } } + +func (s *decimalTestSuite) TestLn() { + var expectedErrTolerance = MustNewDecFromStr("0.000000000000000000000000000000000100") + + tests := map[string]struct { + initialValue BigDec + expected BigDec + + expectedPanic bool + }{ + "log_e{-1}; invalid; panic": { + initialValue: OneDec().Neg(), + expectedPanic: true, + }, + "log_e{0}; invalid; panic": { + initialValue: ZeroDec(), + expectedPanic: true, + }, + "log_e{0.001} = -6.90775527898213705205397436405309262": { + initialValue: MustNewDecFromStr("0.001"), + // From: https://www.wolframalpha.com/input?i=log0.001+to+36+digits+with+36+decimals + expected: MustNewDecFromStr("-6.90775527898213705205397436405309262"), + }, + "log_e{0.56171821941421412902170941} = -0.576754943768592057376050794884207180": { + initialValue: MustNewDecFromStr("0.56171821941421412902170941"), + // From: https://www.wolframalpha.com/input?i=log0.56171821941421412902170941+to+36+digits + expected: MustNewDecFromStr("-0.576754943768592057376050794884207180"), + }, + "log_e{0.999912345} = -0.000087658841924023373535614212850888": { + initialValue: MustNewDecFromStr("0.999912345"), + // From: https://www.wolframalpha.com/input?i=log0.999912345+to+32+digits + expected: MustNewDecFromStr("-0.000087658841924023373535614212850888"), + }, + "log_e{1} = 0": { + initialValue: NewBigDec(1), + expected: NewBigDec(0), + }, + "log_e{e} = 1": { + initialValue: MustNewDecFromStr("2.718281828459045235360287471352662498"), + // From: https://www.wolframalpha.com/input?i=e+with+36+decimals + expected: NewBigDec(1), + }, + "log_e{7} = 1.945910149055313305105352743443179730": { + initialValue: NewBigDec(7), + // From: https://www.wolframalpha.com/input?i=log7+up+to+36+decimals + expected: MustNewDecFromStr("1.945910149055313305105352743443179730"), + }, + "log_e{512} = 6.238324625039507784755089093123589113": { + initialValue: NewBigDec(512), + // From: https://www.wolframalpha.com/input?i=log512+up+to+36+decimals + expected: MustNewDecFromStr("6.238324625039507784755089093123589113"), + }, + "log_e{580} = 6.36302810354046502061849560850445238": { + initialValue: NewBigDec(580), + // From: https://www.wolframalpha.com/input?i=log580+up+to+36+decimals + expected: MustNewDecFromStr("6.36302810354046502061849560850445238"), + }, + "log_e{1024.987654321} = 6.93243584693509415029056534690631614": { + initialValue: NewDecWithPrec(1024987654321, 9), + // From: https://www.wolframalpha.com/input?i=log1024.987654321+to+36+digits + expected: MustNewDecFromStr("6.93243584693509415029056534690631614"), + }, + "log_e{912648174127941279170121098210.92821920190204131121} = 68.986147965719214790400745338243805015": { + initialValue: MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + // From: https://www.wolframalpha.com/input?i=log912648174127941279170121098210.92821920190204131121+to+38+digits + expected: MustNewDecFromStr("68.986147965719214790400745338243805015"), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + osmoassert.ConditionalPanic(s.T(), tc.expectedPanic, func() { + // Create a copy to test that the original was not modified. + // That is, that Ln() is non-mutative. + initialCopy := ZeroDec() + initialCopy.i.Set(tc.initialValue.i) + + // system under test. + res := tc.initialValue.Ln() + require.True(DecApproxEq(s.T(), tc.expected, res, expectedErrTolerance)) + require.Equal(s.T(), initialCopy, tc.initialValue) + }) + }) + } +} + +func (s *decimalTestSuite) TestTickLog() { + tests := map[string]struct { + initialValue BigDec + expected BigDec + + expectedErrTolerance BigDec + expectedPanic bool + }{ + "log_1.0001{-1}; invalid; panic": { + initialValue: OneDec().Neg(), + expectedPanic: true, + }, + "log_1.0001{0}; invalid; panic": { + initialValue: ZeroDec(), + expectedPanic: true, + }, + "log_1.0001{0.001} = -69081.006609899112313305835611219486392199": { + initialValue: MustNewDecFromStr("0.001"), + // From: https://www.wolframalpha.com/input?i=log_1.0001%280.001%29+to+41+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000143031879"), + expected: MustNewDecFromStr("-69081.006609899112313305835611219486392199"), + }, + "log_1.0001{0.999912345} = -0.876632247930741919880461740717176538": { + initialValue: MustNewDecFromStr("0.999912345"), + // From: https://www.wolframalpha.com/input?i=log_1.0001%280.999912345%29+to+36+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000138702"), + expected: MustNewDecFromStr("-0.876632247930741919880461740717176538"), + }, + "log_1.0001{1} = 0": { + initialValue: NewBigDec(1), + + expectedErrTolerance: ZeroDec(), + expected: NewBigDec(0), + }, + "log_1.0001{1.0001} = 1": { + initialValue: MustNewDecFromStr("1.0001"), + + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000152500"), + expected: OneDec(), + }, + "log_1.0001{512} = 62386.365360724158196763710649998441051753": { + initialValue: NewBigDec(512), + // From: https://www.wolframalpha.com/input?i=log_1.0001%28512%29+to+41+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000129292137"), + expected: MustNewDecFromStr("62386.365360724158196763710649998441051753"), + }, + "log_1.0001{1024.987654321} = 69327.824629506998657531621822514042777198": { + initialValue: NewDecWithPrec(1024987654321, 9), + // From: https://www.wolframalpha.com/input?i=log_1.0001%281024.987654321%29+to+41+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000143836264"), + expected: MustNewDecFromStr("69327.824629506998657531621822514042777198"), + }, + "log_1.0001{912648174127941279170121098210.92821920190204131121} = 689895.972156319183538389792485913311778672": { + initialValue: MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + // From: https://www.wolframalpha.com/input?i=log_1.0001%28912648174127941279170121098210.92821920190204131121%29+to+42+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000001429936067"), + expected: MustNewDecFromStr("689895.972156319183538389792485913311778672"), + }, + } + + for name, tc := range tests { + s.Run(name, func() { + osmoassert.ConditionalPanic(s.T(), tc.expectedPanic, func() { + // Create a copy to test that the original was not modified. + // That is, that Ln() is non-mutative. + initialCopy := ZeroDec() + initialCopy.i.Set(tc.initialValue.i) + + // system under test. + res := tc.initialValue.TickLog() + fmt.Println(name, res.Sub(tc.expected).Abs()) + require.True(DecApproxEq(s.T(), tc.expected, res, tc.expectedErrTolerance)) + require.Equal(s.T(), initialCopy, tc.initialValue) + }) + }) + } +} + +func (s *decimalTestSuite) TestCustomBaseLog() { + tests := map[string]struct { + initialValue BigDec + base BigDec + + expected BigDec + expectedErrTolerance BigDec + + expectedPanic bool + }{ + "log_2{-1}: normal base, invalid argument - panics": { + initialValue: NewBigDec(-1), + base: NewBigDec(2), + expectedPanic: true, + }, + "log_2{0}: normal base, invalid argument - panics": { + initialValue: NewBigDec(0), + base: NewBigDec(2), + expectedPanic: true, + }, + "log_(-1)(2): invalid base, normal argument - panics": { + initialValue: NewBigDec(2), + base: NewBigDec(-1), + expectedPanic: true, + }, + "log_1(2): base cannot equal to 1 - panics": { + initialValue: NewBigDec(2), + base: NewBigDec(1), + expectedPanic: true, + }, + "log_30(100) = 1.353984985057691049642502891262784015": { + initialValue: NewBigDec(100), + base: NewBigDec(30), + // From: https://www.wolframalpha.com/input?i=log_30%28100%29+to+37+digits + expectedErrTolerance: ZeroDec(), + expected: MustNewDecFromStr("1.353984985057691049642502891262784015"), + }, + "log_0.2(0.99) = 0.006244624769837438271878639001855450": { + initialValue: MustNewDecFromStr("0.99"), + base: MustNewDecFromStr("0.2"), + // From: https://www.wolframalpha.com/input?i=log_0.2%280.99%29+to+34+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000000013"), + expected: MustNewDecFromStr("0.006244624769837438271878639001855450"), + }, + + "log_0.0001(500000) = -1.424742501084004701196565276318876743": { + initialValue: NewBigDec(500000), + base: NewDecWithPrec(1, 4), + // From: https://www.wolframalpha.com/input?i=log_0.0001%28500000%29+to+37+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000000003"), + expected: MustNewDecFromStr("-1.424742501084004701196565276318876743"), + }, + + "log_500000(0.0001) = -0.701881216598197542030218906945601429": { + initialValue: NewDecWithPrec(1, 4), + base: NewBigDec(500000), + // From: https://www.wolframalpha.com/input?i=log_500000%280.0001%29+to+36+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000000001"), + expected: MustNewDecFromStr("-0.701881216598197542030218906945601429"), + }, + + "log_10000(5000000) = 1.674742501084004701196565276318876743": { + initialValue: NewBigDec(5000000), + base: NewBigDec(10000), + // From: https://www.wolframalpha.com/input?i=log_10000%285000000%29+to+37+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000000002"), + expected: MustNewDecFromStr("1.674742501084004701196565276318876743"), + }, + "log_0.123456789(1) = 0": { + initialValue: OneDec(), + base: MustNewDecFromStr("0.123456789"), + + expectedErrTolerance: ZeroDec(), + expected: ZeroDec(), + }, + "log_1111(1111) = 1": { + initialValue: NewBigDec(1111), + base: NewBigDec(1111), + + expectedErrTolerance: ZeroDec(), + expected: OneDec(), + }, + + "log_1.123{1024.987654321} = 59.760484327223888489694630378785099461": { + initialValue: NewDecWithPrec(1024987654321, 9), + base: NewDecWithPrec(1123, 3), + // From: https://www.wolframalpha.com/input?i=log_1.123%281024.987654321%29+to+38+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000007686"), + expected: MustNewDecFromStr("59.760484327223888489694630378785099461"), + }, + + "log_1.123{912648174127941279170121098210.92821920190204131121} = 594.689327867863079177915648832621538986": { + initialValue: MustNewDecFromStr("912648174127941279170121098210.92821920190204131121"), + base: NewDecWithPrec(1123, 3), + // From: https://www.wolframalpha.com/input?i=log_1.123%28912648174127941279170121098210.92821920190204131121%29+to+39+digits + expectedErrTolerance: MustNewDecFromStr("0.000000000000000000000000000000077705"), + expected: MustNewDecFromStr("594.689327867863079177915648832621538986"), + }, + } + for name, tc := range tests { + s.Run(name, func() { + osmoassert.ConditionalPanic(s.T(), tc.expectedPanic, func() { + // Create a copy to test that the original was not modified. + // That is, that Ln() is non-mutative. + initialCopy := ZeroDec() + initialCopy.i.Set(tc.initialValue.i) + + // system under test. + res := tc.initialValue.CustomBaseLog(tc.base) + require.True(DecApproxEq(s.T(), tc.expected, res, tc.expectedErrTolerance)) + require.Equal(s.T(), initialCopy, tc.initialValue) + }) + }) + } +} diff --git a/proto/osmosis/streamswap/v1/event.proto b/proto/osmosis/streamswap/v1/event.proto deleted file mode 100644 index 1769d18bbbc..00000000000 --- a/proto/osmosis/streamswap/v1/event.proto +++ /dev/null @@ -1,42 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; -option (gogoproto.goproto_getters_all) = false; - -message EventCreateSale { - uint64 id = 1; - string creator = 2; - string token_in = 3; - cosmos.base.v1beta1.Coin token_out = 4 [ (gogoproto.nullable) = false ]; -} - -message EventSubscribe { - string sender = 1; - uint64 sale_id = 2; - string amount = 3; -} - -message EventWithdraw { - string sender = 1; - uint64 sale_id = 2; - // amount of staked token_in withdrawn by user. - string amount = 3; -} - -message EventExit { - string sender = 1; - uint64 sale_id = 2; - // amount of purchased token_out sent to the user - string purchased = 3; -} - -message EventFinalizeSale { - uint64 sale_id = 1; - // amount of earned tokens_in - string income = 3; -} diff --git a/proto/osmosis/streamswap/v1/genesis.proto b/proto/osmosis/streamswap/v1/genesis.proto deleted file mode 100644 index b9f7922c907..00000000000 --- a/proto/osmosis/streamswap/v1/genesis.proto +++ /dev/null @@ -1,27 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "gogoproto/gogo.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; -import "osmosis/streamswap/v1/state.proto"; -import "osmosis/streamswap/v1/params.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; - -// GenesisState defines the streamswap module's genesis state. -message GenesisState { - repeated Sale sales = 1 [ (gogoproto.nullable) = false ]; - repeated UserPositionKV user_positions = 2 [ (gogoproto.nullable) = false ]; - uint64 next_sale_id = 3; - Params params = 4 [ (gogoproto.nullable) = false ]; -} - -// UserPositionKV is a record in genesis representing acc_address user position -// of a sale_id sale. -message UserPositionKV { - // user account address - string acc_address = 1; - uint64 sale_id = 2; - UserPosition user_position = 3 [ (gogoproto.nullable) = false ]; -} diff --git a/proto/osmosis/streamswap/v1/params.proto b/proto/osmosis/streamswap/v1/params.proto deleted file mode 100644 index ec2d04dbf75..00000000000 --- a/proto/osmosis/streamswap/v1/params.proto +++ /dev/null @@ -1,34 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/any.proto"; -import "cosmos_proto/cosmos.proto"; -import "cosmos/base/v1beta1/coin.proto"; - -import "google/protobuf/duration.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; - -// Params holds parameters for the streamswap module -message Params { - // fee charged when creating a new sale. The fee will go to the - // sale_fee_recipient unless it is not defined (empty). - repeated cosmos.base.v1beta1.Coin sale_creation_fee = 1 [ - (gogoproto.castrepeated) = "github.com/cosmos/cosmos-sdk/types.Coins", - (gogoproto.moretags) = "yaml:\"sale_creation_fee\"", - (gogoproto.nullable) = false - ]; - - // bech32 address of the fee recipient - string sale_creation_fee_recipient = 2; - - // minimum amount duration of time between the sale creation and the sale - // start time. - google.protobuf.Duration min_duration_until_start_time = 3 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; - - // minimum duration for every new sale. - google.protobuf.Duration min_sale_duration = 4 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; -} diff --git a/proto/osmosis/streamswap/v1/query.proto b/proto/osmosis/streamswap/v1/query.proto deleted file mode 100644 index 1a522a9e828..00000000000 --- a/proto/osmosis/streamswap/v1/query.proto +++ /dev/null @@ -1,63 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "gogoproto/gogo.proto"; -import "google/api/annotations.proto"; -import "cosmos/base/query/v1beta1/pagination.proto"; - -import "osmosis/streamswap/v1/state.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; -option (gogoproto.goproto_getters_all) = false; - -// Query defines the gRPC querier service. -service Query { - // Returns list of Sales ordered by the creation time - rpc Sales(QuerySales) returns (QuerySalesResponse) { - option (google.api.http).get = "/cosmos/streamswap/v1/sales"; - } - - // Returns the specific Sale object - rpc Sale(QuerySale) returns (QuerySaleResponse) { - option (google.api.http).get = "/cosmos/streamswap/v1/sales/{sale_id}"; - } - - rpc UserPosition(QueryUserPosition) returns (QueryUserPositionResponse) { - option (google.api.http).get = - "/cosmos/streamswap/v1/sales/{sale_id}/{user}"; - } -} - -message QuerySales { - // pagination defines an pagination for the request. - cosmos.base.query.v1beta1.PageRequest pagination = 1; -} - -message QuerySalesResponse { - repeated osmosis.streamswap.v1.Sale sales = 1 - [ (gogoproto.nullable) = false ]; - cosmos.base.query.v1beta1.PageResponse pagination = 2; -} - -// Request type for Query/Sale -message QuerySale { - // Sale ID - uint64 sale_id = 1; -} - -message QuerySaleResponse { - osmosis.streamswap.v1.Sale sale = 1 [ (gogoproto.nullable) = false ]; -} - -// Request type for Query/Sale -message QueryUserPosition { - // ID of the Sale - uint64 sale_id = 1; - // user account address - string user = 2; -} - -message QueryUserPositionResponse { - osmosis.streamswap.v1.UserPosition user_position = 1 - [ (gogoproto.nullable) = false ]; -} diff --git a/proto/osmosis/streamswap/v1/state.proto b/proto/osmosis/streamswap/v1/state.proto deleted file mode 100644 index 9e1f85be7b0..00000000000 --- a/proto/osmosis/streamswap/v1/state.proto +++ /dev/null @@ -1,114 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "google/protobuf/timestamp.proto"; -import "cosmos_proto/cosmos.proto"; -import "gogoproto/gogo.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; -option (gogoproto.goproto_getters_all) = false; - -message Sale { - // Destination for the earned token_in - string treasury = 1; - uint64 id = 2; - - // token_out is a token denom to be bootstraped. May be referred as base - // currency, or a sale token. - string token_out = 3; - // token_in is a token denom used to buy sale tokens (`token_out`). May be - // referred as quote_currency or payment token. - string token_in = 4; - - // total number of `tokens_out` to be sold during the continuous sale. - string token_out_supply = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // start time when the token emission starts. - google.protobuf.Timestamp start_time = 6 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - // end time when the token emission ends. Can't be bigger than start + - // 139years (to avoid round overflow) - google.protobuf.Timestamp end_time = 7 - [ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; - - // Round number when the sale was last time updated. - int64 round = 8; - - // Last round of the Sale; - int64 end_round = 9; - - // amout of remaining token_out to sell - string out_remaining = 10 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // amount of token_out sold - string out_sold = 11 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // out token per share - string out_per_share = 12 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // total amount of currently staked coins (token_in) but not spent coins. - string staked = 13 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // total amount of earned coins (token_in) - string income = 14 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // total amount of shares - string shares = 15 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // Name for the sale. - string name = 20; - // URL with sale and project details. - string url = 21; -} - -// UserPosition represents user account in a sale -message UserPosition { - - string shares = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - // total number of currently staked tokens - string staked = 2 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // last token/share ratio - string out_per_share = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // amount of token_in spent - string spent = 4 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; - - // Amount of accumulated, not withdrawn, purchased tokens (token_out) - string purchased = 5 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} diff --git a/proto/osmosis/streamswap/v1/tx.proto b/proto/osmosis/streamswap/v1/tx.proto deleted file mode 100644 index 087a35e030c..00000000000 --- a/proto/osmosis/streamswap/v1/tx.proto +++ /dev/null @@ -1,141 +0,0 @@ -syntax = "proto3"; -package osmosis.streamswap.v1; - -import "gogoproto/gogo.proto"; -import "google/protobuf/duration.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/empty.proto"; - -import "cosmos/base/v1beta1/coin.proto"; -import "cosmos_proto/cosmos.proto"; - -option go_package = "github.com/osmosis-labs/osmosis/v12/x/streamswap/types"; -option (gogoproto.goproto_getters_all) = false; - -service Msg { - // CreateSale creates new token sale. Anyone can create a new sale. - // params.SaleBond OSMO will be charged as a bond (returned in FinalizeSale) - // to avoid spams. - // The sale follows the streamswap functionality explained in the - // x/launchapd/spec - rpc CreateSale(MsgCreateSale) returns (MsgCreateSaleResponse); - - // Subscribe to a token sale. Any use at any time before the sale end can join - // the sale by sending `token_in` to the Sale through the Subscribe msg. - // During the sale, user `token_in` will be automatically charged every - // epoch to purchase `token_out`. - rpc Subscribe(MsgSubscribe) returns (google.protobuf.Empty); - - // Withdraw sends back `amount` of unspent tokens_in to the user. - // If `amount` is empty, it will default to all unspent tokens. - // User can do it any time unless his deposit is empty. - rpc Withdraw(MsgWithdraw) returns (google.protobuf.Empty); - - // ExitSale withdraws (by a user who subscribed to the sale) purchased - // tokens_out from the pool and remained tokens_in. Must be called after - // the sale end. - rpc ExitSale(MsgExitSale) returns (MsgExitSaleResponse); - - // FinalizeSale clean ups the sale and sends income (earned tokens_in) to the - // Sale recipient. Returns error if called before the Sale end or it was - // already finalized. Anyone can call this method. - rpc FinalizeSale(MsgFinalizeSale) returns (MsgFinalizeSaleResponse); -} - -message MsgCreateSale { - // Sale creator and the account which provides token (token_out) to the sale. - // When processing this message, token_out - string creator = 1; - // token_in is a denom used to buy `token_out`. May be referred as a - // "quote currency". - string token_in = 2; - // token_out is a coin supply (denom + amount) to sell. May be referred as - // "base currency". The whole supply will be transferred from the creator - // to the module and will be sold during the sale. - cosmos.base.v1beta1.Coin token_out = 3 [ (gogoproto.nullable) = false ]; - - // Maximum fee the creator is going to pay for creating a sale. The creator - // will be charged params.SaleCreationFee. Transaction will fail if - // max_fee is smaller than params.SaleCreationFee. If empty, the creator - // doesn't accept any fee. - repeated cosmos.base.v1beta1.Coin max_fee = 4 - [ (gogoproto.nullable) = false ]; - - // start time when the token sale starts. - google.protobuf.Timestamp start_time = 5 - [ (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; - // duration time that the sale takes place over - google.protobuf.Duration duration = 6 - [ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ]; - - // Recipient is the account which receives earned `token_in` from when the - // sale is finalized. If not defined (empty) the creator - // account will be used. - string recipient = 7; - - // Name for the sale, max 40 characters, min 4. Required. - string name = 8; - // URL with sale and project details. Can be a link a link to IPFS, - // hackmd, project page, blog post... Max 120 characters. Must be - // valid agains Go url.ParseRequestURI. Required. - string url = 9; -} - -message MsgCreateSaleResponse { - uint64 sale_id = 1 [ (gogoproto.moretags) = "yaml:\"sale_id\"" ]; -} - -message MsgSubscribe { - // sender is an account address adding a deposit - string sender = 1; - // ID of an existing sale. - uint64 sale_id = 2 [ (gogoproto.moretags) = "yaml:\"sale_id\"" ]; - // number of sale.token_in staked by a user. - string amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message MsgWithdraw { - // sender is an account address subscribed to the sale_id - string sender = 1; - // ID of a sale. - uint64 sale_id = 2 [ (gogoproto.moretags) = "yaml:\"sale_id\"" ]; - // amount of tokens_in to withdraw. Must be at most the amount of not spent - // tokens, unless set to null - then all remaining balance will be withdrawn. - string amount = 3 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = true - ]; -} - -message MsgExitSale { - // sender is an account address exiting a sale - string sender = 1; - // ID of an existing sale. - uint64 sale_id = 2 [ (gogoproto.moretags) = "yaml:\"sale_id\"" ]; -} - -message MsgExitSaleResponse { - // Purchased amount of "out" tokens withdrawn to the user. - string purchased = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} - -message MsgFinalizeSale { - // sender is an account signing the message and triggering the finalization. - string sender = 1; - // ID of an existing sale. - uint64 sale_id = 2 [ (gogoproto.moretags) = "yaml:\"sale_id\"" ]; -} - -message MsgFinalizeSaleResponse { - // Income amount of token_in sent to the sale recipient. - string income = 1 [ - (gogoproto.customtype) = "github.com/cosmos/cosmos-sdk/types.Int", - (gogoproto.nullable) = false - ]; -} diff --git a/scripts/check_release.sh b/scripts/check_release.sh new file mode 100644 index 00000000000..befaeaf8ed8 --- /dev/null +++ b/scripts/check_release.sh @@ -0,0 +1,21 @@ +# this script checks if existing upgrade handler's version is not smaller than current release + +#!/bin/bash + +VERSION=$1 +latest_version=0 +for f in app/upgrades/*; do + s_f=(${f//// }) + version=${s_f[2]} + num_version=${version//[!0-9]/} + if [[ $num_version -gt $latest_version ]]; then + latest_version=$num_version + fi +done + +VERSION=${VERSION[@]:1} +VERSION_MAJOR=(${VERSION//./ }) +VERSION_MAJOR=${VERSION_MAJOR[0]} +if [[ $VERSION_MAJOR -gt $latest_version ]]; then + echo "MAJOR=1" >> $GITHUB_ENV +fi \ No newline at end of file diff --git a/scripts/empty_upgrade_handler_gen.sh b/scripts/empty_upgrade_handler_gen.sh new file mode 100755 index 00000000000..1ca78fcbcab --- /dev/null +++ b/scripts/empty_upgrade_handler_gen.sh @@ -0,0 +1,92 @@ +#!/bin/bash + +# 1) this script creates an empty directory in app/upgrades called "vX" where X is a previous version + 1 with an empty upgrade handler. +# 2) increases E2E_UPGRADE_VERSION in makefile by 1 +# 3) adds new version to app.go + +# Also insures that all the imports make use of a current module version from go mod: +# (see: module=$(go mod edit -json | jq ".Module.Path") in this script) +# Github workflow which calls this script can be found here: osmosis/.github/workflows/auto-update-upgrade.yml + + latest_version=0 + for f in app/upgrades/*; do + s_f=(${f//// }) + version=${s_f[2]} + num_version=${version//[!0-9]/} + if [[ $num_version -gt $latest_version ]]; then + LATEST_FILE=$f + latest_version=$num_version + fi + done + version_create=$((latest_version+1)) + new_file=./app/upgrades/v${version_create} + + mkdir $new_file + CONSTANTS_FILE=$new_file/constants.go + UPGRADES_FILE=$new_file/upgrades.go + touch $CONSTANTS_FILE + touch $UPGRADES_FILE + + module=$(go mod edit -json | jq ".Module.Path") + module=${module%?} + path=${module%???} + + bracks='"' + # set packages + echo -e "package v${version_create}\n" >> $CONSTANTS_FILE + echo -e "package v${version_create}\n" >> $UPGRADES_FILE + + # imports + echo "import (" >> $CONSTANTS_FILE + echo "import (" >> $UPGRADES_FILE + + # set imports for constants.go + echo -e "\t$module/app/upgrades$bracks\n" >> $CONSTANTS_FILE + echo -e '\tstore "github.com/cosmos/cosmos-sdk/store/types"' >> $CONSTANTS_FILE + + # set imports for upgrades.go + echo -e '\tsdk "github.com/cosmos/cosmos-sdk/types"' >> $UPGRADES_FILE + echo -e '\t"github.com/cosmos/cosmos-sdk/types/module"' >> $UPGRADES_FILE + echo -e '\tupgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"\n' >> $UPGRADES_FILE + echo -e "\t$module/app/keepers$bracks" >> $UPGRADES_FILE + echo -e "\t$module/app/upgrades$bracks" >> $UPGRADES_FILE + + # close import + echo ")" >> $UPGRADES_FILE + echo -e ")\n" >> $CONSTANTS_FILE + + # constants.go logic + echo "// UpgradeName defines the on-chain upgrade name for the Osmosis v$version_create upgrade." >> $CONSTANTS_FILE + echo "const UpgradeName = ${bracks}v$version_create$bracks" >> $CONSTANTS_FILE + echo " +var Upgrade = upgrades.Upgrade{ + UpgradeName: UpgradeName, + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: store.StoreUpgrades{}, +}" >> $CONSTANTS_FILE + + # upgrades.go logic + echo " +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + bpm upgrades.BaseAppParamManager, + keepers *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { + return mm.RunMigrations(ctx, configurator, fromVM) + } +}" >> $UPGRADES_FILE + + # change app/app.go file + app_file=./app/app.go + UPGRADES_LINE=$(grep -F upgrades.Upgrade{ $app_file) + UPGRADES_LINE="${UPGRADES_LINE%?}, v${version_create}.Upgrade}" + sed -i "s|.*upgrades.Upgrade{.*|$UPGRADES_LINE|" $app_file + + PREV_IMPORT="v$latest_version $module/app/upgrades/v$latest_version$bracks" + NEW_IMPORT="v$version_create $module/app/upgrades/v$version_create$bracks" + sed -i "s|.*$PREV_IMPORT.*|\t$PREV_IMPORT\n\t$NEW_IMPORT|" $app_file + + # change e2e version in makefile + sed -i "s/E2E_UPGRADE_VERSION := ${bracks}v$latest_version$bracks/E2E_UPGRADE_VERSION := ${bracks}v$version_create$bracks/" ./Makefile \ No newline at end of file diff --git a/tests/e2e/configurer/chain/commands.go b/tests/e2e/configurer/chain/commands.go index 7879d2e0c8a..4a37d2c8ec4 100644 --- a/tests/e2e/configurer/chain/commands.go +++ b/tests/e2e/configurer/chain/commands.go @@ -105,7 +105,7 @@ func (n *NodeConfig) FailIBCTransfer(from, recipient, amount string) { cmd := []string{"osmosisd", "tx", "ibc-transfer", "transfer", "transfer", "channel-0", recipient, amount, fmt.Sprintf("--from=%s", from)} - _, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "rate limit exceeded") + _, _, err := n.containerManager.ExecTxCmdWithSuccessString(n.t, n.chainId, n.Name, cmd, "Rate Limit exceeded") require.NoError(n.t, err) n.LogActionF("Failed to send IBC transfer (as expected)") diff --git a/tests/e2e/containers/config.go b/tests/e2e/containers/config.go index 0c223477132..03f3503b5ba 100644 --- a/tests/e2e/containers/config.go +++ b/tests/e2e/containers/config.go @@ -24,10 +24,10 @@ const ( // It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset // for this functionality to be used. previousVersionOsmoRepository = "osmolabs/osmosis" - previousVersionOsmoTag = "12.1" + previousVersionOsmoTag = "12.2" // Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion) previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain" - previousVersionInitTag = "v12.1.0-e2e-v1" + previousVersionInitTag = "v12.2.0" // Hermes repo/version for relayer relayerRepository = "osmolabs/hermes" relayerTag = "0.13.0" diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 774763c13a3..567441cd3c9 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package e2e import ( @@ -15,6 +12,8 @@ import ( ) const ( + // Environment variable signifying whether to run e2e tests. + e2eEnabledEnv = "OSMOSIS_E2E" // Environment variable name to skip the upgrade tests skipUpgradeEnv = "OSMOSIS_E2E_SKIP_UPGRADE" // Environment variable name to skip the IBC tests @@ -40,6 +39,10 @@ type IntegrationTestSuite struct { } func TestIntegrationTestSuite(t *testing.T) { + isEnabled := os.Getenv(e2eEnabledEnv) + if isEnabled != "True" { + t.Skip(fmt.Sprintf("e2e test is disabled. To run, set %s to True", e2eEnabledEnv)) + } suite.Run(t, new(IntegrationTestSuite)) } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 43bcb62ac3c..47840e8d91c 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -1,15 +1,18 @@ -//go:build e2e -// +build e2e - package e2e import ( + "encoding/json" "fmt" + "io" "os" "path/filepath" "strconv" "time" + paramsutils "github.com/cosmos/cosmos-sdk/x/params/client/utils" + + ibcratelimittypes "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + sdk "github.com/cosmos/cosmos-sdk/types" coretypes "github.com/tendermint/tendermint/rpc/core/types" @@ -110,6 +113,124 @@ func (s *IntegrationTestSuite) TestSuperfluidVoting() { ) } +// Copy a file from A to B with io.Copy +func copyFile(a, b string) error { + source, err := os.Open(a) + if err != nil { + return err + } + defer source.Close() + destination, err := os.Create(b) + if err != nil { + return err + } + defer destination.Close() + _, err = io.Copy(destination, source) + if err != nil { + return err + } + return nil +} + +func (s *IntegrationTestSuite) TestIBCTokenTransferRateLimiting() { + if s.skipIBC { + s.T().Skip("Skipping IBC tests") + } + chainA := s.configurer.GetChainConfig(0) + chainB := s.configurer.GetChainConfig(1) + + node, err := chainA.GetDefaultNode() + s.NoError(err) + + supply, err := node.QueryTotalSupply() + s.NoError(err) + osmoSupply := supply.AmountOf("uosmo") + + // balance, err := node.QueryBalances(chainA.NodeConfigs[1].PublicAddress) + // s.NoError(err) + + f, err := osmoSupply.ToDec().Float64() + s.NoError(err) + + over := f * 0.02 + + // Sending >1% + chainA.SendIBC(chainB, chainB.NodeConfigs[0].PublicAddress, sdk.NewInt64Coin(initialization.OsmoDenom, int64(over))) + + // copy the contract from x/rate-limit/testdata/ + wd, err := os.Getwd() + s.NoError(err) + // co up two levels + projectDir := filepath.Dir(filepath.Dir(wd)) + fmt.Println(wd, projectDir) + err = copyFile(projectDir+"/x/ibc-rate-limit/bytecode/rate_limiter.wasm", wd+"/scripts/rate_limiter.wasm") + s.NoError(err) + node.StoreWasmCode("rate_limiter.wasm", initialization.ValidatorWalletName) + chainA.LatestCodeId += 1 + node.InstantiateWasmContract( + strconv.Itoa(chainA.LatestCodeId), + fmt.Sprintf(`{"gov_module": "%s", "ibc_module": "%s", "paths": [{"channel_id": "channel-0", "denom": "%s", "quotas": [{"name":"testQuota", "duration": 86400, "send_recv": [1, 1]}] } ] }`, node.PublicAddress, node.PublicAddress, initialization.OsmoToken.Denom), + initialization.ValidatorWalletName) + + // Using code_id 1 because this is the only contract right now. This may need to change if more contracts are added + contracts, err := node.QueryContractsFromId(chainA.LatestCodeId) + s.NoError(err) + s.Require().Len(contracts, 1, "Wrong number of contracts for the rate limiter") + + proposal := paramsutils.ParamChangeProposalJSON{ + Title: "Param Change", + Description: "Changing the rate limit contract param", + Changes: paramsutils.ParamChangesJSON{ + paramsutils.ParamChangeJSON{ + Subspace: ibcratelimittypes.ModuleName, + Key: "contract", + Value: []byte(fmt.Sprintf(`"%s"`, contracts[0])), + }, + }, + Deposit: "625000000uosmo", + } + proposalJson, err := json.Marshal(proposal) + s.NoError(err) + + node.SubmitParamChangeProposal(string(proposalJson), initialization.ValidatorWalletName) + chainA.LatestProposalNumber += 1 + + for _, n := range chainA.NodeConfigs { + n.VoteYesProposal(initialization.ValidatorWalletName, chainA.LatestProposalNumber) + } + + // The value is returned as a string, so we have to unmarshal twice + type Params struct { + Key string `json:"key"` + Subspace string `json:"subspace"` + Value string `json:"value"` + } + + s.Eventually( + func() bool { + var params Params + node.QueryParams(ibcratelimittypes.ModuleName, "contract", ¶ms) + var val string + err := json.Unmarshal([]byte(params.Value), &val) + if err != nil { + return false + } + return val != "" + }, + 1*time.Minute, + 10*time.Millisecond, + "Osmosis node failed to retrieve params", + ) + + // Sending <1%. Should work + chainA.SendIBC(chainB, chainB.NodeConfigs[0].PublicAddress, sdk.NewInt64Coin(initialization.OsmoDenom, 1)) + // Sending >1%. Should fail + node.FailIBCTransfer(initialization.ValidatorWalletName, chainB.NodeConfigs[0].PublicAddress, fmt.Sprintf("%duosmo", int(over))) + + // Removing the rate limit so it doesn't affect other tests + node.WasmExecute(contracts[0], `{"remove_path": {"channel_id": "channel-0", "denom": "uosmo"}}`, initialization.ValidatorWalletName) +} + // TestAddToExistingLockPostUpgrade ensures addToExistingLock works for locks created preupgrade. func (s *IntegrationTestSuite) TestAddToExistingLockPostUpgrade() { if s.skipUpgrade { @@ -401,7 +522,7 @@ func (s *IntegrationTestSuite) TestStateSync() { // start the state synchin node. err = stateSynchingNode.Run() - s.NoError(err) + s.Require().NoError(err) // ensure that the state synching node cathes up to the running node. s.Require().Eventually(func() bool { @@ -417,7 +538,7 @@ func (s *IntegrationTestSuite) TestStateSync() { // stop the state synching node. err = chainA.RemoveNode(stateSynchingNode.Name) - s.NoError(err) + s.Require().NoError(err) } func (s *IntegrationTestSuite) TestExpeditedProposals() { diff --git a/tests/e2e/initialization/init_test.go b/tests/e2e/initialization/init_test.go index cc8cb8d2c95..7ff20a0e9b2 100644 --- a/tests/e2e/initialization/init_test.go +++ b/tests/e2e/initialization/init_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package initialization_test import ( diff --git a/x/ibc-rate-limit/README.md b/x/ibc-rate-limit/README.md index f9a91cb8c1c..22a41d3d7f9 100644 --- a/x/ibc-rate-limit/README.md +++ b/x/ibc-rate-limit/README.md @@ -1,26 +1,119 @@ -# # IBC Rate Limit +# IBC Rate Limit -The ``IBC Rate Limit`` middleware implements an [IBC Middleware](https://github.com/cosmos/ibc-go/blob/f57170b1d4dd202a3c6c1c61dcf302b6a9546405/docs/ibc/middleware/develop.md) -that wraps a [transfer](https://ibc.cosmos.network/main/apps/transfer/overview.html) app to regulate how much value can -flow in and out of the chain for a specific denom and channel. +The IBC Rate Limit module is responsible for adding a governance-configurable rate limit to IBC transfers. +This is a safety control, intended to protect assets on osmosis in event of: -## Contents +* a bug/hack on osmosis +* a bug/hack on the counter-party chain +* a bug/hack in IBC itself -1. **[Concepts](#concepts)** -2. **[Parameters](#parameters)** -3. **[Contract](#contract)** -4. **[Integration](#integration)** +This is done in exchange for a potential (one-way) bridge liveness tradeoff, in periods of high deposits or withdrawals. -## Concepts +The architecture of this package is a minimal go package which implements an [IBC Middleware](https://github.com/cosmos/ibc-go/blob/f57170b1d4dd202a3c6c1c61dcf302b6a9546405/docs/ibc/middleware/develop.md) that wraps the [ICS20 transfer](https://ibc.cosmos.network/main/apps/transfer/overview.html) app, and calls into a cosmwasm contract. +The cosmwasm contract then has all of the actual IBC rate limiting logic. +The Cosmwasm code can be found in the [`contracts`](./contracts/) package, with bytecode findable in the [`bytecode`](./bytecode/) folder. The cosmwasm VM usage allows Osmosis chain governance to choose to change this safety control with no hard forks, via a parameter change proposal, a great mitigation for faster threat adaptavity. -### Overview +The status of the module is being in a state suitable for some initial governance settable rate limits for high value bridged assets. +Its not in its long term / end state for all channels by any means, but does act as a strong protection we +can instantiate today for high value IBC connections. -The `x/ibc-rate-limit` module implements an IBC middleware and a transfer app wrapper. The middleware checks if the -amount of value of a specific denom transferred through a channel has exceeded a quota defined by governance for -that channel/denom. These checks are handled through a CosmWasm contract. The contract to be used for this is -configured via a parameter. +## Motivation -### Middleware +The motivation of IBC-rate-limit comes from the empirical observations of blockchain bridge hacks that a rate limit would have massively reduced the stolen amount of assets in: + +- [Polynetwork Bridge Hack ($611 million)](https://rekt.news/polynetwork-rekt/) +- [BNB Bridge Hack ($586 million)](https://rekt.news/bnb-bridge-rekt/) +- [Wormhole Bridge Hack ($326 million)](https://rekt.news/wormhole-rekt/) +- [Nomad Bridge Hack ($190 million)](https://rekt.news/nomad-rekt/) +- [Harmony Bridge Hack ($100 million)](https://rekt.news/harmony-rekt/) - (Would require rate limit + monitoring) +- [Dragonberry IBC bug](https://forum.cosmos.network/t/ibc-security-advisory-dragonberry/7702) (can't yet disclose amount at risk, but was saved due to being found first by altruistic Osmosis core developers) + +In the presence of a software bug on Osmosis, IBC itself, or on a counterparty chain, we would like to prevent the bridge from being fully depegged. +This stems from the idea that a 30% asset depeg is ~infinitely better than a 100% depeg. +Its _crazy_ that today these complex bridged assets can instantly go to 0 in event of bug. +The goal of a rate limit is to raise an alert that something has potentially gone wrong, allowing validators and developers to have time to analyze, react, and protect larger portions of user funds. + +The thesis of this is that, it is worthwile to sacrifice liveness in the case of legitimate demand to send extreme amounts of funds, to prevent the terrible long-tail full fund risks. +Rate limits aren't the end-all of safety controls, they're merely the simplest automated one. More should be explored and added onto IBC! + +## Rate limit types + +We express rate limits in time-based periods. +This means, we set rate limits for (say) 6-hour, daily, and weekly intervals. +The rate limit for a given time period stores the relevant amount of assets at the start of the rate limit. +Rate limits are then defined on percentage terms of the asset. +The time windows for rate limits are currently _not_ rolling, they have discrete start/end times. + +We allow setting separate rate limits for the inflow and outflow of assets. +We do all of our rate limits based on the _net flow_ of assets on a channel pair. This prevents DOS issues, of someone repeatedly sending assets back and forth, to trigger rate limits and break liveness. + +We currently envision creating two kinds of rate limits: + +* Per denomination rate limits + - allows safety statements like "Only 30% of Stars on Osmosis can flow out in one day" or "The amount of Atom on Osmosis can at most double per day". +* Per channel rate limits + - Limit the total inflow and outflow on a given IBC channel, based on "USDC" equivalent, using Osmosis as the price oracle. + +We currently only implement per denomination rate limits for non-native assets. We do not yet implement channel based rate limits. + +Currently these rate limits automatically "expire" at the end of the quota duration. TODO: Think of better designs here. E.g. can we have a constant number of subsequent quotas start filled? Or perhaps harmonically decreasing amounts of next few quotas pre-filled? Halted until DAO override seems not-great. + +## Instantiating rate limits + +Today all rate limit quotas must be set manually by governance. +In the future, we should design towards some conservative rate limit to add as a safety-backstop automatically for channels. +Ideas for how this could look: + +* One month after a channel has been created, automatically add in some USDC-based rate limit +* One month after governance incentivizes an asset, add on a per-denomination rate limit. + +Definitely needs far more ideation and iteration! + +## Parameterizing the rate limit + +One element is we don't want any rate limit timespan thats too short, e.g. not enough time for humans to react to. So we wouldn't want a 1 hour rate limit, unless we think that if its hit, it could be assessed within an hour. + +### Handling rate limit boundaries + +We want to be safe against the case where say we have a daily rate limit ending at a given time, and an adversary attempts to attack near the boundary window. +We would not like them to be able to "double extract funds" by timing their extraction near a window boundary. + +Admittedly, not a lot of thought has been put into how to deal with this well. +Right now we envision simply handling this by saying if you want a quota of duration D, instead include two quotas of duration D, but offset by `D/2` from each other. + +Ideally we can change windows to be more 'rolling' in the future, to avoid this overhead and more cleanly handle the problem. (Perhaps rolling ~1 hour at a time) + +### Inflow parameterization + +The "Inflow" side of a rate limit is essentially protection against unforeseen bug on a counterparty chain. +This can be quite conservative (e.g. bridged amount doubling in one week). This covers a few cases: + +* Counter-party chain B having a token theft attack + - TODO: description of how this looks +* Counter-party chain B runaway mint + - TODO: description of how this looks +* IBC theft + - TODO: description of how this looks + +It does get more complex when the counterparty chain is itself a DEX, but this is still much more protection than nothing. + +### Outflow parameterization + +The "Outflow" side of a rate limit is protection against a bug on Osmosis OR IBC. +This has potential for much more user-frustrating issues, if set too low. +E.g. if theres some event that causes many people to suddenly withdraw many STARS or many USDC. + +So this parameterization has to contend with being a tradeoff of withdrawal liveness in high volatility periods vs being a crucial safety rail, in event of on-Osmosis bug. + +TODO: Better fill out + +### Example suggested parameterization + +## Code structure + +As mentioned at the beginning of the README, the go code is a relatively minimal ICS 20 wrapper, that dispatches relevant calls to a cosmwasm contract that implements the rate limiting functionality. + +### Go Middleware To achieve this, the middleware needs to implement the `porttypes.Middleware` interface and the `porttypes.ICS4Wrapper` interface. This allows the middleware to send and receive IBC messages by wrapping @@ -28,23 +121,14 @@ any IBC module, and be used as an ICS4 wrapper by a transfer module (for sending Of those interfaces, just the following methods have custom logic: -* `ICS4Wrapper.SendPacket` adds tracking of value sent via an ibc channel -* `Middleware.OnRecvPacket` adds tracking of value received via an ibc channel -* `Middleware.OnAcknowledgementPacket` undos the tracking of a sent packet if the acknowledgment is not a success -* `OnTimeoutPacket` undos the tracking of a sent packet if the packet times out (is not relayed) +* `ICS4Wrapper.SendPacket` forwards to contract, with intent of tracking of value sent via an ibc channel +* `Middleware.OnRecvPacket` forwards to contract, with intent of tracking of value received via an ibc channel +* `Middleware.OnAcknowledgementPacket` forwards to contract, with intent of undoing the tracking of a sent packet if the acknowledgment is not a success +* `OnTimeoutPacket` forwards to contract, with intent of undoing the tracking of a sent packet if the packet times out (is not relayed) All other methods from those interfaces are passthroughs to the underlying implementations. -### Contract Concepts - -The tracking contract uses the following concepts - -1. **RateLimit** - tracks the value flow transferred and the quota for a path. -2. **Path** - is a (denom, channel) pair. -3. **Flow** - tracks the value that has moved through a path during the current time window. -4. **Quota** - is the percentage of the denom's total value that can be transferred through the path in a given period of time (duration) - -## Parameters +#### Parameters The middleware uses the following parameters: @@ -55,23 +139,45 @@ The middleware uses the following parameters: 1. **ContractAddress** - The contract address is the address of an instantiated version of the contract provided under `./contracts/` -## Contract +### Cosmwasm Contract Concepts + +Something to keep in mind with all of the code, is that we have to reason separately about every item in the following matrix: + +| Native Token | Non-Native Token | +|----------------------|--------------------------| +| Send Native Token | Send Non-Native Token | +| Receive Native Token | Receive Non-Native Token | +| Timeout Native Send | Timeout Non-native Send | -### Messages +(Error ACK can reuse the same code as timeout) + +TODO: Spend more time on sudo messages in the following description. We need to better describe how we map the quota concepts onto the code. +Need to describe how we get the quota beginning balance, and that its different for sends and receives. +Explain intracacies of tracking that a timeout and/or ErrorAck must appear from the same quota, else we ignore its update to the quotas. + + +The tracking contract uses the following concepts + +1. **RateLimit** - tracks the value flow transferred and the quota for a path. +2. **Path** - is a (denom, channel) pair. +3. **Flow** - tracks the value that has moved through a path during the current time window. +4. **Quota** - is the percentage of the denom's total value that can be transferred through the path in a given period of time (duration) + +#### Messages The contract specifies the following messages: -#### Query +##### Query * GetQuotas - Returns the quotas for a path -#### Exec +##### Exec * AddPath - Adds a list of quotas for a path * RemovePath - Removes a path * ResetPathQuota - If a rate limit has been reached, the contract's governance address can reset the quota so that transfers are allowed again -#### Sudo +##### Sudo Sudo messages can only be executed by the chain. @@ -79,7 +185,7 @@ Sudo messages can only be executed by the chain. * RecvPacket - Increments the amount used out of the receive quota and checks that the receive is allowed. If it isn't, it will return a RateLimitExceeded error * UndoSend - If a send has failed, the undo message is used to remove its cost from the send quota -## Integration +### Integration The rate limit middleware wraps the `transferIBCModule` and is added as the entry route for IBC transfers. @@ -87,3 +193,30 @@ The module is also provided to the underlying `transferIBCModule` as its `ICS4Wr pointed to a channel, which also implements the `ICS4Wrapper` interface. This integration can be seen in [osmosis/app/keepers/keepers.go](https://github.com/osmosis-labs/osmosis/blob/main/app/keepers/keepers.go) + +## Testing strategy + +TODO: Fill this out + +## Known Future work + +Items that've been highlighted above: + +* Making automated rate limits get added for channels, instead of manual configuration only +* Improving parameterization strategies / data analysis +* Adding the USDC based rate limits +* We need better strategies for how rate limits "expire". + +Not yet highlighted + +* Making monitoring tooling to know when approaching rate limiting and when they're hit +* Making tooling to easily give us summaries we can use, to reason about "bug or not bug" in event of rate limit being hit +* Enabling ways to pre-declare large transfers so as to not hit rate limits. + * Perhaps you can on-chain declare intent to send these assets with a large delay, that raises monitoring but bypasses rate limits? + * Maybe contract-based tooling to split up the transfer suffices? +* Strategies to account for high volatility periods without hitting rate limits + * Can imagine "Hop network" style markets emerging + * Could imagine tieng it into looking at AMM volatility, or off-chain oracles + * but these are both things we should be wary of security bugs in. + * Maybe [constraint based programming with tracking of provenance](https://youtu.be/HB5TrK7A4pI?t=2852) as a solution +* Analyze changing denom-based rate limits, to just overall withdrawal amount for Osmosis \ No newline at end of file diff --git a/x/ibc-rate-limit/bytecode/rate_limiter.wasm b/x/ibc-rate-limit/bytecode/rate_limiter.wasm new file mode 100644 index 00000000000..e19651209c4 Binary files /dev/null and b/x/ibc-rate-limit/bytecode/rate_limiter.wasm differ diff --git a/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml b/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml index e166d606418..4c78fcf37fb 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml +++ b/x/ibc-rate-limit/contracts/rate-limiter/Cargo.toml @@ -15,17 +15,6 @@ exclude = [ [lib] crate-type = ["cdylib", "rlib"] -[profile.release] -opt-level = 3 -debug = false -rpath = false -lto = true -debug-assertions = false -codegen-units = 1 -panic = 'abort' -incremental = false -overflow-checks = true - [features] # for more explicit tests, cargo test --features=backtraces backtraces = ["cosmwasm-std/backtraces"] @@ -43,8 +32,9 @@ optimize = """docker run --rm -v "$(pwd)":/code \ """ [dependencies] -cosmwasm-std = "1.0.0" -cosmwasm-storage = "1.0.0" +cosmwasm-std = "1.1.0" +cosmwasm-storage = "1.1.0" +cosmwasm-schema = "1.1.0" cw-storage-plus = "0.13.2" cw2 = "0.13.2" schemars = "0.8.8" @@ -52,5 +42,4 @@ serde = { version = "1.0.137", default-features = false, features = ["derive"] } thiserror = { version = "1.0.31" } [dev-dependencies] -cosmwasm-schema = "1.0.0" cw-multi-test = "0.13.2" diff --git a/x/ibc-rate-limit/contracts/rate-limiter/examples/schema.rs b/x/ibc-rate-limit/contracts/rate-limiter/examples/schema.rs new file mode 100644 index 00000000000..954edd462e1 --- /dev/null +++ b/x/ibc-rate-limit/contracts/rate-limiter/examples/schema.rs @@ -0,0 +1,13 @@ +use cosmwasm_schema::write_api; + +use rate_limiter::msg::{ExecuteMsg, InstantiateMsg, MigrateMsg, QueryMsg, SudoMsg}; + +fn main() { + write_api! { + instantiate: InstantiateMsg, + query: QueryMsg, + execute: ExecuteMsg, + sudo: SudoMsg, + migrate: MigrateMsg, + } +} diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs index 3eef38eed8b..fa5b99e49da 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/contract_tests.rs @@ -2,7 +2,7 @@ use crate::{contract::*, ContractError}; use cosmwasm_std::testing::{mock_dependencies, mock_env, mock_info}; -use cosmwasm_std::{from_binary, Addr, Attribute}; +use cosmwasm_std::{from_binary, Addr, Attribute, Uint256}; use crate::helpers::tests::verify_query_response; use crate::msg::{InstantiateMsg, PathMsg, QueryMsg, QuotaMsg, SudoMsg}; @@ -52,8 +52,8 @@ fn consume_allowance() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); @@ -64,8 +64,8 @@ fn consume_allowance() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let err = sudo(deps.as_mut(), mock_env(), msg).unwrap_err(); assert!(matches!(err, ContractError::RateLimitExceded { .. })); @@ -91,14 +91,14 @@ fn symetric_flows_dont_consume_allowance() { let send_msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let recv_msg = SudoMsg::RecvPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_000_u32.into(), + funds: 300_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); @@ -154,8 +154,8 @@ fn asymetric_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 60, + channel_value: 3_060_u32.into(), + funds: 60_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); let Attribute { key, value } = &res.attributes[4]; @@ -166,8 +166,8 @@ fn asymetric_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 60, + channel_value: 3_060_u32.into(), + funds: 60_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), msg).unwrap(); @@ -180,8 +180,8 @@ fn asymetric_quotas() { let recv_msg = SudoMsg::RecvPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 30, + channel_value: 3_000_u32.into(), + funds: 30_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), recv_msg).unwrap(); let Attribute { key, value } = &res.attributes[3]; @@ -195,8 +195,8 @@ fn asymetric_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 60, + channel_value: 3_060_u32.into(), + funds: 60_u32.into(), }; let err = sudo(deps.as_mut(), mock_env(), msg.clone()).unwrap_err(); assert!(matches!(err, ContractError::RateLimitExceded { .. })); @@ -205,8 +205,8 @@ fn asymetric_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 30, + channel_value: 3_060_u32.into(), + funds: 30_u32.into(), }; let res = sudo(deps.as_mut(), mock_env(), msg.clone()).unwrap(); let Attribute { key, value } = &res.attributes[3]; @@ -246,8 +246,8 @@ fn query_state() { assert_eq!(value[0].quota.max_percentage_send, 10); assert_eq!(value[0].quota.max_percentage_recv, 10); assert_eq!(value[0].quota.duration, RESET_TIME_WEEKLY); - assert_eq!(value[0].flow.inflow, 0); - assert_eq!(value[0].flow.outflow, 0); + assert_eq!(value[0].flow.inflow, Uint256::from(0_u32)); + assert_eq!(value[0].flow.outflow, Uint256::from(0_u32)); assert_eq!( value[0].flow.period_end, env.block.time.plus_seconds(RESET_TIME_WEEKLY) @@ -256,16 +256,16 @@ fn query_state() { let send_msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); let recv_msg = SudoMsg::RecvPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 30, + channel_value: 3_000_u32.into(), + funds: 30_u32.into(), }; sudo(deps.as_mut(), mock_env(), recv_msg.clone()).unwrap(); @@ -277,8 +277,8 @@ fn query_state() { "weekly", (10, 10), RESET_TIME_WEEKLY, - 30, - 300, + 30_u32.into(), + 300_u32.into(), env.block.time.plus_seconds(RESET_TIME_WEEKLY), ); } @@ -317,8 +317,8 @@ fn bad_quotas() { "bad_quota", (100, 100), 200, - 0, - 0, + 0_u32.into(), + 0_u32.into(), env.block.time.plus_seconds(200), ); } @@ -343,13 +343,13 @@ fn undo_send() { let send_msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let undo_msg = SudoMsg::UndoSend { channel_id: format!("channel"), denom: format!("denom"), - funds: 300, + funds: 300_u32.into(), }; sudo(deps.as_mut(), mock_env(), send_msg.clone()).unwrap(); @@ -357,7 +357,10 @@ fn undo_send() { let trackers = RATE_LIMIT_TRACKERS .load(&deps.storage, ("channel".to_string(), "denom".to_string())) .unwrap(); - assert_eq!(trackers.first().unwrap().flow.outflow, 300); + assert_eq!( + trackers.first().unwrap().flow.outflow, + Uint256::from(300_u32) + ); let period_end = trackers.first().unwrap().flow.period_end; let channel_value = trackers.first().unwrap().quota.channel_value; @@ -366,7 +369,7 @@ fn undo_send() { let trackers = RATE_LIMIT_TRACKERS .load(&deps.storage, ("channel".to_string(), "denom".to_string())) .unwrap(); - assert_eq!(trackers.first().unwrap().flow.outflow, 0); + assert_eq!(trackers.first().unwrap().flow.outflow, Uint256::from(0_u32)); assert_eq!(trackers.first().unwrap().flow.period_end, period_end); assert_eq!(trackers.first().unwrap().quota.channel_value, channel_value); } diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs index dc40f708d1c..367180baf59 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/error.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{StdError, Timestamp}; +use cosmwasm_std::{StdError, Timestamp, Uint256}; use thiserror::Error; #[derive(Error, Debug)] @@ -9,10 +9,14 @@ pub enum ContractError { #[error("Unauthorized")] Unauthorized {}, - #[error("IBC Rate Limit exceded for channel {channel:?} and denom {denom:?}. Try again after {reset:?}")] + #[error("IBC Rate Limit exceeded for {channel}/{denom}. Tried to transfer {amount} which exceeds capacity on the '{quota_name}' quota ({used}/{max}). Try again after {reset:?}")] RateLimitExceded { channel: String, denom: String, + amount: Uint256, + quota_name: String, + used: Uint256, + max: Uint256, reset: Timestamp, }, diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/execute.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/execute.rs index 4bac4c0d37f..047a2179dd0 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/execute.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/execute.rs @@ -159,8 +159,8 @@ mod tests { "daily", (3, 5), 1600, - 0, - 0, + 0_u32.into(), + 0_u32.into(), env.block.time.plus_seconds(1600), ); @@ -208,8 +208,8 @@ mod tests { "daily", (3, 5), 1600, - 0, - 0, + 0_u32.into(), + 0_u32.into(), env.block.time.plus_seconds(1600), ); @@ -241,8 +241,8 @@ mod tests { "different", (50, 30), 5000, - 0, - 0, + 0_u32.into(), + 0_u32.into(), env.block.time.plus_seconds(5000), ); } diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/helpers.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/helpers.rs index 6cfd60a65a8..530d3b6cf2d 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/helpers.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/helpers.rs @@ -37,7 +37,7 @@ impl RateLimitingContract { } pub mod tests { - use cosmwasm_std::Timestamp; + use cosmwasm_std::{Timestamp, Uint256}; use crate::state::RateLimit; @@ -46,8 +46,8 @@ pub mod tests { quota_name: &str, send_recv: (u32, u32), duration: u64, - inflow: u128, - outflow: u128, + inflow: Uint256, + outflow: Uint256, period_end: Timestamp, ) { assert_eq!(value.quota.name, quota_name); diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs index 8807028fcb9..d5d76acb0e8 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/integration_tests.rs @@ -42,7 +42,7 @@ fn mock_app() -> App { // Instantiate the contract fn proper_instantiate(paths: Vec) -> (App, RateLimitingContract) { let mut app = mock_app(); - let cw_template_id = app.store_code(contract_template()); + let cw_code_id = app.store_code(contract_template()); let msg = InstantiateMsg { gov_module: Addr::unchecked(GOV_ADDR), @@ -52,7 +52,7 @@ fn proper_instantiate(paths: Vec) -> (App, RateLimitingContract) { let cw_rate_limit_contract_addr = app .instantiate_contract( - cw_template_id, + cw_code_id, Addr::unchecked(GOV_ADDR), &msg, &[], @@ -82,8 +82,8 @@ fn expiration() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); let res = app.sudo(cosmos_msg).unwrap(); @@ -105,8 +105,8 @@ fn expiration() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); let _err = app.sudo(cosmos_msg).unwrap_err(); @@ -123,8 +123,8 @@ fn expiration() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_300_u32.into(), + funds: 300_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); @@ -162,8 +162,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -172,8 +172,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -188,8 +188,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); @@ -207,8 +207,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -224,8 +224,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -240,8 +240,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -257,8 +257,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -272,8 +272,8 @@ fn multiple_quotas() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 101_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -296,8 +296,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 1, + channel_value: 100_u32.into(), + funds: 1_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap(); @@ -306,8 +306,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100, - funds: 3, + channel_value: 100_u32.into(), + funds: 3_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -316,8 +316,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 100000, - funds: 3, + channel_value: 100000_u32.into(), + funds: 3_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); app.sudo(cosmos_msg).unwrap_err(); @@ -336,8 +336,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 10_000, - funds: 100, + channel_value: 10_000_u32.into(), + funds: 100_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); @@ -353,8 +353,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 10_000, - funds: 100, + channel_value: 10_000_u32.into(), + funds: 100_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); @@ -364,8 +364,8 @@ fn channel_value_cached() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 1, - funds: 75, + channel_value: 1_u32.into(), + funds: 75_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg); @@ -380,8 +380,8 @@ fn add_paths_later() { let msg = SudoMsg::SendPacket { channel_id: format!("channel"), denom: format!("denom"), - channel_value: 3_000, - funds: 300, + channel_value: 3_000_u32.into(), + funds: 300_u32.into(), }; let cosmos_msg = cw_rate_limit_contract.sudo(msg.clone()); let res = app.sudo(cosmos_msg).unwrap(); diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs index 7ae027efd25..0f1f0c4b061 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/msg.rs @@ -1,4 +1,5 @@ -use cosmwasm_std::Addr; +use cosmwasm_schema::{cw_serde, QueryResponses}; +use cosmwasm_std::{Addr, Uint256}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; @@ -44,7 +45,7 @@ impl QuotaMsg { /// Initialize the contract with the address of the IBC module and any existing channels. /// Only the ibc module is allowed to execute actions on this contract -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] +#[cw_serde] pub struct InstantiateMsg { pub gov_module: Addr, pub ibc_module: Addr, @@ -53,8 +54,7 @@ pub struct InstantiateMsg { /// The caller (IBC module) is responsible for correctly calculating the funds /// being sent through the channel -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum ExecuteMsg { AddPath { channel_id: String, @@ -72,34 +72,33 @@ pub enum ExecuteMsg { }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] +#[derive(QueryResponses)] pub enum QueryMsg { + #[returns(Vec)] GetQuotas { channel_id: String, denom: String }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum SudoMsg { SendPacket { channel_id: String, denom: String, - channel_value: u128, - funds: u128, + channel_value: Uint256, + funds: Uint256, }, RecvPacket { channel_id: String, denom: String, - channel_value: u128, - funds: u128, + channel_value: Uint256, + funds: Uint256, }, UndoSend { channel_id: String, denom: String, - funds: u128, + funds: Uint256, }, } -#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)] -#[serde(rename_all = "snake_case")] +#[cw_serde] pub enum MigrateMsg {} diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs new file mode 100644 index 00000000000..6bc5b8cfed1 --- /dev/null +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/packet.rs @@ -0,0 +1,64 @@ +use cosmwasm_std::{Addr, Deps, Timestamp}; +use serde::{Deserialize, Serialize}; + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +pub struct Height { + /// Previously known as "epoch" + revision_number: Option, + + /// The height of a block + revision_height: Option, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +pub struct FungibleTokenData { + denom: String, + amount: u128, + sender: Addr, + receiver: Addr, +} + +#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] +pub struct Packet { + pub sequence: u64, + pub source_port: String, + pub source_channel: String, + pub destination_port: String, + pub destination_channel: String, + pub data: FungibleTokenData, + pub timeout_height: Height, + pub timeout_timestamp: Option, +} + +impl Packet { + pub fn channel_value(&self, _deps: Deps) -> u128 { + // let balance = deps.querier.query_all_balances("address", self.data.denom); + // deps.querier.sup + return 125000000000011250 * 2; + } + + pub fn get_funds(&self) -> u128 { + return self.data.amount; + } + + fn local_channel(&self) -> String { + // Pick the appropriate channel depending on whether this is a send or a recv + return self.destination_channel.clone(); + } + + fn local_demom(&self) -> String { + // This should actually convert the denom from the packet to the osmosis denom, but for now, just returning this + return self.data.denom.clone(); + } + + pub fn path_data(&self) -> (String, String) { + let denom = self.local_demom(); + let channel = if denom.starts_with("ibc/") { + self.local_channel() + } else { + "any".to_string() // native tokens are rate limited globally + }; + + return (channel, denom); + } +} diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs index 8dc5f9fa2f6..e28fc1004b7 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/state.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{Addr, Timestamp}; +use cosmwasm_std::{Addr, Timestamp, Uint256}; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::cmp; @@ -62,16 +62,15 @@ pub enum FlowType { /// This is a design decision to avoid the period calculations and thus reduce gas consumption #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Copy)] pub struct Flow { - // Q: Do we have edge case issues with inflow/outflow being u128, e.g. what if a token has super high precision. - pub inflow: u128, - pub outflow: u128, + pub inflow: Uint256, + pub outflow: Uint256, pub period_end: Timestamp, } impl Flow { pub fn new( - inflow: impl Into, - outflow: impl Into, + inflow: impl Into, + outflow: impl Into, now: Timestamp, duration: u64, ) -> Self { @@ -87,7 +86,7 @@ impl Flow { /// (balance_in, balance_out) where balance_in in is how much has been /// transferred into the flow, and balance_out is how much value transferred /// out. - pub fn balance(&self) -> (u128, u128) { + pub fn balance(&self) -> (Uint256, Uint256) { ( self.inflow.saturating_sub(self.outflow), self.outflow.saturating_sub(self.inflow), @@ -95,7 +94,7 @@ impl Flow { } /// checks if the flow, in the current state, has exceeded a max allowance - pub fn exceeds(&self, direction: &FlowType, max_inflow: u128, max_outflow: u128) -> bool { + pub fn exceeds(&self, direction: &FlowType, max_inflow: Uint256, max_outflow: Uint256) -> bool { let (balance_in, balance_out) = self.balance(); match direction { FlowType::In => balance_in > max_inflow, @@ -103,6 +102,15 @@ impl Flow { } } + /// returns the balance in a direction. This is used for displaying cleaner errors + pub fn balance_on(&self, direction: &FlowType) -> Uint256 { + let (balance_in, balance_out) = self.balance(); + match direction { + FlowType::In => balance_in, + FlowType::Out => balance_out, + } + } + /// If now is greater than the period_end, the Flow is considered expired. pub fn is_expired(&self, now: Timestamp) -> bool { self.period_end < now @@ -113,13 +121,13 @@ impl Flow { /// Expire resets the Flow to start tracking the value transfer from the /// moment this method is called. pub fn expire(&mut self, now: Timestamp, duration: u64) { - self.inflow = 0; - self.outflow = 0; + self.inflow = Uint256::from(0_u32); + self.outflow = Uint256::from(0_u32); self.period_end = now.plus_seconds(duration); } /// Updates the current flow incrementing it by a transfer of value. - pub fn add_flow(&mut self, direction: FlowType, value: u128) { + pub fn add_flow(&mut self, direction: FlowType, value: Uint256) { match direction { FlowType::In => self.inflow = self.inflow.saturating_add(value), FlowType::Out => self.outflow = self.outflow.saturating_add(value), @@ -127,7 +135,7 @@ impl Flow { } /// Updates the current flow reducing it by a transfer of value. - pub fn undo_flow(&mut self, direction: FlowType, value: u128) { + pub fn undo_flow(&mut self, direction: FlowType, value: Uint256) { match direction { FlowType::In => self.inflow = self.inflow.saturating_sub(value), FlowType::Out => self.outflow = self.outflow.saturating_sub(value), @@ -139,7 +147,7 @@ impl Flow { fn apply_transfer( &mut self, direction: &FlowType, - funds: u128, + funds: Uint256, now: Timestamp, quota: &Quota, ) -> bool { @@ -166,7 +174,7 @@ pub struct Quota { pub max_percentage_send: u32, pub max_percentage_recv: u32, pub duration: u64, - pub channel_value: Option, + pub channel_value: Option, } impl Quota { @@ -174,13 +182,22 @@ impl Quota { /// total_value) in each direction based on the total value of the denom in /// the channel. The result tuple represents the max capacity when the /// transfer is in directions: (FlowType::In, FlowType::Out) - pub fn capacity(&self) -> (u128, u128) { + pub fn capacity(&self) -> (Uint256, Uint256) { match self.channel_value { Some(total_value) => ( - total_value * (self.max_percentage_recv as u128) / 100_u128, - total_value * (self.max_percentage_send as u128) / 100_u128, + total_value * Uint256::from(self.max_percentage_recv) / Uint256::from(100_u32), + total_value * Uint256::from(self.max_percentage_send) / Uint256::from(100_u32), ), - None => (0, 0), // This should never happen, but ig the channel value is not set, we disallow any transfer + None => (0_u32.into(), 0_u32.into()), // This should never happen, but ig the channel value is not set, we disallow any transfer + } + } + + /// returns the capacity in a direction. This is used for displaying cleaner errors + pub fn capacity_on(&self, direction: &FlowType) -> Uint256 { + let (max_in, max_out) = self.capacity(); + match direction { + FlowType::In => max_in, + FlowType::Out => max_out, } } } @@ -210,6 +227,29 @@ pub struct RateLimit { pub flow: Flow, } +// The channel value on send depends on the amount on escrow. The ibc transfer +// module modifies the escrow amount by "funds" on sends before calling the +// contract. This function takes that into account so that the channel value +// that we track matches the channel value at the moment when the ibc +// transaction started executing +fn calculate_channel_value( + channel_value: Uint256, + denom: &str, + funds: Uint256, + direction: &FlowType, +) -> Uint256 { + match direction { + FlowType::Out => { + if denom.contains("ibc") { + channel_value + funds // Non-Native tokens get removed from the supply on send. Add that amount back + } else { + channel_value - funds // Native tokens increase escrow amount on send. Remove that amount here + } + } + FlowType::In => channel_value, + } +} + impl RateLimit { /// Checks if a transfer is allowed and updates the data structures /// accordingly. @@ -221,14 +261,26 @@ impl RateLimit { &mut self, path: &Path, direction: &FlowType, - funds: u128, - channel_value: u128, + funds: Uint256, + channel_value: Uint256, now: Timestamp, ) -> Result { + // Flow used before this transaction is applied. + // This is used to make error messages more informative + let initial_flow = self.flow.balance_on(direction); + + // Apply the transfer. From here on, we will updated the flow with the new transfer + // and check if it exceeds the quota at the current time + let expired = self.flow.apply_transfer(direction, funds, now, &self.quota); // Cache the channel value if it has never been set or it has expired. if self.quota.channel_value.is_none() || expired { - self.quota.channel_value = Some(channel_value) + self.quota.channel_value = Some(calculate_channel_value( + channel_value, + &path.denom, + funds, + direction, + )) } let (max_in, max_out) = self.quota.capacity(); @@ -237,6 +289,10 @@ impl RateLimit { true => Err(ContractError::RateLimitExceded { channel: path.channel.to_string(), denom: path.denom.to_string(), + amount: funds, + quota_name: self.quota.name.to_string(), + used: initial_flow, + max: self.quota.capacity_on(direction), reset: self.flow.period_end, }), false => Ok(RateLimit { @@ -292,18 +348,18 @@ pub mod tests { assert!(!flow.is_expired(epoch.plus_seconds(RESET_TIME_WEEKLY))); assert!(flow.is_expired(epoch.plus_seconds(RESET_TIME_WEEKLY).plus_nanos(1))); - assert_eq!(flow.balance(), (0_u128, 0_u128)); - flow.add_flow(FlowType::In, 5); - assert_eq!(flow.balance(), (5_u128, 0_u128)); - flow.add_flow(FlowType::Out, 2); - assert_eq!(flow.balance(), (3_u128, 0_u128)); + assert_eq!(flow.balance(), (0_u32.into(), 0_u32.into())); + flow.add_flow(FlowType::In, 5_u32.into()); + assert_eq!(flow.balance(), (5_u32.into(), 0_u32.into())); + flow.add_flow(FlowType::Out, 2_u32.into()); + assert_eq!(flow.balance(), (3_u32.into(), 0_u32.into())); // Adding flow doesn't affect expiration assert!(!flow.is_expired(epoch.plus_seconds(RESET_TIME_DAILY))); flow.expire(epoch.plus_seconds(RESET_TIME_WEEKLY), RESET_TIME_WEEKLY); - assert_eq!(flow.balance(), (0_u128, 0_u128)); - assert_eq!(flow.inflow, 0_u128); - assert_eq!(flow.outflow, 0_u128); + assert_eq!(flow.balance(), (0_u32.into(), 0_u32.into())); + assert_eq!(flow.inflow, Uint256::from(0_u32)); + assert_eq!(flow.outflow, Uint256::from(0_u32)); assert_eq!(flow.period_end, epoch.plus_seconds(RESET_TIME_WEEKLY * 2)); // Expiration has moved diff --git a/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs b/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs index 8315a01fcf8..0a8ae8e5161 100644 --- a/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs +++ b/x/ibc-rate-limit/contracts/rate-limiter/src/sudo.rs @@ -1,4 +1,4 @@ -use cosmwasm_std::{DepsMut, Response, Timestamp}; +use cosmwasm_std::{DepsMut, Response, Timestamp, Uint256}; use crate::{ state::{FlowType, Path, RateLimit, RATE_LIMIT_TRACKERS}, @@ -14,8 +14,8 @@ use crate::{ pub fn try_transfer( deps: DepsMut, path: &Path, - channel_value: u128, - funds: u128, + channel_value: Uint256, + funds: Uint256, direction: FlowType, now: Timestamp, ) -> Result { @@ -96,7 +96,7 @@ fn add_rate_limit_attributes(response: Response, result: &RateLimit) -> Response // This function manually injects an inflow. This is used when reverting a // packet that failed ack or timed-out. -pub fn undo_send(deps: DepsMut, path: &Path, funds: u128) -> Result { +pub fn undo_send(deps: DepsMut, path: &Path, funds: Uint256) -> Result { // Sudo call. Only go modules should be allowed to access this let trackers = RATE_LIMIT_TRACKERS.may_load(deps.storage, path.into())?; diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go new file mode 100644 index 00000000000..497916d8b1a --- /dev/null +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -0,0 +1,462 @@ +package ibc_rate_limit_test + +import ( + "encoding/json" + "fmt" + "strconv" + "strings" + "testing" + "time" + + ibc_rate_limit "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + sdk "github.com/cosmos/cosmos-sdk/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" + "github.com/osmosis-labs/osmosis/v12/app" + "github.com/osmosis-labs/osmosis/v12/app/apptesting" + "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/testutil" + "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + "github.com/stretchr/testify/suite" +) + +type MiddlewareTestSuite struct { + apptesting.KeeperTestHelper + + coordinator *ibctesting.Coordinator + + // testing chains used for convenience and readability + chainA *osmosisibctesting.TestChain + chainB *osmosisibctesting.TestChain + path *ibctesting.Path +} + +// Setup +func TestMiddlewareTestSuite(t *testing.T) { + suite.Run(t, new(MiddlewareTestSuite)) +} + +func SetupTestingApp() (ibctesting.TestingApp, map[string]json.RawMessage) { + osmosisApp := app.Setup(false) + return osmosisApp, app.NewDefaultGenesisState() +} + +func NewTransferPath(chainA, chainB *osmosisibctesting.TestChain) *ibctesting.Path { + path := ibctesting.NewPath(chainA.TestChain, chainB.TestChain) + path.EndpointA.ChannelConfig.PortID = ibctesting.TransferPort + path.EndpointB.ChannelConfig.PortID = ibctesting.TransferPort + path.EndpointA.ChannelConfig.Version = transfertypes.Version + path.EndpointB.ChannelConfig.Version = transfertypes.Version + return path +} + +func (suite *MiddlewareTestSuite) SetupTest() { + suite.Setup() + ibctesting.DefaultTestingAppInit = SetupTestingApp + suite.coordinator = ibctesting.NewCoordinator(suite.T(), 2) + suite.chainA = &osmosisibctesting.TestChain{ + TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(1)), + } + // Remove epochs to prevent minting + suite.chainA.MoveEpochsToTheFuture() + suite.chainB = &osmosisibctesting.TestChain{ + TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(2)), + } + suite.path = NewTransferPath(suite.chainA, suite.chainB) + suite.coordinator.Setup(suite.path) +} + +// Helpers +func (suite *MiddlewareTestSuite) MessageFromAToB(denom string, amount sdk.Int) sdk.Msg { + coin := sdk.NewCoin(denom, amount) + port := suite.path.EndpointA.ChannelConfig.PortID + channel := suite.path.EndpointA.ChannelID + accountFrom := suite.chainA.SenderAccount.GetAddress().String() + accountTo := suite.chainB.SenderAccount.GetAddress().String() + timeoutHeight := clienttypes.NewHeight(0, 100) + return transfertypes.NewMsgTransfer( + port, + channel, + coin, + accountFrom, + accountTo, + timeoutHeight, + 0, + ) +} + +func (suite *MiddlewareTestSuite) MessageFromBToA(denom string, amount sdk.Int) sdk.Msg { + coin := sdk.NewCoin(denom, amount) + port := suite.path.EndpointB.ChannelConfig.PortID + channel := suite.path.EndpointB.ChannelID + accountFrom := suite.chainB.SenderAccount.GetAddress().String() + accountTo := suite.chainA.SenderAccount.GetAddress().String() + timeoutHeight := clienttypes.NewHeight(0, 100) + return transfertypes.NewMsgTransfer( + port, + channel, + coin, + accountFrom, + accountTo, + timeoutHeight, + 0, + ) +} + +// Tests that a receiver address longer than 4096 is not accepted +func (suite *MiddlewareTestSuite) TestInvalidReceiver() { + msg := transfertypes.NewMsgTransfer( + suite.path.EndpointB.ChannelConfig.PortID, + suite.path.EndpointB.ChannelID, + sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1)), + suite.chainB.SenderAccount.GetAddress().String(), + strings.Repeat("x", 4097), + clienttypes.NewHeight(0, 100), + 0, + ) + _, ack, _ := suite.FullSendBToA(msg) + suite.Require().Contains(string(ack), "error", + "acknowledgment is not an error") + suite.Require().Contains(string(ack), sdkerrors.ErrInvalidAddress.Error(), + "acknowledgment error is not of the right type") +} + +func (suite *MiddlewareTestSuite) FullSendBToA(msg sdk.Msg) (*sdk.Result, string, error) { + sendResult, err := suite.chainB.SendMsgsNoCheck(msg) + suite.Require().NoError(err) + + packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) + suite.Require().NoError(err) + + err = suite.path.EndpointA.UpdateClient() + suite.Require().NoError(err) + + res, err := suite.path.EndpointA.RecvPacketWithResult(packet) + suite.Require().NoError(err) + + ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + + err = suite.path.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = suite.path.EndpointB.UpdateClient() + suite.Require().NoError(err) + + return sendResult, string(ack), err +} + +func (suite *MiddlewareTestSuite) FullSendAToB(msg sdk.Msg) (*sdk.Result, string, error) { + sendResult, err := suite.chainA.SendMsgsNoCheck(msg) + if err != nil { + return nil, "", err + } + + packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) + if err != nil { + return nil, "", err + } + + err = suite.path.EndpointB.UpdateClient() + if err != nil { + return nil, "", err + } + + res, err := suite.path.EndpointB.RecvPacketWithResult(packet) + if err != nil { + return nil, "", err + } + + ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + if err != nil { + return nil, "", err + } + + err = suite.path.EndpointA.UpdateClient() + if err != nil { + return nil, "", err + } + err = suite.path.EndpointB.UpdateClient() + if err != nil { + return nil, "", err + } + + return sendResult, string(ack), nil +} + +func (suite *MiddlewareTestSuite) AssertReceive(success bool, msg sdk.Msg) (string, error) { + _, ack, err := suite.FullSendBToA(msg) + if success { + suite.Require().NoError(err) + suite.Require().NotContains(string(ack), "error", + "acknowledgment is an error") + } else { + suite.Require().Contains(string(ack), "error", + "acknowledgment is not an error") + suite.Require().Contains(string(ack), types.ErrRateLimitExceeded.Error(), + "acknowledgment error is not of the right type") + } + return ack, err +} + +func (suite *MiddlewareTestSuite) AssertSend(success bool, msg sdk.Msg) (*sdk.Result, error) { + r, _, err := suite.FullSendAToB(msg) + if success { + suite.Require().NoError(err, "IBC send failed. Expected success. %s", err) + } else { + suite.Require().Error(err, "IBC send succeeded. Expected failure") + suite.ErrorContains(err, types.ErrRateLimitExceeded.Error(), "Bad error type") + } + return r, err +} + +func (suite *MiddlewareTestSuite) BuildChannelQuota(name, denom string, duration, send_precentage, recv_percentage uint32) string { + return fmt.Sprintf(` + {"channel_id": "channel-0", "denom": "%s", "quotas": [{"name":"%s", "duration": %d, "send_recv":[%d, %d]}] } + `, denom, name, duration, send_precentage, recv_percentage) +} + +// Tests + +// Test that Sending IBC messages works when the middleware isn't configured +func (suite *MiddlewareTestSuite) TestSendTransferNoContract() { + one := sdk.NewInt(1) + suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, one)) +} + +// Test that Receiving IBC messages works when the middleware isn't configured +func (suite *MiddlewareTestSuite) TestReceiveTransferNoContract() { + one := sdk.NewInt(1) + suite.AssertReceive(true, suite.MessageFromBToA(sdk.DefaultBondDenom, one)) +} + +func (suite *MiddlewareTestSuite) initializeEscrow() (totalEscrow, expectedSed sdk.Int) { + osmosisApp := suite.chainA.GetOsmosisApp() + supply := osmosisApp.BankKeeper.GetSupplyWithOffset(suite.chainA.GetContext(), sdk.DefaultBondDenom) + + // Move some funds from chainA to chainB so that there is something in escrow + // Each user has 10% of the supply, so we send most of the funds from one user to chainA + transferAmount := supply.Amount.QuoRaw(20) + + // When sending, the amount we're sending goes into escrow before we enter the middleware and thus + // it's used as part of the channel value in the rate limiting contract + // To account for that, we subtract the amount we'll send first (2.5% of transferAmount) here + sendAmount := transferAmount.QuoRaw(40) + + // Send from A to B + _, _, err := suite.FullSendAToB(suite.MessageFromAToB(sdk.DefaultBondDenom, transferAmount.Sub(sendAmount))) + suite.Require().NoError(err) + // Send from A to B + _, _, err = suite.FullSendBToA(suite.MessageFromBToA(sdk.DefaultBondDenom, transferAmount.Sub(sendAmount))) + suite.Require().NoError(err) + + return transferAmount, sendAmount +} + +func (suite *MiddlewareTestSuite) fullSendTest(native bool) map[string]string { + quotaPercentage := 5 + suite.initializeEscrow() + // Get the denom and amount to send + denom := sdk.DefaultBondDenom + if !native { + denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", denom)) + denom = denomTrace.IBCDenom() + } + + osmosisApp := suite.chainA.GetOsmosisApp() + + // This is the first one. Inside the tests. It works as expected. + channelValue := ibc_rate_limit.CalculateChannelValue(suite.chainA.GetContext(), denom, "transfer", "channel-0", osmosisApp.BankKeeper) + + // The amount to be sent is send 2.5% (quota is 5%) + quota := channelValue.QuoRaw(int64(100 / quotaPercentage)) + sendAmount := quota.QuoRaw(2) + + fmt.Printf("Testing send rate limiting for denom=%s, channelValue=%s, quota=%s, sendAmount=%s\n", denom, channelValue, quota, sendAmount) + + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite) + quotas := suite.BuildChannelQuota("weekly", denom, 604800, 5, 5) + fmt.Println(quotas) + addr := suite.chainA.InstantiateContract(&suite.Suite, quotas) + suite.chainA.RegisterRateLimitingContract(addr) + + // TODO: Remove native from MessafeFrom calls + // send 2.5% (quota is 5%) + fmt.Println("trying to send ", sendAmount) + suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) + + // send 2.5% (quota is 5%) + fmt.Println("trying to send ", sendAmount) + r, _ := suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) + + // Calculate remaining allowance in the quota + attrs := suite.ExtractAttributes(suite.FindEvent(r.GetEvents(), "wasm")) + + used, ok := sdk.NewIntFromString(attrs["weekly_used_out"]) + suite.Require().True(ok) + + suite.Require().Equal(used, sendAmount.MulRaw(2)) + + // Sending above the quota should fail. We use 2 instead of 1 here to avoid rounding issues + suite.AssertSend(false, suite.MessageFromAToB(denom, sdk.NewInt(2))) + return attrs +} + +// Test rate limiting on sends +func (suite *MiddlewareTestSuite) TestSendTransferWithRateLimitingNative() { + suite.fullSendTest(true) +} + +// Test rate limiting on sends +func (suite *MiddlewareTestSuite) TestSendTransferWithRateLimitingNonNative() { + suite.fullSendTest(false) +} + +// Test rate limits are reset when the specified time period has passed +func (suite *MiddlewareTestSuite) TestSendTransferReset() { + // Same test as above, but the quotas get reset after time passes + attrs := suite.fullSendTest(true) + parts := strings.Split(attrs["weekly_period_end"], ".") // Splitting timestamp into secs and nanos + secs, err := strconv.ParseInt(parts[0], 10, 64) + suite.Require().NoError(err) + nanos, err := strconv.ParseInt(parts[1], 10, 64) + suite.Require().NoError(err) + resetTime := time.Unix(secs, nanos) + + // Move chainA forward one block + suite.chainA.NextBlock() + suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + + // Reset time + one second + oneSecAfterReset := resetTime.Add(time.Second) + suite.coordinator.IncrementTimeBy(oneSecAfterReset.Sub(suite.coordinator.CurrentTime)) + + // Sending should succeed again + suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) +} + +// Test rate limiting on receives +func (suite *MiddlewareTestSuite) fullRecvTest(native bool) { + quotaPercentage := 5 + suite.initializeEscrow() + // Get the denom and amount to send + denom := sdk.DefaultBondDenom + if !native { + denomTrace := transfertypes.ParseDenomTrace(transfertypes.GetPrefixedDenom("transfer", "channel-0", denom)) + denom = denomTrace.IBCDenom() + } + + osmosisApp := suite.chainA.GetOsmosisApp() + + // This is the first one. Inside the tests. It works as expected. + channelValue := ibc_rate_limit.CalculateChannelValue(suite.chainA.GetContext(), denom, "transfer", "channel-0", osmosisApp.BankKeeper) + + // The amount to be sent is send 2.5% (quota is 5%) + quota := channelValue.QuoRaw(int64(100 / quotaPercentage)) + sendAmount := quota.QuoRaw(2) + + fmt.Printf("Testing recv rate limiting for denom=%s, channelValue=%s, quota=%s, sendAmount=%s\n", denom, channelValue, quota, sendAmount) + + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite) + quotas := suite.BuildChannelQuota("weekly", denom, 604800, 5, 5) + addr := suite.chainA.InstantiateContract(&suite.Suite, quotas) + suite.chainA.RegisterRateLimitingContract(addr) + + // receive 2.5% (quota is 5%) + suite.AssertReceive(true, suite.MessageFromBToA(denom, sendAmount)) + + // receive 2.5% (quota is 5%) + suite.AssertReceive(true, suite.MessageFromBToA(denom, sendAmount)) + + // Sending above the quota should fail. We send 2 instead of 1 to account for rounding errors + suite.AssertReceive(false, suite.MessageFromBToA(denom, sdk.NewInt(2))) +} + +func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNative() { + suite.fullRecvTest(true) +} + +func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNonNative() { + suite.fullRecvTest(false) +} + +// Test no rate limiting occurs when the contract is set, but not quotas are condifured for the path +func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite) + addr := suite.chainA.InstantiateContract(&suite.Suite, ``) + suite.chainA.RegisterRateLimitingContract(addr) + + // send 1 token. + // If the contract doesn't have a quota for the current channel, all transfers are allowed + suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) +} + +// Test rate limits are reverted if a "send" fails +func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { + suite.initializeEscrow() + // Setup contract + suite.chainA.StoreContractCode(&suite.Suite) + quotas := suite.BuildChannelQuota("weekly", sdk.DefaultBondDenom, 604800, 1, 1) + addr := suite.chainA.InstantiateContract(&suite.Suite, quotas) + suite.chainA.RegisterRateLimitingContract(addr) + + // Get the escrowed amount + osmosisApp := suite.chainA.GetOsmosisApp() + escrowAddress := transfertypes.GetEscrowAddress("transfer", "channel-0") + escrowed := osmosisApp.BankKeeper.GetBalance(suite.chainA.GetContext(), escrowAddress, sdk.DefaultBondDenom) + + quota := escrowed.Amount.QuoRaw(100) // 1% of the escrowed amount + + // Use the whole quota + coins := sdk.NewCoin(sdk.DefaultBondDenom, quota) + port := suite.path.EndpointA.ChannelConfig.PortID + channel := suite.path.EndpointA.ChannelID + accountFrom := suite.chainA.SenderAccount.GetAddress().String() + timeoutHeight := clienttypes.NewHeight(0, 100) + msg := transfertypes.NewMsgTransfer(port, channel, coins, accountFrom, "INVALID", timeoutHeight, 0) + + // Sending the message manually because AssertSend updates both clients. We need to update the clients manually + // for this test so that the failure to receive on chain B happens after the second packet is sent from chain A. + // That way we validate that chain A is blocking as expected, but the flow is reverted after the receive failure is + // acknowledged on chain A + res, err := suite.chainA.SendMsgsNoCheck(msg) + suite.Require().NoError(err) + + // Sending again fails as the quota is filled + suite.AssertSend(false, suite.MessageFromAToB(sdk.DefaultBondDenom, quota)) + + // Move forward one block + suite.chainA.NextBlock() + suite.chainA.SenderAccount.SetSequence(suite.chainA.SenderAccount.GetSequence() + 1) + suite.chainA.Coordinator.IncrementTime() + + // Update both clients + err = suite.path.EndpointA.UpdateClient() + suite.Require().NoError(err) + err = suite.path.EndpointB.UpdateClient() + suite.Require().NoError(err) + + // Execute the acknowledgement from chain B in chain A + + // extract the sent packet + packet, err := ibctesting.ParsePacketFromEvents(res.GetEvents()) + suite.Require().NoError(err) + + // recv in chain b + res, err = suite.path.EndpointB.RecvPacketWithResult(packet) + + // get the ack from the chain b's response + ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) + suite.Require().NoError(err) + + // manually relay it to chain a + err = suite.path.EndpointA.AcknowledgePacket(packet, ack) + suite.Require().NoError(err) + + // We should be able to send again because the packet that exceeded the quota failed and has been reverted + suite.AssertSend(true, suite.MessageFromAToB(sdk.DefaultBondDenom, sdk.NewInt(1))) +} diff --git a/x/ibc-rate-limit/ibc_module.go b/x/ibc-rate-limit/ibc_module.go index c1df7c9219f..433826dddac 100644 --- a/x/ibc-rate-limit/ibc_module.go +++ b/x/ibc-rate-limit/ibc_module.go @@ -103,12 +103,27 @@ func (im *IBCModule) OnChanCloseConfirm( return im.app.OnChanCloseConfirm(ctx, portID, channelID) } +func ValidateReceiverAddress(packet channeltypes.Packet) error { + var packetData transfertypes.FungibleTokenPacketData + if err := json.Unmarshal(packet.GetData(), &packetData); err != nil { + return err + } + if len(packetData.Receiver) >= 4096 { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "IBC Receiver address too long. Max supported length is %d", 4096) + } + return nil +} + // OnRecvPacket implements the IBCModule interface func (im *IBCModule) OnRecvPacket( ctx sdk.Context, packet channeltypes.Packet, relayer sdk.AccAddress, ) exported.Acknowledgement { + if err := ValidateReceiverAddress(packet); err != nil { + return channeltypes.NewErrorAcknowledgement(err.Error()) + } + contract := im.ics4Middleware.GetParams(ctx) if contract == "" { // The contract has not been configured. Continue as usual @@ -116,9 +131,10 @@ func (im *IBCModule) OnRecvPacket( } amount, denom, err := GetFundsFromPacket(packet) if err != nil { - return channeltypes.NewErrorAcknowledgement("bad packet") + return channeltypes.NewErrorAcknowledgement("bad packet in rate limit's OnRecvPacket") } - channelValue := im.ics4Middleware.CalculateChannelValue(ctx, denom) + + channelValue := im.ics4Middleware.CalculateChannelValue(ctx, denom, packet) err = CheckAndUpdateRateLimits( ctx, @@ -127,11 +143,11 @@ func (im *IBCModule) OnRecvPacket( contract, channelValue, packet.GetDestChannel(), - denom, + denom, // We always use the packet's denom here, as we want the limits to be the same on both directions amount, ) if err != nil { - return channeltypes.NewErrorAcknowledgement(types.RateLimitExceededMsg) + return channeltypes.NewErrorAcknowledgement(types.ErrRateLimitExceeded.Error()) } // if this returns an Acknowledgement that isn't successful, all state changes are discarded diff --git a/x/ibc-rate-limit/ics4_wrapper.go b/x/ibc-rate-limit/ics4_wrapper.go index bdf7e935aaf..453de40a4fc 100644 --- a/x/ibc-rate-limit/ics4_wrapper.go +++ b/x/ibc-rate-limit/ics4_wrapper.go @@ -53,9 +53,11 @@ func (i *ICS4Wrapper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capab amount, denom, err := GetFundsFromPacket(packet) if err != nil { - return sdkerrors.Wrap(err, "Rate limited SendPacket") + return sdkerrors.Wrap(err, "Rate limit SendPacket") } - channelValue := i.CalculateChannelValue(ctx, denom) + + channelValue := i.CalculateChannelValue(ctx, denom, packet) + err = CheckAndUpdateRateLimits( ctx, i.ContractKeeper, @@ -63,11 +65,11 @@ func (i *ICS4Wrapper) SendPacket(ctx sdk.Context, chanCap *capabilitytypes.Capab contract, channelValue, packet.GetSourceChannel(), - denom, + denom, // We always use the packet's denom here, as we want the limits to be the same on both directions amount, ) if err != nil { - return sdkerrors.Wrap(err, "Rate limited SendPacket") + return sdkerrors.Wrap(err, "bad packet in rate limit's SendPacket") } return i.channel.SendPacket(ctx, chanCap, packet) @@ -84,6 +86,7 @@ func (i *ICS4Wrapper) GetParams(ctx sdk.Context) (contract string) { // CalculateChannelValue The value of an IBC channel. This is calculated using the denom supplied by the sender. // if the denom is not correct, the transfer should fail somewhere else on the call chain -func (i *ICS4Wrapper) CalculateChannelValue(ctx sdk.Context, denom string) sdk.Int { - return i.bankKeeper.GetSupplyWithOffset(ctx, denom).Amount +func (i *ICS4Wrapper) CalculateChannelValue(ctx sdk.Context, denom string, packet exported.PacketI) sdk.Int { + // The logic is etracted into a function here so that it can be used within the tests + return CalculateChannelValue(ctx, denom, packet.GetSourcePort(), packet.GetSourceChannel(), i.bankKeeper) } diff --git a/x/ibc-rate-limit/rate_limit.go b/x/ibc-rate-limit/rate_limit.go index 665f04b2990..5c91e5ffeed 100644 --- a/x/ibc-rate-limit/rate_limit.go +++ b/x/ibc-rate-limit/rate_limit.go @@ -2,10 +2,13 @@ package ibc_rate_limit import ( "encoding/json" + "strings" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" ) @@ -15,11 +18,6 @@ var ( msgRecv = "recv_packet" ) -type PacketData struct { - Denom string `json:"denom"` - Amount string `json:"amount"` -} - func CheckAndUpdateRateLimits(ctx sdk.Context, contractKeeper *wasmkeeper.PermissionedKeeper, msgType, contract string, channelValue sdk.Int, sourceChannel, denom string, @@ -42,6 +40,7 @@ func CheckAndUpdateRateLimits(ctx sdk.Context, contractKeeper *wasmkeeper.Permis } _, err = contractKeeper.Sudo(ctx, contractAddr, sendPacketMsg) + if err != nil { return sdkerrors.Wrap(types.ErrRateLimitExceeded, err.Error()) } @@ -128,10 +127,41 @@ func BuildWasmExecMsg(msgType, sourceChannel, denom string, channelValue sdk.Int } func GetFundsFromPacket(packet exported.PacketI) (string, string, error) { - var packetData PacketData + var packetData transfertypes.FungibleTokenPacketData err := json.Unmarshal(packet.GetData(), &packetData) if err != nil { return "", "", err } - return packetData.Amount, packetData.Denom, nil + return packetData.Amount, GetLocalDenom(packetData.Denom), nil +} + +func GetLocalDenom(denom string) string { + // Expected denoms in the following cases: + // + // send non-native: transfer/channel-0/denom -> ibc/xxx + // send native: denom -> denom + // recv (B)non-native: denom + // recv (B)native: transfer/channel-0/denom + // + if strings.HasPrefix(denom, "transfer/") { + denomTrace := transfertypes.ParseDenomTrace(denom) + return denomTrace.IBCDenom() + } else { + return denom + } +} + +func CalculateChannelValue(ctx sdk.Context, denom string, port, channel string, bankKeeper bankkeeper.Keeper) sdk.Int { + if strings.HasPrefix(denom, "ibc/") { + return bankKeeper.GetSupplyWithOffset(ctx, denom).Amount + } + + if channel == "any" { + // ToDo: Get all channels and sum the escrow addr value over all the channels + escrowAddress := transfertypes.GetEscrowAddress(port, channel) + return bankKeeper.GetBalance(ctx, escrowAddress, denom).Amount + } else { + escrowAddress := transfertypes.GetEscrowAddress(port, channel) + return bankKeeper.GetBalance(ctx, escrowAddress, denom).Amount + } } diff --git a/x/ibc-rate-limit/testdata/rate_limiter.wasm b/x/ibc-rate-limit/testdata/rate_limiter.wasm deleted file mode 100644 index 0341a5b1c9a..00000000000 Binary files a/x/ibc-rate-limit/testdata/rate_limiter.wasm and /dev/null differ diff --git a/x/ibc-rate-limit/testutil/chain.go b/x/ibc-rate-limit/testutil/chain.go new file mode 100644 index 00000000000..3ab9c26f0e2 --- /dev/null +++ b/x/ibc-rate-limit/testutil/chain.go @@ -0,0 +1,96 @@ +package osmosisibctesting + +import ( + "time" + + "github.com/cosmos/cosmos-sdk/baseapp" + "github.com/cosmos/cosmos-sdk/client" + cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + sdk "github.com/cosmos/cosmos-sdk/types" + ibctesting "github.com/cosmos/ibc-go/v3/testing" + "github.com/cosmos/ibc-go/v3/testing/simapp/helpers" + "github.com/osmosis-labs/osmosis/v12/app" + abci "github.com/tendermint/tendermint/abci/types" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" +) + +type TestChain struct { + *ibctesting.TestChain +} + +// SendMsgsNoCheck overrides ibctesting.TestChain.SendMsgs so that it doesn't check for errors. That should be handled by the caller +func (chain *TestChain) SendMsgsNoCheck(msgs ...sdk.Msg) (*sdk.Result, error) { + // ensure the chain has the latest time + chain.Coordinator.UpdateTimeForChain(chain.TestChain) + + _, r, err := SignAndDeliver( + chain.TxConfig, + chain.App.GetBaseApp(), + chain.GetContext().BlockHeader(), + msgs, + chain.ChainID, + []uint64{chain.SenderAccount.GetAccountNumber()}, + []uint64{chain.SenderAccount.GetSequence()}, + chain.SenderPrivKey, + ) + if err != nil { + return nil, err + } + + // SignAndDeliver calls app.Commit() + chain.NextBlock() + + // increment sequence for successful transaction execution + err = chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) + if err != nil { + return nil, err + } + + chain.Coordinator.IncrementTime() + + return r, nil +} + +// SignAndDeliver signs and delivers a transaction without asserting the results. This overrides the function +// from ibctesting +func SignAndDeliver( + txCfg client.TxConfig, app *baseapp.BaseApp, header tmproto.Header, msgs []sdk.Msg, + chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey, +) (sdk.GasInfo, *sdk.Result, error) { + tx, _ := helpers.GenTx( + txCfg, + msgs, + sdk.Coins{sdk.NewInt64Coin(sdk.DefaultBondDenom, 0)}, + helpers.DefaultGenTxGas, + chainID, + accNums, + accSeqs, + priv..., + ) + + // Simulate a sending a transaction and committing a block + app.BeginBlock(abci.RequestBeginBlock{Header: header}) + gInfo, res, err := app.Deliver(txCfg.TxEncoder(), tx) + + app.EndBlock(abci.RequestEndBlock{}) + app.Commit() + + return gInfo, res, err +} + +// Move epochs to the future to avoid issues with minting +func (chain *TestChain) MoveEpochsToTheFuture() { + epochsKeeper := chain.GetOsmosisApp().EpochsKeeper + ctx := chain.GetContext() + for _, epoch := range epochsKeeper.AllEpochInfos(ctx) { + epoch.StartTime = ctx.BlockTime().Add(time.Hour * 24 * 30) + epochsKeeper.DeleteEpochInfo(chain.GetContext(), epoch.Identifier) + _ = epochsKeeper.AddEpochInfo(ctx, epoch) + } +} + +// GetOsmosisApp returns the current chain's app as an OsmosisApp +func (chain *TestChain) GetOsmosisApp() *app.OsmosisApp { + v, _ := chain.App.(*app.OsmosisApp) + return v +} diff --git a/x/ibc-rate-limit/testutil/wasm.go b/x/ibc-rate-limit/testutil/wasm.go new file mode 100644 index 00000000000..e9506059786 --- /dev/null +++ b/x/ibc-rate-limit/testutil/wasm.go @@ -0,0 +1,70 @@ +package osmosisibctesting + +import ( + "fmt" + "io/ioutil" + + "github.com/stretchr/testify/require" + + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" + wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" + sdk "github.com/cosmos/cosmos-sdk/types" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" + "github.com/osmosis-labs/osmosis/v12/x/ibc-rate-limit/types" + "github.com/stretchr/testify/suite" +) + +func (chain *TestChain) StoreContractCode(suite *suite.Suite) { + osmosisApp := chain.GetOsmosisApp() + + govKeeper := osmosisApp.GovKeeper + wasmCode, err := ioutil.ReadFile("./bytecode/rate_limiter.wasm") + suite.Require().NoError(err) + + addr := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + src := wasmtypes.StoreCodeProposalFixture(func(p *wasmtypes.StoreCodeProposal) { + p.RunAs = addr.String() + p.WASMByteCode = wasmCode + }) + + // when stored + storedProposal, err := govKeeper.SubmitProposal(chain.GetContext(), src, false) + suite.Require().NoError(err) + + // and proposal execute + handler := govKeeper.Router().GetRoute(storedProposal.ProposalRoute()) + err = handler(chain.GetContext(), storedProposal.GetContent()) + suite.Require().NoError(err) +} + +func (chain *TestChain) InstantiateContract(suite *suite.Suite, quotas string) sdk.AccAddress { + osmosisApp := chain.GetOsmosisApp() + transferModule := osmosisApp.AccountKeeper.GetModuleAddress(transfertypes.ModuleName) + govModule := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + + initMsgBz := []byte(fmt.Sprintf(`{ + "gov_module": "%s", + "ibc_module":"%s", + "paths": [%s] + }`, + govModule, transferModule, quotas)) + + contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(osmosisApp.WasmKeeper) + codeID := uint64(1) + creator := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + addr, _, err := contractKeeper.Instantiate(chain.GetContext(), codeID, creator, creator, initMsgBz, "rate limiting contract", nil) + suite.Require().NoError(err) + return addr +} + +func (chain *TestChain) RegisterRateLimitingContract(addr []byte) { + addrStr, err := sdk.Bech32ifyAddressBytes("osmo", addr) + require.NoError(chain.T, err) + params, err := types.NewParams(addrStr) + require.NoError(chain.T, err) + osmosisApp := chain.GetOsmosisApp() + paramSpace, ok := osmosisApp.AppKeepers.ParamsKeeper.GetSubspace(types.ModuleName) + require.True(chain.T, ok) + paramSpace.SetParamSet(chain.GetContext(), ¶ms) +} diff --git a/x/ibc-rate-limit/types/errors.go b/x/ibc-rate-limit/types/errors.go index 67d81abeb79..5394ce11e3d 100644 --- a/x/ibc-rate-limit/types/errors.go +++ b/x/ibc-rate-limit/types/errors.go @@ -5,8 +5,7 @@ import ( ) var ( - RateLimitExceededMsg = "rate limit exceeded" - ErrRateLimitExceeded = sdkerrors.Register(ModuleName, 2, RateLimitExceededMsg) + ErrRateLimitExceeded = sdkerrors.Register(ModuleName, 2, "rate limit exceeded") ErrBadMessage = sdkerrors.Register(ModuleName, 3, "bad message") ErrContractError = sdkerrors.Register(ModuleName, 4, "contract error") ) diff --git a/x/streamswap/README.md b/x/streamswap/README.md deleted file mode 100644 index e3e3817d096..00000000000 --- a/x/streamswap/README.md +++ /dev/null @@ -1,121 +0,0 @@ -# Streamswap - -## Abstract - -Streamswap is a new way and innovative way of selling token sale. -The mechanism allows anyone to create a new Sale event and sell any -amount of tokens in a more democratic way than the traditional solutions. - -## Context - -Since the first ICO boom, token sale mechanism was one of the driving -force for web3 onboarding. -Promise of a cheap tokens which can quickly accrue value is very attractive -for casual any sort of investors. Easy way of fundrising (the funding team) -opened doors for cohorts of new teams to focus on building on web3. - -Traditional mechanisms of token sale included: - -- Automated ICO, where team decides about the issuance price and the sale - happens through a swap controlled by a smart contract. -- Regulated, centralized ICO - token sale controlled by a dedicated company, - which will preform all operations using centralized services meeting - regulatory requirements (KYC...). Example: Coinlist sales. -- Balancer style ICO: a novel solution to utilize Dutch Auction mechanism to - find a fair strike price. - -The first two mechanisms are not well suited for early stage startups, where -the token sale price is usually defined by a founding team and can't be -impacted by the ecosystem wisdom. False marketing actions are usually setup -to support their initial price. - -The latter mechanism is not democratic - big entities can control the -price movements or place big orders leaving smaller investors with nothing. - -## Design - -### Sale Creation - -[Sale](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/state.proto#L11) object represent a particular token sale event and describes the main -required parameters guarding the sale process: - -- `treasury`: address where the sale earnings will go. When the sale is over, - anyone can trigger a [`MsgFinalizeSale`](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/tx.proto#L42) - to clean up the sale state and move the earning to the treasury. -- `id`: unique identifier of the sale. -- `token_out`: denom to sale (distributed to the investors). - Also known as a base currency. -- `token_in`: payment denom - used to buy `token_out`. - Also known as quote currency. -- `token_out_supply`: total initial supply of `token_in` to sale. -- `start_time`: Unix timestamp when the sale starts. -- `end_time`: Unix timestamp when the sale ends. -- `name`: Name of the sale. -- `url`: an external resource describing a sale. Can be IPFS link or a - commonwealth post. - -The `Sale` object contains also other internal attributes to describe the current -status of the sale. - -Anyone can create a `Sale` by sending [`MsgCreateSale`](https://github.com/osmosis-labs/osmosis/blob/robert%2Fstreamswap-spec/proto/osmosis/streamswap/v1/tx.proto#L21) transaction. -When doing so, `token_out` amount of `Sale.token_out` tokens will be debited from -his account and escrowed in the module account to distribute to Sale investors. -Moreover the creator will be charged `sale_creation_fee` (module param) and the -fee will be transferred to `sale_creation_fee_recipient` (module param) account. -This fee is not recoverable. - -See other [module parameters](https://github.com/osmosis-labs/osmosis/main/proto/osmosis/streamswap/v1/params.proto) which control the sale creation. - -### Investing and distribution mechanism - -Anyone can join a sale by sending a [MsgSubscribe](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/tx.proto#L13) transaction. -When doing so, the transaction author has to specify the `amount` he wants to spend in the sale. -That `amount` will be credited from tx author and pledged to the sale. - -`MsgSubscribe` can be submitted at any time after the sale is created and before it's end time. - -From that moment, the investor will join the **token sale distribution stream**: - -- The distribution happens discretely in rounds. Each round is 1 second long. - We define: `total_rounds := (sale.end_time - sale.start_time) / round_duration`. -- During each round we stream `round_supply := sale.token_out_supply / total_rounds`. -- During each round each investor receives `round_supply * current_investor_pledge / total_remaining_sale_pledge` share of the `token_out`. - -At any time an investor can increase his participation for the sale by sending again `MsgSubscribe` -(his pledge will increase accordingly) or cancel it by sending -[`MsgWithdraw`](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/tx.proto#32). -When cancelling, the module will send back unspent pledged tokens to the investor -and keep the purchased tokens until the sale end_time. - -### Withdrawing purchased tokens - -When participating in a sale, investors receives a stream of sale tokens. -These tokens are locked until sale end to avoid second market creating during -the sale. Once sale is finished (block time is after `sale.end_time`), every -investor can send [`MsgExitSale`](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/tx.proto#L37) -to close his position and withdraw purchased tokens to his account. - -### Withdrawing sale proceedings - -To withdraw earned token to the `sale.treasury` account anyone can send a -transaction with [`MsgFinalizeSale`](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/tx.proto#L42) after the `sale.end_time`. -This transaction will send `sale.income` tokens from the module escrow account -to the `sale.treasury` and set `sale.finalized = true`. - -### Events - -The module uses typed events. Please see [`event.proto`](https://github.com/osmosis-labs/osmosis/blob/main/proto/osmosis/streamswap/v1/event.proto) -to inspect list events. - -## Consequences - -- The new sale mechanism provides a truly democratic way for token distribution and sale. -- It can be easily integrated with AMM pools: proceedings from the sale can - automatically be pledged to AMM. -- After the sale ends, there are few algorithms to provide token indicative market price: - - average price: `sale.income / sale.token_out_supply` - - last streamed price: `round_supply(last_round) / (sale.token_out_supply / total_rounds)` - -## Future directions - -- providing incentive for sales with `OSMO` or `ATOM` used as a base currency. diff --git a/x/streamswap/types/event.pb.go b/x/streamswap/types/event.pb.go deleted file mode 100644 index 61373d08f64..00000000000 --- a/x/streamswap/types/event.pb.go +++ /dev/null @@ -1,1344 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/event.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type EventCreateSale struct { - Id uint64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` - Creator string `protobuf:"bytes,2,opt,name=creator,proto3" json:"creator,omitempty"` - TokenIn string `protobuf:"bytes,3,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty"` - TokenOut types.Coin `protobuf:"bytes,4,opt,name=token_out,json=tokenOut,proto3" json:"token_out"` -} - -func (m *EventCreateSale) Reset() { *m = EventCreateSale{} } -func (m *EventCreateSale) String() string { return proto.CompactTextString(m) } -func (*EventCreateSale) ProtoMessage() {} -func (*EventCreateSale) Descriptor() ([]byte, []int) { - return fileDescriptor_31fe170f2829736b, []int{0} -} -func (m *EventCreateSale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventCreateSale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventCreateSale.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 *EventCreateSale) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventCreateSale.Merge(m, src) -} -func (m *EventCreateSale) XXX_Size() int { - return m.Size() -} -func (m *EventCreateSale) XXX_DiscardUnknown() { - xxx_messageInfo_EventCreateSale.DiscardUnknown(m) -} - -var xxx_messageInfo_EventCreateSale proto.InternalMessageInfo - -type EventSubscribe struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *EventSubscribe) Reset() { *m = EventSubscribe{} } -func (m *EventSubscribe) String() string { return proto.CompactTextString(m) } -func (*EventSubscribe) ProtoMessage() {} -func (*EventSubscribe) Descriptor() ([]byte, []int) { - return fileDescriptor_31fe170f2829736b, []int{1} -} -func (m *EventSubscribe) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventSubscribe) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventSubscribe.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 *EventSubscribe) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventSubscribe.Merge(m, src) -} -func (m *EventSubscribe) XXX_Size() int { - return m.Size() -} -func (m *EventSubscribe) XXX_DiscardUnknown() { - xxx_messageInfo_EventSubscribe.DiscardUnknown(m) -} - -var xxx_messageInfo_EventSubscribe proto.InternalMessageInfo - -type EventWithdraw struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - // amount of staked token_in withdrawn by user. - Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` -} - -func (m *EventWithdraw) Reset() { *m = EventWithdraw{} } -func (m *EventWithdraw) String() string { return proto.CompactTextString(m) } -func (*EventWithdraw) ProtoMessage() {} -func (*EventWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_31fe170f2829736b, []int{2} -} -func (m *EventWithdraw) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventWithdraw.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 *EventWithdraw) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventWithdraw.Merge(m, src) -} -func (m *EventWithdraw) XXX_Size() int { - return m.Size() -} -func (m *EventWithdraw) XXX_DiscardUnknown() { - xxx_messageInfo_EventWithdraw.DiscardUnknown(m) -} - -var xxx_messageInfo_EventWithdraw proto.InternalMessageInfo - -type EventExit struct { - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - // amount of purchased token_out sent to the user - Purchased string `protobuf:"bytes,3,opt,name=purchased,proto3" json:"purchased,omitempty"` -} - -func (m *EventExit) Reset() { *m = EventExit{} } -func (m *EventExit) String() string { return proto.CompactTextString(m) } -func (*EventExit) ProtoMessage() {} -func (*EventExit) Descriptor() ([]byte, []int) { - return fileDescriptor_31fe170f2829736b, []int{3} -} -func (m *EventExit) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventExit) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventExit.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 *EventExit) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventExit.Merge(m, src) -} -func (m *EventExit) XXX_Size() int { - return m.Size() -} -func (m *EventExit) XXX_DiscardUnknown() { - xxx_messageInfo_EventExit.DiscardUnknown(m) -} - -var xxx_messageInfo_EventExit proto.InternalMessageInfo - -type EventFinalizeSale struct { - SaleId uint64 `protobuf:"varint,1,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - // amount of earned tokens_in - Income string `protobuf:"bytes,3,opt,name=income,proto3" json:"income,omitempty"` -} - -func (m *EventFinalizeSale) Reset() { *m = EventFinalizeSale{} } -func (m *EventFinalizeSale) String() string { return proto.CompactTextString(m) } -func (*EventFinalizeSale) ProtoMessage() {} -func (*EventFinalizeSale) Descriptor() ([]byte, []int) { - return fileDescriptor_31fe170f2829736b, []int{4} -} -func (m *EventFinalizeSale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *EventFinalizeSale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_EventFinalizeSale.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 *EventFinalizeSale) XXX_Merge(src proto.Message) { - xxx_messageInfo_EventFinalizeSale.Merge(m, src) -} -func (m *EventFinalizeSale) XXX_Size() int { - return m.Size() -} -func (m *EventFinalizeSale) XXX_DiscardUnknown() { - xxx_messageInfo_EventFinalizeSale.DiscardUnknown(m) -} - -var xxx_messageInfo_EventFinalizeSale proto.InternalMessageInfo - -func init() { - proto.RegisterType((*EventCreateSale)(nil), "osmosis.streamswap.v1.EventCreateSale") - proto.RegisterType((*EventSubscribe)(nil), "osmosis.streamswap.v1.EventSubscribe") - proto.RegisterType((*EventWithdraw)(nil), "osmosis.streamswap.v1.EventWithdraw") - proto.RegisterType((*EventExit)(nil), "osmosis.streamswap.v1.EventExit") - proto.RegisterType((*EventFinalizeSale)(nil), "osmosis.streamswap.v1.EventFinalizeSale") -} - -func init() { proto.RegisterFile("osmosis/streamswap/v1/event.proto", fileDescriptor_31fe170f2829736b) } - -var fileDescriptor_31fe170f2829736b = []byte{ - // 419 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x92, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0xe3, 0x52, 0x75, 0xc4, 0x88, 0x21, 0x22, 0xfe, 0xa4, 0x13, 0x32, 0x25, 0xa7, 0x5e, - 0x88, 0x95, 0x21, 0x71, 0xe2, 0xb4, 0x31, 0xa4, 0x9d, 0x90, 0x32, 0x24, 0x60, 0x97, 0xca, 0x49, - 0x5e, 0xb5, 0x16, 0x89, 0x1d, 0xd9, 0x4e, 0x36, 0xf8, 0x14, 0x1c, 0xf8, 0x50, 0x3d, 0xee, 0xc8, - 0x09, 0x41, 0xfb, 0x45, 0x50, 0x6c, 0x57, 0x9b, 0xb8, 0x21, 0xed, 0x96, 0xdf, 0xfb, 0xd8, 0x4f, - 0x7e, 0x92, 0x5f, 0xfc, 0x42, 0xea, 0x46, 0x6a, 0xae, 0xa9, 0x36, 0x0a, 0x58, 0xa3, 0x2f, 0x58, - 0x4b, 0xfb, 0x8c, 0x42, 0x0f, 0xc2, 0xa4, 0xad, 0x92, 0x46, 0x46, 0x8f, 0xfd, 0x91, 0xf4, 0xfa, - 0x48, 0xda, 0x67, 0x07, 0xa4, 0xb4, 0x73, 0x5a, 0x30, 0x0d, 0xb4, 0xcf, 0x0a, 0x30, 0x2c, 0xa3, - 0xa5, 0xe4, 0xc2, 0x5d, 0x3b, 0x98, 0xba, 0x7c, 0x61, 0x89, 0x3a, 0xf0, 0xd1, 0xa3, 0xa5, 0x5c, - 0x4a, 0x37, 0x1f, 0xbe, 0xdc, 0x34, 0xf9, 0x81, 0xf0, 0x83, 0x93, 0xe1, 0xbf, 0xc7, 0x0a, 0x98, - 0x81, 0x33, 0x56, 0x43, 0xb4, 0x8f, 0x47, 0xbc, 0x8a, 0xd1, 0x0c, 0xcd, 0xc7, 0xf9, 0x88, 0x57, - 0x51, 0x8c, 0xf7, 0xca, 0x21, 0x95, 0x2a, 0x1e, 0xcd, 0xd0, 0x3c, 0xcc, 0x77, 0x18, 0x4d, 0xf1, - 0x5d, 0x23, 0xbf, 0x80, 0x58, 0x70, 0x11, 0xdf, 0x71, 0x91, 0xe5, 0x53, 0x11, 0xbd, 0xc1, 0xa1, - 0x8b, 0x64, 0x67, 0xe2, 0xf1, 0x0c, 0xcd, 0xef, 0x1d, 0x4e, 0x53, 0x2f, 0x34, 0xd8, 0xa7, 0xde, - 0x3e, 0x3d, 0x96, 0x5c, 0x1c, 0x8d, 0xd7, 0xbf, 0x9e, 0x07, 0xb9, 0x2b, 0x7b, 0xdf, 0x99, 0xe4, - 0x33, 0xde, 0xb7, 0x56, 0x67, 0x5d, 0xa1, 0x4b, 0xc5, 0x0b, 0x88, 0x9e, 0xe0, 0x89, 0x06, 0x51, - 0x81, 0xb2, 0x62, 0x61, 0xee, 0x29, 0x7a, 0x8a, 0xf7, 0x34, 0xab, 0x61, 0xc1, 0x2b, 0x2b, 0x37, - 0xce, 0x27, 0x03, 0x9e, 0x56, 0xc3, 0x05, 0xd6, 0xc8, 0x4e, 0x18, 0x6f, 0xe6, 0x29, 0xf9, 0x84, - 0xef, 0xdb, 0xea, 0x8f, 0xdc, 0xac, 0x2a, 0xc5, 0x2e, 0x6e, 0xaf, 0xf9, 0x1c, 0x87, 0xb6, 0xf9, - 0xe4, 0x92, 0x9b, 0xff, 0x6f, 0x7d, 0x86, 0xc3, 0xb6, 0x53, 0xe5, 0x8a, 0x69, 0xa8, 0x7c, 0xf1, - 0xf5, 0x20, 0x79, 0x8b, 0x1f, 0xda, 0xee, 0x77, 0x5c, 0xb0, 0x9a, 0x7f, 0x73, 0x0f, 0x75, 0xa3, - 0x0b, 0xfd, 0x6b, 0xc8, 0x45, 0x29, 0x1b, 0xd8, 0x19, 0x3a, 0x3a, 0xfa, 0xb0, 0xfe, 0x43, 0x82, - 0xf5, 0x86, 0xa0, 0xab, 0x0d, 0x41, 0xbf, 0x37, 0x04, 0x7d, 0xdf, 0x92, 0xe0, 0x6a, 0x4b, 0x82, - 0x9f, 0x5b, 0x12, 0x9c, 0xbf, 0x5e, 0x72, 0xb3, 0xea, 0x8a, 0xb4, 0x94, 0x0d, 0xf5, 0xeb, 0xf7, - 0xb2, 0x66, 0x85, 0xde, 0x01, 0xed, 0xb3, 0x43, 0x7a, 0x79, 0x73, 0x69, 0xcd, 0xd7, 0x16, 0x74, - 0x31, 0xb1, 0xab, 0xf4, 0xea, 0x6f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x6c, 0x03, 0xe4, 0x50, 0xd7, - 0x02, 0x00, 0x00, -} - -func (m *EventCreateSale) 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 *EventCreateSale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventCreateSale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.TokenOut.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintEvent(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if len(m.TokenIn) > 0 { - i -= len(m.TokenIn) - copy(dAtA[i:], m.TokenIn) - i = encodeVarintEvent(dAtA, i, uint64(len(m.TokenIn))) - i-- - dAtA[i] = 0x1a - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0x12 - } - if m.Id != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *EventSubscribe) 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 *EventSubscribe) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventSubscribe) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Amount) > 0 { - i -= len(m.Amount) - copy(dAtA[i:], m.Amount) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Amount))) - i-- - dAtA[i] = 0x1a - } - if m.SaleId != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EventWithdraw) 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 *EventWithdraw) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventWithdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Amount) > 0 { - i -= len(m.Amount) - copy(dAtA[i:], m.Amount) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Amount))) - i-- - dAtA[i] = 0x1a - } - if m.SaleId != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EventExit) 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 *EventExit) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventExit) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Purchased) > 0 { - i -= len(m.Purchased) - copy(dAtA[i:], m.Purchased) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Purchased))) - i-- - dAtA[i] = 0x1a - } - if m.SaleId != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - if len(m.Sender) > 0 { - i -= len(m.Sender) - copy(dAtA[i:], m.Sender) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Sender))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *EventFinalizeSale) 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 *EventFinalizeSale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *EventFinalizeSale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Income) > 0 { - i -= len(m.Income) - copy(dAtA[i:], m.Income) - i = encodeVarintEvent(dAtA, i, uint64(len(m.Income))) - i-- - dAtA[i] = 0x1a - } - if m.SaleId != 0 { - i = encodeVarintEvent(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintEvent(dAtA []byte, offset int, v uint64) int { - offset -= sovEvent(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *EventCreateSale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Id != 0 { - n += 1 + sovEvent(uint64(m.Id)) - } - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - l = len(m.TokenIn) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - l = m.TokenOut.Size() - n += 1 + l + sovEvent(uint64(l)) - return n -} - -func (m *EventSubscribe) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovEvent(uint64(m.SaleId)) - } - l = len(m.Amount) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - return n -} - -func (m *EventWithdraw) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovEvent(uint64(m.SaleId)) - } - l = len(m.Amount) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - return n -} - -func (m *EventExit) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovEvent(uint64(m.SaleId)) - } - l = len(m.Purchased) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - return n -} - -func (m *EventFinalizeSale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SaleId != 0 { - n += 1 + sovEvent(uint64(m.SaleId)) - } - l = len(m.Income) - if l > 0 { - n += 1 + l + sovEvent(uint64(l)) - } - return n -} - -func sovEvent(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozEvent(x uint64) (n int) { - return sovEvent(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *EventCreateSale) 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 ErrIntOverflowEvent - } - 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: EventCreateSale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventCreateSale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - 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 ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenIn = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthEvent - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TokenOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvent(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventSubscribe) 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 ErrIntOverflowEvent - } - 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: EventSubscribe: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventSubscribe: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Amount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvent(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventWithdraw) 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 ErrIntOverflowEvent - } - 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: EventWithdraw: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventWithdraw: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Amount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvent(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventExit) 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 ErrIntOverflowEvent - } - 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: EventExit: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventExit: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sender = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Purchased", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Purchased = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvent(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *EventFinalizeSale) 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 ErrIntOverflowEvent - } - 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: EventFinalizeSale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: EventFinalizeSale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Income", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowEvent - } - 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 ErrInvalidLengthEvent - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthEvent - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Income = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipEvent(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthEvent - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipEvent(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvent - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvent - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowEvent - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthEvent - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupEvent - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthEvent - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthEvent = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowEvent = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupEvent = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/streamswap/types/genesis.pb.go b/x/streamswap/types/genesis.pb.go deleted file mode 100644 index 8bafdfa7006..00000000000 --- a/x/streamswap/types/genesis.pb.go +++ /dev/null @@ -1,758 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/genesis.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// GenesisState defines the streamswap module's genesis state. -type GenesisState struct { - Sales []Sale `protobuf:"bytes,1,rep,name=sales,proto3" json:"sales"` - UserPositions []UserPositionKV `protobuf:"bytes,2,rep,name=user_positions,json=userPositions,proto3" json:"user_positions"` - NextSaleId uint64 `protobuf:"varint,3,opt,name=next_sale_id,json=nextSaleId,proto3" json:"next_sale_id,omitempty"` - Params Params `protobuf:"bytes,4,opt,name=params,proto3" json:"params"` -} - -func (m *GenesisState) Reset() { *m = GenesisState{} } -func (m *GenesisState) String() string { return proto.CompactTextString(m) } -func (*GenesisState) ProtoMessage() {} -func (*GenesisState) Descriptor() ([]byte, []int) { - return fileDescriptor_8e54537622481acf, []int{0} -} -func (m *GenesisState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *GenesisState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_GenesisState.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 *GenesisState) XXX_Merge(src proto.Message) { - xxx_messageInfo_GenesisState.Merge(m, src) -} -func (m *GenesisState) XXX_Size() int { - return m.Size() -} -func (m *GenesisState) XXX_DiscardUnknown() { - xxx_messageInfo_GenesisState.DiscardUnknown(m) -} - -var xxx_messageInfo_GenesisState proto.InternalMessageInfo - -func (m *GenesisState) GetSales() []Sale { - if m != nil { - return m.Sales - } - return nil -} - -func (m *GenesisState) GetUserPositions() []UserPositionKV { - if m != nil { - return m.UserPositions - } - return nil -} - -func (m *GenesisState) GetNextSaleId() uint64 { - if m != nil { - return m.NextSaleId - } - return 0 -} - -func (m *GenesisState) GetParams() Params { - if m != nil { - return m.Params - } - return Params{} -} - -// UserPositionKV is a record in genesis representing acc_address user position -// of a sale_id sale. -type UserPositionKV struct { - // user account address - AccAddress string `protobuf:"bytes,1,opt,name=acc_address,json=accAddress,proto3" json:"acc_address,omitempty"` - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - UserPosition UserPosition `protobuf:"bytes,3,opt,name=user_position,json=userPosition,proto3" json:"user_position"` -} - -func (m *UserPositionKV) Reset() { *m = UserPositionKV{} } -func (m *UserPositionKV) String() string { return proto.CompactTextString(m) } -func (*UserPositionKV) ProtoMessage() {} -func (*UserPositionKV) Descriptor() ([]byte, []int) { - return fileDescriptor_8e54537622481acf, []int{1} -} -func (m *UserPositionKV) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UserPositionKV) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UserPositionKV.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 *UserPositionKV) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserPositionKV.Merge(m, src) -} -func (m *UserPositionKV) XXX_Size() int { - return m.Size() -} -func (m *UserPositionKV) XXX_DiscardUnknown() { - xxx_messageInfo_UserPositionKV.DiscardUnknown(m) -} - -var xxx_messageInfo_UserPositionKV proto.InternalMessageInfo - -func (m *UserPositionKV) GetAccAddress() string { - if m != nil { - return m.AccAddress - } - return "" -} - -func (m *UserPositionKV) GetSaleId() uint64 { - if m != nil { - return m.SaleId - } - return 0 -} - -func (m *UserPositionKV) GetUserPosition() UserPosition { - if m != nil { - return m.UserPosition - } - return UserPosition{} -} - -func init() { - proto.RegisterType((*GenesisState)(nil), "osmosis.streamswap.v1.GenesisState") - proto.RegisterType((*UserPositionKV)(nil), "osmosis.streamswap.v1.UserPositionKV") -} - -func init() { - proto.RegisterFile("osmosis/streamswap/v1/genesis.proto", fileDescriptor_8e54537622481acf) -} - -var fileDescriptor_8e54537622481acf = []byte{ - // 401 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0xc1, 0xaa, 0xd3, 0x40, - 0x14, 0x86, 0x33, 0x6d, 0xad, 0x38, 0x69, 0xbb, 0x08, 0x8a, 0xb1, 0x62, 0x1a, 0x5b, 0x84, 0x6c, - 0xcc, 0x90, 0x08, 0xba, 0x70, 0x65, 0x37, 0x22, 0x82, 0x94, 0x14, 0x5d, 0xb8, 0x09, 0x93, 0x64, - 0x88, 0x81, 0x26, 0x13, 0x72, 0xa6, 0xb1, 0xbe, 0x85, 0x6b, 0x9f, 0xa8, 0xcb, 0x2e, 0x5d, 0x89, - 0xb4, 0x6f, 0x71, 0x57, 0x97, 0x64, 0xa6, 0xdc, 0x16, 0x5a, 0xb8, 0xbb, 0x9c, 0x73, 0xbe, 0x39, - 0xff, 0xff, 0xe7, 0xe0, 0x19, 0x87, 0x9c, 0x43, 0x06, 0x04, 0x44, 0xc5, 0x68, 0x0e, 0x3f, 0x69, - 0x49, 0x6a, 0x8f, 0xa4, 0xac, 0x60, 0x90, 0x81, 0x5b, 0x56, 0x5c, 0x70, 0xe3, 0x89, 0x82, 0xdc, - 0x3b, 0xc8, 0xad, 0xbd, 0xf1, 0xe3, 0x94, 0xa7, 0xbc, 0x25, 0x48, 0xf3, 0x25, 0xe1, 0xf1, 0xb3, - 0xb8, 0xa5, 0x43, 0x39, 0x90, 0x85, 0x1a, 0x59, 0xb2, 0x22, 0x11, 0x05, 0x46, 0x6a, 0x2f, 0x62, - 0x82, 0x7a, 0x24, 0xe6, 0x59, 0xa1, 0xe6, 0x2f, 0x2f, 0x9b, 0x01, 0x41, 0x05, 0x53, 0xc8, 0xf4, - 0x32, 0x52, 0xd2, 0x8a, 0xe6, 0x4a, 0x66, 0x7a, 0x83, 0xf0, 0xe0, 0xa3, 0x0c, 0xb0, 0x6c, 0x9e, - 0x1a, 0xef, 0xf0, 0x03, 0xa0, 0x2b, 0x06, 0x26, 0xb2, 0xbb, 0x8e, 0xee, 0x3f, 0x77, 0x2f, 0xe6, - 0x71, 0x97, 0x74, 0xc5, 0xe6, 0xbd, 0xed, 0xbf, 0x89, 0x16, 0x48, 0xde, 0x08, 0xf0, 0x68, 0x0d, - 0xac, 0x0a, 0x4b, 0x0e, 0x99, 0xc8, 0x78, 0x01, 0x66, 0xa7, 0xdd, 0xf0, 0xea, 0xca, 0x86, 0xaf, - 0xc0, 0xaa, 0x85, 0x62, 0x3f, 0x7f, 0x53, 0xbb, 0x86, 0xeb, 0x93, 0x2e, 0x18, 0x36, 0x1e, 0x14, - 0x6c, 0x23, 0xc2, 0x46, 0x21, 0xcc, 0x12, 0xb3, 0x6b, 0x23, 0xa7, 0x17, 0xe0, 0xa6, 0xd7, 0x18, - 0xf8, 0x94, 0x18, 0xef, 0x71, 0x5f, 0xe6, 0x31, 0x7b, 0x36, 0x72, 0x74, 0xff, 0xc5, 0x15, 0xb5, - 0x45, 0x0b, 0x29, 0x15, 0xf5, 0x64, 0xfa, 0x07, 0xe1, 0xd1, 0xb9, 0x0d, 0x63, 0x82, 0x75, 0x1a, - 0xc7, 0x21, 0x4d, 0x92, 0x8a, 0x41, 0xf3, 0x13, 0x90, 0xf3, 0x28, 0xc0, 0x34, 0x8e, 0x3f, 0xc8, - 0x8e, 0xf1, 0x14, 0x3f, 0x3c, 0xba, 0xe9, 0xb4, 0x6e, 0xfa, 0x20, 0x9d, 0x7c, 0xc1, 0xc3, 0xb3, - 0xfc, 0xad, 0x59, 0xdd, 0x9f, 0xdd, 0x23, 0xbe, 0xb2, 0x35, 0x38, 0x0d, 0x3f, 0x5f, 0x6c, 0xf7, - 0x16, 0xda, 0xed, 0x2d, 0xf4, 0x7f, 0x6f, 0xa1, 0xdf, 0x07, 0x4b, 0xdb, 0x1d, 0x2c, 0xed, 0xef, - 0xc1, 0xd2, 0xbe, 0xbf, 0x4d, 0x33, 0xf1, 0x63, 0x1d, 0xb9, 0x31, 0xcf, 0x89, 0x5a, 0xfe, 0x7a, - 0x45, 0x23, 0x38, 0x16, 0xa4, 0xf6, 0x7c, 0xb2, 0x39, 0xbd, 0xba, 0xf8, 0x55, 0x32, 0x88, 0xfa, - 0xed, 0xc9, 0xdf, 0xdc, 0x06, 0x00, 0x00, 0xff, 0xff, 0x4f, 0xcf, 0x66, 0x28, 0xc8, 0x02, 0x00, - 0x00, -} - -func (m *GenesisState) 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 *GenesisState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - if m.NextSaleId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.NextSaleId)) - i-- - dAtA[i] = 0x18 - } - if len(m.UserPositions) > 0 { - for iNdEx := len(m.UserPositions) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.UserPositions[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Sales) > 0 { - for iNdEx := len(m.Sales) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Sales[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *UserPositionKV) 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 *UserPositionKV) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UserPositionKV) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.UserPosition.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintGenesis(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.SaleId != 0 { - i = encodeVarintGenesis(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - if len(m.AccAddress) > 0 { - i -= len(m.AccAddress) - copy(dAtA[i:], m.AccAddress) - i = encodeVarintGenesis(dAtA, i, uint64(len(m.AccAddress))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintGenesis(dAtA []byte, offset int, v uint64) int { - offset -= sovGenesis(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *GenesisState) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Sales) > 0 { - for _, e := range m.Sales { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if len(m.UserPositions) > 0 { - for _, e := range m.UserPositions { - l = e.Size() - n += 1 + l + sovGenesis(uint64(l)) - } - } - if m.NextSaleId != 0 { - n += 1 + sovGenesis(uint64(m.NextSaleId)) - } - l = m.Params.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - -func (m *UserPositionKV) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.AccAddress) - if l > 0 { - n += 1 + l + sovGenesis(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovGenesis(uint64(m.SaleId)) - } - l = m.UserPosition.Size() - n += 1 + l + sovGenesis(uint64(l)) - return n -} - -func sovGenesis(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozGenesis(x uint64) (n int) { - return sovGenesis(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *GenesisState) 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 ErrIntOverflowGenesis - } - 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: GenesisState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: GenesisState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sales", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sales = append(m.Sales, Sale{}) - if err := m.Sales[len(m.Sales)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserPositions", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserPositions = append(m.UserPositions, UserPositionKV{}) - if err := m.UserPositions[len(m.UserPositions)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field NextSaleId", wireType) - } - m.NextSaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.NextSaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Params", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UserPositionKV) 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 ErrIntOverflowGenesis - } - 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: UserPositionKV: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UserPositionKV: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AccAddress", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - 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 ErrInvalidLengthGenesis - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AccAddress = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserPosition", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowGenesis - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthGenesis - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthGenesis - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UserPosition.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipGenesis(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthGenesis - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipGenesis(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowGenesis - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthGenesis - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupGenesis - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthGenesis - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthGenesis = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowGenesis = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupGenesis = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/streamswap/types/params.pb.go b/x/streamswap/types/params.pb.go deleted file mode 100644 index 1f80e7cd20f..00000000000 --- a/x/streamswap/types/params.pb.go +++ /dev/null @@ -1,513 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/params.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - _ "github.com/cosmos/cosmos-sdk/codec/types" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -// Params holds parameters for the streamswap module -type Params struct { - // fee charged when creating a new sale. The fee will go to the - // sale_fee_recipient unless it is not defined (empty). - SaleCreationFee github_com_cosmos_cosmos_sdk_types.Coins `protobuf:"bytes,1,rep,name=sale_creation_fee,json=saleCreationFee,proto3,castrepeated=github.com/cosmos/cosmos-sdk/types.Coins" json:"sale_creation_fee" yaml:"sale_creation_fee"` - // bech32 address of the fee recipient - SaleCreationFeeRecipient string `protobuf:"bytes,2,opt,name=sale_creation_fee_recipient,json=saleCreationFeeRecipient,proto3" json:"sale_creation_fee_recipient,omitempty"` - // minimum amount duration of time between the sale creation and the sale - // start time. - MinDurationUntilStartTime time.Duration `protobuf:"bytes,3,opt,name=min_duration_until_start_time,json=minDurationUntilStartTime,proto3,stdduration" json:"min_duration_until_start_time"` - // minimum duration for every new sale. - MinSaleDuration time.Duration `protobuf:"bytes,4,opt,name=min_sale_duration,json=minSaleDuration,proto3,stdduration" json:"min_sale_duration"` -} - -func (m *Params) Reset() { *m = Params{} } -func (m *Params) String() string { return proto.CompactTextString(m) } -func (*Params) ProtoMessage() {} -func (*Params) Descriptor() ([]byte, []int) { - return fileDescriptor_e87cd402886b5ef9, []int{0} -} -func (m *Params) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Params) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Params.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 *Params) XXX_Merge(src proto.Message) { - xxx_messageInfo_Params.Merge(m, src) -} -func (m *Params) XXX_Size() int { - return m.Size() -} -func (m *Params) XXX_DiscardUnknown() { - xxx_messageInfo_Params.DiscardUnknown(m) -} - -var xxx_messageInfo_Params proto.InternalMessageInfo - -func (m *Params) GetSaleCreationFee() github_com_cosmos_cosmos_sdk_types.Coins { - if m != nil { - return m.SaleCreationFee - } - return nil -} - -func (m *Params) GetSaleCreationFeeRecipient() string { - if m != nil { - return m.SaleCreationFeeRecipient - } - return "" -} - -func (m *Params) GetMinDurationUntilStartTime() time.Duration { - if m != nil { - return m.MinDurationUntilStartTime - } - return 0 -} - -func (m *Params) GetMinSaleDuration() time.Duration { - if m != nil { - return m.MinSaleDuration - } - return 0 -} - -func init() { - proto.RegisterType((*Params)(nil), "osmosis.streamswap.v1.Params") -} - -func init() { - proto.RegisterFile("osmosis/streamswap/v1/params.proto", fileDescriptor_e87cd402886b5ef9) -} - -var fileDescriptor_e87cd402886b5ef9 = []byte{ - // 418 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0x4f, 0x6b, 0xd4, 0x40, - 0x14, 0xcf, 0xb8, 0x52, 0x34, 0x1e, 0x4a, 0x83, 0x42, 0xb6, 0x62, 0xb2, 0xe4, 0xb4, 0x97, 0xce, - 0x90, 0x0a, 0x1e, 0x04, 0x2f, 0xad, 0x78, 0x12, 0x2c, 0xa9, 0x5e, 0xbc, 0x0c, 0x93, 0xf4, 0x35, - 0x0e, 0x66, 0x66, 0x42, 0x66, 0x12, 0xdd, 0x6f, 0x21, 0x88, 0xe0, 0x67, 0xf0, 0x93, 0xf4, 0xd8, - 0xa3, 0xa7, 0x56, 0x76, 0xbf, 0x81, 0x9f, 0x40, 0x32, 0x99, 0xd1, 0xd2, 0xbd, 0x78, 0x4a, 0xde, - 0xfc, 0xfe, 0xbd, 0xf7, 0x78, 0x61, 0xa6, 0xb4, 0x50, 0x9a, 0x6b, 0xa2, 0x4d, 0x07, 0x4c, 0xe8, - 0x4f, 0xac, 0x25, 0x43, 0x4e, 0x5a, 0xd6, 0x31, 0xa1, 0x71, 0xdb, 0x29, 0xa3, 0xa2, 0x47, 0x8e, - 0x83, 0xff, 0x71, 0xf0, 0x90, 0xef, 0x3f, 0xac, 0x55, 0xad, 0x2c, 0x83, 0x8c, 0x7f, 0x13, 0x79, - 0x7f, 0x5e, 0x2b, 0x55, 0x37, 0x40, 0x6c, 0x55, 0xf6, 0xe7, 0x84, 0xc9, 0x95, 0x87, 0x2a, 0x6b, - 0x44, 0x27, 0xcd, 0x54, 0x38, 0x28, 0x99, 0x2a, 0x52, 0x32, 0x0d, 0x64, 0xc8, 0x4b, 0x30, 0x2c, - 0x27, 0x95, 0xe2, 0xd2, 0xe3, 0xb7, 0x5d, 0xcf, 0xfa, 0x8e, 0x19, 0xae, 0x1c, 0x9e, 0x7d, 0x9b, - 0x85, 0x3b, 0x27, 0xb6, 0xe7, 0xe8, 0x2b, 0x0a, 0xf7, 0x34, 0x6b, 0x80, 0x56, 0x1d, 0x58, 0x0a, - 0x3d, 0x07, 0x88, 0xd1, 0x62, 0xb6, 0x7c, 0x70, 0x38, 0xc7, 0x2e, 0x75, 0xcc, 0xc1, 0x2e, 0x07, - 0x1f, 0x2b, 0x2e, 0x8f, 0x5e, 0x5f, 0x5c, 0xa5, 0xc1, 0xef, 0xab, 0x34, 0x5e, 0x31, 0xd1, 0x3c, - 0xcf, 0xb6, 0x1c, 0xb2, 0x1f, 0xd7, 0xe9, 0xb2, 0xe6, 0xe6, 0x43, 0x5f, 0xe2, 0x4a, 0x09, 0xd7, - 0xbe, 0xfb, 0x1c, 0xe8, 0xb3, 0x8f, 0xc4, 0xac, 0x5a, 0xd0, 0xd6, 0x4c, 0x17, 0xbb, 0xa3, 0xfe, - 0xd8, 0xc9, 0x5f, 0x01, 0x44, 0x2f, 0xc2, 0xc7, 0x5b, 0x96, 0xb4, 0x83, 0x8a, 0xb7, 0x1c, 0xa4, - 0x89, 0xef, 0x2c, 0xd0, 0xf2, 0x7e, 0x11, 0xdf, 0x52, 0x15, 0x1e, 0x8f, 0x20, 0x7c, 0x22, 0xb8, - 0xa4, 0x7e, 0x6a, 0xda, 0x4b, 0xc3, 0x1b, 0xaa, 0x0d, 0xeb, 0x0c, 0x35, 0x5c, 0x40, 0x3c, 0x5b, - 0x20, 0x3b, 0xdf, 0xb4, 0x27, 0xec, 0xf7, 0x84, 0x5f, 0x3a, 0xc5, 0xd1, 0xbd, 0x71, 0xbe, 0xef, - 0xd7, 0x29, 0x2a, 0xe6, 0x82, 0x4b, 0xff, 0xfc, 0x6e, 0xf4, 0x39, 0x1d, 0x6d, 0xde, 0x72, 0x01, - 0xd1, 0x9b, 0x70, 0x6f, 0x8c, 0xb1, 0x9d, 0xfa, 0xac, 0xf8, 0xee, 0xff, 0x5b, 0xef, 0x0a, 0x2e, - 0x4f, 0x59, 0x03, 0x7f, 0xa1, 0x93, 0x8b, 0x75, 0x82, 0x2e, 0xd7, 0x09, 0xfa, 0xb5, 0x4e, 0xd0, - 0x97, 0x4d, 0x12, 0x5c, 0x6e, 0x92, 0xe0, 0xe7, 0x26, 0x09, 0xde, 0x3f, 0xbb, 0xb1, 0x4b, 0x77, - 0x5f, 0x07, 0x0d, 0x2b, 0xb5, 0x2f, 0xc8, 0x90, 0x1f, 0x92, 0xcf, 0x37, 0xcf, 0xd2, 0xee, 0xb7, - 0xdc, 0xb1, 0xf9, 0x4f, 0xff, 0x04, 0x00, 0x00, 0xff, 0xff, 0x87, 0x6c, 0xd4, 0x78, 0xb9, 0x02, - 0x00, 0x00, -} - -func (m *Params) 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 *Params) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Params) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MinSaleDuration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinSaleDuration):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintParams(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x22 - n2, err2 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.MinDurationUntilStartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinDurationUntilStartTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintParams(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x1a - if len(m.SaleCreationFeeRecipient) > 0 { - i -= len(m.SaleCreationFeeRecipient) - copy(dAtA[i:], m.SaleCreationFeeRecipient) - i = encodeVarintParams(dAtA, i, uint64(len(m.SaleCreationFeeRecipient))) - i-- - dAtA[i] = 0x12 - } - if len(m.SaleCreationFee) > 0 { - for iNdEx := len(m.SaleCreationFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.SaleCreationFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintParams(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func encodeVarintParams(dAtA []byte, offset int, v uint64) int { - offset -= sovParams(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Params) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.SaleCreationFee) > 0 { - for _, e := range m.SaleCreationFee { - l = e.Size() - n += 1 + l + sovParams(uint64(l)) - } - } - l = len(m.SaleCreationFeeRecipient) - if l > 0 { - n += 1 + l + sovParams(uint64(l)) - } - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinDurationUntilStartTime) - n += 1 + l + sovParams(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.MinSaleDuration) - n += 1 + l + sovParams(uint64(l)) - return n -} - -func sovParams(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozParams(x uint64) (n int) { - return sovParams(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Params) 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 ErrIntOverflowParams - } - 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: Params: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Params: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleCreationFee", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SaleCreationFee = append(m.SaleCreationFee, types.Coin{}) - if err := m.SaleCreationFee[len(m.SaleCreationFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleCreationFeeRecipient", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - 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 ErrInvalidLengthParams - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SaleCreationFeeRecipient = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinDurationUntilStartTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MinDurationUntilStartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinSaleDuration", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowParams - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthParams - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthParams - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.MinSaleDuration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipParams(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthParams - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipParams(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowParams - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthParams - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupParams - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthParams - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthParams = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowParams = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupParams = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/streamswap/types/query.pb.go b/x/streamswap/types/query.pb.go deleted file mode 100644 index 3c0fe540961..00000000000 --- a/x/streamswap/types/query.pb.go +++ /dev/null @@ -1,1404 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/query.proto - -package types - -import ( - context "context" - fmt "fmt" - query "github.com/cosmos/cosmos-sdk/types/query" - _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" - _ "google.golang.org/genproto/googleapis/api/annotations" - 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. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type QuerySales struct { - // pagination defines an pagination for the request. - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QuerySales) Reset() { *m = QuerySales{} } -func (m *QuerySales) String() string { return proto.CompactTextString(m) } -func (*QuerySales) ProtoMessage() {} -func (*QuerySales) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{0} -} -func (m *QuerySales) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySales) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySales.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 *QuerySales) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySales.Merge(m, src) -} -func (m *QuerySales) XXX_Size() int { - return m.Size() -} -func (m *QuerySales) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySales.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySales proto.InternalMessageInfo - -type QuerySalesResponse struct { - Sales []Sale `protobuf:"bytes,1,rep,name=sales,proto3" json:"sales"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` -} - -func (m *QuerySalesResponse) Reset() { *m = QuerySalesResponse{} } -func (m *QuerySalesResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySalesResponse) ProtoMessage() {} -func (*QuerySalesResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{1} -} -func (m *QuerySalesResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySalesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySalesResponse.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 *QuerySalesResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySalesResponse.Merge(m, src) -} -func (m *QuerySalesResponse) XXX_Size() int { - return m.Size() -} -func (m *QuerySalesResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySalesResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySalesResponse proto.InternalMessageInfo - -// Request type for Query/Sale -type QuerySale struct { - // Sale ID - SaleId uint64 `protobuf:"varint,1,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` -} - -func (m *QuerySale) Reset() { *m = QuerySale{} } -func (m *QuerySale) String() string { return proto.CompactTextString(m) } -func (*QuerySale) ProtoMessage() {} -func (*QuerySale) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{2} -} -func (m *QuerySale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySale.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 *QuerySale) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySale.Merge(m, src) -} -func (m *QuerySale) XXX_Size() int { - return m.Size() -} -func (m *QuerySale) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySale.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySale proto.InternalMessageInfo - -type QuerySaleResponse struct { - Sale Sale `protobuf:"bytes,1,opt,name=sale,proto3" json:"sale"` -} - -func (m *QuerySaleResponse) Reset() { *m = QuerySaleResponse{} } -func (m *QuerySaleResponse) String() string { return proto.CompactTextString(m) } -func (*QuerySaleResponse) ProtoMessage() {} -func (*QuerySaleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{3} -} -func (m *QuerySaleResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QuerySaleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QuerySaleResponse.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 *QuerySaleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QuerySaleResponse.Merge(m, src) -} -func (m *QuerySaleResponse) XXX_Size() int { - return m.Size() -} -func (m *QuerySaleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QuerySaleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QuerySaleResponse proto.InternalMessageInfo - -// Request type for Query/Sale -type QueryUserPosition struct { - // ID of the Sale - SaleId uint64 `protobuf:"varint,1,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - // user account address - User string `protobuf:"bytes,2,opt,name=user,proto3" json:"user,omitempty"` -} - -func (m *QueryUserPosition) Reset() { *m = QueryUserPosition{} } -func (m *QueryUserPosition) String() string { return proto.CompactTextString(m) } -func (*QueryUserPosition) ProtoMessage() {} -func (*QueryUserPosition) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{4} -} -func (m *QueryUserPosition) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUserPosition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUserPosition.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 *QueryUserPosition) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUserPosition.Merge(m, src) -} -func (m *QueryUserPosition) XXX_Size() int { - return m.Size() -} -func (m *QueryUserPosition) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUserPosition.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUserPosition proto.InternalMessageInfo - -type QueryUserPositionResponse struct { - UserPosition UserPosition `protobuf:"bytes,1,opt,name=user_position,json=userPosition,proto3" json:"user_position"` -} - -func (m *QueryUserPositionResponse) Reset() { *m = QueryUserPositionResponse{} } -func (m *QueryUserPositionResponse) String() string { return proto.CompactTextString(m) } -func (*QueryUserPositionResponse) ProtoMessage() {} -func (*QueryUserPositionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_3fb259eb5fae3ea4, []int{5} -} -func (m *QueryUserPositionResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *QueryUserPositionResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_QueryUserPositionResponse.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 *QueryUserPositionResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_QueryUserPositionResponse.Merge(m, src) -} -func (m *QueryUserPositionResponse) XXX_Size() int { - return m.Size() -} -func (m *QueryUserPositionResponse) XXX_DiscardUnknown() { - xxx_messageInfo_QueryUserPositionResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_QueryUserPositionResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*QuerySales)(nil), "osmosis.streamswap.v1.QuerySales") - proto.RegisterType((*QuerySalesResponse)(nil), "osmosis.streamswap.v1.QuerySalesResponse") - proto.RegisterType((*QuerySale)(nil), "osmosis.streamswap.v1.QuerySale") - proto.RegisterType((*QuerySaleResponse)(nil), "osmosis.streamswap.v1.QuerySaleResponse") - proto.RegisterType((*QueryUserPosition)(nil), "osmosis.streamswap.v1.QueryUserPosition") - proto.RegisterType((*QueryUserPositionResponse)(nil), "osmosis.streamswap.v1.QueryUserPositionResponse") -} - -func init() { proto.RegisterFile("osmosis/streamswap/v1/query.proto", fileDescriptor_3fb259eb5fae3ea4) } - -var fileDescriptor_3fb259eb5fae3ea4 = []byte{ - // 528 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x4f, 0x6f, 0xd3, 0x30, - 0x18, 0xc6, 0x9b, 0x2d, 0x1d, 0x9a, 0x37, 0x0e, 0x58, 0x20, 0x46, 0x06, 0xa1, 0xcb, 0x80, 0x15, - 0xc4, 0x6c, 0x52, 0xfe, 0x5d, 0xd1, 0x0e, 0x20, 0x38, 0xa0, 0x11, 0xc6, 0x85, 0xcb, 0xe4, 0x6c, - 0x56, 0x88, 0x68, 0xe3, 0x2c, 0xaf, 0x53, 0x18, 0xd3, 0x0e, 0xf0, 0x09, 0x90, 0x90, 0x38, 0x73, - 0xe6, 0x93, 0xf4, 0x38, 0x89, 0x0b, 0x27, 0x04, 0x2d, 0x1f, 0x04, 0xd9, 0xf1, 0xd2, 0x14, 0xe8, - 0xda, 0x5b, 0x12, 0xff, 0xf2, 0x3c, 0x3f, 0xe7, 0xb5, 0x82, 0x56, 0x04, 0x74, 0x04, 0xc4, 0x40, - 0x41, 0x66, 0x9c, 0x75, 0xe0, 0x0d, 0x4b, 0x69, 0xd7, 0xa7, 0x7b, 0x39, 0xcf, 0xf6, 0x49, 0x9a, - 0x09, 0x29, 0xf0, 0x39, 0x83, 0x90, 0x21, 0x42, 0xba, 0xbe, 0x73, 0x36, 0x12, 0x91, 0xd0, 0x04, - 0x55, 0x57, 0x05, 0xec, 0x5c, 0x8c, 0x84, 0x88, 0xda, 0x9c, 0xb2, 0x34, 0xa6, 0x2c, 0x49, 0x84, - 0x64, 0x32, 0x16, 0x09, 0x98, 0xd5, 0x1b, 0x3b, 0x3a, 0x8b, 0x86, 0x0c, 0x78, 0xd1, 0x41, 0xbb, - 0x7e, 0xc8, 0x25, 0xf3, 0x69, 0xca, 0xa2, 0x38, 0xd1, 0xb0, 0x61, 0xc7, 0x98, 0x81, 0x64, 0x92, - 0x17, 0x88, 0xb7, 0x85, 0xd0, 0x33, 0x15, 0xf2, 0x9c, 0xb5, 0x39, 0xe0, 0x87, 0x08, 0x0d, 0x43, - 0x96, 0xac, 0x86, 0xd5, 0x5c, 0x68, 0x5d, 0x23, 0x45, 0x23, 0x51, 0x8d, 0xa4, 0xd8, 0x95, 0x69, - 0x24, 0x9b, 0x2c, 0xe2, 0x01, 0xdf, 0xcb, 0x39, 0xc8, 0xa0, 0xf2, 0xa6, 0xf7, 0xd9, 0x42, 0x78, - 0x18, 0x1b, 0x70, 0x48, 0x45, 0x02, 0x1c, 0xdf, 0x47, 0x75, 0x50, 0x0f, 0x96, 0xac, 0xc6, 0x6c, - 0x73, 0xa1, 0xb5, 0x4c, 0xfe, 0xfb, 0x59, 0x88, 0x7a, 0x69, 0xc3, 0xee, 0xfd, 0xb8, 0x5c, 0x0b, - 0x0a, 0x1e, 0x3f, 0x1a, 0xf1, 0x9a, 0xd1, 0x5e, 0x6b, 0x13, 0xbd, 0x8a, 0xd6, 0x11, 0xb1, 0x2b, - 0x68, 0xbe, 0xf4, 0xc2, 0xe7, 0xd1, 0x29, 0x15, 0xbf, 0x1d, 0xef, 0xea, 0xad, 0xda, 0xc1, 0x9c, - 0xba, 0x7d, 0xbc, 0xeb, 0x3d, 0x41, 0x67, 0x4a, 0xaa, 0x94, 0xbf, 0x8b, 0x6c, 0xb5, 0x6c, 0xbe, - 0xca, 0x14, 0xee, 0x1a, 0xf7, 0x1e, 0x98, 0xac, 0x17, 0xc0, 0xb3, 0x4d, 0x01, 0xb1, 0xd2, 0x18, - 0xdb, 0x8c, 0x31, 0xb2, 0x73, 0xe0, 0x99, 0xde, 0xe2, 0x7c, 0xa0, 0xaf, 0xbd, 0xd7, 0xe8, 0xc2, - 0x3f, 0x09, 0xa5, 0xd5, 0x53, 0x74, 0x5a, 0x41, 0xdb, 0xa9, 0x59, 0x30, 0x7a, 0xab, 0x63, 0xf4, - 0xaa, 0x19, 0x46, 0x73, 0x31, 0xaf, 0x3c, 0x6b, 0x7d, 0x9d, 0x45, 0x75, 0xdd, 0x86, 0xdf, 0xa1, - 0x7a, 0x71, 0x28, 0x56, 0xc6, 0x64, 0x0d, 0x07, 0xec, 0x5c, 0x9f, 0x88, 0x1c, 0x0b, 0x7b, 0xab, - 0x1f, 0xbe, 0xfd, 0xfe, 0x34, 0x73, 0x09, 0x2f, 0x53, 0x73, 0x90, 0xff, 0x3a, 0x9b, 0xba, 0xf2, - 0xbd, 0x85, 0x6c, 0x3d, 0xa2, 0xc6, 0xa4, 0x60, 0xa7, 0x39, 0x89, 0x28, 0x9b, 0xd7, 0x75, 0xf3, - 0x1a, 0xbe, 0x7a, 0x42, 0x33, 0x3d, 0x30, 0x73, 0x39, 0xc4, 0x5f, 0x2c, 0xb4, 0x38, 0x32, 0xb4, - 0x13, 0x9b, 0xaa, 0xa4, 0x73, 0x6b, 0x5a, 0xb2, 0x74, 0xbb, 0xa3, 0xdd, 0x08, 0xbe, 0x39, 0x95, - 0x1b, 0x3d, 0x50, 0x33, 0x3b, 0xdc, 0xd8, 0xea, 0xfd, 0x72, 0x6b, 0xbd, 0xbe, 0x6b, 0x1d, 0xf5, - 0x5d, 0xeb, 0x67, 0xdf, 0xb5, 0x3e, 0x0e, 0xdc, 0xda, 0xd1, 0xc0, 0xad, 0x7d, 0x1f, 0xb8, 0xb5, - 0x97, 0xf7, 0xa2, 0x58, 0xbe, 0xca, 0x43, 0xb2, 0x23, 0x3a, 0xd4, 0xf8, 0xac, 0xb7, 0x59, 0x08, - 0xc7, 0x37, 0xb4, 0xeb, 0xb7, 0xe8, 0xdb, 0x6a, 0x93, 0xdc, 0x4f, 0x39, 0x84, 0x73, 0xfa, 0xcf, - 0x70, 0xfb, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x1d, 0xdc, 0xd4, 0x91, 0xd8, 0x04, 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// QueryClient is the client API for Query service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. -type QueryClient interface { - // Returns list of Sales ordered by the creation time - Sales(ctx context.Context, in *QuerySales, opts ...grpc.CallOption) (*QuerySalesResponse, error) - // Returns the specific Sale object - Sale(ctx context.Context, in *QuerySale, opts ...grpc.CallOption) (*QuerySaleResponse, error) - UserPosition(ctx context.Context, in *QueryUserPosition, opts ...grpc.CallOption) (*QueryUserPositionResponse, error) -} - -type queryClient struct { - cc grpc1.ClientConn -} - -func NewQueryClient(cc grpc1.ClientConn) QueryClient { - return &queryClient{cc} -} - -func (c *queryClient) Sales(ctx context.Context, in *QuerySales, opts ...grpc.CallOption) (*QuerySalesResponse, error) { - out := new(QuerySalesResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Query/Sales", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) Sale(ctx context.Context, in *QuerySale, opts ...grpc.CallOption) (*QuerySaleResponse, error) { - out := new(QuerySaleResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Query/Sale", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *queryClient) UserPosition(ctx context.Context, in *QueryUserPosition, opts ...grpc.CallOption) (*QueryUserPositionResponse, error) { - out := new(QueryUserPositionResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Query/UserPosition", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// QueryServer is the server API for Query service. -type QueryServer interface { - // Returns list of Sales ordered by the creation time - Sales(context.Context, *QuerySales) (*QuerySalesResponse, error) - // Returns the specific Sale object - Sale(context.Context, *QuerySale) (*QuerySaleResponse, error) - UserPosition(context.Context, *QueryUserPosition) (*QueryUserPositionResponse, error) -} - -// UnimplementedQueryServer can be embedded to have forward compatible implementations. -type UnimplementedQueryServer struct { -} - -func (*UnimplementedQueryServer) Sales(ctx context.Context, req *QuerySales) (*QuerySalesResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Sales not implemented") -} -func (*UnimplementedQueryServer) Sale(ctx context.Context, req *QuerySale) (*QuerySaleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method Sale not implemented") -} -func (*UnimplementedQueryServer) UserPosition(ctx context.Context, req *QueryUserPosition) (*QueryUserPositionResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method UserPosition not implemented") -} - -func RegisterQueryServer(s grpc1.Server, srv QueryServer) { - s.RegisterService(&_Query_serviceDesc, srv) -} - -func _Query_Sales_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySales) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Sales(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Query/Sales", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Sales(ctx, req.(*QuerySales)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_Sale_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QuerySale) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).Sale(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Query/Sale", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).Sale(ctx, req.(*QuerySale)) - } - return interceptor(ctx, in, info, handler) -} - -func _Query_UserPosition_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryUserPosition) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(QueryServer).UserPosition(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Query/UserPosition", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(QueryServer).UserPosition(ctx, req.(*QueryUserPosition)) - } - return interceptor(ctx, in, info, handler) -} - -var _Query_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.streamswap.v1.Query", - HandlerType: (*QueryServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Sales", - Handler: _Query_Sales_Handler, - }, - { - MethodName: "Sale", - Handler: _Query_Sale_Handler, - }, - { - MethodName: "UserPosition", - Handler: _Query_UserPosition_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/streamswap/v1/query.proto", -} - -func (m *QuerySales) 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 *QuerySales) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySales) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *QuerySalesResponse) 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 *QuerySalesResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySalesResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Pagination != nil { - { - size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.Sales) > 0 { - for iNdEx := len(m.Sales) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Sales[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *QuerySale) 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 *QuerySale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SaleId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QuerySaleResponse) 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 *QuerySaleResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QuerySaleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.Sale.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *QueryUserPosition) 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 *QueryUserPosition) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUserPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.User) > 0 { - i -= len(m.User) - copy(dAtA[i:], m.User) - i = encodeVarintQuery(dAtA, i, uint64(len(m.User))) - i-- - dAtA[i] = 0x12 - } - if m.SaleId != 0 { - i = encodeVarintQuery(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *QueryUserPositionResponse) 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 *QueryUserPositionResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *QueryUserPositionResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size, err := m.UserPosition.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintQuery(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintQuery(dAtA []byte, offset int, v uint64) int { - offset -= sovQuery(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *QuerySales) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QuerySalesResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Sales) > 0 { - for _, e := range m.Sales { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) - } - } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QuerySale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SaleId != 0 { - n += 1 + sovQuery(uint64(m.SaleId)) - } - return n -} - -func (m *QuerySaleResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Sale.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func (m *QueryUserPosition) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SaleId != 0 { - n += 1 + sovQuery(uint64(m.SaleId)) - } - l = len(m.User) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) - } - return n -} - -func (m *QueryUserPositionResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.UserPosition.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} - -func sovQuery(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozQuery(x uint64) (n int) { - return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *QuerySales) 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 ErrIntOverflowQuery - } - 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: QuerySales: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySales: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageRequest{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QuerySalesResponse) 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 ErrIntOverflowQuery - } - 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: QuerySalesResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySalesResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sales", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Sales = append(m.Sales, Sale{}) - if err := m.Sales[len(m.Sales)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Pagination == nil { - m.Pagination = &query.PageResponse{} - } - if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QuerySale) 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 ErrIntOverflowQuery - } - 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: QuerySale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QuerySaleResponse) 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 ErrIntOverflowQuery - } - 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: QuerySaleResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QuerySaleResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Sale", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Sale.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUserPosition) 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 ErrIntOverflowQuery - } - 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: QueryUserPosition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserPosition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field User", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - 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 ErrInvalidLengthQuery - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.User = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *QueryUserPositionResponse) 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 ErrIntOverflowQuery - } - 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: QueryUserPositionResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: QueryUserPositionResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserPosition", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowQuery - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthQuery - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthQuery - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.UserPosition.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipQuery(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthQuery - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipQuery(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowQuery - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthQuery - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupQuery - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthQuery - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/streamswap/types/query.pb.gw.go b/x/streamswap/types/query.pb.gw.go deleted file mode 100644 index 2c3073c0204..00000000000 --- a/x/streamswap/types/query.pb.gw.go +++ /dev/null @@ -1,395 +0,0 @@ -// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. -// source: osmosis/streamswap/v1/query.proto - -/* -Package types is a reverse proxy. - -It translates gRPC into RESTful JSON APIs. -*/ -package types - -import ( - "context" - "io" - "net/http" - - "github.com/golang/protobuf/descriptor" - "github.com/golang/protobuf/proto" - "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/grpc-ecosystem/grpc-gateway/utilities" - "google.golang.org/grpc" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/grpclog" - "google.golang.org/grpc/metadata" - "google.golang.org/grpc/status" -) - -// Suppress "imported and not used" errors -var _ codes.Code -var _ io.Reader -var _ status.Status -var _ = runtime.String -var _ = utilities.NewDoubleArray -var _ = descriptor.ForMessage -var _ = metadata.Join - -var ( - filter_Query_Sales_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} -) - -func request_Query_Sales_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySales - 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_Sales_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := client.Sales(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Sales_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySales - 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_Sales_0); err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) - } - - msg, err := server.Sales(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_Sale_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySale - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["sale_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sale_id") - } - - protoReq.SaleId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sale_id", err) - } - - msg, err := client.Sale(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_Sale_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QuerySale - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["sale_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sale_id") - } - - protoReq.SaleId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sale_id", err) - } - - msg, err := server.Sale(ctx, &protoReq) - return msg, metadata, err - -} - -func request_Query_UserPosition_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUserPosition - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["sale_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sale_id") - } - - protoReq.SaleId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sale_id", err) - } - - val, ok = pathParams["user"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user") - } - - protoReq.User, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) - } - - msg, err := client.UserPosition(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) - return msg, metadata, err - -} - -func local_request_Query_UserPosition_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { - var protoReq QueryUserPosition - var metadata runtime.ServerMetadata - - var ( - val string - ok bool - err error - _ = err - ) - - val, ok = pathParams["sale_id"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "sale_id") - } - - protoReq.SaleId, err = runtime.Uint64(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "sale_id", err) - } - - val, ok = pathParams["user"] - if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "user") - } - - protoReq.User, err = runtime.String(val) - - if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "user", err) - } - - msg, err := server.UserPosition(ctx, &protoReq) - return msg, metadata, err - -} - -// 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 to stop working. Consider using RegisterQueryHandlerFromEndpoint instead. -func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error { - - mux.Handle("GET", pattern_Query_Sales_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_Sales_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_Sales_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Sale_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_Sale_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_Sale_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_UserPosition_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_UserPosition_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_UserPosition_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but -// automatically dials to "endpoint" and closes the connection when "ctx" gets done. -func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) { - conn, err := grpc.Dial(endpoint, opts...) - if err != nil { - return err - } - defer func() { - if err != nil { - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - return - } - go func() { - <-ctx.Done() - if cerr := conn.Close(); cerr != nil { - grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr) - } - }() - }() - - return RegisterQueryHandler(ctx, mux, conn) -} - -// RegisterQueryHandler registers the http handlers for service Query to "mux". -// The handlers forward requests to the grpc endpoint over "conn". -func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { - return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn)) -} - -// RegisterQueryHandlerClient registers the http handlers for service Query -// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient". -// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient" -// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in -// "QueryClient" to call the correct interceptors. -func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error { - - mux.Handle("GET", pattern_Query_Sales_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) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Sales_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_Sales_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_Sale_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) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_Sale_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_Sale_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - mux.Handle("GET", pattern_Query_UserPosition_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) - rctx, err := runtime.AnnotateContext(ctx, mux, req) - if err != nil { - runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) - return - } - resp, md, err := request_Query_UserPosition_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_UserPosition_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) - - }) - - return nil -} - -var ( - pattern_Query_Sales_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"cosmos", "streamswap", "v1", "sales"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_Sale_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"cosmos", "streamswap", "v1", "sales", "sale_id"}, "", runtime.AssumeColonVerbOpt(false))) - - pattern_Query_UserPosition_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4, 1, 0, 4, 1, 5, 5}, []string{"cosmos", "streamswap", "v1", "sales", "sale_id", "user"}, "", runtime.AssumeColonVerbOpt(false))) -) - -var ( - forward_Query_Sales_0 = runtime.ForwardResponseMessage - - forward_Query_Sale_0 = runtime.ForwardResponseMessage - - forward_Query_UserPosition_0 = runtime.ForwardResponseMessage -) diff --git a/x/streamswap/types/state.pb.go b/x/streamswap/types/state.pb.go deleted file mode 100644 index b4e8695d297..00000000000 --- a/x/streamswap/types/state.pb.go +++ /dev/null @@ -1,1400 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/state.proto - -package types - -import ( - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type Sale struct { - // Destination for the earned token_in - Treasury string `protobuf:"bytes,1,opt,name=treasury,proto3" json:"treasury,omitempty"` - Id uint64 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` - // token_out is a token denom to be bootstraped. May be referred as base - // currency, or a sale token. - TokenOut string `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out,omitempty"` - // token_in is a token denom used to buy sale tokens (`token_out`). May be - // referred as quote_currency or payment token. - TokenIn string `protobuf:"bytes,4,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty"` - // total number of `tokens_out` to be sold during the continuous sale. - TokenOutSupply github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=token_out_supply,json=tokenOutSupply,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"token_out_supply"` - // start time when the token emission starts. - StartTime time.Time `protobuf:"bytes,6,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` - // end time when the token emission ends. Can't be bigger than start + - // 139years (to avoid round overflow) - EndTime time.Time `protobuf:"bytes,7,opt,name=end_time,json=endTime,proto3,stdtime" json:"end_time"` - // Round number when the sale was last time updated. - Round int64 `protobuf:"varint,8,opt,name=round,proto3" json:"round,omitempty"` - // Last round of the Sale; - EndRound int64 `protobuf:"varint,9,opt,name=end_round,json=endRound,proto3" json:"end_round,omitempty"` - // amout of remaining token_out to sell - OutRemaining github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,10,opt,name=out_remaining,json=outRemaining,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"out_remaining"` - // amount of token_out sold - OutSold github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,11,opt,name=out_sold,json=outSold,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"out_sold"` - // out token per share - OutPerShare github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,12,opt,name=out_per_share,json=outPerShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"out_per_share"` - // total amount of currently staked coins (token_in) but not spent coins. - Staked github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,13,opt,name=staked,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"staked"` - // total amount of earned coins (token_in) - Income github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,14,opt,name=income,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"income"` - // total amount of shares - Shares github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,15,opt,name=shares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"shares"` - // Name for the sale. - Name string `protobuf:"bytes,20,opt,name=name,proto3" json:"name,omitempty"` - // URL with sale and project details. - Url string `protobuf:"bytes,21,opt,name=url,proto3" json:"url,omitempty"` -} - -func (m *Sale) Reset() { *m = Sale{} } -func (m *Sale) String() string { return proto.CompactTextString(m) } -func (*Sale) ProtoMessage() {} -func (*Sale) Descriptor() ([]byte, []int) { - return fileDescriptor_7602494b1425cb83, []int{0} -} -func (m *Sale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Sale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Sale.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 *Sale) XXX_Merge(src proto.Message) { - xxx_messageInfo_Sale.Merge(m, src) -} -func (m *Sale) XXX_Size() int { - return m.Size() -} -func (m *Sale) XXX_DiscardUnknown() { - xxx_messageInfo_Sale.DiscardUnknown(m) -} - -var xxx_messageInfo_Sale proto.InternalMessageInfo - -// UserPosition represents user account in a sale -type UserPosition struct { - Shares github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=shares,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"shares"` - // total number of currently staked tokens - Staked github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,2,opt,name=staked,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"staked"` - // last token/share ratio - OutPerShare github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=out_per_share,json=outPerShare,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"out_per_share"` - // amount of token_in spent - Spent github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,4,opt,name=spent,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"spent"` - // Amount of accumulated, not withdrawn, purchased tokens (token_out) - Purchased github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,5,opt,name=purchased,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"purchased"` -} - -func (m *UserPosition) Reset() { *m = UserPosition{} } -func (m *UserPosition) String() string { return proto.CompactTextString(m) } -func (*UserPosition) ProtoMessage() {} -func (*UserPosition) Descriptor() ([]byte, []int) { - return fileDescriptor_7602494b1425cb83, []int{1} -} -func (m *UserPosition) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *UserPosition) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_UserPosition.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 *UserPosition) XXX_Merge(src proto.Message) { - xxx_messageInfo_UserPosition.Merge(m, src) -} -func (m *UserPosition) XXX_Size() int { - return m.Size() -} -func (m *UserPosition) XXX_DiscardUnknown() { - xxx_messageInfo_UserPosition.DiscardUnknown(m) -} - -var xxx_messageInfo_UserPosition proto.InternalMessageInfo - -func init() { - proto.RegisterType((*Sale)(nil), "osmosis.streamswap.v1.Sale") - proto.RegisterType((*UserPosition)(nil), "osmosis.streamswap.v1.UserPosition") -} - -func init() { proto.RegisterFile("osmosis/streamswap/v1/state.proto", fileDescriptor_7602494b1425cb83) } - -var fileDescriptor_7602494b1425cb83 = []byte{ - // 584 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xa4, 0x94, 0xcb, 0x6a, 0xdb, 0x4c, - 0x14, 0xc7, 0x2d, 0xdb, 0xf1, 0x65, 0x72, 0xf9, 0xc2, 0x90, 0xc0, 0xc4, 0x1f, 0xc8, 0x6e, 0x16, - 0xc5, 0x9b, 0x48, 0x24, 0x85, 0x6e, 0x0b, 0x69, 0x29, 0x18, 0x0a, 0x0d, 0x72, 0x0a, 0xa5, 0x1b, - 0x31, 0xb6, 0xa6, 0xb2, 0xb0, 0x34, 0x23, 0xe6, 0xe2, 0xd6, 0x2f, 0xd0, 0x75, 0x1e, 0xcb, 0xcb, - 0x2c, 0x4b, 0x17, 0x69, 0x6b, 0x3f, 0x40, 0x5f, 0xa1, 0xcc, 0x8c, 0x1c, 0x1b, 0xba, 0x8a, 0xbc, - 0xf2, 0x9c, 0xcb, 0xff, 0x77, 0x0e, 0x7f, 0x99, 0x03, 0x9e, 0x31, 0x91, 0x31, 0x91, 0x08, 0x5f, - 0x48, 0x4e, 0x70, 0x26, 0xbe, 0xe0, 0xdc, 0x9f, 0x5d, 0xfa, 0x42, 0x62, 0x49, 0xbc, 0x9c, 0x33, - 0xc9, 0xe0, 0x69, 0xd1, 0xe2, 0x6d, 0x5a, 0xbc, 0xd9, 0x65, 0xa7, 0x1b, 0x33, 0x16, 0xa7, 0xc4, - 0x37, 0x4d, 0x23, 0xf5, 0xd9, 0x97, 0x49, 0x46, 0x84, 0xc4, 0x59, 0x6e, 0x75, 0x9d, 0xb3, 0xb1, - 0x11, 0x86, 0x26, 0xf2, 0x6d, 0x50, 0x94, 0x4e, 0x62, 0x16, 0x33, 0x9b, 0xd7, 0x2f, 0x9b, 0x3d, - 0xff, 0xd3, 0x00, 0xf5, 0x21, 0x4e, 0x09, 0xec, 0x80, 0x96, 0x1e, 0x25, 0x14, 0x9f, 0x23, 0xa7, - 0xe7, 0xf4, 0xdb, 0xc1, 0x63, 0x0c, 0x8f, 0x40, 0x35, 0x89, 0x50, 0xb5, 0xe7, 0xf4, 0xeb, 0x41, - 0x35, 0x89, 0xe0, 0xff, 0xa0, 0x2d, 0xd9, 0x94, 0xd0, 0x90, 0x29, 0x89, 0x6a, 0x45, 0xb3, 0x4e, - 0xbc, 0x57, 0x12, 0x9e, 0x01, 0xfb, 0x0e, 0x13, 0x8a, 0xea, 0xa6, 0xd6, 0x34, 0xf1, 0x80, 0xc2, - 0x8f, 0xe0, 0xf8, 0x51, 0x17, 0x0a, 0x95, 0xe7, 0xe9, 0x1c, 0xed, 0xe9, 0x96, 0x6b, 0x6f, 0xf1, - 0xd0, 0xad, 0xfc, 0x78, 0xe8, 0x3e, 0x8f, 0x13, 0x39, 0x51, 0x23, 0x6f, 0xcc, 0xb2, 0x62, 0xfb, - 0xe2, 0xe7, 0x42, 0x44, 0x53, 0x5f, 0xce, 0x73, 0x22, 0xbc, 0x01, 0x95, 0xc1, 0xd1, 0x7a, 0xdc, - 0xd0, 0x50, 0xe0, 0x6b, 0x00, 0x84, 0xc4, 0x5c, 0x86, 0xda, 0x10, 0xd4, 0xe8, 0x39, 0xfd, 0xfd, - 0xab, 0x8e, 0x67, 0xdd, 0xf2, 0xd6, 0x6e, 0x79, 0xb7, 0x6b, 0xb7, 0xae, 0x5b, 0x7a, 0xde, 0xdd, - 0xcf, 0xae, 0x13, 0xb4, 0x8d, 0x4e, 0x57, 0xe0, 0x2b, 0xd0, 0x22, 0x34, 0xb2, 0x88, 0xe6, 0x13, - 0x10, 0x4d, 0x42, 0x23, 0x03, 0x38, 0x01, 0x7b, 0x9c, 0x29, 0x1a, 0xa1, 0x56, 0xcf, 0xe9, 0xd7, - 0x02, 0x1b, 0x68, 0xb7, 0x34, 0xd6, 0x56, 0xda, 0xa6, 0xa2, 0xe7, 0x04, 0xa6, 0x38, 0x04, 0x87, - 0xda, 0x0c, 0x4e, 0x32, 0x9c, 0xd0, 0x84, 0xc6, 0x08, 0x94, 0xf2, 0xe3, 0x80, 0x29, 0x19, 0xac, - 0x19, 0x70, 0x00, 0x5a, 0xc6, 0x61, 0x96, 0x46, 0x68, 0xbf, 0x14, 0xaf, 0xc9, 0x94, 0x1c, 0xb2, - 0x34, 0x82, 0x81, 0xdd, 0x2f, 0x27, 0x3c, 0x14, 0x13, 0xcc, 0x09, 0x3a, 0x28, 0xc5, 0xdb, 0x67, - 0x4a, 0xde, 0x10, 0x3e, 0xd4, 0x08, 0xf8, 0x16, 0x34, 0x84, 0xc4, 0x53, 0x12, 0xa1, 0xc3, 0x52, - 0xb0, 0x42, 0xad, 0x39, 0x09, 0x1d, 0xb3, 0x8c, 0xa0, 0xa3, 0x72, 0x1c, 0xab, 0x36, 0xfb, 0xe8, - 0xc5, 0x04, 0xfa, 0xaf, 0xe4, 0x3e, 0x46, 0x0d, 0x21, 0xa8, 0x53, 0x9c, 0x11, 0x74, 0x62, 0xfe, - 0xf5, 0xe6, 0x0d, 0x8f, 0x41, 0x4d, 0xf1, 0x14, 0x9d, 0x9a, 0x94, 0x7e, 0x9e, 0x7f, 0xab, 0x81, - 0x83, 0x0f, 0x82, 0xf0, 0x1b, 0x26, 0x12, 0x99, 0x30, 0xba, 0x35, 0xde, 0xd9, 0x69, 0xfc, 0xc6, - 0xd6, 0xea, 0x4e, 0xb6, 0xfe, 0xf3, 0xc9, 0x6b, 0xbb, 0x7f, 0xf2, 0x37, 0x60, 0x4f, 0xe4, 0x84, - 0x4a, 0x7b, 0x11, 0x9e, 0xcc, 0xb2, 0x62, 0xf8, 0x0e, 0xb4, 0x73, 0xc5, 0xc7, 0x13, 0x2c, 0x48, - 0x54, 0xf2, 0x70, 0x6c, 0x00, 0xd7, 0xb7, 0x8b, 0xdf, 0x6e, 0x65, 0xb1, 0x74, 0x9d, 0xfb, 0xa5, - 0xeb, 0xfc, 0x5a, 0xba, 0xce, 0xdd, 0xca, 0xad, 0xdc, 0xaf, 0xdc, 0xca, 0xf7, 0x95, 0x5b, 0xf9, - 0xf4, 0x72, 0x0b, 0x58, 0x1c, 0xe3, 0x8b, 0x14, 0x8f, 0xc4, 0x3a, 0xf0, 0x67, 0x97, 0x57, 0xfe, - 0xd7, 0xed, 0x13, 0x6e, 0x86, 0x8c, 0x1a, 0xe6, 0x54, 0xbc, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, - 0xae, 0x73, 0x1c, 0x24, 0xe5, 0x05, 0x00, 0x00, -} - -func (m *Sale) 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 *Sale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Sale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Url) > 0 { - i -= len(m.Url) - copy(dAtA[i:], m.Url) - i = encodeVarintState(dAtA, i, uint64(len(m.Url))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xaa - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintState(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x1 - i-- - dAtA[i] = 0xa2 - } - { - size := m.Shares.Size() - i -= size - if _, err := m.Shares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x7a - { - size := m.Income.Size() - i -= size - if _, err := m.Income.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x72 - { - size := m.Staked.Size() - i -= size - if _, err := m.Staked.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x6a - { - size := m.OutPerShare.Size() - i -= size - if _, err := m.OutPerShare.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x62 - { - size := m.OutSold.Size() - i -= size - if _, err := m.OutSold.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x5a - { - size := m.OutRemaining.Size() - i -= size - if _, err := m.OutRemaining.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x52 - if m.EndRound != 0 { - i = encodeVarintState(dAtA, i, uint64(m.EndRound)) - i-- - dAtA[i] = 0x48 - } - if m.Round != 0 { - i = encodeVarintState(dAtA, i, uint64(m.Round)) - i-- - dAtA[i] = 0x40 - } - n1, err1 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.EndTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintState(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x3a - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintState(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x32 - { - size := m.TokenOutSupply.Size() - i -= size - if _, err := m.TokenOutSupply.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - if len(m.TokenIn) > 0 { - i -= len(m.TokenIn) - copy(dAtA[i:], m.TokenIn) - i = encodeVarintState(dAtA, i, uint64(len(m.TokenIn))) - i-- - dAtA[i] = 0x22 - } - if len(m.TokenOut) > 0 { - i -= len(m.TokenOut) - copy(dAtA[i:], m.TokenOut) - i = encodeVarintState(dAtA, i, uint64(len(m.TokenOut))) - i-- - dAtA[i] = 0x1a - } - if m.Id != 0 { - i = encodeVarintState(dAtA, i, uint64(m.Id)) - i-- - dAtA[i] = 0x10 - } - if len(m.Treasury) > 0 { - i -= len(m.Treasury) - copy(dAtA[i:], m.Treasury) - i = encodeVarintState(dAtA, i, uint64(len(m.Treasury))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *UserPosition) 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 *UserPosition) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *UserPosition) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Purchased.Size() - i -= size - if _, err := m.Purchased.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x2a - { - size := m.Spent.Size() - i -= size - if _, err := m.Spent.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - { - size := m.OutPerShare.Size() - i -= size - if _, err := m.OutPerShare.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - { - size := m.Staked.Size() - i -= size - if _, err := m.Staked.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - { - size := m.Shares.Size() - i -= size - if _, err := m.Shares.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintState(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintState(dAtA []byte, offset int, v uint64) int { - offset -= sovState(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Sale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Treasury) - if l > 0 { - n += 1 + l + sovState(uint64(l)) - } - if m.Id != 0 { - n += 1 + sovState(uint64(m.Id)) - } - l = len(m.TokenOut) - if l > 0 { - n += 1 + l + sovState(uint64(l)) - } - l = len(m.TokenIn) - if l > 0 { - n += 1 + l + sovState(uint64(l)) - } - l = m.TokenOutSupply.Size() - n += 1 + l + sovState(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovState(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.EndTime) - n += 1 + l + sovState(uint64(l)) - if m.Round != 0 { - n += 1 + sovState(uint64(m.Round)) - } - if m.EndRound != 0 { - n += 1 + sovState(uint64(m.EndRound)) - } - l = m.OutRemaining.Size() - n += 1 + l + sovState(uint64(l)) - l = m.OutSold.Size() - n += 1 + l + sovState(uint64(l)) - l = m.OutPerShare.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Staked.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Income.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Shares.Size() - n += 1 + l + sovState(uint64(l)) - l = len(m.Name) - if l > 0 { - n += 2 + l + sovState(uint64(l)) - } - l = len(m.Url) - if l > 0 { - n += 2 + l + sovState(uint64(l)) - } - return n -} - -func (m *UserPosition) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Shares.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Staked.Size() - n += 1 + l + sovState(uint64(l)) - l = m.OutPerShare.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Spent.Size() - n += 1 + l + sovState(uint64(l)) - l = m.Purchased.Size() - n += 1 + l + sovState(uint64(l)) - return n -} - -func sovState(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozState(x uint64) (n int) { - return sovState(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Sale) 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 ErrIntOverflowState - } - 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: Sale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Sale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Treasury", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Treasury = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - m.Id = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Id |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenOut = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TokenIn = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenOutSupply", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.TokenOutSupply.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthState - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EndTime", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthState - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.EndTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 8: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Round", wireType) - } - m.Round = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Round |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 9: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field EndRound", wireType) - } - m.EndRound = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.EndRound |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 10: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutRemaining", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutRemaining.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 11: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutSold", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutSold.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 12: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutPerShare", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutPerShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 13: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Staked", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Staked.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 14: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Income", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Income.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 15: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Shares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 20: - 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 ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 21: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Url", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Url = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipState(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthState - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *UserPosition) 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 ErrIntOverflowState - } - 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: UserPosition: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: UserPosition: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Shares", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Shares.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Staked", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Staked.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field OutPerShare", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.OutPerShare.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Spent", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Spent.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Purchased", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowState - } - 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 ErrInvalidLengthState - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthState - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if err := m.Purchased.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipState(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthState - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipState(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowState - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowState - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowState - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthState - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupState - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthState - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthState = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowState = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupState = fmt.Errorf("proto: unexpected end of group") -) diff --git a/x/streamswap/types/tx.pb.go b/x/streamswap/types/tx.pb.go deleted file mode 100644 index eb6eaacc52f..00000000000 --- a/x/streamswap/types/tx.pb.go +++ /dev/null @@ -1,2359 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: osmosis/streamswap/v1/tx.proto - -package types - -import ( - context "context" - fmt "fmt" - _ "github.com/cosmos/cosmos-proto" - github_com_cosmos_cosmos_sdk_types "github.com/cosmos/cosmos-sdk/types" - types "github.com/cosmos/cosmos-sdk/types" - _ "github.com/gogo/protobuf/gogoproto" - grpc1 "github.com/gogo/protobuf/grpc" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" - emptypb "google.golang.org/protobuf/types/known/emptypb" - io "io" - math "math" - math_bits "math/bits" - time "time" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf -var _ = time.Kitchen - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type MsgCreateSale struct { - // Sale creator and the account which provides token (token_out) to the sale. - // When processing this message, token_out - Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` - // token_in is a denom used to buy `token_out`. May be referred as a - // "quote currency". - TokenIn string `protobuf:"bytes,2,opt,name=token_in,json=tokenIn,proto3" json:"token_in,omitempty"` - // token_out is a coin supply (denom + amount) to sell. May be referred as - // "base currency". The whole supply will be transferred from the creator - // to the module and will be sold during the sale. - TokenOut types.Coin `protobuf:"bytes,3,opt,name=token_out,json=tokenOut,proto3" json:"token_out"` - // Maximum fee the creator is going to pay for creating a sale. The creator - // will be charged params.SaleCreationFee. Transaction will fail if - // max_fee is smaller than params.SaleCreationFee. If empty, the creator - // doesn't accept any fee. - MaxFee []types.Coin `protobuf:"bytes,4,rep,name=max_fee,json=maxFee,proto3" json:"max_fee"` - // start time when the token sale starts. - StartTime time.Time `protobuf:"bytes,5,opt,name=start_time,json=startTime,proto3,stdtime" json:"start_time"` - // duration time that the sale takes place over - Duration time.Duration `protobuf:"bytes,6,opt,name=duration,proto3,stdduration" json:"duration"` - // Recipient is the account which receives earned `token_in` from when the - // sale is finalized. If not defined (empty) the creator - // account will be used. - Recipient string `protobuf:"bytes,7,opt,name=recipient,proto3" json:"recipient,omitempty"` - // Name for the sale, max 40 characters, min 4. Required. - Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"` - // URL with sale and project details. Can be a link a link to IPFS, - // hackmd, project page, blog post... Max 120 characters. Must be - // valid agains Go url.ParseRequestURI. Required. - Url string `protobuf:"bytes,9,opt,name=url,proto3" json:"url,omitempty"` -} - -func (m *MsgCreateSale) Reset() { *m = MsgCreateSale{} } -func (m *MsgCreateSale) String() string { return proto.CompactTextString(m) } -func (*MsgCreateSale) ProtoMessage() {} -func (*MsgCreateSale) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{0} -} -func (m *MsgCreateSale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateSale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateSale.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 *MsgCreateSale) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateSale.Merge(m, src) -} -func (m *MsgCreateSale) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateSale) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateSale.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateSale proto.InternalMessageInfo - -type MsgCreateSaleResponse struct { - SaleId uint64 `protobuf:"varint,1,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty" yaml:"sale_id"` -} - -func (m *MsgCreateSaleResponse) Reset() { *m = MsgCreateSaleResponse{} } -func (m *MsgCreateSaleResponse) String() string { return proto.CompactTextString(m) } -func (*MsgCreateSaleResponse) ProtoMessage() {} -func (*MsgCreateSaleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{1} -} -func (m *MsgCreateSaleResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgCreateSaleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgCreateSaleResponse.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 *MsgCreateSaleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgCreateSaleResponse.Merge(m, src) -} -func (m *MsgCreateSaleResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgCreateSaleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgCreateSaleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgCreateSaleResponse proto.InternalMessageInfo - -type MsgSubscribe struct { - // sender is an account address adding a deposit - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // ID of an existing sale. - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty" yaml:"sale_id"` - // number of sale.token_in staked by a user. - Amount github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount"` -} - -func (m *MsgSubscribe) Reset() { *m = MsgSubscribe{} } -func (m *MsgSubscribe) String() string { return proto.CompactTextString(m) } -func (*MsgSubscribe) ProtoMessage() {} -func (*MsgSubscribe) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{2} -} -func (m *MsgSubscribe) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgSubscribe) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgSubscribe.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 *MsgSubscribe) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgSubscribe.Merge(m, src) -} -func (m *MsgSubscribe) XXX_Size() int { - return m.Size() -} -func (m *MsgSubscribe) XXX_DiscardUnknown() { - xxx_messageInfo_MsgSubscribe.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgSubscribe proto.InternalMessageInfo - -type MsgWithdraw struct { - // sender is an account address subscribed to the sale_id - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // ID of a sale. - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty" yaml:"sale_id"` - // amount of tokens_in to withdraw. Must be at most the amount of not spent - // tokens, unless set to null - then all remaining balance will be withdrawn. - Amount *github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,3,opt,name=amount,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"amount,omitempty"` -} - -func (m *MsgWithdraw) Reset() { *m = MsgWithdraw{} } -func (m *MsgWithdraw) String() string { return proto.CompactTextString(m) } -func (*MsgWithdraw) ProtoMessage() {} -func (*MsgWithdraw) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{3} -} -func (m *MsgWithdraw) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgWithdraw) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgWithdraw.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 *MsgWithdraw) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgWithdraw.Merge(m, src) -} -func (m *MsgWithdraw) XXX_Size() int { - return m.Size() -} -func (m *MsgWithdraw) XXX_DiscardUnknown() { - xxx_messageInfo_MsgWithdraw.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgWithdraw proto.InternalMessageInfo - -type MsgExitSale struct { - // sender is an account address exiting a sale - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // ID of an existing sale. - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty" yaml:"sale_id"` -} - -func (m *MsgExitSale) Reset() { *m = MsgExitSale{} } -func (m *MsgExitSale) String() string { return proto.CompactTextString(m) } -func (*MsgExitSale) ProtoMessage() {} -func (*MsgExitSale) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{4} -} -func (m *MsgExitSale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgExitSale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgExitSale.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 *MsgExitSale) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgExitSale.Merge(m, src) -} -func (m *MsgExitSale) XXX_Size() int { - return m.Size() -} -func (m *MsgExitSale) XXX_DiscardUnknown() { - xxx_messageInfo_MsgExitSale.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgExitSale proto.InternalMessageInfo - -type MsgExitSaleResponse struct { - // Purchased amount of "out" tokens withdrawn to the user. - Purchased github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=purchased,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"purchased"` -} - -func (m *MsgExitSaleResponse) Reset() { *m = MsgExitSaleResponse{} } -func (m *MsgExitSaleResponse) String() string { return proto.CompactTextString(m) } -func (*MsgExitSaleResponse) ProtoMessage() {} -func (*MsgExitSaleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{5} -} -func (m *MsgExitSaleResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgExitSaleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgExitSaleResponse.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 *MsgExitSaleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgExitSaleResponse.Merge(m, src) -} -func (m *MsgExitSaleResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgExitSaleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgExitSaleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgExitSaleResponse proto.InternalMessageInfo - -type MsgFinalizeSale struct { - // sender is an account signing the message and triggering the finalization. - Sender string `protobuf:"bytes,1,opt,name=sender,proto3" json:"sender,omitempty"` - // ID of an existing sale. - SaleId uint64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty" yaml:"sale_id"` -} - -func (m *MsgFinalizeSale) Reset() { *m = MsgFinalizeSale{} } -func (m *MsgFinalizeSale) String() string { return proto.CompactTextString(m) } -func (*MsgFinalizeSale) ProtoMessage() {} -func (*MsgFinalizeSale) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{6} -} -func (m *MsgFinalizeSale) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgFinalizeSale) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgFinalizeSale.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 *MsgFinalizeSale) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgFinalizeSale.Merge(m, src) -} -func (m *MsgFinalizeSale) XXX_Size() int { - return m.Size() -} -func (m *MsgFinalizeSale) XXX_DiscardUnknown() { - xxx_messageInfo_MsgFinalizeSale.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgFinalizeSale proto.InternalMessageInfo - -type MsgFinalizeSaleResponse struct { - // Income amount of token_in sent to the sale recipient. - Income github_com_cosmos_cosmos_sdk_types.Int `protobuf:"bytes,1,opt,name=income,proto3,customtype=github.com/cosmos/cosmos-sdk/types.Int" json:"income"` -} - -func (m *MsgFinalizeSaleResponse) Reset() { *m = MsgFinalizeSaleResponse{} } -func (m *MsgFinalizeSaleResponse) String() string { return proto.CompactTextString(m) } -func (*MsgFinalizeSaleResponse) ProtoMessage() {} -func (*MsgFinalizeSaleResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4988bf90ab6cecf3, []int{7} -} -func (m *MsgFinalizeSaleResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *MsgFinalizeSaleResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_MsgFinalizeSaleResponse.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 *MsgFinalizeSaleResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_MsgFinalizeSaleResponse.Merge(m, src) -} -func (m *MsgFinalizeSaleResponse) XXX_Size() int { - return m.Size() -} -func (m *MsgFinalizeSaleResponse) XXX_DiscardUnknown() { - xxx_messageInfo_MsgFinalizeSaleResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_MsgFinalizeSaleResponse proto.InternalMessageInfo - -func init() { - proto.RegisterType((*MsgCreateSale)(nil), "osmosis.streamswap.v1.MsgCreateSale") - proto.RegisterType((*MsgCreateSaleResponse)(nil), "osmosis.streamswap.v1.MsgCreateSaleResponse") - proto.RegisterType((*MsgSubscribe)(nil), "osmosis.streamswap.v1.MsgSubscribe") - proto.RegisterType((*MsgWithdraw)(nil), "osmosis.streamswap.v1.MsgWithdraw") - proto.RegisterType((*MsgExitSale)(nil), "osmosis.streamswap.v1.MsgExitSale") - proto.RegisterType((*MsgExitSaleResponse)(nil), "osmosis.streamswap.v1.MsgExitSaleResponse") - proto.RegisterType((*MsgFinalizeSale)(nil), "osmosis.streamswap.v1.MsgFinalizeSale") - proto.RegisterType((*MsgFinalizeSaleResponse)(nil), "osmosis.streamswap.v1.MsgFinalizeSaleResponse") -} - -func init() { proto.RegisterFile("osmosis/streamswap/v1/tx.proto", fileDescriptor_4988bf90ab6cecf3) } - -var fileDescriptor_4988bf90ab6cecf3 = []byte{ - // 738 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x55, 0xdf, 0x4e, 0x13, 0x4f, - 0x14, 0xee, 0xd2, 0xfe, 0xda, 0xee, 0x81, 0x9f, 0x9a, 0x51, 0x70, 0xa9, 0x66, 0x4b, 0x56, 0x43, - 0x88, 0xca, 0x6e, 0x8a, 0x89, 0x31, 0xc6, 0xc4, 0xa4, 0x40, 0x23, 0x89, 0x8d, 0x49, 0x21, 0x9a, - 0x70, 0x53, 0x67, 0xb7, 0xc3, 0x32, 0xa1, 0xbb, 0xb3, 0xd9, 0x99, 0x2d, 0xc5, 0x07, 0xf0, 0x9a, - 0x4b, 0xa3, 0xcf, 0xe2, 0x3d, 0x97, 0x5c, 0x1a, 0x2f, 0x50, 0xe1, 0x0d, 0x7c, 0x02, 0xb3, 0x7f, - 0x5b, 0xaa, 0x15, 0x24, 0x78, 0xd5, 0x39, 0xfb, 0x7d, 0xe7, 0x9b, 0x6f, 0xce, 0x39, 0x33, 0x05, - 0x95, 0x71, 0x87, 0x71, 0xca, 0x0d, 0x2e, 0x7c, 0x82, 0x1d, 0xbe, 0x8b, 0x3d, 0xa3, 0x57, 0x33, - 0x44, 0x5f, 0xf7, 0x7c, 0x26, 0x18, 0x9a, 0x4e, 0x70, 0x7d, 0x80, 0xeb, 0xbd, 0x5a, 0xe5, 0x86, - 0xcd, 0x6c, 0x16, 0x31, 0x8c, 0x70, 0x15, 0x93, 0x2b, 0xaa, 0xcd, 0x98, 0xdd, 0x25, 0x46, 0x14, - 0x99, 0xc1, 0x96, 0xd1, 0x09, 0x7c, 0x2c, 0x28, 0x73, 0x13, 0xbc, 0x3a, 0x8a, 0x0b, 0xea, 0x10, - 0x2e, 0xb0, 0xe3, 0x25, 0x84, 0x5b, 0xa3, 0x04, 0xe2, 0x78, 0x62, 0x2f, 0x55, 0xb7, 0x22, 0x2f, - 0x86, 0x89, 0x39, 0x31, 0x7a, 0x35, 0x93, 0x08, 0x5c, 0x33, 0x2c, 0x46, 0x53, 0xf5, 0xd9, 0x18, - 0x6f, 0xc7, 0xb6, 0xe2, 0x20, 0x86, 0xb4, 0x77, 0x79, 0xf8, 0xbf, 0xc9, 0xed, 0x65, 0x9f, 0x60, - 0x41, 0xd6, 0x71, 0x97, 0x20, 0x05, 0x4a, 0x56, 0x18, 0x31, 0x5f, 0x91, 0xe6, 0xa4, 0x05, 0xb9, - 0x95, 0x86, 0x68, 0x16, 0xca, 0x82, 0xed, 0x10, 0xb7, 0x4d, 0x5d, 0x65, 0x22, 0x86, 0xa2, 0x78, - 0xcd, 0x45, 0x4f, 0x41, 0x8e, 0x21, 0x16, 0x08, 0x25, 0x3f, 0x27, 0x2d, 0x4c, 0x2e, 0xcd, 0xea, - 0xc9, 0x46, 0xa1, 0x2b, 0x3d, 0x71, 0xa5, 0x2f, 0x33, 0xea, 0xd6, 0x0b, 0x07, 0x47, 0xd5, 0x5c, - 0x2b, 0x16, 0x7b, 0x19, 0x08, 0xf4, 0x18, 0x4a, 0x0e, 0xee, 0xb7, 0xb7, 0x08, 0x51, 0x0a, 0x73, - 0xf9, 0xf3, 0xe4, 0x16, 0x1d, 0xdc, 0x6f, 0x10, 0x82, 0x96, 0x01, 0xb8, 0xc0, 0xbe, 0x68, 0x87, - 0xf5, 0x52, 0xfe, 0x8b, 0x36, 0xae, 0xe8, 0x71, 0xad, 0xf4, 0xb4, 0x56, 0xfa, 0x46, 0x5a, 0xcc, - 0x7a, 0x39, 0xcc, 0xde, 0xff, 0x5a, 0x95, 0x5a, 0x72, 0x94, 0x17, 0x22, 0xe8, 0x19, 0x94, 0xd3, - 0x76, 0x28, 0xc5, 0xc4, 0xfb, 0xa8, 0xc4, 0x4a, 0x42, 0x88, 0x15, 0xde, 0x87, 0x0a, 0x59, 0x12, - 0xba, 0x0d, 0xb2, 0x4f, 0x2c, 0xea, 0x51, 0xe2, 0x0a, 0xa5, 0x14, 0x55, 0x66, 0xf0, 0x01, 0x21, - 0x28, 0xb8, 0xd8, 0x21, 0x4a, 0x39, 0x02, 0xa2, 0x35, 0xba, 0x06, 0xf9, 0xc0, 0xef, 0x2a, 0x72, - 0xf4, 0x29, 0x5c, 0x6a, 0x2b, 0x30, 0x7d, 0xaa, 0x0f, 0x2d, 0xc2, 0x3d, 0xe6, 0x72, 0x82, 0xee, - 0x43, 0x89, 0xe3, 0x2e, 0x69, 0xd3, 0x4e, 0xd4, 0x8f, 0x42, 0x1d, 0xfd, 0x38, 0xaa, 0x5e, 0xd9, - 0xc3, 0x4e, 0xf7, 0x89, 0x96, 0x00, 0x5a, 0xab, 0x18, 0xae, 0xd6, 0x3a, 0xda, 0x47, 0x09, 0xa6, - 0x9a, 0xdc, 0x5e, 0x0f, 0x4c, 0x6e, 0xf9, 0xd4, 0x24, 0x68, 0x06, 0x8a, 0x9c, 0xb8, 0x1d, 0x92, - 0x36, 0x33, 0x89, 0x86, 0x55, 0x27, 0xce, 0x52, 0x45, 0x0d, 0x28, 0x62, 0x87, 0x05, 0x6e, 0xdc, - 0x5a, 0xb9, 0xae, 0x87, 0x35, 0xf8, 0x72, 0x54, 0x9d, 0xb7, 0xa9, 0xd8, 0x0e, 0x4c, 0xdd, 0x62, - 0x4e, 0x32, 0x55, 0xc9, 0xcf, 0x22, 0xef, 0xec, 0x18, 0x62, 0xcf, 0x23, 0x5c, 0x5f, 0x73, 0x45, - 0x2b, 0xc9, 0xd6, 0x3e, 0x48, 0x30, 0xd9, 0xe4, 0xf6, 0x6b, 0x2a, 0xb6, 0x3b, 0x3e, 0xde, 0xfd, - 0x77, 0xe6, 0xa4, 0x0b, 0x98, 0x6b, 0x45, 0xde, 0x56, 0xfb, 0x54, 0x44, 0xd7, 0xe0, 0x32, 0xbc, - 0x69, 0x16, 0x5c, 0x1f, 0xd2, 0xcc, 0x5a, 0xfa, 0x02, 0x64, 0x2f, 0xf0, 0xad, 0x6d, 0xcc, 0x49, - 0xdc, 0xd4, 0xbf, 0x2f, 0xe9, 0x40, 0x40, 0x7b, 0x05, 0x57, 0x9b, 0xdc, 0x6e, 0x50, 0x17, 0x77, - 0xe9, 0x5b, 0x72, 0x79, 0xe6, 0x31, 0xdc, 0x1c, 0xd1, 0xcd, 0x0e, 0xd0, 0x80, 0x22, 0x75, 0x2d, - 0xe6, 0x90, 0x0b, 0xba, 0x4f, 0xb2, 0x97, 0x3e, 0xe5, 0x21, 0xdf, 0xe4, 0x36, 0x7a, 0x03, 0x30, - 0xf4, 0x02, 0xdd, 0xd5, 0x7f, 0xfb, 0xb4, 0xea, 0xa7, 0xee, 0x47, 0xe5, 0xc1, 0x79, 0x58, 0x99, - 0xe3, 0xe7, 0x20, 0x0f, 0x2e, 0xc5, 0x9d, 0xf1, 0xa9, 0x19, 0xa9, 0x32, 0xf3, 0xcb, 0x1b, 0xb0, - 0x1a, 0x3e, 0xb9, 0xa8, 0x01, 0xe5, 0x6c, 0x80, 0xb5, 0xf1, 0x42, 0x29, 0x67, 0xac, 0xce, 0x26, - 0x94, 0xb3, 0x61, 0xfb, 0x83, 0x4e, 0xca, 0xa9, 0xdc, 0x3b, 0x9b, 0x93, 0x9d, 0x76, 0x0b, 0xa6, - 0x4e, 0xcd, 0xc3, 0xfc, 0xf8, 0xdc, 0x61, 0x5e, 0x45, 0x3f, 0x1f, 0x2f, 0xdd, 0xa7, 0xbe, 0x71, - 0xf0, 0x5d, 0xcd, 0x1d, 0x1c, 0xab, 0xd2, 0xe1, 0xb1, 0x2a, 0x7d, 0x3b, 0x56, 0xa5, 0xfd, 0x13, - 0x35, 0x77, 0x78, 0xa2, 0xe6, 0x3e, 0x9f, 0xa8, 0xb9, 0xcd, 0x47, 0x43, 0xd3, 0x90, 0xe8, 0x2e, - 0x76, 0xb1, 0xc9, 0xd3, 0xc0, 0xe8, 0xd5, 0x96, 0x8c, 0xfe, 0xf0, 0xff, 0x6b, 0x34, 0x21, 0x66, - 0x31, 0xaa, 0xd4, 0xc3, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x58, 0xb3, 0x24, 0x42, 0x82, 0x07, - 0x00, 0x00, -} - -// Reference imports to suppress errors if they are not otherwise used. -var _ context.Context -var _ grpc.ClientConn - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -const _ = grpc.SupportPackageIsVersion4 - -// MsgClient is the client API for Msg service. -// -// 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 { - // CreateSale creates new token sale. Anyone can create a new sale. - // params.SaleBond OSMO will be charged as a bond (returned in FinalizeSale) - // to avoid spams. - // The sale follows the streamswap functionality explained in the - // x/launchapd/spec - CreateSale(ctx context.Context, in *MsgCreateSale, opts ...grpc.CallOption) (*MsgCreateSaleResponse, error) - // Subscribe to a token sale. Any use at any time before the sale end can join - // the sale by sending `token_in` to the Sale through the Subscribe msg. - // During the sale, user `token_in` will be automatically charged every - // epoch to purchase `token_out`. - Subscribe(ctx context.Context, in *MsgSubscribe, opts ...grpc.CallOption) (*emptypb.Empty, error) - // Withdraw sends back `amount` of unspent tokens_in to the user. - // If `amount` is empty, it will default to all unspent tokens. - // User can do it any time unless his deposit is empty. - Withdraw(ctx context.Context, in *MsgWithdraw, opts ...grpc.CallOption) (*emptypb.Empty, error) - // ExitSale withdraws (by a user who subscribed to the sale) purchased - // tokens_out from the pool and remained tokens_in. Must be called after - // the sale end. - ExitSale(ctx context.Context, in *MsgExitSale, opts ...grpc.CallOption) (*MsgExitSaleResponse, error) - // FinalizeSale clean ups the sale and sends income (earned tokens_in) to the - // Sale recipient. Returns error if called before the Sale end or it was - // already finalized. Anyone can call this method. - FinalizeSale(ctx context.Context, in *MsgFinalizeSale, opts ...grpc.CallOption) (*MsgFinalizeSaleResponse, error) -} - -type msgClient struct { - cc grpc1.ClientConn -} - -func NewMsgClient(cc grpc1.ClientConn) MsgClient { - return &msgClient{cc} -} - -func (c *msgClient) CreateSale(ctx context.Context, in *MsgCreateSale, opts ...grpc.CallOption) (*MsgCreateSaleResponse, error) { - out := new(MsgCreateSaleResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Msg/CreateSale", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Subscribe(ctx context.Context, in *MsgSubscribe, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Msg/Subscribe", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) Withdraw(ctx context.Context, in *MsgWithdraw, opts ...grpc.CallOption) (*emptypb.Empty, error) { - out := new(emptypb.Empty) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Msg/Withdraw", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) ExitSale(ctx context.Context, in *MsgExitSale, opts ...grpc.CallOption) (*MsgExitSaleResponse, error) { - out := new(MsgExitSaleResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Msg/ExitSale", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *msgClient) FinalizeSale(ctx context.Context, in *MsgFinalizeSale, opts ...grpc.CallOption) (*MsgFinalizeSaleResponse, error) { - out := new(MsgFinalizeSaleResponse) - err := c.cc.Invoke(ctx, "/osmosis.streamswap.v1.Msg/FinalizeSale", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// MsgServer is the server API for Msg service. -type MsgServer interface { - // CreateSale creates new token sale. Anyone can create a new sale. - // params.SaleBond OSMO will be charged as a bond (returned in FinalizeSale) - // to avoid spams. - // The sale follows the streamswap functionality explained in the - // x/launchapd/spec - CreateSale(context.Context, *MsgCreateSale) (*MsgCreateSaleResponse, error) - // Subscribe to a token sale. Any use at any time before the sale end can join - // the sale by sending `token_in` to the Sale through the Subscribe msg. - // During the sale, user `token_in` will be automatically charged every - // epoch to purchase `token_out`. - Subscribe(context.Context, *MsgSubscribe) (*emptypb.Empty, error) - // Withdraw sends back `amount` of unspent tokens_in to the user. - // If `amount` is empty, it will default to all unspent tokens. - // User can do it any time unless his deposit is empty. - Withdraw(context.Context, *MsgWithdraw) (*emptypb.Empty, error) - // ExitSale withdraws (by a user who subscribed to the sale) purchased - // tokens_out from the pool and remained tokens_in. Must be called after - // the sale end. - ExitSale(context.Context, *MsgExitSale) (*MsgExitSaleResponse, error) - // FinalizeSale clean ups the sale and sends income (earned tokens_in) to the - // Sale recipient. Returns error if called before the Sale end or it was - // already finalized. Anyone can call this method. - FinalizeSale(context.Context, *MsgFinalizeSale) (*MsgFinalizeSaleResponse, error) -} - -// UnimplementedMsgServer can be embedded to have forward compatible implementations. -type UnimplementedMsgServer struct { -} - -func (*UnimplementedMsgServer) CreateSale(ctx context.Context, req *MsgCreateSale) (*MsgCreateSaleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method CreateSale not implemented") -} -func (*UnimplementedMsgServer) Subscribe(ctx context.Context, req *MsgSubscribe) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Subscribe not implemented") -} -func (*UnimplementedMsgServer) Withdraw(ctx context.Context, req *MsgWithdraw) (*emptypb.Empty, error) { - return nil, status.Errorf(codes.Unimplemented, "method Withdraw not implemented") -} -func (*UnimplementedMsgServer) ExitSale(ctx context.Context, req *MsgExitSale) (*MsgExitSaleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method ExitSale not implemented") -} -func (*UnimplementedMsgServer) FinalizeSale(ctx context.Context, req *MsgFinalizeSale) (*MsgFinalizeSaleResponse, error) { - return nil, status.Errorf(codes.Unimplemented, "method FinalizeSale not implemented") -} - -func RegisterMsgServer(s grpc1.Server, srv MsgServer) { - s.RegisterService(&_Msg_serviceDesc, srv) -} - -func _Msg_CreateSale_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgCreateSale) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).CreateSale(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Msg/CreateSale", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).CreateSale(ctx, req.(*MsgCreateSale)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Subscribe_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgSubscribe) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Subscribe(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Msg/Subscribe", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Subscribe(ctx, req.(*MsgSubscribe)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_Withdraw_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgWithdraw) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).Withdraw(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Msg/Withdraw", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).Withdraw(ctx, req.(*MsgWithdraw)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_ExitSale_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgExitSale) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).ExitSale(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Msg/ExitSale", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).ExitSale(ctx, req.(*MsgExitSale)) - } - return interceptor(ctx, in, info, handler) -} - -func _Msg_FinalizeSale_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(MsgFinalizeSale) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(MsgServer).FinalizeSale(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/osmosis.streamswap.v1.Msg/FinalizeSale", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(MsgServer).FinalizeSale(ctx, req.(*MsgFinalizeSale)) - } - return interceptor(ctx, in, info, handler) -} - -var _Msg_serviceDesc = grpc.ServiceDesc{ - ServiceName: "osmosis.streamswap.v1.Msg", - HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "CreateSale", - Handler: _Msg_CreateSale_Handler, - }, - { - MethodName: "Subscribe", - Handler: _Msg_Subscribe_Handler, - }, - { - MethodName: "Withdraw", - Handler: _Msg_Withdraw_Handler, - }, - { - MethodName: "ExitSale", - Handler: _Msg_ExitSale_Handler, - }, - { - MethodName: "FinalizeSale", - Handler: _Msg_FinalizeSale_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "osmosis/streamswap/v1/tx.proto", -} - -func (m *MsgCreateSale) 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 *MsgCreateSale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateSale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Url) > 0 { - i -= len(m.Url) - copy(dAtA[i:], m.Url) - i = encodeVarintTx(dAtA, i, uint64(len(m.Url))) - i-- - dAtA[i] = 0x4a - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintTx(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0x42 - } - if len(m.Recipient) > 0 { - i -= len(m.Recipient) - copy(dAtA[i:], m.Recipient) - i = encodeVarintTx(dAtA, i, uint64(len(m.Recipient))) - i-- - dAtA[i] = 0x3a - } - n1, err1 := github_com_gogo_protobuf_types.StdDurationMarshalTo(m.Duration, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdDuration(m.Duration):]) - if err1 != nil { - return 0, err1 - } - i -= n1 - i = encodeVarintTx(dAtA, i, uint64(n1)) - i-- - dAtA[i] = 0x32 - n2, err2 := github_com_gogo_protobuf_types.StdTimeMarshalTo(m.StartTime, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime):]) - if err2 != nil { - return 0, err2 - } - i -= n2 - i = encodeVarintTx(dAtA, i, uint64(n2)) - i-- - dAtA[i] = 0x2a - if len(m.MaxFee) > 0 { - for iNdEx := len(m.MaxFee) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.MaxFee[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - } - { - size, err := m.TokenOut.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if len(m.TokenIn) > 0 { - i -= len(m.TokenIn) - copy(dAtA[i:], m.TokenIn) - i = encodeVarintTx(dAtA, i, uint64(len(m.TokenIn))) - i-- - dAtA[i] = 0x12 - } - if len(m.Creator) > 0 { - i -= len(m.Creator) - copy(dAtA[i:], m.Creator) - i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgCreateSaleResponse) 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 *MsgCreateSaleResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgCreateSaleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SaleId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *MsgSubscribe) 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 *MsgSubscribe) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgSubscribe) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - if m.SaleId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - 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] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgWithdraw) 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 *MsgWithdraw) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgWithdraw) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Amount != nil { - { - size := m.Amount.Size() - i -= size - if _, err := m.Amount.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.SaleId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - 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] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgExitSale) 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 *MsgExitSale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgExitSale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SaleId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - 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] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgExitSaleResponse) 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 *MsgExitSaleResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgExitSaleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Purchased.Size() - i -= size - if _, err := m.Purchased.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func (m *MsgFinalizeSale) 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 *MsgFinalizeSale) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgFinalizeSale) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.SaleId != 0 { - i = encodeVarintTx(dAtA, i, uint64(m.SaleId)) - i-- - dAtA[i] = 0x10 - } - 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] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *MsgFinalizeSaleResponse) 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 *MsgFinalizeSaleResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *MsgFinalizeSaleResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - { - size := m.Income.Size() - i -= size - if _, err := m.Income.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - i = encodeVarintTx(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - return len(dAtA) - i, nil -} - -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *MsgCreateSale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.TokenIn) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = m.TokenOut.Size() - n += 1 + l + sovTx(uint64(l)) - if len(m.MaxFee) > 0 { - for _, e := range m.MaxFee { - l = e.Size() - n += 1 + l + sovTx(uint64(l)) - } - } - l = github_com_gogo_protobuf_types.SizeOfStdTime(m.StartTime) - n += 1 + l + sovTx(uint64(l)) - l = github_com_gogo_protobuf_types.SizeOfStdDuration(m.Duration) - n += 1 + l + sovTx(uint64(l)) - l = len(m.Recipient) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Name) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Url) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgCreateSaleResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.SaleId != 0 { - n += 1 + sovTx(uint64(m.SaleId)) - } - return n -} - -func (m *MsgSubscribe) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovTx(uint64(m.SaleId)) - } - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgWithdraw) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovTx(uint64(m.SaleId)) - } - if m.Amount != nil { - l = m.Amount.Size() - n += 1 + l + sovTx(uint64(l)) - } - return n -} - -func (m *MsgExitSale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovTx(uint64(m.SaleId)) - } - return n -} - -func (m *MsgExitSaleResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Purchased.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func (m *MsgFinalizeSale) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Sender) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - if m.SaleId != 0 { - n += 1 + sovTx(uint64(m.SaleId)) - } - return n -} - -func (m *MsgFinalizeSaleResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = m.Income.Size() - n += 1 + l + sovTx(uint64(l)) - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *MsgCreateSale) 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: MsgCreateSale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSale: 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 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.Creator = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenIn", 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.TokenIn = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TokenOut", 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.TokenOut.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MaxFee", 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.MaxFee = append(m.MaxFee, types.Coin{}) - if err := m.MaxFee[len(m.MaxFee)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StartTime", 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 := github_com_gogo_protobuf_types.StdTimeUnmarshal(&m.StartTime, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Duration", 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 := github_com_gogo_protobuf_types.StdDurationUnmarshal(&m.Duration, dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 7: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Recipient", 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.Recipient = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 8: - 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 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.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Url", 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.Url = 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 *MsgCreateSaleResponse) 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: MsgCreateSaleResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateSaleResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgSubscribe) 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: MsgSubscribe: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgSubscribe: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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.Amount.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 *MsgWithdraw) 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: MsgWithdraw: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgWithdraw: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Amount", 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 - } - var v github_com_cosmos_cosmos_sdk_types.Int - m.Amount = &v - if err := m.Amount.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 *MsgExitSale) 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: MsgExitSale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExitSale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgExitSaleResponse) 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: MsgExitSaleResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgExitSaleResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Purchased", 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.Purchased.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 *MsgFinalizeSale) 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: MsgFinalizeSale: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgFinalizeSale: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - 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 - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field SaleId", wireType) - } - m.SaleId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.SaleId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - 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 *MsgFinalizeSaleResponse) 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: MsgFinalizeSaleResponse: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: MsgFinalizeSaleResponse: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Income", 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.Income.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 skipTx(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowTx - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthTx - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupTx - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthTx - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") -)