mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 01:37:54 +00:00
eth api error handling clean up and token flag
This commit is contained in:
parent
96bfafcd19
commit
461267ec95
2 changed files with 24 additions and 14 deletions
|
@ -1023,6 +1023,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
final response = await EthereumAPI.getEthTransactions(
|
final response = await EthereumAPI.getEthTransactions(
|
||||||
address: thisAddress,
|
address: thisAddress,
|
||||||
firstBlock: isRescan ? 0 : firstBlock,
|
firstBlock: isRescan ? 0 : firstBlock,
|
||||||
|
includeTokens: true,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.value == null) {
|
if (response.value == null) {
|
||||||
|
@ -1057,8 +1058,10 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
txFailed = true;
|
txFailed = true;
|
||||||
}
|
}
|
||||||
isIncoming = false;
|
isIncoming = false;
|
||||||
} else {
|
} else if (checksumEthereumAddress(element.to) == thisAddress) {
|
||||||
isIncoming = true;
|
isIncoming = true;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculate fees (GasLimit * gasPrice)
|
//Calculate fees (GasLimit * gasPrice)
|
||||||
|
|
|
@ -50,6 +50,7 @@ abstract class EthereumAPI {
|
||||||
static Future<EthereumResponse<List<EthTxDTO>>> getEthTransactions({
|
static Future<EthereumResponse<List<EthTxDTO>>> getEthTransactions({
|
||||||
required String address,
|
required String address,
|
||||||
int firstBlock = 0,
|
int firstBlock = 0,
|
||||||
|
bool includeTokens = false,
|
||||||
}) async {
|
}) async {
|
||||||
try {
|
try {
|
||||||
final response = await get(
|
final response = await get(
|
||||||
|
@ -67,7 +68,7 @@ abstract class EthereumAPI {
|
||||||
for (final map in list!) {
|
for (final map in list!) {
|
||||||
final txn = EthTxDTO.fromMap(Map<String, dynamic>.from(map as Map));
|
final txn = EthTxDTO.fromMap(Map<String, dynamic>.from(map as Map));
|
||||||
|
|
||||||
if (txn.hasToken == 0) {
|
if (txn.hasToken == 0 || includeTokens) {
|
||||||
txns.add(txn);
|
txns.add(txn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,9 +77,11 @@ abstract class EthereumAPI {
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw EthApiException(
|
// nice that the api returns an empty body instead of being
|
||||||
"getEthTransactions($address) response is empty but status code is "
|
// consistent and returning a json object with no transactions
|
||||||
"${response.statusCode}",
|
return EthereumResponse(
|
||||||
|
[],
|
||||||
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -196,9 +199,11 @@ abstract class EthereumAPI {
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw EthApiException(
|
// nice that the api returns an empty body instead of being
|
||||||
"getEthTransactionNonces($txns) response is empty but status code is "
|
// consistent and returning a json object with no transactions
|
||||||
"${response.statusCode}",
|
return EthereumResponse(
|
||||||
|
[],
|
||||||
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -252,13 +257,13 @@ abstract class EthereumAPI {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw EthApiException(
|
throw EthApiException(
|
||||||
"getEthTransaction($txids) response is empty but status code is "
|
"getEthTokenTransactionsByTxids($txids) response is empty but status code is "
|
||||||
"${response.statusCode}",
|
"${response.statusCode}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw EthApiException(
|
throw EthApiException(
|
||||||
"getEthTransaction($txids) failed with status code: "
|
"getEthTokenTransactionsByTxids($txids) failed with status code: "
|
||||||
"${response.statusCode}",
|
"${response.statusCode}",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -269,7 +274,7 @@ abstract class EthereumAPI {
|
||||||
);
|
);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
"getEthTransaction($txids): $e\n$s",
|
"getEthTokenTransactionsByTxids($txids): $e\n$s",
|
||||||
level: LogLevel.Error,
|
level: LogLevel.Error,
|
||||||
);
|
);
|
||||||
return EthereumResponse(
|
return EthereumResponse(
|
||||||
|
@ -307,9 +312,11 @@ abstract class EthereumAPI {
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
throw EthApiException(
|
// nice that the api returns an empty body instead of being
|
||||||
"getTokenTransactions($address, $tokenContractAddress) response is empty but status code is "
|
// consistent and returning a json object with no transactions
|
||||||
"${response.statusCode}",
|
return EthereumResponse(
|
||||||
|
[],
|
||||||
|
null,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue