Git Product home page Git Product logo

ic-kit's Issues

Requesting clarification on the following: Dynamic canister creation, automatic Candid generation, inter canister calls

It would be really helpful if you could document how to do the following with ic-kit:

  • dynamic canister creation
  • automatic Candid generation
  • inter canister calls

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 :)

How to mock canister with existing method?

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?

Compitable with ic_cdk 0.4.0

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`
    |

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.