Skip to content

Commit

Permalink
fix: init bridge call from account (#548)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored Jun 4, 2024
1 parent 7e7224e commit 812df7d
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/upgrades/v7/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
autytypes "github.com/cosmos/cosmos-sdk/x/auth/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/functionx/fx-core/v7/app/keepers"
Expand All @@ -30,6 +31,10 @@ func CreateUpgradeHandler(mm *module.Manager, configurator module.Configurator,
UpdateFIP20LogicCode(cacheCtx, app.EvmKeeper)
CleanCrosschainAttestations(ctx, app.AppCodec(), app.GetKey(ethtypes.ModuleName))
CleanCrosschainAttestations(ctx, app.AppCodec(), app.GetKey(layer2types.ModuleName))
crosschainBridgeCallFrom := autytypes.NewModuleAddress(crosschaintypes.ModuleName)
if account := app.AccountKeeper.GetAccount(ctx, crosschainBridgeCallFrom); account == nil {
app.AccountKeeper.SetAccount(ctx, app.AccountKeeper.NewAccountWithAddress(ctx, crosschainBridgeCallFrom))
}

commit()
ctx.Logger().Info("upgrade complete", "module", "upgrade")
Expand Down
4 changes: 2 additions & 2 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (suite *rpcTestSuite) TestClient_Tx() {

account, err := cli.QueryAccount(toAddress.String())
suite.NoError(err)
suite.Equal(authtypes.NewBaseAccount(toAddress, nil, uint64(13+i), 0), account)
suite.Equal(authtypes.NewBaseAccount(toAddress, nil, uint64(14+i), 0), account)
}

ethPrivKey := suite.GetPrivKeyByIndex(hd2.EthSecp256k1Type, 0)
Expand Down Expand Up @@ -210,7 +210,7 @@ func (suite *rpcTestSuite) TestClient_Tx() {

account, err := cli.QueryAccount(ethAddress.String())
suite.NoError(err)
suite.Equal(authtypes.NewBaseAccount(ethAddress, nil, uint64(16), 0), account)
suite.Equal(authtypes.NewBaseAccount(ethAddress, nil, uint64(17), 0), account)
}

for i := 0; i < len(clients); i++ {
Expand Down
5 changes: 5 additions & 0 deletions x/crosschain/keeper/genesis.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"
autytypes "github.com/cosmos/cosmos-sdk/x/auth/types"

"github.com/functionx/fx-core/v7/x/crosschain/types"
)
Expand All @@ -13,6 +14,10 @@ func InitGenesis(ctx sdk.Context, k Keeper, state *types.GenesisState) {
if err := k.SetParams(ctx, &state.Params); err != nil {
panic(err)
}
crosschainBridgeCallFrom := autytypes.NewModuleAddress(types.ModuleName)
if account := k.ak.GetAccount(ctx, crosschainBridgeCallFrom); account == nil {
k.ak.SetAccount(ctx, k.ak.NewAccountWithAddress(ctx, crosschainBridgeCallFrom))
}

// 0x24
k.SetLastObservedEventNonce(ctx, state.LastObservedEventNonce)
Expand Down
12 changes: 12 additions & 0 deletions x/crosschain/mock/expected_keepers_mocks.go

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

1 change: 1 addition & 0 deletions x/crosschain/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ type IBCTransferKeeper interface {
type AccountKeeper interface {
GetModuleAddress(name string) sdk.AccAddress
GetAccount(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
SetAccount(ctx sdk.Context, acc authtypes.AccountI)
NewAccountWithAddress(ctx sdk.Context, addr sdk.AccAddress) authtypes.AccountI
}

Expand Down

0 comments on commit 812df7d

Please sign in to comment.