Skip to content

Commit

Permalink
Add genesis logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jcompagni10 committed Jun 18, 2024
1 parent 1ec8d8c commit 55b431a
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 13 deletions.
1 change: 1 addition & 0 deletions proto/osmosis/tokenfactory/v1beta1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ message GenesisDenom {
(gogoproto.moretags) = "yaml:\"authority_metadata\"",
(gogoproto.nullable) = false
];
bool whitelisted = 3 [(gogoproto.moretags) = "yaml:\"whitelisted\""];
}
2 changes: 1 addition & 1 deletion x/tokenfactory/keeper/before_send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (suite *KeeperTestSuite) TestTrackBeforeSendWasm() {
queryResp, err = suite.GetNeutronZoneApp(suite.ChainA).WasmKeeper.QuerySmart(suite.ChainA.GetContext(), cosmwasmAddress, []byte(`{"total_supply_at":{}}`))
suite.Require().NoError(err)

//Whitelisted contract has now been called
// Whitelisted contract has now been called
suite.Require().Equal("\"100\"", string(queryResp))
})
}
Expand Down
4 changes: 4 additions & 0 deletions x/tokenfactory/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func (k Keeper) InitGenesis(ctx sdk.Context, genState types.GenesisState) {
if err != nil {
panic(err)
}

k.setIsWhitelistedDenom(ctx, genDenom.GetDenom(), genDenom.GetWhitelisted())
}
}

Expand All @@ -47,10 +49,12 @@ func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState {
if err != nil {
panic(err)
}
whitelisted := k.getIsWhitelistedDenom(ctx, denom)

genDenoms = append(genDenoms, types.GenesisDenom{
Denom: denom,
AuthorityMetadata: authorityMetadata,
Whitelisted: whitelisted,
})
}

Expand Down
2 changes: 2 additions & 0 deletions x/tokenfactory/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func (suite *KeeperTestSuite) TestGenesis() {
AuthorityMetadata: types.DenomAuthorityMetadata{
Admin: "neutron1m9l358xunhhwds0568za49mzhvuxx9ux8xafx2",
},
Whitelisted: true,
},
},
}
Expand All @@ -45,4 +46,5 @@ func (suite *KeeperTestSuite) TestGenesis() {
exportedGenesis := app.TokenFactoryKeeper.ExportGenesis(context)
suite.Require().NotNil(exportedGenesis)
suite.Require().Equal(genesisState, *exportedGenesis)

}
3 changes: 2 additions & 1 deletion x/tokenfactory/keeper/whitelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/neutron-org/neutron/v4/x/tokenfactory/types"
)

Expand All @@ -10,7 +11,7 @@ var isWhitelistedBz = []byte{1}
func (k Keeper) setIsWhitelistedDenom(ctx sdk.Context, denom string, isWhitelisted bool) {
store := k.GetDenomPrefixStore(ctx, denom)
if isWhitelisted {
store.Set([]byte(types.WhitelistPrefixKey), []byte{1})
store.Set([]byte(types.WhitelistPrefixKey), isWhitelistedBz)
} else {
store.Delete([]byte(types.WhitelistPrefixKey))
}
Expand Down
63 changes: 55 additions & 8 deletions x/tokenfactory/types/genesis.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions x/tokenfactory/types/tx.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 55b431a

Please sign in to comment.