2021-12-06 14:58:53 +00:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-01-20 15:34:00 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/starknet"
|
2021-12-06 14:58:53 +00:00
|
|
|
"github.com/ledgerwatch/erigon-lib/gointerfaces/txpool"
|
|
|
|
"github.com/ledgerwatch/erigon/common/hexutil"
|
|
|
|
"github.com/ledgerwatch/erigon/rpc"
|
|
|
|
|
|
|
|
"github.com/ledgerwatch/erigon-lib/kv"
|
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
type StarknetAPI interface {
|
|
|
|
SendRawTransaction(ctx context.Context, encodedTx hexutil.Bytes) (common.Hash, error)
|
|
|
|
GetCode(ctx context.Context, address common.Address, blockNrOrHash rpc.BlockNumberOrHash) (hexutil.Bytes, error)
|
2022-01-20 15:34:00 +00:00
|
|
|
Call(ctx context.Context, request StarknetCallRequest, blockNrOrHash rpc.BlockNumberOrHash) ([]string, error)
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type StarknetImpl struct {
|
|
|
|
*BaseAPI
|
|
|
|
db kv.RoDB
|
2022-01-20 15:34:00 +00:00
|
|
|
client starknet.CAIROVMClient
|
|
|
|
txPool txpool.TxpoolClient
|
2021-12-06 14:58:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-20 15:34:00 +00:00
|
|
|
func NewStarknetAPI(base *BaseAPI, db kv.RoDB, client starknet.CAIROVMClient, txPool txpool.TxpoolClient) *StarknetImpl {
|
2021-12-06 14:58:53 +00:00
|
|
|
return &StarknetImpl{
|
|
|
|
BaseAPI: base,
|
|
|
|
db: db,
|
2022-01-20 15:34:00 +00:00
|
|
|
client: client,
|
2021-12-06 14:58:53 +00:00
|
|
|
txPool: txPool,
|
|
|
|
}
|
|
|
|
}
|