buildTxCompressedData function
Encode tx compressed data @param {Object} tx - Transaction object @returns {BigInt} Encoded tx compressed data
Implementation
BigInt buildTxCompressedData(Map<String, dynamic> tx) {
final signatureConstant = BigInt.parse('3322668559');
BigInt res = BigInt.zero;
final chainId =
BigInt.from((tx['chainId'] != null ? tx['chainId'] : 0)) << 32;
final fromAccountIndex = BigInt.from(
(tx['fromAccountIndex'] != null ? tx['fromAccountIndex'] : 0)) <<
48;
final toAccountIndex =
BigInt.from((tx['toAccountIndex'] != null ? tx['toAccountIndex'] : 0)) <<
96;
final tokenId =
BigInt.from((tx['tokenId'] != null ? tx['tokenId'] : 0)) << 144;
final nonce = BigInt.from((tx['nonce'] != null ? tx['nonce'] : 0)) << 176;
final fee = BigInt.from((tx['fee'] != null ? tx['fee'] : 0)) << 216;
final toBjjSign = BigInt.from((tx['toBjjSign'] != null ? 1 : 0)) << 224;
res = res + signatureConstant; // SignConst --> 32 bits -> 4 bytes
res = res + chainId; // chainId --> 16 bits
res = res + fromAccountIndex; // fromIdx --> 48 bits
res = res + toAccountIndex; // toIdx --> 48 bits
res = res + tokenId; // tokenID --> 32 bits
res = res + nonce; // nonce --> 40 bits
res = res + fee; // userFee --> 8 bits
res = res + toBjjSign; // toBjjSign --> 1 bit
return res;
}