Skip to content
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

ICS27: Update Callbacks #789

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions spec/app/ics-027-interchain-accounts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ function onChanOpenInit(
channelIdentifier: Identifier,
counterpartyPortIdentifier: Identifier,
counterpartyChannelIdentifier: Identifier,
version: string) {
version: string) => (version: string, err: Error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit of a nit but in some function signatures we use => and in others :. It would be good to have some kind of coding guidelines for the pseudocode language that we use in the specs. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed. i like => it pops out more when i skim through the pseudocode and stands out from the rest of the connection syntax

// only ordered channels allowed
abortTransactionUnless(order === ORDERED)
// validate port format
Expand All @@ -389,16 +389,31 @@ function onChanOpenInit(
// only open the channel if there is no active channel already set (with status OPEN)
abortTransactionUnless(activeChannel === nil)

// validate metadata
metadata = UnmarshalJSON(version)
abortTransactionUnless(metadata.Version === "ics27-1")
// all elements in encoding list and tx type list must be supported
abortTransactionUnless(IsSupportedEncoding(metadata.Encoding))
abortTransactionUnless(IsSupportedTxType(metadata.TxType))

// connectionID and counterpartyConnectionID is retrievable in Channel
abortTransactionUnless(metadata.ControllerConnectionId === connectionId)
abortTransactionUnless(metadata.HostConnectionId === counterpartyConnectionId)
if version != "" {
// validate metadata
metadata = UnmarshalJSON(version)
abortTransactionUnless(metadata.Version === "ics27-1")
// all elements in encoding list and tx type list must be supported
abortTransactionUnless(IsSupportedEncoding(metadata.Encoding))
abortTransactionUnless(IsSupportedTxType(metadata.TxType))

// connectionID and counterpartyConnectionID is retrievable in Channel
abortTransactionUnless(metadata.ControllerConnectionId === connectionId)
abortTransactionUnless(metadata.HostConnectionId === counterpartyConnectionId)
} else {
// construct default metadata
metadata = {
Version: "ics27-1",
ControllerConnectionId: connectionId,
HostConnectionId: counterpartyConnectionId,
// implementation may choose a default encoding and TxType
// e.g. DefaultEncoding=protobuf, DefaultTxType=sdk.MultiMsg
Encoding: DefaultEncoding,
TxType: DefaultTxType,
}
version = marshalJSON(metadata)
}
return version, nil
}
```

Expand All @@ -411,7 +426,7 @@ function onChanOpenTry(
channelIdentifier: Identifier,
counterpartyPortIdentifier: Identifier,
counterpartyChannelIdentifier: Identifier,
counterpartyVersion: string) (version: string) {
counterpartyVersion: string) (version: string, err: Error) {
// only ordered channels allowed
abortTransactionUnless(order === ORDERED)
// validate port ID
Expand Down Expand Up @@ -443,7 +458,7 @@ function onChanOpenTry(
"TxType": cpMetadata.TxType,
}

return string(MarshalJSON(metadata))
return string(MarshalJSON(metadata)), nil
}
```

Expand Down