mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
clean up
This commit is contained in:
parent
953acb493c
commit
0fc68a3702
1 changed files with 1 additions and 489 deletions
|
@ -14,25 +14,15 @@ import 'package:flutter/material.dart';
|
|||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:hive_flutter/hive_flutter.dart';
|
||||
import 'package:isar/isar.dart';
|
||||
import 'package:stackwallet/db/hive/db.dart';
|
||||
import 'package:stackwallet/electrumx_rpc/electrumx_client.dart';
|
||||
import 'package:stackwallet/models/isar/models/isar_models.dart';
|
||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||
import 'package:stackwallet/providers/global/debug_service_provider.dart';
|
||||
import 'package:stackwallet/providers/providers.dart';
|
||||
import 'package:stackwallet/themes/stack_colors.dart';
|
||||
import 'package:stackwallet/utilities/amount/amount.dart';
|
||||
import 'package:stackwallet/utilities/assets.dart';
|
||||
import 'package:stackwallet/utilities/constants.dart';
|
||||
import 'package:stackwallet/utilities/default_nodes.dart';
|
||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||
import 'package:stackwallet/utilities/text_styles.dart';
|
||||
import 'package:stackwallet/utilities/util.dart';
|
||||
import 'package:stackwallet/wallets/models/tx_data.dart';
|
||||
import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart';
|
||||
import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart';
|
||||
import 'package:stackwallet/widgets/background.dart';
|
||||
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
|
||||
import 'package:stackwallet/widgets/onetime_popups/tor_has_been_add_dialog.dart';
|
||||
|
@ -225,98 +215,7 @@ class HiddenSettings extends StatelessWidget {
|
|||
),
|
||||
);
|
||||
}),
|
||||
// const SizedBox(
|
||||
// height: 12,
|
||||
// ),
|
||||
// Consumer(builder: (_, ref, __) {
|
||||
// return GestureDetector(
|
||||
// onTap: () async {
|
||||
// final x =
|
||||
// await MajesticBankAPI.instance.getRates();
|
||||
// print(x);
|
||||
// },
|
||||
// child: RoundedWhiteContainer(
|
||||
// child: Text(
|
||||
// "Click me",
|
||||
// style: STextStyles.button(context).copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .accentColorDark),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// const SizedBox(
|
||||
// height: 12,
|
||||
// ),
|
||||
// Consumer(builder: (_, ref, __) {
|
||||
// return GestureDetector(
|
||||
// onTap: () async {
|
||||
// ref
|
||||
// .read(priceAnd24hChangeNotifierProvider)
|
||||
// .tokenContractAddressesToCheck
|
||||
// .add(
|
||||
// "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
|
||||
// ref
|
||||
// .read(priceAnd24hChangeNotifierProvider)
|
||||
// .tokenContractAddressesToCheck
|
||||
// .add(
|
||||
// "0xdAC17F958D2ee523a2206206994597C13D831ec7");
|
||||
// await ref
|
||||
// .read(priceAnd24hChangeNotifierProvider)
|
||||
// .updatePrice();
|
||||
//
|
||||
// final x = ref
|
||||
// .read(priceAnd24hChangeNotifierProvider)
|
||||
// .getTokenPrice(
|
||||
// "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
|
||||
//
|
||||
// print(
|
||||
// "PRICE 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48: $x");
|
||||
// },
|
||||
// child: RoundedWhiteContainer(
|
||||
// child: Text(
|
||||
// "Click me",
|
||||
// style: STextStyles.button(context).copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .accentColorDark),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
// const SizedBox(
|
||||
// height: 12,
|
||||
// ),
|
||||
// Consumer(builder: (_, ref, __) {
|
||||
// return GestureDetector(
|
||||
// onTap: () async {
|
||||
// // final erc20 = Erc20ContractInfo(
|
||||
// // contractAddress: 'some con',
|
||||
// // name: "loonamsn",
|
||||
// // symbol: "DD",
|
||||
// // decimals: 19,
|
||||
// // );
|
||||
// //
|
||||
// // final json = erc20.toJson();
|
||||
// //
|
||||
// // print(json);
|
||||
// //
|
||||
// // final ee = EthContractInfo.fromJson(json);
|
||||
// //
|
||||
// // print(ee);
|
||||
// },
|
||||
// child: RoundedWhiteContainer(
|
||||
// child: Text(
|
||||
// "Click me",
|
||||
// style: STextStyles.button(context).copyWith(
|
||||
// color: Theme.of(context)
|
||||
// .extension<StackColors>()!
|
||||
// .accentColorDark),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }),
|
||||
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
|
@ -353,9 +252,6 @@ class HiddenSettings extends StatelessWidget {
|
|||
}
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
|
@ -374,390 +270,6 @@ class HiddenSettings extends StatelessWidget {
|
|||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
final n = DefaultNodes.firoTestnet;
|
||||
|
||||
final e = ElectrumXClient.from(
|
||||
node: ElectrumXNode(
|
||||
address: n.host,
|
||||
port: n.port,
|
||||
name: n.name,
|
||||
id: n.id,
|
||||
useSSL: n.useSSL,
|
||||
),
|
||||
prefs:
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers: [],
|
||||
);
|
||||
|
||||
// Call and print getSparkAnonymitySet.
|
||||
final anonymitySet =
|
||||
await e.getSparkAnonymitySet(
|
||||
coinGroupId: "1",
|
||||
startBlockHash: "",
|
||||
);
|
||||
|
||||
Util.printJson(anonymitySet, "anonymitySet");
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Spark getSparkAnonymitySet",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
final n = DefaultNodes.firoTestnet;
|
||||
|
||||
final e = ElectrumXClient.from(
|
||||
node: ElectrumXNode(
|
||||
address: n.host,
|
||||
port: n.port,
|
||||
name: n.name,
|
||||
id: n.id,
|
||||
useSSL: n.useSSL,
|
||||
),
|
||||
prefs:
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers: [],
|
||||
);
|
||||
|
||||
// Call and print getUsedCoinsTags.
|
||||
final usedCoinsTags = await e
|
||||
.getSparkUsedCoinsTags(startNumber: 0);
|
||||
|
||||
print(
|
||||
"usedCoinsTags['tags'].length: ${usedCoinsTags.length}");
|
||||
Util.printJson(
|
||||
usedCoinsTags, "usedCoinsTags");
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Spark getSparkUsedCoinsTags",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
final n = DefaultNodes.firoTestnet;
|
||||
|
||||
final e = ElectrumXClient.from(
|
||||
node: ElectrumXNode(
|
||||
address: n.host,
|
||||
port: n.port,
|
||||
name: n.name,
|
||||
id: n.id,
|
||||
useSSL: n.useSSL,
|
||||
),
|
||||
prefs:
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers: [],
|
||||
);
|
||||
|
||||
// Call and print getSparkMintMetaData.
|
||||
final mintMetaData =
|
||||
await e.getSparkMintMetaData(
|
||||
sparkCoinHashes: [
|
||||
"b476ed2b374bb081ea51d111f68f0136252521214e213d119b8dc67b92f5a390",
|
||||
],
|
||||
);
|
||||
|
||||
Util.printJson(mintMetaData, "mintMetaData");
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Spark getSparkMintMetaData",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
final n = DefaultNodes.firoTestnet;
|
||||
|
||||
final e = ElectrumXClient.from(
|
||||
node: ElectrumXNode(
|
||||
address: n.host,
|
||||
port: n.port,
|
||||
name: n.name,
|
||||
id: n.id,
|
||||
useSSL: n.useSSL,
|
||||
),
|
||||
prefs:
|
||||
ref.read(prefsChangeNotifierProvider),
|
||||
failovers: [],
|
||||
);
|
||||
|
||||
// Call and print getSparkLatestCoinId.
|
||||
final latestCoinId =
|
||||
await e.getSparkLatestCoinId();
|
||||
|
||||
Util.printJson(latestCoinId, "latestCoinId");
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Spark getSparkLatestCoinId",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
// Run refreshSparkData.
|
||||
//
|
||||
// Search wallets for a Firo testnet wallet.
|
||||
for (final wallet
|
||||
in ref.read(pWallets).wallets) {
|
||||
if (!(wallet.info.coin ==
|
||||
Coin.firoTestNet)) {
|
||||
continue;
|
||||
}
|
||||
// This is a Firo testnet wallet.
|
||||
final walletId = wallet.info.walletId;
|
||||
|
||||
// // Search for `circle chunk...` mnemonic.
|
||||
// final potentialWallet =
|
||||
// ref.read(pWallets).getWallet(walletId)
|
||||
// as MnemonicInterface;
|
||||
// final mnemonic = await potentialWallet
|
||||
// .getMnemonicAsWords();
|
||||
// if (!(mnemonic[0] == "circle" &&
|
||||
// mnemonic[1] == "chunk)")) {
|
||||
// // That ain't it. Skip this one.
|
||||
// return;
|
||||
// }
|
||||
// Hardcode key in refreshSparkData instead.
|
||||
|
||||
// Get a Spark interface.
|
||||
final fusionWallet = ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId) as SparkInterface;
|
||||
|
||||
// Refresh Spark data.
|
||||
await fusionWallet.refreshSparkData();
|
||||
|
||||
// We only need to run this once.
|
||||
break;
|
||||
}
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Refresh Spark wallet",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
try {
|
||||
// Run prepareSparkMintTransaction.
|
||||
for (final wallet
|
||||
in ref.read(pWallets).wallets) {
|
||||
// Prepare tx with a Firo testnet wallet.
|
||||
if (!(wallet.info.coin ==
|
||||
Coin.firoTestNet)) {
|
||||
continue;
|
||||
}
|
||||
final walletId = wallet.info.walletId;
|
||||
|
||||
// Get a Spark interface.
|
||||
final fusionWallet = ref
|
||||
.read(pWallets)
|
||||
.getWallet(walletId) as SparkInterface;
|
||||
|
||||
// Make a dummy TxData.
|
||||
TxData txData = TxData(); // TODO
|
||||
|
||||
await fusionWallet
|
||||
.prepareSparkMintTransaction(
|
||||
txData: txData);
|
||||
|
||||
// We only need to run this once.
|
||||
break;
|
||||
}
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"Prepare Spark mint transaction",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(
|
||||
height: 12,
|
||||
),
|
||||
Consumer(
|
||||
builder: (_, ref, __) {
|
||||
return GestureDetector(
|
||||
onTap: () async {
|
||||
const enableBurningMints = false;
|
||||
|
||||
try {
|
||||
if (enableBurningMints) {
|
||||
final wallet = ref
|
||||
.read(pWallets)
|
||||
.wallets
|
||||
.firstWhere((e) =>
|
||||
e.info.name == "circle chunk")
|
||||
as FiroWallet;
|
||||
|
||||
final utxos = await ref
|
||||
.read(mainDBProvider)
|
||||
.isar
|
||||
.utxos
|
||||
.where()
|
||||
.walletIdEqualTo(wallet.walletId)
|
||||
.findAll();
|
||||
|
||||
final Set<UTXO> utxosToUse = {};
|
||||
|
||||
for (final u in utxos) {
|
||||
if (u.used != true &&
|
||||
u.value < 500000000 &&
|
||||
u.value > 9000000) {
|
||||
utxosToUse.add(u);
|
||||
break;
|
||||
}
|
||||
if (utxosToUse.length > 2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
print("utxosToUse: $utxosToUse");
|
||||
|
||||
final inputData = TxData(
|
||||
utxos: utxosToUse,
|
||||
recipients: [
|
||||
(
|
||||
address: (await wallet
|
||||
.getCurrentReceivingSparkAddress())!
|
||||
.value,
|
||||
amount: Amount(
|
||||
rawValue: BigInt.from(utxosToUse
|
||||
.map((e) => e.value)
|
||||
.fold(0, (p, e) => p + e) -
|
||||
20000),
|
||||
fractionDigits: 8,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
final mint = await wallet
|
||||
.prepareSparkMintTransaction(
|
||||
txData: inputData,
|
||||
);
|
||||
|
||||
print("MINT: $mint");
|
||||
|
||||
print("Submitting...");
|
||||
final result = await wallet
|
||||
.confirmSparkMintTransaction(
|
||||
txData: mint);
|
||||
print("Submitted result: $result");
|
||||
}
|
||||
} catch (e, s) {
|
||||
print("$e\n$s");
|
||||
}
|
||||
},
|
||||
child: RoundedWhiteContainer(
|
||||
child: Text(
|
||||
"💣💣💣 DANGER 💣💣💣** Random Spark mint **💣💣💣 DANGER 💣💣💣 ",
|
||||
style: STextStyles.button(context).copyWith(
|
||||
color: Theme.of(context)
|
||||
.extension<StackColors>()!
|
||||
.accentColorDark),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
Loading…
Reference in a new issue