Skip to content

Commit

Permalink
add nft-transfer module
Browse files Browse the repository at this point in the history
  • Loading branch information
harish551 committed Oct 28, 2023
1 parent 34dae59 commit 4d649e9
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 7 deletions.
34 changes: 29 additions & 5 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -51,6 +52,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
icahosttypes.StoreKey,
icqtypes.StoreKey,
packetforwardtypes.StoreKey,
ibcnfttransfertypes.StoreKey,
capabilitytypes.StoreKey,
crisistypes.StoreKey,
feegrant.StoreKey,
Expand Down
8 changes: 8 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -122,6 +124,7 @@ var (
vesting.AppModuleBasic{},
globalfee.AppModuleBasic{},
tokenfactory.AppModuleBasic{},
nfttransfer.AppModuleBasic{},

alloc.AppModuleBasic{},
onft.AppModuleBasic{},
Expand All @@ -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,
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -301,6 +306,7 @@ func orderBeginBlockers() []string {
icatypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
ibcnfttransfertypes.ModuleName,
genutiltypes.ModuleName,
authz.ModuleName,
authtypes.ModuleName,
Expand Down Expand Up @@ -334,6 +340,7 @@ func orderEndBlockers() []string {
icatypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
ibcnfttransfertypes.ModuleName,
minttypes.ModuleName,
slashingtypes.ModuleName,
distrtypes.ModuleName,
Expand Down Expand Up @@ -387,6 +394,7 @@ func orderInitGenesis() []string {
icatypes.ModuleName,
icqtypes.ModuleName,
packetforwardtypes.ModuleName,
ibcnfttransfertypes.ModuleName,
alloctypes.ModuleName,
onfttypes.ModuleName,
marketplacetypes.ModuleName,
Expand Down
5 changes: 3 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down

0 comments on commit 4d649e9

Please sign in to comment.