generateAndSendL2Tx function
Compact L2 transaction generated and sent to a Coordinator. @param {Object} transaction - ethAddress and babyPubKey together @param {String} transaction.from - The account index that's sending the transaction e.g hez:DAI:4444 @param {String} transaction.to - The account index of the receiver e.g hez:DAI:2156. If it's an Exit, set to a falseable value @param {BigInt} transaction.amount - The amount being sent as a BigInt @param {Number} transaction.fee - The amount of tokens to be sent as a fee to the Coordinator @param {Number} transaction.nonce - The current nonce of the sender's token account @param {HermezWallet} wallet - Transaction sender Hermez Wallet @param {Token} token - The token information object as returned from the Coordinator.
Implementation
dynamic generateAndSendL2Tx(
dynamic transaction, HermezWallet wallet, Token token) async {
final Set<Map<String, dynamic>> l2TxParams = await generateL2Transaction(
transaction, wallet.publicKeyCompressedHex, token);
Map<String, dynamic> l2Transaction = l2TxParams.first;
Map<String, dynamic> l2EncodedTransaction = l2TxParams.last;
wallet.signTransaction(l2Transaction, l2EncodedTransaction);
final l2TxResult =
await sendL2Transaction(l2Transaction, wallet.publicKeyCompressedHex);
return l2TxResult;
}