transferPreCombine method
Implementation
Future<rosetta.ConstructionPayloadsResponse> transferPreCombine(
Uint8List srcPub,
Uint8List destAddr,
BigInt count,
BigInt? maxFee,
Map<String, dynamic>? opt) async {
assert(networkIdentifier != null, "Cannot get networkIdentifier");
var netId = networkIdentifier;
var oper1 = rosetta.Operation.fromMap(
{
"operation_identifier": {"index": 0},
"type": "TRANSACTION",
"account": {
"address": getAccountIdFromEd25519PublicKey(srcPub).toHex()
},
"amount": {
"value": "-${count.toRadixString(10)}",
"currency": currency?.toJson(),
},
},
).toJson();
var oper2 = rosetta.Operation.fromMap(
{
"operation_identifier": {"index": 1},
"type": "TRANSACTION",
"account": {
"address": crc32Add(destAddr).toHex(),
},
"amount": {
"value": count.toRadixString(10),
"currency": currency?.toJson(),
},
},
).toJson();
var oper3 = rosetta.Operation.fromMap(
{
"operation_identifier": {"index": 2},
"type": "FEE",
"account": {
"address": getAccountIdFromEd25519PublicKey(srcPub).toHex()
},
"amount": {
"value":
"-${maxFee?.toRadixString(10) ?? suggestedFee?.toRadixString(10)}",
"currency": currency?.toJson(),
},
},
).toJson();
var metaResult = await metadata(rosetta.ConstructionMetadataRequest.fromMap(
{"network_identifier": netId?.toJson()}));
var meta = {...metaResult.metadata, ...?opt};
var _payloads = rosetta.ConstructionPayloadsRequest.fromMap({
"network_identifier": netId?.toJson(),
"operations": [oper1, oper2, oper3],
"metadata": meta,
"public_keys": [
{
"hex_bytes": srcPub.toHex(),
"curve_type": "edwards25519",
},
],
});
// print(jsonEncode(_payloads.toJson()));
return await payloads(_payloads);
}