Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…-cosmos into develop2
  • Loading branch information
hoank101 committed Apr 25, 2024
2 parents 53c857e + b67db99 commit 299753b
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 37 deletions.
10 changes: 5 additions & 5 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# .goreleaser.yml

project_name: centaurid
project_name: picad

env:
- CGO_ENABLED=1

builds:
- id: linux
main: ./cmd/centaurid
binary: centaurid
main: ./cmd/picad
binary: picad
hooks:
pre:
- cmd: bash scripts/release_pre_linux.sh
Expand All @@ -28,8 +28,8 @@ builds:
- -mod=readonly
- -trimpath
ldflags:
- -X github.com/cosmos/cosmos-sdk/version.Name=centauri
- -X github.com/cosmos/cosmos-sdk/version.AppName=centaurid
- -X github.com/cosmos/cosmos-sdk/version.Name=pica
- -X github.com/cosmos/cosmos-sdk/version.AppName=picad
- -X github.com/cosmos/cosmos-sdk/version.Version={{ .Version }}
- -X github.com/cosmos/cosmos-sdk/version.Commit={{ .Commit }}
- -X "github.com/cosmos/cosmos-sdk/version.BuildTags=netgo,ledger,muslc"
Expand Down
13 changes: 12 additions & 1 deletion app/ibctesting/simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ import (
simappupgrades "github.com/notional-labs/composable/v6/app/ibctesting/simapp/upgrades"
v6 "github.com/notional-labs/composable/v6/app/ibctesting/simapp/upgrades/v6"
v7 "github.com/notional-labs/composable/v6/app/ibctesting/simapp/upgrades/v7"
ibctransfermiddleware "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/keeper"
ibctransfermiddlewaretypes "github.com/notional-labs/composable/v6/x/ibctransfermiddleware/types"
transfermiddleware "github.com/notional-labs/composable/v6/x/transfermiddleware"
transfermiddlewarekeeper "github.com/notional-labs/composable/v6/x/transfermiddleware/keeper"
transfermiddlewaretypes "github.com/notional-labs/composable/v6/x/transfermiddleware/types"
Expand Down Expand Up @@ -258,7 +260,8 @@ type SimApp struct {
ICAAuthModule ibcmock.IBCModule
FeeMockModule ibcmock.IBCModule

TransferMiddlewarekeeper transfermiddlewarekeeper.Keeper
TransferMiddlewarekeeper transfermiddlewarekeeper.Keeper
IbcTransferMiddlewareKeeper ibctransfermiddleware.Keeper

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -378,13 +381,21 @@ func NewSimApp(

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())
app.IbcTransferMiddlewareKeeper = ibctransfermiddleware.NewKeeper(appCodec, keys[ibctransfermiddlewaretypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String(),
[]string{
"pica1ay9y5uns9khw2kzaqr3r33v2pkuptfnnunlt5x",
"pica14lz7gaw92valqjearnye4shex7zg2p05yfguqm",
"pica1r2zlh2xn85v8ljmwymnfrnsmdzjl7k6w9f2ja8",
"pica10556m38z4x6pqalr9rl5ytf3cff8q46nf36090",
})
app.TransferMiddlewarekeeper = transfermiddlewarekeeper.NewKeeper(
keys[transfermiddlewaretypes.StoreKey],
app.GetSubspace(transfermiddlewaretypes.ModuleName),
appCodec,
app.IBCKeeper.ChannelKeeper,
app.TransferKeeper,
app.BankKeeper,
&app.IbcTransferMiddlewareKeeper,
authtypes.NewModuleAddress(govtypes.ModuleName).String(),
)
app.AuthzKeeper = authzkeeper.NewKeeper(keys[authzkeeper.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper)
Expand Down
1 change: 1 addition & 0 deletions app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ func (appKeepers *AppKeepers) InitNormalKeepers(
&appKeepers.RatelimitKeeper,
&appKeepers.TransferKeeper,
appKeepers.BankKeeper,
&appKeepers.IbcTransferMiddlewareKeeper,
authorityAddress,
)

Expand Down
4 changes: 4 additions & 0 deletions app/upgrades/v6_6_0/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import (
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
icahosttypes "github.com/cosmos/ibc-go/v7/modules/apps/27-interchain-accounts/host/types"

"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/app/upgrades"
bech32authmigration "github.com/notional-labs/composable/v6/bech32-migration/auth"
bech32govmigration "github.com/notional-labs/composable/v6/bech32-migration/gov"
bech32icamigration "github.com/notional-labs/composable/v6/bech32-migration/ica"
bech32mintmigration "github.com/notional-labs/composable/v6/bech32-migration/mint"
bech32PfmMigration "github.com/notional-labs/composable/v6/bech32-migration/pfmmiddleware"
bech32slashingmigration "github.com/notional-labs/composable/v6/bech32-migration/slashing"
bech32stakingmigration "github.com/notional-labs/composable/v6/bech32-migration/staking"
bech32transfermiddlewaremigration "github.com/notional-labs/composable/v6/bech32-migration/transfermiddleware"
Expand Down Expand Up @@ -45,6 +48,7 @@ func CreateUpgradeHandler(
bech32mintmigration.MigrateAddressBech32(ctx, keys[minttypes.StoreKey], codec)
bech32transfermiddlewaremigration.MigrateAddressBech32(ctx, keys[transfermiddlewaretypes.StoreKey], codec)
bech32WasmMigration.MigrateAddressBech32(ctx, keys[wasm.StoreKey], codec)
bech32PfmMigration.MigrateAddressBech32(ctx, keys[routertypes.StoreKey], codec, keepers)
return mm.RunMigrations(ctx, configurator, vm)
}
}
42 changes: 42 additions & 0 deletions app/upgrades/v6_6_0/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
apptesting "github.com/notional-labs/composable/v6/app"
"github.com/notional-labs/composable/v6/bech32-migration/utils"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -58,6 +59,7 @@ func (s *UpgradeTestSuite) TestForMigratingNewPrefix() {
prepareForTestingICAHostModule(s)
prepareForTestingMintModule(s)
prepareForTestingTransferMiddlewareModule(s)
prepareForTestingPfmMiddlewareModule(s)

/* == UPGRADE == */
upgradeHeight := int64(5)
Expand All @@ -72,6 +74,7 @@ func (s *UpgradeTestSuite) TestForMigratingNewPrefix() {
checkUpgradeICAHostModule(s)
checkUpgradeMintModule(s)
checkUpgradeTransferMiddlewareModule(s)
checkUpgradePfmMiddlewareModule(s)
}

func prepareForTestingGovModule(s *UpgradeTestSuite) (sdk.AccAddress, govtypes.Proposal) {
Expand Down Expand Up @@ -214,6 +217,37 @@ func prepareForTestingTransferMiddlewareModule(s *UpgradeTestSuite) {
s.App.TransferMiddlewareKeeper.SetAllowRlyAddress(s.Ctx, acc1.String())
}

func prepareForTestingPfmMiddlewareModule(s *UpgradeTestSuite) {
store := s.Ctx.KVStore(s.App.GetKey(routertypes.StoreKey))
inFlightPacket := routertypes.InFlightPacket{
PacketData: []byte("{\"amount\":\"10000\",\"denom\":\"transfer/channel-6660/ppica\",\"memo\":\"{\\\"forward\\\":{\\\"receiver\\\":\\\"osmo1wkjvpgkuchq0r8425g4z4sf6n85zj5wth3u77y\\\",\\\"port\\\":\\\"transfer\\\",\\\"channel\\\":\\\"channel-9\\\",\\\"timeout\\\":600000000000,\\\"retries\\\":0}}\",\"receiver\":\"centauri1wkjvpgkuchq0r8425g4z4sf6n85zj5wtmqzjv9\",\"sender\":\"osmo1wkjvpgkuchq0r8425g4z4sf6n85zj5wth3u77y\"}"),
OriginalSenderAddress: "centauri1wkjvpgkuchq0r8425g4z4sf6n85zj5wtmqzjv9",
RefundChannelId: "channel-9",
RefundPortId: "transfer",
RefundSequence: 18,
PacketSrcPortId: "transfer",
PacketSrcChannelId: "channel-66660",

PacketTimeoutTimestamp: 1712153063084849609,
PacketTimeoutHeight: "5-123",

RetriesRemaining: int32(0),
Timeout: uint64(600000000000),
Nonrefundable: false,
}

encCdc := apptesting.MakeEncodingConfig()

key := routertypes.RefundPacketKey("channel-9", "transfer", 0)
bz := encCdc.Amino.MustMarshal(&inFlightPacket)
store.Set(key, bz)

key = routertypes.RefundPacketKey("channel-9", "transfer", 2)
inFlightPacket.OriginalSenderAddress = "centauri1hj5fveer5cjtn4wd6wstzugjfdxzl0xpzxlwgs"
bz = encCdc.Amino.MustMarshal(&inFlightPacket)
store.Set(key, bz)
}

func checkUpgradeGovModule(s *UpgradeTestSuite, acc1 sdk.AccAddress, proposal govtypes.Proposal) {
// CONVERT ACC TO NEW PREFIX
_, bz, _ := bech32.DecodeAndConvert(acc1.String())
Expand Down Expand Up @@ -409,6 +443,14 @@ func checkUpgradeTransferMiddlewareModule(s *UpgradeTestSuite) {
s.Suite.Equal(found, true)
}

func checkUpgradePfmMiddlewareModule(s *UpgradeTestSuite) {
data := s.App.RouterKeeper.GetAndClearInFlightPacket(s.Ctx, "channel-9", "transfer", 0)
s.Suite.Equal("pica1wkjvpgkuchq0r8425g4z4sf6n85zj5wtykvtv3", data.OriginalSenderAddress)

data = s.App.RouterKeeper.GetAndClearInFlightPacket(s.Ctx, "channel-9", "transfer", 2)
s.Suite.Equal("pica1hj5fveer5cjtn4wd6wstzugjfdxzl0xpas3hgy", data.OriginalSenderAddress)
}

func CreateVestingAccount(s *UpgradeTestSuite,
) vestingtypes.ContinuousVestingAccount {
str := `{"@type":"/cosmos.vesting.v1beta1.ContinuousVestingAccount","base_vesting_account":{"base_account":{"address":"centauri1alga5e8vr6ccr9yrg0kgxevpt5xgmgrvfkc5p8","pub_key":{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":4,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AlnzK22KrkylnvTCvZZc8eZnydtQuzCWLjJJSMFUvVHf"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Aiw2Ftg+fnoHDU7M3b0VMRsI0qurXlerW0ahtfzSDZA4"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AvEHv+MVYRVau8FbBcJyG0ql85Tbbn7yhSA0VGmAY4ku"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Az5VHWqi3zMJu1rLGcu2EgNXLLN+al4Dy/lj6UZTzTCl"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Ai4GlSH3uG+joMnAFbQC3jQeHl9FPvVTlRmwIFt7d7TI"},{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"A2kAzH2bZr530jmFq/bRFrT2q8SRqdnfIebba+YIBqI1"}]},"account_number":46,"sequence":27},"original_vesting":[{"denom":"stake","amount":"22165200000000"}],"delegated_free":[{"denom":"stake","amount":"443382497453"}],"delegated_vesting":[{"denom":"stake","amount":"22129422502547"}],"end_time":1770994800},"start_time":1676300400}`
Expand Down
67 changes: 67 additions & 0 deletions bech32-migration/pfmmiddleware/pfmmiddleware.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package pfmmiddleware

import (
"encoding/json"

"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
routertypes "github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7/packetforward/types"
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types"
"github.com/notional-labs/composable/v6/app/keepers"
"github.com/notional-labs/composable/v6/bech32-migration/utils"
)

func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec, keepers *keepers.AppKeepers) {
ctx.Logger().Info("Migration of address bech32 for pfmmiddleware module begin")
totalAddr := uint64(0)

store := ctx.KVStore(storeKey)

channelKey := []byte("channel")
iterator := sdk.KVStorePrefixIterator(store, channelKey)
for ; iterator.Valid(); iterator.Next() {
totalAddr++
fullKey := iterator.Key()
if !store.Has(fullKey) {
continue
}
bz := store.Get(fullKey)
var inFlightPacket routertypes.InFlightPacket
cdc.MustUnmarshal(bz, &inFlightPacket)
inFlightPacket.OriginalSenderAddress = utils.SafeConvertAddress(inFlightPacket.OriginalSenderAddress)
var data transfertypes.FungibleTokenPacketData
if err := transfertypes.ModuleCdc.UnmarshalJSON(inFlightPacket.PacketData, &data); err != nil {
continue
}
data.Receiver = utils.SafeConvertAddress(data.Receiver)
data.Sender = utils.SafeConvertAddress(data.Sender)

d := make(map[string]interface{})
err := json.Unmarshal([]byte(data.Memo), &d)
// parse memo
if err == nil && d["forward"] != nil {
var m routertypes.PacketMetadata
err = json.Unmarshal([]byte(data.Memo), &m)
if err != nil {
continue
}
m.Forward.Receiver = utils.SafeConvertAddress(m.Forward.Receiver)
bzM, err := json.Marshal(m)
if err != nil {
continue
}
data.Memo = string(bzM)
}
bz = cdc.MustMarshal(&data)
inFlightPacket.PacketData = bz
bz = cdc.MustMarshal(&inFlightPacket)
totalAddr++
store.Set(fullKey, bz)
}

ctx.Logger().Info(
"Migration of address bech32 for pfmmiddleware module done",
"totalAddr", totalAddr,
)
}
4 changes: 0 additions & 4 deletions bech32-migration/transfermiddleware/transfermiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ func MigrateAddressBech32(ctx sdk.Context, storeKey storetypes.StoreKey, cdc cod
newPrefixAddr := utils.ConvertAccAddr(trimedAddr)
store.Set(types.GetKeyByRlyAddress(newPrefixAddr), relayAddressPrefix)
}
if allowRelayAddressCount == 0 {
// TODO: only using in localtest
store.Set(types.GetKeyByRlyAddress("pica12smx2wdlyttvyzvzg54y2vnqwq2qjate0ww798"), relayAddressPrefix)
}

ctx.Logger().Info(
"Migration of address bech32 for transfermiddleware module done",
Expand Down
2 changes: 1 addition & 1 deletion custom/ibc-transfer/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (k msgServer) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*typ

newAmount := msg.Token.Amount.Sub(charge)

if newAmount.IsPositive() {
if newAmount.IsPositive() && coin.Percentage != 0 {
percentageCharge := newAmount.QuoRaw(coin.Percentage)
newAmount = newAmount.Sub(percentageCharge)
charge = charge.Add(percentageCharge)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ replace (

github.com/cosmos/ibc-apps/middleware/packet-forward-middleware/v7 => github.com/ComposableFi/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0-20240320115741-f32994360827
// ibc-go with wasm client
github.com/cosmos/ibc-go/v7 => github.com/notional-labs/ibc-go/v7 v7.2.1-0.20240411073925-d50434ebb89a
github.com/cosmos/ibc-go/v7 => github.com/ComposableFi/ibc-go/v7 v7.0.0-20240417235838-759a4130305e

github.com/syndtr/goleveldb => github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
github.com/terra-money/alliance => github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQ
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
github.com/ComposableFi/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0-20240320115741-f32994360827 h1:PkDT2gEjAgttuF9lZTP+niYjcXutnmqHHK2UaAL9bLs=
github.com/ComposableFi/ibc-apps/middleware/packet-forward-middleware/v7 v7.0.0-20240320115741-f32994360827/go.mod h1:3PHOr4UiPNtnZJutT22fm5+pjIefTlDEgtWGoOJg3A0=
github.com/ComposableFi/ibc-go/v7 v7.0.0-20240417235838-759a4130305e h1:1X7RvVEC9FfJIZl0FUPVN/SFzHkYKaZjYkZb9+kDmAk=
github.com/ComposableFi/ibc-go/v7 v7.0.0-20240417235838-759a4130305e/go.mod h1:hjcl3RPLSDf0LSXrFyk2iTQCCFs5pfLbJb8h/5gJ2Vg=
github.com/CosmWasm/wasmd v0.40.1 h1:LxbO78t/6S8TkeQlUrJ0m5O87HtAwLx4RGHq3rdrOEU=
github.com/CosmWasm/wasmd v0.40.1/go.mod h1:6EOwnv7MpuFaEqxcUOdFV9i4yvrdOciaY6VQ1o7A3yg=
github.com/CosmWasm/wasmvm v1.2.6 h1:QmOaiJUyeh8+pPCjJBTgWrbi/hCzCuWewduDO85Pcpc=
Expand Down Expand Up @@ -970,8 +972,6 @@ github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647 h1:vCSokMIO60u0td51l7NB+pikUChJozIwIb4u8UeqTKI=
github.com/notional-labs/alliance v1.0.1-0.20231106184124-5cc1ff759647/go.mod h1:GFQ8TsXDMTpu7kif0Dwddz6rxazy0ZJQHfN38ZmAodI=
github.com/notional-labs/ibc-go/v7 v7.2.1-0.20240411073925-d50434ebb89a h1:RyNoU/JH092wEuvAZBzowQsScpcSEC+yqlySqH7NsWs=
github.com/notional-labs/ibc-go/v7 v7.2.1-0.20240411073925-d50434ebb89a/go.mod h1:hjcl3RPLSDf0LSXrFyk2iTQCCFs5pfLbJb8h/5gJ2Vg=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/oklog/oklog v0.3.2/go.mod h1:FCV+B7mhrz4o+ueLpx+KqkyXRGMWOYEvfiXtdGtbWGs=
Expand Down
18 changes: 9 additions & 9 deletions scripts/testnode.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ DENOM=${2:-ppica}
# remove existing daemon
rm -rf ~/.banksy*

centaurid config keyring-backend $KEYRING
centaurid config chain-id $CHAINID
picad config keyring-backend $KEYRING
picad config chain-id $CHAINID

# if $KEY exists it should be deleted
echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | centaurid keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover
echo "decorate bright ozone fork gallery riot bus exhaust worth way bone indoor calm squirrel merry zero scheme cotton until shop any excess stage laundry" | picad keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO --recover

centaurid init $MONIKER --chain-id $CHAINID
picad init $MONIKER --chain-id $CHAINID

update_test_genesis () {
# update_test_genesis '.consensus_params["block"]["max_gas"]="100000000"'
cat $HOME_DIR/config/genesis.json | jq "$1" > $HOME_DIR/config/tmp_genesis.json && mv $HOME_DIR/config/tmp_genesis.json $HOME_DIR/config/genesis.json
}

# Allocate genesis accounts (cosmos formatted addresses)
centaurid add-genesis-account $KEY 100000000000000000000000000ppica --keyring-backend $KEYRING
picad add-genesis-account $KEY 100000000000000000000000000ppica --keyring-backend $KEYRING

# Sign genesis transaction
centaurid gentx $KEY 10030009994127689ppica --keyring-backend $KEYRING --chain-id $CHAINID
picad gentx $KEY 10030009994127689ppica --keyring-backend $KEYRING --chain-id $CHAINID

update_test_genesis '.app_state["gov"]["params"]["voting_period"]="20s"'
update_test_genesis '.app_state["mint"]["params"]["mint_denom"]="'$DENOM'"'
Expand All @@ -43,10 +43,10 @@ update_test_genesis '.app_state["crisis"]["constant_fee"]={"denom":"'$DENOM'","a
update_test_genesis '.app_state["staking"]["params"]["bond_denom"]="'$DENOM'"'

# Collect genesis tx
centaurid collect-gentxs
picad collect-gentxs

# Run this to ensure everything worked and that the genesis file is setup correctly
centaurid validate-genesis
picad validate-genesis

if [[ $1 == "pending" ]]; then
echo "pending mode is on, please wait for the first block committed."
Expand All @@ -57,4 +57,4 @@ fi
sed -i'' -e 's/max_body_bytes = /max_body_bytes = 1/g' ~/.banksy/config/config.toml

# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
# centaurid start --pruning=nothing --minimum-gas-prices=0.0001ppica --rpc.laddr tcp://0.0.0.0:26657
picad start --pruning=nothing --minimum-gas-prices=0.0001ppica --rpc.laddr tcp://0.0.0.0:26657
18 changes: 18 additions & 0 deletions x/ibctransfermiddleware/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,21 @@ func (k Keeper) GetParams(ctx sdk.Context) (p types.Params) {
k.cdc.MustUnmarshal(bz, &p)
return p
}

func (k Keeper) GetCoin(ctx sdk.Context, targetChannelID, denom string) *types.CoinItem {
params := k.GetParams(ctx)
channelFee := findChannelParams(params.ChannelFees, targetChannelID)
if channelFee == nil {
return nil
}
return findCoinByDenom(channelFee.AllowedTokens, denom)
}

func (k Keeper) GetChannelFeeAddress(ctx sdk.Context, targetChannelID string) string {
params := k.GetParams(ctx)
channelFee := findChannelParams(params.ChannelFees, targetChannelID)
if channelFee == nil {
return ""
}
return channelFee.FeeAddress
}
Loading

0 comments on commit 299753b

Please sign in to comment.