Some checks failed
CodeQL / Analyze (push) Waiting to run
golangci-lint / lint (push) Waiting to run
Tests / Code Coverage / build (amd64) (push) Waiting to run
Tests / Code Coverage / build (arm64) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[additional-args:-tags="test_e2e" name:e2e path:./e2e]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:08-wasm path:./modules/light-clients/08-wasm]) (push) Waiting to run
Tests / Code Coverage / unit-tests (map[name:ibc-go path:.]) (push) Waiting to run
Docker Build & Push Simapp (main) / docker-build (push) Has been cancelled
35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
package keeper
|
|
|
|
import (
|
|
errorsmod "cosmossdk.io/errors"
|
|
|
|
sdk "git.cw.tr/mukan-network/mukan-sdk/types"
|
|
authtypes "git.cw.tr/mukan-network/mukan-sdk/x/auth/types"
|
|
|
|
icatypes "git.cw.tr/mukan-network/mukan-ibc/modules/apps/27-interchain-accounts/types"
|
|
)
|
|
|
|
// createInterchainAccount creates a new interchain account. An address is generated using the host connectionID, the controller portID,
|
|
// and block dependent information. An error is returned if an account already exists for the generated account.
|
|
// An interchain account type is set in the account keeper and the interchain account address mapping is updated.
|
|
func (k Keeper) createInterchainAccount(ctx sdk.Context, connectionID, controllerPortID string) (sdk.AccAddress,
|
|
error,
|
|
) {
|
|
accAddress := icatypes.GenerateAddress(ctx, connectionID, controllerPortID)
|
|
|
|
if acc := k.accountKeeper.GetAccount(ctx, accAddress); acc != nil {
|
|
return nil, errorsmod.Wrapf(icatypes.ErrAccountAlreadyExist, "existing account for newly generated interchain account address %s", accAddress)
|
|
}
|
|
|
|
interchainAccount := icatypes.NewInterchainAccount(
|
|
authtypes.NewBaseAccountWithAddress(accAddress),
|
|
controllerPortID,
|
|
)
|
|
|
|
k.accountKeeper.NewAccount(ctx, interchainAccount)
|
|
k.accountKeeper.SetAccount(ctx, interchainAccount)
|
|
|
|
k.SetInterchainAccountAddress(ctx, connectionID, controllerPortID, interchainAccount.Address)
|
|
|
|
return accAddress, nil
|
|
}
|