Skip to content

Commit

Permalink
v10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Brady Lee authored and Brady Lee committed Nov 27, 2023
1 parent 63f72ca commit 9d7f074
Show file tree
Hide file tree
Showing 49 changed files with 4,142 additions and 4,925 deletions.
Binary file added curium/.DS_Store
Binary file not shown.
411 changes: 205 additions & 206 deletions curium/app/ante/NewSetupContextDecorator_test.go

Large diffs are not rendered by default.

43 changes: 4 additions & 39 deletions curium/app/app.go
@@ -1,21 +1,16 @@
package app

import (
"fmt"
"io"
"net/http"
"os"
"path/filepath"
"strings"

ipfsConfig "github.com/bluzelle/ipfs-kubo/config"

appAnte "github.com/bluzelle/bluzelle-public/curium/app/ante"
"github.com/bluzelle/bluzelle-public/curium/app/ante/gasmeter"
appTypes "github.com/bluzelle/bluzelle-public/curium/app/types"
"github.com/bluzelle/bluzelle-public/curium/x/curium"
curiumipfs "github.com/bluzelle/bluzelle-public/curium/x/storage-ipfs/ipfs"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/x/auth/ante"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand Down Expand Up @@ -106,9 +101,6 @@ import (
curiummodule "github.com/bluzelle/bluzelle-public/curium/x/curium"
curiummodulekeeper "github.com/bluzelle/bluzelle-public/curium/x/curium/keeper"
curiummoduletypes "github.com/bluzelle/bluzelle-public/curium/x/curium/types"
faucetmodule "github.com/bluzelle/bluzelle-public/curium/x/faucet"
faucetmodulekeeper "github.com/bluzelle/bluzelle-public/curium/x/faucet/keeper"
faucetmoduletypes "github.com/bluzelle/bluzelle-public/curium/x/faucet/types"
"github.com/bluzelle/bluzelle-public/curium/x/nft"
nftmodule "github.com/bluzelle/bluzelle-public/curium/x/nft"
nftkeeper "github.com/bluzelle/bluzelle-public/curium/x/nft/keeper"
Expand Down Expand Up @@ -169,7 +161,6 @@ var (
authzmodule.AppModuleBasic{},
curiummodule.AppModuleBasic{},
storagemodule.AppModuleBasic{},
faucetmodule.AppModuleBasic{},
taxmodule.AppModuleBasic{},
nft.AppModuleBasic{},
// this line is used by starport scaffolding # stargate/app/moduleBasic
Expand All @@ -185,7 +176,6 @@ var (
govtypes.ModuleName: {authtypes.Burner},
ibctransfertypes.ModuleName: {authtypes.Minter, authtypes.Burner},
nfttypes.ModuleName: {authtypes.Minter, authtypes.Burner},
faucetmoduletypes.ModuleName: {authtypes.Minter, authtypes.Burner, authtypes.Staking},
taxmoduletypes.ModuleName: nil,
// this line is used by starport scaffolding # stargate/app/maccPerms
}
Expand Down Expand Up @@ -250,8 +240,6 @@ type App struct {

StorageKeeper storagemodulekeeper.Keeper

FaucetKeeper faucetmodulekeeper.Keeper

TaxKeeper taxmodulekeeper.Keeper
// this line is used by starport scaffolding # stargate/app/keeperDeclaration

Expand Down Expand Up @@ -289,7 +277,6 @@ func NewCuriumApp(
evidencetypes.StoreKey, ibctransfertypes.StoreKey, capabilitytypes.StoreKey,
curiummoduletypes.StoreKey,
storagemoduletypes.StoreKey,
faucetmoduletypes.StoreKey,
taxmoduletypes.StoreKey,
nfttypes.StoreKey,
authzkeeper.StoreKey, icahosttypes.StoreKey,
Expand Down Expand Up @@ -349,7 +336,6 @@ func NewCuriumApp(

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp)
//app.UpgradeKeeper.SetUpgradeHandler("Upgrade 1", firstupgrade.CreateUpgradeHandler(app.mm, app.Configurator))

// register the staking hooks
// NOTE: stakingKeeper above is passed by reference, so that it will contain these hooks
Expand Down Expand Up @@ -413,9 +399,7 @@ func NewCuriumApp(
curiumModule := curiummodule.NewAppModule(appCodec, &app.CuriumKeeper)

storageDir := appOpts.Get("storage-dir").(string)
filter := appOpts.Get("filter").(string)
fmt.Println(filter)
storageNode, err := startupStorageNode(storageDir, filter)
storageNode, err := startupStorageNode(storageDir)

app.StorageKeeper = *storagemodulekeeper.NewKeeper(
appCodec,
Expand All @@ -426,18 +410,6 @@ func NewCuriumApp(
)
storageModule := storagemodule.NewAppModule(appCodec, app.StorageKeeper)

app.FaucetKeeper = *faucetmodulekeeper.NewKeeper(
appCodec,
keys[faucetmoduletypes.StoreKey],
keys[faucetmoduletypes.MemStoreKey],
app.GetSubspace(faucetmoduletypes.ModuleName),
app.BankKeeper,
curium.NewKeyRingReader(appOpts.Get(flags.FlagHome).(string)),
curiummodulekeeper.NewMsgBroadcaster(&app.AccountKeeper, cast.ToString(appOpts.Get(flags.FlagHome))),
)

faucetModule := faucetmodule.NewAppModule(appCodec, app.FaucetKeeper, app.AccountKeeper, app.BankKeeper)

app.TaxKeeper = *taxmodulekeeper.NewKeeper(
appCodec,
keys[taxmoduletypes.StoreKey],
Expand Down Expand Up @@ -492,7 +464,6 @@ func NewCuriumApp(
transferModule,
&curiumModule,
storageModule,
faucetModule,
taxModule,
nftModule,
// this line is used by starport scaffolding # stargate/app/appModule
Expand Down Expand Up @@ -522,7 +493,6 @@ func NewCuriumApp(
genutiltypes.ModuleName,
authtypes.ModuleName,
banktypes.ModuleName,
faucetmoduletypes.ModuleName,
crisistypes.ModuleName,
taxmoduletypes.ModuleName,
storagemoduletypes.ModuleName,
Expand All @@ -546,7 +516,6 @@ func NewCuriumApp(
genutiltypes.ModuleName,
authtypes.ModuleName,
ibctransfertypes.ModuleName,
faucetmoduletypes.ModuleName,
banktypes.ModuleName,
capabilitytypes.ModuleName,
evidencetypes.ModuleName,
Expand Down Expand Up @@ -578,7 +547,6 @@ func NewCuriumApp(
nfttypes.ModuleName,
curiummoduletypes.ModuleName,
storagemoduletypes.ModuleName,
faucetmoduletypes.ModuleName,
taxmoduletypes.ModuleName,

paramstypes.ModuleName,
Expand All @@ -593,7 +561,6 @@ func NewCuriumApp(
app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino)
app.Configurator = module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())
app.mm.RegisterServices(app.Configurator)

// initialize stores
app.MountKVStores(keys)
app.MountTransientStores(tkeys)
Expand All @@ -620,6 +587,7 @@ func NewCuriumApp(

app.SetAnteHandler(anteHandler)
app.SetEndBlocker(app.EndBlocker)
app.setupUpgradeHandlers(app.Configurator)

if loadLatest {
if err := app.LoadLatestVersion(); err != nil {
Expand Down Expand Up @@ -661,16 +629,14 @@ func New(
)
}

func startupStorageNode(storageDir string, filter string) (*curiumipfs.StorageIpfsNode, error) {
func startupStorageNode(storageDir string) (*curiumipfs.StorageIpfsNode, error) {
homeDir, err := os.UserHomeDir()
if err != nil {
return nil, err
}
storageDir = strings.ReplaceAll(storageDir, "~", homeDir)

err = storagemodulekeeper.CreateRepoIfNotExist(storageDir, curiumipfs.CreateRepoOptions{
Transformer: ipfsConfig.Profiles[filter].Transform,
})
err = storagemodulekeeper.CreateRepoIfNotExist(storageDir, curiumipfs.CreateRepoOptions{})
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -823,7 +789,6 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(ibchost.ModuleName)
paramsKeeper.Subspace(curiummoduletypes.ModuleName)
paramsKeeper.Subspace(storagemoduletypes.ModuleName)
paramsKeeper.Subspace(faucetmoduletypes.ModuleName)
paramsKeeper.Subspace(taxmoduletypes.ModuleName)
paramsKeeper.Subspace(nfttypes.ModuleName)

Expand Down
25 changes: 25 additions & 0 deletions curium/app/upgrades.go
@@ -0,0 +1,25 @@
package app

import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
)

func (app *App) setupUpgradeHandlers(
configurator module.Configurator,
) {
app.UpgradeKeeper.SetUpgradeHandler("10.0", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
return app.mm.RunMigrations(ctx, configurator, fromVM)
})
var storeUpgrades *storetypes.StoreUpgrades

storeUpgrades = &storetypes.StoreUpgrades{
Deleted: []string{"faucet"},
}

if storeUpgrades != nil {
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(3333333, storeUpgrades))
}
}

0 comments on commit 9d7f074

Please sign in to comment.