previousSignaturePayload method
Generate the payload for the previous signature by encoding address, type and data
Implementation
Uint8List previousSignaturePayload() {
final Uint8List bufCodeSize = encodeInt32(this.data!.code!.length);
int contentSize = this.data!.content!.length;
if (this.data!.content! is String) {
contentSize =
Uint8List.fromList(utf8.encode(this.data!.content!)).lengthInBytes;
}
final Uint8List bufContentSize = encodeInt32(contentSize);
final Uint8List bufSecretSize =
encodeInt32(this.data!.keys!.secret!.length);
Uint8List authorizedKeysBuffers = Uint8List(0);
this.data!.keys!.authorizedKeys!.forEach((authorizedKey) {
authorizedKeysBuffers = concatUint8List([
hexToUint8List(authorizedKey.publicKey!),
hexToUint8List(authorizedKey.encryptedKey!)
]);
});
Uint8List ucoTransfersBuffers = Uint8List(0);
if (this.data!.ledger!.uco!.transfers!.isNotEmpty) {
this
.data!
.ledger!
.uco!
.transfers!
.forEach((ucoTransfer) => ucoTransfersBuffers = concatUint8List([
ucoTransfersBuffers,
hexToUint8List(ucoTransfer.to!),
encodeFloat64(ucoTransfer.amount!)
]));
}
Uint8List nftTransfersBuffers = Uint8List(0);
if (this.data!.ledger!.nft!.transfers!.isNotEmpty) {
this
.data!
.ledger!
.nft!
.transfers!
.forEach((NFTTransfer) => nftTransfersBuffers = concatUint8List([
nftTransfersBuffers,
hexToUint8List(this.data!.ledger!.nft!.transfers![0].nft!),
hexToUint8List(this.data!.ledger!.nft!.transfers![0].to!),
encodeFloat64(this.data!.ledger!.nft!.transfers![0].amount!)
]));
}
Uint8List recipients = Uint8List(0);
this.data!.recipients!.forEach((recipient) {
recipients = concatUint8List([recipients, hexToUint8List(recipient)]);
});
return concatUint8List([
encodeInt32(this.version!),
hexToUint8List(this.address!),
Uint8List.fromList([txTypes[this.type]!]),
bufCodeSize,
Uint8List.fromList(utf8.encode(this.data!.code!)),
bufContentSize,
Uint8List.fromList(utf8.encode(this.data!.content!)),
bufSecretSize,
Uint8List.fromList(utf8.encode(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]),
recipients
]);
}