Skip to content

Commit baf4904

Browse files
committed
更新交易返回属性
1 parent 2d0395f commit baf4904

File tree

4 files changed

+84
-24
lines changed

4 files changed

+84
-24
lines changed

client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"net/http"
1616
"net/http/httputil"
1717
"net/url"
18+
"strings"
1819
"time"
1920
)
2021

@@ -172,7 +173,7 @@ func (c *Client) call(module, action string, param map[string]interface{}, outco
172173
err = wrapErr(err, "json unmarshal envelope")
173174
return
174175
}
175-
if envelope.Status != 1 {
176+
if envelope.Status != 1 && !strings.EqualFold(envelope.Message, "No transactions found") {
176177
err = fmt.Errorf("etherscan server: %s", envelope.Message)
177178
return
178179
}

go.mod

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,24 @@ module github.com/idoall/etherscan-api
22

33
go 1.19
44

5-
require github.com/google/go-cmp v0.5.7
5+
require github.com/google/go-cmp v0.5.9
6+
7+
require (
8+
github.com/bits-and-blooms/bitset v1.13.0 // indirect
9+
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
10+
github.com/consensys/bavard v0.1.13 // indirect
11+
github.com/consensys/gnark-crypto v0.12.1 // indirect
12+
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
13+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
14+
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
15+
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 // indirect
16+
github.com/ethereum/go-ethereum v1.13.11 // indirect
17+
github.com/holiman/uint256 v1.2.4 // indirect
18+
github.com/mmcloughlin/addchain v0.4.0 // indirect
19+
github.com/supranational/blst v0.3.11 // indirect
20+
golang.org/x/crypto v0.18.0 // indirect
21+
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
22+
golang.org/x/sync v0.6.0 // indirect
23+
golang.org/x/sys v0.17.0 // indirect
24+
rsc.io/tmplfunc v0.0.3 // indirect
25+
)

go.sum

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,41 @@
1+
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
2+
github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
3+
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
4+
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
5+
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
6+
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
7+
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
8+
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
9+
github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA=
10+
github.com/crate-crypto/go-kzg-4844 v0.7.0/go.mod h1:1kMhvPgI0Ky3yIa+9lFySEBUBXkYxeOi8ZF1sYioxhc=
11+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
12+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
13+
github.com/ethereum/c-kzg-4844 v0.4.0 h1:3MS1s4JtA868KpJxroZoepdV0ZKBp3u/O5HcZ7R3nlY=
14+
github.com/ethereum/c-kzg-4844 v0.4.0/go.mod h1:VewdlzQmpT5QSrVhbBuGoCdFJkpaJlO1aQputP83wc0=
15+
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4 h1:B2mpK+MNqgPqk2/KNi1LbqwtZDy5F7iy0mynQiBr8VA=
16+
github.com/ethereum/c-kzg-4844/bindings/go v0.0.0-20230126171313-363c7d7593b4/go.mod h1:y4GA2JbAUama1S4QwYjC2hefgGLU8Ul0GMtL/ADMF1c=
17+
github.com/ethereum/go-ethereum v1.13.11 h1:b51Dsm+rEg7anFRUMGB8hODXHvNfcRKzz9vcj8wSdUs=
18+
github.com/ethereum/go-ethereum v1.13.11/go.mod h1:gFtlVORuUcT+UUIcJ/veCNjkuOSujCi338uSHJrYAew=
119
github.com/google/go-cmp v0.5.7 h1:81/ik6ipDQS2aGcBfIN5dHDB36BwrStyeAQquSYCV4o=
220
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
21+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
22+
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
23+
github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU=
24+
github.com/holiman/uint256 v1.2.4/go.mod h1:EOMSn4q6Nyt9P6efbI3bueV4e1b3dGlUCXeiRV4ng7E=
25+
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
26+
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
27+
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
28+
github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4=
29+
github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
30+
golang.org/x/crypto v0.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
31+
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
32+
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 h1:/RIbNt/Zr7rVhIkQhooTxCxFcdWLGIKnZA4IXNFSrvo=
33+
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3/go.mod h1:idGWGoKP1toJGkd5/ig9ZLuPcZBC3ewk7SzmH0uou08=
34+
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
35+
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
36+
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
37+
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
338
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
439
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
40+
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
41+
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=

response.go

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ type AccountBalance struct {
3232

3333
// NormalTx holds info from normal tx query
3434
type NormalTx struct {
35-
BlockNumber int `json:"blockNumber,string"`
35+
BlockNumber int64 `json:"blockNumber,string"`
3636
TimeStamp Time `json:"timeStamp"`
3737
Hash string `json:"hash"`
3838
Nonce int `json:"nonce,string"`
@@ -41,20 +41,22 @@ type NormalTx struct {
4141
From string `json:"from"`
4242
To string `json:"to"`
4343
Value *BigInt `json:"value"`
44-
Gas int `json:"gas,string"`
44+
Gas int64 `json:"gas,string"`
4545
GasPrice *BigInt `json:"gasPrice"`
4646
IsError int `json:"isError,string"`
4747
TxReceiptStatus string `json:"txreceipt_status"`
4848
Input string `json:"input"`
4949
ContractAddress string `json:"contractAddress"`
50-
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
51-
GasUsed int `json:"gasUsed,string"`
50+
CumulativeGasUsed int64 `json:"cumulativeGasUsed,string"`
51+
GasUsed int64 `json:"gasUsed,string"`
5252
Confirmations int `json:"confirmations,string"`
53+
MethodId string `json:"methodId"`
54+
FunctionName string `json:"functionName"`
5355
}
5456

5557
// InternalTx holds info from internal tx query
5658
type InternalTx struct {
57-
BlockNumber int `json:"blockNumber,string"`
59+
BlockNumber int64 `json:"blockNumber,string"`
5860
TimeStamp Time `json:"timeStamp"`
5961
Hash string `json:"hash"`
6062
From string `json:"from"`
@@ -63,19 +65,19 @@ type InternalTx struct {
6365
ContractAddress string `json:"contractAddress"`
6466
Input string `json:"input"`
6567
Type string `json:"type"`
66-
Gas int `json:"gas,string"`
67-
GasUsed int `json:"gasUsed,string"`
68+
Gas int64 `json:"gas,string"`
69+
GasUsed int64 `json:"gasUsed,string"`
6870
TraceID string `json:"traceId"`
6971
IsError int `json:"isError,string"`
7072
ErrCode string `json:"errCode"`
7173
}
7274

7375
// ERC20Transfer holds info from ERC20 token transfer event query
7476
type ERC20Transfer struct {
75-
BlockNumber int `json:"blockNumber,string"`
77+
BlockNumber int64 `json:"blockNumber,string"`
7678
TimeStamp Time `json:"timeStamp"`
7779
Hash string `json:"hash"`
78-
Nonce int `json:"nonce,string"`
80+
Nonce int64 `json:"nonce,string"`
7981
BlockHash string `json:"blockHash"`
8082
From string `json:"from"`
8183
ContractAddress string `json:"contractAddress"`
@@ -85,20 +87,20 @@ type ERC20Transfer struct {
8587
TokenSymbol string `json:"tokenSymbol"`
8688
TokenDecimal uint8 `json:"tokenDecimal,string"`
8789
TransactionIndex int `json:"transactionIndex,string"`
88-
Gas int `json:"gas,string"`
90+
Gas int64 `json:"gas,string"`
8991
GasPrice *BigInt `json:"gasPrice"`
90-
GasUsed int `json:"gasUsed,string"`
91-
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
92+
GasUsed int64 `json:"gasUsed,string"`
93+
CumulativeGasUsed int64 `json:"cumulativeGasUsed,string"`
9294
Input string `json:"input"`
9395
Confirmations int `json:"confirmations,string"`
9496
}
9597

9698
// ERC721Transfer holds info from ERC721 token transfer event query
9799
type ERC721Transfer struct {
98-
BlockNumber int `json:"blockNumber,string"`
100+
BlockNumber int64 `json:"blockNumber,string"`
99101
TimeStamp Time `json:"timeStamp"`
100102
Hash string `json:"hash"`
101-
Nonce int `json:"nonce,string"`
103+
Nonce int64 `json:"nonce,string"`
102104
BlockHash string `json:"blockHash"`
103105
From string `json:"from"`
104106
ContractAddress string `json:"contractAddress"`
@@ -108,20 +110,20 @@ type ERC721Transfer struct {
108110
TokenSymbol string `json:"tokenSymbol"`
109111
TokenDecimal uint8 `json:"tokenDecimal,string"`
110112
TransactionIndex int `json:"transactionIndex,string"`
111-
Gas int `json:"gas,string"`
113+
Gas int64 `json:"gas,string"`
112114
GasPrice *BigInt `json:"gasPrice"`
113-
GasUsed int `json:"gasUsed,string"`
114-
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
115+
GasUsed int64 `json:"gasUsed,string"`
116+
CumulativeGasUsed int64 `json:"cumulativeGasUsed,string"`
115117
Input string `json:"input"`
116118
Confirmations int `json:"confirmations,string"`
117119
}
118120

119121
// ERC1155Transfer holds info from ERC1155 token transfer event query
120122
type ERC1155Transfer struct {
121-
BlockNumber int `json:"blockNumber,string"`
123+
BlockNumber int64 `json:"blockNumber,string"`
122124
TimeStamp Time `json:"timeStamp"`
123125
Hash string `json:"hash"`
124-
Nonce int `json:"nonce,string"`
126+
Nonce int64 `json:"nonce,string"`
125127
BlockHash string `json:"blockHash"`
126128
From string `json:"from"`
127129
ContractAddress string `json:"contractAddress"`
@@ -132,10 +134,10 @@ type ERC1155Transfer struct {
132134
TokenDecimal uint8 `json:"tokenDecimal,string"`
133135
TokenValue uint8 `json:"tokenValue,string"`
134136
TransactionIndex int `json:"transactionIndex,string"`
135-
Gas int `json:"gas,string"`
137+
Gas int64 `json:"gas,string"`
136138
GasPrice *BigInt `json:"gasPrice"`
137-
GasUsed int `json:"gasUsed,string"`
138-
CumulativeGasUsed int `json:"cumulativeGasUsed,string"`
139+
GasUsed int64 `json:"gasUsed,string"`
140+
CumulativeGasUsed int64 `json:"cumulativeGasUsed,string"`
139141
Input string `json:"input"`
140142
Confirmations int `json:"confirmations,string"`
141143
}

0 commit comments

Comments
 (0)