mirror of
https://github.com/grassrootseconomics/cic-chain-events.git
synced 2024-11-27 01:06:45 +01:00
Mohammed Sohail
df88d9df16
* update config to better defaults * add docs, inline and md * add context support throughout * replace json with goccy/go-json for better decoding of large JSON * update graphql fetcher: replace ioutil with io * test runner script (until CI is ready) * update CI build config
38 lines
965 B
Go
38 lines
965 B
Go
package fetch
|
|
|
|
import "context"
|
|
|
|
// Fetch defines a block fetcher that must return a full JSON response
|
|
type Fetch interface {
|
|
Block(ctx context.Context, block uint64) (fetchResponse FetchResponse, err error)
|
|
}
|
|
|
|
// Transaction reprsents a JSON object of all important mined transaction information
|
|
type Transaction struct {
|
|
Block struct {
|
|
Number uint `json:"number"`
|
|
Timestamp string `json:"timestamp"`
|
|
} `json:"block"`
|
|
Hash string `json:"hash"`
|
|
Index uint `json:"index"`
|
|
From struct {
|
|
Address string `json:"address"`
|
|
} `json:"from"`
|
|
To struct {
|
|
Address string `json:"address"`
|
|
} `json:"to"`
|
|
Value string `json:"value"`
|
|
InputData string `json:"inputData"`
|
|
Status uint `json:"status"`
|
|
GasUsed uint `json:"gasUsed"`
|
|
}
|
|
|
|
// BlockResponse represents a full fetch JSON response
|
|
type FetchResponse struct {
|
|
Data struct {
|
|
Block struct {
|
|
Transactions []Transaction `json:"transactions"`
|
|
} `json:"block"`
|
|
} `json:"data"`
|
|
}
|