SolanaTransaction.fromJson constructor

SolanaTransaction.fromJson(
  1. Map<String, dynamic> json, {
  2. TransactionType? version,
})

Implementation

factory SolanaTransaction.fromJson(Map<String, dynamic> json,
    {TransactionType? version}) {
  final message = VersionedMessage.fromJson(json["message"], type: version);

  final List<List<int>> signatures = (json["signatures"] as List)
      .map<List<int>>((e) => Base58Decoder.decode(e))
      .toList();
  final transaction = SolanaTransaction._(
      List.generate(
          message.header.numRequiredSignatures,
          (index) => List<int>.unmodifiable(List<int>.filled(
              SolanaTransactionConstant.signatureLengthInBytes, 0))),
      message: message);
  final signerPubkeys =
      message.accountKeys.sublist(0, message.header.numRequiredSignatures);
  for (int i = 0; i < signatures.length; i++) {
    transaction.addSignature(
        signerPubkeys.elementAt(i), signatures.elementAt(i),

        /// Supports only versioned Transaction legacy or V0.
        /// Older Transactions may fail.
        verifySignature: version != null);
  }
  return transaction;
}