From 780a34b7dc005801adf40e7aa63a0f58b1a8b5f6 Mon Sep 17 00:00:00 2001 From: julian Date: Mon, 4 Dec 2023 10:46:34 -0600 Subject: [PATCH] eth token api endpoint update --- lib/services/ethereum/ethereum_api.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index 8f0024774..b9a118352 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -611,7 +611,8 @@ abstract class EthereumAPI { try { final response = await client.get( url: Uri.parse( - "$stackBaseServer/tokens?addrs=$contractAddress&parts=all", + // "$stackBaseServer/tokens?addrs=$contractAddress&parts=all", + "$stackBaseServer/names?terms=$contractAddress", ), proxyInfo: Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() @@ -621,6 +622,10 @@ abstract class EthereumAPI { if (response.code == 200) { final json = jsonDecode(response.body) as Map; if (json["data"] is List) { + if ((json["data"] as List).isEmpty) { + throw EthApiException("Unknown token"); + } + final map = Map.from(json["data"].first as Map); EthContract? token; if (map["isErc20"] == true) {