createAndFundMultisig static method

Future<MultisigResponse> createAndFundMultisig({
  1. required KeyPair depositorKeyPair,
  2. required int threshold,
  3. required String recipientAddress,
  4. required BigInt amount,
  5. required Provider provider,
  6. required List<String> otherSignatoriesAddressList,
  7. int tip = 0,
  8. int eraPeriod = 64,
})

This creates the multisig account on the chain and funds it.

Implementation

static Future<MultisigResponse> createAndFundMultisig({
  required KeyPair depositorKeyPair,
  required int threshold,
  required String recipientAddress,
  required BigInt amount,
  required Provider provider,
  required List<String> otherSignatoriesAddressList,
  int tip = 0,
  int eraPeriod = 64,
}) async {
  final meta = await MultiSigMeta.fromProvider(provider: provider);

  /// Make Signatories
  final Signatories signatories = Signatories.fromAddresses(
      [depositorKeyPair.address, ...otherSignatoriesAddressList], threshold);
  final Uint8List mutisigBytes = signatories.mutiSigBytes;

  //
  // Create and Fund the Multisig Account
  {
    await _createAndSubmitPayload(
      meta: meta,
      method: Transfers.transferKeepAlive.encode(
        meta.runtimeMetadata.chainInfo,
        mutisigBytes,
        amount,
      ),
      tip: tip,
      eraPeriod: eraPeriod,
      signer: depositorKeyPair,
      provider: provider,
    );
  }

  // Making the callData
  final Uint8List callData = Transfers.transferKeepAlive.encode(
    meta.runtimeMetadata.chainInfo,
    Address.decode(recipientAddress).pubkey,
    amount,
  );

  return MultisigResponse(
    callData: callData.toHex(),
    callHash: Hasher.blake2b256.hash(callData).toHex(),
    threshold: threshold,
    allSignatories: signatories.sortedSignatoriesAddresses,
  );
}