mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 03:49:22 +00:00
eth trueblocks fetch token abi call
This commit is contained in:
parent
1cca6e8e70
commit
85c416fb50
1 changed files with 7 additions and 14 deletions
|
@ -427,34 +427,27 @@ abstract class EthereumAPI {
|
|||
}
|
||||
}
|
||||
|
||||
static Future<EthereumResponse<String>> getTokenAbi(
|
||||
String contractAddress) async {
|
||||
static Future<EthereumResponse<String>> getTokenAbi({
|
||||
required String name,
|
||||
required String contractAddress,
|
||||
}) async {
|
||||
try {
|
||||
final response = await get(
|
||||
Uri.parse(
|
||||
"$stackBaseServer/abis?addrs=$contractAddress",
|
||||
"$stackBaseServer/abis?addrs=$contractAddress&verbose=true",
|
||||
),
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
final json = jsonDecode(response.body)["data"] as List;
|
||||
|
||||
// trueblocks api does not contain the `anonymous` value
|
||||
// web3dart expects it so hack it in
|
||||
// TODO: fix this if we ever actually need to use contract ABI events
|
||||
for (final map in json) {
|
||||
if (map["type"] == "event") {
|
||||
map["anonymous"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
return EthereumResponse(
|
||||
jsonEncode(json),
|
||||
null,
|
||||
);
|
||||
} else {
|
||||
throw EthApiException(
|
||||
"getTokenAbi($contractAddress) failed with status code: "
|
||||
"getTokenAbi($name, $contractAddress) failed with status code: "
|
||||
"${response.statusCode}",
|
||||
);
|
||||
}
|
||||
|
@ -465,7 +458,7 @@ abstract class EthereumAPI {
|
|||
);
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"getTokenAbi(): $e\n$s",
|
||||
"getTokenAbi($name, $contractAddress): $e\n$s",
|
||||
level: LogLevel.Error,
|
||||
);
|
||||
return EthereumResponse(
|
||||
|
|
Loading…
Reference in a new issue