alchemysdk

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 14 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateRequestAndSign

func CreateRequestAndSign(callData []byte, rgap JSONRPCResponseGasAndPaymaster, chainID int64, entryPointAddr common.Address, sender common.Address, senderScw common.Address, nonce uint64, id int, myPK string, factoryAddr common.Address, appendEntryPoint bool) ([]byte, error)

creates a JSONRPCRequest with "eth_sendUserOperation" formatted data

func CreateRequestGetUserOperationByHash

func CreateRequestGetUserOperationByHash(operationHash string, id int) ([]byte, error)

TODO: test

func CreateRequestGetUserOperationReceipt

func CreateRequestGetUserOperationReceipt(operationHash string, id int) ([]byte, error)

creates a JSONRPCRequest with "eth_getUserOperationReceipt" formatted data

func CreateRequestStep2

func CreateRequestStep2(alchemyRequestId int, signedByUserData []byte, uo UserOperation, entryPointAddr common.Address) ([]byte, error)

adds signature to UserOperation and creates final JSONRPCRequest that can be sent with 'SendRequest'

func DecodeResponseSendRequest

func DecodeResponseSendRequest(response []byte) (opHash string, err error)

func SendRequest

func SendRequest(apiKey string, jsonDATA []byte) ([]byte, error)

can be used to send any type of request to Alchemy

Types

type EntryPointAddress

type EntryPointAddress interface{}

type GasAndPaymentStruct

type GasAndPaymentStruct struct {
	PolicyID       string        `json:"policyId"`
	EntryPoint     string        `json:"entryPoint"`
	UserOperation  UserOperation `json:"userOperation"`
	DummySignature string        `json:"dummySignature"`
}

type JSONRPCRequest

type JSONRPCRequest struct {
	ID      int             `json:"id"`
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  []UserOperation `json:"params"`
}

type JSONRPCRequestGasAndPaymaster

type JSONRPCRequestGasAndPaymaster struct {
	ID      int                   `json:"id"`
	JSONRPC string                `json:"jsonrpc"`
	Method  string                `json:"method"`
	Params  []GasAndPaymentStruct `json:"params"`
}

func CreateRequestGasAndPaymasterData

func CreateRequestGasAndPaymasterData(callData []byte, sender common.Address, senderScw common.Address, nonce uint64, policyID string, entryPointAddr common.Address, factoryAddr common.Address, id int) (JSONRPCRequestGasAndPaymaster, error)

if factoryAddr is non-null -> will set init code should create a GasAndPaymentStruct

type JSONRPCRequestGetUserOperationReceipt

type JSONRPCRequestGetUserOperationReceipt struct {
	ID      int      `json:"id"`
	JSONRPC string   `json:"jsonrpc"`
	Method  string   `json:"method"`
	Hashes  []string `json:"params"`
}

type JSONRPCResponseGasAndPaymaster

type JSONRPCResponseGasAndPaymaster struct {
	ID      int    `json:"id"`
	JSONRPC string `json:"jsonrpc"`

	Error struct {
		Code    int    `json:"code,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"error,omitempty"`

	Result struct {
		PreVerificationGas   string `json:"preVerificationGas,omitempty"`
		CallGasLimit         string `json:"callGasLimit,omitempty"`
		VerificationGasLimit string `json:"verificationGasLimit,omitempty"`
		PaymasterAndData     string `json:"paymasterAndData,omitempty"`
		MaxFeePerGas         string `json:"maxFeePerGas,omitempty"`
		MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas,omitempty"`
	} `json:"result"`
}

type JSONRPCResponseGetOp

type JSONRPCResponseGetOp struct {
	ID      int    `json:"id"`
	JSONRPC string `json:"jsonrpc"`

	Error struct {
		Code    int    `json:"code,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"error,omitempty"`

	Result struct {
		UserOpHash string `json:"userOpHash,omitempty"`
		Success    bool   `json:"success,omitempty"`
	} `json:"result"`
}

func DecodeResponseGetUserOperationReceipt

func DecodeResponseGetUserOperationReceipt(response []byte) (ret *JSONRPCResponseGetOp, err error)

type JSONRPCResponseGetUserOpByHash

type JSONRPCResponseGetUserOpByHash struct {
	ID      int    `json:"id"`
	JSONRPC string `json:"jsonrpc"`

	Error struct {
		Code    int    `json:"code,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"error,omitempty"`

	Result struct {
		UserOperation   string `json:"userOperation,omitempty"`
		BlockNumber     string `json:"blockNumber,omitempty"`
		BlockHash       string `json:"blockNumber,omitempty"`
		TransactionHash string `json:"blockNumber,omitempty"`
	} `json:"result"`
}

func DecodeResponseGetUserOperationByHash

func DecodeResponseGetUserOperationByHash(response []byte) (ret *JSONRPCResponseGetUserOpByHash, err error)

TODO: test

type JSONRPCResponseUserOpHash

type JSONRPCResponseUserOpHash struct {
	ID      int    `json:"id"`
	JSONRPC string `json:"jsonrpc"`

	Error struct {
		Code    int    `json:"code,omitempty"`
		Message string `json:"message,omitempty"`
	} `json:"error,omitempty"`

	Result string `json:"result"`
}

type UserOperation

type UserOperation struct {
	Sender               string `json:"sender,omitempty"`
	Nonce                string `json:"nonce,omitempty"`
	InitCode             string `json:"initCode,omitempty"`
	CallData             string `json:"callData,omitempty"`
	Signature            string `json:"signature,omitempty"`
	CallGasLimit         string `json:"callGasLimit,omitempty"`
	VerificationGasLimit string `json:"verificationGasLimit,omitempty"`
	PreVerificationGas   string `json:"preVerificationGas,omitempty"`
	MaxFeePerGas         string `json:"maxFeePerGas,omitempty"`
	MaxPriorityFeePerGas string `json:"maxPriorityFeePerGas,omitempty"`
	PaymasterAndData     string `json:"paymasterAndData,omitempty"`
}

func CreateRequestStep1

func CreateRequestStep1(callData []byte, rgap JSONRPCResponseGasAndPaymaster, chainID int64, entryPointAddr common.Address, sender common.Address, nonce uint64) (dataToSign []byte, uo UserOperation, err error)

creates a UserOperation and data to sign with user's private key

Jump to

Keyboard shortcuts

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