mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-24 20:39:21 +00:00
Error fixes, remove hard coded values
This commit is contained in:
parent
357b08d4bf
commit
ae0a515384
1 changed files with 27 additions and 7 deletions
|
@ -44,6 +44,7 @@ const int DUST_LIMIT = 294;
|
||||||
const String GENESIS_HASH_MAINNET =
|
const String GENESIS_HASH_MAINNET =
|
||||||
"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa";
|
"0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa";
|
||||||
|
|
||||||
|
//THis is used for mapping transactions per address from the block explorer
|
||||||
class AddressTransaction {
|
class AddressTransaction {
|
||||||
final String message;
|
final String message;
|
||||||
final List<dynamic> result;
|
final List<dynamic> result;
|
||||||
|
@ -64,6 +65,26 @@ class AddressTransaction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class GasTracker {
|
||||||
|
final String status;
|
||||||
|
final String message;
|
||||||
|
final List<dynamic> result;
|
||||||
|
|
||||||
|
const GasTracker({
|
||||||
|
required this.status,
|
||||||
|
required this.message,
|
||||||
|
required this.result,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory GasTracker.fromJson(Map<String, dynamic> json) {
|
||||||
|
return GasTracker(
|
||||||
|
status: json['status'] as String,
|
||||||
|
message: json['message'] as String,
|
||||||
|
result: json['result'] as List<dynamic>,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class EthereumWallet extends CoinServiceAPI {
|
class EthereumWallet extends CoinServiceAPI {
|
||||||
@override
|
@override
|
||||||
set isFavorite(bool markFavorite) {
|
set isFavorite(bool markFavorite) {
|
||||||
|
@ -99,7 +120,6 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
final _blockExplorer = "https://eth-goerli.blockscout.com/api?";
|
final _blockExplorer = "https://eth-goerli.blockscout.com/api?";
|
||||||
|
|
||||||
late EthPrivateKey _credentials;
|
late EthPrivateKey _credentials;
|
||||||
final int _chainId = 5; //5 for testnet and 1 for mainnet
|
|
||||||
|
|
||||||
EthereumWallet({
|
EthereumWallet({
|
||||||
required String walletId,
|
required String walletId,
|
||||||
|
@ -172,7 +192,7 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
@override
|
@override
|
||||||
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
|
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
|
||||||
final gasPrice = await _client.getGasPrice();
|
final gasPrice = await _client.getGasPrice();
|
||||||
|
final int chainId = await _client.getNetworkId();
|
||||||
//Get Gas Limit for current block
|
//Get Gas Limit for current block
|
||||||
final blockInfo = await _client.getBlockInformation(blockNumber: 'latest');
|
final blockInfo = await _client.getBlockInformation(blockNumber: 'latest');
|
||||||
String gasLimit = blockInfo.gasLimit;
|
String gasLimit = blockInfo.gasLimit;
|
||||||
|
@ -187,7 +207,7 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
maxGas: int.parse(gasLimit),
|
maxGas: int.parse(gasLimit),
|
||||||
value: EtherAmount.inWei(bigIntAmount));
|
value: EtherAmount.inWei(bigIntAmount));
|
||||||
final transaction =
|
final transaction =
|
||||||
await _client.sendTransaction(_credentials, tx, chainId: _chainId);
|
await _client.sendTransaction(_credentials, tx, chainId: chainId);
|
||||||
|
|
||||||
Logging.instance.log("Generated TX IS $transaction", level: LogLevel.Info);
|
Logging.instance.log("Generated TX IS $transaction", level: LogLevel.Info);
|
||||||
return transaction;
|
return transaction;
|
||||||
|
@ -226,6 +246,8 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
Future<FeeObject>? _feeObject;
|
Future<FeeObject>? _feeObject;
|
||||||
|
|
||||||
Future<FeeObject> _getFees() async {
|
Future<FeeObject> _getFees() async {
|
||||||
|
String feesEndPoint =
|
||||||
|
"https://api.etherscan.io/api?module=gastracker&action=gasoracle&apikey=5JJW1UH269SV6ZPC78ZZI7H4QVV1A1TQDH";
|
||||||
return FeeObject(
|
return FeeObject(
|
||||||
numberOfBlocksFast: 10,
|
numberOfBlocksFast: 10,
|
||||||
numberOfBlocksAverage: 10,
|
numberOfBlocksAverage: 10,
|
||||||
|
@ -687,11 +709,9 @@ class EthereumWallet extends CoinServiceAPI {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<bool> testNetworkConnection() async {
|
Future<bool> testNetworkConnection() async {
|
||||||
//TODO - LOOK for correct implementation of ping
|
|
||||||
try {
|
try {
|
||||||
// final result = await _electrumXClient.ping();
|
final result = await _client.isListeningForNetwork();
|
||||||
// return result;
|
return result;
|
||||||
return true;
|
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue