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

feat: add XCS registry permissioning and docs #4553

Merged
merged 37 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7ac3247
adds XCS registry permission and docs
czarcas7ic Mar 9, 2023
4f6abc9
intialize contract in tests
czarcas7ic Mar 9, 2023
d00e36a
initialize contract in tests
czarcas7ic Mar 9, 2023
032225c
clarifying comments
czarcas7ic Mar 9, 2023
59c4bdd
test authorized addresses
czarcas7ic Mar 9, 2023
3b07d0e
clarify some tests
czarcas7ic Mar 10, 2023
406b2b7
Merge branch 'main' into adam/xcs-registry-perms-and-doc
czarcas7ic Mar 10, 2023
cc5c990
small edits to readme
czarcas7ic Mar 10, 2023
63800cd
remove dead code
czarcas7ic Mar 10, 2023
8b5a995
Delete go.work.sum
czarcas7ic Mar 10, 2023
3172ce7
test
czarcas7ic Mar 10, 2023
04b90f8
Merge branch 'adam/xcs-registry-perms-and-doc' of https://github.com/…
czarcas7ic Mar 10, 2023
009f07a
Merge branch 'main' into adam/xcs-registry-perms-and-doc
czarcas7ic Mar 10, 2023
ad6814a
correct authorized address logic
czarcas7ic Mar 10, 2023
26a6314
lint
czarcas7ic Mar 10, 2023
10f0820
initial expansion of permission
czarcas7ic Mar 11, 2023
ce60170
add enable / disable mapping logic
czarcas7ic Mar 12, 2023
e8d4e5b
lint
czarcas7ic Mar 12, 2023
e8e343a
lint
czarcas7ic Mar 12, 2023
6f17126
clean up queries
czarcas7ic Mar 12, 2023
6a9c161
add enable disable for connection
czarcas7ic Mar 12, 2023
ce11e23
custom errors
czarcas7ic Mar 13, 2023
d148c54
update readme
czarcas7ic Mar 13, 2023
6aa1465
expand tests
czarcas7ic Mar 13, 2023
f422f5e
Merge branch 'main' into adam/xcs-registry-perms-and-doc
czarcas7ic Mar 14, 2023
ddd9055
have query set to lowercase
czarcas7ic Mar 14, 2023
622fe65
fix formatting
czarcas7ic Mar 14, 2023
78e4657
Update cosmwasm/contracts/crosschain-registry/README.md
czarcas7ic Mar 14, 2023
d2afa3b
test privilege escalation
czarcas7ic Mar 14, 2023
c73d320
Merge branch 'adam/xcs-registry-perms-and-doc' of https://github.com/…
czarcas7ic Mar 14, 2023
93e2243
clarify inputs
czarcas7ic Mar 14, 2023
618a6d6
removed unnecessary query
nicolaslara Mar 15, 2023
1d76a09
updated bytecode
nicolaslara Mar 15, 2023
571b4e4
fix test and better errors
nicolaslara Mar 15, 2023
e8a327f
x86 bytecode
nicolaslara Mar 15, 2023
53d21cf
acrually right bytecode
nicolaslara Mar 15, 2023
3167abe
fix tests
nicolaslara Mar 15, 2023
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
60 changes: 60 additions & 0 deletions cosmwasm/contracts/crosschain-registry/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Swap Router Registry Contract

This is a CosmWasm smart contract that allows the creation and maintenance of cross-chain connection channels between IBC-enabled blockchains. This contract acts as a central registry where various blockchains can create, update, and delete IBC channels in a coordinated way, without having to deal with the complexity of handling low-level details when creating cross-chain swap messages.

The registry contains the following mappings:

- contract alias to contract address
- maps a human-readable name to the address of a target contract
- chain channel to source chain/destination chain
- maps a channel number to the source and destination chains it connects to
- chain name to Bech32 prefix
- maps a chain name to its corresponding Bech32 prefix, which is used for address encoding

It also exposes a query entry point to retrieve the address from the alias, the destination chain from the source chain via the channel, the channel from the chain pair, the bech32 prefix from the chain name, and the native denom on the source chain from the IBC denom trace.

All registry connections can be created, modified, and deleted by the contract owner. For each source_chain, the contract owner can specify an address that is allowed to create, modify, and delete registry connections for that source_chain and that source_chain alone. This allows other chains to maintain their own registry while keeping all the information consolidated on a single contract.

## Operations

### ModifyContractAlias

The `ModifyContractAlias` operation allows the contract owner to create, update, or delete aliases that can be used to identify contracts on other blockchains. The operation expects a vector of ContractAliasOperation, where each operation is either a CreateAlias, UpdateAlias, or DeleteAlias operation.

### ModifyChainChannelLinks

The `ModifyChainChannelLinks` operation allows the owner (or an authorized address for a specific source_chain) to create, update, or delete IBC channel links between each chain. The operation expects a vector of ConnectionOperation, where each operation is either a CreateConnection, UpdateConnection, or DeleteConnection operation.

### ModifyBech32Prefixes

The `ModifyBech32Prefixes` operation allows the owner (or an authorized address for a specific source_chain) to create, update, or delete Bech32 prefixes for each chain. The operation expects a vector of ChainToPrefixOperation, where each operation is either a CreatePrefix, UpdatePrefix, or DeletePrefix operation.

### UnwrapCoin

The `UnwrapCoin` operation allows the contract to take an IBC denom and unwrap it into a memo that can be used by the crosschain swaps contract to send the coins to the source chain.
czarcas7ic marked this conversation as resolved.
Show resolved Hide resolved

## Queries

### GetAddressFromAlias

The `GetAddressFromAlias` query allows a caller to retrieve the address of a contract on another blockchain, given the alias of that contract.

### GetDestinationChainFromSourceChainViaChannel

The `GetDestinationChainFromSourceChainViaChannel` query allows a caller to retrieve the destination chain for an IBC channel given the source chain and the channel id.

### GetChannelFromChainPair

The `GetChannelFromChainPair` query allows a caller to retrieve the channel id for an IBC channel given the source and destination chain.

### GetBech32PrefixFromChainName

The `GetBech32PrefixFromChainName` query allows a caller to retrieve the Bech32 prefix for a given chain.

### GetDenomTrace

The `GetDenomTrace` query allows a caller to retrieve the denom trace for a given IBC denom.

### UnwrapDenom

The `UnwrapDenom` query allows a caller to retrieve the denom trace for a given IBC denom and then unwrap it into its constituent coins on the originating blockchain.
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we want to expose this at all. If so we may want to change the name, as "unwrap" should refer to actually sending the message

Copy link
Member Author

Choose a reason for hiding this comment

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

True, we really have no reason to expose this. If you agree then I can remove it here!

Copy link
Contributor

Choose a reason for hiding this comment

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

fixed in 618a6d6

11 changes: 8 additions & 3 deletions cosmwasm/contracts/crosschain-registry/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,22 @@ pub fn execute(
match msg {
// Contract aliases
ExecuteMsg::ModifyContractAlias { operations } => {
execute::contract_alias_operations(deps, operations)
execute::contract_alias_operations(deps, info.sender, operations)
}

// Chain channel links
ExecuteMsg::ModifyChainChannelLinks { operations } => {
execute::connection_operations(deps, operations)
execute::connection_operations(deps, info.sender, operations)
}

// Bech32 prefixes
ExecuteMsg::ModifyBech32Prefixes { operations } => {
execute::chain_to_prefix_operations(deps, operations)
execute::chain_to_prefix_operations(deps, info.sender, operations)
}

// Authorized addresses
ExecuteMsg::ModifyAuthorizedAddresses { operations } => {
execute::authorized_address_operations(deps, info.sender, operations)
}

ExecuteMsg::UnwrapCoin { receiver } => {
Expand Down
3 changes: 3 additions & 0 deletions cosmwasm/contracts/crosschain-registry/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,7 @@ pub enum ContractError {

#[error("missing field: {field:?}")]
MissingField { field: String },

#[error("custom error: {msg:?}")]
CustomError { msg: String },
}
Loading