tokentype

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_ABI = "" /* 2257-byte string literal not displayed */
View Source
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000000000000000000000000000"

Variables

View Source
var (
	// Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)
	PERMIT_DAI_LIKE = "0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb"
	// Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)
	PERMIT_COMMON = "0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9"

	PERMIT_DAI_LIKE_TYPES = []apitypes.Type{
		{Name: "holder", Type: "address"},
		{Name: "spender", Type: "address"},
		{Name: "nonce", Type: "uint256"},
		{Name: "expiry", Type: "uint256"},
		{Name: "allowed", Type: "bool"},
	}
	PERMIT_COMMON_TYPES = []apitypes.Type{
		{Name: "owner", Type: "address"},
		{Name: "spender", Type: "address"},
		{Name: "value", Type: "uint256"},
		{Name: "nonce", Type: "uint256"},
		{Name: "deadline", Type: "uint256"},
	}
)

permit types

View Source
var (
	// EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)
	DOMAIN_COMMON = "0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f"
	// EIP712Domain(string name,uint256 chainId,address verifyingContract)
	DOMAIN_UNI_LIKE = "0x8cad95687ba82c2ce50e74f7b754645e5117c3a5bec8151c0726d5857980a866"
	// EIP712Domain(uint256 chainId,address verifyingContract)
	DOMAIN_ONLY_CHAIN = "0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218"
	// EIP712Domain(string name,string version,address verifyingContract,bytes32 salt)
	DOMAIN_SALT_LIKE = "0x36c25de3e541d5d970f66e4210d728721220fff5c077cc6cd008b3a0c62adab7"

	DOMAIN_COMMON_TYPES = []apitypes.Type{
		{Name: "name", Type: "string"},
		{Name: "version", Type: "string"},
		{Name: "chainId", Type: "uint256"},
		{Name: "verifyingContract", Type: "address"},
	}
	DOMAIN_UNI_LIKE_TYPES = []apitypes.Type{
		{Name: "name", Type: "string"},
		{Name: "chainId", Type: "uint256"},
		{Name: "verifyingContract", Type: "address"},
	}
	DOMAIN_ONLY_CHAIN_TYPES = []apitypes.Type{
		{Name: "chainId", Type: "uint256"},
		{Name: "verifyingContract", Type: "address"},
	}
	DOMAIN_SALT_LIKE_TYPES = []apitypes.Type{
		{Name: "name", Type: "string"},
		{Name: "version", Type: "string"},
		{Name: "verifyingContract", Type: "address"},
		{Name: "salt", Type: "bytes32"},
	}
)

domain types

View Source
var APIMap = map[string]string{
	"1":     "https://api.etherscan.io/api",
	"5":     "https://api-goerli.etherscan.io/api",
	"56":    "https://api.bscscan.com/api",
	"97":    "https://api-testnet.bscscan.com/api",
	"137":   "https://api.polygonscan.com/api",
	"80001": "https://api-testnet.polygonscan.com/api",
}

api maps

for request ABI
https://api.etherscan.io/api
   ?module=contract
   &action=getabi
   &address=0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413
   &apikey=YourApiKeyToken

domain maps

View Source
var IMPLEMENTATION_SLOTS = []string{
	"0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc",
	"0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3",
}

Functions

This section is empty.

Types

type APITypedData

type APITypedData struct {
	apitypes.TypedData
}

func (*APITypedData) ConvertTypedData

func (atd *APITypedData) ConvertTypedData() *TypedData

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(httpRpc string) (*Client, error)

func (*Client) NewContract

func (client *Client) NewContract(address string) (*Contract, error)

func (*Client) TokenTypedData

func (c *Client) TokenTypedData(req *PermitMessage) (*TypedData, error)

func (*Client) WithAPIKey

func (c *Client) WithAPIKey(apiKey string)

func (*Client) WithDebug

func (c *Client) WithDebug(isDebug bool)

type Contract

type Contract struct {
	// contains filtered or unexported fields
}

func (*Contract) Address

func (c *Contract) Address() string

func (*Contract) DOMAIN_SEPARATOR

func (c *Contract) DOMAIN_SEPARATOR() (string, error)

func (*Contract) DOMAIN_TYPEHASH

func (c *Contract) DOMAIN_TYPEHASH() (string, error)

func (*Contract) Decimals

func (c *Contract) Decimals() (uint8, error)

func (*Contract) HasMethod

func (c *Contract) HasMethod(method string) bool

func (*Contract) Implementation

func (c *Contract) Implementation() (common.Address, error)

func (*Contract) Name

func (c *Contract) Name() (string, error)

func (*Contract) Nonces

func (c *Contract) Nonces(sender string) (*big.Int, error)

func (*Contract) PERMIT_TYPEHASH

func (c *Contract) PERMIT_TYPEHASH() (string, error)

func (*Contract) Version

func (c *Contract) Version() (string, error)

type ContractABIResp

type ContractABIResp struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  string `json:"result"`
}

type PermitMessage

type PermitMessage struct {
	Token    string
	Owner    string
	Spender  string
	Value    string
	Deadline int64
}

type TokenInfo

type TokenInfo struct {
	DomainTypehash  string
	DomainSeparator string
	PermitTypehash  string
	Name            string
	Version         string
	Nonce           *big.Int
	Token           string
}

type TypedData

type TypedData struct {
	Types       apitypes.Types            `json:"types"`
	PrimaryType string                    `json:"primaryType"`
	Domain      apitypes.TypedDataMessage `json:"domain"`
	Message     apitypes.TypedDataMessage `json:"message"`
}

Jump to

Keyboard shortcuts

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