-
Notifications
You must be signed in to change notification settings - Fork 6
/
account.go
27 lines (21 loc) · 1009 Bytes
/
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
27
package keeper
import (
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
icatypes "github.com/cosmos/ibc-go/v3/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
}
interchainAccount := icatypes.NewInterchainAccount(
authtypes.NewBaseAccountWithAddress(accAddress),
controllerPortID,
)
k.accountKeeper.NewAccount(ctx, interchainAccount)
k.accountKeeper.SetAccount(ctx, interchainAccount)
k.SetInterchainAccountAddress(ctx, connectionID, controllerPortID, interchainAccount.Address)
}