TransactionReference.fromJson constructor
TransactionReference.fromJson(
- Map<String, dynamic> json
)
Implementation
factory TransactionReference.fromJson(Map<String, dynamic> json) {
// Tolerate a wrapped envelope: some senders (e.g. Base payment agents) emit
// {"transactionReference": {...}} instead of the canonical flat object.
// Keeping this here means both the codec and any reload-from-storage path
// share one wire-tolerant entry point.
final inner = json['transactionReference'];
final obj = inner is Map ? Map<String, dynamic>.from(inner) : json;
final rawNetworkId = obj['networkId'];
final networkId = rawNetworkId == null
? ''
: (rawNetworkId is String ? rawNetworkId : rawNetworkId.toString());
final rawMeta = obj['metadata'];
final metadata = rawMeta is Map
? TransactionMetadata.fromJson(Map<String, dynamic>.from(rawMeta))
: null;
return TransactionReference(
namespace: obj['namespace'] as String?,
networkId: networkId,
reference: (obj['reference'] as String?) ?? '',
metadata: metadata,
);
}