@@ -1108,7 +1108,7 @@ class MintInfo {
11081108 ValueTransferOutput vto = ValueTransferOutput (
11091109 value: outputValues[i],
11101110 pkh: Address .fromAddress (outputAddresses[i]).publicKeyHash! ,
1111- // fixme : the explorer should return some value
1111+ // TODO : the explorer should return some value
11121112 timeLock: 0 ,
11131113 );
11141114 outputs.add (vto);
@@ -1151,102 +1151,246 @@ class MintInfo {
11511151class InputUtxo {
11521152 InputUtxo ({
11531153 required this .address,
1154- required this .input ,
1154+ required this .inputUtxo ,
11551155 required this .value,
11561156 });
11571157
11581158 final String address;
1159- final Input input ;
1159+ final String inputUtxo ;
11601160 final int value;
11611161
11621162 String rawJson () => json.encode (jsonMap ());
11631163
11641164 Map <String , dynamic > jsonMap () {
11651165 return {
1166- "pkh" : address,
1167- "output_pointer" :
1168- '${input .outputPointer .transactionId .hex }:${input .outputPointer .outputIndex }' ,
1166+ "address" : address,
11691167 "value" : value,
1168+ "input_utxo" : inputUtxo,
11701169 };
11711170 }
11721171
1172+ factory InputUtxo .fromJson (Map <String , dynamic > json) => InputUtxo (
1173+ address: json["address" ],
1174+ inputUtxo: json["input_utxo" ],
1175+ value: json["value" ]);
1176+
11731177 @override
11741178 String toString () {
11751179 // TODO: implement toString
11761180 return rawJson ();
11771181 }
11781182}
11791183
1180- class ValueTransferInfo extends HashInfo {
1181- ValueTransferInfo ({
1182- required this .epoch,
1183- required this .timestamp,
1184- required this .hash,
1185- required this .inputAddresses,
1186- required this .outputAddresses,
1184+ class InputMerged {
1185+ final String address;
1186+ final int value;
1187+
1188+ InputMerged ({
1189+ required this .address,
11871190 required this .value,
1188- required this .fee,
1189- required this .weight,
1190- required this .priority,
1191- }) : super (
1191+ });
1192+
1193+ factory InputMerged .fromJson (Map <String , dynamic > json) {
1194+ return InputMerged (address: json["address" ], value: json["value" ]);
1195+ }
1196+
1197+ String rawJson () => json.encode (jsonMap ());
1198+
1199+ Map <String , dynamic > jsonMap () {
1200+ return {"address" : address, 'value' : value};
1201+ }
1202+ }
1203+
1204+ class TransactionUtxo {
1205+ final String address;
1206+ final int value;
1207+ final int timelock;
1208+ final bool locked;
1209+
1210+ TransactionUtxo ({
1211+ required this .address,
1212+ required this .value,
1213+ required this .timelock,
1214+ required this .locked,
1215+ });
1216+
1217+ factory TransactionUtxo .fromJson (Map <String , dynamic > json) {
1218+ return TransactionUtxo (
1219+ address: json["address" ],
1220+ value: json["value" ],
1221+ timelock: json["timelock" ],
1222+ locked: json["locked" ]);
1223+ }
1224+
1225+ String rawJson () => json.encode (jsonMap ());
1226+
1227+ Map <String , dynamic > jsonMap () {
1228+ return {
1229+ "address" : address,
1230+ 'value' : value,
1231+ 'timelock' : timelock,
1232+ 'locked' : locked
1233+ };
1234+ }
1235+ }
1236+
1237+ // TransactionStatus getTransactionStatus(Map<String, dynamic> options) {
1238+ // TransactionStatus status;
1239+ // if (options["reverted"] == true) {
1240+ // status = TransactionStatus.reverted;
1241+ // } else if (options["confirmed"] == true) {
1242+ // status = TransactionStatus.confirmed;
1243+ // } else {
1244+ // status = TransactionStatus.pending;
1245+ // }
1246+
1247+ // return status;
1248+ // }
1249+
1250+ // TODO: move to a different place
1251+ // TODO: use this enum in all the package
1252+ enum TransactionStatus { pending, confirmed, reverted }
1253+
1254+ enum TransactionType { value_transfer, data_request }
1255+
1256+ class ValueTransferInfo extends HashInfo {
1257+ ValueTransferInfo (
1258+ {required this .epoch,
1259+ required this .timestamp,
1260+ required this .hash,
1261+ required this .inputAddresses,
1262+ required this .outputAddresses,
1263+ required this .value,
1264+ required this .fee,
1265+ required this .weight,
1266+ required this .priority,
1267+ required this .block,
1268+ required this .confirmed,
1269+ required this .reverted,
1270+ required this .inputUtxos,
1271+ required this .inputsMerged,
1272+ required this .outputValues,
1273+ required this .timelocks,
1274+ required this .utxos,
1275+ required this .utxosMerged,
1276+ required this .trueOutputAddresses,
1277+ required this .changeOutputAddresses,
1278+ required this .trueValue,
1279+ required this .changeValue,
1280+ required this .status,
1281+ required this .outputs})
1282+ : super (
11921283 txnHash: hash,
1193- // TODO: fix
1194- status: "status" ,
1195- // TODO: fix
1196- type: "type" ,
1284+ status: status,
1285+ type: TransactionType .value_transfer,
11971286 txnTime: epoch,
11981287 blockHash: null );
11991288
12001289 final int epoch;
12011290 final int timestamp;
12021291 final String hash;
1292+ final String block;
1293+ final bool confirmed;
1294+ final bool reverted;
12031295 final List <String > inputAddresses;
1296+ final List <InputUtxo > inputUtxos;
1297+ final List <InputMerged > inputsMerged;
12041298 final List <String > outputAddresses;
1205- final int value;
1299+ final List <int > outputValues;
1300+ final List <int > timelocks;
1301+ final List <TransactionUtxo > utxos;
1302+ final List <TransactionUtxo > utxosMerged;
12061303 final int fee;
1304+ final int value;
12071305 final int weight;
12081306 final int priority;
1307+ final List <String > trueOutputAddresses;
1308+ final List <String > changeOutputAddresses;
1309+ final int trueValue;
1310+ final int changeValue;
1311+ final TransactionStatus status;
1312+ final List <ValueTransferOutput > outputs;
12091313
12101314 factory ValueTransferInfo .fromJson (Map <String , dynamic > data) {
1315+ TransactionStatus status;
1316+ if (data["reverted" ] == true ) {
1317+ status = TransactionStatus .reverted;
1318+ } else if (data["confirmed" ] == true ) {
1319+ status = TransactionStatus .confirmed;
1320+ } else {
1321+ status = TransactionStatus .pending;
1322+ }
1323+
1324+ List <int > outputValues = data["output_values" ];
1325+ List <String > outputAddresses = data["output_addresses" ];
1326+ List <int > timelocks = data["timelocks" ];
1327+
1328+ List <ValueTransferOutput > outputs = [];
1329+ for (int i = 0 ; i < data.length; i++ ) {
1330+ ValueTransferOutput vto = ValueTransferOutput (
1331+ value: outputValues[i],
1332+ pkh: Address .fromAddress (outputAddresses[i]).publicKeyHash! ,
1333+ timeLock: timelocks[i],
1334+ );
1335+ outputs.add (vto);
1336+ }
1337+
12111338 return ValueTransferInfo (
12121339 epoch: data["epoch" ],
12131340 timestamp: data["timestamp" ],
12141341 hash: data["hash" ],
1342+ block: data["block" ],
1343+ confirmed: data["confirmed" ],
1344+ reverted: data["reverted" ],
12151345 inputAddresses: data["input_addresses" ],
1216- outputAddresses: data["output_addresses" ],
1217- value: data["value" ],
1346+ inputUtxos: data["input_utxos" ].map ((x) => InputUtxo .fromJson (x)),
1347+ inputsMerged: data["inputs_merged" ].map ((x) => InputMerged .fromJson (x)),
1348+ outputAddresses: outputAddresses,
1349+ outputValues: outputValues,
1350+ timelocks: timelocks,
1351+ utxos: data["utxos" ].map ((e) => TransactionUtxo .fromJson (e)),
1352+ utxosMerged:
1353+ data["utxos_merged" ].map ((e) => TransactionUtxo .fromJson (e)),
12181354 fee: data["fee" ],
1355+ value: data["value" ],
1356+ priority: data["priority" ],
12191357 weight: data["weight" ],
1220- priority: data["priority" ]);
1221- }
1222-
1223- factory ValueTransferInfo .fromDbJson (Map <String , dynamic > data) {
1224- return ValueTransferInfo (
1225- epoch: data["epoch" ],
1226- timestamp: data["timestamp" ],
1227- hash: data["hash" ],
1228- inputAddresses: data["input_addresses" ],
1229- outputAddresses: data["output_addresses" ],
1230- value: data["value" ],
1231- fee: data["fee" ],
1232- weight: data["weight" ],
1233- priority: data["priority" ],
1234- );
1358+ trueOutputAddresses: data["true_output_addresses" ],
1359+ changeOutputAddresses: data["change_output_addresses" ],
1360+ trueValue: data["true_value" ],
1361+ changeValue: data["change_value" ],
1362+ status: status,
1363+ outputs: outputs);
12351364 }
12361365
12371366 String rawJson () => json.encode (jsonMap ());
12381367
12391368 Map <String , dynamic > jsonMap () {
12401369 return {
12411370 "epoch" : epoch,
1242- 'timestamp' : timestamp,
1243- 'hash' : hash,
1244- 'input_addresses' : inputAddresses,
1245- 'output_addresses' : outputAddresses,
1246- 'value' : value,
1247- 'fee' : fee,
1248- 'weight' : weight,
1249- 'priority' : priority,
1371+ "timestamp" : timestamp,
1372+ "hash" : hash,
1373+ "block" : block,
1374+ "confirmed" : confirmed,
1375+ "reverted" : reverted,
1376+ "input_addresses" : inputAddresses,
1377+ "input_utxos" : inputUtxos.map ((e) => e.jsonMap ()),
1378+ "inputs_merged" : inputsMerged.map ((e) => e.jsonMap ()),
1379+ "output_addresses" : outputAddresses,
1380+ "output_values" : outputValues,
1381+ "timelocks" : timelocks,
1382+ "utxos" : utxos.map ((e) => e.jsonMap ()),
1383+ "utxos_merged" : utxosMerged.map ((e) => e.jsonMap ()),
1384+ "fee" : fee,
1385+ "value" : value,
1386+ "priority" : priority,
1387+ "weight" : weight,
1388+ "true_output_addresses" : trueOutputAddresses,
1389+ "change_output_addresses" : changeOutputAddresses,
1390+ "trueValue" : trueValue,
1391+ "changeValue" : changeValue,
1392+ "status" : status,
1393+ "outputs" : outputs,
12501394 };
12511395 }
12521396
@@ -1690,8 +1834,8 @@ class HashInfo {
16901834 });
16911835
16921836 final String txnHash;
1693- final String status;
1694- final String type;
1837+ final TransactionStatus status;
1838+ final TransactionType type;
16951839 final int txnTime;
16961840 final dynamic blockHash;
16971841
0 commit comments