@@ -27,19 +27,28 @@ func MustInit(client *web3go.Client, store *store.MysqlStore) {
27
27
28
28
var charge struct {
29
29
Erc20TokenAddress string
30
+ Symbol string
31
+ Decimals uint8
30
32
}
31
33
viperUtil .MustUnmarshalKey ("charge" , & charge )
32
34
33
- name , symbol , decimals , err := nhContract .TokenInfo (client , charge .Erc20TokenAddress )
34
- if err != nil {
35
- logrus .WithError (err ).Fatal ("Get erc20 token info" )
36
- }
37
-
38
- chargeToken = & TokenInfo {
39
- Address : charge .Erc20TokenAddress ,
40
- Name : name ,
41
- Symbol : symbol ,
42
- Decimals : decimals ,
35
+ if charge .Erc20TokenAddress != "" {
36
+ name , symbol , decimals , err := nhContract .TokenInfo (client , charge .Erc20TokenAddress )
37
+ if err != nil {
38
+ logrus .WithError (err ).Fatal ("Get erc20 token info" )
39
+ }
40
+ chargeToken = & TokenInfo {
41
+ Address : charge .Erc20TokenAddress ,
42
+ Name : name ,
43
+ Symbol : symbol ,
44
+ Decimals : decimals ,
45
+ }
46
+ } else {
47
+ chargeToken = & TokenInfo {
48
+ Symbol : charge .Symbol ,
49
+ Decimals : charge .Decimals ,
50
+ }
51
+ chargeToken .Native = true
43
52
}
44
53
45
54
var flow struct {
@@ -49,7 +58,7 @@ func MustInit(client *web3go.Client, store *store.MysqlStore) {
49
58
viperUtil .MustUnmarshalKey ("flow" , & flow )
50
59
}
51
60
52
- // @title 0G Storage Scan API
61
+ // @title 0G Storage Scan API
53
62
// @version 1.0
54
63
// @description Use any http client to fetch data from the 0G Storage Scan.
55
64
func init () {
@@ -60,7 +69,7 @@ func init() {
60
69
//
61
70
// @Summary Statistics dashboard
62
71
// @Description Query statistics dashboard includes `storage fee` and `log sync height`
63
- // @Tags statistic
72
+ // @Tags (deprecated) statistic
64
73
// @Produce json
65
74
// @Success 200 {object} api.BusinessError{Data=Dashboard}
66
75
// @Failure 600 {object} api.BusinessError
@@ -73,7 +82,7 @@ func dashboardHandler(c *gin.Context) {
73
82
//
74
83
// @Summary Transaction statistics
75
84
// @Description Query transaction statistics, including incremental and full data, and support querying at hourly or daily time intervals
76
- // @Tags statistic
85
+ // @Tags (deprecated) statistic
77
86
// @Accept json
78
87
// @Produce json
79
88
// @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
@@ -93,7 +102,7 @@ func listTxStatHandler(c *gin.Context) {
93
102
//
94
103
// @Summary Data storage statistics
95
104
// @Description Query data storage statistics, including incremental and full data, and support querying at hourly or daily time intervals
96
- // @Tags statistic
105
+ // @Tags (deprecated) statistic
97
106
// @Accept json
98
107
// @Produce json
99
108
// @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
@@ -113,7 +122,7 @@ func listDataStatHandler(c *gin.Context) {
113
122
//
114
123
// @Summary fee statistics
115
124
// @Description Query fee statistics, including incremental and full data, and support querying at hourly or daily time intervals
116
- // @Tags statistic
125
+ // @Tags (deprecated) statistic
117
126
// @Accept json
118
127
// @Produce json
119
128
// @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
@@ -133,7 +142,7 @@ func listFeeStatHandler(c *gin.Context) {
133
142
//
134
143
// @Summary Layer2 transaction list
135
144
// @Description Query layer2 transactions, support address and root hash filter
136
- // @Tags transaction
145
+ // @Tags (deprecated) transaction
137
146
// @Accept json
138
147
// @Produce json
139
148
// @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
@@ -151,7 +160,7 @@ func listTxHandler(c *gin.Context) {
151
160
//
152
161
// @Summary Layer2 transaction overview
153
162
// @Description Query layer2 transaction overview by txSeq
154
- // @Tags transaction
163
+ // @Tags (deprecated) transaction
155
164
// @Accept json
156
165
// @Produce json
157
166
// @Param txSeq query string true "Lay2 transaction sequence number"
@@ -166,7 +175,7 @@ func getTxBriefHandler(c *gin.Context) {
166
175
//
167
176
// @Summary Layer2 transaction advanced info
168
177
// @Description Query layer2 transaction advanced info by txSeq
169
- // @Tags transaction
178
+ // @Tags (deprecated) transaction
170
179
// @Accept json
171
180
// @Produce json
172
181
// @Param txSeq query string true "Lay2 transaction sequence number"
@@ -191,5 +200,140 @@ func RegisterRouter(router *gin.Engine) {
191
200
txRoute .GET ("brief" , getTxBriefHandler )
192
201
txRoute .GET ("detail" , getTxDetailHandler )
193
202
203
+ statsRoute := apiRoute .Group ("/stats" )
204
+ statsRoute .GET ("summary" , summaryHandler )
205
+ statsRoute .GET ("layer1-tx" , listTxStatsHandler )
206
+ statsRoute .GET ("storage" , listDataStatsHandler )
207
+ statsRoute .GET ("fee" , listFeeStatsHandler )
208
+
209
+ txsRoute := apiRoute .Group ("/txs" )
210
+ txsRoute .GET ("" , listTxsHandler )
211
+ txsRoute .GET (":txSeq" , getTxHandler )
212
+
213
+ accountsRoute := apiRoute .Group ("/accounts" )
214
+ accountsRoute .GET (":address/txs" , listAddressTxsHandler )
215
+
194
216
router .GET ("/swagger/*any" , ginSwagger .WrapHandler (swaggerFiles .Handler ))
195
217
}
218
+
219
+ // summaryHandler godoc
220
+ //
221
+ // @Summary Statistics summary
222
+ // @Description Query statistics summary includes `storage fee` and `log sync height`
223
+ // @Tags statistic
224
+ // @Produce json
225
+ // @Success 200 {object} api.BusinessError{Data=Summary}
226
+ // @Failure 600 {object} api.BusinessError
227
+ // @Router /stats/summary [get]
228
+ func summaryHandler (c * gin.Context ) {
229
+ api .Wrap (summary )(c )
230
+ }
231
+
232
+ // listTxStatsHandler godoc
233
+ //
234
+ // @Summary Layer1 transaction statistics
235
+ // @Description Query transaction statistics, including incremental and full data, and support querying at hourly or daily time intervals
236
+ // @Tags statistic
237
+ // @Accept json
238
+ // @Produce json
239
+ // @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
240
+ // @Param limit query int false "The number of records displayed on the page" minimum(1) maximum(2000) default(10)
241
+ // @Param minTimestamp query int false "Timestamp in seconds"
242
+ // @Param maxTimestamp query int false "Timestamp in seconds"
243
+ // @Param intervalType query string false "Statistics interval" Enums(hour, day) default(day)
244
+ // @Param sort query string false "Sort by timestamp" Enums(asc, desc) default(desc)
245
+ // @Success 200 {object} api.BusinessError{Data=TxStatList}
246
+ // @Failure 600 {object} api.BusinessError
247
+ // @Router /stats/layer1-tx [get]
248
+ func listTxStatsHandler (c * gin.Context ) {
249
+ api .Wrap (listTxStat )(c )
250
+ }
251
+
252
+ // listDataStatsHandler godoc
253
+ //
254
+ // @Summary Data storage statistics
255
+ // @Description Query data storage statistics, including incremental and full data, and support querying at hourly or daily time intervals
256
+ // @Tags statistic
257
+ // @Accept json
258
+ // @Produce json
259
+ // @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
260
+ // @Param limit query int false "The number of records displayed on the page" minimum(1) maximum(2000) default(10)
261
+ // @Param minTimestamp query int false "Timestamp in seconds"
262
+ // @Param maxTimestamp query int false "Timestamp in seconds"
263
+ // @Param intervalType query string false "Statistics interval" Enums(hour, day) default(day)
264
+ // @Param sort query string false "Sort by timestamp" Enums(asc, desc) default(desc)
265
+ // @Success 200 {object} api.BusinessError{Data=DataStatList}
266
+ // @Failure 600 {object} api.BusinessError
267
+ // @Router /stats/storage [get]
268
+ func listDataStatsHandler (c * gin.Context ) {
269
+ api .Wrap (listDataStat )(c )
270
+ }
271
+
272
+ // listFeeStatsHandler godoc
273
+ //
274
+ // @Summary Storage fee statistics
275
+ // @Description Query fee statistics, including incremental and full data, and support querying at hourly or daily time intervals
276
+ // @Tags statistic
277
+ // @Accept json
278
+ // @Produce json
279
+ // @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
280
+ // @Param limit query int false "The number of records displayed on the page" minimum(1) maximum(2000) default(10)
281
+ // @Param minTimestamp query int false "Timestamp in seconds"
282
+ // @Param maxTimestamp query int false "Timestamp in seconds"
283
+ // @Param intervalType query string false "Statistics interval" Enums(hour, day) default(day)
284
+ // @Param sort query string false "Sort by timestamp" Enums(asc, desc) default(desc)
285
+ // @Success 200 {object} api.BusinessError{Data=FeeStatList}
286
+ // @Failure 600 {object} api.BusinessError
287
+ // @Router /stats/fee [get]
288
+ func listFeeStatsHandler (c * gin.Context ) {
289
+ api .Wrap (listFeeStat )(c )
290
+ }
291
+
292
+ // listTxsHandler godoc
293
+ //
294
+ // @Summary Storage transaction list
295
+ // @Description Query storage transactions, support address and root hash filter
296
+ // @Tags transaction
297
+ // @Accept json
298
+ // @Produce json
299
+ // @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
300
+ // @Param limit query int false "The number of records displayed on the page" minimum(1) maximum(100) default(10)
301
+ // @Success 200 {object} api.BusinessError{Data=StorageTxList}
302
+ // @Failure 600 {object} api.BusinessError
303
+ // @Router /txs [get]
304
+ func listTxsHandler (c * gin.Context ) {
305
+ api .Wrap (listStorageTx )(c )
306
+ }
307
+
308
+ // getTxHandler godoc
309
+ //
310
+ // @Summary Storage transaction information
311
+ // @Description Query storage transaction by txSeq
312
+ // @Tags transaction
313
+ // @Accept json
314
+ // @Produce json
315
+ // @Param txSeq path string true "storage transaction sequence number"
316
+ // @Success 200 {object} api.BusinessError{Data=StorageTxDetail}
317
+ // @Failure 600 {object} api.BusinessError
318
+ // @Router /txs/{txSeq} [get]
319
+ func getTxHandler (c * gin.Context ) {
320
+ api .Wrap (getStorageTx )(c )
321
+ }
322
+
323
+ // listAddressTxsHandler godoc
324
+ //
325
+ // @Summary Account's storage transaction list
326
+ // @Description Query storage transactions for specified account, support root hash filter
327
+ // @Tags account
328
+ // @Accept json
329
+ // @Produce json
330
+ // @Param address path string false "The submitter address of the uploaded file"
331
+ // @Param skip query int false "The number of skipped records, usually it's pageSize * (pageNumber - 1)" minimum(0) default(0)
332
+ // @Param limit query int false "The number of records displayed on the page" minimum(1) maximum(100) default(10)
333
+ // @Param rootHash query string false "The merkle root hash of the uploaded file"
334
+ // @Success 200 {object} api.BusinessError{Data=StorageTxList}
335
+ // @Failure 600 {object} api.BusinessError
336
+ // @Router /accounts/{address}/txs [get]
337
+ func listAddressTxsHandler (c * gin.Context ) {
338
+ api .Wrap (listAddressStorageTx )(c )
339
+ }
0 commit comments