shareDocumentsList static method
Create a new transaction that allows to share a list of previously
generated documents commercioDocsList
signing with wallet
.
Optionally fee
and broadcasting mode
parameters can be specified.
Implementation
static Future<TransactionResult> shareDocumentsList(
List<CommercioDoc> commercioDocsList,
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 = commercioDocsList.map((commercioDoc) {
// Convert the new CommercioDoc entity to the old format
final legacy21Doc = legacy.CommercioDocMapper.toLegacy(commercioDoc);
// Replace the msg with the newer document with the legacy one
return legacy.MsgShareDocument(document: legacy21Doc);
}).toList();
} else {
msgs = commercioDocsList
.map((commercioDoc) => MsgShareDocument(document: commercioDoc))
.toList();
}
return TxHelper.createSignAndSendTx(
msgs,
wallet,
fee: fee,
mode: mode,
client: client,
);
}