-
Notifications
You must be signed in to change notification settings - Fork 2
/
rollupclient.go
60 lines (48 loc) · 1.76 KB
/
rollupclient.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
package sources
import (
"context"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/sliceledger-blockchain/slice-ledger/op-node/client"
"github.com/sliceledger-blockchain/slice-ledger/op-node/eth"
"github.com/sliceledger-blockchain/slice-ledger/op-node/rollup"
)
type RollupClient struct {
rpc client.RPC
}
func NewRollupClient(rpc client.RPC) *RollupClient {
return &RollupClient{rpc}
}
func (r *RollupClient) OutputAtBlock(ctx context.Context, blockNum uint64) (*eth.OutputResponse, error) {
var output *eth.OutputResponse
err := r.rpc.CallContext(ctx, &output, "slice_outputAtBlock", hexutil.Uint64(blockNum))
return output, err
}
func (r *RollupClient) SyncStatus(ctx context.Context) (*eth.SyncStatus, error) {
var output *eth.SyncStatus
err := r.rpc.CallContext(ctx, &output, "slice_syncStatus")
return output, err
}
func (r *RollupClient) RollupConfig(ctx context.Context) (*rollup.Config, error) {
var output *rollup.Config
err := r.rpc.CallContext(ctx, &output, "slice_rollupConfig")
return output, err
}
func (r *RollupClient) Version(ctx context.Context) (string, error) {
var output string
err := r.rpc.CallContext(ctx, &output, "slice_version")
return output, err
}
func (r *RollupClient) StartSequencer(ctx context.Context, unsafeHead common.Hash) error {
return r.rpc.CallContext(ctx, nil, "admin_startSequencer", unsafeHead)
}
func (r *RollupClient) StopSequencer(ctx context.Context) (common.Hash, error) {
var result common.Hash
err := r.rpc.CallContext(ctx, &result, "admin_stopSequencer")
return result, err
}
func (r *RollupClient) SequencerActive(ctx context.Context) (bool, error) {
var result bool
err := r.rpc.CallContext(ctx, &result, "admin_sequencerActive")
return result, err
}