From 4d649e9047c02ad5186d12498956905334b5d9b8 Mon Sep 17 00:00:00 2001 From: Harish Marri Date: Sat, 28 Oct 2023 19:25:15 +0530 Subject: [PATCH] add nft-transfer module --- app/keepers/keepers.go | 34 +++++++++++++++++++++++++++++----- app/keepers/keys.go | 2 ++ app/modules.go | 8 ++++++++ go.mod | 5 +++-- go.sum | 4 ++++ 5 files changed, 46 insertions(+), 7 deletions(-) diff --git a/app/keepers/keepers.go b/app/keepers/keepers.go index 2e20bc56..b8d0edc9 100644 --- a/app/keepers/keepers.go +++ b/app/keepers/keepers.go @@ -1,6 +1,7 @@ package keepers import ( + nfttransfer "github.com/bianjieai/nft-transfer" "github.com/cometbft/cometbft/libs/log" tmos "github.com/cometbft/cometbft/libs/os" "github.com/cosmos/cosmos-sdk/baseapp" @@ -102,6 +103,9 @@ import ( streampaykeeper "github.com/OmniFlix/streampay/v2/x/streampay/keeper" streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" + + ibcnfttransferkeeper "github.com/bianjieai/nft-transfer/keeper" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" ) var tokenFactoryCapabilities = []string{ @@ -140,12 +144,14 @@ type AppKeepers struct { GlobalFeeKeeper globalfeekeeper.Keeper GroupKeeper groupkeeper.Keeper TokenFactoryKeeper tokenfactorykeeper.Keeper + IBCNFTTransferKeeper ibcnfttransferkeeper.Keeper // make scoped keepers public for test purposes - ScopedIBCKeeper capabilitykeeper.ScopedKeeper - ScopedTransferKeeper capabilitykeeper.ScopedKeeper - ScopedICAHostKeeper capabilitykeeper.ScopedKeeper - ScopedICQKeeper capabilitykeeper.ScopedKeeper + ScopedIBCKeeper capabilitykeeper.ScopedKeeper + ScopedTransferKeeper capabilitykeeper.ScopedKeeper + ScopedICAHostKeeper capabilitykeeper.ScopedKeeper + ScopedICQKeeper capabilitykeeper.ScopedKeeper + ScopedNFTTransferKeeper capabilitykeeper.ScopedKeeper AllocKeeper allockeeper.Keeper ONFTKeeper onftkeeper.Keeper @@ -205,6 +211,7 @@ func NewAppKeeper( appKeepers.ScopedTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibctransfertypes.ModuleName) appKeepers.ScopedICAHostKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icahosttypes.SubModuleName) appKeepers.ScopedICQKeeper = appKeepers.CapabilityKeeper.ScopeToModule(icqtypes.ModuleName) + appKeepers.ScopedNFTTransferKeeper = appKeepers.CapabilityKeeper.ScopeToModule(ibcnfttransfertypes.ModuleName) appKeepers.CapabilityKeeper.Seal() @@ -443,6 +450,22 @@ func NewAppKeeper( appKeepers.DistrKeeper, govModAddress, ) + + appKeepers.IBCNFTTransferKeeper = ibcnfttransferkeeper.NewKeeper( + appCodec, + keys[ibcnfttransfertypes.StoreKey], + govModAddress, + appKeepers.IBCKeeper.ChannelKeeper, + appKeepers.IBCKeeper.ChannelKeeper, + &appKeepers.IBCKeeper.PortKeeper, + appKeepers.AccountKeeper, + nil, + // ics721nft.NewICS721NftKeeper(appCodec, appKeepers.ONFTKeeper, appKeepers.AccountKeeper), + appKeepers.ScopedNFTTransferKeeper, + ) + + nfttransferIBCModule := nfttransfer.NewIBCModule(appKeepers.IBCNFTTransferKeeper) + appKeepers.MarketplaceKeeper = marketplacekeeper.NewKeeper( appCodec, appKeepers.keys[marketplacetypes.StoreKey], @@ -490,7 +513,8 @@ func NewAppKeeper( ibcRouter. AddRoute(ibctransfertypes.ModuleName, ibcStack). AddRoute(icahosttypes.SubModuleName, icaHostIBCModule). - AddRoute(icqtypes.ModuleName, icqModule) + AddRoute(icqtypes.ModuleName, icqModule). + AddRoute(ibcnfttransfertypes.ModuleName, nfttransferIBCModule) appKeepers.IBCKeeper.SetRouter(ibcRouter) diff --git a/app/keepers/keys.go b/app/keepers/keys.go index 37aae3f4..c51afee7 100644 --- a/app/keepers/keys.go +++ b/app/keepers/keys.go @@ -8,6 +8,7 @@ import ( onfttypes "github.com/OmniFlix/omniflixhub/v2/x/onft/types" tokenfactorytypes "github.com/OmniFlix/omniflixhub/v2/x/tokenfactory/types" streampaytypes "github.com/OmniFlix/streampay/v2/x/streampay/types" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" storetypes "github.com/cosmos/cosmos-sdk/store/types" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -51,6 +52,7 @@ func (appKeepers *AppKeepers) GenerateKeys() { icahosttypes.StoreKey, icqtypes.StoreKey, packetforwardtypes.StoreKey, + ibcnfttransfertypes.StoreKey, capabilitytypes.StoreKey, crisistypes.StoreKey, feegrant.StoreKey, diff --git a/app/modules.go b/app/modules.go index ddf8e2c5..92ed722d 100644 --- a/app/modules.go +++ b/app/modules.go @@ -3,6 +3,8 @@ package app import ( appparams "github.com/OmniFlix/omniflixhub/v2/app/params" "github.com/OmniFlix/omniflixhub/v2/x/globalfee" + nfttransfer "github.com/bianjieai/nft-transfer" + ibcnfttransfertypes "github.com/bianjieai/nft-transfer/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/auth" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" @@ -122,6 +124,7 @@ var ( vesting.AppModuleBasic{}, globalfee.AppModuleBasic{}, tokenfactory.AppModuleBasic{}, + nfttransfer.AppModuleBasic{}, alloc.AppModuleBasic{}, onft.AppModuleBasic{}, @@ -140,6 +143,7 @@ var ( stakingtypes.NotBondedPoolName: {authtypes.Burner, authtypes.Staking}, govtypes.ModuleName: {authtypes.Burner}, ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner}, + ibcnfttransfertypes.ModuleName: nil, icatypes.ModuleName: nil, tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, globalfee.ModuleName: nil, @@ -222,6 +226,7 @@ func appModules( transfer.NewAppModule(app.TransferKeeper), ica.NewAppModule(nil, &app.ICAHostKeeper), icq.NewAppModule(app.ICQKeeper), + nfttransfer.NewAppModule(app.IBCNFTTransferKeeper), packetforward.NewAppModule(app.PacketForwardKeeper), globalfee.NewAppModule(appCodec, app.GlobalFeeKeeper, bondDenom), alloc.NewAppModule(appCodec, app.AllocKeeper, app.GetSubspace(alloctypes.ModuleName)), @@ -301,6 +306,7 @@ func orderBeginBlockers() []string { icatypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, + ibcnfttransfertypes.ModuleName, genutiltypes.ModuleName, authz.ModuleName, authtypes.ModuleName, @@ -334,6 +340,7 @@ func orderEndBlockers() []string { icatypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, + ibcnfttransfertypes.ModuleName, minttypes.ModuleName, slashingtypes.ModuleName, distrtypes.ModuleName, @@ -387,6 +394,7 @@ func orderInitGenesis() []string { icatypes.ModuleName, icqtypes.ModuleName, packetforwardtypes.ModuleName, + ibcnfttransfertypes.ModuleName, alloctypes.ModuleName, onfttypes.ModuleName, marketplacetypes.ModuleName, diff --git a/go.mod b/go.mod index b96790e1..a502b4d2 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/OmniFlix/omniflixhub/v2 -go 1.20 +go 1.21 require ( github.com/OmniFlix/streampay/v2 v2.1.1-0.20230922163133-93e80c4663ef @@ -9,9 +9,10 @@ require ( github.com/cosmos/cosmos-proto v1.0.0-beta.2 github.com/cosmos/cosmos-sdk v0.47.5 github.com/cosmos/gogoproto v1.4.10 + github.com/bianjieai/nft-transfer v1.1.2-ibc-v6.1.0.0.20231027024800-d841419984f1 github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0 github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 - github.com/cosmos/ibc-go/v7 v7.2.0 + github.com/cosmos/ibc-go/v7 v7.3.0 github.com/golang/protobuf v1.5.3 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 diff --git a/go.sum b/go.sum index 3676a3f5..8f96158a 100644 --- a/go.sum +++ b/go.sum @@ -284,6 +284,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816 h1:41iFGWnSlI2gVpmOtVTJZNodLdLQLn/KsJqFvXwnd/s= github.com/bgentry/speakeasy v0.1.1-0.20220910012023-760eaf8b6816/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bianjieai/nft-transfer v1.1.2-ibc-v6.1.0.0.20231027024800-d841419984f1 h1:o/h+Px+W3aQ+VDq6gGWiGLq2/84YeGr6B8SFbDKLnlU= +github.com/bianjieai/nft-transfer v1.1.2-ibc-v6.1.0.0.20231027024800-d841419984f1/go.mod h1:u2PNH4v8CD4AWU4Rf7yt8/qqQtrrwwHiw03qQSKERhg= github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c= github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps= github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8= @@ -408,6 +410,8 @@ github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0 h1:mMHedP3Q+mz5gpOWNz0P+X github.com/cosmos/ibc-apps/modules/async-icq/v7 v7.0.0/go.mod h1:/P6l2bWo2AR3rrsfs0DHuFZO3Imzb93sxFD3ihrIgw4= github.com/cosmos/ibc-go/v7 v7.2.0 h1:dx0DLUl7rxdyZ8NiT6UsrbzKOJx/w7s+BOaewFRH6cg= github.com/cosmos/ibc-go/v7 v7.2.0/go.mod h1:OOcjKIRku/j1Xs1RgKK0yvKRrJ5iFuZYMetR1n3yMlc= +github.com/cosmos/ibc-go/v7 v7.3.0 h1:QtGeVMi/3JeLWuvEuC60sBHpAF40Oenx/y+bP8+wRRw= +github.com/cosmos/ibc-go/v7 v7.3.0/go.mod h1:mUmaHFXpXrEdcxfdXyau+utZf14pGKVUiXwYftRZZfQ= github.com/cosmos/ics23/go v0.10.0 h1:iXqLLgp2Lp+EdpIuwXTYIQU+AiHj9mOC2X9ab++bZDM= github.com/cosmos/ics23/go v0.10.0/go.mod h1:ZfJSmng/TBNTBkFemHHHj5YY7VAU/MBU980F4VU1NG0= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo=