diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart index 781a566ef..4bd42f70b 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart @@ -197,7 +197,7 @@ class _AddEditNodeViewState extends ConsumerState { case Coin.nano: case Coin.banano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: throw UnimplementedError(); //TODO: check network/node case Coin.tezos: @@ -732,11 +732,14 @@ class _NodeFormState extends ConsumerState { case Coin.namecoin: case Coin.bitcoincash: case Coin.particl: + case Coin.stellar: + case Coin.tezos: case Coin.bitcoinTestNet: case Coin.litecoinTestNet: case Coin.bitcoincashTestnet: case Coin.firoTestNet: case Coin.dogecoinTestNet: + case Coin.stellarTestNet: case Coin.epicCash: case Coin.nano: case Coin.banano: diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart index 31a9c6717..d22af6e25 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart @@ -174,7 +174,7 @@ class _NodeDetailsViewState extends ConsumerState { case Coin.banano: case Coin.tezos: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: throw UnimplementedError(); //TODO: check network/node } diff --git a/lib/services/coins/coin_service.dart b/lib/services/coins/coin_service.dart index 394ff5fc1..9ee397e0d 100644 --- a/lib/services/coins/coin_service.dart +++ b/lib/services/coins/coin_service.dart @@ -229,6 +229,15 @@ abstract class CoinServiceAPI { tracker: tracker, ); + case Coin.stellarTestNet: + return StellarWallet( + walletId: walletId, + walletName: walletName, + coin: coin, + secureStore: secureStorageInterface, + tracker: tracker, + ); + case Coin.tezos: return TezosWallet( walletId: walletId, diff --git a/lib/services/coins/tezos/tezos_wallet.dart b/lib/services/coins/tezos/tezos_wallet.dart index 4f66df22e..9fa8e499f 100644 --- a/lib/services/coins/tezos/tezos_wallet.dart +++ b/lib/services/coins/tezos/tezos_wallet.dart @@ -332,60 +332,61 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB { Future updateTransactions() async { // TODO: Use node RPC instead of tzstats API - var api = - "https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}"; - var jsonResponse = - jsonDecode(await get(Uri.parse(api)).then((value) => value.body)); + var api = "https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}"; + var jsonResponse = jsonDecode(await get(Uri.parse(api)).then((value) => value.body)); List> txs = []; for (var tx in jsonResponse as List) { - var txApi = "https://api.tzstats.com/explorer/op/${tx["hash"]}"; - var txJsonResponse = jsonDecode( - await get(Uri.parse(txApi)).then((value) => value.body))[0]; - TransactionType txType; - if (txJsonResponse["sender"] == (await currentReceivingAddress)) { - txType = TransactionType.outgoing; - } else { - txType = TransactionType.incoming; + if (tx[1] == "transaction") { + var txApi = "https://api.tzstats.com/explorer/op/${tx[2]}"; + var txJsonResponse = jsonDecode(await get(Uri.parse(txApi)).then((value) => value.body)); + // Check if list is larger than 1 (if it is, it's a batch transaction) + if (!((txJsonResponse as List).length > 1)) { + for (var (opJson as Map) in txJsonResponse) { + if (opJson.containsKey("volume")) { // This is to check if transaction is a token transfer + TransactionType txType; + if (opJson["sender"] == (await currentReceivingAddress)) { + txType = TransactionType.outgoing; + } else { + txType = TransactionType.incoming; + } + var theTx = Transaction( + walletId: walletId, + txid: opJson["hash"].toString(), + timestamp: DateTime.parse(opJson["time"].toString()).toUtc().millisecondsSinceEpoch ~/ 1000, + type: txType, + subType: TransactionSubType.none, + amount: (float.parse(opJson["volume"].toString()) * 1000000).toInt(), + amountString: Amount( + rawValue: BigInt.parse((float.parse(opJson["volume"].toString()) * 1000000).toInt().toString()), + fractionDigits: 6 + ).toJsonString(), + fee: (float.parse(opJson["fee"].toString()) * 1000000).toInt(), + height: int.parse(opJson["height"].toString()), + isCancelled: false, + isLelantus: false, + slateId: "", + otherData: "", + inputs: [], + outputs: [], + nonce: 0, + numberOfMessages: null, + ); + var theAddress = Address( + walletId: walletId, + value: opJson["receiver"].toString(), + publicKey: [], // TODO: Add public key + derivationIndex: 0, + derivationPath: null, + type: AddressType.unknown, + subType: AddressSubType.unknown, + ); + txs.add(Tuple2(theTx, theAddress)); + } + } + } } - var theTx = Transaction( - walletId: walletId, - txid: txJsonResponse["hash"].toString(), - timestamp: DateTime.parse(txJsonResponse["time"].toString()) - .toUtc() - .millisecondsSinceEpoch ~/ - 1000, - type: txType, - subType: TransactionSubType.none, - amount: (float.parse(txJsonResponse["volume"].toString()) * 1000000) - .toInt(), - amountString: Amount( - rawValue: BigInt.parse( - (float.parse(txJsonResponse["volume"].toString()) * 1000000) - .toString()), - fractionDigits: 6) - .toJsonString(), - fee: (float.parse(txJsonResponse["fee"].toString()) * 1000000).toInt(), - height: int.parse(txJsonResponse["height"].toString()), - isCancelled: false, - isLelantus: false, - slateId: "", - otherData: "", - inputs: [], - outputs: [], - nonce: 0, - numberOfMessages: null, - ); - var theAddress = Address( - walletId: walletId, - value: txJsonResponse["receiver"].toString(), - publicKey: [], // TODO: Add public key - derivationIndex: 0, - derivationPath: null, - type: AddressType.unknown, - subType: AddressSubType.unknown, - ); - txs.add(Tuple2(theTx, theAddress)); } + Logging.instance.log("Transactions: $txs", level: LogLevel.Info); await db.addNewTransactionData(txs, walletId); } diff --git a/lib/themes/color_theme.dart b/lib/themes/color_theme.dart index abec28d4e..0e6816dd8 100644 --- a/lib/themes/color_theme.dart +++ b/lib/themes/color_theme.dart @@ -65,7 +65,7 @@ class CoinThemeColorDefault { case Coin.particl: return particl; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return stellar; case Coin.nano: return nano; diff --git a/lib/themes/stack_colors.dart b/lib/themes/stack_colors.dart index cbec0077a..fde5219cf 100644 --- a/lib/themes/stack_colors.dart +++ b/lib/themes/stack_colors.dart @@ -1708,7 +1708,7 @@ class StackColors extends ThemeExtension { case Coin.particl: return _coin.particl; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return _coin.stellar; case Coin.nano: return _coin.nano; diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index 3fa895282..b4974d8c6 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -143,7 +143,7 @@ class AddressUtils { return Address.validateAddress(address, firoTestNetwork); case Coin.dogecoinTestNet: return Address.validateAddress(address, dogecointestnet); - case Coin.stellarTestnet: + case Coin.stellarTestNet: return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); } } diff --git a/lib/utilities/amount/amount_unit.dart b/lib/utilities/amount/amount_unit.dart index 6a646fd11..00055a0fe 100644 --- a/lib/utilities/amount/amount_unit.dart +++ b/lib/utilities/amount/amount_unit.dart @@ -51,7 +51,7 @@ enum AmountUnit { case Coin.eCash: case Coin.epicCash: case Coin.stellar: // TODO: check if this is correct - case Coin.stellarTestnet: + case Coin.stellarTestNet: case Coin.tezos: return AmountUnit.values.sublist(0, 4); diff --git a/lib/utilities/block_explorers.dart b/lib/utilities/block_explorers.dart index bb4ac06fb..ddc055fb1 100644 --- a/lib/utilities/block_explorers.dart +++ b/lib/utilities/block_explorers.dart @@ -60,7 +60,7 @@ Uri getDefaultBlockExplorerUrlFor({ return Uri.parse("https://www.nanolooker.com/block/$txid"); case Coin.banano: return Uri.parse("https://www.bananolooker.com/block/$txid"); - case Coin.stellarTestnet: + case Coin.stellarTestNet: return Uri.parse("https://testnet.stellarchain.io/transactions/$txid"); case Coin.tezos: return Uri.parse("https://tzstats.com/$txid"); diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 1253e08f1..1bd3a5a50 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -102,7 +102,7 @@ abstract class Constants { return _satsPerCoinECash; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return _satsPerCoinStellar; case Coin.tezos: @@ -146,7 +146,7 @@ abstract class Constants { return _decimalPlacesECash; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return _decimalPlacesStellar; case Coin.tezos: @@ -174,7 +174,7 @@ abstract class Constants { case Coin.particl: case Coin.nano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: values.addAll([24, 12]); break; case Coin.banano: @@ -238,7 +238,7 @@ abstract class Constants { return 1; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return 5; case Coin.tezos: @@ -271,7 +271,7 @@ abstract class Constants { case Coin.nano: case Coin.banano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: case Coin.tezos: return 24; diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 7a4daf2f2..7fed3d7fd 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -292,10 +292,10 @@ abstract class DefaultNodes { host: "https://horizon-testnet.stellar.org/", port: 50022, name: defaultName, - id: _nodeId(Coin.stellarTestnet), + id: _nodeId(Coin.stellarTestNet), useSSL: true, enabled: true, - coinName: Coin.stellarTestnet.name, + coinName: Coin.stellarTestNet.name, isFailover: true, isDown: false, ); @@ -365,7 +365,7 @@ abstract class DefaultNodes { case Coin.dogecoinTestNet: return dogecoinTestnet; - case Coin.stellarTestnet: + case Coin.stellarTestNet: return stellarTestnet; } } diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart index b62e4ea67..2e5062b6d 100644 --- a/lib/utilities/enums/coin_enum.dart +++ b/lib/utilities/enums/coin_enum.dart @@ -60,9 +60,10 @@ enum Coin { dogecoinTestNet, firoTestNet, litecoinTestNet, + stellarTestNet, } -final int kTestNetCoinCount = 4; // Util.isDesktop ? 5 : 4; +final int kTestNetCoinCount = 5; // Util.isDesktop ? 5 : 4; // remove firotestnet for now extension CoinExt on Coin { @@ -110,6 +111,8 @@ extension CoinExt on Coin { return "tFiro"; case Coin.dogecoinTestNet: return "tDogecoin"; + case Coin.stellarTestNet: + return "tStellar"; } } @@ -157,7 +160,7 @@ extension CoinExt on Coin { return "tFIRO"; case Coin.dogecoinTestNet: return "tDOGE"; - case Coin.stellarTestnet: + case Coin.stellarTestNet: return "tXLM"; } } @@ -207,7 +210,7 @@ extension CoinExt on Coin { return "firo"; case Coin.dogecoinTestNet: return "dogecoin"; - case Coin.stellarTestnet: + case Coin.stellarTestNet: return "stellar"; } } @@ -237,7 +240,7 @@ extension CoinExt on Coin { case Coin.nano: case Coin.banano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return false; } } @@ -267,7 +270,7 @@ extension CoinExt on Coin { case Coin.nano: case Coin.banano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return false; } } @@ -297,7 +300,7 @@ extension CoinExt on Coin { case Coin.litecoinTestNet: case Coin.bitcoincashTestnet: case Coin.firoTestNet: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return true; } } @@ -337,7 +340,7 @@ extension CoinExt on Coin { case Coin.firoTestNet: return Coin.firo; - case Coin.stellarTestnet: + case Coin.stellarTestNet: return Coin.stellar; } } @@ -380,7 +383,7 @@ extension CoinExt on Coin { return particl.MINIMUM_CONFIRMATIONS; case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: return xlm.MINIMUM_CONFIRMATIONS; case Coin.tezos: @@ -500,7 +503,7 @@ Coin coinFromPrettyName(String name) { case "Stellar Testnet": case "stellarTestnet": case "tStellar": - return Coin.stellarTestnet; + return Coin.stellarTestNet; default: throw ArgumentError.value( @@ -556,7 +559,7 @@ Coin coinFromTickerCaseInsensitive(String ticker) { case "ban": return Coin.banano; case "txlm": - return Coin.stellarTestnet; + return Coin.stellarTestNet; default: throw ArgumentError.value( ticker, "name", "No Coin enum value with that ticker"); diff --git a/lib/utilities/enums/derive_path_type_enum.dart b/lib/utilities/enums/derive_path_type_enum.dart index 5b94f41f6..f3c456f67 100644 --- a/lib/utilities/enums/derive_path_type_enum.dart +++ b/lib/utilities/enums/derive_path_type_enum.dart @@ -50,7 +50,7 @@ extension DerivePathTypeExt on DerivePathType { case Coin.nano: case Coin.banano: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: case Coin.tezos: // TODO: Is this true? throw UnsupportedError( "$coin does not use bitcoin style derivation paths"); diff --git a/lib/widgets/node_card.dart b/lib/widgets/node_card.dart index 661af4190..8d4c29ac2 100644 --- a/lib/widgets/node_card.dart +++ b/lib/widgets/node_card.dart @@ -196,7 +196,7 @@ class _NodeCardState extends ConsumerState { case Coin.banano: case Coin.tezos: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: throw UnimplementedError(); //TODO: check network/node } diff --git a/lib/widgets/node_options_sheet.dart b/lib/widgets/node_options_sheet.dart index 953ac78a1..63fd2b13e 100644 --- a/lib/widgets/node_options_sheet.dart +++ b/lib/widgets/node_options_sheet.dart @@ -179,7 +179,7 @@ class NodeOptionsSheet extends ConsumerWidget { case Coin.banano: case Coin.tezos: case Coin.stellar: - case Coin.stellarTestnet: + case Coin.stellarTestNet: throw UnimplementedError(); //TODO: check network/node } diff --git a/pubspec.lock b/pubspec.lock index cfdf7a710..c01aca249 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -25,6 +25,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.12.30" + ansicolor: + dependency: transitive + description: + name: ansicolor + sha256: "607f8fa9786f392043f169898923e6c59b4518242b68b8862eb8a8b7d9c30b4a" + url: "https://pub.dev" + source: hosted + version: "2.0.1" archive: dependency: "direct main" description: @@ -298,10 +306,10 @@ packages: dependency: "direct main" description: name: crypto - sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67 url: "https://pub.dev" source: hosted - version: "3.0.3" + version: "3.0.2" cryptography: dependency: transitive description: @@ -454,10 +462,10 @@ packages: dependency: transitive description: name: dio - sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993" + sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8" url: "https://pub.dev" source: hosted - version: "5.3.0" + version: "4.0.6" dropdown_button2: dependency: "direct main" description: @@ -942,6 +950,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" + json_serializable: + dependency: transitive + description: + name: json_serializable + sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969 + url: "https://pub.dev" + source: hosted + version: "6.7.1" keyboard_dismisser: dependency: "direct main" description: @@ -1005,6 +1021,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" + memoize: + dependency: transitive + description: + name: memoize + sha256: "51481d328c86cbdc59711369179bac88551ca0556569249be5317e66fc796cac" + url: "https://pub.dev" + source: hosted + version: "3.0.0" meta: dependency: transitive description: @@ -1230,13 +1254,13 @@ packages: source: hosted version: "5.4.0" pinenacl: - dependency: transitive + dependency: "direct overridden" description: name: pinenacl - sha256: "3a5503637587d635647c93ea9a8fecf48a420cc7deebe6f1fc85c2a5637ab327" + sha256: e5fb0bce1717b7f136f35ee98b5c02b3e6383211f8a77ca882fa7812232a07b9 url: "https://pub.dev" source: hosted - version: "0.5.1" + version: "0.3.4" platform: dependency: transitive description: @@ -1269,6 +1293,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.1" + pretty_dio_logger: + dependency: transitive + description: + name: pretty_dio_logger + sha256: "948f7eeb36e7aa0760b51c1a8e3331d4b21e36fabd39efca81f585ed93893544" + url: "https://pub.dev" + source: hosted + version: "1.2.0-beta-1" process: dependency: transitive description: @@ -1317,6 +1349,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.1.0" + quiver: + dependency: transitive + description: + name: quiver + sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47 + url: "https://pub.dev" + source: hosted + version: "3.2.1" rational: dependency: transitive description: @@ -1325,6 +1365,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.2" + retry: + dependency: transitive + description: + name: retry + sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc" + url: "https://pub.dev" + source: hosted + version: "3.1.2" riverpod: dependency: transitive description: @@ -1471,10 +1519,10 @@ packages: dependency: "direct main" description: name: stellar_flutter_sdk - sha256: "7a9b7dc76018bbd0b9c828045cf0e26e07ec44208fb1a1733273de2390205475" + sha256: "4c55b1b6dfbde7f89bba59a422754280715fa3b5726cff5e7eeaed454d2c4b89" url: "https://pub.dev" source: hosted - version: "1.6.0" + version: "1.5.3" stream_channel: dependency: transitive description: @@ -1547,6 +1595,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.5.1" + tezart: + dependency: "direct main" + description: + name: tezart + sha256: "35d526f2e6ca250c64461ebfb4fa9f64b6599fab8c4242c8e89ae27d4ac2e15a" + url: "https://pub.dev" + source: hosted + version: "2.0.5" time: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 506d6d431..e3fa11745 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -138,7 +138,7 @@ dependencies: desktop_drop: ^0.4.1 nanodart: ^2.0.0 basic_utils: ^5.5.4 - stellar_flutter_sdk: ^1.6.0 + stellar_flutter_sdk: ^1.5.3 tezart: ^2.0.5 dev_dependencies: @@ -202,6 +202,7 @@ dependency_overrides: crypto: 3.0.2 analyzer: ^5.2.0 + pinenacl: ^0.3.3 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec