Actor Class Management

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:

2 Likes

There’s also an example of upgrading the nodes of a distributed map here:

@kentosugama gave a demo here:

I think it starts around 1h:06m

Here’s the link to the code Kento was demoing:

https://play.motoko.org/?tag=3132085630

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.

1 Like