cancelAsMulti static method

Future<bool> cancelAsMulti({
  1. required MultisigResponse multisigResponse,
  2. required Provider provider,
  3. required KeyPair signer,
  4. Duration storageKeyDelay = const Duration(seconds: 20),
  5. int tip = 0,
  6. int eraPeriod = 64,
})

CancelAsMulti (Only the owner can cancel the multisig call.)

It cancels the multisig transaction.

Implementation

static Future<bool> cancelAsMulti({
  required MultisigResponse multisigResponse,
  required Provider provider,
  required KeyPair signer,
  Duration storageKeyDelay = const Duration(seconds: 20),
  int tip = 0,
  int eraPeriod = 64,
}) async {
  final MultisigStorage? multisigStorage = await fetchMultisigStorage(
      provider,
      storageKeyDelay,
      multisigResponse.callHash.hexToUint8List(),
      multisigResponse.multisigBytes);

  assertion(multisigStorage != null,
      'The multisig storage does not exist on the chain.');

  if (multisigStorage!
      .isApprovedByAll(multisigResponse.allSignatories.length)) {
    return false;
  }

  if (multisigStorage.isOwner(signer.publicKey.bytes.toUint8List()) ==
      false) {
    throw OwnerCallException('Only the owner can cancel the multisig call.');
  }

  final meta = await MultiSigMeta.fromProvider(provider: provider);
  final signatories = Signatories.fromAddresses(
      multisigResponse.allSignatories, multisigResponse.threshold);

  await _createAndSubmitPayload(
    meta: meta,
    method: cancelAsMultiMethod(
      chainInfo: meta.runtimeMetadata.chainInfo,
      otherSignatories:
          signatories.signatoriesExcludeBytes(signer.publicKey.bytes),
      threshold: multisigResponse.threshold,
      callHash: Uint8List.fromList(hex.decode(multisigResponse.callHash)),
      multiSigStorage: multisigStorage,
    ),
    tip: tip,
    eraPeriod: eraPeriod,
    signer: signer,
    provider: provider,
  );
  return true;
}