Skip to content

Commit 74b0ca8

Browse files
authored
Merge pull request #641 from detherminal/add-xtz
fix conflicts and add filter for other operations
2 parents 724f619 + a1ef84f commit 74b0ca8

File tree

17 files changed

+161
-88
lines changed

17 files changed

+161
-88
lines changed

lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
197197
case Coin.nano:
198198
case Coin.banano:
199199
case Coin.stellar:
200-
case Coin.stellarTestnet:
200+
case Coin.stellarTestNet:
201201
throw UnimplementedError();
202202
//TODO: check network/node
203203
case Coin.tezos:
@@ -732,11 +732,14 @@ class _NodeFormState extends ConsumerState<NodeForm> {
732732
case Coin.namecoin:
733733
case Coin.bitcoincash:
734734
case Coin.particl:
735+
case Coin.stellar:
736+
case Coin.tezos:
735737
case Coin.bitcoinTestNet:
736738
case Coin.litecoinTestNet:
737739
case Coin.bitcoincashTestnet:
738740
case Coin.firoTestNet:
739741
case Coin.dogecoinTestNet:
742+
case Coin.stellarTestNet:
740743
case Coin.epicCash:
741744
case Coin.nano:
742745
case Coin.banano:

lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
174174
case Coin.banano:
175175
case Coin.tezos:
176176
case Coin.stellar:
177-
case Coin.stellarTestnet:
177+
case Coin.stellarTestNet:
178178
throw UnimplementedError();
179179
//TODO: check network/node
180180
}

lib/services/coins/coin_service.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,15 @@ abstract class CoinServiceAPI {
229229
tracker: tracker,
230230
);
231231

232+
case Coin.stellarTestNet:
233+
return StellarWallet(
234+
walletId: walletId,
235+
walletName: walletName,
236+
coin: coin,
237+
secureStore: secureStorageInterface,
238+
tracker: tracker,
239+
);
240+
232241
case Coin.tezos:
233242
return TezosWallet(
234243
walletId: walletId,

lib/services/coins/tezos/tezos_wallet.dart

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -332,60 +332,61 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
332332

333333
Future<void> updateTransactions() async {
334334
// TODO: Use node RPC instead of tzstats API
335-
var api =
336-
"https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}";
337-
var jsonResponse =
338-
jsonDecode(await get(Uri.parse(api)).then((value) => value.body));
335+
var api = "https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}";
336+
var jsonResponse = jsonDecode(await get(Uri.parse(api)).then((value) => value.body));
339337
List<Tuple2<Transaction, Address>> txs = [];
340338
for (var tx in jsonResponse as List) {
341-
var txApi = "https://api.tzstats.com/explorer/op/${tx["hash"]}";
342-
var txJsonResponse = jsonDecode(
343-
await get(Uri.parse(txApi)).then((value) => value.body))[0];
344-
TransactionType txType;
345-
if (txJsonResponse["sender"] == (await currentReceivingAddress)) {
346-
txType = TransactionType.outgoing;
347-
} else {
348-
txType = TransactionType.incoming;
339+
if (tx[1] == "transaction") {
340+
var txApi = "https://api.tzstats.com/explorer/op/${tx[2]}";
341+
var txJsonResponse = jsonDecode(await get(Uri.parse(txApi)).then((value) => value.body));
342+
// Check if list is larger than 1 (if it is, it's a batch transaction)
343+
if (!((txJsonResponse as List).length > 1)) {
344+
for (var (opJson as Map) in txJsonResponse) {
345+
if (opJson.containsKey("volume")) { // This is to check if transaction is a token transfer
346+
TransactionType txType;
347+
if (opJson["sender"] == (await currentReceivingAddress)) {
348+
txType = TransactionType.outgoing;
349+
} else {
350+
txType = TransactionType.incoming;
351+
}
352+
var theTx = Transaction(
353+
walletId: walletId,
354+
txid: opJson["hash"].toString(),
355+
timestamp: DateTime.parse(opJson["time"].toString()).toUtc().millisecondsSinceEpoch ~/ 1000,
356+
type: txType,
357+
subType: TransactionSubType.none,
358+
amount: (float.parse(opJson["volume"].toString()) * 1000000).toInt(),
359+
amountString: Amount(
360+
rawValue: BigInt.parse((float.parse(opJson["volume"].toString()) * 1000000).toInt().toString()),
361+
fractionDigits: 6
362+
).toJsonString(),
363+
fee: (float.parse(opJson["fee"].toString()) * 1000000).toInt(),
364+
height: int.parse(opJson["height"].toString()),
365+
isCancelled: false,
366+
isLelantus: false,
367+
slateId: "",
368+
otherData: "",
369+
inputs: [],
370+
outputs: [],
371+
nonce: 0,
372+
numberOfMessages: null,
373+
);
374+
var theAddress = Address(
375+
walletId: walletId,
376+
value: opJson["receiver"].toString(),
377+
publicKey: [], // TODO: Add public key
378+
derivationIndex: 0,
379+
derivationPath: null,
380+
type: AddressType.unknown,
381+
subType: AddressSubType.unknown,
382+
);
383+
txs.add(Tuple2(theTx, theAddress));
384+
}
385+
}
386+
}
349387
}
350-
var theTx = Transaction(
351-
walletId: walletId,
352-
txid: txJsonResponse["hash"].toString(),
353-
timestamp: DateTime.parse(txJsonResponse["time"].toString())
354-
.toUtc()
355-
.millisecondsSinceEpoch ~/
356-
1000,
357-
type: txType,
358-
subType: TransactionSubType.none,
359-
amount: (float.parse(txJsonResponse["volume"].toString()) * 1000000)
360-
.toInt(),
361-
amountString: Amount(
362-
rawValue: BigInt.parse(
363-
(float.parse(txJsonResponse["volume"].toString()) * 1000000)
364-
.toString()),
365-
fractionDigits: 6)
366-
.toJsonString(),
367-
fee: (float.parse(txJsonResponse["fee"].toString()) * 1000000).toInt(),
368-
height: int.parse(txJsonResponse["height"].toString()),
369-
isCancelled: false,
370-
isLelantus: false,
371-
slateId: "",
372-
otherData: "",
373-
inputs: [],
374-
outputs: [],
375-
nonce: 0,
376-
numberOfMessages: null,
377-
);
378-
var theAddress = Address(
379-
walletId: walletId,
380-
value: txJsonResponse["receiver"].toString(),
381-
publicKey: [], // TODO: Add public key
382-
derivationIndex: 0,
383-
derivationPath: null,
384-
type: AddressType.unknown,
385-
subType: AddressSubType.unknown,
386-
);
387-
txs.add(Tuple2(theTx, theAddress));
388388
}
389+
Logging.instance.log("Transactions: $txs", level: LogLevel.Info);
389390
await db.addNewTransactionData(txs, walletId);
390391
}
391392

lib/themes/color_theme.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class CoinThemeColorDefault {
6565
case Coin.particl:
6666
return particl;
6767
case Coin.stellar:
68-
case Coin.stellarTestnet:
68+
case Coin.stellarTestNet:
6969
return stellar;
7070
case Coin.nano:
7171
return nano;

lib/themes/stack_colors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ class StackColors extends ThemeExtension<StackColors> {
17081708
case Coin.particl:
17091709
return _coin.particl;
17101710
case Coin.stellar:
1711-
case Coin.stellarTestnet:
1711+
case Coin.stellarTestNet:
17121712
return _coin.stellar;
17131713
case Coin.nano:
17141714
return _coin.nano;

lib/utilities/address_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ class AddressUtils {
143143
return Address.validateAddress(address, firoTestNetwork);
144144
case Coin.dogecoinTestNet:
145145
return Address.validateAddress(address, dogecointestnet);
146-
case Coin.stellarTestnet:
146+
case Coin.stellarTestNet:
147147
return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address);
148148
}
149149
}

lib/utilities/amount/amount_unit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ enum AmountUnit {
5151
case Coin.eCash:
5252
case Coin.epicCash:
5353
case Coin.stellar: // TODO: check if this is correct
54-
case Coin.stellarTestnet:
54+
case Coin.stellarTestNet:
5555
case Coin.tezos:
5656
return AmountUnit.values.sublist(0, 4);
5757

lib/utilities/block_explorers.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Uri getDefaultBlockExplorerUrlFor({
6060
return Uri.parse("https://www.nanolooker.com/block/$txid");
6161
case Coin.banano:
6262
return Uri.parse("https://www.bananolooker.com/block/$txid");
63-
case Coin.stellarTestnet:
63+
case Coin.stellarTestNet:
6464
return Uri.parse("https://testnet.stellarchain.io/transactions/$txid");
6565
case Coin.tezos:
6666
return Uri.parse("https://tzstats.com/$txid");

lib/utilities/constants.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ abstract class Constants {
102102
return _satsPerCoinECash;
103103

104104
case Coin.stellar:
105-
case Coin.stellarTestnet:
105+
case Coin.stellarTestNet:
106106
return _satsPerCoinStellar;
107107

108108
case Coin.tezos:
@@ -146,7 +146,7 @@ abstract class Constants {
146146
return _decimalPlacesECash;
147147

148148
case Coin.stellar:
149-
case Coin.stellarTestnet:
149+
case Coin.stellarTestNet:
150150
return _decimalPlacesStellar;
151151

152152
case Coin.tezos:
@@ -174,7 +174,7 @@ abstract class Constants {
174174
case Coin.particl:
175175
case Coin.nano:
176176
case Coin.stellar:
177-
case Coin.stellarTestnet:
177+
case Coin.stellarTestNet:
178178
values.addAll([24, 12]);
179179
break;
180180
case Coin.banano:
@@ -238,7 +238,7 @@ abstract class Constants {
238238
return 1;
239239

240240
case Coin.stellar:
241-
case Coin.stellarTestnet:
241+
case Coin.stellarTestNet:
242242
return 5;
243243

244244
case Coin.tezos:
@@ -271,7 +271,7 @@ abstract class Constants {
271271
case Coin.nano:
272272
case Coin.banano:
273273
case Coin.stellar:
274-
case Coin.stellarTestnet:
274+
case Coin.stellarTestNet:
275275
case Coin.tezos:
276276
return 24;
277277

0 commit comments

Comments
 (0)