Motoko Upgrade Actor Class Canister

164 Views Asked by At

I am utilizing actor classes within my motoko app that are created dynamically. How do I upgrade those canisters using dfx.

When using dfx deploy it only upgrades the static actor canisters, not any of my dynamically created actor classes.

Update 1:

I have found the IC management canister can install new code on other canisters with webassembly bytes, but am unsure how to get that new code to update the actor class instances

What is the proper way of rolling out updates to all dynamically created actor classes that are deployed already?

Example

Main.mo

import A "ActorClass";
import Array "mo:base/Array";
import Cycles "mo:base/ExperimentalCycles";


actor MainCanister {

    var created_canisters : [A.ActorClass] = [];

    public func create_player() : async A.ActorClass {
        let canister : A.ActorClass = await A.ActorClass();
        created_canisters := Array.append(created_canisters, [canister]);
        return canister;
    };
};

ActorClass.mo

actor class ActorClass() {

}

Step 1: Deploy

MainCainster is installed as expected

Step 2: Call create_player func

A instance/canister of ActorClass is created

Step 3: Update ActorClass with new/changed functionality

Step 4: Re-Deploy

ONLY MainCanister is updated, not any ActorClass instance


1

There are 1 best solutions below

1
On

check this thread. it explains how to upgrade child canisters with a node script and a management canister.

https://forum.dfinity.org/t/how-do-i-upgrade-child-canisters-that-were-dynamically-created-from-a-parent-canister-of-which-i-am-the-controlller-in-motoko/12289/4