-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: introduce candid-extractor for candid export (#424)
* remove wasi feature * export_candid * examples and CI * speed up ic-wasm install * fix * add candid-extractor crate * update readme and ic0.txt * update CI * fix CI * try again * fix ci * fix * bump versions and update changelog * update date * Update src/ic-cdk-timers/CHANGELOG.md Co-authored-by: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com> --------- Co-authored-by: Adam Spofford <93943719+adamspofford-dfinity@users.noreply.github.com>
- Loading branch information
1 parent
e64b923
commit b264573
Showing
35 changed files
with
502 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
ic0.msg_arg_data_size : () -> i32; // I U Q CQ Ry CRy F | ||
ic0.msg_arg_data_copy : (dst : i32, offset : i32, size : i32) -> (); // I U Q CQ Ry CRy F | ||
ic0.msg_caller_size : () -> i32; // * | ||
ic0.msg_caller_copy : (dst : i32, offset: i32, size : i32) -> (); // * | ||
ic0.msg_reject_code : () -> i32; // Ry Rt CRy CRt | ||
ic0.msg_reject_msg_size : () -> i32; // Rt CRt | ||
ic0.msg_reject_msg_copy : (dst : i32, offset : i32, size : i32) -> (); // Rt CRt | ||
|
||
ic0.msg_reply_data_append : (src : i32, size : i32) -> (); // U Q CQ Ry Rt CRy CRt | ||
ic0.msg_reply : () -> (); // U Q CQ Ry Rt CRy CRt | ||
ic0.msg_reject : (src : i32, size : i32) -> (); // U Q CQ Ry Rt CRy CRt | ||
|
||
ic0.msg_cycles_available : () -> i64; // U Rt Ry | ||
ic0.msg_cycles_available128 : (dst : i32) -> (); // U Rt Ry | ||
ic0.msg_cycles_refunded : () -> i64; // Rt Ry | ||
ic0.msg_cycles_refunded128 : (dst : i32) -> (); // Rt Ry | ||
ic0.msg_cycles_accept : (max_amount : i64) -> (amount : i64); // U Rt Ry | ||
ic0.msg_cycles_accept128 : (max_amount_high : i64, max_amount_low: i64, dst : i32) | ||
-> (); // U Rt Ry | ||
|
||
ic0.canister_self_size : () -> i32; // * | ||
ic0.canister_self_copy : (dst : i32, offset : i32, size : i32) -> (); // * | ||
ic0.canister_cycle_balance : () -> i64; // * | ||
ic0.canister_cycle_balance128 : (dst : i32) -> (); // * | ||
ic0.canister_status : () -> i32; // * | ||
ic0.canister_version : () -> i64; // * | ||
|
||
ic0.msg_method_name_size : () -> i32; // F | ||
ic0.msg_method_name_copy : (dst : i32, offset : i32, size : i32) -> (); // F | ||
ic0.accept_message : () -> (); // F | ||
|
||
ic0.call_new : // U CQ Ry Rt CRy CRt T | ||
( callee_src : i32, | ||
callee_size : i32, | ||
name_src : i32, | ||
name_size : i32, | ||
reply_fun : i32, | ||
reply_env : i32, | ||
reject_fun : i32, | ||
reject_env : i32 | ||
) -> (); | ||
ic0.call_on_cleanup : (fun : i32, env : i32) -> (); // U CQ Ry Rt CRy CRt T | ||
ic0.call_data_append : (src : i32, size : i32) -> (); // U CQ Ry Rt CRy CRt T | ||
ic0.call_cycles_add : (amount : i64) -> (); // U Ry Rt T | ||
ic0.call_cycles_add128 : (amount_high : i64, amount_low: i64) -> (); // U Ry Rt T | ||
ic0.call_perform : () -> ( err_code : i32 ); // U CQ Ry Rt CRy CRt T | ||
|
||
ic0.stable_size : () -> (page_count : i32); // * s | ||
ic0.stable_grow : (new_pages : i32) -> (old_page_count : i32); // * s | ||
ic0.stable_write : (offset : i32, src : i32, size : i32) -> (); // * s | ||
ic0.stable_read : (dst : i32, offset : i32, size : i32) -> (); // * s | ||
ic0.stable64_size : () -> (page_count : i64); // * s | ||
ic0.stable64_grow : (new_pages : i64) -> (old_page_count : i64); // * s | ||
ic0.stable64_write : (offset : i64, src : i64, size : i64) -> (); // * s | ||
ic0.stable64_read : (dst : i64, offset : i64, size : i64) -> (); // * s | ||
|
||
ic0.certified_data_set : (src: i32, size: i32) -> (); // I G U Ry Rt T | ||
ic0.data_certificate_present : () -> i32; // * | ||
ic0.data_certificate_size : () -> i32; // * | ||
ic0.data_certificate_copy : (dst: i32, offset: i32, size: i32) -> (); // * | ||
|
||
ic0.time : () -> (timestamp : i64); // * | ||
ic0.global_timer_set : (timestamp : i64) -> i64; // I G U Ry Rt C T | ||
ic0.performance_counter : (counter_type : i32) -> (counter : i64); // * s | ||
ic0.is_controller: (src: i32, size: i32) -> ( result: i32); // * s | ||
|
||
ic0.debug_print : (src : i32, size : i32) -> (); // * s | ||
ic0.trap : (src : i32, size : i32) -> (); // * s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
[package] | ||
name = "candid-extractor" | ||
version = "0.1.0" | ||
authors.workspace = true | ||
edition.workspace = true | ||
license.workspace = true | ||
rust-version.workspace = true | ||
repository.workspace = true | ||
description = "CLI tool to extract candid definition from canister WASM." | ||
readme = "README.md" | ||
categories = ["development-tools"] | ||
keywords = ["internet-computer", "wasm", "dfinity", "canister", "cdk"] | ||
include = ["src", "Cargo.toml", "LICENSE", "README.md"] | ||
|
||
[dependencies] | ||
anyhow = "1.0.72" | ||
wasmtime = "12" | ||
|
||
[dev-dependencies] | ||
quote.workspace = true | ||
syn = { workspace = true, features = ["parsing", "full", "extra-traits"] } | ||
|
||
[[example]] | ||
name = "generate_mock_wat" | ||
path = "util/generate_mock_wat.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# candid-extractor | ||
|
||
A CLI tool to extract candid definition from canister WASM. | ||
|
||
## Installation | ||
|
||
``` | ||
cargo install candid-extractor | ||
``` | ||
|
||
## Usage | ||
|
||
``` | ||
candid-extractor path/to/canister.wasm | ||
``` | ||
|
||
## Update ic_mock.wat | ||
|
||
`candid-extractor` requires a mock WASM (`ic_mock.wat`) which provides ic0 imports. | ||
|
||
Such `ic_mock.wat` is directly generated from the [system API][1]. | ||
|
||
When interface-spec releases a new version that modify ic0 system API: | ||
|
||
1. replace `ic0.txt` in the root of this project; | ||
2. execute `cargo run --example=generate_mock_wat`; | ||
|
||
`ic_mock.wat` should be updated. | ||
|
||
[1]: https://internetcomputer.org/docs/current/references/ic-interface-spec/#system-api-imports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../ic0.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
(module | ||
;; This file is generated from ic0.txt. | ||
;; Don't manually modify it. | ||
(func (export "msg_arg_data_size") (result i32) i32.const 0) | ||
(func (export "msg_arg_data_copy") (param i32 i32 i32) ) | ||
(func (export "msg_caller_size") (result i32) i32.const 0) | ||
(func (export "msg_caller_copy") (param i32 i32 i32) ) | ||
(func (export "msg_reject_code") (result i32) i32.const 0) | ||
(func (export "msg_reject_msg_size") (result i32) i32.const 0) | ||
(func (export "msg_reject_msg_copy") (param i32 i32 i32) ) | ||
(func (export "msg_reply_data_append") (param i32 i32) ) | ||
(func (export "msg_reply") ) | ||
(func (export "msg_reject") (param i32 i32) ) | ||
(func (export "msg_cycles_available") (result i64) i64.const 0) | ||
(func (export "msg_cycles_available128") (param i32) ) | ||
(func (export "msg_cycles_refunded") (result i64) i64.const 0) | ||
(func (export "msg_cycles_refunded128") (param i32) ) | ||
(func (export "msg_cycles_accept") (param i64) (result i64) i64.const 0) | ||
(func (export "msg_cycles_accept128") (param i64 i64 i32) ) | ||
(func (export "canister_self_size") (result i32) i32.const 0) | ||
(func (export "canister_self_copy") (param i32 i32 i32) ) | ||
(func (export "canister_cycle_balance") (result i64) i64.const 0) | ||
(func (export "canister_cycle_balance128") (param i32) ) | ||
(func (export "canister_status") (result i32) i32.const 0) | ||
(func (export "canister_version") (result i64) i64.const 0) | ||
(func (export "msg_method_name_size") (result i32) i32.const 0) | ||
(func (export "msg_method_name_copy") (param i32 i32 i32) ) | ||
(func (export "accept_message") ) | ||
(func (export "call_new") (param i32 i32 i32 i32 i32 i32 i32 i32) ) | ||
(func (export "call_on_cleanup") (param i32 i32) ) | ||
(func (export "call_data_append") (param i32 i32) ) | ||
(func (export "call_cycles_add") (param i64) ) | ||
(func (export "call_cycles_add128") (param i64 i64) ) | ||
(func (export "call_perform") (result i32) i32.const 0) | ||
(func (export "stable_size") (result i32) i32.const 0) | ||
(func (export "stable_grow") (param i32) (result i32) i32.const 0) | ||
(func (export "stable_write") (param i32 i32 i32) ) | ||
(func (export "stable_read") (param i32 i32 i32) ) | ||
(func (export "stable64_size") (result i64) i64.const 0) | ||
(func (export "stable64_grow") (param i64) (result i64) i64.const 0) | ||
(func (export "stable64_write") (param i64 i64 i64) ) | ||
(func (export "stable64_read") (param i64 i64 i64) ) | ||
(func (export "certified_data_set") (param i32 i32) ) | ||
(func (export "data_certificate_present") (result i32) i32.const 0) | ||
(func (export "data_certificate_size") (result i32) i32.const 0) | ||
(func (export "data_certificate_copy") (param i32 i32 i32) ) | ||
(func (export "time") (result i64) i64.const 0) | ||
(func (export "global_timer_set") (param i64) (result i64) i64.const 0) | ||
(func (export "performance_counter") (param i32) (result i64) i64.const 0) | ||
(func (export "is_controller") (param i32 i32) (result i32) i32.const 0) | ||
(func (export "debug_print") (param i32 i32) ) | ||
(func (export "trap") (param i32 i32) ) | ||
) |
Oops, something went wrong.