walletconnect

package
v0.171.31 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2023 License: MPL-2.0 Imports: 21 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SupportedEip155Namespace = "eip155"

	ProposeUserPairEvent = walletevent.EventType("WalletConnectProposeUserPair")
)

Variables

View Source
var (
	ErrorInvalidSessionProposal = errors.New("invalid session proposal")
	ErrorNamespaceNotSupported  = errors.New("namespace not supported")
	ErrorChainsNotSupported     = errors.New("chains not supported")
	ErrorInvalidParamsCount     = errors.New("invalid params count")
	ErrorInvalidAddressMsgIndex = errors.New("invalid address and/or msg index (must be 0 or 1)")
	ErrorMethodNotSupported     = errors.New("method not supported")
)

Functions

func ChangePairingState added in v0.171.25

func ChangePairingState(db *sql.DB, topic Topic, active bool) error

func HasActivePairings

func HasActivePairings(db *sql.DB, expiryNotOlderThanTimestamp int64) (bool, error)

func InsertPairing

func InsertPairing(db *sql.DB, pairing Pairing) error

Types

type JSONProxyType

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

JSONProxyType provides a generic way of changing the JSON value before unmarshalling it into the target. transform function is called before unmarshalling.

func (*JSONProxyType) UnmarshalJSON

func (b *JSONProxyType) UnmarshalJSON(input []byte) error

type Metadata

type Metadata struct {
	Description string   `json:"description"`
	URL         string   `json:"url"`
	Icons       []string `json:"icons"`
	Name        string   `json:"name"`
	VerifyURL   string   `json:"verifyUrl"`
}

type Namespace

type Namespace struct {
	Methods  []string `json:"methods"`
	Chains   []string `json:"chains"` // CAIP-2 format e.g. ["eip155:1"]
	Events   []string `json:"events"`
	Accounts []string `json:"accounts,omitempty"` // CAIP-10 format e.g. ["eip155:1:0x453...228"]
}

func (*Namespace) Valid

func (n *Namespace) Valid(namespaceName string, chainID *uint64) bool

Valid namespace

type PairSessionResponse

type PairSessionResponse struct {
	SessionProposal     SessionProposal      `json:"sessionProposal"`
	SupportedNamespaces map[string]Namespace `json:"supportedNamespaces"`
}

type Pairing

type Pairing struct {
	Topic       Topic    `json:"topic"`
	Expiry      int64    `json:"expiry"`
	Active      bool     `json:"active"`
	AppName     string   `json:"appName"`
	URL         string   `json:"url"`
	Description string   `json:"description"`
	Icon        string   `json:"icon"`
	Verified    Verified `json:"verified"`
}

func GetActivePairings

func GetActivePairings(db *sql.DB, expiryNotOlderThanTimestamp int64) ([]Pairing, error)

GetActivePairings returns all active pairings (active and not expired) that have an expiry timestamp newer or equal to the given timestamp.

func GetPairingByTopic

func GetPairingByTopic(db *sql.DB, topic Topic) (*Pairing, error)

type Params

type Params struct {
	ID                 int64                `json:"id"`
	PairingTopic       Topic                `json:"pairingTopic"`
	Expiry             int64                `json:"expiry"`
	RequiredNamespaces map[string]Namespace `json:"requiredNamespaces"`
	OptionalNamespaces map[string]Namespace `json:"optionalNamespaces"`
	Proposer           Proposer             `json:"proposer"`
	Verify             VerifyContext        `json:"verifyContext"`
}

func (*Params) Valid

func (p *Params) Valid() bool

Valid params

type Proposer

type Proposer struct {
	PublicKey string   `json:"publicKey"`
	Metadata  Metadata `json:"metadata"`
}

type RequestParams

type RequestParams struct {
	Request struct {
		Method string            `json:"method"`
		Params []json.RawMessage `json:"params"`
	} `json:"request"`
	ChainID string `json:"chainId"`
}

type Service

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

func NewService

func NewService(db *sql.DB, networkManager *network.Manager, accountsDB *accounts.Database,
	transactionManager *transfer.TransactionManager, gethManager *account.GethManager, eventFeed *event.Feed,
	config *params.NodeConfig) *Service

func (*Service) AuthRequest added in v0.171.30

func (s *Service) AuthRequest(address common.Address, authMessage string) (*transfer.TxResponse, error)

func (*Service) ChangePairingState added in v0.171.25

func (s *Service) ChangePairingState(topic Topic, active bool) error

func (*Service) HasActivePairings

func (s *Service) HasActivePairings() (bool, error)

func (*Service) PairSessionProposal

func (s *Service) PairSessionProposal(proposal SessionProposal) (*PairSessionResponse, error)

func (*Service) RecordSuccessfulPairing

func (s *Service) RecordSuccessfulPairing(proposal SessionProposal) error

func (*Service) SessionRequest

func (s *Service) SessionRequest(request SessionRequest) (response *transfer.TxResponse, err error)

type SessionDelete

type SessionDelete struct {
	ID    int64 `json:"id"`
	Topic Topic `json:"topic"`
}

type SessionProposal

type SessionProposal struct {
	ID     int64  `json:"id"`
	Params Params `json:"params"`
}

type SessionRequest

type SessionRequest struct {
	ID     int64         `json:"id"`
	Topic  Topic         `json:"topic"`
	Params RequestParams `json:"params"`
	Verify VerifyContext `json:"verifyContext"`
}

type Topic

type Topic string

type Verified

type Verified struct {
	VerifyURL  string `json:"verifyUrl"`
	Validation string `json:"validation"`
	Origin     string `json:"origin"`
	IsScam     bool   `json:"isScam,omitempty"`
}

type VerifyContext

type VerifyContext struct {
	Verified Verified `json:"verified"`
}

Jump to

Keyboard shortcuts

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