transactionDataToGrpcTransaction function
Implementation
grpc_transaction.Transaction transactionDataToGrpcTransaction(TransactionData data) {
final inputs = data.inputs?.map(callArgToGrpcInput).toList();
final commands = data.commands?.map(commandToGrpcCommand).toList();
final tx = grpc_transaction.Transaction(
version: 1,
sender: data.sender,
kind: grpc_transaction.TransactionKind(
kind: grpc_transaction.TransactionKind_Kind.PROGRAMMABLE_TRANSACTION,
programmableTransaction: (grpc_transaction.ProgrammableTransaction()
..inputs.addAll(inputs ?? [])
..commands.addAll(commands ?? [])),
),
gasPayment: grpc_transaction.GasPayment(
objects: data.gasData.payment
?.map(
(ref) => ObjectReference()
..objectId = ref.objectId
..version = Int64.parseRadix(ref.version.toString(), 10)
..digest = ref.digest,
)
.toList(),
owner: data.gasData.owner ?? data.sender,
price: data.gasData.price != null
? Int64.parseRadix(data.gasData.price.toString(), 10)
: null,
budget: data.gasData.budget != null
? Int64.parseRadix(data.gasData.budget.toString(), 10)
: null,
),
);
if (data.expiration != null) {
if (data.expiration?.epoch == null) {
tx.expiration = (grpc_transaction.TransactionExpiration()
..kind = grpc_transaction.TransactionExpiration_TransactionExpirationKind.NONE);
} else {
tx.expiration = (grpc_transaction.TransactionExpiration()
..kind = grpc_transaction.TransactionExpiration_TransactionExpirationKind.EPOCH
..epoch = Int64.parseRadix(data.expiration!.epoch.toString(), 10));
}
}
return tx;
}