Can anyone help me with proper syntax for upgrading a canister from inside Motoko as mentioned in Language quick reference | Internet Computer
@claudio
I’m able to see the system module inside actor class but how to use #new, #upgrade, etc?
Can anyone help me with proper syntax for upgrading a canister from inside Motoko as mentioned in Language quick reference | Internet Computer
@claudio
I’m able to see the system module inside actor class but how to use #new, #upgrade, etc?
Sorry, this really need better documentation, but there some examples for you here from out test-suite:
There’s also an example of upgrading the nodes of a distributed map here:
Here’s the link to the code Kento was demoing:
The crucial line for doing an upgrade looks like this:
await (system Buckets.Bucket)(#upgrade oldBucket)()
Buckets is the library containing the class, (#upgrade oldBucket)
is the instruction to upgrade the oldBucker actor (of some actor {}
type), finally ()
are the arguments to the class (in this case just a trivial empty tuple, but could be something more interesting, depending on the definition of the actor class).
Hope that helps,
Claudio
PS. We really need to document this better.