When I deploy locally the CMC using JavaScript, the CMC prints following message:
2024-05-12 19:46:32.120446192 UTC: [Canister rkp4c-7iaaa-aaaaa-aaaca-cai] [cycles] init() with ledger canister ryjl3-tyaaa-aaaaa-aaaba-cai, governance canister rrkah-fqaaa-aaaaa-aaaaq-cai, exchange rate canister , and minting account
i.e. it informs me that the minting account is none however, from types and code perspective, everything seems fine on my hand.
const minterAccountIdentifier = AccountIdentifier.fromPrincipal({
principal: minterIdentity.getPrincipal()
});
console.log('-------------------->', minterAccountIdentifier, minterAccountIdentifier.toHex());
const sourceArg: CyclesCanisterInitPayload = {
exchange_rate_canister: [],
last_purged_notification: [0n],
governance_canister_id: [Principal.fromText(governanceCanisterId)],
minting_account_id: [{bytes: minterAccountIdentifier.toUint8Array()}],
ledger_canister_id: [Principal.fromText(icpLedgerCanisterId)]
};
// Type definitions generated by Candid are not clean enough.
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const arg = IDL.encode(init({IDL}), [[sourceArg]]);
The above printing an account identifier equals to:
--------------------> By {
bytes: Uint8Array(32) [
41, 192, 86, 134, 16, 164, 21, 239,
235, 244, 103, 115, 119, 41, 65, 99,
255, 184, 34, 109, 71, 61, 173, 184,
117, 150, 212, 221, 164, 135, 4, 71
]
} 29c0568610a415efebf4677377294163ffb8226d473dadb87596d4dda4870447
The minter account identifier toUint8Array
provides the bytes
public toUint8Array(): Uint8Array {
return this.bytes;
}
And the candid definition of the CMC also expect bytes
export interface AccountIdentifier {
bytes: Uint8Array | number[];
}
So I’m a bit confuse about the issue. Is it possible that the CMC did file is incorrect and its Accountidentifier should actually be encoded differently?
type AccountIdentifier = record {
bytes: blob;
};
type CyclesCanisterInitPayload = record {
ledger_canister_id: opt principal;
governance_canister_id: opt principal;
minting_account_id: opt AccountIdentifier;
last_purged_notification: opt nat64;
exchange_rate_canister: opt ExchangeRateCanister;
};