createSignature method
Implementation
Future<SignatureV2> createSignature(
CORE_SIGN.SignDoc tx, List<dynamic> messages) async {
var keyDto = KeysDto(CosmosKeys.SECP256K1_SIMP_PUBKEY, 0,
publicKey!.getPublicKeyAsBase64(), null);
var copyTx = tx;
copyTx.auth_info.signer_infos = [
SignerInfo(keyDto, copyTx.sequence,
ModeInfo(SignatureV2Single(mode: SignMode.SIGN_MODE_DIRECT)))
];
var dataToEncode = copyTx.toProto(
messages: messages
.map((w) => JSONMessageBodyConverter.getJsonFromBody(w))
.toList());
var signature = sign(dataToEncode);
var sigBytes = TerraStringExtension.getBase64FromBytes(signature);
return SignatureV2(
keyDto,
SignatureV2Descriptor(SignatureV2Single(
mode: SignMode.SIGN_MODE_DIRECT, signature: sigBytes)),
tx.sequence);
}