setSignatures method
Sets the given signatures
as the transaction sigantures.
Implementation
void setSignatures(List<SignatureV2> signatures) {
final signerInfos = <SignerInfo>[];
final rawSigs = <List<int>>[];
for (var index = 0; index < signatures.length; index++) {
final signature = signatures[index];
if (signature.data is! SingleSignatureData) {
throw Exception('Signature data not supported: ${signature.data}');
}
final data = signature.data as SingleSignatureData;
if (data.signature != null) {
rawSigs.add(data.signature!);
}
final single = ModeInfo_Single.create()..mode = data.signMode;
final modeInfo = ModeInfo.create()..single = single;
final signerInfo = SignerInfo.create()
..modeInfo = modeInfo
..publicKey = signature.pubKey;
// Do not include default values as per ADR-027
if (signature.sequence > 0) {
signerInfo.sequence = signature.sequence;
}
signerInfos.add(signerInfo);
}
// Set the raw signatures
_stdTx.signatures.clear();
_stdTx.signatures.addAll(rawSigs);
// Create the AuthInfo if not existing
if (!_stdTx.hasAuthInfo()) {
_stdTx.authInfo = AuthInfo.create();
}
// Set the signer infos
_stdTx.authInfo.signerInfos.clear();
_stdTx.authInfo.signerInfos.addAll(signerInfos);
}