diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 8a8a2769..6d9767ff 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -18,6 +18,8 @@ jobs: docker build -t chain:static -f Dockerfile.static . id=$(docker create chain:static) docker cp $id:/usr/bin/odind artifacts/odind-${{ github.ref_name }}-linux-amd64 + docker cp $id:/usr/bin/yoda artifacts/yoda-${{ github.ref_name }}-linux-amd64 + docker cp $id:/usr/bin/kvasir artifacts/kvasir-${{ github.ref_name }}-linux-amd64 docker rm -v $id - name: Create checksums diff --git a/Dockerfile.static b/Dockerfile.static index 27885885..3b4a384e 100644 --- a/Dockerfile.static +++ b/Dockerfile.static @@ -30,5 +30,7 @@ RUN LEDGER_ENABLED=true BUILD_TAGS=muslc LINK_STATICALLY=true make install \ FROM alpine:3.16 COPY --from=go-builder /go/bin/odind /usr/bin/odind +COPY --from=go-builder /go/bin/yoda /usr/bin/yoda +COPY --from=go-builder /go/bin/kvasir /usr/bin/kvasir ENTRYPOINT ["/usr/bin/odind"] diff --git a/Makefile b/Makefile index 5cc11ce9..9bb36df2 100644 --- a/Makefile +++ b/Makefile @@ -44,17 +44,25 @@ all: install install: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/odind go install -mod=readonly $(BUILD_FLAGS) ./cmd/yoda + go install -mod=readonly $(BUILD_FLAGS) ./cmd/kvasir install-yoda: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/yoda +install-kvasir: go.sum + go install -mod=readonly $(BUILD_FLAGS) ./cmd/kvasir + build: go.sum go build -mod=readonly -o ./build/odind $(BUILD_FLAGS) ./cmd/odind go build -mod=readonly -o ./build/yoda $(BUILD_FLAGS) ./cmd/yoda + go build -mod=readonly -o ./build/kvasir $(BUILD_FLAGS) ./cmd/kvasir build-yoda: go.sum go build -mod=readonly -o ./build/yoda $(BUILD_FLAGS) ./cmd/yoda +build-kvasir: go.sum + go build -mod=readonly -o ./build/kvasir $(BUILD_FLAGS) ./cmd/kvasir + faucet: go.sum go install -mod=readonly $(BUILD_FLAGS) ./cmd/faucet diff --git a/app/app.go b/app/app.go index c1f0253f..8ed1c6ff 100644 --- a/app/app.go +++ b/app/app.go @@ -15,6 +15,9 @@ import ( "cosmossdk.io/core/appmodule" circuitkeeper "cosmossdk.io/x/circuit/keeper" circuittypes "cosmossdk.io/x/circuit/types" + "github.com/ODIN-PROTOCOL/odin-core/app/upgrades/v10_0" + "github.com/ODIN-PROTOCOL/odin-core/x/onft" + onftkeeper "github.com/ODIN-PROTOCOL/odin-core/x/onft/keeper" wasmkeeper "github.com/ODIN-PROTOCOL/wasmd/x/wasm/keeper" wasmvm "github.com/ODIN-PROTOCOL/wasmvm/v2" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" @@ -157,6 +160,7 @@ import ( proofservice "github.com/ODIN-PROTOCOL/odin-core/client/grpc/oracle/proof" odinbank "github.com/ODIN-PROTOCOL/odin-core/x/bank" odinbankkeeper "github.com/ODIN-PROTOCOL/odin-core/x/bank/keeper" + onfttypes "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" "github.com/ODIN-PROTOCOL/odin-core/x/oracle" oraclekeeper "github.com/ODIN-PROTOCOL/odin-core/x/oracle/keeper" oracletypes "github.com/ODIN-PROTOCOL/odin-core/x/oracle/types" @@ -212,6 +216,7 @@ var ( wasm.AppModuleBasic{}, wasmlc.AppModuleBasic{}, icq.AppModuleBasic{}, + onft.AppModuleBasic{}, ) // module account permissions maccPerms = map[string][]string{ @@ -227,6 +232,7 @@ var ( nft.ModuleName: nil, wasmtypes.ModuleName: {authtypes.Burner}, icqtypes.ModuleName: nil, + onfttypes.ModuleName: nil, } Upgrades = []upgrades.Upgrade{ @@ -236,6 +242,7 @@ var ( v7_12.Upgrade, v8_3.Upgrade, v9_3.Upgrade, + v10_0.Upgrade, } ) @@ -340,6 +347,7 @@ func NewOdinApp( wasmtypes.StoreKey, wasmlctypes.StoreKey, icqtypes.StoreKey, + onfttypes.StoreKey, ) tkeys := storetypes.NewTransientStoreKeys(paramstypes.TStoreKey) memKeys := storetypes.NewMemoryStoreKeys(capabilitytypes.MemStoreKey) @@ -563,6 +571,14 @@ func NewOdinApp( app.NFTKeeper = nftkeeper.NewKeeper(runtime.NewKVStoreService(keys[nftkeeper.StoreKey]), appCodec, app.AccountKeeper, app.BankKeeper) + app.ONFTKeeper = onftkeeper.NewKeeper( + appCodec, + runtime.NewKVStoreService(keys[onfttypes.StoreKey]), + app.AccountKeeper, + app.NFTKeeper, + authtypes.NewModuleAddress(govtypes.ModuleName).String(), + ) + app.TransferKeeper = ibctransferkeeper.NewKeeper( appCodec, keys[ibctransfertypes.StoreKey], app.GetSubspace(ibctransfertypes.ModuleName), app.IBCKeeper.ChannelKeeper, app.IBCKeeper.ChannelKeeper, app.IBCKeeper.PortKeeper, @@ -651,6 +667,19 @@ func NewOdinApp( //// The last arguments can contain custom message handlers, and custom query handlers, //// if we want to allow any custom callbacks + messenger := wasmkeeper.NewMessageHandlerChain( + onftkeeper.NewMintNFTMessageHandler(app.ONFTKeeper), //should be first + wasmkeeper.NewDefaultMessageHandler( + app.MsgServiceRouter(), + app.IBCKeeper.ChannelKeeper, + app.IBCKeeper.ChannelKeeper, + scopedWasmKeeper, + app.BankKeeper, + appCodec, + app.TransferKeeper, + ), + ) + app.WasmKeeper = wasmkeeper.NewKeeper( appCodec, runtime.NewKVStoreService(keys[wasmtypes.StoreKey]), @@ -669,10 +698,9 @@ func NewOdinApp( wasmConfig, wasmkeeper.BuiltInCapabilities(), authtypes.NewModuleAddress(govtypes.ModuleName).String(), - append(wasmOpts, wasmkeeper.WithWasmEngine(mainWasmer))..., + append(wasmOpts, wasmkeeper.WithWasmEngine(mainWasmer), wasmkeeper.WithMessageHandler(messenger))..., ) - // 08-wasm light client accepted := make([]string, 0) for k := range acceptedStargateQueries { @@ -820,6 +848,7 @@ func NewOdinApp( wasm.NewAppModule(appCodec, &app.WasmKeeper, app.StakingKeeper, app.AccountKeeper, app.BankKeeper, app.MsgServiceRouter(), app.GetSubspace(wasmtypes.ModuleName)), wasmlc.NewAppModule(app.AppKeepers.WasmClientKeeper), icq.NewAppModule(app.AppKeepers.ICQKeeper, app.GetSubspace(icqtypes.ModuleName)), + onft.NewAppModule(app.ONFTKeeper), ) // BasicModuleManager defines the module BasicManager is in charge of setting up basic, @@ -842,9 +871,8 @@ func NewOdinApp( // NOTE: Oracle module must occur before distr as it takes some fee to distribute to active oracle validators. // NOTE: During begin block slashing happens after distr.BeginBlocker so that there is nothing left - // over in the validator fee pool, so as to keep the CanWithdrawInvariant invariant. + // over in the validator fee pool, to keep the CanWithdrawInvariant invariant. - // TODO: Recheck all Begin/End block logic order app.ModuleManager.SetOrderBeginBlockers( upgradetypes.ModuleName, capabilitytypes.ModuleName, @@ -871,6 +899,7 @@ func NewOdinApp( wasmtypes.ModuleName, icqtypes.ModuleName, wasmlctypes.ModuleName, + onfttypes.ModuleName, ) app.ModuleManager.SetOrderEndBlockers( crisistypes.ModuleName, @@ -898,6 +927,7 @@ func NewOdinApp( wasmtypes.ModuleName, icqtypes.ModuleName, wasmlctypes.ModuleName, + onfttypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are // properly initialized with tokens from genesis accounts. @@ -933,6 +963,7 @@ func NewOdinApp( wasmtypes.ModuleName, icqtypes.ModuleName, wasmlctypes.ModuleName, + onfttypes.ModuleName, ) // NOTE: upgrade module is required to be prioritized diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 60e9927b..1e252476 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -28,6 +28,7 @@ import ( ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper" odinbankkeeper "github.com/ODIN-PROTOCOL/odin-core/x/bank/keeper" + onftkeeper "github.com/ODIN-PROTOCOL/odin-core/x/onft/keeper" ) type AppKeepers struct { @@ -58,6 +59,7 @@ type AppKeepers struct { WasmKeeper wasmkeeper.Keeper WasmClientKeeper wasmlckeeper.Keeper ICQKeeper icqkeeper.Keeper + ONFTKeeper onftkeeper.Keeper // make scoped keepers public for test purposes ScopedIBCKeeper capabilitykeeper.ScopedKeeper diff --git a/app/upgrades/v10_0/upgrades.go b/app/upgrades/v10_0/upgrades.go new file mode 100644 index 00000000..b67973fd --- /dev/null +++ b/app/upgrades/v10_0/upgrades.go @@ -0,0 +1,41 @@ +package v10_0 + +import ( + "context" + + storetypes "cosmossdk.io/store/types" + upgradetypes "cosmossdk.io/x/upgrade/types" + "github.com/ODIN-PROTOCOL/odin-core/app/keepers" + "github.com/ODIN-PROTOCOL/odin-core/app/upgrades" + onfttypes "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" +) + +func CreateUpgradeHandler( + mm *module.Manager, + configurator module.Configurator, + _ upgrades.AppManager, + _ *keepers.AppKeepers, +) upgradetypes.UpgradeHandler { + return func(ctx context.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { + goCtx := sdk.UnwrapSDKContext(ctx) + goCtx.Logger().Info("Starting module migrations...") + + vm, err := mm.RunMigrations(ctx, configurator, vm) + if err != nil { + return vm, err + } + + goCtx.Logger().Info("Upgrade v10 complete") + return vm, nil + } +} + +var Upgrade = upgrades.Upgrade{ + UpgradeName: "v0.10.0", + CreateUpgradeHandler: CreateUpgradeHandler, + StoreUpgrades: storetypes.StoreUpgrades{ + Added: []string{onfttypes.StoreKey}, + }, +} diff --git a/cmd/kvasir/main.go b/cmd/kvasir/main.go new file mode 100644 index 00000000..e9031148 --- /dev/null +++ b/cmd/kvasir/main.go @@ -0,0 +1,9 @@ +package main + +import ( + "github.com/ODIN-PROTOCOL/odin-core/kvasir" +) + +func main() { + kvasir.Main() +} diff --git a/go.mod b/go.mod index 1c81107e..1456f440 100644 --- a/go.mod +++ b/go.mod @@ -41,6 +41,7 @@ require ( github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/gorilla/mux v1.8.1 github.com/grpc-ecosystem/grpc-gateway v1.16.0 + github.com/ipfs/go-ipfs-api v0.7.0 github.com/kyokomi/emoji v2.2.4+incompatible github.com/levigross/grequests v0.0.0-20190908174114-253788527a1a github.com/oasisprotocol/oasis-core/go v0.2202.7 @@ -84,14 +85,16 @@ require ( github.com/StirlingMarketingGroup/go-namecase v1.0.0 // indirect github.com/avast/retry-go/v4 v4.5.1 // indirect github.com/aws/aws-sdk-go v1.44.224 // indirect + github.com/benbjohnson/clock v1.3.5 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 // indirect github.com/bits-and-blooms/bitset v1.10.0 // indirect + github.com/blang/semver/v4 v4.0.0 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect - github.com/cenkalti/backoff/v4 v4.1.3 // indirect + github.com/cenkalti/backoff/v4 v4.2.0 // indirect github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/chzyer/readline v1.5.1 // indirect github.com/cloudwego/base64x v0.1.4 // indirect @@ -108,6 +111,7 @@ require ( github.com/cosmos/iavl v1.1.2 // indirect github.com/cosmos/interchain-security/v5 v5.0.0-alpha1.0.20240424193412-7cd900ad2a74 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect + github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 // indirect github.com/creachadair/atomicfile v0.3.1 // indirect github.com/creachadair/tomledit v0.0.24 // indirect github.com/danieljoos/wincred v1.1.2 // indirect @@ -185,6 +189,7 @@ require ( github.com/icza/dyno v0.0.0-20220812133438-f0b6f8a18845 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/ipfs/boxo v0.12.0 // indirect github.com/ipfs/go-cid v0.4.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmhodges/levigo v1.0.0 // indirect @@ -196,6 +201,7 @@ require ( github.com/leodido/go-urn v1.4.0 // indirect github.com/lib/pq v1.10.9 // indirect github.com/libp2p/go-buffer-pool v0.1.0 // indirect + github.com/libp2p/go-flow-metrics v0.1.0 // indirect github.com/libp2p/go-libp2p v0.31.0 // indirect github.com/linxGnu/grocksdb v1.8.14 // indirect github.com/magiconair/properties v1.8.7 // indirect @@ -219,6 +225,7 @@ require ( github.com/multiformats/go-multibase v0.2.0 // indirect github.com/multiformats/go-multicodec v0.9.0 // indirect github.com/multiformats/go-multihash v0.2.3 // indirect + github.com/multiformats/go-multistream v0.4.1 // indirect github.com/multiformats/go-varint v0.0.7 // indirect github.com/ncruces/go-strftime v0.1.9 // indirect github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect diff --git a/go.sum b/go.sum index bbbce952..3ec5f6dc 100644 --- a/go.sum +++ b/go.sum @@ -291,6 +291,8 @@ github.com/aws/aws-sdk-go v1.44.224 h1:09CiaaF35nRmxrzWZ2uRq5v6Ghg/d2RiPjZnSgtt+ github.com/aws/aws-sdk-go v1.44.224/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= +github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= +github.com/benbjohnson/clock v1.3.5/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -302,6 +304,8 @@ github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2 github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.10.0 h1:ePXTeiPEazB5+opbv5fr8umg2R/1NlzgDsyepwsSr88= github.com/bits-and-blooms/bitset v1.10.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8= +github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM= +github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ= github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c= github.com/btcsuite/btcd/btcec/v2 v2.3.3 h1:6+iXlDKE8RMtKsvK0gshlXIuPbyWM/h84Ensb7o3sC0= github.com/btcsuite/btcd/btcec/v2 v2.3.3/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04= @@ -323,13 +327,15 @@ github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4= github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM= github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= -github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= -github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.2.0 h1:HN5dHm3WBOgndBH6E8V0q2jIYIR3s9yglV8k/+MN3u4= +github.com/cenkalti/backoff/v4 v4.2.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927 h1:SKI1/fuSdodxmNNyVBR8d7X/HuLnRpvvFO0AgyQk764= +github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= @@ -417,6 +423,8 @@ github.com/cosmos/ledger-cosmos-go v0.13.3 h1:7ehuBGuyIytsXbd4MP43mLeoN2LTOEnk5n github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5XV6svsnkk9vdJtLr8= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3 h1:HVTnpeuvF6Owjd5mniCL8DEXo7uYXdQEmOP4FJbV5tg= +github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p1d6YEZWvFzEh4KLyvBcVSnrfNDDvK2zfK/4x2v/4pE= github.com/creachadair/atomicfile v0.3.1 h1:yQORkHjSYySh/tv5th1dkKcn02NEW5JleB84sjt+W4Q= github.com/creachadair/atomicfile v0.3.1/go.mod h1:mwfrkRxFKwpNAflYZzytbSwxvbK6fdGRRlp0KEQc0qU= github.com/creachadair/tomledit v0.0.24 h1:5Xjr25R2esu1rKCbQEmjZYlrhFkDspoAbAKb6QKQDhQ= @@ -795,8 +803,12 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo= +github.com/ipfs/boxo v0.12.0 h1:AXHg/1ONZdRQHQLgG5JHsSC3XoE4DjCAMgK+asZvUcQ= +github.com/ipfs/boxo v0.12.0/go.mod h1:xAnfiU6PtxWCnRqu7dcXQ10bB5/kvI1kXRotuGqGBhg= github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s= github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk= +github.com/ipfs/go-ipfs-api v0.7.0 h1:CMBNCUl0b45coC+lQCXEVpMhwoqjiaCwUIrM+coYW2Q= +github.com/ipfs/go-ipfs-api v0.7.0/go.mod h1:AIxsTNB0+ZhkqIfTZpdZ0VR/cpX5zrXjATa3prSay3g= github.com/jhump/protoreflect v1.15.3 h1:6SFRuqU45u9hIZPJAoZ8c28T3nK64BNdp9w6jFonzls= github.com/jhump/protoreflect v1.15.3/go.mod h1:4ORHmSBmlCW8fh3xHmJMGyul1zNqZK4Elxc8qKP+p1k= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= @@ -852,6 +864,8 @@ github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8= github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg= +github.com/libp2p/go-flow-metrics v0.1.0 h1:0iPhMI8PskQwzh57jB9WxIuIOQ0r+15PChFGkx3Q3WM= +github.com/libp2p/go-flow-metrics v0.1.0/go.mod h1:4Xi8MX8wj5aWNDAZttg6UPmc0ZrnFNsMtpsYUClFtro= github.com/libp2p/go-libp2p v0.31.0 h1:LFShhP8F6xthWiBBq3euxbKjZsoRajVEyBS9snfHxYg= github.com/libp2p/go-libp2p v0.31.0/go.mod h1:W/FEK1c/t04PbRH3fA9i5oucu5YcgrG0JVoBWT1B7Eg= github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743/go.mod h1:qklhhLq1aX+mtWk9cPHPzaBjWImj5ULL6C7HFJtXQMM= @@ -929,6 +943,8 @@ github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3 github.com/multiformats/go-multicodec v0.9.0/go.mod h1:L3QTQvMIaVBkXOXXtVmYE+LI16i14xuaojr/H7Ai54k= github.com/multiformats/go-multihash v0.2.3 h1:7Lyc8XfX/IY2jWb/gI7JP+o7JEq9hOa7BFvVU9RSh+U= github.com/multiformats/go-multihash v0.2.3/go.mod h1:dXgKXCXjBzdscBLk9JkjINiEsCKRVch90MdaGiKsvSM= +github.com/multiformats/go-multistream v0.4.1 h1:rFy0Iiyn3YT0asivDUIR05leAdwZq3de4741sbiSdfo= +github.com/multiformats/go-multistream v0.4.1/go.mod h1:Mz5eykRVAjJWckE2U78c6xqdtyNUEhKSM0Lwar2p77Q= github.com/multiformats/go-varint v0.0.7 h1:sWSGR+f/eu5ABZA2ZpYKBILXTTs9JWpdEM/nEGOHFS8= github.com/multiformats/go-varint v0.0.7/go.mod h1:r8PUYw/fD/SjBCiKOoDlGF6QawOELpZAu9eioSos/OU= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= diff --git a/kvasir/config.go b/kvasir/config.go new file mode 100644 index 00000000..0eabd651 --- /dev/null +++ b/kvasir/config.go @@ -0,0 +1,20 @@ +package kvasir + +import ( + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +func configCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "config [key] [value]", + Aliases: []string{"c"}, + Short: "Set kvasir configuration environment", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + viper.Set(args[0], args[1]) + return viper.WriteConfig() + }, + } + return cmd +} diff --git a/kvasir/context.go b/kvasir/context.go new file mode 100644 index 00000000..92229b5f --- /dev/null +++ b/kvasir/context.go @@ -0,0 +1,101 @@ +package kvasir + +import ( + "sync/atomic" + "time" + + "github.com/ODIN-PROTOCOL/odin-core/kvasir/executor" + wasmtypes "github.com/ODIN-PROTOCOL/wasmd/x/wasm/types" + rpcclient "github.com/cometbft/cometbft/rpc/client" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc" +) + +type Request struct { + ChosenValidators []string `json:"chosen_validators"` + Metadata string `json:"metadata"` + PartsReceived uint32 `json:"parts_received"` + PartsRequested uint32 `json:"parts_requested"` + Payed sdk.Coins `json:"payed"` + RequestHeight uint64 `json:"request_Height"` + RequestID uint64 `json:"request_id"` + Sender string `json:"sender"` + Status string `json:"status"` +} + +type RequestKey struct { + ContractAddress string + RequestID uint64 +} + +type ReportMsgWithKey struct { + result []byte + contractAddress string + msg *wasmtypes.RawContractMessage + execVersion string + keyIndex int64 + request Request +} + +type Context struct { + client rpcclient.Client + validator sdk.ValAddress + validatorAccAddr sdk.AccAddress + gasPrices string + keys []*keyring.Record + executor executor.Executor + broadcastTimeout time.Duration + maxTry uint64 + rpcPollInterval time.Duration + maxReport uint64 + grpc *grpc.ClientConn + + ipfs string + ipfsProjectID string + ipfsProjectSecret string + + pendingMsgs chan ReportMsgWithKey + freeKeys chan int64 + keyRoundRobinIndex int64 // Must use in conjunction with sync/atomic + + pendingRequests map[RequestKey]bool + + contracts []string + + metricsEnabled bool + handlingGauge int64 + pendingGauge int64 + errorCount int64 + submittedCount int64 + home string +} + +func (c *Context) nextKeyIndex() int64 { + keyIndex := atomic.AddInt64(&c.keyRoundRobinIndex, 1) % int64(len(c.keys)) + return keyIndex +} + +func (c *Context) updateHandlingGauge(amount int64) { + if c.metricsEnabled { + atomic.AddInt64(&c.handlingGauge, amount) + } +} + +func (c *Context) updatePendingGauge(amount int64) { + if c.metricsEnabled { + atomic.AddInt64(&c.pendingGauge, amount) + } +} + +func (c *Context) updateErrorCount(amount int64) { + if c.metricsEnabled { + atomic.AddInt64(&c.errorCount, amount) + } +} + +func (c *Context) updateSubmittedCount(amount int64) { + if c.metricsEnabled { + atomic.AddInt64(&c.submittedCount, amount) + } +} diff --git a/kvasir/event.go b/kvasir/event.go new file mode 100644 index 00000000..cb27b10b --- /dev/null +++ b/kvasir/event.go @@ -0,0 +1,27 @@ +package kvasir + +import ( + abci "github.com/cometbft/cometbft/abci/types" +) + +type rawRequest struct { + contract string + requestID uint64 + calldata string +} + +// GetEventValues returns the list of all values in the given log with the given type and key. +func GetEventValues(log []abci.Event, evType string, evKey string) (res []string) { + for _, ev := range log { + if ev.Type != evType { + continue + } + + for _, attr := range ev.Attributes { + if attr.Key == evKey { + res = append(res, attr.Value) + } + } + } + return res +} diff --git a/kvasir/execute.go b/kvasir/execute.go new file mode 100644 index 00000000..8ec64c2a --- /dev/null +++ b/kvasir/execute.go @@ -0,0 +1,319 @@ +package kvasir + +import ( + "bytes" + "context" + "encoding/json" + "fmt" + "image/jpeg" + "image/png" + "os" + "strings" + "time" + + shell "github.com/ipfs/go-ipfs-api" + + app "github.com/ODIN-PROTOCOL/odin-core/app" + wasmtypes "github.com/ODIN-PROTOCOL/wasmd/x/wasm/types" + ctypes "github.com/cometbft/cometbft/rpc/core/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/version" + authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + "github.com/cosmos/cosmos-sdk/x/authz" +) + +var ( + // Proto codec for encoding/decoding proto message + cdc = app.MakeEncodingConfig().Marshaler +) + +func signAndBroadcast( + c *Context, key *keyring.Record, msgs []sdk.Msg, gasLimit uint64, memo string, +) (string, error) { + clientCtx := client.Context{ + Client: c.client, + Codec: cdc, + TxConfig: app.MakeEncodingConfig().TxConfig, + BroadcastMode: "sync", + InterfaceRegistry: app.MakeEncodingConfig().InterfaceRegistry, + } + acc, err := queryAccount(clientCtx, key) + if err != nil { + return "", fmt.Errorf("unable to get account: %w", err) + } + + txf := tx.Factory{}. + WithAccountNumber(acc.GetAccountNumber()). + WithSequence(acc.GetSequence()). + WithTxConfig(app.MakeEncodingConfig().TxConfig). + WithGas(gasLimit).WithGasAdjustment(1). + WithChainID(cfg.ChainID). + WithMemo(memo). + WithGasPrices(c.gasPrices). + WithKeybase(kb). + WithAccountRetriever(clientCtx.AccountRetriever) + + address, err := key.GetAddress() + if err != nil { + return "", err + } + + execMsg := authz.NewMsgExec(address, msgs) + + txb, err := txf.BuildUnsignedTx(&execMsg) + if err != nil { + return "", err + } + + err = tx.Sign(context.Background(), txf, key.Name, txb, true) + if err != nil { + return "", err + } + + txBytes, err := clientCtx.TxConfig.TxEncoder()(txb.GetTx()) + if err != nil { + return "", err + } + + // broadcast to a Tendermint node + res, err := clientCtx.BroadcastTx(txBytes) + if err != nil { + return "", err + } + + return res.TxHash, nil +} + +func queryAccount(clientCtx client.Context, key *keyring.Record) (client.Account, error) { + accountRetriever := authtypes.AccountRetriever{} + + address, err := key.GetAddress() + if err != nil { + return nil, err + } + + acc, err := accountRetriever.GetAccount(clientCtx, address) + if err != nil { + return nil, err + } + + return acc, nil +} + +// SubmitReport TODO: rework +func SubmitReport(c *Context, l *Logger, keyIndex int64, reports []ReportMsgWithKey) { + // Return key and update pending metric when done with SubmitReport whether successfully or not. + defer func() { + c.freeKeys <- keyIndex + }() + defer c.updatePendingGauge(int64(-len(reports))) + + // Summarize execute version + versionMap := make(map[string]bool) + msgs := make([]sdk.Msg, len(reports)) + ids := make([]uint64, len(reports)) + + for i, report := range reports { + hash, err := uploadToIPFS(c, l, report.result, report) + if err != nil { + fmt.Println(err) + continue + } + fmt.Println(hash) + + contractMsg := fmt.Sprintf( + "{\"report_data\":{\"val_address\": \"%s\", \"request_id\": %d, \"response\": \"%s\"}}", + c.validator.String(), + report.request.RequestID, + hash, + ) + + msg := wasmtypes.MsgExecuteContract{ + Sender: c.validatorAccAddr.String(), + Contract: report.contractAddress, + Msg: []byte(contractMsg), + Funds: sdk.Coins{}, + } + + if err := msg.ValidateBasic(); err != nil { + l.Error(":exploding_head: Failed to validate basic with error: %s", c, err.Error()) + return + } + msgs[i] = sdk.Msg(&msg) + ids[i] = report.request.RequestID + versionMap[report.execVersion] = true + } + l = l.With("rids", ids) + + versions := make([]string, 0, len(versionMap)) + for exec := range versionMap { + versions = append(versions, exec) + } + memo := fmt.Sprintf("kvasir:%s/exec:%s", version.Version, strings.Join(versions, ",")) + key := c.keys[keyIndex] + + clientCtx := client.Context{ + Client: c.client, + TxConfig: app.MakeEncodingConfig().TxConfig, + InterfaceRegistry: app.MakeEncodingConfig().InterfaceRegistry, + } + + gasLimit := uint64(300_000 * len(msgs)) + // We want to resend transaction only if tx returns Out of gas error. + for sendAttempt := uint64(1); sendAttempt <= c.maxTry; sendAttempt++ { + var txHash string + l.Info(":e-mail: Sending report transaction attempt: (%d/%d)", sendAttempt, c.maxTry) + for broadcastTry := uint64(1); broadcastTry <= c.maxTry; broadcastTry++ { + l.Info(":writing_hand: Try to sign and broadcast report transaction(%d/%d)", broadcastTry, c.maxTry) + hash, err := signAndBroadcast(c, key, msgs, gasLimit, memo) + if err != nil { + // Use info level because this error can happen and retry process can solve this error. + l.Info(":warning: %s", err.Error()) + time.Sleep(c.rpcPollInterval) + continue + } + // Transaction passed CheckTx process and wait to include in block. + txHash = hash + break + } + if txHash == "" { + l.Error(":exploding_head: Cannot try to broadcast more than %d try", c, c.maxTry) + return + } + txFound := false + FindTx: + for start := time.Now(); time.Since(start) < c.broadcastTimeout; { + time.Sleep(c.rpcPollInterval) + txRes, err := authtx.QueryTx(clientCtx, txHash) + if err != nil { + l.Debug(":warning: Failed to query tx with error: %s", err.Error()) + continue + } + + if txRes.Code == 0 { + l.Info(":smiling_face_with_sunglasses: Successfully broadcast tx with hash: %s", txHash) + c.updateSubmittedCount(int64(len(reports))) + return + } + if txRes.Codespace == sdkerrors.RootCodespace && + txRes.Code == sdkerrors.ErrOutOfGas.ABCICode() { + // Increase gas limit and try to broadcast again + gasLimit = gasLimit * 110 / 100 + l.Info(":fuel_pump: Tx(%s) is out of gas and will be rebroadcasted with %d gas", txHash, gasLimit) + txFound = true + break FindTx + } else { + l.Error(":exploding_head: Tx returned nonzero code %d with log %s, tx hash: %s", c, txRes.Code, txRes.RawLog, txRes.TxHash) + return + } + } + if !txFound { + l.Error( + ":question_mark: Cannot get transaction response from hash: %s transaction might be included in the next few blocks or check your node's health.", + c, + txHash, + ) + return + } + } + l.Error(":anxious_face_with_sweat: Cannot send reports with adjusted gas: %d", c, gasLimit) +} + +// abciQuery will try to query data from OdinChain node maxTry time before give up and return error +func abciQuery(c *Context, l *Logger, path string, data []byte) (*ctypes.ResultABCIQuery, error) { + var lastErr error + for try := 0; try < int(c.maxTry); try++ { + res, err := c.client.ABCIQuery(context.Background(), path, data) + if err != nil { + l.Debug(":skull: Failed to query on %s request with error: %s", path, err.Error()) + lastErr = err + time.Sleep(c.rpcPollInterval) + continue + } + return res, nil + } + return nil, lastErr +} + +func uploadToIPFS(c *Context, l *Logger, file []byte, report ReportMsgWithKey) (string, error) { + pngFile, err := os.Open(string(file)) + if err != nil { + return "", err + } + defer func() { + pngFile.Close() + os.Remove(string(file)) + }() + + img, err := png.Decode(pngFile) + if err != nil { + return "", err + } + + // Create a new JPG file + jpgFile, err := os.Create(string(file) + ".jpg") + if err != nil { + return "", err + } + defer func() { + jpgFile.Close() + os.Remove(string(file) + ".jpg") + }() + + options := jpeg.Options{ + Quality: 80, + } + + // Encode the image to JPEG and save it + err = jpeg.Encode(jpgFile, img, &options) + if err != nil { + return "", err + } + + var sh *shell.Shell + + if c.ipfsProjectID != "" && c.ipfsProjectSecret != "" { + sh = shell.NewShellWithClient(c.ipfs, NewClient(c.ipfsProjectID, c.ipfsProjectSecret)) + } else { + sh = shell.NewShell(c.ipfs) + } + + // Upload the image to IPFS + pngFile.Seek(0, 0) + pngCID, err := sh.Add(pngFile, shell.Pin(true)) + if err != nil { + return "", err + } + + jpgFile.Seek(0, 0) + jpgCID, err := sh.Add(jpgFile, shell.Pin(true)) + if err != nil { + return "", err + } + + data := map[string]interface{}{ + "image": fmt.Sprintf("https://ipfs.io/ipfs/%s", pngCID), + "preview": fmt.Sprintf("https://ipfs.io/ipfs/%s", jpgCID), + "request_id": report.request.RequestID, + "request_height": report.request.RequestHeight, + "prompt": report.request.Metadata, + "owner": report.request.Sender, + } + + jsonData, err := json.Marshal(data) + if err != nil { + return "", err + } + + cid, err := sh.Add(bytes.NewReader(jsonData), shell.Pin(true)) + if err != nil { + return "", err + } + + return cid, nil +} diff --git a/kvasir/executor/executor.go b/kvasir/executor/executor.go new file mode 100644 index 00000000..83169bf3 --- /dev/null +++ b/kvasir/executor/executor.go @@ -0,0 +1,94 @@ +package executor + +import ( + "errors" + "fmt" + "net/url" + "strings" + "time" +) + +const ( + flagQueryTimeout = "timeout" +) + +var ( + ErrExecutionimeout = errors.New("execution timeout") + ErrRestNotOk = errors.New("rest return non 2XX response") +) + +type ExecResult struct { + Output []byte + Code uint32 + Version string +} + +type Executor interface { + Exec(arg string, env interface{}) (ExecResult, error) +} + +// NewExecutor returns executor by name and executor URL +func NewExecutor(executor string) (exec Executor, err error) { + name, base, timeout, err := parseExecutor(executor) + if err != nil { + return nil, err + } + switch name { + case "rest": + exec = NewRestExec(base, timeout) + case "docker": + return nil, fmt.Errorf("docker executor is currently not supported") + default: + return nil, fmt.Errorf("invalid executor name: %s, base: %s", name, base) + } + + // TODO: Remove hardcode in test execution + return exec, nil + + //res, err := exec.Exec("TEST_ARG", map[string]interface{}{ + // "ODIN_CHAIN_ID": "test-chain-id", + // "ODIN_VALIDATOR": "test-validator", + // "ODIN_REQUEST_ID": "test-request-id", + // "ODIN_EXTERNAL_ID": "test-external-id", + // "ODIN_REPORTER": "test-reporter", + // "ODIN_SIGNATURE": "test-signature", + //}) + // + //if err != nil { + // return nil, fmt.Errorf("failed to run test program: %s", err.Error()) + //} + //if res.Code != 0 { + // return nil, fmt.Errorf("test program returned nonzero code: %d", res.Code) + //} + //if string(res.Output) != "TEST_ARG test-chain-id\n" { + // return nil, fmt.Errorf("test program returned wrong output: %s", res.Output) + //} + //return exec, nil +} + +// parseExecutor splits the executor string in the form of "name:base?timeout=" into parts. +func parseExecutor(executorStr string) (name string, base string, timeout time.Duration, err error) { + executor := strings.SplitN(executorStr, ":", 2) + if len(executor) != 2 { + return "", "", 0, fmt.Errorf("invalid executor, cannot parse executor: %s", executorStr) + } + u, err := url.Parse(executor[1]) + if err != nil { + return "", "", 0, fmt.Errorf("invalid url, cannot parse %s to url with error: %s", executor[1], err.Error()) + } + + query := u.Query() + timeoutStr := query.Get(flagQueryTimeout) + if timeoutStr == "" { + return "", "", 0, fmt.Errorf("invalid timeout, executor requires query timeout") + } + // Remove timeout from query because we need to return `base` + query.Del(flagQueryTimeout) + u.RawQuery = query.Encode() + + timeout, err = time.ParseDuration(timeoutStr) + if err != nil { + return "", "", 0, fmt.Errorf("invalid timeout, cannot parse duration with error: %s", err.Error()) + } + return executor[0], u.String(), timeout, nil +} diff --git a/kvasir/executor/executor_test.go b/kvasir/executor/executor_test.go new file mode 100644 index 00000000..a1f5d7d3 --- /dev/null +++ b/kvasir/executor/executor_test.go @@ -0,0 +1,43 @@ +package executor + +import ( + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func TestParseExecutor(t *testing.T) { + name, url, timeout, err := parseExecutor("beeb:www.beebprotocol.com?timeout=3s") + require.Equal(t, name, "beeb") + require.Equal(t, timeout, 3*time.Second) + require.Equal(t, url, "www.beebprotocol.com") + require.NoError(t, err) + + name, url, timeout, err = parseExecutor("beeb2:www.beeb.com/anna/kondanna?timeout=300ms") + require.Equal(t, name, "beeb2") + require.Equal(t, timeout, 300*time.Millisecond) + require.Equal(t, url, "www.beeb.com/anna/kondanna") + require.NoError(t, err) + + name, url, timeout, err = parseExecutor("beeb3:https://odinprotocol.com/gg/gg2/odinchain?timeout=1s300ms") + require.Equal(t, name, "beeb3") + require.Equal(t, timeout, 1*time.Second+300*time.Millisecond) + require.Equal(t, url, "https://odinprotocol.com/gg/gg2/odinchain") + require.NoError(t, err) +} + +func TestParseExecutorWithoutRawQuery(t *testing.T) { + _, _, _, err := parseExecutor("beeb:www.beebprotocol.com") + require.EqualError(t, err, "invalid timeout, executor requires query timeout") +} + +func TestParseExecutorInvalidExecutorError(t *testing.T) { + _, _, _, err := parseExecutor("beeb") + require.EqualError(t, err, "invalid executor, cannot parse executor: beeb") +} + +func TestParseExecutorInvalidTimeoutError(t *testing.T) { + _, _, _, err := parseExecutor("beeb:www.beebprotocol.com?timeout=beeb") + require.EqualError(t, err, "invalid timeout, cannot parse duration with error: time: invalid duration \"beeb\"") +} diff --git a/kvasir/executor/rest.go b/kvasir/executor/rest.go new file mode 100644 index 00000000..d07ffba6 --- /dev/null +++ b/kvasir/executor/rest.go @@ -0,0 +1,72 @@ +package executor + +import ( + "fmt" + "net/url" + "time" + + "github.com/levigross/grequests" +) + +type RestExec struct { + url string + timeout time.Duration +} + +func NewRestExec(url string, timeout time.Duration) *RestExec { + return &RestExec{url: url, timeout: timeout} +} + +type externalExecutionResponse struct { + Returncode uint32 `json:"returncode"` + Stdout string `json:"stdout"` + Stderr string `json:"stderr"` + Version string `json:"version"` +} + +func (e *RestExec) Exec(arg string, env interface{}) (ExecResult, error) { + resp, err := grequests.Post( + e.url, + &grequests.RequestOptions{ + Headers: map[string]string{ + "Content-Type": "application/json", + }, + JSON: map[string]interface{}{ + "prompt": arg, + //"timeout": e.timeout.Milliseconds(), + //"env": env, + }, + RequestTimeout: e.timeout, + }, + ) + + if err != nil { + urlErr, ok := err.(*url.Error) + if !ok || !urlErr.Timeout() { + return ExecResult{}, err + } + // Return timeout code + return ExecResult{Output: []byte{}, Code: 111}, nil + } + + if !resp.Ok { + return ExecResult{}, ErrRestNotOk + } + + // TODO: find better solution and refactor + r := externalExecutionResponse{} + + now := time.Now() + name := fmt.Sprintf("%d-%d.png", now.Second(), now.Nanosecond()) + + err = resp.DownloadToFile(name) + if err != nil { + return ExecResult{}, err + } + + if r.Returncode == 0 { + return ExecResult{Output: []byte(name), Code: 0, Version: r.Version}, nil + } else { + return ExecResult{Output: []byte(r.Stderr), Code: r.Returncode, Version: r.Version}, nil + } +} diff --git a/kvasir/executor/rest_test.go b/kvasir/executor/rest_test.go new file mode 100644 index 00000000..8f5378b5 --- /dev/null +++ b/kvasir/executor/rest_test.go @@ -0,0 +1,97 @@ +package executor + +import ( + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + "time" + + "github.com/stretchr/testify/require" +) + +func creatDefaultServer() *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(200) + ret := externalExecutionResponse{ + Returncode: 0, + Stdout: "BEEB", + Stderr: "Stderr", + } + json.NewEncoder(res).Encode(ret) + })) +} + +func createResponseNotOkSenarioServer() *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(500) + })) +} + +func createCannotDecodeJsonSenarioServer() *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(200) + res.Write([]byte("invalid bytes")) + })) +} + +func creatExecuteFailSenarioServer() *httptest.Server { + return httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + res.WriteHeader(200) + ret := externalExecutionResponse{ + Returncode: 1, + Stdout: "BEEB", + Stderr: "Stderr", + } + json.NewEncoder(res).Encode(ret) + })) +} + +//func TestExecuteSuccess(t *testing.T) { +// testServer := creatDefaultServer() +// defer func() { testServer.Close() }() +// +// executor := NewRestExec(testServer.URL, 1*time.Second) +// res, err := executor.Exec("calldata", nil) +// require.NoError(t, err) +// require.Equal(t, uint32(0), res.Code) +// require.Equal(t, []byte("BEEB"), res.Output) +//} + +func TestExecuteBadUrlFail(t *testing.T) { + testServer := creatDefaultServer() + defer func() { testServer.Close() }() + + executor := NewRestExec("www.beeb.com", 1*time.Second) // bad url + _, err := executor.Exec("calldata", nil) + require.Error(t, err) +} + +//func TestExecuteDecodeStructFail(t *testing.T) { +// testServer := createCannotDecodeJsonSenarioServer() +// defer func() { testServer.Close() }() +// +// executor := NewRestExec(testServer.URL, 1*time.Second) +// _, err := executor.Exec("calldata", nil) +// require.Error(t, err) +//} + +func TestExecuteResponseNotOk(t *testing.T) { + testServer := createResponseNotOkSenarioServer() + defer func() { testServer.Close() }() + + executor := NewRestExec(testServer.URL, 1*time.Second) + _, err := executor.Exec("calldata", nil) + require.ErrorIs(t, err, ErrRestNotOk) +} + +//func TestExecuteFail(t *testing.T) { +// testServer := creatExecuteFailSenarioServer() +// defer func() { testServer.Close() }() +// +// executor := NewRestExec(testServer.URL, 1*time.Second) +// res, err := executor.Exec("calldata", nil) +// require.NoError(t, err) +// require.Equal(t, uint32(1), res.Code) +// require.Equal(t, []byte("Stderr"), res.Output) +//} diff --git a/kvasir/handler.go b/kvasir/handler.go new file mode 100644 index 00000000..36c01c3b --- /dev/null +++ b/kvasir/handler.go @@ -0,0 +1,142 @@ +package kvasir + +import ( + "encoding/hex" + "strconv" + + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cometbft/cometbft/crypto/tmhash" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/types/tx/signing" +) + +type processingResult struct { + result []byte + version string +} + +func handleTransaction(c *Context, l *Logger, tx abci.TxResult) { + l.Debug(":eyes: Inspecting incoming transaction: %X", tmhash.Sum(tx.Tx)) + if tx.Result.Code != 0 { + l.Debug(":alien: Skipping transaction with non-zero code: %d", tx.Result.Code) + return + } + + go handleRequestLog(c, l, tx.Result.Events) +} + +func handleRequestLog(c *Context, l *Logger, log []abci.Event) { + idStrs := GetEventValues(log, "wasm-wasm_request", "id") + contractStrs := GetEventValues(log, "wasm-wasm_request", "contract") + + for i, idStr := range idStrs { + id, err := strconv.ParseUint(idStr, 10, 64) + if err != nil { + l.Error(":cold_sweat: Failed to convert %s to integer with error: %s", c, idStr, err.Error()) + return + } + + // TODO: write better solution + contract := contractStrs[i] + + // If id is in pending requests list, then skip it. + if c.pendingRequests[RequestKey{ + ContractAddress: contract, + RequestID: id, + }] { + l.Debug(":eyes: Request is in pending list, then skip") + return + } + + request, err := queryPendingRequest(c, l, id, contract) + if err != nil { + l.Error(":cold_sweat: Failed to query pending request with error: %s", c, err.Error()) + continue + } + + go handleRequest(c, l, contract, request) + } +} + +func handleRequest(c *Context, l *Logger, contract string, request Request) { + l = l.With("contract", contract, "rid", request.RequestID) + + hasMe := false + for _, val := range request.ChosenValidators { + if val == c.validator.String() { + hasMe = true + break + } + } + if !hasMe { + l.Debug(":next_track_button: Skip request not related to this validator") + return + } + + l.Info(":delivery_truck: Processing request") + + keyIndex := c.nextKeyIndex() + key := c.keys[keyIndex] + + rawRequest := rawRequest{ + contract: contract, + requestID: request.RequestID, + calldata: request.Metadata, + } + + // process raw requests + result, err := handleRawRequest(c, l, rawRequest, key) + if err != nil { + l.Debug("Cannot process request: %s", err.Error()) + return + } + + c.pendingMsgs <- ReportMsgWithKey{ + contractAddress: contract, + //msg: types.NewMsgReportData(types.RequestID(id), reports, c.validator), + execVersion: result.version, + keyIndex: keyIndex, + result: result.result, + request: request, + } +} + +func handleRawRequest( + c *Context, + l *Logger, + req rawRequest, + key *keyring.Record, +) (*processingResult, error) { + c.updateHandlingGauge(1) + defer c.updateHandlingGauge(-1) + + vmsg := NewRequestVerification(cfg.ChainID, c.validator, req.requestID, req.contract) + sig, pubkey, err := kb.Sign(key.Name, vmsg.GetSignBytes(), signing.SignMode_SIGN_MODE_DIRECT) + if err != nil { + l.Error(":skull: Failed to sign verify message: %s", c, err.Error()) + return nil, err + } + + result, err := c.executor.Exec(req.calldata, map[string]interface{}{ + "ODIN_CHAIN_ID": vmsg.ChainID, + "ODIN_CONTRACT": vmsg.Contract, + "ODIN_VALIDATOR": vmsg.Validator, + "ODIN_REQUEST_ID": strconv.Itoa(int(vmsg.RequestID)), + "ODIN_REPORTER": hex.EncodeToString(pubkey.Bytes()), + "ODIN_SIGNATURE": sig, + }) + + if err != nil { + l.Error(":skull: Failed to execute data source script: %s", c, err.Error()) + return nil, err + } else { + l.Debug( + ":sparkles: Query data done with calldata: %q, result: %q, exitCode: %d", + req.calldata, result.Output, result.Code, + ) + return &processingResult{ + result: result.Output, + version: result.Version, + }, err + } +} diff --git a/kvasir/ipfs_client.go b/kvasir/ipfs_client.go new file mode 100644 index 00000000..b9fdd269 --- /dev/null +++ b/kvasir/ipfs_client.go @@ -0,0 +1,25 @@ +package kvasir + +import "net/http" + +func NewClient(projectId, projectSecret string) *http.Client { + return &http.Client{ + Transport: authTransport{ + RoundTripper: http.DefaultTransport, + ProjectId: projectId, + ProjectSecret: projectSecret, + }, + } +} + +// authTransport decorates each request with a basic auth header. +type authTransport struct { + http.RoundTripper + ProjectId string + ProjectSecret string +} + +func (t authTransport) RoundTrip(r *http.Request) (*http.Response, error) { + r.SetBasicAuth(t.ProjectId, t.ProjectSecret) + return t.RoundTripper.RoundTrip(r) +} diff --git a/kvasir/keys.go b/kvasir/keys.go new file mode 100644 index 00000000..9a8df262 --- /dev/null +++ b/kvasir/keys.go @@ -0,0 +1,235 @@ +package kvasir + +import ( + "bufio" + "context" + "fmt" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/input" + "github.com/cosmos/cosmos-sdk/crypto/hd" + bip39 "github.com/cosmos/go-bip39" + "github.com/kyokomi/emoji" + "github.com/spf13/cobra" + "github.com/spf13/viper" + + app "github.com/ODIN-PROTOCOL/odin-core/app" + "github.com/ODIN-PROTOCOL/odin-core/x/oracle/types" +) + +const ( + flagAccount = "account" + flagIndex = "index" + flagCoinType = "coin-type" + flagRecover = "recover" + flagAddress = "address" +) + +func keysCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "keys", + Aliases: []string{"k"}, + Short: "Manage key held by the process", + } + cmd.AddCommand( + keysAddCmd(c), + keysDeleteCmd(c), + keysListCmd(c), + keysShowCmd(c), + ImportKeyHexCommand(), + ) + return cmd +} + +func keysAddCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "add [name]", + Aliases: []string{"a"}, + Short: "Add a new key to the keychain", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + var mnemonic string + recover, err := cmd.Flags().GetBool(flagRecover) + if err != nil { + return err + } + if recover { + inBuf := bufio.NewReader(cmd.InOrStdin()) + var err error + mnemonic, err = input.GetString("Enter your bip39 mnemonic", inBuf) + if err != nil { + return err + } + } else { + seed, err := bip39.NewEntropy(256) + if err != nil { + return err + } + mnemonic, err = bip39.NewMnemonic(seed) + if err != nil { + return err + } + fmt.Printf("Mnemonic: %s\n", mnemonic) + } + + if err != nil { + return err + } + account, err := cmd.Flags().GetUint32(flagAccount) + if err != nil { + return err + } + index, err := cmd.Flags().GetUint32(flagIndex) + if err != nil { + return err + } + hdPath := hd.CreateHDPath(app.Bip44CoinType, account, index) + info, err := kb.NewAccount(args[0], mnemonic, "", hdPath.String(), hd.Secp256k1) + if err != nil { + return err + } + + address, err := info.GetAddress() + if err != nil { + return err + } + + fmt.Printf("Address: %s\n", address.String()) + return nil + }, + } + cmd.Flags().Bool(flagRecover, false, "Provide seed phrase to recover existing key instead of creating") + cmd.Flags().Uint32(flagAccount, 0, "Account number for HD derivation") + cmd.Flags().Uint32(flagIndex, 0, "Address index number for HD derivation") + return cmd +} + +func keysDeleteCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "delete [name]", + Aliases: []string{"d"}, + Short: "Delete a key from the keychain", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + name := args[0] + + _, err := kb.Key(name) + if err != nil { + return err + } + + inBuf := bufio.NewReader(cmd.InOrStdin()) + confirmInput, err := input.GetString("Key will be deleted. Continue?[y/N]", inBuf) + if err != nil { + return err + } + + if confirmInput != "y" { + fmt.Println("Cancel") + return nil + } + + if err := kb.Delete(name); err != nil { + return err + } + + fmt.Printf("Deleted key: %s\n", name) + return nil + }, + } + return cmd +} + +func ImportKeyHexCommand() *cobra.Command { + cmd := &cobra.Command{ + Use: "import-hex ", + Short: "Import private keys into the local keybase", + Long: "Import hex encoded private key into the local keybase.\nSupported key-types can be obtained with:\n list-key-types", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + keyType, _ := cmd.Flags().GetString(flags.FlagKeyType) + return kb.ImportPrivKeyHex(args[0], args[1], keyType) + }, + } + cmd.Flags().String(flags.FlagKeyType, string(hd.Secp256k1Type), "private key signing algorithm kind") + return cmd +} + +func keysListCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "list", + Aliases: []string{"l"}, + Short: "List all the keys in the keychain", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientQueryContext(cmd) + if err != nil { + return err + } + keys, err := kb.List() + if err != nil { + return err + } + isShowAddr := viper.GetBool(flagAddress) + for _, key := range keys { + address, err := key.GetAddress() + if err != nil { + return err + } + + if isShowAddr { + fmt.Printf("%s ", address.String()) + } else { + queryClient := types.NewQueryClient(clientCtx) + r, err := queryClient.IsReporter( + context.Background(), + &types.QueryIsReporterRequest{ValidatorAddress: cfg.Validator, ReporterAddress: address.String()}, + ) + s := ":question:" + if err == nil { + if r.IsReporter { + s = ":white_check_mark:" + } else { + s = ":x:" + } + } + emoji.Printf("%s%s => %s\n", s, key.Name, address.String()) + } + } + + return nil + }, + } + cmd.Flags().BoolP(flagAddress, "a", false, "Output the address only") + viper.BindPFlag(flagAddress, cmd.Flags().Lookup(flagAddress)) + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func keysShowCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "show [name]", + Aliases: []string{"s"}, + Short: "Show address from name in the keychain", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + name := args[0] + + key, err := kb.Key(name) + if err != nil { + return err + } + + address, err := key.GetAddress() + if err != nil { + return err + } + fmt.Println(address.String()) + return nil + }, + } + return cmd +} diff --git a/kvasir/logger.go b/kvasir/logger.go new file mode 100644 index 00000000..1b0bc25b --- /dev/null +++ b/kvasir/logger.go @@ -0,0 +1,33 @@ +package kvasir + +import ( + "os" + + "github.com/cometbft/cometbft/libs/log" + "github.com/kyokomi/emoji" +) + +type Logger struct { + logger log.Logger +} + +func NewLogger(level log.Option) *Logger { + return &Logger{logger: log.NewFilter(log.NewTMLogger(os.Stdout), level)} +} + +func (l *Logger) Debug(format string, args ...interface{}) { + l.logger.Debug(emoji.Sprintf(format, args...)) +} + +func (l *Logger) Info(format string, args ...interface{}) { + l.logger.Info(emoji.Sprintf(format, args...)) +} + +func (l *Logger) Error(format string, c *Context, args ...interface{}) { + l.logger.Error(emoji.Sprintf(format, args...)) + c.updateErrorCount(1) +} + +func (l *Logger) With(keyvals ...interface{}) *Logger { + return &Logger{logger: l.logger.With(keyvals...)} +} diff --git a/kvasir/main.go b/kvasir/main.go new file mode 100644 index 00000000..738efb7f --- /dev/null +++ b/kvasir/main.go @@ -0,0 +1,109 @@ +package kvasir + +import ( + "fmt" + "os" + "path" + "path/filepath" + + app "github.com/ODIN-PROTOCOL/odin-core/app" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/crypto/keyring" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/version" + "github.com/spf13/cobra" + "github.com/spf13/viper" +) + +const ( + flagValidator = "validator" + flagLogLevel = "log-level" + flagExecutor = "executor" + flagBroadcastTimeout = "broadcast-timeout" + flagRPCPollInterval = "rpc-poll-interval" + flagMaxTry = "max-try" + flagMaxReport = "max-report" +) + +type Config struct { + ChainID string `mapstructure:"chain-id"` // ChainID of the target chain + NodeURI string `mapstructure:"node"` // Remote RPC URI of OdinChain node to connect to + Validator string `mapstructure:"validator"` // The validator address that I'm responsible for + ValidatorAccAddr string `mapstructure:"validator-acc"` + GasPrices string `mapstructure:"gas-prices"` // Gas prices of the transaction + LogLevel string `mapstructure:"log-level"` // Log level of the logger + Executor string `mapstructure:"executor"` // Executor name and URL (example: "Executor name:URL") + BroadcastTimeout string `mapstructure:"broadcast-timeout"` // The time that Yoda will wait for tx commit + RPCPollInterval string `mapstructure:"rpc-poll-interval"` // The duration of rpc poll interval + MaxTry uint64 `mapstructure:"max-try"` // The maximum number of tries to submit a report transaction + MaxReport uint64 `mapstructure:"max-report"` // The maximum number of reports in one transaction + MetricsListenAddr string `mapstructure:"metrics-listen-addr"` // Address to listen on for prometheus metrics + Contracts []string `mapstructure:"contracts"` + IPFS string `mapstructure:"ipfs"` + IPFSProjectID string `mapstructure:"ipfs_project_id"` // For Infura IPFS usage, leave empty otherwise + IPFSProjectSecret string `mapstructure:"ipfs_project_secret"` + GRPC string `mapstructure:"grpc"` +} + +// Global instances. +var ( + cfg Config + kb keyring.Keyring + DefaultKvasirHome string +) + +func initConfig(c *Context, cmd *cobra.Command) error { + viper.SetConfigFile(path.Join(c.home, "config.yaml")) + _ = viper.ReadInConfig() // If we fail to read config file, we'll just rely on cmd flags. + if err := viper.Unmarshal(&cfg); err != nil { + return err + } + return nil +} + +func init() { + userHomeDir, err := os.UserHomeDir() + if err != nil { + panic(err) + } + + DefaultKvasirHome = filepath.Join(userHomeDir, ".kvasir") +} + +func Main() { + appConfig := sdk.GetConfig() + app.SetBech32AddressPrefixesAndBip44CoinTypeAndSeal(appConfig) + + ctx := &Context{} + rootCmd := &cobra.Command{ + Use: "yoda", + Short: "OdinChain oracle daemon to subscribe and response to oracle requests", + } + + rootCmd.AddCommand( + configCmd(), + keysCmd(ctx), + runCmd(ctx), + version.NewVersionCommand(), + ) + rootCmd.PersistentPreRunE = func(_ *cobra.Command, _ []string) error { + home, err := rootCmd.PersistentFlags().GetString(flags.FlagHome) + if err != nil { + return err + } + ctx.home = home + if err := os.MkdirAll(home, os.ModePerm); err != nil { + return err + } + kb, err = keyring.New("odin", keyring.BackendTest, home, nil, cdc) + if err != nil { + return err + } + return initConfig(ctx, rootCmd) + } + rootCmd.PersistentFlags().String(flags.FlagHome, DefaultKvasirHome, "home directory") + if err := rootCmd.Execute(); err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/kvasir/run.go b/kvasir/run.go new file mode 100644 index 00000000..1ec6adc1 --- /dev/null +++ b/kvasir/run.go @@ -0,0 +1,258 @@ +package kvasir + +import ( + "context" + "encoding/json" + "errors" + "fmt" + "time" + + "github.com/ODIN-PROTOCOL/odin-core/kvasir/executor" + wasmtypes "github.com/ODIN-PROTOCOL/wasmd/x/wasm/types" + "github.com/cometbft/cometbft/libs/log" + httpclient "github.com/cometbft/cometbft/rpc/client/http" + tmtypes "github.com/cometbft/cometbft/types" + "github.com/cosmos/cosmos-sdk/client/flags" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/spf13/cobra" + "github.com/spf13/viper" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" +) + +const ( + TxQuery = "tm.event = 'Tx' AND wasm-wasm_request.id EXISTS AND wasm-wasm_request.contract EXISTS" + // EventChannelCapacity is a buffer size of channel between node and this program + EventChannelCapacity = 2000 +) + +func runImpl(c *Context, l *Logger) error { + l.Info(":rocket: Starting WebSocket subscriber") + err := c.client.Start() + if err != nil { + return err + } + defer c.client.Stop() + + ctx, cxl := context.WithTimeout(context.Background(), 5*time.Second) + defer cxl() + + l.Info(":ear: Subscribing to events with query: %s...", TxQuery) + eventChan, err := c.client.Subscribe(ctx, "", TxQuery, EventChannelCapacity) + if err != nil { + return err + } + + //if c.metricsEnabled { + // l.Info(":eyes: Starting Prometheus listener") + // go metricsListen(cfg.MetricsListenAddr, c) + //} + + availiableKeys := make([]bool, len(c.keys)) + waitingMsgs := make([][]ReportMsgWithKey, len(c.keys)) + for i := range availiableKeys { + availiableKeys[i] = true + waitingMsgs[i] = []ReportMsgWithKey{} + } + + pendingRequests := make(map[string][]Request) + pendingRequestsCount := 0 + + for _, contract := range c.contracts { + requests, err := queryPendingRequests(c, l, contract) + if err != nil { + l.Error(":exploding_head: Failed to get pending requests from contract %s: %s", c, contract, err.Error()) + } + + pendingRequests[contract] = requests + pendingRequestsCount += len(requests) + } + + l.Info(":mag: Found %d pending requests", pendingRequestsCount) + for contract, requests := range pendingRequests { + for _, request := range requests { + c.pendingRequests[RequestKey{ + ContractAddress: contract, + RequestID: request.RequestID, + }] = true + + go handleRequest(c, l, contract, request) + } + } + + for { + select { + case ev := <-eventChan: + go handleTransaction(c, l, ev.Data.(tmtypes.EventDataTx).TxResult) + case keyIndex := <-c.freeKeys: + if len(waitingMsgs[keyIndex]) != 0 { + if uint64(len(waitingMsgs[keyIndex])) > c.maxReport { + go SubmitReport(c, l, keyIndex, waitingMsgs[keyIndex][:c.maxReport]) + waitingMsgs[keyIndex] = waitingMsgs[keyIndex][c.maxReport:] + } else { + go SubmitReport(c, l, keyIndex, waitingMsgs[keyIndex]) + waitingMsgs[keyIndex] = []ReportMsgWithKey{} + } + } else { + availiableKeys[keyIndex] = true + } + case pm := <-c.pendingMsgs: + c.updatePendingGauge(1) + if availiableKeys[pm.keyIndex] { + availiableKeys[pm.keyIndex] = false + go SubmitReport(c, l, pm.keyIndex, []ReportMsgWithKey{pm}) + } else { + waitingMsgs[pm.keyIndex] = append(waitingMsgs[pm.keyIndex], pm) + } + } + } +} + +func runCmd(c *Context) *cobra.Command { + cmd := &cobra.Command{ + Use: "run", + Aliases: []string{"r"}, + Short: "Run the oracle process", + Args: cobra.ExactArgs(0), + RunE: func(cmd *cobra.Command, args []string) error { + if cfg.ChainID == "" { + return errors.New("chain ID must not be empty") + } + keys, err := kb.List() + if err != nil { + return err + } + if len(keys) == 0 { + return errors.New("no key available") + } + c.keys = keys + c.validator, err = sdk.ValAddressFromBech32(cfg.Validator) + if err != nil { + return err + } + err = sdk.VerifyAddressFormat(c.validator) + if err != nil { + return err + } + + c.validatorAccAddr, err = sdk.AccAddressFromBech32(cfg.ValidatorAccAddr) + if err != nil { + return err + } + err = sdk.VerifyAddressFormat(c.validatorAccAddr) + if err != nil { + return err + } + + c.gasPrices = cfg.GasPrices + + allowLevel, err := log.AllowLevel(cfg.LogLevel) + if err != nil { + return err + } + l := NewLogger(allowLevel) + c.executor, err = executor.NewExecutor(cfg.Executor) + if err != nil { + return err + } + l.Info(":star: Creating HTTP client with node URI: %s", cfg.NodeURI) + c.client, err = httpclient.New(cfg.NodeURI, "/websocket") + if err != nil { + return err + } + c.broadcastTimeout, err = time.ParseDuration(cfg.BroadcastTimeout) + if err != nil { + return err + } + c.maxTry = cfg.MaxTry + c.maxReport = cfg.MaxReport + c.rpcPollInterval, err = time.ParseDuration(cfg.RPCPollInterval) + if err != nil { + return err + } + c.pendingMsgs = make(chan ReportMsgWithKey) + c.freeKeys = make(chan int64, len(keys)) + c.keyRoundRobinIndex = -1 + c.pendingRequests = make(map[RequestKey]bool) + c.metricsEnabled = cfg.MetricsListenAddr != "" + c.contracts = cfg.Contracts + c.ipfs = cfg.IPFS + c.ipfsProjectID = cfg.IPFSProjectID + c.ipfsProjectSecret = cfg.IPFSProjectSecret + + c.grpc, err = grpc.NewClient(cfg.GRPC, grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + return err + } + + return runImpl(c, l) + }, + } + cmd.Flags().String(flags.FlagChainID, "", "chain ID of OdinChain network") + cmd.Flags().String(flags.FlagNode, "tcp://localhost:26657", "RPC url to OdinChain node") + cmd.Flags().String(flagValidator, "", "validator address") + cmd.Flags().String(flagExecutor, "", "executor name and url for executing the data source script") + cmd.Flags().String(flags.FlagGasPrices, "", "gas prices for report transaction") + cmd.Flags().String(flagLogLevel, "info", "set the logger level") + cmd.Flags().String(flagBroadcastTimeout, "5m", "The time that Yoda will wait for tx commit") + cmd.Flags().String(flagRPCPollInterval, "1s", "The duration of rpc poll interval") + cmd.Flags().Uint64(flagMaxTry, 5, "The maximum number of tries to submit a report transaction") + cmd.Flags().Uint64(flagMaxReport, 10, "The maximum number of reports in one transaction") + viper.BindPFlag(flags.FlagChainID, cmd.Flags().Lookup(flags.FlagChainID)) + viper.BindPFlag(flags.FlagNode, cmd.Flags().Lookup(flags.FlagNode)) + viper.BindPFlag(flagValidator, cmd.Flags().Lookup(flagValidator)) + viper.BindPFlag(flags.FlagGasPrices, cmd.Flags().Lookup(flags.FlagGasPrices)) + viper.BindPFlag(flagLogLevel, cmd.Flags().Lookup(flagLogLevel)) + viper.BindPFlag(flagExecutor, cmd.Flags().Lookup(flagExecutor)) + viper.BindPFlag(flagBroadcastTimeout, cmd.Flags().Lookup(flagBroadcastTimeout)) + viper.BindPFlag(flagRPCPollInterval, cmd.Flags().Lookup(flagRPCPollInterval)) + viper.BindPFlag(flagMaxTry, cmd.Flags().Lookup(flagMaxTry)) + viper.BindPFlag(flagMaxReport, cmd.Flags().Lookup(flagMaxReport)) + return cmd +} + +func queryPendingRequests(c *Context, l *Logger, contractAddr string) ([]Request, error) { + query := "{\"list_pending_requests\":{}}" + + client := wasmtypes.NewQueryClient(c.grpc) + res, err := client.SmartContractState(context.Background(), &wasmtypes.QuerySmartContractStateRequest{ + Address: contractAddr, + QueryData: []byte(query), + }) + if err != nil { + l.Error(":exploding_head: Failed to get pending requests with error: %s", c, err.Error()) + } + + l.Debug(fmt.Sprintf("%v", res)) + + resp := make([]Request, 0) + err = json.Unmarshal(res.Data, &resp) + if err != nil { + return nil, err + } + + return resp, nil +} + +func queryPendingRequest(c *Context, l *Logger, requestID uint64, contractAddr string) (Request, error) { + query := fmt.Sprintf("{\"get_request\":{\"request_id\": %d}}", requestID) + + client := wasmtypes.NewQueryClient(c.grpc) + res, err := client.SmartContractState(context.Background(), &wasmtypes.QuerySmartContractStateRequest{ + Address: contractAddr, + QueryData: []byte(query), + }) + if err != nil { + l.Error(":exploding_head: Failed to get pending requests with error: %s", c, err.Error()) + } + + l.Debug(fmt.Sprintf("%v", res)) + + var resp Request + err = json.Unmarshal(res.Data, &resp) + if err != nil { + return resp, err + } + + return resp, nil +} diff --git a/kvasir/verify_request.go b/kvasir/verify_request.go new file mode 100644 index 00000000..ab177092 --- /dev/null +++ b/kvasir/verify_request.go @@ -0,0 +1,33 @@ +package kvasir + +import ( + "encoding/json" + + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type RequestVerification struct { + ChainID string `protobuf:"bytes,1,opt,name=chain_id,json=chainId,proto3" json:"chain_id,omitempty"` + Validator string `protobuf:"bytes,2,opt,name=validator,proto3" json:"validator,omitempty"` + RequestID uint64 `protobuf:"varint,3,opt,name=request_id,json=requestId,proto3,casttype=RequestID" json:"request_id,omitempty"` + Contract string `protobuf:"varint,4,opt,name=contract,json=externalId,proto3,casttype=ExternalID" json:"contract,omitempty"` +} + +func NewRequestVerification( + chainID string, + validator sdk.ValAddress, + requestID uint64, + contract string, +) RequestVerification { + return RequestVerification{ + ChainID: chainID, + Validator: validator.String(), + RequestID: requestID, + Contract: contract, + } +} + +func (msg RequestVerification) GetSignBytes() []byte { + bz, _ := json.Marshal(msg) + return sdk.MustSortJSON(bz) +} diff --git a/proto/onft/v1/genesis.proto b/proto/onft/v1/genesis.proto new file mode 100644 index 00000000..2b4bdc54 --- /dev/null +++ b/proto/onft/v1/genesis.proto @@ -0,0 +1,15 @@ +syntax = "proto3"; +package onft.v1; + +option go_package = "github.com/ODIN-PROTOCOL/odin-core/x/onft/types"; + +import "gogoproto/gogo.proto"; + +// GenesisState defines the onft module's genesis state. +message GenesisState { + // NFTClassID defines number of NFTs minted by module + uint64 nft_class_id = 1 [(gogoproto.moretags) = "yaml:\"nft_class_id\""]; + + // ClassOwners are owners of NFT classes + map class_owners = 2 [(gogoproto.moretags) = "yaml:\"class_owners\""]; +} \ No newline at end of file diff --git a/proto/onft/v1/onft.proto b/proto/onft/v1/onft.proto new file mode 100644 index 00000000..a8ec8e73 --- /dev/null +++ b/proto/onft/v1/onft.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; +package onft.v1; + +import "google/protobuf/any.proto"; + +option go_package = "github.com/ODIN-PROTOCOL/odin-core/x/onft/types"; + +// Class defines the class of the nft type. +message Class { + // id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 + string id = 1; + + // name defines the human-readable name of the NFT classification. Optional + string name = 2; + + // symbol is an abbreviated name for nft classification. Optional + string symbol = 3; + + // description is a brief description of nft classification. Optional + string description = 4; + + // uri for the class metadata stored off chain. It can define schema for Class and NFT `Data` attributes. Optional + string uri = 5; + + // uri_hash is a hash of the document pointed by uri. Optional + string uri_hash = 6; + + // data is the app specific metadata of the NFT class. Optional + google.protobuf.Any data = 7; + + // owner is the owner address of the following nft class + string owner = 8; +} + +// NFT defines the NFT. +message NFT { + // class_id associated with the NFT, similar to the contract address of ERC721 + string class_id = 1; + + // id is a unique identifier of the NFT + string id = 2; + + // uri for the NFT metadata stored off chain + string uri = 3; + + // uri_hash is a hash of the document pointed by uri + string uri_hash = 4; + + // owner is the owner address of the following nft + string owner = 5; + + // data is an app specific data of the NFT. Optional + google.protobuf.Any data = 10; +} \ No newline at end of file diff --git a/proto/onft/v1/query.proto b/proto/onft/v1/query.proto new file mode 100644 index 00000000..31017d0d --- /dev/null +++ b/proto/onft/v1/query.proto @@ -0,0 +1,112 @@ +syntax = "proto3"; +package onft.v1; + +option go_package = "github.com/ODIN-PROTOCOL/odin-core/x/onft/types"; + +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "onft/v1/onft.proto"; + +// Query defines the gRPC querier service. +service Query { + // ClassOwner queries the owner of the NFT class + rpc ClassOwner(QueryClassOwnerRequest) returns (QueryClassOwnerResponse) { + option (google.api.http).get = "/onft/v1/class/{class_id}/owner"; + } + + // NFTs queries all NFTs with owners of a given class or owner,choose at least one of the two, + // similar to tokenByIndex in ERC721Enumerable + rpc NFTs(QueryNFTsRequest) returns (QueryNFTsResponse) { + option (google.api.http).get = "/onft/v1/nfts"; + } + + // NFT queries an NFT with owner based on its class and id + rpc NFT(QueryNFTRequest) returns (QueryNFTResponse) { + option (google.api.http).get = "/onft/v1/nfts/{class_id}/{id}"; + } + + // Class queries an NFT class based on its id with class owner + rpc Class(QueryClassRequest) returns (QueryClassResponse) { + option (google.api.http).get = "/onft/v1/classes/{class_id}"; + } + + // Classes queries all NFT classes with owners + rpc Classes(QueryClassesRequest) returns (QueryClassesResponse) { + option (google.api.http).get = "/onft/v1/classes"; + } +} + +// QueryClassOwnerRequest is the request type for the Query/Owner RPC method +message QueryClassOwnerRequest { + // class_id associated with nft collection + string class_id = 1; +} + +// QueryClassOwnerResponse is the response type for the Query/Owner RPC method +message QueryClassOwnerResponse { + // owner is the owner address of the nft class + string owner = 1; +} + +// QueryNFTstRequest is the request type for the Query/NFTs RPC method +message QueryNFTsRequest { + // class_id associated with the nft + string class_id = 1; + + // owner is the owner address of the nft + string owner = 2; + + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 3; +} + +// QueryNFTsResponse is the response type for the Query/NFTs RPC methods +message QueryNFTsResponse { + // NFT defines the NFT + repeated NFT nfts = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +// QueryNFTRequest is the request type for the Query/NFT RPC method +message QueryNFTRequest { + // class_id associated with the nft + string class_id = 1; + + // id is a unique identifier of the NFT + string id = 2; +} + +// QueryNFTResponse is the response type for the Query/NFT RPC method +message QueryNFTResponse { + // owner is the owner address of the nft + NFT nft = 1; +} + +// QueryClassRequest is the request type for the Query/Class RPC method +message QueryClassRequest { + // class_id associated with the nft + string class_id = 1; +} + +// QueryClassResponse is the response type for the Query/Class RPC method +message QueryClassResponse { + // class defines the class of the nft type. + Class class = 1; +} + +// QueryClassesRequest is the request type for the Query/Classes RPC method +message QueryClassesRequest { + // pagination defines an optional pagination for the request. + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +// QueryClassesResponse is the response type for the Query/Classes RPC method +message QueryClassesResponse { + // class defines the class of the nft type. + repeated Class classes = 1; + + // pagination defines the pagination in the response. + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} \ No newline at end of file diff --git a/proto/onft/v1/tx.proto b/proto/onft/v1/tx.proto new file mode 100644 index 00000000..bd1aa445 --- /dev/null +++ b/proto/onft/v1/tx.proto @@ -0,0 +1,103 @@ +syntax = "proto3"; +package onft.v1; + +option go_package = "github.com/ODIN-PROTOCOL/odin-core/x/onft/types"; + +import "gogoproto/gogo.proto"; +import "cosmos/msg/v1/msg.proto"; +import "cosmos_proto/cosmos.proto"; +import "amino/amino.proto"; +import "google/protobuf/any.proto"; + +// Msg defines the onft Msg service. +service Msg { + // CreateNFTClass defines a method for creating new nft class + rpc CreateNFTClass(MsgCreateNFTClass) returns (MsgCreateNFTClassResponse); + + rpc TransferClassOwnership(MsgTransferClassOwnership) returns (MsgTransferClassOwnershipResponse); + + rpc MintNFT(MsgMintNFT) returns (MsgMintNFTResponse); +} + +// MsgCreateNFTClass is a message for creating new NFT class +message MsgCreateNFTClass { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "onft/CreateNFTClass"; + + option (gogoproto.equal) = true; + + // name defines the human-readable name of the NFT classification. Optional + string name = 1; + + // symbol is an abbreviated name for nft classification. Optional + string symbol = 2; + + // description is a brief description of nft classification. Optional + string description = 3; + + // uri for the class metadata stored off chain. It can define schema for Class and NFT `Data` attributes. Optional + string uri = 4; + + // uri_hash is a hash of the document pointed by uri. Optional + string uri_hash = 5; + + // data is the app specific metadata of the NFT class. Optional + google.protobuf.Any data = 6; + + // Sender is an account address of message sender. + string sender = 7 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgCreateNFTClassResponse is response data for MsgCreateNFTClass message +message MsgCreateNFTClassResponse { + // id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 + string id = 1; +} + +// MsgTransferClassOwnership is a message for transferring class ownership to another owner +message MsgTransferClassOwnership { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "onft/TransferClassOwnership"; + + option (gogoproto.equal) = true; + + string class_id = 1; + + // Sender is an account address of message sender. + string sender = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + string new_owner = 3 [(cosmos_proto.scalar) = "cosmos.AddressString"]; +} + +// MsgTransferClassOwnershipResponse is response data for MsgTransferClassOwnership message +message MsgTransferClassOwnershipResponse {} + +message MsgMintNFT { + option (cosmos.msg.v1.signer) = "sender"; + option (amino.name) = "onft/MintNft"; + + option (gogoproto.equal) = true; + + // class_id associated with the NFT, similar to the contract address of ERC721 + string class_id = 1; + + // uri for the NFT metadata stored off chain + string uri = 2; + + // uri_hash is a hash of the document pointed by uri + string uri_hash = 3; + + // Sender is an account address of message sender. + string sender = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + string receiver = 5 [(cosmos_proto.scalar) = "cosmos.AddressString"]; + + // data is an app specific data of the NFT. Optional + google.protobuf.Any data = 10; +} + +// MsgMintNFTResponse is response data for MsgMintNFT message +message MsgMintNFTResponse { + // id defines the unique identifier of the NFT token + string id = 1; +} \ No newline at end of file diff --git a/x/onft/client/cli/tx.go b/x/onft/client/cli/tx.go new file mode 100644 index 00000000..51608225 --- /dev/null +++ b/x/onft/client/cli/tx.go @@ -0,0 +1,127 @@ +package cli + +import ( + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +// NewTxCmd returns the transaction commands for the NFT module +func NewTxCmd() *cobra.Command { + txCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "NFT transaction subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + txCmd.AddCommand( + GetCmdCreateNFTClass(), + GetCmdTransferClassOwnership(), + GetCmdMintNFT(), + ) + + return txCmd +} + +// GetCmdCreateNFTClass implements the create NFT class command. +func GetCmdCreateNFTClass() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-class [name] [symbol] [description] [uri] [uri-hash]", + Short: "Create a new NFT class", + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreateNFTClass( + args[0], // name + args[1], // symbol + args[2], // description + args[3], // uri + args[4], // uri-hash + nil, + clientCtx.GetFromAddress(), // sender + ) + + err = msg.ValidateBasic() + if err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdTransferClassOwnership implements the transfer class ownership command. +func GetCmdTransferClassOwnership() *cobra.Command { + cmd := &cobra.Command{ + Use: "transfer-class-ownership [class-id] [new-owner]", + Short: "Transfer ownership of an NFT class", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgTransferClassOwnership( + args[0], // class ID + clientCtx.GetFromAddress(), // sender + args[1], // new owner + ) + + err = msg.ValidateBasic() + if err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +// GetCmdMintNFT implements the mint NFT command. +func GetCmdMintNFT() *cobra.Command { + cmd := &cobra.Command{ + Use: "mint [class-id] [uri] [uri-hash] [receiver]", + Short: "Mint a new NFT in a given class", + Args: cobra.ExactArgs(4), + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgMintNFT( + args[0], // class ID + args[1], // uri + args[2], // uri-hash + clientCtx.GetFromAddress(), // sender + args[3], // receiver + nil, + ) + + err = msg.ValidateBasic() + if err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/onft/genesis.go b/x/onft/genesis.go new file mode 100644 index 00000000..da57638d --- /dev/null +++ b/x/onft/genesis.go @@ -0,0 +1,60 @@ +package onft + +import ( + "github.com/ODIN-PROTOCOL/odin-core/x/onft/keeper" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis performs genesis initialization for the oracle module. +func InitGenesis(ctx sdk.Context, k keeper.Keeper, data *types.GenesisState) { + err := k.NFTClassID.Set(ctx, data.NftClassId) + if err != nil { + panic(err) + } + + codec := k.AuthKeeper.AddressCodec() + + for class, owner := range data.ClassOwners { + ownerAddr, err := codec.StringToBytes(owner) + if err != nil { + panic(err) + } + + err = k.ClassOwners.Set(ctx, class, ownerAddr) + if err != nil { + panic(err) + } + } +} + +// ExportGenesis returns a GenesisState for a given context and keeper. +func ExportGenesis(ctx sdk.Context, k keeper.Keeper) (*types.GenesisState, error) { + nftClassID, err := k.NFTClassID.Peek(ctx) + if err != nil { + return nil, err + } + + codec := k.AuthKeeper.AddressCodec() + + classOwners := make(map[string]string) + + err = k.ClassOwners.Walk(ctx, nil, func(class string, owner []byte) (stop bool, err error) { + ownerAddr, err := codec.BytesToString(owner) + if err != nil { + return false, err + } + + classOwners[class] = ownerAddr + + return false, nil + }) + if err != nil { + return nil, err + } + + return &types.GenesisState{ + NftClassId: nftClassID, + ClassOwners: classOwners, + }, nil +} diff --git a/x/onft/keeper/grpc_query.go b/x/onft/keeper/grpc_query.go new file mode 100644 index 00000000..cee49b8b --- /dev/null +++ b/x/onft/keeper/grpc_query.go @@ -0,0 +1,180 @@ +package keeper + +import ( + "context" + + "cosmossdk.io/x/nft" + onfttypes "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var _ onfttypes.QueryServer = Keeper{} + +func (k Keeper) ClassOwner(ctx context.Context, r *onfttypes.QueryClassOwnerRequest) (*onfttypes.QueryClassOwnerResponse, error) { + if r == nil { + return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request") + } + + if len(r.ClassId) == 0 { + return nil, nft.ErrEmptyClassID + } + + owner, err := k.ClassOwners.Get(ctx, r.ClassId) + if err != nil { + return nil, err + } + + ownerStr, err := k.addressCodec.BytesToString(owner) + if err != nil { + return nil, err + } + + return &onfttypes.QueryClassOwnerResponse{Owner: ownerStr}, nil +} + +func (k Keeper) NFTs(ctx context.Context, r *onfttypes.QueryNFTsRequest) (*onfttypes.QueryNFTsResponse, error) { + if r == nil { + return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request") + } + + nfts, err := k.nftKeeper.NFTs(ctx, &nft.QueryNFTsRequest{Pagination: r.Pagination}) + if err != nil { + return nil, err + } + + nftsOwners := make([]*onfttypes.NFT, len(nfts.Nfts)) + for i, n := range nfts.Nfts { + ownerStr := "" + owner := k.nftKeeper.GetOwner(ctx, n.ClassId, n.Id) + if !owner.Empty() { + ownerStr, _ = k.addressCodec.BytesToString(owner) + } + + nftsOwners[i] = &onfttypes.NFT{ + Id: n.Id, + ClassId: n.ClassId, + Uri: n.Uri, + UriHash: n.UriHash, + Data: n.Data, + Owner: ownerStr, + } + } + + return &onfttypes.QueryNFTsResponse{ + Nfts: nftsOwners, + Pagination: nfts.Pagination, + }, nil +} + +func (k Keeper) NFT(ctx context.Context, r *onfttypes.QueryNFTRequest) (*onfttypes.QueryNFTResponse, error) { + if r == nil { + return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request") + } + + if len(r.ClassId) == 0 { + return nil, nft.ErrEmptyClassID + } + if len(r.Id) == 0 { + return nil, nft.ErrEmptyNFTID + } + + n, has := k.nftKeeper.GetNFT(ctx, r.ClassId, r.Id) + if !has { + return nil, nft.ErrNFTNotExists.Wrapf("not found nft: class: %s, id: %s", r.ClassId, r.Id) + } + + owner := k.nftKeeper.GetOwner(ctx, r.ClassId, r.Id) + ownerStr, err := k.addressCodec.BytesToString(owner) + if err != nil { + return nil, err + } + + resp := &onfttypes.QueryNFTResponse{ + Nft: &onfttypes.NFT{ + ClassId: n.ClassId, + Id: n.Id, + Uri: n.Uri, + UriHash: n.UriHash, + Owner: ownerStr, + Data: n.Data, + }, + } + + return resp, nil +} + +func (k Keeper) Class(ctx context.Context, r *onfttypes.QueryClassRequest) (*onfttypes.QueryClassResponse, error) { + if r == nil { + return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request") + } + + if len(r.ClassId) == 0 { + return nil, nft.ErrEmptyClassID + } + + class, has := k.nftKeeper.GetClass(ctx, r.ClassId) + if !has { + return nil, nft.ErrClassNotExists.Wrapf("not found class: %s", r.ClassId) + } + + owner, err := k.ClassOwners.Get(ctx, r.ClassId) + if err != nil { + return nil, err + } + + ownerStr, err := k.addressCodec.BytesToString(owner) + if err != nil { + return nil, err + } + + resp := &onfttypes.QueryClassResponse{ + Class: &onfttypes.Class{ + Id: class.Id, + Name: class.Name, + Symbol: class.Symbol, + Description: class.Description, + Uri: class.Uri, + UriHash: class.UriHash, + Data: class.Data, + Owner: ownerStr, + }, + } + + return resp, nil +} + +func (k Keeper) Classes(ctx context.Context, r *onfttypes.QueryClassesRequest) (*onfttypes.QueryClassesResponse, error) { + if r == nil { + return nil, sdkerrors.ErrInvalidRequest.Wrap("empty request") + } + + classes, err := k.nftKeeper.Classes(ctx, &nft.QueryClassesRequest{Pagination: r.Pagination}) + if err != nil { + return nil, err + } + + classesOwners := make([]*onfttypes.Class, len(classes.Classes)) + for i, class := range classes.Classes { + ownerStr := "" + owner, err := k.ClassOwners.Get(ctx, class.Id) + if err == nil { + ownerStr, _ = k.addressCodec.BytesToString(owner) + } + + classesOwners[i] = &onfttypes.Class{ + Id: class.Id, + Name: class.Name, + Symbol: class.Symbol, + Description: class.Description, + Uri: class.Uri, + UriHash: class.UriHash, + Data: class.Data, + Owner: ownerStr, + } + } + + return &onfttypes.QueryClassesResponse{ + Classes: classesOwners, + Pagination: classes.Pagination, + }, nil +} diff --git a/x/onft/keeper/keeper.go b/x/onft/keeper/keeper.go new file mode 100644 index 00000000..1494d420 --- /dev/null +++ b/x/onft/keeper/keeper.go @@ -0,0 +1,69 @@ +package keeper + +import ( + "cosmossdk.io/collections" + addresscodec "cosmossdk.io/core/address" + storetypes "cosmossdk.io/core/store" + "cosmossdk.io/log" + nftkeeper "cosmossdk.io/x/nft/keeper" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/bank/types" +) + +type Keeper struct { + cdc codec.BinaryCodec + storeService storetypes.KVStoreService + AuthKeeper authtypes.AccountKeeper + nftKeeper nftkeeper.Keeper + addressCodec addresscodec.Codec + + Schema collections.Schema + NFTClassID collections.Sequence + ClassOwners collections.Map[string, []byte] + + // the address capable of executing a MsgUpdateParams message. Typically, this + // should be the x/gov module account. + authority string +} + +func NewKeeper( + cdc codec.BinaryCodec, + storeService storetypes.KVStoreService, + authKeeper authtypes.AccountKeeper, + nftKeeper nftkeeper.Keeper, + authority string, +) Keeper { + sb := collections.NewSchemaBuilder(storeService) + + k := Keeper{ + cdc: cdc, + storeService: storeService, + AuthKeeper: authKeeper, + nftKeeper: nftKeeper, + addressCodec: authKeeper.AddressCodec(), + authority: authority, + + NFTClassID: collections.NewSequence(sb, types.NFTClassIDStoreKeyPrefix, "nft_class_id"), + ClassOwners: collections.NewMap(sb, types.ClassOwnersStoreKeyPrefix, "class_owners", collections.StringKey, collections.BytesValue), + } + + schema, err := sb.Build() + if err != nil { + panic(err) + } + k.Schema = schema + + return k +} + +// GetAuthority returns the x/oracle module's authority. +func (k Keeper) GetAuthority() string { + return k.authority +} + +// Logger returns a module-specific logger. +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", "x/"+types.ModuleName) +} diff --git a/x/onft/keeper/msg_server.go b/x/onft/keeper/msg_server.go new file mode 100644 index 00000000..21435f83 --- /dev/null +++ b/x/onft/keeper/msg_server.go @@ -0,0 +1,160 @@ +package keeper + +import ( + "bytes" + "context" + "fmt" + + "cosmossdk.io/x/nft" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +type msgServer struct { + Keeper +} + +// NewMsgServerImpl returns an implementation of the mint MsgServer interface +// for the provided Keeper. +func NewMsgServerImpl(keeper Keeper) types.MsgServer { + return &msgServer{ + Keeper: keeper, + } +} + +var _ types.MsgServer = msgServer{} + +func (m msgServer) CreateNFTClass(ctx context.Context, msg *types.MsgCreateNFTClass) (*types.MsgCreateNFTClassResponse, error) { + classID, err := m.NFTClassID.Next(ctx) + if err != nil { + return nil, err + } + + sender, err := m.addressCodec.StringToBytes(msg.Sender) + if err != nil { + return nil, err + } + + id := fmt.Sprintf("%s%d", types.NFTClassPrefix, classID) + + // TODO: add checks + err = m.nftKeeper.SaveClass(ctx, nft.Class{ + Id: id, + Name: msg.Name, + Symbol: msg.Symbol, + Description: msg.Description, + Uri: msg.Uri, + UriHash: msg.UriHash, + Data: msg.Data, + }) + if err != nil { + return nil, err + } + + err = m.ClassOwners.Set(ctx, id, sender) + + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeCreateNFTClass, + sdk.NewAttribute(types.AttributeKeyClassID, id), + sdk.NewAttribute(types.AttributeKeyUri, msg.Uri), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + ) + + return &types.MsgCreateNFTClassResponse{Id: id}, nil +} + +func (m msgServer) TransferClassOwnership(ctx context.Context, msg *types.MsgTransferClassOwnership) (*types.MsgTransferClassOwnershipResponse, error) { + if !m.nftKeeper.HasClass(ctx, msg.ClassId) { + return nil, types.ErrClassNotFound + } + + owner, err := m.ClassOwners.Get(ctx, msg.ClassId) + if err != nil { + return nil, err + } + + sender, err := m.addressCodec.StringToBytes(msg.Sender) + if err != nil { + return nil, err + } + + if !bytes.Equal(sender, owner) { + return nil, types.ErrSenderNotAuthorized + } + + newOwner, err := m.addressCodec.StringToBytes(msg.NewOwner) + if err != nil { + return nil, err + } + + err = m.ClassOwners.Set(ctx, msg.ClassId, newOwner) + if err != nil { + return nil, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeTransferClassOwnership, + sdk.NewAttribute(types.AttributeKeyClassID, msg.ClassId), + sdk.NewAttribute(types.AttributeKeyReceiver, msg.NewOwner), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + ) + + return &types.MsgTransferClassOwnershipResponse{}, nil +} + +func (m msgServer) MintNFT(ctx context.Context, msg *types.MsgMintNFT) (*types.MsgMintNFTResponse, error) { + if !m.nftKeeper.HasClass(ctx, msg.ClassId) { + return nil, types.ErrClassNotFound + } + + owner, err := m.ClassOwners.Get(ctx, msg.ClassId) + if err != nil { + return nil, err + } + + sender, err := m.addressCodec.StringToBytes(msg.Sender) + if err != nil { + return nil, err + } + + if !bytes.Equal(sender, owner) { + return nil, types.ErrSenderNotAuthorized + } + + receiver, err := m.addressCodec.StringToBytes(msg.Receiver) + if err != nil { + return nil, err + } + + nftID := fmt.Sprintf("%d", m.nftKeeper.GetTotalSupply(ctx, msg.ClassId)) + + err = m.nftKeeper.Mint(ctx, nft.NFT{ + ClassId: msg.ClassId, + Id: nftID, + Uri: msg.Uri, + UriHash: msg.UriHash, + Data: msg.Data, + }, receiver) + if err != nil { + return nil, err + } + + sdkCtx := sdk.UnwrapSDKContext(ctx) + sdkCtx.EventManager().EmitEvent( + sdk.NewEvent( + types.EventTypeMintNFT, + sdk.NewAttribute(types.AttributeKeyNFTID, nftID), + sdk.NewAttribute(types.AttributeKeyClassID, msg.ClassId), + sdk.NewAttribute(types.AttributeKeyUri, msg.Uri), + sdk.NewAttribute(sdk.AttributeKeySender, msg.Sender), + ), + ) + + return &types.MsgMintNFTResponse{Id: nftID}, nil +} diff --git a/x/onft/keeper/wasm_hander_plugin.go b/x/onft/keeper/wasm_hander_plugin.go new file mode 100644 index 00000000..167dd8e5 --- /dev/null +++ b/x/onft/keeper/wasm_hander_plugin.go @@ -0,0 +1,81 @@ +package keeper + +import ( + "bytes" + "encoding/json" + "fmt" + + "cosmossdk.io/x/nft" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + wasmkeeper "github.com/ODIN-PROTOCOL/wasmd/x/wasm/keeper" + wasmtypes "github.com/ODIN-PROTOCOL/wasmd/x/wasm/types" + wasmvmtypes "github.com/ODIN-PROTOCOL/wasmvm/v2/types" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +var _ wasmkeeper.Messenger = MessageHandlerFunc(nil) + +// MessageHandlerFunc is a helper to construct a function based message handler. +type MessageHandlerFunc func(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, msgResponses [][]*codectypes.Any, err error) + +// DispatchMsg delegates dispatching of provided message into the MessageHandlerFunc. +func (m MessageHandlerFunc) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddress, contractIBCPortID string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, msgResponses [][]*codectypes.Any, err error) { + return m(ctx, contractAddr, contractIBCPortID, msg) +} + +func NewMintNFTMessageHandler(onftKeeper Keeper) MessageHandlerFunc { + return func(ctx sdk.Context, contractAddr sdk.AccAddress, _ string, msg wasmvmtypes.CosmosMsg) (events []sdk.Event, data [][]byte, msgResponses [][]*codectypes.Any, err error) { + if len(msg.Any.Value) > 0 && msg.Any.TypeURL == "onft/mint" { + var msgNFT types.MsgMintNFT + err := json.Unmarshal(msg.Any.Value, &msgNFT) + if err != nil { + return nil, nil, nil, err + } + + if !onftKeeper.nftKeeper.HasClass(ctx, msgNFT.ClassId) { + return nil, nil, nil, types.ErrClassNotFound + } + + owner, err := onftKeeper.ClassOwners.Get(ctx, msgNFT.ClassId) + if err != nil { + return nil, nil, nil, err + } + + if !bytes.Equal(contractAddr, owner) { + return nil, nil, nil, types.ErrSenderNotAuthorized + } + + nftID := fmt.Sprintf("%d", onftKeeper.nftKeeper.GetTotalSupply(ctx, msgNFT.ClassId)) + + receiver, err := sdk.AccAddressFromBech32(msgNFT.Receiver) + if err != nil { + return nil, nil, nil, err + } + + err = onftKeeper.nftKeeper.Mint(ctx, nft.NFT{ + ClassId: msgNFT.ClassId, + Id: nftID, + Uri: msgNFT.Uri, + UriHash: msgNFT.UriHash, + Data: nil, + }, receiver) + if err != nil { + return nil, nil, nil, err + } + + ctx.Logger(). + With("module", fmt.Sprintf("x/%s", wasmtypes.ModuleName)). + Info("Minted NFT", "id", nftID) + + resp, err := codectypes.NewAnyWithValue(&types.MsgMintNFTResponse{Id: nftID}) + if err != nil { + return nil, nil, nil, err + } + + return events, nil, [][]*codectypes.Any{{resp}}, nil + } + + return nil, nil, nil, wasmtypes.ErrUnknownMsg + } +} diff --git a/x/onft/module.go b/x/onft/module.go new file mode 100644 index 00000000..b81e9021 --- /dev/null +++ b/x/onft/module.go @@ -0,0 +1,137 @@ +package onft + +import ( + "context" + "encoding/json" + "fmt" + + "cosmossdk.io/core/appmodule" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/client/cli" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/keeper" + "github.com/ODIN-PROTOCOL/odin-core/x/onft/types" + abci "github.com/cometbft/cometbft/abci/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/codec" + cdctypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/module" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" +) + +var ( + _ module.AppModuleBasic = AppModuleBasic{} + _ module.HasServices = AppModule{} + _ module.HasInvariants = AppModule{} + _ module.HasABCIGenesis = AppModule{} + + _ appmodule.AppModule = AppModule{} + _ appmodule.HasBeginBlocker = AppModule{} + _ appmodule.HasEndBlocker = AppModule{} +) + +const ConsensusVersion = 1 + +type AppModuleBasic struct { + cdc codec.Codec +} + +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterLegacyAminoCodec(cdc) +} + +func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(registry) +} + +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *runtime.ServeMux) { + err := types.RegisterQueryHandlerClient(context.Background(), mux, types.NewQueryClient(clientCtx)) + if err != nil { + panic(err) + } +} + +// GetTxCmd returns cobra CLI command to send txs for this module (SDK AppModuleBasic interface). +func (AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.NewTxCmd() +} + +// DefaultGenesis returns the default genesis state as raw bytes. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesisState()) +} + +// ValidateGenesis checks the Genesis +func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error { + var gs types.GenesisState + if err := cdc.UnmarshalJSON(bz, &gs); err != nil { + return fmt.Errorf("failed to unmarshal %s genesis state: %w", types.ModuleName, err) + } + + return gs.Validate() +} + +// AppModule represents the AppModule for this module. +type AppModule struct { + AppModuleBasic + keeper keeper.Keeper +} + +// NewAppModule creates a new AppModule object. +func NewAppModule(k keeper.Keeper) AppModule { + return AppModule{ + keeper: k, + } +} + +// RegisterInvariants is a noop function to satisfy SDK AppModule interface. +func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) { + // TODO +} + +// RegisterServices registers module services. +func (am AppModule) RegisterServices(cfg module.Configurator) { + types.RegisterMsgServer(cfg.MsgServer(), keeper.NewMsgServerImpl(am.keeper)) + + types.RegisterQueryServer(cfg.QueryServer(), types.QueryServer(am.keeper)) +} + +// InitGenesis performs genesis initialization for the oracle module. +func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate { + var genesisState types.GenesisState + cdc.MustUnmarshalJSON(data, &genesisState) + InitGenesis(ctx, am.keeper, &genesisState) + return []abci.ValidatorUpdate{} +} + +// ExportGenesis returns the current state as genesis raw bytes. +func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage { + gs, err := ExportGenesis(ctx, am.keeper) + if err != nil { + panic(err) + } + return cdc.MustMarshalJSON(gs) +} + +// ConsensusVersion implements AppModule/ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return ConsensusVersion } + +// IsOnePerModuleType implements the depinject.OnePerModuleType interface. +func (am AppModule) IsOnePerModuleType() {} + +// IsAppModule implements the appmodule.AppModule interface. +func (am AppModule) IsAppModule() {} + +// BeginBlock processes ABCI begin block message for this oracle module (SDK AppModule interface). +func (am AppModule) BeginBlock(_ context.Context) error { + return nil +} + +// EndBlock processes ABCI end block message for this oracle module (SDK AppModule interface). +func (am AppModule) EndBlock(_ context.Context) error { + return nil +} diff --git a/x/onft/types/codec.go b/x/onft/types/codec.go new file mode 100644 index 00000000..f8238dac --- /dev/null +++ b/x/onft/types/codec.go @@ -0,0 +1,48 @@ +package types + +import ( + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/msgservice" +) + +// RegisterLegacyAminoCodec registers the necessary x/oracle interfaces and concrete types +// on the provided LegacyAmino codec. These types are used for Amino JSON serialization. +func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreateNFTClass{}, "onft/CreateNFTClass", nil) + cdc.RegisterConcrete(&MsgTransferClassOwnership{}, "onft/TransferClassOwnership", nil) + cdc.RegisterConcrete(&MsgMintNFT{}, "onft/MintNft", nil) +} + +// RegisterInterfaces register the oracle module interfaces to protobuf Any. +func RegisterInterfaces(registry codectypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateNFTClass{}, + &MsgTransferClassOwnership{}, + &MsgMintNFT{}, + ) + + msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) +} + +var ( + amino = codec.NewLegacyAmino() + + // ModuleCdc references the global x/oracle module codec. Note, the codec + // should ONLY be used in certain instances of tests and for JSON encoding. + // + // The actual codec used for serialization should be provided to x/oracle and + // defined at the application level. + ModuleCdc = codec.NewProtoCodec(codectypes.NewInterfaceRegistry()) + + // AminoCdc is a amino codec created to support amino json compatible msgs. + AminoCdc = codec.NewAminoCodec(amino) +) + +func init() { + RegisterLegacyAminoCodec(amino) + cryptocodec.RegisterCrypto(amino) + amino.Seal() +} diff --git a/x/onft/types/errors.go b/x/onft/types/errors.go new file mode 100644 index 00000000..e9cce38f --- /dev/null +++ b/x/onft/types/errors.go @@ -0,0 +1,10 @@ +package types + +import sdkerrors "cosmossdk.io/errors" + +var ( + ErrClassNotFound = sdkerrors.New(ModuleName, 1, "class not found") + ErrSenderNotAuthorized = sdkerrors.Register(ModuleName, 2, "sender not authorized") + ErrEmptyClassID = sdkerrors.Register(ModuleName, 3, "empty class id") + ErrEmptyNFTID = sdkerrors.Register(ModuleName, 4, "empty nft id") +) diff --git a/x/onft/types/events.go b/x/onft/types/events.go new file mode 100644 index 00000000..90256947 --- /dev/null +++ b/x/onft/types/events.go @@ -0,0 +1,12 @@ +package types + +const ( + EventTypeMintNFT = "mint_nft" + EventTypeCreateNFTClass = "create_nft_class" + EventTypeTransferClassOwnership = "transfer_class_ownership" + + AttributeKeyNFTID = "nft_id" + AttributeKeyClassID = "class_id" + AttributeKeyUri = "uri" + AttributeKeyReceiver = "receiver" +) diff --git a/x/onft/types/genesis.go b/x/onft/types/genesis.go new file mode 100644 index 00000000..22554bec --- /dev/null +++ b/x/onft/types/genesis.go @@ -0,0 +1,19 @@ +package types + +func NewGenesisState(nftClassID uint64, classOwners map[string]string) *GenesisState { + return &GenesisState{ + NftClassId: nftClassID, + ClassOwners: classOwners, + } +} + +func DefaultGenesisState() *GenesisState { + return &GenesisState{ + NftClassId: uint64(0), + ClassOwners: make(map[string]string), + } +} + +// Validate performs basic genesis state validation returning an error upon any +// failure. +func (g *GenesisState) Validate() error { return nil } diff --git a/x/onft/types/genesis.pb.go b/x/onft/types/genesis.pb.go new file mode 100644 index 00000000..37752d9c --- /dev/null +++ b/x/onft/types/genesis.pb.go @@ -0,0 +1,474 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onft/v1/genesis.proto + +package types + +import ( + fmt "fmt" + _ "github.com/cosmos/gogoproto/gogoproto" + proto "github.com/cosmos/gogoproto/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 onft module's genesis state. +type GenesisState struct { + // NFTClassID defines number of NFTs minted by module + NftClassId uint64 `protobuf:"varint,1,opt,name=nft_class_id,json=nftClassId,proto3" json:"nft_class_id,omitempty" yaml:"nft_class_id"` + // ClassOwners are owners of NFT classes + ClassOwners map[string]string `protobuf:"bytes,2,rep,name=class_owners,json=classOwners,proto3" json:"class_owners,omitempty" yaml:"class_owners" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +} + +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_3ca6272c050e00ff, []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) GetNftClassId() uint64 { + if m != nil { + return m.NftClassId + } + return 0 +} + +func (m *GenesisState) GetClassOwners() map[string]string { + if m != nil { + return m.ClassOwners + } + return nil +} + +func init() { + proto.RegisterType((*GenesisState)(nil), "onft.v1.GenesisState") + proto.RegisterMapType((map[string]string)(nil), "onft.v1.GenesisState.ClassOwnersEntry") +} + +func init() { proto.RegisterFile("onft/v1/genesis.proto", fileDescriptor_3ca6272c050e00ff) } + +var fileDescriptor_3ca6272c050e00ff = []byte{ + // 291 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xcd, 0xcf, 0x4b, 0x2b, + 0xd1, 0x2f, 0x33, 0xd4, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0x62, 0x07, 0x09, 0xeb, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xc5, + 0xf4, 0x41, 0x2c, 0x88, 0xb4, 0xd2, 0x5b, 0x46, 0x2e, 0x1e, 0x77, 0x88, 0x86, 0xe0, 0x92, 0xc4, + 0x92, 0x54, 0x21, 0x4b, 0x2e, 0x9e, 0xbc, 0xb4, 0x92, 0xf8, 0xe4, 0x9c, 0xc4, 0xe2, 0xe2, 0xf8, + 0xcc, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x16, 0x27, 0xf1, 0x4f, 0xf7, 0xe4, 0x85, 0x2b, 0x13, + 0x73, 0x73, 0xac, 0x94, 0x90, 0x65, 0x95, 0x82, 0xb8, 0xf2, 0xd2, 0x4a, 0x9c, 0x41, 0x3c, 0xcf, + 0x14, 0xa1, 0x24, 0x2e, 0x1e, 0x88, 0x44, 0x7e, 0x79, 0x5e, 0x6a, 0x51, 0xb1, 0x04, 0x93, 0x02, + 0xb3, 0x06, 0xb7, 0x91, 0x9a, 0x1e, 0xd4, 0x05, 0x7a, 0xc8, 0xf6, 0xe8, 0x81, 0x35, 0xf9, 0x83, + 0x15, 0xba, 0xe6, 0x95, 0x14, 0x55, 0x22, 0x5b, 0x81, 0x6c, 0x8a, 0x52, 0x10, 0x77, 0x32, 0x42, + 0xa9, 0x94, 0x1d, 0x97, 0x00, 0xba, 0x4e, 0x21, 0x01, 0x2e, 0xe6, 0xec, 0xd4, 0x4a, 0xb0, 0x4b, + 0x39, 0x83, 0x40, 0x4c, 0x21, 0x11, 0x2e, 0xd6, 0xb2, 0xc4, 0x9c, 0xd2, 0x54, 0x09, 0x26, 0xb0, + 0x18, 0x84, 0x63, 0xc5, 0x64, 0xc1, 0xe8, 0xe4, 0x79, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, + 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, + 0x72, 0x0c, 0x51, 0xfa, 0xe9, 0x99, 0x25, 0x19, 0xa5, 0x49, 0x7a, 0xc9, 0xf9, 0xb9, 0xfa, 0xfe, + 0x2e, 0x9e, 0x7e, 0xba, 0x01, 0x41, 0xfe, 0x21, 0xfe, 0xce, 0xfe, 0x3e, 0xfa, 0xf9, 0x29, 0x99, + 0x79, 0xba, 0xc9, 0xf9, 0x45, 0xa9, 0xfa, 0x15, 0xfa, 0xe0, 0x40, 0x2e, 0xa9, 0x2c, 0x48, 0x2d, + 0x4e, 0x62, 0x03, 0x87, 0xa0, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0x99, 0x02, 0x84, 0x07, 0x79, + 0x01, 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 + if len(m.ClassOwners) > 0 { + for k := range m.ClassOwners { + v := m.ClassOwners[k] + baseI := i + i -= len(v) + copy(dAtA[i:], v) + i = encodeVarintGenesis(dAtA, i, uint64(len(v))) + i-- + dAtA[i] = 0x12 + i -= len(k) + copy(dAtA[i:], k) + i = encodeVarintGenesis(dAtA, i, uint64(len(k))) + i-- + dAtA[i] = 0xa + i = encodeVarintGenesis(dAtA, i, uint64(baseI-i)) + i-- + dAtA[i] = 0x12 + } + } + if m.NftClassId != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.NftClassId)) + i-- + dAtA[i] = 0x8 + } + 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 m.NftClassId != 0 { + n += 1 + sovGenesis(uint64(m.NftClassId)) + } + if len(m.ClassOwners) > 0 { + for k, v := range m.ClassOwners { + _ = k + _ = v + mapEntrySize := 1 + len(k) + sovGenesis(uint64(len(k))) + 1 + len(v) + sovGenesis(uint64(len(v))) + n += mapEntrySize + 1 + sovGenesis(uint64(mapEntrySize)) + } + } + 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 != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NftClassId", wireType) + } + m.NftClassId = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.NftClassId |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassOwners", 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 m.ClassOwners == nil { + m.ClassOwners = make(map[string]string) + } + var mapkey string + var mapvalue string + for iNdEx < postIndex { + entryPreIndex := 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) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthGenesis + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthGenesis + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var stringLenmapvalue uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapvalue |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapvalue := int(stringLenmapvalue) + if intStringLenmapvalue < 0 { + return ErrInvalidLengthGenesis + } + postStringIndexmapvalue := iNdEx + intStringLenmapvalue + if postStringIndexmapvalue < 0 { + return ErrInvalidLengthGenesis + } + if postStringIndexmapvalue > l { + return io.ErrUnexpectedEOF + } + mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) + iNdEx = postStringIndexmapvalue + } else { + iNdEx = entryPreIndex + skippy, err := skipGenesis(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGenesis + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.ClassOwners[mapkey] = mapvalue + 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/onft/types/keys.go b/x/onft/types/keys.go new file mode 100644 index 00000000..44deaf84 --- /dev/null +++ b/x/onft/types/keys.go @@ -0,0 +1,14 @@ +package types + +const ( + ModuleName = "onft" + + StoreKey = ModuleName + + NFTClassPrefix = "onft-" +) + +var ( + NFTClassIDStoreKeyPrefix = []byte{0x01} + ClassOwnersStoreKeyPrefix = []byte{0x02} +) diff --git a/x/onft/types/msgs.go b/x/onft/types/msgs.go new file mode 100644 index 00000000..ba13baa6 --- /dev/null +++ b/x/onft/types/msgs.go @@ -0,0 +1,120 @@ +package types + +import ( + "cosmossdk.io/errors" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +var ( + _ sdk.Msg = &MsgCreateNFTClass{} + _ sdk.Msg = &MsgTransferClassOwnership{} + _ sdk.Msg = &MsgMintNFT{} + + _ sdk.HasValidateBasic = &MsgCreateNFTClass{} + _ sdk.HasValidateBasic = &MsgTransferClassOwnership{} + _ sdk.HasValidateBasic = &MsgMintNFT{} +) + +func NewMsgCreateNFTClass( + name string, + symbol string, + description string, + uri string, + uriHash string, + data *codectypes.Any, + sender sdk.AccAddress, +) *MsgCreateNFTClass { + return &MsgCreateNFTClass{ + Name: name, + Symbol: symbol, + Description: description, + Uri: uri, + UriHash: uriHash, + Data: data, + Sender: sender.String(), + } +} + +func (msg *MsgCreateNFTClass) ValidateBasic() error { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "sender: %s", msg.Sender) + } + + return nil +} + +func NewMsgTransferClassOwnership( + classID string, + sender sdk.AccAddress, + newOwner string, +) *MsgTransferClassOwnership { + return &MsgTransferClassOwnership{ + ClassId: classID, + Sender: sender.String(), + NewOwner: newOwner, + } +} + +func (msg *MsgTransferClassOwnership) ValidateBasic() error { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "sender: %s", msg.Sender) + } + + newOwner, err := sdk.AccAddressFromBech32(msg.NewOwner) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(newOwner); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "new_owner: %s", msg.Sender) + } + + return nil +} + +func NewMsgMintNFT( + classID string, + uri string, + uriHash string, + sender sdk.AccAddress, + receiver string, + data *codectypes.Any, +) *MsgMintNFT { + return &MsgMintNFT{ + ClassId: classID, + Uri: uri, + UriHash: uriHash, + Sender: sender.String(), + Receiver: receiver, + Data: data, + } +} + +func (msg *MsgMintNFT) ValidateBasic() error { + sender, err := sdk.AccAddressFromBech32(msg.Sender) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(sender); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "sender: %s", msg.Sender) + } + + receiver, err := sdk.AccAddressFromBech32(msg.Receiver) + if err != nil { + return err + } + if err := sdk.VerifyAddressFormat(receiver); err != nil { + return errors.Wrapf(sdkerrors.ErrInvalidAddress, "new_owner: %s", msg.Sender) + } + + return nil +} diff --git a/x/onft/types/onft.pb.go b/x/onft/types/onft.pb.go new file mode 100644 index 00000000..a15d0113 --- /dev/null +++ b/x/onft/types/onft.pb.go @@ -0,0 +1,1143 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onft/v1/onft.proto + +package types + +import ( + fmt "fmt" + types "github.com/cosmos/cosmos-sdk/codec/types" + proto "github.com/cosmos/gogoproto/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 + +// Class defines the class of the nft type. +type Class struct { + // id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + // name defines the human-readable name of the NFT classification. Optional + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + // symbol is an abbreviated name for nft classification. Optional + Symbol string `protobuf:"bytes,3,opt,name=symbol,proto3" json:"symbol,omitempty"` + // description is a brief description of nft classification. Optional + Description string `protobuf:"bytes,4,opt,name=description,proto3" json:"description,omitempty"` + // uri for the class metadata stored off chain. It can define schema for Class and NFT `Data` attributes. Optional + Uri string `protobuf:"bytes,5,opt,name=uri,proto3" json:"uri,omitempty"` + // uri_hash is a hash of the document pointed by uri. Optional + UriHash string `protobuf:"bytes,6,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"` + // data is the app specific metadata of the NFT class. Optional + Data *types.Any `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"` + // owner is the owner address of the following nft class + Owner string `protobuf:"bytes,8,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *Class) Reset() { *m = Class{} } +func (m *Class) String() string { return proto.CompactTextString(m) } +func (*Class) ProtoMessage() {} +func (*Class) Descriptor() ([]byte, []int) { + return fileDescriptor_d219138c4316c810, []int{0} +} +func (m *Class) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Class) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Class.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 *Class) XXX_Merge(src proto.Message) { + xxx_messageInfo_Class.Merge(m, src) +} +func (m *Class) XXX_Size() int { + return m.Size() +} +func (m *Class) XXX_DiscardUnknown() { + xxx_messageInfo_Class.DiscardUnknown(m) +} + +var xxx_messageInfo_Class proto.InternalMessageInfo + +func (m *Class) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *Class) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Class) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *Class) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Class) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +func (m *Class) GetUriHash() string { + if m != nil { + return m.UriHash + } + return "" +} + +func (m *Class) GetData() *types.Any { + if m != nil { + return m.Data + } + return nil +} + +func (m *Class) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// NFT defines the NFT. +type NFT struct { + // class_id associated with the NFT, similar to the contract address of ERC721 + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` + // id is a unique identifier of the NFT + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` + // uri for the NFT metadata stored off chain + Uri string `protobuf:"bytes,3,opt,name=uri,proto3" json:"uri,omitempty"` + // uri_hash is a hash of the document pointed by uri + UriHash string `protobuf:"bytes,4,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"` + // owner is the owner address of the following nft + Owner string `protobuf:"bytes,5,opt,name=owner,proto3" json:"owner,omitempty"` + // data is an app specific data of the NFT. Optional + Data *types.Any `protobuf:"bytes,10,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *NFT) Reset() { *m = NFT{} } +func (m *NFT) String() string { return proto.CompactTextString(m) } +func (*NFT) ProtoMessage() {} +func (*NFT) Descriptor() ([]byte, []int) { + return fileDescriptor_d219138c4316c810, []int{1} +} +func (m *NFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *NFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_NFT.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 *NFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_NFT.Merge(m, src) +} +func (m *NFT) XXX_Size() int { + return m.Size() +} +func (m *NFT) XXX_DiscardUnknown() { + xxx_messageInfo_NFT.DiscardUnknown(m) +} + +var xxx_messageInfo_NFT proto.InternalMessageInfo + +func (m *NFT) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +func (m *NFT) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func (m *NFT) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +func (m *NFT) GetUriHash() string { + if m != nil { + return m.UriHash + } + return "" +} + +func (m *NFT) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *NFT) GetData() *types.Any { + if m != nil { + return m.Data + } + return nil +} + +func init() { + proto.RegisterType((*Class)(nil), "onft.v1.Class") + proto.RegisterType((*NFT)(nil), "onft.v1.NFT") +} + +func init() { proto.RegisterFile("onft/v1/onft.proto", fileDescriptor_d219138c4316c810) } + +var fileDescriptor_d219138c4316c810 = []byte{ + // 343 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xcd, 0x4a, 0x03, 0x31, + 0x14, 0x85, 0x9b, 0xf9, 0xe9, 0xd4, 0x14, 0x44, 0x42, 0x91, 0xd4, 0xc5, 0x50, 0xba, 0xea, 0xa6, + 0x13, 0xaa, 0x4f, 0xa0, 0x15, 0xb1, 0x20, 0x1d, 0x29, 0x5d, 0xb9, 0x29, 0x99, 0x9f, 0x76, 0x02, + 0x6d, 0x52, 0x92, 0x99, 0xea, 0xbc, 0x85, 0x2f, 0xe0, 0xfb, 0xb8, 0x2c, 0xae, 0x5c, 0x4a, 0xfb, + 0x22, 0x32, 0xe9, 0x38, 0x54, 0x10, 0x5c, 0xe5, 0xde, 0x73, 0x2f, 0xf7, 0x7c, 0x87, 0x40, 0x24, + 0xf8, 0x3c, 0x25, 0x9b, 0x01, 0x29, 0x5e, 0x6f, 0x2d, 0x45, 0x2a, 0x90, 0xa3, 0xeb, 0xcd, 0xe0, + 0xa2, 0xbd, 0x10, 0x62, 0xb1, 0x8c, 0x89, 0x96, 0x83, 0x6c, 0x4e, 0x28, 0xcf, 0x0f, 0x3b, 0xdd, + 0x0f, 0x00, 0xed, 0xe1, 0x92, 0x2a, 0x85, 0x4e, 0xa1, 0xc1, 0x22, 0x0c, 0x3a, 0xa0, 0x77, 0x32, + 0x31, 0x58, 0x84, 0x10, 0xb4, 0x38, 0x5d, 0xc5, 0xd8, 0xd0, 0x8a, 0xae, 0xd1, 0x39, 0xac, 0xab, + 0x7c, 0x15, 0x88, 0x25, 0x36, 0xb5, 0x5a, 0x76, 0xa8, 0x03, 0x9b, 0x51, 0xac, 0x42, 0xc9, 0xd6, + 0x29, 0x13, 0x1c, 0x5b, 0x7a, 0x78, 0x2c, 0xa1, 0x33, 0x68, 0x66, 0x92, 0x61, 0x5b, 0x4f, 0x8a, + 0x12, 0xb5, 0x61, 0x23, 0x93, 0x6c, 0x96, 0x50, 0x95, 0xe0, 0xba, 0x96, 0x9d, 0x4c, 0xb2, 0x7b, + 0xaa, 0x12, 0xd4, 0x83, 0x56, 0x44, 0x53, 0x8a, 0x9d, 0x0e, 0xe8, 0x35, 0x2f, 0x5b, 0xde, 0x01, + 0xdf, 0xfb, 0xc1, 0xf7, 0xae, 0x79, 0x3e, 0xd1, 0x1b, 0xa8, 0x05, 0x6d, 0xf1, 0xcc, 0x63, 0x89, + 0x1b, 0xfa, 0xc2, 0xa1, 0xe9, 0xbe, 0x01, 0x68, 0x8e, 0xef, 0xa6, 0x85, 0x45, 0x58, 0x64, 0x9b, + 0x55, 0xc1, 0x1c, 0xdd, 0x8f, 0xa2, 0x32, 0xad, 0x51, 0xa5, 0x2d, 0xf9, 0xcc, 0xbf, 0xf9, 0xac, + 0xdf, 0x7c, 0x95, 0xab, 0x7d, 0xe4, 0x5a, 0x51, 0xc3, 0xff, 0xa8, 0x6f, 0x46, 0xef, 0x3b, 0x17, + 0x6c, 0x77, 0x2e, 0xf8, 0xda, 0xb9, 0xe0, 0x75, 0xef, 0xd6, 0xb6, 0x7b, 0xb7, 0xf6, 0xb9, 0x77, + 0x6b, 0x4f, 0x64, 0xc1, 0xd2, 0x24, 0x0b, 0xbc, 0x50, 0xac, 0x88, 0x7f, 0x3b, 0x1a, 0xf7, 0x1f, + 0x27, 0xfe, 0xd4, 0x1f, 0xfa, 0x0f, 0x44, 0x44, 0x8c, 0xf7, 0x43, 0x21, 0x63, 0xf2, 0xa2, 0xff, + 0x98, 0xa4, 0xf9, 0x3a, 0x56, 0x41, 0x5d, 0x9f, 0xbf, 0xfa, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x06, + 0x74, 0xee, 0xc6, 0x00, 0x02, 0x00, 0x00, +} + +func (m *Class) 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 *Class) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Class) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x42 + } + if m.Data != nil { + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOnft(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + if len(m.UriHash) > 0 { + i -= len(m.UriHash) + copy(dAtA[i:], m.UriHash) + i = encodeVarintOnft(dAtA, i, uint64(len(m.UriHash))) + i-- + dAtA[i] = 0x32 + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x2a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x22 + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x1a + } + if len(m.Name) > 0 { + i -= len(m.Name) + copy(dAtA[i:], m.Name) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Name))) + i-- + dAtA[i] = 0x12 + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *NFT) 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 *NFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *NFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Data != nil { + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintOnft(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x2a + } + if len(m.UriHash) > 0 { + i -= len(m.UriHash) + copy(dAtA[i:], m.UriHash) + i = encodeVarintOnft(dAtA, i, uint64(len(m.UriHash))) + i-- + dAtA[i] = 0x22 + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x1a + } + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintOnft(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintOnft(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintOnft(dAtA []byte, offset int, v uint64) int { + offset -= sovOnft(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *Class) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Name) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.UriHash) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + if m.Data != nil { + l = m.Data.Size() + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + return n +} + +func (m *NFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.UriHash) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovOnft(uint64(l)) + } + if m.Data != nil { + l = m.Data.Size() + n += 1 + l + sovOnft(uint64(l)) + } + return n +} + +func sovOnft(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozOnft(x uint64) (n int) { + return sovOnft(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *Class) 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 ErrIntOverflowOnft + } + 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: Class: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Class: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Name = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UriHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UriHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOnft + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = &types.Any{} + } + if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOnft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOnft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *NFT) 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 ErrIntOverflowOnft + } + 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: NFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: NFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ClassId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UriHash", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UriHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + 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 ErrInvalidLengthOnft + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowOnft + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthOnft + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthOnft + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = &types.Any{} + } + if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipOnft(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthOnft + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipOnft(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, ErrIntOverflowOnft + } + 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, ErrIntOverflowOnft + } + 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, ErrIntOverflowOnft + } + 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, ErrInvalidLengthOnft + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupOnft + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthOnft + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthOnft = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowOnft = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupOnft = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/onft/types/query.pb.go b/x/onft/types/query.pb.go new file mode 100644 index 00000000..dfc0f758 --- /dev/null +++ b/x/onft/types/query.pb.go @@ -0,0 +1,2472 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onft/v1/query.proto + +package types + +import ( + context "context" + fmt "fmt" + query "github.com/cosmos/cosmos-sdk/types/query" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/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 + +// QueryClassOwnerRequest is the request type for the Query/Owner RPC method +type QueryClassOwnerRequest struct { + // class_id associated with nft collection + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` +} + +func (m *QueryClassOwnerRequest) Reset() { *m = QueryClassOwnerRequest{} } +func (m *QueryClassOwnerRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClassOwnerRequest) ProtoMessage() {} +func (*QueryClassOwnerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{0} +} +func (m *QueryClassOwnerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassOwnerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassOwnerRequest.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 *QueryClassOwnerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassOwnerRequest.Merge(m, src) +} +func (m *QueryClassOwnerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClassOwnerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassOwnerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassOwnerRequest proto.InternalMessageInfo + +func (m *QueryClassOwnerRequest) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +// QueryClassOwnerResponse is the response type for the Query/Owner RPC method +type QueryClassOwnerResponse struct { + // owner is the owner address of the nft class + Owner string `protobuf:"bytes,1,opt,name=owner,proto3" json:"owner,omitempty"` +} + +func (m *QueryClassOwnerResponse) Reset() { *m = QueryClassOwnerResponse{} } +func (m *QueryClassOwnerResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClassOwnerResponse) ProtoMessage() {} +func (*QueryClassOwnerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{1} +} +func (m *QueryClassOwnerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassOwnerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassOwnerResponse.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 *QueryClassOwnerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassOwnerResponse.Merge(m, src) +} +func (m *QueryClassOwnerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClassOwnerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassOwnerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassOwnerResponse proto.InternalMessageInfo + +func (m *QueryClassOwnerResponse) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +// QueryNFTstRequest is the request type for the Query/NFTs RPC method +type QueryNFTsRequest struct { + // class_id associated with the nft + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` + // owner is the owner address of the nft + Owner string `protobuf:"bytes,2,opt,name=owner,proto3" json:"owner,omitempty"` + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryNFTsRequest) Reset() { *m = QueryNFTsRequest{} } +func (m *QueryNFTsRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNFTsRequest) ProtoMessage() {} +func (*QueryNFTsRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{2} +} +func (m *QueryNFTsRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNFTsRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNFTsRequest.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 *QueryNFTsRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTsRequest.Merge(m, src) +} +func (m *QueryNFTsRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNFTsRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTsRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNFTsRequest proto.InternalMessageInfo + +func (m *QueryNFTsRequest) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +func (m *QueryNFTsRequest) GetOwner() string { + if m != nil { + return m.Owner + } + return "" +} + +func (m *QueryNFTsRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryNFTsResponse is the response type for the Query/NFTs RPC methods +type QueryNFTsResponse struct { + // NFT defines the NFT + Nfts []*NFT `protobuf:"bytes,1,rep,name=nfts,proto3" json:"nfts,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryNFTsResponse) Reset() { *m = QueryNFTsResponse{} } +func (m *QueryNFTsResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNFTsResponse) ProtoMessage() {} +func (*QueryNFTsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{3} +} +func (m *QueryNFTsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNFTsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNFTsResponse.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 *QueryNFTsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTsResponse.Merge(m, src) +} +func (m *QueryNFTsResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNFTsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNFTsResponse proto.InternalMessageInfo + +func (m *QueryNFTsResponse) GetNfts() []*NFT { + if m != nil { + return m.Nfts + } + return nil +} + +func (m *QueryNFTsResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryNFTRequest is the request type for the Query/NFT RPC method +type QueryNFTRequest struct { + // class_id associated with the nft + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` + // id is a unique identifier of the NFT + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *QueryNFTRequest) Reset() { *m = QueryNFTRequest{} } +func (m *QueryNFTRequest) String() string { return proto.CompactTextString(m) } +func (*QueryNFTRequest) ProtoMessage() {} +func (*QueryNFTRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{4} +} +func (m *QueryNFTRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNFTRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNFTRequest.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 *QueryNFTRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTRequest.Merge(m, src) +} +func (m *QueryNFTRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryNFTRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNFTRequest proto.InternalMessageInfo + +func (m *QueryNFTRequest) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +func (m *QueryNFTRequest) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +// QueryNFTResponse is the response type for the Query/NFT RPC method +type QueryNFTResponse struct { + // owner is the owner address of the nft + Nft *NFT `protobuf:"bytes,1,opt,name=nft,proto3" json:"nft,omitempty"` +} + +func (m *QueryNFTResponse) Reset() { *m = QueryNFTResponse{} } +func (m *QueryNFTResponse) String() string { return proto.CompactTextString(m) } +func (*QueryNFTResponse) ProtoMessage() {} +func (*QueryNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{5} +} +func (m *QueryNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryNFTResponse.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 *QueryNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryNFTResponse.Merge(m, src) +} +func (m *QueryNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryNFTResponse proto.InternalMessageInfo + +func (m *QueryNFTResponse) GetNft() *NFT { + if m != nil { + return m.Nft + } + return nil +} + +// QueryClassRequest is the request type for the Query/Class RPC method +type QueryClassRequest struct { + // class_id associated with the nft + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` +} + +func (m *QueryClassRequest) Reset() { *m = QueryClassRequest{} } +func (m *QueryClassRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClassRequest) ProtoMessage() {} +func (*QueryClassRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{6} +} +func (m *QueryClassRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassRequest.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 *QueryClassRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassRequest.Merge(m, src) +} +func (m *QueryClassRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClassRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassRequest proto.InternalMessageInfo + +func (m *QueryClassRequest) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +// QueryClassResponse is the response type for the Query/Class RPC method +type QueryClassResponse struct { + // class defines the class of the nft type. + Class *Class `protobuf:"bytes,1,opt,name=class,proto3" json:"class,omitempty"` +} + +func (m *QueryClassResponse) Reset() { *m = QueryClassResponse{} } +func (m *QueryClassResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClassResponse) ProtoMessage() {} +func (*QueryClassResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{7} +} +func (m *QueryClassResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassResponse.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 *QueryClassResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassResponse.Merge(m, src) +} +func (m *QueryClassResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClassResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassResponse proto.InternalMessageInfo + +func (m *QueryClassResponse) GetClass() *Class { + if m != nil { + return m.Class + } + return nil +} + +// QueryClassesRequest is the request type for the Query/Classes RPC method +type QueryClassesRequest struct { + // pagination defines an optional pagination for the request. + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryClassesRequest) Reset() { *m = QueryClassesRequest{} } +func (m *QueryClassesRequest) String() string { return proto.CompactTextString(m) } +func (*QueryClassesRequest) ProtoMessage() {} +func (*QueryClassesRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{8} +} +func (m *QueryClassesRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassesRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassesRequest.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 *QueryClassesRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassesRequest.Merge(m, src) +} +func (m *QueryClassesRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryClassesRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassesRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassesRequest proto.InternalMessageInfo + +func (m *QueryClassesRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +// QueryClassesResponse is the response type for the Query/Classes RPC method +type QueryClassesResponse struct { + // class defines the class of the nft type. + Classes []*Class `protobuf:"bytes,1,rep,name=classes,proto3" json:"classes,omitempty"` + // pagination defines the pagination in the response. + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryClassesResponse) Reset() { *m = QueryClassesResponse{} } +func (m *QueryClassesResponse) String() string { return proto.CompactTextString(m) } +func (*QueryClassesResponse) ProtoMessage() {} +func (*QueryClassesResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_75a97f4510dee2b2, []int{9} +} +func (m *QueryClassesResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryClassesResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryClassesResponse.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 *QueryClassesResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryClassesResponse.Merge(m, src) +} +func (m *QueryClassesResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryClassesResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryClassesResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryClassesResponse proto.InternalMessageInfo + +func (m *QueryClassesResponse) GetClasses() []*Class { + if m != nil { + return m.Classes + } + return nil +} + +func (m *QueryClassesResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +func init() { + proto.RegisterType((*QueryClassOwnerRequest)(nil), "onft.v1.QueryClassOwnerRequest") + proto.RegisterType((*QueryClassOwnerResponse)(nil), "onft.v1.QueryClassOwnerResponse") + proto.RegisterType((*QueryNFTsRequest)(nil), "onft.v1.QueryNFTsRequest") + proto.RegisterType((*QueryNFTsResponse)(nil), "onft.v1.QueryNFTsResponse") + proto.RegisterType((*QueryNFTRequest)(nil), "onft.v1.QueryNFTRequest") + proto.RegisterType((*QueryNFTResponse)(nil), "onft.v1.QueryNFTResponse") + proto.RegisterType((*QueryClassRequest)(nil), "onft.v1.QueryClassRequest") + proto.RegisterType((*QueryClassResponse)(nil), "onft.v1.QueryClassResponse") + proto.RegisterType((*QueryClassesRequest)(nil), "onft.v1.QueryClassesRequest") + proto.RegisterType((*QueryClassesResponse)(nil), "onft.v1.QueryClassesResponse") +} + +func init() { proto.RegisterFile("onft/v1/query.proto", fileDescriptor_75a97f4510dee2b2) } + +var fileDescriptor_75a97f4510dee2b2 = []byte{ + // 619 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x94, 0x4d, 0x6f, 0xd3, 0x4c, + 0x10, 0xc7, 0xe3, 0xbc, 0x3c, 0x79, 0x98, 0x42, 0x5b, 0xb6, 0x05, 0x12, 0xb7, 0x71, 0x82, 0x79, + 0x69, 0x84, 0x54, 0xaf, 0x92, 0xde, 0x10, 0x27, 0x8a, 0x82, 0x22, 0xa1, 0xa4, 0x44, 0x39, 0x21, + 0x21, 0x70, 0xe2, 0x4d, 0xb0, 0xd4, 0x7a, 0xd3, 0xac, 0x13, 0x5a, 0x55, 0xe5, 0x00, 0x27, 0xc4, + 0x05, 0x89, 0x2f, 0xc5, 0xb1, 0x12, 0x17, 0x8e, 0x28, 0xe1, 0x83, 0x20, 0xef, 0xae, 0xdf, 0x52, + 0x57, 0xad, 0x10, 0x47, 0xef, 0xcc, 0xfc, 0x7f, 0xb3, 0xff, 0xd9, 0x31, 0xac, 0x51, 0x67, 0xe0, + 0xe2, 0x69, 0x0d, 0x1f, 0x4e, 0xc8, 0xf8, 0xd8, 0x18, 0x8d, 0xa9, 0x4b, 0x51, 0xde, 0x3b, 0x34, + 0xa6, 0x35, 0x75, 0x73, 0x48, 0xe9, 0x70, 0x9f, 0x60, 0x73, 0x64, 0x63, 0xd3, 0x71, 0xa8, 0x6b, + 0xba, 0x36, 0x75, 0x98, 0x48, 0x53, 0x1f, 0xf5, 0x29, 0x3b, 0xa0, 0x0c, 0xf7, 0x4c, 0x46, 0x44, + 0x3d, 0x9e, 0xd6, 0x7a, 0xc4, 0x35, 0x6b, 0x78, 0x64, 0x0e, 0x6d, 0x87, 0x27, 0xcb, 0x5c, 0xe4, + 0x73, 0xb8, 0x34, 0x3f, 0xd3, 0x77, 0xe0, 0xf6, 0x4b, 0xaf, 0x6a, 0x77, 0xdf, 0x64, 0xac, 0xfd, + 0xde, 0x21, 0xe3, 0x0e, 0x39, 0x9c, 0x10, 0xe6, 0xa2, 0x22, 0xfc, 0xdf, 0xf7, 0x0e, 0xdf, 0xd8, + 0x56, 0x41, 0xa9, 0x28, 0xd5, 0x6b, 0x9d, 0x3c, 0xff, 0x6e, 0x5a, 0x3a, 0x86, 0x3b, 0xe7, 0x8a, + 0xd8, 0x88, 0x3a, 0x8c, 0xa0, 0x75, 0xc8, 0x51, 0xef, 0x40, 0x96, 0x88, 0x0f, 0xfd, 0x8b, 0x02, + 0xab, 0xbc, 0xa2, 0xd5, 0xe8, 0xb2, 0xcb, 0x01, 0xa1, 0x4a, 0x3a, 0xa2, 0x82, 0x1a, 0x00, 0xe1, + 0x9d, 0x0a, 0x99, 0x8a, 0x52, 0x5d, 0xaa, 0x3f, 0x34, 0x84, 0x01, 0x86, 0x67, 0x80, 0x21, 0x0c, + 0x94, 0x06, 0x18, 0x7b, 0xe6, 0x90, 0x48, 0x58, 0x27, 0x52, 0xa9, 0x7f, 0x80, 0x9b, 0x91, 0x66, + 0x64, 0xe3, 0x15, 0xc8, 0x3a, 0x03, 0x97, 0x15, 0x94, 0x4a, 0xa6, 0xba, 0x54, 0xbf, 0x6e, 0x48, + 0xfb, 0x8d, 0x56, 0xa3, 0xdb, 0xe1, 0x11, 0xf4, 0x3c, 0x86, 0x4f, 0x73, 0xfc, 0xd6, 0xa5, 0x78, + 0x21, 0x1f, 0xe3, 0x3f, 0x81, 0x15, 0x9f, 0x7f, 0x05, 0x2f, 0x96, 0x21, 0x6d, 0x5b, 0xd2, 0x88, + 0xb4, 0x6d, 0xe9, 0xf5, 0xd0, 0xca, 0xa0, 0x79, 0x0d, 0x32, 0xce, 0xc0, 0xe5, 0x95, 0x8b, 0xbd, + 0x7b, 0x01, 0xdd, 0x90, 0x37, 0xe6, 0x03, 0xbb, 0xc2, 0x80, 0x1f, 0x03, 0x8a, 0xe6, 0x4b, 0xca, + 0x7d, 0xc8, 0xf1, 0x04, 0xc9, 0x59, 0x0e, 0x38, 0x22, 0x4d, 0x04, 0xf5, 0xd7, 0xb0, 0x16, 0xd6, + 0x92, 0x80, 0x16, 0x1f, 0x9e, 0xf2, 0xd7, 0xc3, 0xfb, 0xac, 0xc0, 0x7a, 0x5c, 0x5f, 0x76, 0x57, + 0x05, 0xd1, 0x3e, 0xf1, 0x67, 0xb8, 0xd8, 0x9f, 0x1f, 0xfe, 0x67, 0x83, 0xac, 0x7f, 0xca, 0x42, + 0x8e, 0xf7, 0x82, 0x8e, 0x00, 0xc2, 0x65, 0x40, 0xe5, 0x80, 0x9c, 0xbc, 0x5b, 0x6a, 0xe5, 0xe2, + 0x04, 0x81, 0xd1, 0xb7, 0x3e, 0xfe, 0xf8, 0xfd, 0x2d, 0x7d, 0x17, 0x95, 0xb1, 0xbf, 0xb4, 0xbc, + 0x7b, 0x7c, 0xe2, 0x8f, 0xec, 0x14, 0x8b, 0xa5, 0xe8, 0x42, 0xd6, 0x7b, 0xc7, 0xa8, 0x18, 0x97, + 0x8c, 0x2c, 0x9a, 0xaa, 0x26, 0x85, 0x24, 0xe7, 0x16, 0xe7, 0xac, 0xa0, 0x1b, 0x01, 0x87, 0xbf, + 0x75, 0x13, 0x32, 0xad, 0x46, 0x17, 0x15, 0xce, 0x55, 0xfa, 0x9a, 0xc5, 0x84, 0x88, 0x94, 0x7c, + 0xc0, 0x25, 0xcb, 0xa8, 0x14, 0x93, 0x8c, 0x76, 0x7e, 0x62, 0x5b, 0xa7, 0x88, 0x40, 0x8e, 0xdf, + 0x1b, 0xa9, 0x09, 0x66, 0xf8, 0x98, 0x8d, 0xc4, 0x98, 0x04, 0xdd, 0xe3, 0xa0, 0x12, 0xda, 0x88, + 0x7b, 0x44, 0xa2, 0x2c, 0xf4, 0x16, 0xf2, 0xf2, 0xa5, 0xa0, 0xcd, 0x04, 0xb1, 0xe0, 0x81, 0xaa, + 0xa5, 0x0b, 0xa2, 0x12, 0x56, 0xe0, 0x30, 0x84, 0x56, 0x17, 0x61, 0x4f, 0x9b, 0xdf, 0x67, 0x9a, + 0x72, 0x36, 0xd3, 0x94, 0x5f, 0x33, 0x4d, 0xf9, 0x3a, 0xd7, 0x52, 0x67, 0x73, 0x2d, 0xf5, 0x73, + 0xae, 0xa5, 0x5e, 0xe1, 0xa1, 0xed, 0xbe, 0x9b, 0xf4, 0x8c, 0x3e, 0x3d, 0xc0, 0xed, 0x67, 0xcd, + 0xd6, 0xf6, 0x5e, 0xa7, 0xdd, 0x6d, 0xef, 0xb6, 0x5f, 0x60, 0x6a, 0xd9, 0xce, 0x76, 0x9f, 0x8e, + 0x09, 0x3e, 0x12, 0x7a, 0xee, 0xf1, 0x88, 0xb0, 0xde, 0x7f, 0xfc, 0xa7, 0xbc, 0xf3, 0x27, 0x00, + 0x00, 0xff, 0xff, 0x3c, 0xa6, 0x93, 0xb0, 0x12, 0x06, 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 { + // ClassOwner queries the owner of the NFT class + ClassOwner(ctx context.Context, in *QueryClassOwnerRequest, opts ...grpc.CallOption) (*QueryClassOwnerResponse, error) + // NFTs queries all NFTs with owners of a given class or owner,choose at least one of the two, + // similar to tokenByIndex in ERC721Enumerable + NFTs(ctx context.Context, in *QueryNFTsRequest, opts ...grpc.CallOption) (*QueryNFTsResponse, error) + // NFT queries an NFT with owner based on its class and id + NFT(ctx context.Context, in *QueryNFTRequest, opts ...grpc.CallOption) (*QueryNFTResponse, error) + // Class queries an NFT class based on its id with class owner + Class(ctx context.Context, in *QueryClassRequest, opts ...grpc.CallOption) (*QueryClassResponse, error) + // Classes queries all NFT classes with owners + Classes(ctx context.Context, in *QueryClassesRequest, opts ...grpc.CallOption) (*QueryClassesResponse, error) +} + +type queryClient struct { + cc grpc1.ClientConn +} + +func NewQueryClient(cc grpc1.ClientConn) QueryClient { + return &queryClient{cc} +} + +func (c *queryClient) ClassOwner(ctx context.Context, in *QueryClassOwnerRequest, opts ...grpc.CallOption) (*QueryClassOwnerResponse, error) { + out := new(QueryClassOwnerResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Query/ClassOwner", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) NFTs(ctx context.Context, in *QueryNFTsRequest, opts ...grpc.CallOption) (*QueryNFTsResponse, error) { + out := new(QueryNFTsResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Query/NFTs", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) NFT(ctx context.Context, in *QueryNFTRequest, opts ...grpc.CallOption) (*QueryNFTResponse, error) { + out := new(QueryNFTResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Query/NFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Class(ctx context.Context, in *QueryClassRequest, opts ...grpc.CallOption) (*QueryClassResponse, error) { + out := new(QueryClassResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Query/Class", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) Classes(ctx context.Context, in *QueryClassesRequest, opts ...grpc.CallOption) (*QueryClassesResponse, error) { + out := new(QueryClassesResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Query/Classes", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// QueryServer is the server API for Query service. +type QueryServer interface { + // ClassOwner queries the owner of the NFT class + ClassOwner(context.Context, *QueryClassOwnerRequest) (*QueryClassOwnerResponse, error) + // NFTs queries all NFTs with owners of a given class or owner,choose at least one of the two, + // similar to tokenByIndex in ERC721Enumerable + NFTs(context.Context, *QueryNFTsRequest) (*QueryNFTsResponse, error) + // NFT queries an NFT with owner based on its class and id + NFT(context.Context, *QueryNFTRequest) (*QueryNFTResponse, error) + // Class queries an NFT class based on its id with class owner + Class(context.Context, *QueryClassRequest) (*QueryClassResponse, error) + // Classes queries all NFT classes with owners + Classes(context.Context, *QueryClassesRequest) (*QueryClassesResponse, error) +} + +// UnimplementedQueryServer can be embedded to have forward compatible implementations. +type UnimplementedQueryServer struct { +} + +func (*UnimplementedQueryServer) ClassOwner(ctx context.Context, req *QueryClassOwnerRequest) (*QueryClassOwnerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClassOwner not implemented") +} +func (*UnimplementedQueryServer) NFTs(ctx context.Context, req *QueryNFTsRequest) (*QueryNFTsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NFTs not implemented") +} +func (*UnimplementedQueryServer) NFT(ctx context.Context, req *QueryNFTRequest) (*QueryNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method NFT not implemented") +} +func (*UnimplementedQueryServer) Class(ctx context.Context, req *QueryClassRequest) (*QueryClassResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Class not implemented") +} +func (*UnimplementedQueryServer) Classes(ctx context.Context, req *QueryClassesRequest) (*QueryClassesResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Classes not implemented") +} + +func RegisterQueryServer(s grpc1.Server, srv QueryServer) { + s.RegisterService(&_Query_serviceDesc, srv) +} + +func _Query_ClassOwner_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClassOwnerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).ClassOwner(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Query/ClassOwner", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).ClassOwner(ctx, req.(*QueryClassOwnerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_NFTs_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNFTsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NFTs(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Query/NFTs", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NFTs(ctx, req.(*QueryNFTsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_NFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryNFTRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).NFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Query/NFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).NFT(ctx, req.(*QueryNFTRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Class_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClassRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Class(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Query/Class", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Class(ctx, req.(*QueryClassRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_Classes_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryClassesRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).Classes(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Query/Classes", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).Classes(ctx, req.(*QueryClassesRequest)) + } + return interceptor(ctx, in, info, handler) +} + +var _Query_serviceDesc = grpc.ServiceDesc{ + ServiceName: "onft.v1.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "ClassOwner", + Handler: _Query_ClassOwner_Handler, + }, + { + MethodName: "NFTs", + Handler: _Query_NFTs_Handler, + }, + { + MethodName: "NFT", + Handler: _Query_NFT_Handler, + }, + { + MethodName: "Class", + Handler: _Query_Class_Handler, + }, + { + MethodName: "Classes", + Handler: _Query_Classes_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "onft/v1/query.proto", +} + +func (m *QueryClassOwnerRequest) 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 *QueryClassOwnerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassOwnerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryClassOwnerResponse) 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 *QueryClassOwnerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassOwnerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNFTsRequest) 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 *QueryNFTsRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNFTsRequest) 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] = 0x1a + } + if len(m.Owner) > 0 { + i -= len(m.Owner) + copy(dAtA[i:], m.Owner) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Owner))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNFTsResponse) 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 *QueryNFTsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNFTsResponse) 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.Nfts) > 0 { + for iNdEx := len(m.Nfts) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Nfts[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 *QueryNFTRequest) 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 *QueryNFTRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNFTRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryNFTResponse) 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 *QueryNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Nft != nil { + { + size, err := m.Nft.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 *QueryClassRequest) 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 *QueryClassRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryClassResponse) 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 *QueryClassResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Class != nil { + { + size, err := m.Class.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 *QueryClassesRequest) 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 *QueryClassesRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassesRequest) 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 *QueryClassesResponse) 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 *QueryClassesResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryClassesResponse) 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.Classes) > 0 { + for iNdEx := len(m.Classes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Classes[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 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 *QueryClassOwnerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClassOwnerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNFTsRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Owner) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNFTsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Nfts) > 0 { + for _, e := range m.Nfts { + 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 *QueryNFTRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Nft != nil { + l = m.Nft.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClassRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClassResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Class != nil { + l = m.Class.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryClassesRequest) 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 *QueryClassesResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Classes) > 0 { + for _, e := range m.Classes { + 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 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 *QueryClassOwnerRequest) 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: QueryClassOwnerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassOwnerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = 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 *QueryClassOwnerResponse) 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: QueryClassOwnerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassOwnerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = 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 *QueryNFTsRequest) 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: QueryNFTsRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNFTsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Owner", 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.Owner = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + 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 *QueryNFTsResponse) 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: QueryNFTsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNFTsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nfts", 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.Nfts = append(m.Nfts, &NFT{}) + if err := m.Nfts[len(m.Nfts)-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 *QueryNFTRequest) 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: QueryNFTRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNFTRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Id = 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 *QueryNFTResponse) 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: QueryNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Nft", 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.Nft == nil { + m.Nft = &NFT{} + } + if err := m.Nft.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 *QueryClassRequest) 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: QueryClassRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = 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 *QueryClassResponse) 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: QueryClassResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Class", 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.Class == nil { + m.Class = &Class{} + } + if err := m.Class.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 *QueryClassesRequest) 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: QueryClassesRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassesRequest: 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 *QueryClassesResponse) 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: QueryClassesResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryClassesResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Classes", 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.Classes = append(m.Classes, &Class{}) + if err := m.Classes[len(m.Classes)-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 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/onft/types/query.pb.gw.go b/x/onft/types/query.pb.gw.go new file mode 100644 index 00000000..2bfda689 --- /dev/null +++ b/x/onft/types/query.pb.gw.go @@ -0,0 +1,579 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: onft/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 + +func request_Query_ClassOwner_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + msg, err := client.ClassOwner(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_ClassOwner_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassOwnerRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + msg, err := server.ClassOwner(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_NFTs_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_NFTs_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTsRequest + 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_NFTs_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.NFTs(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NFTs_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTsRequest + 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_NFTs_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.NFTs(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_NFT_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := client.NFT(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_NFT_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryNFTRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + val, ok = pathParams["id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "id") + } + + protoReq.Id, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "id", err) + } + + msg, err := server.NFT(ctx, &protoReq) + return msg, metadata, err + +} + +func request_Query_Class_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + msg, err := client.Class(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Class_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["class_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "class_id") + } + + protoReq.ClassId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "class_id", err) + } + + msg, err := server.Class(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_Classes_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_Classes_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassesRequest + 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_Classes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.Classes(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_Classes_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryClassesRequest + 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_Classes_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.Classes(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_ClassOwner_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_ClassOwner_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_ClassOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NFTs_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_NFTs_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_NFTs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NFT_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + var stream runtime.ServerTransportStream + ctx = grpc.NewContextWithServerTransportStream(ctx, &stream) + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_Query_NFT_0(rctx, inboundMarshaler, server, req, pathParams) + md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer()) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_Query_NFT_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Class_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_Class_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_Class_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Classes_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_Classes_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_Classes_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_ClassOwner_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_ClassOwner_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_ClassOwner_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NFTs_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_NFTs_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_NFTs_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_NFT_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + 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_NFT_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_NFT_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Class_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_Class_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_Class_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_Classes_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_Classes_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_Classes_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + return nil +} + +var ( + pattern_Query_ClassOwner_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"onft", "v1", "class", "class_id", "owner"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_NFTs_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"onft", "v1", "nfts"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_NFT_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4}, []string{"onft", "v1", "nfts", "class_id", "id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Class_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3}, []string{"onft", "v1", "classes", "class_id"}, "", runtime.AssumeColonVerbOpt(false))) + + pattern_Query_Classes_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"onft", "v1", "classes"}, "", runtime.AssumeColonVerbOpt(false))) +) + +var ( + forward_Query_ClassOwner_0 = runtime.ForwardResponseMessage + + forward_Query_NFTs_0 = runtime.ForwardResponseMessage + + forward_Query_NFT_0 = runtime.ForwardResponseMessage + + forward_Query_Class_0 = runtime.ForwardResponseMessage + + forward_Query_Classes_0 = runtime.ForwardResponseMessage +) diff --git a/x/onft/types/tx.pb.go b/x/onft/types/tx.pb.go new file mode 100644 index 00000000..b219f476 --- /dev/null +++ b/x/onft/types/tx.pb.go @@ -0,0 +1,2119 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: onft/v1/tx.proto + +package types + +import ( + context "context" + fmt "fmt" + _ "github.com/cosmos/cosmos-proto" + types "github.com/cosmos/cosmos-sdk/codec/types" + _ "github.com/cosmos/cosmos-sdk/types/msgservice" + _ "github.com/cosmos/cosmos-sdk/types/tx/amino" + _ "github.com/cosmos/gogoproto/gogoproto" + grpc1 "github.com/cosmos/gogoproto/grpc" + proto "github.com/cosmos/gogoproto/proto" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +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 + +// MsgCreateNFTClass is a message for creating new NFT class +type MsgCreateNFTClass struct { + // name defines the human-readable name of the NFT classification. Optional + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // symbol is an abbreviated name for nft classification. Optional + Symbol string `protobuf:"bytes,2,opt,name=symbol,proto3" json:"symbol,omitempty"` + // description is a brief description of nft classification. Optional + Description string `protobuf:"bytes,3,opt,name=description,proto3" json:"description,omitempty"` + // uri for the class metadata stored off chain. It can define schema for Class and NFT `Data` attributes. Optional + Uri string `protobuf:"bytes,4,opt,name=uri,proto3" json:"uri,omitempty"` + // uri_hash is a hash of the document pointed by uri. Optional + UriHash string `protobuf:"bytes,5,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"` + // data is the app specific metadata of the NFT class. Optional + Data *types.Any `protobuf:"bytes,6,opt,name=data,proto3" json:"data,omitempty"` + // Sender is an account address of message sender. + Sender string `protobuf:"bytes,7,opt,name=sender,proto3" json:"sender,omitempty"` +} + +func (m *MsgCreateNFTClass) Reset() { *m = MsgCreateNFTClass{} } +func (m *MsgCreateNFTClass) String() string { return proto.CompactTextString(m) } +func (*MsgCreateNFTClass) ProtoMessage() {} +func (*MsgCreateNFTClass) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{0} +} +func (m *MsgCreateNFTClass) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateNFTClass) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateNFTClass.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 *MsgCreateNFTClass) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateNFTClass.Merge(m, src) +} +func (m *MsgCreateNFTClass) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateNFTClass) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateNFTClass.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateNFTClass proto.InternalMessageInfo + +func (m *MsgCreateNFTClass) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *MsgCreateNFTClass) GetSymbol() string { + if m != nil { + return m.Symbol + } + return "" +} + +func (m *MsgCreateNFTClass) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *MsgCreateNFTClass) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +func (m *MsgCreateNFTClass) GetUriHash() string { + if m != nil { + return m.UriHash + } + return "" +} + +func (m *MsgCreateNFTClass) GetData() *types.Any { + if m != nil { + return m.Data + } + return nil +} + +func (m *MsgCreateNFTClass) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +// MsgCreateNFTClassResponse is response data for MsgCreateNFTClass message +type MsgCreateNFTClassResponse struct { + // id defines the unique identifier of the NFT classification, similar to the contract address of ERC721 + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgCreateNFTClassResponse) Reset() { *m = MsgCreateNFTClassResponse{} } +func (m *MsgCreateNFTClassResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateNFTClassResponse) ProtoMessage() {} +func (*MsgCreateNFTClassResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{1} +} +func (m *MsgCreateNFTClassResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateNFTClassResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateNFTClassResponse.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 *MsgCreateNFTClassResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateNFTClassResponse.Merge(m, src) +} +func (m *MsgCreateNFTClassResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateNFTClassResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateNFTClassResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateNFTClassResponse proto.InternalMessageInfo + +func (m *MsgCreateNFTClassResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +// MsgTransferClassOwnership is a message for transferring class ownership to another owner +type MsgTransferClassOwnership struct { + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` + // Sender is an account address of message sender. + Sender string `protobuf:"bytes,2,opt,name=sender,proto3" json:"sender,omitempty"` + NewOwner string `protobuf:"bytes,3,opt,name=new_owner,json=newOwner,proto3" json:"new_owner,omitempty"` +} + +func (m *MsgTransferClassOwnership) Reset() { *m = MsgTransferClassOwnership{} } +func (m *MsgTransferClassOwnership) String() string { return proto.CompactTextString(m) } +func (*MsgTransferClassOwnership) ProtoMessage() {} +func (*MsgTransferClassOwnership) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{2} +} +func (m *MsgTransferClassOwnership) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransferClassOwnership) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransferClassOwnership.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 *MsgTransferClassOwnership) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransferClassOwnership.Merge(m, src) +} +func (m *MsgTransferClassOwnership) XXX_Size() int { + return m.Size() +} +func (m *MsgTransferClassOwnership) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransferClassOwnership.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransferClassOwnership proto.InternalMessageInfo + +func (m *MsgTransferClassOwnership) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +func (m *MsgTransferClassOwnership) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgTransferClassOwnership) GetNewOwner() string { + if m != nil { + return m.NewOwner + } + return "" +} + +// MsgTransferClassOwnershipResponse is response data for MsgTransferClassOwnership message +type MsgTransferClassOwnershipResponse struct { +} + +func (m *MsgTransferClassOwnershipResponse) Reset() { *m = MsgTransferClassOwnershipResponse{} } +func (m *MsgTransferClassOwnershipResponse) String() string { return proto.CompactTextString(m) } +func (*MsgTransferClassOwnershipResponse) ProtoMessage() {} +func (*MsgTransferClassOwnershipResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{3} +} +func (m *MsgTransferClassOwnershipResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgTransferClassOwnershipResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgTransferClassOwnershipResponse.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 *MsgTransferClassOwnershipResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgTransferClassOwnershipResponse.Merge(m, src) +} +func (m *MsgTransferClassOwnershipResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgTransferClassOwnershipResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgTransferClassOwnershipResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgTransferClassOwnershipResponse proto.InternalMessageInfo + +type MsgMintNFT struct { + // class_id associated with the NFT, similar to the contract address of ERC721 + ClassId string `protobuf:"bytes,1,opt,name=class_id,json=classId,proto3" json:"class_id,omitempty"` + // uri for the NFT metadata stored off chain + Uri string `protobuf:"bytes,2,opt,name=uri,proto3" json:"uri,omitempty"` + // uri_hash is a hash of the document pointed by uri + UriHash string `protobuf:"bytes,3,opt,name=uri_hash,json=uriHash,proto3" json:"uri_hash,omitempty"` + // Sender is an account address of message sender. + Sender string `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"` + Receiver string `protobuf:"bytes,5,opt,name=receiver,proto3" json:"receiver,omitempty"` + // data is an app specific data of the NFT. Optional + Data *types.Any `protobuf:"bytes,10,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *MsgMintNFT) Reset() { *m = MsgMintNFT{} } +func (m *MsgMintNFT) String() string { return proto.CompactTextString(m) } +func (*MsgMintNFT) ProtoMessage() {} +func (*MsgMintNFT) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{4} +} +func (m *MsgMintNFT) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintNFT) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintNFT.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 *MsgMintNFT) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintNFT.Merge(m, src) +} +func (m *MsgMintNFT) XXX_Size() int { + return m.Size() +} +func (m *MsgMintNFT) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintNFT.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintNFT proto.InternalMessageInfo + +func (m *MsgMintNFT) GetClassId() string { + if m != nil { + return m.ClassId + } + return "" +} + +func (m *MsgMintNFT) GetUri() string { + if m != nil { + return m.Uri + } + return "" +} + +func (m *MsgMintNFT) GetUriHash() string { + if m != nil { + return m.UriHash + } + return "" +} + +func (m *MsgMintNFT) GetSender() string { + if m != nil { + return m.Sender + } + return "" +} + +func (m *MsgMintNFT) GetReceiver() string { + if m != nil { + return m.Receiver + } + return "" +} + +func (m *MsgMintNFT) GetData() *types.Any { + if m != nil { + return m.Data + } + return nil +} + +// MsgMintNFTResponse is response data for MsgMintNFT message +type MsgMintNFTResponse struct { + // id defines the unique identifier of the NFT token + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *MsgMintNFTResponse) Reset() { *m = MsgMintNFTResponse{} } +func (m *MsgMintNFTResponse) String() string { return proto.CompactTextString(m) } +func (*MsgMintNFTResponse) ProtoMessage() {} +func (*MsgMintNFTResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_004f909e277b5432, []int{5} +} +func (m *MsgMintNFTResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgMintNFTResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgMintNFTResponse.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 *MsgMintNFTResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgMintNFTResponse.Merge(m, src) +} +func (m *MsgMintNFTResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgMintNFTResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgMintNFTResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgMintNFTResponse proto.InternalMessageInfo + +func (m *MsgMintNFTResponse) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func init() { + proto.RegisterType((*MsgCreateNFTClass)(nil), "onft.v1.MsgCreateNFTClass") + proto.RegisterType((*MsgCreateNFTClassResponse)(nil), "onft.v1.MsgCreateNFTClassResponse") + proto.RegisterType((*MsgTransferClassOwnership)(nil), "onft.v1.MsgTransferClassOwnership") + proto.RegisterType((*MsgTransferClassOwnershipResponse)(nil), "onft.v1.MsgTransferClassOwnershipResponse") + proto.RegisterType((*MsgMintNFT)(nil), "onft.v1.MsgMintNFT") + proto.RegisterType((*MsgMintNFTResponse)(nil), "onft.v1.MsgMintNFTResponse") +} + +func init() { proto.RegisterFile("onft/v1/tx.proto", fileDescriptor_004f909e277b5432) } + +var fileDescriptor_004f909e277b5432 = []byte{ + // 621 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x54, 0x41, 0x6f, 0xd3, 0x30, + 0x18, 0x5d, 0xd2, 0xd2, 0x6e, 0x1e, 0x9a, 0x36, 0x6f, 0x1a, 0x59, 0x26, 0x85, 0x12, 0x90, 0x98, + 0x86, 0x16, 0xb3, 0x01, 0x97, 0x71, 0xda, 0x86, 0x26, 0x26, 0xd1, 0x75, 0x2a, 0x3d, 0x71, 0xa9, + 0xd2, 0xc4, 0x4d, 0x2c, 0x2d, 0x76, 0x65, 0xa7, 0xed, 0x7a, 0xe5, 0x84, 0x38, 0x21, 0xf1, 0x07, + 0xf8, 0x09, 0x3b, 0xf0, 0x23, 0x38, 0x56, 0x9c, 0x38, 0xa2, 0xf6, 0x30, 0x7e, 0x05, 0x42, 0x71, + 0x92, 0xae, 0x65, 0x69, 0xb7, 0x4b, 0x65, 0xbf, 0xf7, 0xbe, 0xc4, 0xef, 0xf9, 0x35, 0x60, 0x99, + 0xd1, 0x66, 0x88, 0x3a, 0xbb, 0x28, 0xbc, 0xb0, 0x5a, 0x9c, 0x85, 0x0c, 0x16, 0x23, 0xc4, 0xea, + 0xec, 0xea, 0x6b, 0x1e, 0xf3, 0x98, 0xc4, 0x50, 0xb4, 0x8a, 0x69, 0xfd, 0x81, 0xc3, 0x44, 0xc0, + 0x04, 0x0a, 0x84, 0x17, 0x8d, 0x05, 0xc2, 0x4b, 0x88, 0x8d, 0x98, 0xa8, 0xc7, 0x13, 0xf1, 0x26, + 0xa1, 0x56, 0xec, 0x80, 0x50, 0x86, 0xe4, 0x6f, 0xaa, 0xf6, 0x18, 0xf3, 0xce, 0x31, 0x92, 0xbb, + 0x46, 0xbb, 0x89, 0x6c, 0xda, 0x8b, 0x29, 0xf3, 0xab, 0x0a, 0x56, 0xca, 0xc2, 0x3b, 0xe2, 0xd8, + 0x0e, 0xf1, 0xe9, 0x71, 0xed, 0xe8, 0xdc, 0x16, 0x02, 0x42, 0x90, 0xa7, 0x76, 0x80, 0x35, 0xa5, + 0xa4, 0x6c, 0x2d, 0x54, 0xe5, 0x1a, 0xae, 0x83, 0x82, 0xe8, 0x05, 0x0d, 0x76, 0xae, 0xa9, 0x12, + 0x4d, 0x76, 0xb0, 0x04, 0x16, 0x5d, 0x2c, 0x1c, 0x4e, 0x5a, 0x21, 0x61, 0x54, 0xcb, 0x49, 0x72, + 0x1c, 0x82, 0xcb, 0x20, 0xd7, 0xe6, 0x44, 0xcb, 0x4b, 0x26, 0x5a, 0xc2, 0x0d, 0x30, 0xdf, 0xe6, + 0xa4, 0xee, 0xdb, 0xc2, 0xd7, 0xee, 0x49, 0xb8, 0xd8, 0xe6, 0xe4, 0xad, 0x2d, 0x7c, 0xb8, 0x05, + 0xf2, 0xae, 0x1d, 0xda, 0x5a, 0xa1, 0xa4, 0x6c, 0x2d, 0xee, 0xad, 0x59, 0xf1, 0xd1, 0xad, 0xf4, + 0xe8, 0xd6, 0x01, 0xed, 0x55, 0xa5, 0x02, 0x3e, 0x07, 0x05, 0x81, 0xa9, 0x8b, 0xb9, 0x56, 0x8c, + 0x1e, 0x71, 0xa8, 0xfd, 0xfc, 0xbe, 0xb3, 0x96, 0x44, 0x71, 0xe0, 0xba, 0x1c, 0x0b, 0xf1, 0x3e, + 0xe4, 0x84, 0x7a, 0xd5, 0x44, 0xb7, 0xff, 0xf4, 0xcf, 0xb7, 0x87, 0xca, 0xc7, 0xab, 0xcb, 0xed, + 0x04, 0xf8, 0x7c, 0x75, 0xb9, 0xbd, 0x2a, 0xef, 0x64, 0xd2, 0xbf, 0xf9, 0x0c, 0x6c, 0xdc, 0x08, + 0xa5, 0x8a, 0x45, 0x8b, 0x51, 0x81, 0xe1, 0x12, 0x50, 0x89, 0x9b, 0x44, 0xa3, 0x12, 0xd7, 0xec, + 0x2b, 0x52, 0x5d, 0xe3, 0x36, 0x15, 0x4d, 0xcc, 0xa5, 0xb8, 0xd2, 0xa5, 0x98, 0x0b, 0x9f, 0xb4, + 0x22, 0xab, 0x4e, 0x84, 0xd4, 0x47, 0x33, 0x45, 0xb9, 0x3f, 0x71, 0xc7, 0x0c, 0xa8, 0x77, 0x33, + 0x00, 0x5f, 0x81, 0x05, 0x8a, 0xbb, 0x75, 0x16, 0x3d, 0x3d, 0x4e, 0x7a, 0xc6, 0xd0, 0x3c, 0xc5, + 0x5d, 0x79, 0x8e, 0x7d, 0x94, 0xe1, 0x7b, 0x53, 0xfa, 0xce, 0x3e, 0xb4, 0xf9, 0x18, 0x3c, 0x9a, + 0xea, 0x28, 0xcd, 0xc1, 0xfc, 0xa4, 0x02, 0x50, 0x16, 0x5e, 0x99, 0xd0, 0xf0, 0xf4, 0xb8, 0x36, + 0xcb, 0x68, 0x52, 0x00, 0x35, 0xbb, 0x00, 0xb9, 0xc9, 0x02, 0x5c, 0xa7, 0x92, 0xbf, 0x63, 0x2a, + 0x2f, 0xc1, 0x3c, 0xc7, 0x0e, 0x26, 0x1d, 0xcc, 0xe3, 0x36, 0xcd, 0x0a, 0x25, 0x55, 0x8e, 0x8a, + 0x06, 0x6e, 0x2b, 0xda, 0x7e, 0x29, 0x23, 0xbe, 0xfb, 0x32, 0x3e, 0xe9, 0xbd, 0x19, 0x9a, 0x4f, + 0x00, 0xbc, 0x4e, 0x62, 0x5a, 0x51, 0xf6, 0xfe, 0x2a, 0x20, 0x57, 0x16, 0x1e, 0x3c, 0x03, 0x4b, + 0xff, 0xfd, 0xdf, 0x74, 0x2b, 0xf9, 0x0e, 0x58, 0x37, 0x6a, 0xa7, 0x9b, 0xd3, 0xb9, 0xd1, 0x9b, + 0x7c, 0xb0, 0x3e, 0xa5, 0x7e, 0x13, 0xd3, 0xd9, 0x1a, 0x7d, 0xfb, 0x76, 0xcd, 0xe8, 0x4d, 0xaf, + 0x41, 0x31, 0xbd, 0xf0, 0xd5, 0xf1, 0xb1, 0x04, 0xd4, 0x37, 0x33, 0xc0, 0x74, 0xf8, 0xf0, 0xe4, + 0xc7, 0xc0, 0x50, 0xfa, 0x03, 0x43, 0xf9, 0x3d, 0x30, 0x94, 0x2f, 0x43, 0x63, 0xae, 0x3f, 0x34, + 0xe6, 0x7e, 0x0d, 0x8d, 0xb9, 0x0f, 0xc8, 0x23, 0xa1, 0xdf, 0x6e, 0x58, 0x0e, 0x0b, 0x50, 0xe5, + 0xcd, 0xc9, 0xe9, 0xce, 0x59, 0xb5, 0x52, 0xab, 0x1c, 0x55, 0xde, 0x21, 0xe6, 0x12, 0xba, 0xe3, + 0x30, 0x8e, 0xd1, 0x05, 0x92, 0x99, 0x87, 0xbd, 0x16, 0x16, 0x8d, 0x82, 0xbc, 0xa7, 0x17, 0xff, + 0x02, 0x00, 0x00, 0xff, 0xff, 0x2f, 0xf3, 0xd7, 0xb4, 0x53, 0x05, 0x00, 0x00, +} + +func (this *MsgCreateNFTClass) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgCreateNFTClass) + if !ok { + that2, ok := that.(MsgCreateNFTClass) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.Name != that1.Name { + return false + } + if this.Symbol != that1.Symbol { + return false + } + if this.Description != that1.Description { + return false + } + if this.Uri != that1.Uri { + return false + } + if this.UriHash != that1.UriHash { + return false + } + if !this.Data.Equal(that1.Data) { + return false + } + if this.Sender != that1.Sender { + return false + } + return true +} +func (this *MsgTransferClassOwnership) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgTransferClassOwnership) + if !ok { + that2, ok := that.(MsgTransferClassOwnership) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClassId != that1.ClassId { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.NewOwner != that1.NewOwner { + return false + } + return true +} +func (this *MsgMintNFT) Equal(that interface{}) bool { + if that == nil { + return this == nil + } + + that1, ok := that.(*MsgMintNFT) + if !ok { + that2, ok := that.(MsgMintNFT) + if ok { + that1 = &that2 + } else { + return false + } + } + if that1 == nil { + return this == nil + } else if this == nil { + return false + } + if this.ClassId != that1.ClassId { + return false + } + if this.Uri != that1.Uri { + return false + } + if this.UriHash != that1.UriHash { + return false + } + if this.Sender != that1.Sender { + return false + } + if this.Receiver != that1.Receiver { + return false + } + if !this.Data.Equal(that1.Data) { + return false + } + return true +} + +// 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 { + // CreateNFTClass defines a method for creating new nft class + CreateNFTClass(ctx context.Context, in *MsgCreateNFTClass, opts ...grpc.CallOption) (*MsgCreateNFTClassResponse, error) + TransferClassOwnership(ctx context.Context, in *MsgTransferClassOwnership, opts ...grpc.CallOption) (*MsgTransferClassOwnershipResponse, error) + MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.CallOption) (*MsgMintNFTResponse, error) +} + +type msgClient struct { + cc grpc1.ClientConn +} + +func NewMsgClient(cc grpc1.ClientConn) MsgClient { + return &msgClient{cc} +} + +func (c *msgClient) CreateNFTClass(ctx context.Context, in *MsgCreateNFTClass, opts ...grpc.CallOption) (*MsgCreateNFTClassResponse, error) { + out := new(MsgCreateNFTClassResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Msg/CreateNFTClass", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) TransferClassOwnership(ctx context.Context, in *MsgTransferClassOwnership, opts ...grpc.CallOption) (*MsgTransferClassOwnershipResponse, error) { + out := new(MsgTransferClassOwnershipResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Msg/TransferClassOwnership", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) MintNFT(ctx context.Context, in *MsgMintNFT, opts ...grpc.CallOption) (*MsgMintNFTResponse, error) { + out := new(MsgMintNFTResponse) + err := c.cc.Invoke(ctx, "/onft.v1.Msg/MintNFT", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// MsgServer is the server API for Msg service. +type MsgServer interface { + // CreateNFTClass defines a method for creating new nft class + CreateNFTClass(context.Context, *MsgCreateNFTClass) (*MsgCreateNFTClassResponse, error) + TransferClassOwnership(context.Context, *MsgTransferClassOwnership) (*MsgTransferClassOwnershipResponse, error) + MintNFT(context.Context, *MsgMintNFT) (*MsgMintNFTResponse, error) +} + +// UnimplementedMsgServer can be embedded to have forward compatible implementations. +type UnimplementedMsgServer struct { +} + +func (*UnimplementedMsgServer) CreateNFTClass(ctx context.Context, req *MsgCreateNFTClass) (*MsgCreateNFTClassResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateNFTClass not implemented") +} +func (*UnimplementedMsgServer) TransferClassOwnership(ctx context.Context, req *MsgTransferClassOwnership) (*MsgTransferClassOwnershipResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TransferClassOwnership not implemented") +} +func (*UnimplementedMsgServer) MintNFT(ctx context.Context, req *MsgMintNFT) (*MsgMintNFTResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method MintNFT not implemented") +} + +func RegisterMsgServer(s grpc1.Server, srv MsgServer) { + s.RegisterService(&_Msg_serviceDesc, srv) +} + +func _Msg_CreateNFTClass_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateNFTClass) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateNFTClass(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Msg/CreateNFTClass", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateNFTClass(ctx, req.(*MsgCreateNFTClass)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_TransferClassOwnership_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgTransferClassOwnership) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).TransferClassOwnership(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Msg/TransferClassOwnership", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).TransferClassOwnership(ctx, req.(*MsgTransferClassOwnership)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_MintNFT_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgMintNFT) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).MintNFT(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/onft.v1.Msg/MintNFT", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).MintNFT(ctx, req.(*MsgMintNFT)) + } + return interceptor(ctx, in, info, handler) +} + +var _Msg_serviceDesc = grpc.ServiceDesc{ + ServiceName: "onft.v1.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateNFTClass", + Handler: _Msg_CreateNFTClass_Handler, + }, + { + MethodName: "TransferClassOwnership", + Handler: _Msg_TransferClassOwnership_Handler, + }, + { + MethodName: "MintNFT", + Handler: _Msg_MintNFT_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "onft/v1/tx.proto", +} + +func (m *MsgCreateNFTClass) 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 *MsgCreateNFTClass) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateNFTClass) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Sender) > 0 { + i -= len(m.Sender) + copy(dAtA[i:], m.Sender) + i = encodeVarintTx(dAtA, i, uint64(len(m.Sender))) + i-- + dAtA[i] = 0x3a + } + if m.Data != nil { + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + if len(m.UriHash) > 0 { + i -= len(m.UriHash) + copy(dAtA[i:], m.UriHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.UriHash))) + i-- + dAtA[i] = 0x2a + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x22 + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintTx(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x1a + } + if len(m.Symbol) > 0 { + i -= len(m.Symbol) + copy(dAtA[i:], m.Symbol) + i = encodeVarintTx(dAtA, i, uint64(len(m.Symbol))) + i-- + dAtA[i] = 0x12 + } + 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] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateNFTClassResponse) 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 *MsgCreateNFTClassResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateNFTClassResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTransferClassOwnership) 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 *MsgTransferClassOwnership) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransferClassOwnership) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.NewOwner) > 0 { + i -= len(m.NewOwner) + copy(dAtA[i:], m.NewOwner) + i = encodeVarintTx(dAtA, i, uint64(len(m.NewOwner))) + i-- + dAtA[i] = 0x1a + } + 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] = 0x12 + } + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgTransferClassOwnershipResponse) 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 *MsgTransferClassOwnershipResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgTransferClassOwnershipResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *MsgMintNFT) 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 *MsgMintNFT) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintNFT) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Data != nil { + { + size, err := m.Data.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTx(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x52 + } + if len(m.Receiver) > 0 { + i -= len(m.Receiver) + copy(dAtA[i:], m.Receiver) + i = encodeVarintTx(dAtA, i, uint64(len(m.Receiver))) + i-- + dAtA[i] = 0x2a + } + 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] = 0x22 + } + if len(m.UriHash) > 0 { + i -= len(m.UriHash) + copy(dAtA[i:], m.UriHash) + i = encodeVarintTx(dAtA, i, uint64(len(m.UriHash))) + i-- + dAtA[i] = 0x1a + } + if len(m.Uri) > 0 { + i -= len(m.Uri) + copy(dAtA[i:], m.Uri) + i = encodeVarintTx(dAtA, i, uint64(len(m.Uri))) + i-- + dAtA[i] = 0x12 + } + if len(m.ClassId) > 0 { + i -= len(m.ClassId) + copy(dAtA[i:], m.ClassId) + i = encodeVarintTx(dAtA, i, uint64(len(m.ClassId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgMintNFTResponse) 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 *MsgMintNFTResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgMintNFTResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTx(dAtA, i, uint64(len(m.Id))) + 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 *MsgCreateNFTClass) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Name) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Symbol) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.UriHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Data != nil { + l = m.Data.Size() + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateNFTClassResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgTransferClassOwnership) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.NewOwner) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgTransferClassOwnershipResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgMintNFT) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.ClassId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Uri) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.UriHash) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Sender) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Receiver) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + if m.Data != nil { + l = m.Data.Size() + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgMintNFTResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Id) + if l > 0 { + 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 *MsgCreateNFTClass) 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: MsgCreateNFTClass: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateNFTClass: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + 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 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Symbol", 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.Symbol = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", 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.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", 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.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UriHash", 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.UriHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = &types.Any{} + } + if err := m.Data.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Sender", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Sender = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateNFTClassResponse) 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: MsgCreateNFTClassResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateNFTClassResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Id = 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 *MsgTransferClassOwnership) 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: MsgTransferClassOwnership: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransferClassOwnership: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field NewOwner", 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.NewOwner = 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 *MsgTransferClassOwnershipResponse) 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: MsgTransferClassOwnershipResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgTransferClassOwnershipResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *MsgMintNFT) 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: MsgMintNFT: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintNFT: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ClassId", 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.ClassId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Uri", 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.Uri = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UriHash", 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.UriHash = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + 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 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Receiver", 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.Receiver = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTx + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Data == nil { + m.Data = &types.Any{} + } + if err := m.Data.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 *MsgMintNFTResponse) 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: MsgMintNFTResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgMintNFTResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 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.Id = 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 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") +) diff --git a/x/oracle/types/genesis.go b/x/oracle/types/genesis.go index 8ecefb48..2a694e45 100644 --- a/x/oracle/types/genesis.go +++ b/x/oracle/types/genesis.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" ) -// NewGenesisState creates a new GenesisState instanc e +// NewGenesisState creates a new GenesisState instance func NewGenesisState(params Params, dataSources []DataSource, oracleScripts []OracleScript) *GenesisState { return &GenesisState{ Params: params,