dfinity / motoko

Simple high-level language for writing Internet Computer canisters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Obtain actor principal without going through async methods

infu opened this issue · comments

commented

There is currently no way of passing 'this' - the current actor to a library inside the body during installation.
Can we add a system function similar to postupgrade that will trigger on new install only.
https://forum.dfinity.org/t/devefi-ledger-icrc-ledger-client-library/27274/3

commented

When writing libraries - middleware, we have to do something like this:

    public shared({caller}) func start() { 
        assert(Principal.isController(caller));
        config.canister := Principal.fromActor(this);
        ledgerOne.setOwner(this); 
    };