sendDocumentReceiptsList static method
Future<TransactionResult>
sendDocumentReceiptsList(
- List<
CommercioDocReceipt> commercioDocReceiptsList, - Wallet wallet, {
- StdFee? fee,
- BroadcastingMode? mode,
- Client? client,
Creates a new transaction which sends
a list of previously generated receipts commercioDocReceiptsList
.
Optionally fee
and broadcasting mode
parameters can be specified.
Implementation
static Future<TransactionResult> sendDocumentReceiptsList(
List<CommercioDocReceipt> commercioDocReceiptsList,
Wallet wallet, {
StdFee? fee,
BroadcastingMode? mode,
http.Client? client,
}) async {
List<StdMsg> msgs;
final isLegacy21Chain = await wallet.networkInfo.isVersion(version: '2.1');
if (isLegacy21Chain) {
msgs = commercioDocReceiptsList.map((docReceipt) {
// Convert the new CommercioDocReceipt entity to the old format
final legacy21Receipt =
legacy.CommercioDocReceiptMapper.toLegacy(docReceipt);
// Replace the msg with the newer document with the legacy one
return legacy.MsgSendDocumentReceipt(receipt: legacy21Receipt);
}).toList();
} else {
msgs = commercioDocReceiptsList
.map((commercioDocReceipt) =>
MsgSendDocumentReceipt(receipt: commercioDocReceipt))
.toList();
}
return TxHelper.createSignAndSendTx(
msgs,
wallet,
fee: fee,
mode: mode,
client: client,
);
}