Skip to content

Commit

Permalink
feat(zkgm): cosmwasm scaffold (#3479)
Browse files Browse the repository at this point in the history
  • Loading branch information
hussein-aitlahcen authored Jan 11, 2025
2 parents 619043d + ae561bb commit cf37e02
Show file tree
Hide file tree
Showing 15 changed files with 1,082 additions and 175 deletions.
169 changes: 22 additions & 147 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ members = [
"cosmwasm/token-factory-api",
"cosmwasm/ucs00-pingpong",
"cosmwasm/ibc-union/app/ucs00-pingpong",
"cosmwasm/ucs01-relay",
"cosmwasm/ucs01-relay-api",
"cosmwasm/ibc-union/app/ucs03-zkgm",
"cosmwasm/ucs02-nft",
"cosmwasm/multicall",

Expand Down Expand Up @@ -262,7 +261,6 @@ subset-of = { path = "lib/subset-of", default-features = false }
subset-of-derive = { path = "lib/subset-of-derive", default-features = false }

token-factory-api = { path = "cosmwasm/token-factory-api", default-features = false }
ucs01-relay-api = { path = "cosmwasm/ucs01-relay-api", default-features = false }
unionlabs = { path = "lib/unionlabs", default-features = false }
unionlabs-primitives = { path = "lib/unionlabs-primitives", default-features = false }
zktrie = { path = "lib/zktrie-rs", default-features = false }
Expand Down
15 changes: 6 additions & 9 deletions cosmwasm/cosmwasm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
ucs02-nft = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/ucs02-nft";
};
ucs01-relay = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/ucs01-relay";
};
ucs01-relay-api = crane.buildWorkspaceMember {
crateDirFromRoot = "cosmwasm/ucs01-relay-api";
};
ucs00-pingpong = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/ucs00-pingpong";
};
Expand All @@ -24,6 +18,9 @@
ibc-union = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/ibc-union/core";
};
ibc-union-ucs03-zkgm = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/ibc-union/app/ucs03-zkgm";
};
multicall = crane.buildWasmContract {
crateDirFromRoot = "cosmwasm/multicall";
};
Expand All @@ -34,10 +31,10 @@
inherit cw721-base;
}
// ucs02-nft.packages
// ucs01-relay.packages
// ucs00-pingpong.packages
// ibc-union.packages
// multicall.packages;
checks = ucs02-nft.checks // ucs01-relay.checks // ucs01-relay-api.checks // ucs00-pingpong.checks;
// multicall.packages
// ibc-union-ucs03-zkgm.packages;
checks = ucs02-nft.checks // ucs00-pingpong.checks // ibc-union-ucs03-zkgm.checks;
};
}
34 changes: 34 additions & 0 deletions cosmwasm/ibc-union/app/ucs03-zkgm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[package]
authors = ["Union.fi Labs"]
edition = { workspace = true }
license-file = { workspace = true }
name = "ibc-union-ucs03-zkgm"
repository = "https://github.com/unionlabs/union"
version = "1.0.0"

[lints]
workspace = true

[lib]
crate-type = ["cdylib", "rlib"]

[features]
library = []

[dependencies]
alloy = { workspace = true, features = ["sol-types"] }
base58 = { version = "0.2" }
cosmwasm-schema = { version = "1.5" }
cosmwasm-std = { version = "1.5" }
cw-storage-plus = { version = "1.2" }
ethabi = { workspace = true }
ibc-solidity = { workspace = true, features = ["serde"] }
ibc-union-msg = { workspace = true }
serde = { workspace = true, features = ["derive"] }
thiserror = { workspace = true }
token-factory-api = { workspace = true }
unionlabs = { workspace = true, features = ["ethabi"] }

[dev-dependencies]
hex = { workspace = true }
serde_json = { workspace = true }
71 changes: 71 additions & 0 deletions cosmwasm/ibc-union/app/ucs03-zkgm/src/com.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use alloy::primitives::U256;

pub const ZKGM_VERSION_0: u8 = 0x00;

pub const OP_FUNGIBLE_ASSET_ORDER: u8 = 0x03;

pub const ACK_ERR_ONLY_MAKER: &[u8] = &[0xDE, 0xAD, 0xC0, 0xDE];

pub const TAG_ACK_FAILURE: U256 = U256::ZERO;
pub const TAG_ACK_SUCCESS: U256 = U256::from_be_slice(&[1]);

pub const FILL_TYPE_PROTOCOL: U256 = U256::from_be_slice(&[0xB0, 0xCA, 0xD0]);
pub const FILL_TYPE_MARKETMAKER: U256 = U256::from_be_slice(&[0xD1, 0xCE, 0xC4, 0x5E]);

alloy::sol! {
struct ZkgmPacket {
bytes32 salt;
uint256 path;
Instruction instruction;
}

struct Instruction {
uint8 version;
uint8 opcode;
bytes operand;
}

struct Forward {
uint32 channel_id;
uint64 timeout_height;
uint64 timeout_timestamp;
Instruction instruction;
}

struct Multiplex {
bytes sender;
bool eureka;
bytes contract_address;
bytes contract_calldata;
}

struct Batch {
Instruction[] instructions;
}

struct FungibleAssetOrder {
bytes sender;
bytes receiver;
bytes base_token;
uint256 base_amount;
string base_token_symbol;
string base_token_name;
uint256 base_token_path;
bytes quote_token;
uint256 quote_amount;
}

struct Ack {
uint256 tag;
bytes inner_ack;
}

struct BatchAck {
bytes[] acknowledgements;
}

struct FungibleAssetOrderAck {
uint256 fill_type;
bytes market_maker;
}
}
Loading

0 comments on commit cf37e02

Please sign in to comment.