Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tokenfactory #3491

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RUN apk add --no-cache $PACKAGES
ARG WASMVM_VERSION=v2.1.4
ADD https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.aarch64.a /lib/libwasmvm_muslc.aarch64.a
ADD https://github.com/CosmWasm/wasmvm/releases/download/${WASMVM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
ADD tokenfactory /src/app/tokenfactory
RUN sha256sum /lib/libwasmvm_muslc.aarch64.a | grep 090b97641157fae1ae45e7ed368a1a8c091f3fef67958d3bc7c2fa7e7c54b6b4
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep a4a3d09b36fabb65b119d5ba23442c23694401fcbee4451fe6b7e22e325a4bac
RUN cp "/lib/libwasmvm_muslc.$(uname -m).a" /lib/libwasmvm_muslc.a
Expand Down
26 changes: 26 additions & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import (
"errors"
"os"

"github.com/cosmos/gaia/v23/x/tokenfactory/bindings"
tokenfactorykeeper "github.com/cosmos/gaia/v23/x/tokenfactory/keeper"
tokenfactorytypes "github.com/cosmos/gaia/v23/x/tokenfactory/types"
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

Expand Down Expand Up @@ -113,6 +116,7 @@ type AppKeepers struct {
AuthzKeeper authzkeeper.Keeper
ConsensusParamsKeeper consensusparamkeeper.Keeper
FeeMarketKeeper *feemarketkeeper.Keeper
TokenFactoryKeeper tokenfactorykeeper.Keeper

// ICS
ProviderKeeper icsproviderkeeper.Keeper
Expand Down Expand Up @@ -482,6 +486,27 @@ func NewAppKeeper(
panic("error while reading wasm config: " + err.Error())
}

tokenFactoryCapabilities := []string{
tokenfactorytypes.EnableBurnFrom,
tokenfactorytypes.EnableForceTransfer,
tokenfactorytypes.EnableSetMetadata,
tokenfactorytypes.EnableSudoMint,
tokenfactorytypes.EnableCommunityPoolFeeFunding,
}

appKeepers.TokenFactoryKeeper = tokenfactorykeeper.NewKeeper(
appCodec,
appKeepers.keys[tokenfactorytypes.StoreKey],
maccPerms,
appKeepers.AccountKeeper,
appKeepers.BankKeeper,
appKeepers.DistrKeeper,
tokenFactoryCapabilities,
tokenfactorykeeper.DefaultIsSudoAdminFunc,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
wasmOpts = append(wasmOpts, bindings.RegisterCustomPlugins(appKeepers.BankKeeper, &appKeepers.TokenFactoryKeeper)...)

appKeepers.WasmKeeper = wasmkeeper.NewKeeper(
appCodec,
runtime.NewKVStoreService(appKeepers.keys[wasmtypes.StoreKey]),
Expand Down Expand Up @@ -588,6 +613,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino
paramsKeeper.Subspace(pfmroutertypes.ModuleName).WithKeyTable(pfmroutertypes.ParamKeyTable())
paramsKeeper.Subspace(ratelimittypes.ModuleName).WithKeyTable(ratelimittypes.ParamKeyTable())
paramsKeeper.Subspace(providertypes.ModuleName).WithKeyTable(providertypes.ParamKeyTable())
paramsKeeper.Subspace(tokenfactorytypes.ModuleName).WithKeyTable(tokenfactorytypes.ParamKeyTable())
paramsKeeper.Subspace(wasmtypes.ModuleName)

return paramsKeeper
Expand Down
2 changes: 2 additions & 0 deletions app/keepers/keys.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keepers

import (
tokenfactorytypes "github.com/cosmos/gaia/v23/x/tokenfactory/types"
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"

routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v8/packetforward/types"
Expand Down Expand Up @@ -62,6 +63,7 @@ func (appKeepers *AppKeepers) GenerateKeys() {
consensusparamtypes.StoreKey,
feemarkettypes.StoreKey,
wasmtypes.StoreKey,
tokenfactorytypes.StoreKey,
)

// Define transient store keys
Expand Down
8 changes: 8 additions & 0 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ import (

"github.com/cosmos/gaia/v23/x/metaprotocols"
metaprotocolstypes "github.com/cosmos/gaia/v23/x/metaprotocols/types"
"github.com/cosmos/gaia/v23/x/tokenfactory"
tokenfactorytypes "github.com/cosmos/gaia/v23/x/tokenfactory/types"
)

var maccPerms = map[string][]string{
Expand All @@ -81,6 +83,7 @@ var maccPerms = map[string][]string{
wasmtypes.ModuleName: {authtypes.Burner},
feemarkettypes.ModuleName: nil,
feemarkettypes.FeeCollectorName: nil,
tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner},
}

func appModules(
Expand Down Expand Up @@ -123,6 +126,7 @@ func appModules(
app.ProviderModule,
metaprotocols.NewAppModule(),
feemarket.NewAppModule(appCodec, *app.FeeMarketKeeper),
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
}
}

Expand Down Expand Up @@ -169,6 +173,7 @@ func simulationModules(
ibc.NewAppModule(app.IBCKeeper),
app.TransferModule,
app.ICAModule,
tokenfactory.NewAppModule(app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper, app.GetSubspace(tokenfactorytypes.ModuleName)),
}
}

Expand Down Expand Up @@ -212,6 +217,7 @@ func orderBeginBlockers() []string {
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
}
}

Expand Down Expand Up @@ -252,6 +258,7 @@ func orderEndBlockers() []string {
consensusparamtypes.ModuleName,
metaprotocolstypes.ModuleName,
wasmtypes.ModuleName,
tokenfactorytypes.ModuleName,
}
}

Expand Down Expand Up @@ -301,5 +308,6 @@ func orderInitBlockers() []string {
// crisis needs to be last so that the genesis state is consistent
// when it checks invariants
crisistypes.ModuleName,
tokenfactorytypes.ModuleName,
}
}
16 changes: 16 additions & 0 deletions app/upgrades/v23/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ package v23
import (
"context"

tokenfactorykeeper "github.com/cosmos/gaia/v23/x/tokenfactory/keeper"
tokenfactorytypes "github.com/cosmos/gaia/v23/x/tokenfactory/types"

errorsmod "cosmossdk.io/errors"
"cosmossdk.io/math"
upgradetypes "cosmossdk.io/x/upgrade/types"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand All @@ -27,7 +31,19 @@ func CreateUpgradeHandler(
return vm, errorsmod.Wrapf(err, "running module migrations")
}

err = setTokenFactoryParams(ctx, keepers.TokenFactoryKeeper)
if err != nil {
return vm, errorsmod.Wrapf(err, "setting token factory params")
}

ctx.Logger().Info("Upgrade v23 complete")
return vm, nil
}
}

func setTokenFactoryParams(ctx sdk.Context, keeper tokenfactorykeeper.Keeper) error {
return keeper.SetParams(ctx, tokenfactorytypes.Params{
// TODO(wllmshao): set this to a fee we agree on
DenomCreationFee: sdk.NewCoins(sdk.NewCoin("uatom", math.NewInt(1000000))),
})
}
22 changes: 13 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,26 @@ toolchain go1.22.9
require (
cosmossdk.io/api v0.7.6
cosmossdk.io/client/v2 v2.0.0-beta.7
cosmossdk.io/core v0.11.1
cosmossdk.io/core v0.12.0
cosmossdk.io/errors v1.0.1
cosmossdk.io/log v1.5.0
cosmossdk.io/math v1.4.0
cosmossdk.io/simapp v0.0.0-20240118210941-3897926e722e
cosmossdk.io/store v1.1.1
cosmossdk.io/tools/confix v0.1.2
cosmossdk.io/tools/rosetta v0.2.1-0.20230613133644-0a778132a60f
cosmossdk.io/x/circuit v0.1.1
cosmossdk.io/x/evidence v0.1.1
cosmossdk.io/x/feegrant v0.1.1
cosmossdk.io/x/nft v0.1.1
cosmossdk.io/x/tx v0.13.7
cosmossdk.io/x/upgrade v0.1.4
github.com/CosmWasm/wasmd v0.53.2
github.com/CosmWasm/wasmvm/v2 v2.1.4
github.com/cometbft/cometbft v0.38.15
github.com/cometbft/cometbft-db v0.14.1
github.com/cosmos/cosmos-db v1.1.1
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.11
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/gogoproto v1.7.0
Expand All @@ -31,6 +35,7 @@ require (
github.com/cosmos/ibc-go/modules/capability v1.0.1
github.com/cosmos/ibc-go/v8 v8.5.2
github.com/cosmos/interchain-security/v6 v6.4.0
github.com/gogo/status v1.1.0
github.com/google/gofuzz v1.2.0
github.com/gorilla/mux v1.8.1
github.com/ory/dockertest/v3 v3.11.0
Expand All @@ -42,32 +47,30 @@ require (
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.10.0
google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53
)

require (
cloud.google.com/go v0.115.0 // indirect
cloud.google.com/go/compute/metadata v0.5.2 // indirect
cloud.google.com/go/iam v1.1.9 // indirect
cloud.google.com/go/storage v1.41.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/protobuf v1.5.4
github.com/grpc-ecosystem/grpc-gateway v1.16.0
google.golang.org/genproto v0.0.0-20240701130421-f6361c86f094 // indirect
google.golang.org/grpc v1.69.2 // indirect
google.golang.org/grpc v1.69.2
)

require (
cloud.google.com/go/auth v0.6.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.2 // indirect
cosmossdk.io/collections v0.4.0 // indirect
cosmossdk.io/depinject v1.1.0 // indirect
cosmossdk.io/x/circuit v0.1.1 // indirect
cosmossdk.io/x/nft v0.1.1 // indirect
dario.cat/mergo v1.0.0 // indirect
filippo.io/edwards25519 v1.1.0 // indirect
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
github.com/99designs/keyring v1.2.2 // indirect
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/CosmWasm/wasmvm/v2 v2.1.4 // indirect
github.com/DataDog/datadog-go v3.2.0+incompatible // indirect
github.com/DataDog/zstd v1.5.5 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
Expand All @@ -94,9 +97,9 @@ require (
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/cosmos/btcutil v1.0.5 // indirect
github.com/cosmos/cosmos-proto v1.0.0-beta.5 // indirect
github.com/cosmos/gogogateway v1.2.0 // indirect
github.com/cosmos/iavl v1.2.2 // indirect
github.com/cosmos/ibc-go/modules/apps/callbacks v0.2.1-0.20231113120333-342c00b0f8bd // indirect
github.com/cosmos/ics23/go v0.11.0 // indirect
github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect
github.com/cosmos/rosetta-sdk-go v0.10.0 // indirect
Expand Down Expand Up @@ -238,14 +241,13 @@ require (
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
google.golang.org/api v0.186.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20241015192408-796eee8c2d53 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.5.1 // indirect
nhooyr.io/websocket v1.8.6 // indirect
nhooyr.io/websocket v1.8.10 // indirect
pgregory.net/rapid v1.1.0 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Expand All @@ -254,6 +256,8 @@ replace (
// Use version with lsm changes
cosmossdk.io/api => github.com/informalsystems/cosmos-sdk/api v0.7.5-lsm

cosmossdk.io/core => cosmossdk.io/core v0.11.1

// Use cosmos keyring
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0

Expand Down
Loading
Loading