asMulti static method
Future<bool>
asMulti({
- required MultisigResponse multisigResponse,
- required Provider provider,
- required KeyPair signer,
- Duration storageKeyDelay = const Duration(seconds: 25),
- int tip = 0,
- int eraPeriod = 64,
AsMulti
It approves the multisig transaction and sends for further approval to other signatories.
Implementation
static Future<bool> asMulti({
required MultisigResponse multisigResponse,
required Provider provider,
required KeyPair signer,
Duration storageKeyDelay = const Duration(seconds: 25),
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. At least one approval with `approveAsMulti` should be done by signatory before calling `asMulti`.');
if (multisigStorage!
.isApprovedByAll(multisigResponse.allSignatories.length)) {
return true;
}
if (multisigStorage
.isAlreadyApprovedBy(signer.publicKey.bytes.toUint8List())) {
return true;
}
final meta = await MultiSigMeta.fromProvider(provider: provider);
final signatories = Signatories.fromAddresses(
multisigResponse.allSignatories, multisigResponse.threshold);
await _createAndSubmitPayload(
meta: meta,
method: asMultiMethod(
chainInfo: meta.runtimeMetadata.chainInfo,
otherSignatories:
signatories.signatoriesExcludeBytes(signer.publicKey.bytes),
threshold: multisigResponse.threshold,
callData: Uint8List.fromList(hex.decode(multisigResponse.callData)),
maxWeight: Weight(
refTime: BigInt.from(160771000),
proofSize: BigInt.from(3593),
),
multiSigStorage: multisigStorage,
),
signer: signer,
tip: tip,
eraPeriod: eraPeriod,
provider: provider,
);
return true;
}