getSignBytes method
getSignBytes returns the sign bytes for the provided SignMode, SignerData and Tx, or an error
Implementation
@override
List<int> getSignBytes(SignMode mode, SignerData data, Tx tx) {
if (mode != SignMode.SIGN_MODE_DIRECT) {
return throw Exception('Unsupported sign mode: $mode');
}
final bodyBytes = tx.body.writeToBuffer();
final authInfoBytes = tx.authInfo.writeToBuffer();
final signDoc = SignDoc.create();
if (bodyBytes.isNotEmpty) {
signDoc.bodyBytes = bodyBytes;
}
if (authInfoBytes.isNotEmpty) {
signDoc.authInfoBytes = authInfoBytes;
}
if (data.chainId.isNotEmpty) {
signDoc.chainId = data.chainId;
}
if (data.accountNumber > 0) {
signDoc.accountNumber = data.accountNumber;
}
return signDoc.writeToBuffer();
}