TransactionRaw.fromJson constructor
Create a new TransactionRaw instance by parsing a JSON map.
Implementation
factory TransactionRaw.fromJson(Map<String, dynamic> json) {
final contractList = OnChainUtils.parseList(
value: json['contract'], name: 'contract', throwOnNull: true)!
.map((e) => TransactionContract.fromJson(OnChainUtils.parseMap(
value: e, name: 'contract', throwOnNull: true)!))
.toList();
if (contractList.length != 1) {
throw const TronPluginException(
'Transaction must contain exactly one contract.');
}
return TransactionRaw(
contract: contractList,
refBlockBytes: OnChainUtils.parseHex(
value: json['ref_block_bytes'], name: 'ref_block_bytes'),
refBlockHash: OnChainUtils.parseHex(
value: json['ref_block_hash'], name: 'ref_block_hash'),
expiration: OnChainUtils.parseBigInt(
value: json['expiration'], name: 'expiration'),
timestamp:
OnChainUtils.parseBigInt(value: json['timestamp'], name: 'timestamp'),
data: OnChainUtils.parseBytes(value: json['data'], name: 'data'),
feeLimit:
OnChainUtils.parseBigInt(value: json['fee_limit'], name: 'fee_limit'),
refBlockNum: OnChainUtils.parseBigInt(
value: json['ref_block_num'], name: 'ref_block_num'),
scripts: OnChainUtils.parseHex(value: json['scripts'], name: 'scripts'),
auths: OnChainUtils.parseList(value: json['auths'], name: 'auths')
?.map((e) => Authority.fromJson(OnChainUtils.parseMap(
value: e, name: 'auths', throwOnNull: true)!))
.toList(),
);
}