previousSignaturePayload method Null safety

Uint8List previousSignaturePayload()

Implementation

Uint8List previousSignaturePayload() {
  Uint8List bufTimestamp = encodeBigInt(BigInt.from(this.timestamp!));
  Uint8List bufCodeSize = encodeInt32(this.data!.code!.length);
  Uint8List bufContentSize = encodeInt32(this.data!.content!.length);
  Uint8List bufSecretSize = encodeInt32(this.data!.keys!.secret!.length);

  Uint8List? authorizedKeysBuffers = new Uint8List(0);
  this.data!.keys!.authorizedKeys!.forEach((publicKey, authorizedKey) {
    authorizedKeysBuffers = concatUint8List([
      hexToUint8List(publicKey),
      this.data!.keys!.authorizedKeys![publicKey]
    ]);
  });

  Uint8List? ucoTransfersBuffers = new Uint8List(0);
  if (this.data!.ledger!.uco!.transfers!.length > 0) {
    ucoTransfersBuffers = concatUint8List([
      this.data!.ledger!.uco!.transfers![0].to!,
      encodeFloat64(this.data!.ledger!.uco!.transfers![0].amount!)
    ]);
  }

  Uint8List? nftTransfersBuffers = new Uint8List(0);
  if (this.data!.ledger!.nft!.transfers!.length > 0) {
    nftTransfersBuffers = concatUint8List([
      this.data!.ledger!.nft!.transfers![0].nft!,
      this.data!.ledger!.nft!.transfers![0].to!,
      encodeFloat64(this.data!.ledger!.nft!.transfers![0].amount!)
    ]);
  }

  return concatUint8List([
    this.address!,
    Uint8List.fromList([txTypes[(this.type)]!]),
    bufTimestamp,
    bufCodeSize,
    this.data!.code!,
    bufContentSize,
    this.data!.content!,
    bufSecretSize,
    this.data!.keys!.secret!,
    Uint8List.fromList([this.data!.keys!.authorizedKeys!.length]),
    authorizedKeysBuffers!,
    Uint8List.fromList([this.data!.ledger!.uco!.transfers!.length]),
    ucoTransfersBuffers,
    Uint8List.fromList([this.data!.ledger!.nft!.transfers!.length]),
    nftTransfersBuffers,
    Uint8List.fromList([this.data!.recipients!.length]),
    concatUint8List(this.data!.recipients!)
  ]);
}