fromJson static method
Returns a new Transaction instance and imports its values from
value
if it's a Map, null otherwise.
Implementation
// ignore: prefer_constructors_over_static_methods
static Transaction? fromJson(dynamic value) {
if (value is Map) {
final json = value.cast<String, dynamic>();
// Ensure that the map contains the required keys.
// Note 1: the values aren't checked for validity beyond being non-null.
// Note 2: this code is stripped in release mode!
assert(() {
requiredKeys.forEach((key) {
assert(json.containsKey(key), 'Required key "Transaction[$key]" is missing from JSON.');
assert(json[key] != null, 'Required key "Transaction[$key]" has a null value in JSON.');
});
return true;
}());
return Transaction(
id: mapValueOfType<String>(json, r'id'),
createdAt: mapDateTime(json, r'createdAt', ''),
updatedAt: mapDateTime(json, r'updatedAt', ''),
amount: mapValueOfType<String>(json, r'amount'),
decimals: mapValueOfType<int>(json, r'decimals'),
destination: mapValueOfType<String>(json, r'destination'),
errors: TransactionError.listFromJson(json[r'errors']) ?? const [],
explorerUrl: mapValueOfType<String>(json, r'explorerUrl'),
feePayer: mapValueOfType<String>(json, r'feePayer'),
ip: mapValueOfType<String>(json, r'ip'),
mint: mapValueOfType<String>(json, r'mint'),
processingDuration: mapValueOfType<int>(json, r'processingDuration'),
referenceId: mapValueOfType<String>(json, r'referenceId'),
referenceType: mapValueOfType<String>(json, r'referenceType'),
signature: mapValueOfType<String>(json, r'signature'),
solanaCommitted: mapDateTime(json, r'solanaCommitted', ''),
solanaCommittedDuration: mapValueOfType<int>(json, r'solanaCommittedDuration'),
solanaFinalized: mapDateTime(json, r'solanaFinalized', ''),
solanaFinalizedDuration: mapValueOfType<int>(json, r'solanaFinalizedDuration'),
solanaStart: mapDateTime(json, r'solanaStart', ''),
solanaTransaction: mapValueOfType<Object>(json, r'solanaTransaction'),
source_: mapValueOfType<String>(json, r'source'),
status: TransactionStatus.fromJson(json[r'status']),
totalDuration: mapValueOfType<int>(json, r'totalDuration'),
tx: mapValueOfType<String>(json, r'tx'),
ua: mapValueOfType<String>(json, r'ua'),
webhookEventStart: mapDateTime(json, r'webhookEventStart', ''),
webhookEventEnd: mapDateTime(json, r'webhookEventEnd', ''),
webhookEventDuration: mapValueOfType<int>(json, r'webhookEventDuration'),
webhookVerifyStart: mapDateTime(json, r'webhookVerifyStart', ''),
webhookVerifyEnd: mapDateTime(json, r'webhookVerifyEnd', ''),
webhookVerifyDuration: mapValueOfType<int>(json, r'webhookVerifyDuration'),
);
}
return null;
}