Documentation ¶
Index ¶
- type APIService
- func (s *APIService) ConstructionCombine(ctx context.Context, req *types.ConstructionCombineRequest) (*types.ConstructionCombineResponse, *types.Error)
- func (s *APIService) ConstructionDerive(ctx context.Context, req *types.ConstructionDeriveRequest) (*types.ConstructionDeriveResponse, *types.Error)
- func (s *APIService) ConstructionHash(ctx context.Context, req *types.ConstructionHashRequest) (*types.TransactionIdentifierResponse, *types.Error)
- func (s APIService) ConstructionMetadata(ctx context.Context, req *types.ConstructionMetadataRequest) (*types.ConstructionMetadataResponse, *types.Error)
- func (s *APIService) ConstructionParse(ctx context.Context, request *types.ConstructionParseRequest) (*types.ConstructionParseResponse, *types.Error)
- func (s *APIService) ConstructionPayloads(ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
- func (s *APIService) ConstructionPreprocess(ctx context.Context, req *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error)
- func (s *APIService) ConstructionSubmit(ctx context.Context, req *types.ConstructionSubmitRequest) (*types.TransactionIdentifierResponse, *types.Error)
- func (s *APIService) CreateOperationDescription(operations []*types.Operation, isContractCall bool) ([]*parser.OperationDescription, error)
- func (s *APIService) CreateOperationDescriptionContractCall() []*parser.OperationDescription
- func (s *APIService) CreateOperationDescriptionERC20(contractAddress string, currencyInfo *types.Currency) []*parser.OperationDescription
- func (s *APIService) CreateOperationDescriptionNative() []*parser.OperationDescription
- type Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIService ¶
type APIService struct {
// contains filtered or unexported fields
}
APIService implements /construction/* endpoints
func NewAPIService ¶
func NewAPIService( cfg *configuration.Configuration, types *sdkTypes.Types, errors []*types.Error, client Client, ) *APIService
NewAPIService creates a new instance of a APIService.
func (*APIService) ConstructionCombine ¶
func (s *APIService) ConstructionCombine( ctx context.Context, req *types.ConstructionCombineRequest, ) (*types.ConstructionCombineResponse, *types.Error)
ConstructionCombine implements /construction/combine endpoint.
Combine creates a network-specific Transaction from an unsigned Transaction and an array of provided signatures. The signed Transaction returned from this method will be sent to the /construction/submit endpoint by the caller.
func (*APIService) ConstructionDerive ¶
func (s *APIService) ConstructionDerive( ctx context.Context, req *types.ConstructionDeriveRequest, ) (*types.ConstructionDeriveResponse, *types.Error)
ConstructionDerive implements the /construction/derive endpoint.
func (*APIService) ConstructionHash ¶
func (s *APIService) ConstructionHash( ctx context.Context, req *types.ConstructionHashRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
ConstructionHash implements /construction/hash endpoint.
TransactionHash returns the network-specific Transaction hash for a signed Transaction.
func (APIService) ConstructionMetadata ¶
func (s APIService) ConstructionMetadata( ctx context.Context, req *types.ConstructionMetadataRequest, ) (*types.ConstructionMetadataResponse, *types.Error)
ConstructionMetadata implements /construction/metadata endpoint.
Get any information required to construct a transaction for a specific network. Metadata returned here could be a recent hash to use, an account sequence number, or even arbitrary chain state. The request used when calling this endpoint is created by calling /construction/preprocess in an offline environment.
func (*APIService) ConstructionParse ¶
func (s *APIService) ConstructionParse( ctx context.Context, request *types.ConstructionParseRequest, ) (*types.ConstructionParseResponse, *types.Error)
ConstructionParse implements the /construction/parse endpoint.
func (*APIService) ConstructionPayloads ¶
func (s *APIService) ConstructionPayloads( ctx context.Context, req *types.ConstructionPayloadsRequest) (*types.ConstructionPayloadsResponse, *types.Error)
ConstructionPayloads implements /construction/payloads endpoint
Payloads is called with an array of operations and the response from /construction/Metadata. It returns an unsigned Transaction blob and a collection of payloads that must be signed by particular AccountIdentifiers using a certain SignatureType. The array of operations provided in Transaction construction often times can not specify all "effects" of a Transaction (consider invoked transactions in Ethereum). However, they can deterministically specify the "intent" of the Transaction, which is sufficient for construction. For this reason, parsing the corresponding Transaction in the Data API (when it lands on chain) will contain a superset of whatever operations were provided during construction.
func (*APIService) ConstructionPreprocess ¶
func (s *APIService) ConstructionPreprocess( ctx context.Context, req *types.ConstructionPreprocessRequest) (*types.ConstructionPreprocessResponse, *types.Error)
ConstructionPreprocess implements /construction/preprocess endpoint.
Preprocess is called prior to /construction/payloads to construct a request for any metadata that is needed for transaction construction given (i.e. account nonce).
func (*APIService) ConstructionSubmit ¶
func (s *APIService) ConstructionSubmit( ctx context.Context, req *types.ConstructionSubmitRequest, ) (*types.TransactionIdentifierResponse, *types.Error)
ConstructionSubmit implements /construction/submit endpoint.
Submit a pre-signed Transaction to the node.
func (*APIService) CreateOperationDescription ¶
func (s *APIService) CreateOperationDescription( operations []*types.Operation, isContractCall bool, ) ([]*parser.OperationDescription, error)
func (*APIService) CreateOperationDescriptionContractCall ¶
func (s *APIService) CreateOperationDescriptionContractCall() []*parser.OperationDescription
func (*APIService) CreateOperationDescriptionERC20 ¶
func (s *APIService) CreateOperationDescriptionERC20( contractAddress string, currencyInfo *types.Currency, ) []*parser.OperationDescription
func (*APIService) CreateOperationDescriptionNative ¶
func (s *APIService) CreateOperationDescriptionNative() []*parser.OperationDescription
type Client ¶
type Client interface { // Status returns the current status of the network Status( context.Context, ) (*RosettaTypes.BlockIdentifier, int64, *RosettaTypes.SyncStatus, []*RosettaTypes.Peer, error, ) // Balance is to fetch the state of an account based on the provided currencies Balance( context.Context, *RosettaTypes.AccountIdentifier, *RosettaTypes.PartialBlockIdentifier, []*RosettaTypes.Currency, ) (*RosettaTypes.AccountBalanceResponse, error) // Submit is to submit a pre-signed transaction to the blockchain Submit(context.Context, *EthTypes.Transaction) error // GetNonce returns the account nonce of the given account // The given account is the from address in Options input GetNonce(context.Context, evmClient.Options) (uint64, error) // GetGasPrice retrieves the currently suggested gas price GetGasPrice(context.Context, evmClient.Options) (*big.Int, error) // GetRosettaConfig returns the Rosetta config we defined for the network GetRosettaConfig() configuration.RosettaConfig // TraceBlockByHash returns all traces for each transaction in the block // by calling geth debug_traceBlockByHash JSON RPC. // The output is map which key is transaction hash, and the value is list of // FlatCall. Each Flatcall is populated from one single trace. TraceBlockByHash( context.Context, common.Hash, []evmClient.RPCTransaction, ) (map[string][]*evmClient.FlatCall, error) // TraceTransaction returns all traces for one transaction // by calling geth debug_traceTransaction JSON RPC. // The output is a list of FlatCall. Each Flatcall is populated from one single trace. TraceTransaction(ctx context.Context, hash common.Hash) (json.RawMessage, []*evmClient.FlatCall, error) // BlockRewardTransaction returns the block reward Rosetta transaction for the miner BlockRewardTransaction( blockIdentifier *RosettaTypes.BlockIdentifier, miner string, uncles []*EthTypes.Header, ) *RosettaTypes.Transaction // GetLoadedTransaction populates the LoadedTransaction which used by Rosetta data APIs GetLoadedTransaction( ctx context.Context, request *RosettaTypes.BlockTransactionRequest, ) (*evmClient.LoadedTransaction, error) // BlockAuthor returns the block author BlockAuthor(ctx context.Context, blockIndex int64) (string, error) // GetUncles calls eth_getUncleByBlockHashAndIndex eth RPC to load uncle blocks GetUncles( ctx context.Context, head *EthTypes.Header, body *evmClient.RPCBlock, ) ([]*EthTypes.Header, error) // TraceReplayBlockTransactions returns all traces for each transaction in the block // by calling open ethereum trace_replayBlockTransactions JSON RPC. // The output is map which key is transaction hash, and the value is list of // FlatCall. Each Flatcall is populated from one single trace. TraceReplayBlockTransactions( ctx context.Context, hsh string, ) (map[string][]*evmClient.FlatCall, error) // TraceTransaction returns all traces for one transaction // by calling open ethereum trace_replayTransaction JSON RPC. // The output is a list of FlatCall. Each Flatcall is populated from one single trace. TraceReplayTransaction(ctx context.Context, hsh string) (json.RawMessage, []*evmClient.FlatCall, error) // PopulateCrossChainTransactions populates all the bridge transactions for the block // This method is used for blockchain that supports bridging function PopulateCrossChainTransactions( *EthTypes.Block, []*evmClient.LoadedTransaction, ) ([]*RosettaTypes.Transaction, error) // GetContractCurrency returns the ERC20 currency into for a specific token contract address GetContractCurrency(addr common.Address, erc20 bool) (*evmClient.ContractCurrency, error) // CallContext performs a JSON-RPC call with the given arguments. // The method is used by the JSON RPC Client, which is the interface // for accessing go-ethereum's JSON RPC endpoint. CallContext(ctx context.Context, result interface{}, method string, args ...interface{}) error // BatchCall sends all given requests as a single batch and waits for the server // to return a response for all of them. The wait duration is bounded by the // context's deadline. // The method is used by the JSON RPC Client, which is the interface // for accessing go-ethereum's JSON RPC endpoint. BatchCallContext(ctx context.Context, b []rpc.BatchElem) error // GetBlockReceipts returns a list of transaction receipts, used by Rosetta block api GetBlockReceipts( ctx context.Context, blockHash common.Hash, txs []evmClient.RPCTransaction, baseFee *big.Int, ) ([]*evmClient.RosettaTxReceipt, error) // GetTransactionReceipt returns the Rosetta transaction receipt, used by Rosetta // block/transaction api GetTransactionReceipt( ctx context.Context, tx *evmClient.LoadedTransaction, ) (*evmClient.RosettaTxReceipt, error) // GetNativeTransferGasLimit returns the estimated gas limit for the native currency transfer // This method is used by Rosetta construction/metadata api GetNativeTransferGasLimit( ctx context.Context, toAddress string, fromAddress string, value *big.Int, ) (uint64, error) // GetErc20TransferGasLimit returns the estimated gas limit for the ERC20 token transfer // This method is used by Rosetta construction/metadata api GetErc20TransferGasLimit( ctx context.Context, toAddress string, fromAddress string, value *big.Int, currency *RosettaTypes.Currency, ) (uint64, error) // GetErc20TransferGasLimit returns the estimated gas limit for the ERC20 token transfer // This method is used by Rosetta construction/metadata api GetContractCallGasLimit( ctx context.Context, toAddress string, fromAddress string, data []byte, ) (uint64, error) // ParseOps returns a list of operations ParseOps( tx *evmClient.LoadedTransaction, ) ([]*RosettaTypes.Operation, error) }
Client contains all the methods required to interact with go-ethereum based blockchain