This repository has been archived by the owner on Nov 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
357 lines (303 loc) · 12.1 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
package eos_contract_api_client
import (
"encoding/json"
"strconv"
"time"
)
type UnixTime int64
func (ts *UnixTime) UnmarshalJSON(b []byte) error {
var i int64
// "borrowed" from "gopkg.in/guregu/null.v4" abit.
if err := json.Unmarshal(b, &i); err != nil {
// If unmarshal to int64 fails, we assume that its a numeric string.
var str string
if err := json.Unmarshal(b, &str); err != nil {
return err
}
// Then we need to parse the string into int64
i, err = strconv.ParseInt(str, 10, 64)
if err != nil {
return err
}
}
*ts = UnixTime(i)
return nil
}
func (ts UnixTime) Time() time.Time {
v := int64(ts)
return time.Unix(v/1000, v%1000).UTC()
}
// Health
type ChainHealth struct {
Status string `json:"status"`
HeadBlock int64 `json:"head_block"`
HeadTime UnixTime `json:"head_time"`
}
type RedisHealth struct {
Status string `json:"status"`
}
type PostgresHealth struct {
Status string `json:"status"`
Readers []map[string]interface{} `json:"readers"`
}
type HealthData struct {
Version string `json:"version"`
Postgres PostgresHealth `json:"postgres"`
Redis RedisHealth `json:"redis"`
Chain ChainHealth `json:"chain"`
}
// Basic types
type Token struct {
Contract string `json:"token_contract"`
Symbol string `json:"token_symbol"`
Precision int `json:"token_precision"`
Amount string `json:"amount"`
}
type Log struct {
ID string `json:"log_id"`
Name string `json:"name"`
Data map[string]interface{} `json:"data"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `json:"created_at_time"`
}
// Asset types
type Asset struct {
ID string `json:"asset_id"`
Contract string `json:"contract"`
Owner string `json:"owner"`
Name string `json:"name"`
IsTransferable bool `json:"is_transferable"`
IsBurnable bool `json:"is_burnable"`
TemplateMint string `json:"template_mint"`
Collection Collection `json:"collection"`
Schema Schema `json:"schema"`
Template Template `json:"template"`
BackedTokens []Token `json:"backed_tokens"`
ImmutableData map[string]interface{} `json:"immutable_data"`
MutableData map[string]interface{} `json:"mutable_data"`
BurnedByAccount string `json:"burned_by_account"`
BurnedAtBlock string `json:"burned_at_block"`
BurnedAtTime string `json:"burned_at_time"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime string `json:"updated_at_time"`
TransferedAtBlock string `json:"transferred_at_block"`
TransferedAtTime string `json:"transferred_at_time"`
MintedAtBlock string `json:"minted_at_block"`
MintedAtTime string `json:"minted_at_time"`
}
type ListingAsset struct {
AssetID string `json:"asset_id"`
Contract string `json:"contract"`
Onwer string `json:"owner"`
Name string `json:"name"`
IsTransferable bool `json:"is_transferable"`
IsBurnable bool `json:"is_burnable"`
TemplateMint string `json:"template_mint"`
Collection Collection `json:"collection"`
Schema Schema `json:"schema"`
Template Template `json:"template"`
BackedTokens []Token `json:"backed_tokens"`
ImmutableData map[string]interface{} `json:"immutable_data"`
MutableData map[string]interface{} `json:"mutable_data"`
Data map[string]interface{} `json:"data"`
BurnedByAccount string `json:"burned_by_account"`
BurnedAtBlock string `json:"burned_at_block"`
BurnedAtTime string `json:"burned_at_time"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime string `json:"updated_at_time"`
TransferedAtBlock string `json:"transferred_at_block"`
TransferedAtTime string `json:"transferred_at_time"`
MintedAtBlock string `json:"minted_at_block"`
MintedAtTime string `json:"minted_at_time"`
Sales []Sale `json:"sales"`
Auctions []Auction `json:"actions"`
Prices []Price `json:"prices"`
}
type AssetSale struct {
ID string `json:"sale_id"`
MarketContract string `json:"market_contract"`
AuctionID string `json:"auction_id"`
BuyOfferID string `json:"buyoffer_id"`
Price string `json:"price"`
TokenSymbol string `json:"token_symbol"`
TokenPrecision int64 `json:"token_precision"`
TokenContract string `json:"token_contract"`
Seller string `json:"seller"`
Buyer string `json:"buyer"`
BlockTime UnixTime `json:"block_time"`
}
// Collection type
type Collection struct {
CollectionName string `json:"collection_name"`
Contract string `json:"contract"`
Name string `json:"name"`
Author string `json:"author"`
AllowNotify bool `json:"allow_notify"`
AuthorizedAccounts []string `json:"authorized_accounts"`
NotifyAccounts []string `json:"notify_accounts"`
MarketFee float64 `json:"market_fee"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime string `json:"created_at_time"`
}
// Schema types
type Schema struct {
Name string `json:"schema_name"`
Contract string `json:"contract"`
Format []SchemaFormat `json:"format"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime string `json:"created_at_time"`
}
type SchemaFormat struct {
Name string `json:"name"`
Type string `json:"type"`
}
// Template types
type Template struct {
ID string `json:"template_id"`
Contract string `json:"contract"`
MaxSupply string `json:"max_supply"`
IssuedSupply string `json:"issued_supply"`
IsTransferable bool `json:"is_transferable"`
IsBurnable bool `json:"is_burnable"`
ImmutableData map[string]interface{} `json:"immutable_data"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime string `json:"created_at_time"`
}
// Offer types
type Offer struct {
ID string `json:"offer_id"`
Contract string `json:"contract"`
Sender string `json:"sender_name"`
Recipient string `json:"recipient_name"`
Memo string `json:"memo"`
State int64 `json:"state"`
IsSenderContract bool `json:"is_sender_contract"`
IsRecipientContract bool `json:"is_recipient_contract"`
SenderAssets []Asset `json:"sender_assets"`
RecipientAssets []Asset `json:"recipient_assets"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime UnixTime `json:"updated_at_time"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
type ListingOffer struct {
ID string `json:"offer_id"`
Contract string `json:"contract"`
Sender string `json:"sender_name"`
Recipient string `json:"recipient_name"`
Memo string `json:"memo"`
State int64 `json:"state"`
IsSenderContract bool `json:"is_sender_contract"`
IsRecipientContract bool `json:"is_recipient_contract"`
SenderAssets []ListingAsset `json:"sender_assets"`
RecipientAssets []ListingAsset `json:"recipient_assets"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime UnixTime `json:"updated_at_time"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
type BuyOffer struct {
ID string `json:"buyoffer_id"`
MarketContract string `json:"market_contract"`
AssetsContract string `json:"assets_contract"`
Seller string `json:"seller"`
Buyer string `json:"buyer"`
Price Token `json:"price"`
Assets []Asset `json:"assets"`
MakerMarketplace string `json:"maker_marketplace,omitempty"`
TakerMarketplace string `json:"taker_marketplace,omitempty"`
Collection Collection `json:"collection"`
State int64 `json:"state"`
Memo string `json:"memo"`
DeclineMemo string `json:"decline_memo"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime UnixTime `json:"updated_at_time"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
// Transfer types
type Transfer struct {
ID string `json:"transfer_id"`
Contract string `json:"contract"`
Sender string `json:"sender_name"`
Recipient string `json:"recipient_name"`
Memo string `json:"memo"`
Assets []Asset `json:"assets"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
type ListingTransfer struct {
ID string `json:"transfer_id"`
Contract string `json:"contract"`
Sender string `json:"sender_name"`
Recipient string `json:"recipient_name"`
Memo string `json:"memo"`
Assets []ListingAsset `json:"assets"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
// Sale types
type Sale struct {
ID string `json:"sales_id"`
MarketContract string `json:"market_contract"`
AsssetsContract string `json:"assets_contract"`
Seller string `json:"seller"`
Buyer string `json:"buyer"`
OfferID string `json:"offer_id"`
Price Price `json:"price"`
ListingPrice int64 `json:"listing_price"`
ListingSymbol string `json:"listing_symbol"`
Assets []Asset `json:"assets"`
MakerMarketplace string `json:"maker_marketplace,omitempty"`
TakerMarketplace string `json:"taker_marketplace,omitempty"`
Collection Collection `json:"collection"`
State int64 `json:"state"`
UpdatedAtBlock string `json:"updated_at_block"`
UpdatedAtTime UnixTime `json:"updated_at_time"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
// Action types
type Auction struct {
ID string `json:"action_id"`
MarketContract string `json:"market_contract"`
}
// Marketplace types
type MarketPlace struct {
Name string `json:"marketplace_name"`
Creator string `json:"creator"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}
// Price types
type Price struct {
Average string `json:"average"`
MarketContract string `json:"market_contract"`
Max string `json:"max"`
Median string `json:"median"`
Min string `json:"min"`
Sales string `json:"sales"`
SuggestedAverage string `json:"suggested_average"`
SuggestedMedian string `json:"suggested_median"`
Token PriceToken `json:"token"`
}
type PriceToken struct {
Contract string `json:"token_contract"`
Symbol string `json:"token_symbol"`
Precision int `json:"token_precision"`
}
// Link types
type Link struct {
ID string `json:"link_id"`
ToolsContract string `json:"tools_contract"`
AssetsContract string `json:"assets_contract"`
Creator string `json:"creator"`
Claimer string `json:"claimer,omitempty"`
State int64 `json:"state"`
PublicKey string `json:"public_key"`
Memo string `json:"memo"`
TxID string `json:"txid"`
Assets []Asset `json:"assets"`
CreatedAtBlock string `json:"created_at_block"`
CreatedAtTime UnixTime `Json:"created_at_time"`
}