It changed the previous error. I updated my Nodejs function as below,
let updateSubCanisters = async () => {
const wasm = fs.readFileSync("./../../.dfx/local/canisters/testaudit/testaudit.wasm")
const args = Array.from(IDL.encode([IDL.Text], ["Xep"]));
console.log(args)
const res = await testaudit.upgradesub([...new Uint8Array(wasm)], args).catch(e => { return "Error" + e });
return res;
}
args print output
[
68, 73, 68, 76, 0,
3, 113, 1, 88
]
And now I’m receiving following error
[ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
I’m trying to update my org.mo dynamic canisters initiated by main.mo canister via main canister.
main.mo
actor {
type Org = orgs.Org;
type Key = Text;
type Value = person.Person;
let IC : ICType.Self = actor "aaaaa-aa";
stable var entries : [(Text, Org)] = [];
let buckets = Map.fromIter<Text,Org>(entries.vals(), 10, Text.equal, Text.hash);
public func put(o: Text, k : Key, v : Value) : async () {
let bucket = switch (buckets.get(o)) {
case null {
// provision next send,
let b = await orgs.Org(o); // dynamically install a new Bucket
buckets.put(o, b);
b;
};
case (?bucket) bucket;
};
await bucket.put(k, v);
};
public func upgradesub(wasm: Blob, args: Blob) : async () {
Debug.print("upgrade_sub: ");
for ((key, bucket) in buckets.entries()) {
let principal = Principal.fromActor(bucket);
let status = await IC.canister_status({canister_id=principal});
Debug.print("cycles: " # Nat.toText(status.cycles));
await IC.stop_canister({canister_id=principal});
await IC.install_code({canister_id=principal; mode=#upgrade; wasm_module=wasm; arg=args});
await IC.start_canister({canister_id=principal});
};
};
Org.mo canister
actor class Org(n : Text) {
};
Any idea what I’m missing here. Appreciate your help.