install static method

Future<void> install(
  1. FieldOptions fields,
  2. ActorConfig config
)

Implementation

static Future<void> install(FieldOptions fields, ActorConfig config) async {
  final String mode = fields.mode ?? CanisterInstallMode.install.name;
  // Need to transform the arg into a number array.
  final arg = fields.arg != null
      ? Uint8List.fromList([...?fields.arg])
      : Uint8List.fromList([]);
  // Same for module.
  final wasmModule = Uint8List.fromList([...fields.module]);
  final canisterId = config.canisterId ?? Principal.fromText('');
  final canister = getManagementCanister(config);
  await canister.getFunc('install_code')!.call([
    {
      'mode': {mode: null},
      'arg': arg,
      'wasm_module': wasmModule,
      'canister_id': canisterId,
    }
  ]);
}