onchain

package
v0.0.5-developer-preview Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproveTokenForRouter

func ApproveTokenForRouter(ctx context.Context, client *ethclient.Client, nonceCache map[string]uint64, config Erc20ApprovalConfig) error

func ConvertSignatureToVRSString

func ConvertSignatureToVRSString(signature string) string

ConvertSignatureToVRSString converts a signature from rsv to padded vrs format

func CreatePermit

func CreatePermit(config *CreatePermitConfig) (string, error)

func CreatePermitParams

func CreatePermitParams(config *PermitParamsConfig) string

func CreatePermitSignature

func CreatePermitSignature(config *PermitSignatureConfig) (string, error)

func ExecuteTransaction

func ExecuteTransaction(ctx context.Context, txConfig TxConfig, ethClient *ethclient.Client, nonceCache map[string]uint64) error

func GetDynamicFeeTx

func GetDynamicFeeTx(client *ethclient.Client, nonce uint64, chainID *big.Int, to string, value *big.Int, data []byte) (*types.Transaction, error)

func GetLegacyTx

func GetLegacyTx(client *ethclient.Client, nonce uint64, to string, value *big.Int, data []byte) (*types.Transaction, error)

func GetNonce

func GetNonce(ethClient *ethclient.Client, key string, publicAddress common.Address, nonceCache map[string]uint64) (uint64, error)

func GetPredicateCalldata

func GetPredicateCalldata(seriesNonceManager string, getTimestampBelowAndNonceEqualsCalldata []byte) ([]byte, error)

func GetTimeSeriesManagerNonce

func GetTimeSeriesManagerNonce(client *ethclient.Client, seriesNonceManager string, publicAddress string) (*big.Int, error)

func GetTimestampBelowAndNonceEqualsCalldata

func GetTimestampBelowAndNonceEqualsCalldata(expiration int64, nonce *big.Int, publicAddress string) ([]byte, error)

func GetTimestampBelowCalldata

func GetTimestampBelowCalldata(expiration int64) ([]byte, error)

func GetTx

func GetTx(client *ethclient.Client, nonce uint64, config TxConfig) (*types.Transaction, error)

func GetTypeHash

func GetTypeHash(client *ethclient.Client, addressAsString string) (string, error)

func ReadContractAllowance

func ReadContractAllowance(client *ethclient.Client, erc20Address common.Address, publicAddress common.Address, spenderAddress common.Address) (*big.Int, error)

ReadContractAllowance reads the allowance a given contract has for a wallet.

func ReadContractDecimals

func ReadContractDecimals(client *ethclient.Client, contractAddress common.Address) (uint8, error)

ReadContractDecimals reads the 'decimals' public variable from a contract.

func ReadContractName

func ReadContractName(client *ethclient.Client, contractAddress common.Address) (string, error)

ReadContractName reads the 'name' public variable from a contract.

func ReadContractNonce

func ReadContractNonce(client *ethclient.Client, publicAddress common.Address, contractAddress common.Address) (int64, error)

ReadContractNonce reads the 'nonces' public variable from a contract.

func ReadContractSymbol

func ReadContractSymbol(client *ethclient.Client, contractAddress common.Address) (string, error)

ReadContractSymbol reads the 'symbol' public variable from a contract.

func ReadContractVersion

func ReadContractVersion(client *ethclient.Client, contractAddress common.Address) (string, error)

func Remove0xPrefix

func Remove0xPrefix(s string) string

func RevokeApprovalForRouter

func RevokeApprovalForRouter(ctx context.Context, client *ethclient.Client, nonceCache map[string]uint64, config Erc20RevokeConfig) error

func ShouldUsePermit

func ShouldUsePermit(ethClient *ethclient.Client, chainId int, srcToken string) bool

func WaitForTransaction

func WaitForTransaction(ctx context.Context, client *ethclient.Client, txHash common.Hash) (*types.Receipt, error)

Types

type ApprovalType

type ApprovalType int
const (
	PermitIfPossible ApprovalType = iota
	PermitAlways
	ApprovalAlways
)

type CreatePermitConfig

type CreatePermitConfig struct {
	EthClient     *ethclient.Client
	MakerAsset    string
	PublicAddress common.Address
	ChainId       int
	PrivateKey    string
	Deadline      int64
}

type Erc20ApprovalConfig

type Erc20ApprovalConfig struct {
	ChainId        int
	Key            string
	Erc20Address   common.Address
	PublicAddress  common.Address
	SpenderAddress common.Address
}

type Erc20RevokeConfig

type Erc20RevokeConfig struct {
	ChainId                 int
	Key                     string
	Erc20Address            common.Address
	PublicAddress           common.Address
	SpenderAddress          common.Address
	AllowanceDecreaseAmount *big.Int
}

type PermitParamsConfig

type PermitParamsConfig struct {
	Owner     string
	Spender   string
	Value     *big.Int
	Deadline  int64
	Signature string
}

type PermitSignatureConfig

type PermitSignatureConfig struct {
	FromToken     string
	Name          string
	Version       string
	PublicAddress string
	ChainId       int
	Key           string
	Nonce         int64
	Deadline      int64
}

type TxConfig

type TxConfig struct {
	Description   string
	PublicAddress common.Address
	PrivateKey    string
	ChainId       *big.Int
	Value         *big.Int
	To            string
	Data          []byte
}

Jump to

Keyboard shortcuts

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