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(ci): Store contract api files in repository #209

Merged
merged 16 commits into from
Nov 26, 2024
53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,56 @@ jobs:
run: |
cd ethereum
forge test
check-api-files:
runs-on: kuberunner
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Install golang
uses: actions/setup-go@v5
with:
go-version: '1.20.1'
- name: Install foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-4923529c743f25a0f37503a7bcf7c68caa6901f1
- name: Build ethereum smart-contracts
run: forge build --force --no-cache
working-directory: ./ethereum
- name: Build workspace
run: cargo build --release --all-targets
- name: Check that files match
run: |
stored=(
"./api/ethereum/ERC20ManagerBridgingPayment.json"
"./api/ethereum/IERC20Manager.json"
"./api/ethereum/IMessageQueue.json"

"./api/gear/bridging_payment.idl"
"./api/gear/erc20_relay.idl"
"./api/gear/vft_manager.idl"
"./api/gear/wrapped_vara.idl"
"./api/gear/extended_vft.idl"
)

generated=(
"./ethereum/out/ERC20Manager.sol/ERC20ManagerBridgingPayment.json"
"./ethereum/out/IERC20Manager.sol/IERC20Manager.json"
"./ethereum/out/IMessageQueue.sol/IMessageQueue.json"

"./target/wasm32-unknown-unknown/release/bridging_payment.idl"
"./target/wasm32-unknown-unknown/release/erc20_relay.idl"
"./target/wasm32-unknown-unknown/release/vft_manager.idl"
"./target/wasm32-unknown-unknown/release/wrapped_vara.idl"
"./target/wasm32-unknown-unknown/release/extended_vft.idl"
)

for i in "${!stored[@]}"; do
if ! cmp -s "${stored[$i]}" "${generated[$i]}"; then
echo "API files ${stored[$i]} and ${generated[$i]} don't match."
diff "${stored[$i]}" "${generated[$i]}"
exit 1
fi
done
6 changes: 6 additions & 0 deletions api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Ethereum smart contracts ABI and gear programs idl files

Contents of this folder are guaranteed to be up to date as there's a workflow in CI that checks that they match with ones generated when the project is built.

> [!WARNING]
> Update CI workflow when adding new files to this folder
1 change: 1 addition & 0 deletions api/ethereum/ERC20ManagerBridgingPayment.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions api/ethereum/IERC20Manager.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"abi":[{"type":"event","name":"BridgingAccepted","inputs":[{"name":"to","type":"address","indexed":true,"internalType":"address"},{"name":"token","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"event","name":"BridgingRequested","inputs":[{"name":"from","type":"address","indexed":true,"internalType":"address"},{"name":"to","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"token","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"type":"error","name":"BadArguments","inputs":[]},{"type":"error","name":"BadVftManagerAddress","inputs":[]},{"type":"error","name":"NotAuthorized","inputs":[]},{"type":"error","name":"UnsupportedTokenSupply","inputs":[]}],"bytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"deployedBytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"methodIdentifiers":{},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"BadArguments\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BadVftManagerAddress\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"NotAuthorized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"UnsupportedTokenSupply\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgingAccepted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"to\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"BridgingRequested\",\"type\":\"event\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/interfaces/IERC20Manager.sol\":\"IERC20Manager\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/\"]},\"sources\":{\"src/interfaces/IERC20Manager.sol\":{\"keccak256\":\"0x6d425acf1bd13155d2835202a2ae3e372753ec3541ba3bcee9c3353c474d3424\",\"urls\":[\"bzz-raw://f70eb3a3e5e92290d338e2be1f59fe9452f1f97a251d7c55a4447daa5910d675\",\"dweb:/ipfs/QmNacCf3MJ2umqVnQPt83rbZzWNUTM8wBoeUFiz5AwxxCW\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.28+commit.7893614a"},"language":"Solidity","output":{"abi":[{"inputs":[],"type":"error","name":"BadArguments"},{"inputs":[],"type":"error","name":"BadVftManagerAddress"},{"inputs":[],"type":"error","name":"NotAuthorized"},{"inputs":[],"type":"error","name":"UnsupportedTokenSupply"},{"inputs":[{"internalType":"address","name":"to","type":"address","indexed":true},{"internalType":"address","name":"token","type":"address","indexed":true},{"internalType":"uint256","name":"amount","type":"uint256","indexed":false}],"type":"event","name":"BridgingAccepted","anonymous":false},{"inputs":[{"internalType":"address","name":"from","type":"address","indexed":true},{"internalType":"bytes32","name":"to","type":"bytes32","indexed":true},{"internalType":"address","name":"token","type":"address","indexed":true},{"internalType":"uint256","name":"amount","type":"uint256","indexed":false}],"type":"event","name":"BridgingRequested","anonymous":false}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","forge-std/=lib/forge-std/src/","halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/interfaces/IERC20Manager.sol":"IERC20Manager"},"evmVersion":"cancun","libraries":{}},"sources":{"src/interfaces/IERC20Manager.sol":{"keccak256":"0x6d425acf1bd13155d2835202a2ae3e372753ec3541ba3bcee9c3353c474d3424","urls":["bzz-raw://f70eb3a3e5e92290d338e2be1f59fe9452f1f97a251d7c55a4447daa5910d675","dweb:/ipfs/QmNacCf3MJ2umqVnQPt83rbZzWNUTM8wBoeUFiz5AwxxCW"],"license":null}},"version":1},"id":59}
1 change: 1 addition & 0 deletions api/ethereum/IMessageQueue.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"abi":[{"type":"function","name":"calculateMerkleRoot","inputs":[{"name":"proof","type":"bytes32[]","internalType":"bytes32[]"},{"name":"hash","type":"bytes32","internalType":"bytes32"},{"name":"width","type":"uint256","internalType":"uint256"},{"name":"leaf_index","type":"uint256","internalType":"uint256"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"type":"function","name":"processMessage","inputs":[{"name":"block_number","type":"uint256","internalType":"uint256"},{"name":"total_leaves","type":"uint256","internalType":"uint256"},{"name":"leaf_index","type":"uint256","internalType":"uint256"},{"name":"message","type":"tuple","internalType":"struct VaraMessage","components":[{"name":"nonce","type":"bytes32","internalType":"bytes32"},{"name":"sender","type":"bytes32","internalType":"bytes32"},{"name":"receiver","type":"address","internalType":"address"},{"name":"data","type":"bytes","internalType":"bytes"}]},{"name":"proof","type":"bytes32[]","internalType":"bytes32[]"}],"outputs":[],"stateMutability":"nonpayable"},{"type":"event","name":"MessageProcessed","inputs":[{"name":"blockNumber","type":"uint256","indexed":true,"internalType":"uint256"},{"name":"messageHash","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"messageNonce","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"type":"event","name":"ProoverAddressUpdated","inputs":[{"name":"proover","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"event","name":"RelayerAddressUpdated","inputs":[{"name":"relayer","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"type":"error","name":"AlreadyInitialized","inputs":[]},{"type":"error","name":"BadProof","inputs":[]},{"type":"error","name":"MerkleRootNotSet","inputs":[{"name":"blockNumber","type":"uint256","internalType":"uint256"}]},{"type":"error","name":"MessageAlreadyProcessed","inputs":[{"name":"messageNonce","type":"bytes32","internalType":"bytes32"}]},{"type":"error","name":"MessageNotProcessed","inputs":[]}],"bytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"deployedBytecode":{"object":"0x","sourceMap":"","linkReferences":{}},"methodIdentifiers":{"calculateMerkleRoot(bytes32[],bytes32,uint256,uint256)":"e1a551cf","processMessage(uint256,uint256,uint256,(bytes32,bytes32,address,bytes),bytes32[])":"44855efc"},"rawMetadata":"{\"compiler\":{\"version\":\"0.8.28+commit.7893614a\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"AlreadyInitialized\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"BadProof\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"}],\"name\":\"MerkleRootNotSet\",\"type\":\"error\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"messageNonce\",\"type\":\"bytes32\"}],\"name\":\"MessageAlreadyProcessed\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MessageNotProcessed\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"blockNumber\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"messageHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"messageNonce\",\"type\":\"bytes32\"}],\"name\":\"MessageProcessed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"proover\",\"type\":\"address\"}],\"name\":\"ProoverAddressUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"relayer\",\"type\":\"address\"}],\"name\":\"RelayerAddressUpdated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"},{\"internalType\":\"bytes32\",\"name\":\"hash\",\"type\":\"bytes32\"},{\"internalType\":\"uint256\",\"name\":\"width\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"leaf_index\",\"type\":\"uint256\"}],\"name\":\"calculateMerkleRoot\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"block_number\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"total_leaves\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"leaf_index\",\"type\":\"uint256\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"nonce\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"sender\",\"type\":\"bytes32\"},{\"internalType\":\"address\",\"name\":\"receiver\",\"type\":\"address\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct VaraMessage\",\"name\":\"message\",\"type\":\"tuple\"},{\"internalType\":\"bytes32[]\",\"name\":\"proof\",\"type\":\"bytes32[]\"}],\"name\":\"processMessage\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"src/interfaces/IMessageQueue.sol\":\"IMessageQueue\"},\"evmVersion\":\"cancun\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":200},\"remappings\":[\":@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/\",\":ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/\",\":erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/\",\":forge-std/=lib/forge-std/src/\",\":halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/\",\":openzeppelin-contracts/=lib/openzeppelin-contracts/\"]},\"sources\":{\"src/interfaces/IMessageQueue.sol\":{\"keccak256\":\"0xf8352567197fd1fe695309bfbb2416c79d76e301cd267215476cd94a14784e74\",\"urls\":[\"bzz-raw://ed0f4f31af4e2a09b9bf190f07b2ead5495ea8b61a0e35bc48d161282e8bc015\",\"dweb:/ipfs/QmP164SwLhsAsAbBPkQm5iQqmgfAcSvfhFpEov4eGRhfD9\"]}},\"version\":1}","metadata":{"compiler":{"version":"0.8.28+commit.7893614a"},"language":"Solidity","output":{"abi":[{"inputs":[],"type":"error","name":"AlreadyInitialized"},{"inputs":[],"type":"error","name":"BadProof"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"type":"error","name":"MerkleRootNotSet"},{"inputs":[{"internalType":"bytes32","name":"messageNonce","type":"bytes32"}],"type":"error","name":"MessageAlreadyProcessed"},{"inputs":[],"type":"error","name":"MessageNotProcessed"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256","indexed":true},{"internalType":"bytes32","name":"messageHash","type":"bytes32","indexed":true},{"internalType":"bytes32","name":"messageNonce","type":"bytes32","indexed":true}],"type":"event","name":"MessageProcessed","anonymous":false},{"inputs":[{"internalType":"address","name":"proover","type":"address","indexed":false}],"type":"event","name":"ProoverAddressUpdated","anonymous":false},{"inputs":[{"internalType":"address","name":"relayer","type":"address","indexed":false}],"type":"event","name":"RelayerAddressUpdated","anonymous":false},{"inputs":[{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"bytes32","name":"hash","type":"bytes32"},{"internalType":"uint256","name":"width","type":"uint256"},{"internalType":"uint256","name":"leaf_index","type":"uint256"}],"stateMutability":"view","type":"function","name":"calculateMerkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}]},{"inputs":[{"internalType":"uint256","name":"block_number","type":"uint256"},{"internalType":"uint256","name":"total_leaves","type":"uint256"},{"internalType":"uint256","name":"leaf_index","type":"uint256"},{"internalType":"struct VaraMessage","name":"message","type":"tuple","components":[{"internalType":"bytes32","name":"nonce","type":"bytes32"},{"internalType":"bytes32","name":"sender","type":"bytes32"},{"internalType":"address","name":"receiver","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}]},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"}],"stateMutability":"nonpayable","type":"function","name":"processMessage"}],"devdoc":{"kind":"dev","methods":{},"version":1},"userdoc":{"kind":"user","methods":{},"version":1}},"settings":{"remappings":["@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/","ds-test/=lib/openzeppelin-contracts/lib/forge-std/lib/ds-test/src/","erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/","forge-std/=lib/forge-std/src/","halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"optimizer":{"enabled":true,"runs":200},"metadata":{"bytecodeHash":"ipfs"},"compilationTarget":{"src/interfaces/IMessageQueue.sol":"IMessageQueue"},"evmVersion":"cancun","libraries":{}},"sources":{"src/interfaces/IMessageQueue.sol":{"keccak256":"0xf8352567197fd1fe695309bfbb2416c79d76e301cd267215476cd94a14784e74","urls":["bzz-raw://ed0f4f31af4e2a09b9bf190f07b2ead5495ea8b61a0e35bc48d161282e8bc015","dweb:/ipfs/QmP164SwLhsAsAbBPkQm5iQqmgfAcSvfhFpEov4eGRhfD9"],"license":null}},"version":1},"id":60}
33 changes: 33 additions & 0 deletions api/gear/bridging_payment.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
type InitConfig = struct {
admin_address: actor_id,
vft_manager_address: actor_id,
config: Config,
};

type Config = struct {
fee: u128,
gas_for_reply_deposit: u64,
gas_to_send_request_to_vft_manager: u64,
reply_timeout: u32,
gas_for_request_to_vft_manager_msg: u64,
};

constructor {
New : (init_config: InitConfig);
};

service BridgingPayment {
MakeRequest : (amount: u256, receiver: h160, vara_token_id: actor_id) -> null;
ReclaimFee : () -> null;
SetConfig : (config: Config) -> null;
SetFee : (fee: u128) -> null;
UpdateVftManagerAddress : (new_vft_manager_address: actor_id) -> null;
query AdminAddress : () -> actor_id;
query GetConfig : () -> Config;
query VftManagerAddress : () -> actor_id;

events {
TeleportVaraToEth: struct { nonce: u256, sender: actor_id, amount: u256, receiver: h160, eth_token_id: h160 };
}
};

Loading
Loading