Merge pull request #641 from detherminal/add-xtz

fix conflicts and add filter for other operations
This commit is contained in:
Rylee Davis 2023-07-28 14:22:49 -06:00 committed by GitHub
commit 74b0ca89bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 161 additions and 88 deletions

View file

@ -197,7 +197,7 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
throw UnimplementedError(); throw UnimplementedError();
//TODO: check network/node //TODO: check network/node
case Coin.tezos: case Coin.tezos:
@ -732,11 +732,14 @@ class _NodeFormState extends ConsumerState<NodeForm> {
case Coin.namecoin: case Coin.namecoin:
case Coin.bitcoincash: case Coin.bitcoincash:
case Coin.particl: case Coin.particl:
case Coin.stellar:
case Coin.tezos:
case Coin.bitcoinTestNet: case Coin.bitcoinTestNet:
case Coin.litecoinTestNet: case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet: case Coin.bitcoincashTestnet:
case Coin.firoTestNet: case Coin.firoTestNet:
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
case Coin.stellarTestNet:
case Coin.epicCash: case Coin.epicCash:
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:

View file

@ -174,7 +174,7 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
case Coin.banano: case Coin.banano:
case Coin.tezos: case Coin.tezos:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
throw UnimplementedError(); throw UnimplementedError();
//TODO: check network/node //TODO: check network/node
} }

View file

@ -229,6 +229,15 @@ abstract class CoinServiceAPI {
tracker: tracker, tracker: tracker,
); );
case Coin.stellarTestNet:
return StellarWallet(
walletId: walletId,
walletName: walletName,
coin: coin,
secureStore: secureStorageInterface,
tracker: tracker,
);
case Coin.tezos: case Coin.tezos:
return TezosWallet( return TezosWallet(
walletId: walletId, walletId: walletId,

View file

@ -332,40 +332,36 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
Future<void> updateTransactions() async { Future<void> updateTransactions() async {
// TODO: Use node RPC instead of tzstats API // TODO: Use node RPC instead of tzstats API
var api = var api = "https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}";
"https://api.tzstats.com/tables/op?address=${await currentReceivingAddress}"; var jsonResponse = jsonDecode(await get(Uri.parse(api)).then((value) => value.body));
var jsonResponse =
jsonDecode(await get(Uri.parse(api)).then((value) => value.body));
List<Tuple2<Transaction, Address>> txs = []; List<Tuple2<Transaction, Address>> txs = [];
for (var tx in jsonResponse as List) { for (var tx in jsonResponse as List) {
var txApi = "https://api.tzstats.com/explorer/op/${tx["hash"]}"; if (tx[1] == "transaction") {
var txJsonResponse = jsonDecode( var txApi = "https://api.tzstats.com/explorer/op/${tx[2]}";
await get(Uri.parse(txApi)).then((value) => value.body))[0]; 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; TransactionType txType;
if (txJsonResponse["sender"] == (await currentReceivingAddress)) { if (opJson["sender"] == (await currentReceivingAddress)) {
txType = TransactionType.outgoing; txType = TransactionType.outgoing;
} else { } else {
txType = TransactionType.incoming; txType = TransactionType.incoming;
} }
var theTx = Transaction( var theTx = Transaction(
walletId: walletId, walletId: walletId,
txid: txJsonResponse["hash"].toString(), txid: opJson["hash"].toString(),
timestamp: DateTime.parse(txJsonResponse["time"].toString()) timestamp: DateTime.parse(opJson["time"].toString()).toUtc().millisecondsSinceEpoch ~/ 1000,
.toUtc()
.millisecondsSinceEpoch ~/
1000,
type: txType, type: txType,
subType: TransactionSubType.none, subType: TransactionSubType.none,
amount: (float.parse(txJsonResponse["volume"].toString()) * 1000000) amount: (float.parse(opJson["volume"].toString()) * 1000000).toInt(),
.toInt(),
amountString: Amount( amountString: Amount(
rawValue: BigInt.parse( rawValue: BigInt.parse((float.parse(opJson["volume"].toString()) * 1000000).toInt().toString()),
(float.parse(txJsonResponse["volume"].toString()) * 1000000) fractionDigits: 6
.toString()), ).toJsonString(),
fractionDigits: 6) fee: (float.parse(opJson["fee"].toString()) * 1000000).toInt(),
.toJsonString(), height: int.parse(opJson["height"].toString()),
fee: (float.parse(txJsonResponse["fee"].toString()) * 1000000).toInt(),
height: int.parse(txJsonResponse["height"].toString()),
isCancelled: false, isCancelled: false,
isLelantus: false, isLelantus: false,
slateId: "", slateId: "",
@ -377,7 +373,7 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
); );
var theAddress = Address( var theAddress = Address(
walletId: walletId, walletId: walletId,
value: txJsonResponse["receiver"].toString(), value: opJson["receiver"].toString(),
publicKey: [], // TODO: Add public key publicKey: [], // TODO: Add public key
derivationIndex: 0, derivationIndex: 0,
derivationPath: null, derivationPath: null,
@ -386,6 +382,11 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
); );
txs.add(Tuple2(theTx, theAddress)); txs.add(Tuple2(theTx, theAddress));
} }
}
}
}
}
Logging.instance.log("Transactions: $txs", level: LogLevel.Info);
await db.addNewTransactionData(txs, walletId); await db.addNewTransactionData(txs, walletId);
} }

View file

@ -65,7 +65,7 @@ class CoinThemeColorDefault {
case Coin.particl: case Coin.particl:
return particl; return particl;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return stellar; return stellar;
case Coin.nano: case Coin.nano:
return nano; return nano;

View file

@ -1708,7 +1708,7 @@ class StackColors extends ThemeExtension<StackColors> {
case Coin.particl: case Coin.particl:
return _coin.particl; return _coin.particl;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return _coin.stellar; return _coin.stellar;
case Coin.nano: case Coin.nano:
return _coin.nano; return _coin.nano;

View file

@ -143,7 +143,7 @@ class AddressUtils {
return Address.validateAddress(address, firoTestNetwork); return Address.validateAddress(address, firoTestNetwork);
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
return Address.validateAddress(address, dogecointestnet); return Address.validateAddress(address, dogecointestnet);
case Coin.stellarTestnet: case Coin.stellarTestNet:
return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address);
} }
} }

View file

@ -51,7 +51,7 @@ enum AmountUnit {
case Coin.eCash: case Coin.eCash:
case Coin.epicCash: case Coin.epicCash:
case Coin.stellar: // TODO: check if this is correct case Coin.stellar: // TODO: check if this is correct
case Coin.stellarTestnet: case Coin.stellarTestNet:
case Coin.tezos: case Coin.tezos:
return AmountUnit.values.sublist(0, 4); return AmountUnit.values.sublist(0, 4);

View file

@ -60,7 +60,7 @@ Uri getDefaultBlockExplorerUrlFor({
return Uri.parse("https://www.nanolooker.com/block/$txid"); return Uri.parse("https://www.nanolooker.com/block/$txid");
case Coin.banano: case Coin.banano:
return Uri.parse("https://www.bananolooker.com/block/$txid"); return Uri.parse("https://www.bananolooker.com/block/$txid");
case Coin.stellarTestnet: case Coin.stellarTestNet:
return Uri.parse("https://testnet.stellarchain.io/transactions/$txid"); return Uri.parse("https://testnet.stellarchain.io/transactions/$txid");
case Coin.tezos: case Coin.tezos:
return Uri.parse("https://tzstats.com/$txid"); return Uri.parse("https://tzstats.com/$txid");

View file

@ -102,7 +102,7 @@ abstract class Constants {
return _satsPerCoinECash; return _satsPerCoinECash;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return _satsPerCoinStellar; return _satsPerCoinStellar;
case Coin.tezos: case Coin.tezos:
@ -146,7 +146,7 @@ abstract class Constants {
return _decimalPlacesECash; return _decimalPlacesECash;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return _decimalPlacesStellar; return _decimalPlacesStellar;
case Coin.tezos: case Coin.tezos:
@ -174,7 +174,7 @@ abstract class Constants {
case Coin.particl: case Coin.particl:
case Coin.nano: case Coin.nano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
values.addAll([24, 12]); values.addAll([24, 12]);
break; break;
case Coin.banano: case Coin.banano:
@ -238,7 +238,7 @@ abstract class Constants {
return 1; return 1;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return 5; return 5;
case Coin.tezos: case Coin.tezos:
@ -271,7 +271,7 @@ abstract class Constants {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
case Coin.tezos: case Coin.tezos:
return 24; return 24;

View file

@ -292,10 +292,10 @@ abstract class DefaultNodes {
host: "https://horizon-testnet.stellar.org/", host: "https://horizon-testnet.stellar.org/",
port: 50022, port: 50022,
name: defaultName, name: defaultName,
id: _nodeId(Coin.stellarTestnet), id: _nodeId(Coin.stellarTestNet),
useSSL: true, useSSL: true,
enabled: true, enabled: true,
coinName: Coin.stellarTestnet.name, coinName: Coin.stellarTestNet.name,
isFailover: true, isFailover: true,
isDown: false, isDown: false,
); );
@ -365,7 +365,7 @@ abstract class DefaultNodes {
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
return dogecoinTestnet; return dogecoinTestnet;
case Coin.stellarTestnet: case Coin.stellarTestNet:
return stellarTestnet; return stellarTestnet;
} }
} }

View file

@ -60,9 +60,10 @@ enum Coin {
dogecoinTestNet, dogecoinTestNet,
firoTestNet, firoTestNet,
litecoinTestNet, litecoinTestNet,
stellarTestNet,
} }
final int kTestNetCoinCount = 4; // Util.isDesktop ? 5 : 4; final int kTestNetCoinCount = 5; // Util.isDesktop ? 5 : 4;
// remove firotestnet for now // remove firotestnet for now
extension CoinExt on Coin { extension CoinExt on Coin {
@ -110,6 +111,8 @@ extension CoinExt on Coin {
return "tFiro"; return "tFiro";
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
return "tDogecoin"; return "tDogecoin";
case Coin.stellarTestNet:
return "tStellar";
} }
} }
@ -157,7 +160,7 @@ extension CoinExt on Coin {
return "tFIRO"; return "tFIRO";
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
return "tDOGE"; return "tDOGE";
case Coin.stellarTestnet: case Coin.stellarTestNet:
return "tXLM"; return "tXLM";
} }
} }
@ -207,7 +210,7 @@ extension CoinExt on Coin {
return "firo"; return "firo";
case Coin.dogecoinTestNet: case Coin.dogecoinTestNet:
return "dogecoin"; return "dogecoin";
case Coin.stellarTestnet: case Coin.stellarTestNet:
return "stellar"; return "stellar";
} }
} }
@ -237,7 +240,7 @@ extension CoinExt on Coin {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return false; return false;
} }
} }
@ -267,7 +270,7 @@ extension CoinExt on Coin {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return false; return false;
} }
} }
@ -297,7 +300,7 @@ extension CoinExt on Coin {
case Coin.litecoinTestNet: case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet: case Coin.bitcoincashTestnet:
case Coin.firoTestNet: case Coin.firoTestNet:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return true; return true;
} }
} }
@ -337,7 +340,7 @@ extension CoinExt on Coin {
case Coin.firoTestNet: case Coin.firoTestNet:
return Coin.firo; return Coin.firo;
case Coin.stellarTestnet: case Coin.stellarTestNet:
return Coin.stellar; return Coin.stellar;
} }
} }
@ -380,7 +383,7 @@ extension CoinExt on Coin {
return particl.MINIMUM_CONFIRMATIONS; return particl.MINIMUM_CONFIRMATIONS;
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
return xlm.MINIMUM_CONFIRMATIONS; return xlm.MINIMUM_CONFIRMATIONS;
case Coin.tezos: case Coin.tezos:
@ -500,7 +503,7 @@ Coin coinFromPrettyName(String name) {
case "Stellar Testnet": case "Stellar Testnet":
case "stellarTestnet": case "stellarTestnet":
case "tStellar": case "tStellar":
return Coin.stellarTestnet; return Coin.stellarTestNet;
default: default:
throw ArgumentError.value( throw ArgumentError.value(
@ -556,7 +559,7 @@ Coin coinFromTickerCaseInsensitive(String ticker) {
case "ban": case "ban":
return Coin.banano; return Coin.banano;
case "txlm": case "txlm":
return Coin.stellarTestnet; return Coin.stellarTestNet;
default: default:
throw ArgumentError.value( throw ArgumentError.value(
ticker, "name", "No Coin enum value with that ticker"); ticker, "name", "No Coin enum value with that ticker");

View file

@ -50,7 +50,7 @@ extension DerivePathTypeExt on DerivePathType {
case Coin.nano: case Coin.nano:
case Coin.banano: case Coin.banano:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
case Coin.tezos: // TODO: Is this true? case Coin.tezos: // TODO: Is this true?
throw UnsupportedError( throw UnsupportedError(
"$coin does not use bitcoin style derivation paths"); "$coin does not use bitcoin style derivation paths");

View file

@ -196,7 +196,7 @@ class _NodeCardState extends ConsumerState<NodeCard> {
case Coin.banano: case Coin.banano:
case Coin.tezos: case Coin.tezos:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
throw UnimplementedError(); throw UnimplementedError();
//TODO: check network/node //TODO: check network/node
} }

View file

@ -179,7 +179,7 @@ class NodeOptionsSheet extends ConsumerWidget {
case Coin.banano: case Coin.banano:
case Coin.tezos: case Coin.tezos:
case Coin.stellar: case Coin.stellar:
case Coin.stellarTestnet: case Coin.stellarTestNet:
throw UnimplementedError(); throw UnimplementedError();
//TODO: check network/node //TODO: check network/node
} }

View file

@ -25,6 +25,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.12.30" version: "1.12.30"
ansicolor:
dependency: transitive
description:
name: ansicolor
sha256: "607f8fa9786f392043f169898923e6c59b4518242b68b8862eb8a8b7d9c30b4a"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
archive: archive:
dependency: "direct main" dependency: "direct main"
description: description:
@ -298,10 +306,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: crypto name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.3" version: "3.0.2"
cryptography: cryptography:
dependency: transitive dependency: transitive
description: description:
@ -454,10 +462,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: dio name: dio
sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993" sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "5.3.0" version: "4.0.6"
dropdown_button2: dropdown_button2:
dependency: "direct main" dependency: "direct main"
description: description:
@ -942,6 +950,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "3.0.2" 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: keyboard_dismisser:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1005,6 +1021,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.2.0"
memoize:
dependency: transitive
description:
name: memoize
sha256: "51481d328c86cbdc59711369179bac88551ca0556569249be5317e66fc796cac"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -1230,13 +1254,13 @@ packages:
source: hosted source: hosted
version: "5.4.0" version: "5.4.0"
pinenacl: pinenacl:
dependency: transitive dependency: "direct overridden"
description: description:
name: pinenacl name: pinenacl
sha256: "3a5503637587d635647c93ea9a8fecf48a420cc7deebe6f1fc85c2a5637ab327" sha256: e5fb0bce1717b7f136f35ee98b5c02b3e6383211f8a77ca882fa7812232a07b9
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.3.4"
platform: platform:
dependency: transitive dependency: transitive
description: description:
@ -1269,6 +1293,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.5.1" 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: process:
dependency: transitive dependency: transitive
description: description:
@ -1317,6 +1349,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.1.0" version: "4.1.0"
quiver:
dependency: transitive
description:
name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
url: "https://pub.dev"
source: hosted
version: "3.2.1"
rational: rational:
dependency: transitive dependency: transitive
description: description:
@ -1325,6 +1365,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.2.2" version: "2.2.2"
retry:
dependency: transitive
description:
name: retry
sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
riverpod: riverpod:
dependency: transitive dependency: transitive
description: description:
@ -1471,10 +1519,10 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
name: stellar_flutter_sdk name: stellar_flutter_sdk
sha256: "7a9b7dc76018bbd0b9c828045cf0e26e07ec44208fb1a1733273de2390205475" sha256: "4c55b1b6dfbde7f89bba59a422754280715fa3b5726cff5e7eeaed454d2c4b89"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.6.0" version: "1.5.3"
stream_channel: stream_channel:
dependency: transitive dependency: transitive
description: description:
@ -1547,6 +1595,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.5.1" version: "0.5.1"
tezart:
dependency: "direct main"
description:
name: tezart
sha256: "35d526f2e6ca250c64461ebfb4fa9f64b6599fab8c4242c8e89ae27d4ac2e15a"
url: "https://pub.dev"
source: hosted
version: "2.0.5"
time: time:
dependency: transitive dependency: transitive
description: description:

View file

@ -138,7 +138,7 @@ dependencies:
desktop_drop: ^0.4.1 desktop_drop: ^0.4.1
nanodart: ^2.0.0 nanodart: ^2.0.0
basic_utils: ^5.5.4 basic_utils: ^5.5.4
stellar_flutter_sdk: ^1.6.0 stellar_flutter_sdk: ^1.5.3
tezart: ^2.0.5 tezart: ^2.0.5
dev_dependencies: dev_dependencies:
@ -202,6 +202,7 @@ dependency_overrides:
crypto: 3.0.2 crypto: 3.0.2
analyzer: ^5.2.0 analyzer: ^5.2.0
pinenacl: ^0.3.3
# For information on the generic Dart part of this file, see the # For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec # following page: https://dart.dev/tools/pub/pubspec