Skip to content

Commit 3747a54

Browse files
Merge pull request #21 from dipdup-io/feature/tzkt-tickets-api
2 parents 7d9896e + 653dd7d commit 3747a54

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

tzkt/api/tickets.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package api
2+
3+
import (
4+
"context"
5+
6+
"github.com/dipdup-net/go-lib/tzkt/data"
7+
)
8+
9+
// GetTicketsCount - Returns a total number of tickets.
10+
func (tzkt *API) GetTicketsCount(ctx context.Context, filters map[string]string) (uint64, error) {
11+
return tzkt.count(ctx, "/v1/tickets/count", filters)
12+
}
13+
14+
// GetTickets - Returns a list of tickets.
15+
func (tzkt *API) GetTickets(ctx context.Context, filters map[string]string) (data []data.Ticket, err error) {
16+
err = tzkt.json(ctx, "/v1/tickets", filters, false, &data)
17+
return
18+
}
19+
20+
// GetTicketBalancesCount - Returns a total number of ticket balances.
21+
func (tzkt *API) GetTicketBalancesCount(ctx context.Context, filters map[string]string) (uint64, error) {
22+
return tzkt.count(ctx, "/v1/tickets/balances/count", filters)
23+
}
24+
25+
// GetTicketBalances - Returns a list of ticket balances.
26+
func (tzkt *API) GetTicketBalances(ctx context.Context, filters map[string]string) (data []data.TicketBalance, err error) {
27+
err = tzkt.json(ctx, "/v1/tickets/balances", filters, false, &data)
28+
return
29+
}
30+
31+
// GetTicketTransfersCount - Returns the total number of ticket transfers.
32+
func (tzkt *API) GetTicketTransfersCount(ctx context.Context, filters map[string]string) (uint64, error) {
33+
return tzkt.count(ctx, "/v1/tickets/transfers/count", filters)
34+
}
35+
36+
// GetTicketTransfers - Returns a list of ticket transfers.
37+
func (tzkt *API) GetTicketTransfers(ctx context.Context, filters map[string]string) (data []data.TicketTransfer, err error) {
38+
err = tzkt.json(ctx, "/v1/tickets/transfers", filters, false, &data)
39+
return
40+
}

tzkt/data/ticket.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package data
2+
3+
import (
4+
"encoding/json"
5+
"time"
6+
)
7+
8+
type Ticket struct {
9+
ID int64 `json:"id"`
10+
Ticketer Address `json:"ticketer"`
11+
RawType json.RawMessage `json:"rawType"`
12+
RawContent json.RawMessage `json:"rawContent"`
13+
Content string `json:"content"`
14+
TypeHash int64 `json:"typeHash"`
15+
ContentHash int64 `json:"contentHash"`
16+
FirstMinter Address `json:"firstMinter"`
17+
FirstLevel uint64 `json:"firstLevel"`
18+
FirstTime time.Time `json:"firstTime"`
19+
LastLevel uint64 `json:"lastLevel"`
20+
LastTime time.Time `json:"lastTime"`
21+
TransfersCount int64 `json:"transfersCount"`
22+
BalancesCount int64 `json:"balancesCount"`
23+
HoldersCount int64 `json:"holdersCount"`
24+
TotalMinted string `json:"totalMinted"`
25+
TotalBurned string `json:"totalBurned"`
26+
TotalSupply string `json:"totalSupply"`
27+
}
28+
29+
type TicketBalance struct {
30+
ID int64 `json:"id"`
31+
Ticket Ticket `json:"ticket"`
32+
Account Address `json:"account"`
33+
Balance string `json:"balance"`
34+
TransfersCount int64 `json:"transfersCount"`
35+
FirstLevel uint64 `json:"firstLevel"`
36+
FirstTime time.Time `json:"firstTime"`
37+
LastLevel uint64 `json:"lastLevel"`
38+
LastTime time.Time `json:"lastTime"`
39+
}
40+
41+
type TicketTransfer struct {
42+
ID int64 `json:"id"`
43+
Level uint64 `json:"level"`
44+
Timestamp time.Time `json:"timestamp"`
45+
Ticket Ticket `json:"ticket"`
46+
To Address `json:"to"`
47+
Amount string `json:"amount"`
48+
TransactionID int64 `json:"transactionId"`
49+
}

0 commit comments

Comments
 (0)