psychedelic / ic-kit Goto Github PK
View Code? Open in Web Editor NEWRust library for developing safe canisters.
Home Page: https://docs.rs/ic-kit
Rust library for developing safe canisters.
Home Page: https://docs.rs/ic-kit
It would be really helpful if you could document how to do the following with ic-kit:
as comments in the examples provided and provide any guidance on how to set it up from scratch on a new project.
I was using ic-kit 0.4.8 before. It included calls to the management canister as documented here for the dynamic creations of canisters but that seems to have been removed in v0.5 onwards.
And I had been using the cargo test
mechanism of automatic Candid generation as used in some other Psychedelic projects like this
For inter canister calls, I tried the mechanism outlined here but it's not type safe so it breaks compilation with Cargo. I created a post for it here
I feel ic-kit 0.5 would probably solve all of the above but I'm unable to make it work atm.
I see some of the examples have pending todos and I imagine you'll be fleshing them out in more details.
In case you already plan to cover the above, please ignore this issue :)
I see that there is something interesting with cycles going on, but I can't quite put my finger on it. Could you elaborate on it, please?
Hi. Amazing library! Can you please provide some insight on how to mock a canister with existing methods.
Say, I have a method
#[update]
async fn do_nothing(my_arg: u64) -> Result<(), String> {
Ok(())
}
How would I create a Canister
mock with the method above? I've tried to use RawHandler
, but cannot figure out how to transfer arguments correctly.
The way I want to use it later is like so:
let canister = Canister::new(mock_principals::alice())
.method("do_nothing", ...);
let ctx = canister.context().inject();
ic::call_with_payment(mock_principals::alice(), "do_nothing", (1000), 100);
Is it even possible with the current implementation?
I found that ic_cdk 0.4.0 deprecate block_on
function and use its own spawn.
ic_kit
use ic_cdk::block_on
to do the job of ic::spwan
.
Besides, ic_cdk::spawn
doesn't need Send
trait bound to the future F
while ic_kit
does.
#[inline(always)]
pub fn spawn<F: 'static + std::future::Future<Output = ()> + std::marker::Send>(future: F) {
get_context().spawn(future)
}
When I have a job which call another canister, the future returned does not have Send
trait. Thus ic::spawn
can not execute the job.
|
498 | let xtc_balance: (Nat, ) = ic::call(Principal::from_text(XTC).unwrap(), "balanceOf", (ic::id(),))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ await occurs here on type `Pin<Box<dyn Future<Output = Result<(ic_kit::candid::Nat,), (RejectionCode, std::string::String)>>>>`, which is not `Send`
note: required by a bound in `ic_kit::ic::spawn`
|
555 | ic::spawn(schedule_job());
| ^^^^^^^^^ future returned by `schedule_job` is not `Send`
|
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.