decodeFromBytes static method
Decode this operation from raw bytes
Implementation
static DeListForSaleOperation decodeFromBytes(Uint8List bytes) {
// Decode byte-by-byte
int offset = 0;
// Signer
AccountNumberCoder acctNumCoder = AccountNumberCoder();
Uint8List signerBytes = bytes.sublist(offset, offset + 4);
AccountNumber signer = acctNumCoder.decodeFromBytes(signerBytes);
offset += 4;
// Target
Uint8List targetBytes = bytes.sublist(offset, offset + 4);
AccountNumber target = acctNumCoder.decodeFromBytes(targetBytes);
offset += 4;
// Optype
Uint8List opTypeBytes = bytes.sublist(offset, offset + 2);
//int opType = OpTypeCoder(2).decodeFromBytes(opTypeBytes);
offset += 2;
// nOp
Uint8List nOperationBytes = bytes.sublist(offset, offset + 4);
int nOperation = Int32.decodeFromBytes(nOperationBytes);
offset += 4;
// Fee
Uint8List feeBytes = bytes.sublist(offset, offset + 8);
Currency fee = CurrencyCoder().decodeFromBytes(feeBytes);
offset += 8;
// Payload
int payloadLength = PDUtil.decodeLength(bytes.sublist(offset, offset + 2));
offset += 2;
Uint8List payload = bytes.sublist(offset, offset + payloadLength);
offset += payloadLength;
// Signature
int rLength = PDUtil.decodeLength(bytes.sublist(offset, offset + 2));
offset += 2;
BigInt r = PDUtil.decodeBigInt(bytes.sublist(offset, offset + rLength));
offset += rLength;
int sLength = PDUtil.decodeLength(bytes.sublist(offset, offset + 2));
offset += 2;
BigInt s = PDUtil.decodeBigInt(bytes.sublist(offset, offset + sLength));
Signature signature = Signature(r: r, s: s);
// Return op
return DeListForSaleOperation(accountSigner: signer, targetSigner: target)
..withNOperation(nOperation)
..withFee(fee)
..withPayload(payload)
..withSignature(signature);
}