-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.go
26 lines (22 loc) · 1.04 KB
/
account.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package keeper
import (
sdk "github.com/furyaxyz/fuxchain/libs/cosmos-sdk/types"
"github.com/furyaxyz/fuxchain/libs/cosmos-sdk/x/auth"
icatypes "github.com/furyaxyz/fuxchain/libs/ibc-go/modules/apps/27-interchain-accounts/types"
)
// RegisterInterchainAccount attempts to create a new account using the provided address and
// stores it in state keyed by the provided connection and port identifiers
// If an account for the provided address already exists this function returns early (no-op)
func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, connectionID, controllerPortID string, accAddress sdk.AccAddress) {
if acc := k.accountKeeper.GetAccount(ctx, accAddress); acc != nil {
return
}
baseAcc := auth.NewBaseAccountWithAddress(accAddress)
interchainAccount := icatypes.NewAminoInterchainAccount(
&baseAcc,
controllerPortID,
)
k.accountKeeper.NewAccount(ctx, interchainAccount)
k.accountKeeper.SetAccount(ctx, interchainAccount)
k.SetInterchainAccountAddress(ctx, connectionID, controllerPortID, interchainAccount.Address.String())
}