metax

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: May 30, 2023 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaAPIURL                 = "https://api.biconomy.io/api/v1/meta-api"
	MetaTxNativeURL            = "https://api.biconomy.io/api/v2/meta-tx/native"
	CreateDappPublicURL        = "https://api.biconomy.io/api/v1/dapp/public-api/create-dapp"
	AddContractURL             = "https://api.biconomy.io/api/v1/smart-contract/public-api/addContract"
	AddMethodURL               = "https://api.biconomy.io/api/v1/meta-api/public-api/addMethod"
	DeleteContractURL          = "https://api.biconomy.io/api/v1/smart-contract/public-api/deleteContract"
	DeleteMethodURL            = "https://api.biconomy.io/api/v1/meta-api/public-api/deleteMethod"
	AddDestinationAddressesURL = "https://api.biconomy.io/api/v1/dapp/whitelist/destination"
	ProxyContractsURL          = "https://api.biconomy.io/api/v1/dapp/whitelist/proxy-contracts"
	UniqueUserDataURL          = "https://data.biconomy.io/api/v1/dapp/uniqueUserData"
	UserLimitURL               = "https://data.biconomy.io/api/v1/dapp/user-limit"
	GasTankBalanceURL          = "https://data.biconomy.io/api/v1/dapp/gas-tank-balance"
	CheckLimitURL              = "https://api.biconomy.io/api/v1/dapp/checkLimits"

	// backend
	BackendLoginURL = "https://dashboard-backend.prod.biconomy.io/api/v1/user/login"
	BackendDappURL  = "https://dashboard-backend.prod.biconomy.io/api/v1/dapp"

	// v1 sdk
	MetaTxNativeURLV1        = "https://gasless-meta.prod.biconomy.io/api/v1/native"
	MetaTransactionStatusURL = "https://gasless-meta.prod.biconomy.io/api/v1/sdk/transaction-status"
)
View Source
const (
	SignatureEIP712Type = "EIP712_SIGN"
	EIP712DomainType    = "EIP712Domain"
	ForwardRequestType  = "ERC20ForwardRequest"
	ForwardRequestName  = "Biconomy Forwarder"
	Version             = "1"
)
View Source
const (
	PACKAGE_VERSION = "3.0.4"
)

Variables

View Source
var ForwarderAddressMap = map[string]common.Address{
	"1":      common.HexToAddress("0x84a0856b038eaAd1cC7E297cF34A7e72685A8693"),
	"3":      common.HexToAddress("0x3D1D6A62c588C1Ee23365AF623bdF306Eb47217A"),
	"4":      common.HexToAddress("0xFD4973FeB2031D4409fB57afEE5dF2051b171104"),
	"5":      common.HexToAddress("0xE041608922d06a4F26C0d4c27d8bCD01daf1f792"),
	"42":     common.HexToAddress("0xF82986F574803dfFd9609BE8b9c7B92f63a1410E"),
	"56":     common.HexToAddress("0x86C80a8aa58e0A4fa09A69624c31Ab2a6CAD56b8"),
	"97":     common.HexToAddress("0x61456BF1715C1415730076BB79ae118E806E74d2"),
	"100":    common.HexToAddress("0x86C80a8aa58e0A4fa09A69624c31Ab2a6CAD56b8"),
	"137":    common.HexToAddress("0xf0511f123164602042ab2bCF02111fA5D3Fe97CD"),
	"250":    common.HexToAddress("0x64CD353384109423a966dCd3Aa30D884C9b2E057"),
	"1287":   common.HexToAddress("0x3AF14449e18f2c3677bFCB5F954Dc68d5fb74a75"),
	"4002":   common.HexToAddress("0x69FB8Dca8067A5D38703b9e8b39cf2D51473E4b4"),
	"80001":  common.HexToAddress("0x69015912AA33720b842dCD6aC059Ed623F28d9f7"),
	"42161":  common.HexToAddress("0xfe0fa3C06d03bDC7fb49c892BbB39113B534fB57"),
	"421611": common.HexToAddress("0x67454E169d613a8e9BA6b06af2D267696EAaAf41"),
}
View Source
var SignedTypes = apitypes.Types{
	"EIP712Domain": []apitypes.Type{
		{Name: "name", Type: "string"},
		{Name: "version", Type: "string"},
		{Name: "verifyingContract", Type: "address"},
		{Name: "salt", Type: "bytes32"},
	},
	"ERC20ForwardRequest": []apitypes.Type{
		{Name: "from", Type: "address"},
		{Name: "to", Type: "address"},
		{Name: "token", Type: "address"},
		{Name: "txGas", Type: "uint256"},
		{Name: "tokenGasPrice", Type: "uint256"},
		{Name: "batchId", Type: "uint256"},
		{Name: "batchNonce", Type: "uint256"},
		{Name: "deadline", Type: "uint256"},
		{Name: "data", Type: "bytes"},
	},
}

Functions

func ConvertToJsonStr added in v0.0.17

func ConvertToJsonStr(obj interface{}) string

func GetDomainSeparator added in v0.0.19

func GetDomainSeparator(forwarderAddress common.Address, chainId *big.Int) (common.Hash, error)

func WaitMined added in v0.0.15

func WaitMined(ctx context.Context, b bind.DeployBackend, txHash common.Hash) (*types.Receipt, error)

WaitMined waits for tx to be mined on the blockchain. It stops waiting when the context is canceled.

Types

type AddContractRequest

type AddContractRequest struct {
	ContractName        string `json:"contractName"`
	ContractAddress     string `json:"contractAddress"`
	ContractType        string `json:"contractType"`        // SCW for contract wallet or SC for contract
	WalletType          string `json:"walletType"`          // SCW or GNOSIS or blank
	MetaTransactionType string `json:"metaTransactionType"` // DEFAULT, TRUSTED_FORWARDER, ERC20_FORWARDER
	ABI                 string `json:"abi"`
}

type AddDestinationRequest

type AddDestinationRequest struct {
	DestinationAddresses []string `json:"destinationAddresses"`
}

type AddDestinationResponse

type AddDestinationResponse struct {
	Code               int      `json:"code"`
	Message            string   `json:"message"`
	RegisteredCount    int      `json:"registeredCount"`
	DuplicateContracts []string `json:"duplicateContracts"`
	InvalidContracts   []string `json:"invalidContracts"`
}

type AddMethodRequest

type AddMethodRequest struct {
	ApiType         string `json:"apiType"`
	MethodType      string `json:"methodType"`
	Name            string `json:"name"`
	ContractAddress string `json:"contractAddress"`
	Method          string `json:"method"`
}

type AddMethodResponse

type AddMethodResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	ApiIds  []struct {
		ApiId  string `json:"apiId"`
		Method string `json:"method"`
		Name   string `json:"name"`
	} `json:"apiIds"`
}

type AddProxyContractsRequest

type AddProxyContractsRequest struct {
	Addresses []string `json:"addresses"`
}

type Bcnmy

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

func NewBcnmy

func NewBcnmy(httpRpc string, apiKey string, timeout time.Duration) (*Bcnmy, error)

func (*Bcnmy) AddContract

func (b *Bcnmy) AddContract(data *AddContractRequest) (*GeneralResponse, error)

func (*Bcnmy) AddDestinationAddresses

func (b *Bcnmy) AddDestinationAddresses(data *AddDestinationRequest) (*AddDestinationResponse, error)

func (*Bcnmy) AddMethod

func (b *Bcnmy) AddMethod(data *AddMethodRequest) (*AddMethodResponse, error)

func (*Bcnmy) AddProxyContracts

func (b *Bcnmy) AddProxyContracts(data *AddProxyContractsRequest) (*ProxyContractsResponse, error)

func (*Bcnmy) BackendDappList added in v0.0.10

func (b *Bcnmy) BackendDappList() (*DappResponse, error)

func (*Bcnmy) BackendLogin added in v0.0.10

func (b *Bcnmy) BackendLogin() (*LoginResponse, error)

func (*Bcnmy) BuildTransactParams added in v0.0.5

func (b *Bcnmy) BuildTransactParams(metaTxMessage *MetaTxMessage, typedDataHash string) ([]byte, error)

func (*Bcnmy) CheckLimits added in v0.0.10

func (b *Bcnmy) CheckLimits(from string, method string) (*CheckLimitResponse, error)

func (*Bcnmy) CreateDapp

func (b *Bcnmy) CreateDapp(data *CreateDappRequest) (*CreateDappResponse, error)

func (*Bcnmy) DeleteContract

func (b *Bcnmy) DeleteContract(data *DeleteContractRequest) (*GeneralResponse, error)

func (*Bcnmy) DeleteMethod

func (b *Bcnmy) DeleteMethod(data *DeleteMethodRequest) (*GeneralResponse, error)

func (*Bcnmy) EnhanceTransact

func (b *Bcnmy) EnhanceTransact(from string, method string, signature []byte, metaTxMessage *MetaTxMessage, typedDataHash string) (*MetaTxResponse, *types.Transaction, *types.Receipt, error)

/ Backend using this method, handle frontend passing signature, MetaTxMessage and / ForwardRequestType data Hash value

func (*Bcnmy) GetAuthorization

func (b *Bcnmy) GetAuthorization() string

func (*Bcnmy) GetBackendDapps added in v0.0.10

func (b *Bcnmy) GetBackendDapps() (*DappResponse, error)

func (*Bcnmy) GetGasTankEffectiveBalance added in v0.0.11

func (b *Bcnmy) GetGasTankEffectiveBalance() (*big.Int, error)

func (*Bcnmy) GetMetaAPI

func (b *Bcnmy) GetMetaAPI(ctx context.Context) (*MetaAPIResponse, error)

func (*Bcnmy) GetProxyContracts

func (b *Bcnmy) GetProxyContracts() (*GetProxyContractsResponse, error)

func (*Bcnmy) GetTransactionStatus added in v0.0.18

func (b *Bcnmy) GetTransactionStatus(transactionId string) (*BiconomyTransaction, error)

func (*Bcnmy) GetUniqueUserData

func (b *Bcnmy) GetUniqueUserData(data *UniqueUserDataRequest) (*UniqueUserDataResponse, error)

func (*Bcnmy) GetUserLimit

func (b *Bcnmy) GetUserLimit(data *UserLimitRequest) (*UserLimitResponse, error)

func (*Bcnmy) Pack

func (b *Bcnmy) Pack(method string, params ...interface{}) ([]byte, error)

func (*Bcnmy) PatchProxyContracts

func (b *Bcnmy) PatchProxyContracts(data *PatchProxyContractsRequest) (*ProxyContractsResponse, error)

func (*Bcnmy) RawTransact

func (b *Bcnmy) RawTransact(signer *Signer, method string, params ...interface{}) (*MetaTxResponse, *types.Transaction, *types.Receipt, error)

func (*Bcnmy) SendMetaNativeTx

func (b *Bcnmy) SendMetaNativeTx(data *MetaTxRequest) (*MetaTxResponse, error)

func (*Bcnmy) SendMetaNativeTxV1 added in v0.0.18

func (b *Bcnmy) SendMetaNativeTxV1(data *MetaTxRequest) (*MetaTxResponse, error)

func (*Bcnmy) WithAuthToken

func (b *Bcnmy) WithAuthToken(authToken string) *Bcnmy

func (*Bcnmy) WithBackend added in v0.0.10

func (b *Bcnmy) WithBackend(email string, password string, timeout time.Duration) error

func (*Bcnmy) WithDapp

func (b *Bcnmy) WithDapp(jsonABI string, dappAddress common.Address) (*Bcnmy, error)

func (*Bcnmy) WithFieldTimeout added in v0.0.2

func (b *Bcnmy) WithFieldTimeout(timeout time.Duration) *Bcnmy

func (*Bcnmy) WithSleepTimeSec added in v0.0.15

func (b *Bcnmy) WithSleepTimeSec(sleepTimeSec int64) *Bcnmy

type BiconomyTransaction added in v0.0.18

type BiconomyTransaction struct {
	Flag int    `json:"flag"`
	Log  string `json:"log"`
	Code int    `json:"code"`
	Data struct {
		Status  string `json:"status"`
		Receipt struct {
			TxHash string `json:"transactionHash"`
		} `json:"receipt"`
	} `json:"data"`
}

type CheckLimitResponse added in v0.0.10

type CheckLimitResponse struct {
	Code         int       `json:"code"`
	Message      string    `json:"message"`
	ResponseCode int       `json:"responseCode"`
	Allowed      bool      `json:"allowed"`
	Limit        LimitInfo `json:"limit"`
}

https://docs-gasless.biconomy.io/api/check-limits code

200
150	when DApp limits are exhausted
151	when User limits are exhausted
152	when API/User limits are exhausted

limit.type

0	the limit was applied on gas usage
1	the limit was applied on the number of meta transaction

type CreateDappRequest

type CreateDappRequest struct {
	DappName             string `json:"dappName"`
	NetworkId            string `json:"networkId"`
	EnableBiconomyWallet bool   `json:"enableBiconomyWallet"`
}

type CreateDappResponse

type CreateDappResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
	Data    struct {
		ApiKey     string   `json:"apiKey"`
		FundingKey *big.Int `json:"fundingKey"`
	} `json:"data"`
}

type Dapp added in v0.0.10

type Dapp struct {
	APIKey                    string    `json:"apiKey"`
	FundingKey                int       `json:"fundingKey"`
	NetworkId                 string    `json:"networkId"`
	DappName                  string    `json:"dappName"`
	DappLimit                 DappLimit `json:"dappLimit"`
	DappLimitStatus           int       `json:"dappLimitStatus"`
	UserLimit                 DappLimit `json:"userLimit"`
	UserLimitStatus           int       `json:"userLimitStatus"`
	ApiLimit                  DappLimit `json:"apiLimit"`
	ApiLimitStatus            int       `json:"apiLimitStatus"`
	GasTankBalance            float64   `json:"gasTankBalance"`
	EffectiveBalance          *big.Int  `json:"effectiveBalance"`
	TransactionCountThisMonth int       `json:"transactionCountThisMonth"`
	TransactionCountInTotal   int       `json:"transactionCountInTotal"`
}

type DappLimit added in v0.0.10

type DappLimit struct {
	Type              int     `json:"type"`
	Value             float32 `json:"value"`
	DurationValue     float32 `json:"durationValue"`
	DurationUnit      string  `json:"durationUnit"`
	LimitStartTime    int64   `json:"limitStartTime"`
	LimitDurationInMs int64   `json:"limitDurationInMs"`
}

type DappResponse added in v0.0.10

type DappResponse struct {
	Log  string `json:"log"`
	Code int    `json:"code"`
	Data Data   `json:"data"`
}

type Data added in v0.0.10

type Data struct {
	Dapps []Dapp `json:"dapps"`
}

type DeleteContractRequest

type DeleteContractRequest struct {
	ContractAddress string `json:"contractAddress"`
	ContractType    string `json:"contractType"` // SCW for contract wallet or SC for contract
}

type DeleteMethodRequest

type DeleteMethodRequest struct {
	ContractAddress string `json:"contractAddress"`
	Method          string `json:"method"`
}

type GeneralResponse

type GeneralResponse struct {
	Code         int    `json:"code"`
	Message      string `json:"message"`
	ResponseCode int    `json:"responseCode"`
}

type GetProxyContractsResponse

type GetProxyContractsResponse struct {
	ProxyContractsResponse
	Total     int `json:"total"`
	Addresses []struct {
		Address string `json:"address"`
		Status  bool   `json:"status"`
	} `json:"addresses"`
}

type LimitInfo added in v0.0.10

type LimitInfo struct {
	Allowed   bool    `json:"allowed"`
	Type      int     `json:"type"`
	ResetTime int64   `json:"resetTime"`
	LimitLeft float32 `json:"limitLeft"`
}

type LoginResponse added in v0.0.10

type LoginResponse struct {
	Message string `json:"message"`
}

type MetaAPIInfo

type MetaAPIInfo struct {
	/// need to filter non contractAdress
	ContractAddress   string      `json:"contractAddress"`
	ID                string      `json:"id"`
	Name              string      `json:"name"`
	URL               string      `json:"url"`
	Version           int         `json:"version"`
	Method            string      `json:"method"`
	MethodType        string      `json:"methodType"`
	APIType           string      `json:"apiType"`
	MetaTxLimitStatus int         `json:"metaTxLimitStatus"`
	MetaTxLimit       MetaTxLimit `json:"metaTxLimit"`
}

type MetaAPIResponse

type MetaAPIResponse struct {
	Log     string        `json:"log"`
	Flag    int           `json:"flag"`
	Total   int           `json:"total"`
	ListAPI []MetaAPIInfo `json:"listApis"`
}

type MetaTxLimit

type MetaTxLimit struct {
	Type              int     `json:"type"`
	Value             float32 `json:"value"`
	DurationValue     int     `json:"durationValue"`
	Day               string  `json:"day"`
	LimitStartTime    int64   `json:"limitStartTime"`
	LimitDurationInMs int64   `json:"limitDurationInMs"`
}

type MetaTxMessage

type MetaTxMessage struct {
	From          common.Address `json:"from"`
	To            common.Address `json:"to"`
	Token         common.Address `json:"token"`
	TxGas         uint64         `json:"txGas"`
	TokenGasPrice string         `json:"tokenGasPrice"`
	BatchId       *big.Int       `json:"batchId"`
	BatchNonce    *big.Int       `json:"batchNonce"`
	Deadline      *big.Int       `json:"deadline"`
	Data          string         `json:"data"`
}

func (*MetaTxMessage) TypedData

func (m *MetaTxMessage) TypedData() apitypes.TypedDataMessage

type MetaTxRequest

type MetaTxRequest struct {
	From          string        `json:"from"`
	To            string        `json:"to"`
	ApiID         string        `json:"apiId"`
	Params        []interface{} `json:"params"`
	SignatureType string        `json:"signatureType"`
}

type MetaTxResponse

type MetaTxResponse struct {
	TxHash  common.Hash `json:"txHash"`
	Log     string      `json:"log"`
	Flag    int         `json:"flag"`
	Message string      `json:"message"`
	Error   string      `json:"error"`
	Code    int         `json:"code"`
	Limit   struct {
		Type      int     `json:"type"`
		LimitLeft float32 `json:"limitLeft"`
		ResetTime int64   `json:"resetTime"`
	} `json:"limit"`
	Allowed bool `json:"allowed"`
}

type MetaTxResponseV1 added in v0.0.18

type MetaTxResponseV1 struct {
	Flag int         `json:"flag"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

type MetaTxV1SuccessData added in v0.0.18

type MetaTxV1SuccessData struct {
	TransactionId string `json:"transactionId"`
	ConnectionUrl string `json:"connectionUrl"`
}

type PatchProxyContractsRequest

type PatchProxyContractsRequest struct {
	Status  int    `json:"status"` // 0 => inactive, 1 => active
	Address string `json:"address"`
}

type ProxyContractsResponse

type ProxyContractsResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

type Signer

type Signer struct {
	Address common.Address
	// contains filtered or unexported fields
}

func NewSigner

func NewSigner(privKey string) (*Signer, error)

func NewSignerFromPath

func NewSignerFromPath(privPath string) (*Signer, error)

func (*Signer) GetPublicKey

func (s *Signer) GetPublicKey() []byte

func (*Signer) SignTypedData

func (s *Signer) SignTypedData(typedData apitypes.TypedData) ([]byte, error)

type UniqueUserDataRequest

type UniqueUserDataRequest struct {
	StartDate string `json:"startDate"` /// Format (“MM-DD-YYYY”) example: 21st Jan 2022 would be 01-21-2022
	EndDate   string `json:"endDate"`   /// Format (“MM-DD-YYYY”)
}

type UniqueUserDataResponse

type UniqueUserDataResponse struct {
	GeneralResponse
	UniqueUserData []struct {
		Date      string   `json:"date"`
		Count     int      `json:"count"`
		Addresses []string `json:"addresses"`
	}
}

type UserLimitRequest

type UserLimitRequest struct {
	SignerAddress string `json:"signerAddress"`
	ApiId         string `json:"apiId"`
}

type UserLimitResponse

type UserLimitResponse struct {
	GeneralResponse
	UserLimitData struct {
		LimitLeft struct {
			SignerAddress        string  `json:"signerAddress"`
			TransactionLimitLeft float32 `json:"transactionLimitLeft"`
			TransactionCount     int     `json:"transactionCount"`
			AreLimitsConsumed    bool    `json:"areLimitsConsumed"`
			UserTransactionLimit int     `json:"userTransactionLimit"`
		} `json:"limitLeft"`
		LimitType        string   `json:"limitType"`
		LimitStartTime   *big.Int `json:"limitStartTime"`
		LimitEndTime     *big.Int `json:"limitEndTime"`
		TimePeriodInDays int      `json:"timePeriodInDays"`
	} `json:"userLimitData"`
}

Jump to

Keyboard shortcuts

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