Secp256k1Layout.fromBuffer constructor

Secp256k1Layout.fromBuffer(
  1. List<int> data
)

Constructs a Secp256k1Layout instance from a buffer.

Implementation

factory Secp256k1Layout.fromBuffer(List<int> data) {
  final decode =
      ProgramLayout.decodeAndValidateStruct(layout: _layout, bytes: data);
  final int messageDataOffset = decode["messageDataOffset"];
  final int messageDataSize = decode["messageDataSize"];
  final List<int> message =
      data.sublist(messageDataOffset, messageDataOffset + messageDataSize);
  return Secp256k1Layout(
      ethAddress: ETHAddress.fromBytes(decode["ethAddress"]),
      numSignatures: decode["numSignatures"],
      signatureOffset: decode["signatureOffset"],
      signatureInstructionIndex: decode["signatureInstructionIndex"],
      ethAddressOffset: decode["ethAddressOffset"],
      ethAddressInstructionIndex: decode["ethAddressInstructionIndex"],
      messageDataOffset: messageDataOffset,
      messageDataSize: messageDataSize,
      messageInstructionIndex: decode["messageInstructionIndex"],
      signature: decode["signature"],
      message: message,
      recoveryId: decode["recoveryId"]);
}