Open lastmjs opened 2 years ago
I'd suggest to use an icp-custom section, like the one used to embed the Candid interface. The data is static and module-specific (not instance specific), so it's a better fit. And you get certification for free!
Also, why not include version information?
I don't know much about how an icp-custom section would be implemented. Do you have any links to how to do this in Rust?
@chenyan-dfinity, do you know?
You can use ic-wasm. But the easiest way to do this in Rust is as follows:
#[link_section = "icp:public cdk"]
pub static LANG = *b"cdk-rs v1.0";
I think LANG
might be better as NAME
since we may have multiple CDKs per language:
#[link_section = "icp:public cdk"]
pub static NAME = *b"kybra v0.0.1";
Unless that variable doesn't show up in the path?
Yep, variable name is just a placeholder. I won't show up in the path.
I've tried adding this:
``rust
pub static NAME: [u8; 12] = *b"kybra v0.0.0";
On my machine everything was working fine, on another's machine, which happend to be an M1 Macbook, we got this error:
LLVM ERROR: Global variable '_ZN24kybra_generated_canister4NAME17h757f254ac293c59bE' has an invalid section specifier 'icp:public cdk': mach-o section specifier requires a segment and section separated by a comma.
Maybe try adding this line above #[link_section]
:
#[cfg(target_arch = "wasm32")]
I don't have an M1, so cannot verify.
The discussion on a similar proposal is proceeding well here: https://forum.dfinity.org/t/rfc-tech-stack-canister-metadata-standard-extension/28692
I've opened this issue with 3 additional CDK projects:
As we've been developing CDKs (TypeScript/JavaScript with Azle and Python with Kybra), we've been thinking about how to measure adoption of various CDKs. In addition to GitHub metrics (such as analyzing dfx.json), it might be a powerful metric to know exactly how many canisters use a particular CDK. For Azle and Kybra, we're adding a simple method
__cdk_name
that returns a string with the name of the CDK. This will allow canister indexers like https://icscan.io/ to index canisters by CDK. This could allow viewing of various CDK metrics over time, which I think would be very interesting to many different parties on the IC.Here's our suggested implementation of the method in cdk-rs:
Here's our suggested implementation of the method in Azle:
Here's our suggested implementation of the method in Kybra:
Do you have any thoughts on this pattern?