-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_block_with_receipts.go
39 lines (32 loc) · 1.17 KB
/
get_block_with_receipts.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
package api
import (
"context"
"github.com/dipdup-io/starknet-go-api/pkg/data"
)
// BlockWithReceipt -
type BlockWithReceipt struct {
Status string `json:"status"`
BlockHash string `json:"block_hash"`
ParentHash string `json:"parent_hash"`
BlockNumber uint64 `json:"block_number"`
NewRoot string `json:"new_root"`
Timestamp int64 `json:"timestamp"`
SequencerAddress string `json:"sequencer_address"`
Version *string `json:"starknet_version,omitempty"`
L1GasPrice L1GasPrice `json:"l1_gas_price"`
Transactions []Tx `json:"transactions"`
}
type Tx struct {
Transaction data.Transaction `json:"transaction"`
Receipt Receipt `json:"receipt"`
}
// GetBlockWithReceipts -
func (api API) GetBlockWithReceipts(ctx context.Context, block data.BlockID, opts ...RequestOption) (*Response[BlockWithReceipt], error) {
if err := block.Validate(); err != nil {
return nil, err
}
request := api.prepareRequest("starknet_getBlockWithReceipts", []any{block}, opts...)
var response Response[BlockWithReceipt]
err := post(ctx, api, *request, &response)
return &response, err
}