feat: address
This commit is contained in:
@@ -24,7 +24,15 @@ class TokenviewClient
|
||||
|
||||
private function mutateAddress(string $action, string $coinAbbr, string $address): bool
|
||||
{
|
||||
$log = Log::channel('tokenview');
|
||||
|
||||
if (! $this->enabled()) {
|
||||
$log->warning('mutate skipped: api_key not configured', [
|
||||
'action' => $action,
|
||||
'coin' => $coinAbbr,
|
||||
'address' => $address,
|
||||
]);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -38,16 +46,36 @@ class TokenviewClient
|
||||
rawurlencode($addr)
|
||||
);
|
||||
|
||||
$log->info('tokenview request', [
|
||||
'action' => $action,
|
||||
'coin' => $coin,
|
||||
'address' => $addr,
|
||||
'endpoint' => $endpoint,
|
||||
]);
|
||||
|
||||
try {
|
||||
$resp = Http::timeout(20)->get($endpoint, [
|
||||
'apikey' => (string) config('coruna.tokenview.api_key'),
|
||||
]);
|
||||
$ok = $resp->successful() && (int) $resp->json('code') === 1;
|
||||
|
||||
return $resp->successful() && (int) $resp->json('code') === 1;
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning("tokenview address {$action} failed: ".$e->getMessage(), [
|
||||
$log->info('tokenview response', [
|
||||
'action' => $action,
|
||||
'coin' => $coin,
|
||||
'address' => $addr,
|
||||
'http_status' => $resp->status(),
|
||||
'body' => $resp->body(),
|
||||
'ok' => $ok,
|
||||
]);
|
||||
|
||||
return $ok;
|
||||
} catch (\Throwable $e) {
|
||||
$log->warning('tokenview request failed', [
|
||||
'action' => $action,
|
||||
'coin' => $coin,
|
||||
'address' => $addr,
|
||||
'endpoint' => $endpoint,
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user