Skip to content

Commit dd8998b

Browse files
committed
Refactor mayan api
1 parent 1055d93 commit dd8998b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

protocol/mayan/api.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,15 @@ func NewMayanExplorer() *MayanExplorer {
3939
}
4040

4141
func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) {
42-
fullURL := fmt.Sprintf("%s/v3/swap/trx/%s", MAYAN_EXPLORER_URL, hash)
43-
44-
resp, err := c.HTTPClient.Get(fullURL)
42+
url := fmt.Sprintf("%s/v3/swap/trx/%s", MAYAN_EXPLORER_URL, hash)
43+
resp, err := c.HTTPClient.Get(url)
4544
if err != nil {
4645
return nil, fmt.Errorf("request failed: %w", err)
4746
}
4847
defer resp.Body.Close()
4948

5049
if resp.StatusCode != http.StatusOK {
51-
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
50+
return nil, fmt.Errorf("unexpected status code: %d, %s", resp.StatusCode, url)
5251
}
5352

5453
body, err := io.ReadAll(resp.Body)
@@ -57,7 +56,7 @@ func (c *MayanExplorer) GetSwap(hash string) (*MayanSwap, error) {
5756
}
5857

5958
var s *MayanSwap
60-
if err := json.Unmarshal(body, &s); err != nil {
59+
if err := json.Unmarshal(body, s); err != nil {
6160
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
6261
}
6362

0 commit comments

Comments
 (0)