-
Notifications
You must be signed in to change notification settings - Fork 640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: RegisterInterchainAccount #814
Changes from 6 commits
1f2bac3
5e6047d
93faf7a
491c552
2bb2b86
6ed1869
d75285f
aa9192b
cc63188
be141c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -21,13 +21,20 @@ func (k Keeper) RegisterInterchainAccount(ctx sdk.Context, connectionID, owner s | |||||
return err | ||||||
} | ||||||
|
||||||
if k.portKeeper.IsBound(ctx, portID) { | ||||||
return sdkerrors.Wrap(icatypes.ErrPortAlreadyBound, portID) | ||||||
// if there is an active channel for this portID / connectionID return an error | ||||||
activeChannelID, found := k.GetOpenActiveChannel(ctx, connectionID, portID) | ||||||
if found { | ||||||
return sdkerrors.Wrapf(icatypes.ErrActiveChannelAlreadySet, "existing active channel %s for portID %s on connection %s for owner %s", activeChannelID, portID, connectionID, owner) | ||||||
} | ||||||
|
||||||
cap := k.BindPort(ctx, portID) | ||||||
if err := k.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { | ||||||
return sdkerrors.Wrap(err, "unable to bind to newly generated portID") | ||||||
switch { | ||||||
case k.portKeeper.IsBound(ctx, portID) && !k.IsBound(ctx, portID): | ||||||
return sdkerrors.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #828 - not to be done now, but thought this change might help in the future |
||||||
case !k.portKeeper.IsBound(ctx, portID): | ||||||
cap := k.BindPort(ctx, portID) | ||||||
if err := k.ClaimCapability(ctx, cap, host.PortPath(portID)); err != nil { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Test coverage is down as we're not covering this line. Not sure what the best way to test this is, or if we even should bother. We're already checking above to ensure the capability is not claimed. |
||||||
return sdkerrors.Wrapf(err, "unable to bind to newly generated portID: %s", portID) | ||||||
} | ||||||
} | ||||||
|
||||||
connectionEnd, err := k.channelKeeper.GetConnection(ctx, connectionID) | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,8 @@ var ( | |
ErrInvalidRoute = sdkerrors.Register(ModuleName, 7, "invalid route") | ||
ErrInterchainAccountNotFound = sdkerrors.Register(ModuleName, 8, "interchain account not found") | ||
ErrInterchainAccountAlreadySet = sdkerrors.Register(ModuleName, 9, "interchain account is already set") | ||
ErrActiveChannelNotFound = sdkerrors.Register(ModuleName, 10, "no active channel for this owner") | ||
ErrActiveChannelAlreadySet = sdkerrors.Register(ModuleName, 11, "active channel already set for this owner") | ||
ErrActiveChannelAlreadySet = sdkerrors.Register(ModuleName, 10, "active channel already set for this owner") | ||
ErrActiveChannelNotFound = sdkerrors.Register(ModuleName, 11, "no active channel for this owner") | ||
Comment on lines
+16
to
+17
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as a side note, this is state machine breaking (ABCI code changes), so I'd generally refrain from reorganizing error code ordering. It is hard to come up with any logical ordering when the code are grouped linearly There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That is an excellent point |
||
ErrInvalidVersion = sdkerrors.Register(ModuleName, 12, "invalid interchain accounts version") | ||
ErrInvalidAccountAddress = sdkerrors.Register(ModuleName, 13, "invalid account address") | ||
ErrUnsupported = sdkerrors.Register(ModuleName, 14, "interchain account does not support this action") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By checking this we're ensuring that an owner address can only have one interchain account per connection. Ideally, an owner could have many accounts per connection. I think this is fine for v1 though.
There's still nothing stopping ica-auth dev from using owner input parameter however they please though (increment a sequence & append or w/e), so it's not a total blocker anyway.
cc @AdityaSripal @colin-axner @damiannolan