rpccalls

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const AlchemyProvider = "alchemy"

providers

View Source
const BiconomyProvider = "biconomy"
View Source
const PimlicoProvider = "pimlico"
View Source
const StackUpPMPayTemplate = "" /* 157-byte string literal not displayed */
View Source
const StackUpProvider = "stackup"
View Source
const StackUpSendOpTemplate = "" /* 131-byte string literal not displayed */
View Source
const StackupAPIDefURL = "https://api.stackup.sh/v1/paymaster/"

Variables

View Source
var ErrRetParse = fmt.Errorf("could not unpack return values")

Functions

func ApiCall added in v0.2.3

func ApiCall(url, key string, ar *APIRequest, result interface{}) ([]byte, error)

Returns unparsed "Result" if successful, otherwise nil and either *APIError or error

func ApiFreeHandCall added in v0.2.3

func ApiFreeHandCall(url, key, methodTemplate string, params ...interface{}) (result []byte, err error)

func CallContract added in v0.2.2

func CallContract(rpc *state.RPCEndpoint, from, to *common.Address, calldata []byte, retType abi.Arguments) ([]interface{}, []byte, error)

CallContract calls a contract with the given calldata Attempts to parse the response with the given return type Returns the result of parsing and the raw response or error, if any

func CreateAndSendTransaction

func CreateAndSendTransaction(rpc *state.RPCEndpoint, from, to common.Address, value *big.Int, calldata []byte, gasLimit uint64, key KeyContainer) (*common.Hash, error)

func CreateSignedTransaction

func CreateSignedTransaction(rpc *state.RPCEndpoint, from, to common.Address, value *big.Int, calldata []byte, gasLimit uint64, key *ecdsa.PrivateKey) (*types.Transaction, error)

func Eth_getUserOperationByHash added in v0.2.3

func Eth_getUserOperationByHash(url, key string, hash string, provider string) ([]byte, error)

func Eth_getUserOperationReceipt added in v0.2.3

func Eth_getUserOperationReceipt(url, key string, hash string, provider string) ([]byte, error)

func Eth_sendUserOperation added in v0.2.3

func Eth_sendUserOperation(url, key string, usop *userop.UserOperation, entrypoint string, entrypointVersion int, provider string) (*string, error)

func Eth_supportedEntryPoints added in v0.2.3

func Eth_supportedEntryPoints(url, key string) (*[]string, error)

func GetBalance added in v0.2.2

func GetBalance(rpc *state.RPCEndpoint, addr common.Address) (*big.Int, error)

func GetNonce added in v0.2.3

func GetNonce(rpc *state.RPCEndpoint, addr common.Address) (uint64, error)

func GetPendingNonce added in v0.2.3

func GetPendingNonce(rpc *state.RPCEndpoint, addr common.Address) (uint64, error)

func GetWalletNonce added in v0.2.2

func GetWalletNonce(rpc *state.RPCEndpoint, addr common.Address) (uint64, error)

func IncorporateStackUpPMResToUserOp added in v0.2.3

func IncorporateStackUpPMResToUserOp(usop *userop.UserOperation, res *StackUpPMPayGResult) error

func PM_getPaymasterStubData added in v0.2.3

func PM_getPaymasterStubData(url, key string, usop *userop.UserOperation, context interface{},
	entrypoint string, chainId interface{}, provider string) ([]byte, error)

func POSTCall added in v0.2.3

func POSTCall(url, key string, data []byte) (result []byte, err error)

func SendTransaction

func SendTransaction(rpc *state.RPCEndpoint, signedTx *types.Transaction) (*common.Hash, error)

Types

type APIError added in v0.2.3

type APIError struct {
	Code    int             `json:"code"`
	Data    json.RawMessage `json:"data"`
	Message string          `json:"message"`
}

func (*APIError) Error added in v0.2.3

func (ae *APIError) Error() string

type APIRPCResponse added in v0.2.3

type APIRPCResponse struct {
	ID      int             `json:"id"`
	Jsonrpc string          `json:"jsonrpc"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   APIError        `json:"error,omitempty"`
}

type APIRequest added in v0.2.3

type APIRequest struct {
	ID      int           `json:"id"`
	Jsonrpc string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
}

func (*APIRequest) ToJSON added in v0.2.3

func (ar *APIRequest) ToJSON() ([]byte, error)

type AlchemyEstimateGasCostResponse added in v0.2.3

type AlchemyEstimateGasCostResponse struct {
	PreVerificationGas   string `json:"preVerificationGas"`
	CallGasLimit         string `json:"callGasLimit"`
	VerificationGasLimit string `json:"verificationGasLimit"`
}

type AlchemyGasAndPaymasterDataResult added in v0.2.3

type AlchemyGasAndPaymasterDataResult struct {
	PaymasterAndData     string `json:"paymasterAndData"`
	CallGasLimit         string `json:"callGasLimit"`
	VerificationGasLimit string `json:"verificationGasLimit"`
	MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas"`
	MaxFeePerGas         string `json:"maxFeePerGas"`
	PreVerificationGas   string `json:"preVerificationGas"`
}

func Alchemy_requestGasAndPaymasterAndData added in v0.2.3

func Alchemy_requestGasAndPaymasterAndData(url, key, policyID, entrypoint, dummysignature string,
	usop userop.UserOperation, overrides *AlchemyOverrides) (*AlchemyGasAndPaymasterDataResult, error)

type AlchemyOverrideMultiplier added in v0.2.3

type AlchemyOverrideMultiplier struct {
	Multiplier float64 `json:"multiplier"`
}

type AlchemyOverrides added in v0.2.3

type AlchemyOverrides struct {
	/*
			{
		  "maxFeePerGas": "hex string" | { "multiplier": number },
		  "maxPriorityFeePerGas": "hex string" | { "multiplier": number },
		  "callGasLimit": "hex string" | { "multiplier": number },
		  "verificationGasLimit": "hex string" | { "multiplier": number },
		  "preVerificationGas": "hex string" | { "multiplier": number },
		}
	*/
	MaxFeePerGas         interface{} `json:"maxFeePerGas"`
	MaxPriorityFeePerGas interface{} `json:"maxPriorityFeePerGas"`
	CallGasLimit         interface{} `json:"callGasLimit"`
	VerificationGasLimit interface{} `json:"verificationGasLimit"`
	PreVerificationGas   interface{} `json:"preVerificationGas"`
}

type AlchemyPMContext added in v0.2.3

type AlchemyPMContext struct {
	PolicyId string `json:"policyId"`
}

type AlchemyReqGasAndPMandDataParams added in v0.2.3

type AlchemyReqGasAndPMandDataParams struct {
	PolicyId       string                 `json:"policyId"`
	EntryPoint     string                 `json:"entryPoint"`
	DummySignature string                 `json:"dummySignature"`
	UserOperation  *userop.UserOpForApiV6 `json:"userOperation"`
	Overrides      *AlchemyOverrides      `json:"overrides"`
}

type AlchemyReqPMandDatParams added in v0.2.3

type AlchemyReqPMandDatParams struct {
	PolicyId      string                 `json:"policyId"`
	EntryPoint    string                 `json:"entryPoint"`
	UserOperation *userop.UserOpForApiV6 `json:"userOperation"`
}

type AlchemyV7UserOp added in v0.2.3

type AlchemyV7UserOp struct {
	Sender                        string `json:"sender"`
	Nonce                         string `json:"nonce"`
	Factory                       string `json:"factory"`
	FactoryData                   string `json:"factoryData"`
	CallData                      string `json:"callData"`
	CallGasLimit                  string `json:"callGasLimit"`
	VerificationGasLimit          string `json:"verificationGasLimit"`
	PreVerificationGas            string `json:"preVerificationGas"`
	MaxFeePerGas                  string `json:"maxFeePerGas"`
	MaxPriorityFeePerGas          string `json:"maxPriorityFeePerGas"`
	PaymasterVerificationGasLimit string `json:"paymasterVerificationGasLimit"`
	PaymasterPostOpGasLimit       string `json:"paymasterPostOpGasLimit"`
	Signature                     string `json:"signature"`
	Paymaster                     string `json:"paymaster"`
	PaymasterData                 string `json:"paymasterData"`
}

type BiconomyPMContext added in v0.2.3

type BiconomyPMContext struct {
	Mode               string `json:"mode"`
	CalculateGasLimits bool   `json:"calculateGasLimits"`
	ExpiryDuration     int    `json:"expiryDuration"`
	SponsorshipInfo    struct {
		WebhookData struct {
		} `json:"webhookData"`
		SmartAccountInfo struct {
			Name    string `json:"name"`
			Version string `json:"version"`
		} `json:"smartAccountInfo"`
	} `json:"sponsorshipInfo"`
}

type EthEstimateUserOperationGasResult added in v0.2.3

type EthEstimateUserOperationGasResult struct {
	CallGasLimit         uint64 `json:"callGasLimit"`
	VerificationGasLimit uint64 `json:"verificationGasLimit"`
	PreVerificationGas   uint64 `json:"preVerificationGas"`
	ValidUntil           string `json:"validUntil"`
	ValidAfter           string `json:"validAfter"`
	MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas"`
	MaxFeePerGas         string `json:"maxFeePerGas"`
}

func Eth_estimateUserOperationGas added in v0.2.3

func Eth_estimateUserOperationGas(url, key string, usop *userop.UserOperation, entrypoint string, entrypointVersion int, provider string) (*EthEstimateUserOperationGasResult, error)

type GetUserOperationByHashResponse_Alchemy added in v0.2.3

type GetUserOperationByHashResponse_Alchemy struct {
	UserOperation struct {
		Sender               string `json:"sender"`
		Nonce                string `json:"nonce"`
		InitCode             string `json:"initCode"`
		CallData             string `json:"callData"`
		CallGasLimit         string `json:"callGasLimit"`
		VerificationGasLimit string `json:"verificationGasLimit"`
		PreVerificationGas   string `json:"preVerificationGas"`
		MaxFeePerGas         string `json:"maxFeePerGas"`
		MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas"`
		PaymasterAndData     string `json:"paymasterAndData"`
		Signature            string `json:"signature"`
	} `json:"userOperation"`
	EntryPoint      string `json:"entryPoint"`
	BlockNumber     string `json:"blockNumber"`
	BlockHash       string `json:"blockHash"`
	TransactionHash string `json:"transactionHash"`
}

func GetUserOperationByHash added in v0.2.3

func GetUserOperationByHash(url, key, hash string) (res *GetUserOperationByHashResponse_Alchemy, err error)

type KeyContainer

type KeyContainer interface {
	GetKey() *ecdsa.PrivateKey
}

type PMandDataResult added in v0.2.3

type PMandDataResult struct {
	PaymasterAndData string `json:"paymasterAndData"`
}

func Alchemy_requestPaymasterAndData added in v0.2.3

func Alchemy_requestPaymasterAndData(url, key, policyID, entrypoint string,
	usop userop.UserOperation) (*PMandDataResult, error)

func PM_getPaymasterData added in v0.2.3

func PM_getPaymasterData(url, key string, usop *userop.UserOperation, context interface{}, entrypoint string,
	chainId interface{}, provider string) (*PMandDataResult, error)

type PimlicoPMTokenContext added in v0.2.3

type PimlicoPMTokenContext struct {
	Token string `json:"token"`
}

type StackUpPMPayGResult added in v0.2.3

type StackUpPMPayGResult struct {
	PaymasterAndData     string `json:"paymasterAndData"`
	PreVerificationGas   string `json:"preVerificationGas"`
	VerificationGasLimit string `json:"verificationGasLimit"`
	CallGasLimit         string `json:"callGasLimit"`
}

func StackUpPMPayCall added in v0.2.3

func StackUpPMPayCall(url, key string, usop *userop.UserOpForApiV6) (*StackUpPMPayGResult, error)

type SupportedEntryPointsResult added in v0.2.3

type SupportedEntryPointsResult []string

func SupportedEntryPoints added in v0.2.3

func SupportedEntryPoints(url, key string) (res *SupportedEntryPointsResult, err error)

type UserOperationReceipt_Alchemy added in v0.2.3

type UserOperationReceipt_Alchemy struct {
	UserOpHash    string `json:"userOpHash"`
	EntryPoint    string `json:"entryPoint"`
	Sender        string `json:"sender"`
	Nonce         string `json:"nonce"`
	Paymaster     string `json:"paymaster"`
	ActualGasCost string `json:"actualGasCost"`
	ActualGasUsed string `json:"actualGasUsed"`
	Success       bool   `json:"success"`
	Reason        string `json:"reason"`
	Logs          []struct {
		Address          string   `json:"address"`
		Topics           []string `json:"topics"`
		Data             string   `json:"data"`
		BlockHash        string   `json:"blockHash"`
		BlockNumber      string   `json:"blockNumber"`
		TransactionHash  string   `json:"transactionHash"`
		TransactionIndex string   `json:"transactionIndex"`
		LogIndex         string   `json:"logIndex"`
		Removed          bool     `json:"removed"`
	} `json:"logs"`
	Receipt struct {
		TransactionHash   string      `json:"transactionHash"`
		TransactionIndex  string      `json:"transactionIndex"`
		BlockHash         string      `json:"blockHash"`
		BlockNumber       string      `json:"blockNumber"`
		From              string      `json:"from"`
		To                string      `json:"to"`
		CumulativeGasUsed string      `json:"cumulativeGasUsed"`
		GasUsed           string      `json:"gasUsed"`
		ContractAddress   interface{} `json:"contractAddress"`
		Logs              []struct {
			Address          string   `json:"address"`
			Topics           []string `json:"topics"`
			Data             string   `json:"data"`
			BlockHash        string   `json:"blockHash"`
			BlockNumber      string   `json:"blockNumber"`
			TransactionHash  string   `json:"transactionHash"`
			TransactionIndex string   `json:"transactionIndex"`
			LogIndex         string   `json:"logIndex"`
			Removed          bool     `json:"removed"`
		} `json:"logs"`
		Status            string `json:"status"`
		LogsBloom         string `json:"logsBloom"`
		Type              string `json:"type"`
		EffectiveGasPrice string `json:"effectiveGasPrice"`
	} `json:"receipt"`
}

type UserOperationReceipt_Biconomy added in v0.2.3

type UserOperationReceipt_Biconomy struct {
	UserOpHash    string `json:"userOpHash"`
	EntryPoint    string `json:"entryPoint"`
	Sender        string `json:"sender"`
	Nonce         int    `json:"nonce"`
	Success       string `json:"success"`
	Paymaster     string `json:"paymaster"`
	ActualGasCost int64  `json:"actualGasCost"`
	ActualGasUsed int    `json:"actualGasUsed"`
	Reason        string `json:"reason"`
	Logs          []struct {
		Address          string   `json:"address"`
		Topics           []string `json:"topics"`
		Data             string   `json:"data"`
		BlockNumber      string   `json:"blockNumber"`
		TransactionHash  string   `json:"transactionHash"`
		TransactionIndex string   `json:"transactionIndex"`
		BlockHash        string   `json:"blockHash"`
		LogIndex         string   `json:"logIndex"`
		Removed          bool     `json:"removed"`
	} `json:"logs"`
	Receipt struct {
		BlockHash         string      `json:"blockHash"`
		BlockNumber       string      `json:"blockNumber"`
		ContractAddress   interface{} `json:"contractAddress"`
		CumulativeGasUsed string      `json:"cumulativeGasUsed"`
		EffectiveGasPrice string      `json:"effectiveGasPrice"`
		From              string      `json:"from"`
		GasUsed           string      `json:"gasUsed"`
		Logs              []struct {
			Address          string   `json:"address"`
			Topics           []string `json:"topics"`
			Data             string   `json:"data"`
			BlockNumber      string   `json:"blockNumber"`
			TransactionHash  string   `json:"transactionHash"`
			TransactionIndex string   `json:"transactionIndex"`
			BlockHash        string   `json:"blockHash"`
			LogIndex         string   `json:"logIndex"`
			Removed          bool     `json:"removed"`
		} `json:"logs"`
		LogsBloom        string `json:"logsBloom"`
		Status           string `json:"status"`
		To               string `json:"to"`
		TransactionHash  string `json:"transactionHash"`
		TransactionIndex string `json:"transactionIndex"`
		Type             string `json:"type"`
	} `json:"receipt"`
}

type UserOperationReceipt_Pimlico added in v0.2.3

type UserOperationReceipt_Pimlico struct {
	UserOpHash    string `json:"userOpHash"`
	EntryPoint    string `json:"entryPoint"`
	Sender        string `json:"sender"`
	Nonce         string `json:"nonce"`
	Paymaster     string `json:"paymaster"`
	ActualGasUsed string `json:"actualGasUsed"`
	ActualGasCost string `json:"actualGasCost"`
	Success       bool   `json:"success"`
	Logs          []struct {
		LogIndex         string   `json:"logIndex"`
		TransactionIndex string   `json:"transactionIndex"`
		TransactionHash  string   `json:"transactionHash"`
		BlockHash        string   `json:"blockHash"`
		BlockNumber      string   `json:"blockNumber"`
		Address          string   `json:"address"`
		Data             string   `json:"data"`
		Topics           []string `json:"topics"`
	} `json:"logs"`
	Receipt struct {
		TransactionHash   string      `json:"transactionHash"`
		TransactionIndex  string      `json:"transactionIndex"`
		BlockHash         string      `json:"blockHash"`
		BlockNumber       string      `json:"blockNumber"`
		From              string      `json:"from"`
		To                string      `json:"to"`
		CumulativeGasUsed string      `json:"cumulativeGasUsed"`
		GasUsed           string      `json:"gasUsed"`
		ContractAddress   interface{} `json:"contractAddress"`
		Logs              []struct {
			LogIndex         string   `json:"logIndex"`
			TransactionIndex string   `json:"transactionIndex"`
			TransactionHash  string   `json:"transactionHash"`
			BlockHash        string   `json:"blockHash"`
			BlockNumber      string   `json:"blockNumber"`
			Address          string   `json:"address"`
			Data             string   `json:"data"`
			Topics           []string `json:"topics"`
		} `json:"logs"`
		LogsBloom         string `json:"logsBloom"`
		Status            string `json:"status"`
		EffectiveGasPrice string `json:"effectiveGasPrice"`
	} `json:"receipt"`
}

type UserOperationReceipt_StackUp added in v0.2.3

type UserOperationReceipt_StackUp struct {
	UserOpHash    string `json:"userOpHash"`
	Sender        string `json:"sender"`
	Paymaster     string `json:"paymaster"`
	Nonce         string `json:"nonce"`
	Success       bool   `json:"success"`
	ActualGasCost string `json:"actualGasCost"`
	ActualGasUsed string `json:"actualGasUsed"`
	From          string `json:"from"`
	Receipt       struct {
		BlockHash         string `json:"blockHash"`
		BlockNumber       string `json:"blockNumber"`
		From              string `json:"from"`
		CumulativeGasUsed string `json:"cumulativeGasUsed"`
		GasUsed           string `json:"gasUsed"`
		Logs              []struct {
			Address          string   `json:"address"`
			Topics           []string `json:"topics"`
			Data             string   `json:"data"`
			BlockNumber      string   `json:"blockNumber"`
			TransactionHash  string   `json:"transactionHash"`
			TransactionIndex string   `json:"transactionIndex"`
			BlockHash        string   `json:"blockHash"`
			LogIndex         string   `json:"logIndex"`
			Removed          bool     `json:"removed"`
		} `json:"logs"`
		LogsBloom         string `json:"logsBloom"`
		TransactionHash   string `json:"transactionHash"`
		TransactionIndex  string `json:"transactionIndex"`
		EffectiveGasPrice string `json:"effectiveGasPrice"`
	} `json:"receipt"`
	Logs []struct {
		Address          string   `json:"address"`
		Topics           []string `json:"topics"`
		Data             string   `json:"data"`
		BlockNumber      string   `json:"blockNumber"`
		TransactionHash  string   `json:"transactionHash"`
		TransactionIndex string   `json:"transactionIndex"`
		BlockHash        string   `json:"blockHash"`
		LogIndex         string   `json:"logIndex"`
		Removed          bool     `json:"removed"`
	} `json:"logs"`
}

func UserOperationReceipt added in v0.2.3

func UserOperationReceipt(url, key string, userOpHash string) (uorec *UserOperationReceipt_StackUp, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL