walletconnect

package
v0.171.34 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MPL-2.0 Imports: 20 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 ChangeSessionState added in v0.171.33

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

func UpsertSession added in v0.171.33

func UpsertSession(db *sql.DB, session DbSession) error

Types

type DbSession added in v0.171.33

type DbSession struct {
	Topic           Topic  `json:"topic"`
	PairingTopic    Topic  `json:"pairingTopic"`
	Expiry          int64  `json:"expiry"`
	Active          bool   `json:"active"`
	DappName        string `json:"dappName"`
	DappURL         string `json:"dappUrl"`
	DappDescription string `json:"dappDescription"`
	DappIcon        string `json:"dappIcon"`
	DappVerifyURL   string `json:"dappVerifyUrl"`
	DappPublicKey   string `json:"dappPublicKey"`
}

func GetActiveSessions added in v0.171.33

func GetActiveSessions(db *sql.DB, expiryNotOlderThanTimestamp int64) ([]DbSession, error)

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

func GetSessionByTopic added in v0.171.33

func GetSessionByTopic(db *sql.DB, topic Topic) (*DbSession, error)

func GetSessionsByPairingTopic added in v0.171.33

func GetSessionsByPairingTopic(db *sql.DB, pairingTopic Topic) ([]DbSession, error)

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 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) ChangeSessionState added in v0.171.33

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

func (*Service) PairSessionProposal

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

func (*Service) SaveOrUpdateSession added in v0.171.33

func (s *Service) SaveOrUpdateSession(session Session) error

func (*Service) SessionRequest

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

type Session added in v0.171.33

type Session struct {
	Acknowledged       bool                 `json:"acknowledged"`
	Controller         string               `json:"controller"`
	Expiry             int64                `json:"expiry"`
	Namespaces         map[string]Namespace `json:"namespaces"`
	OptionalNamespaces map[string]Namespace `json:"optionalNamespaces"`
	PairingTopic       Topic                `json:"pairingTopic"`
	Peer               Proposer             `json:"peer"`
	Relay              json.RawMessage      `json:"relay"`
	RequiredNamespaces map[string]Namespace `json:"requiredNamespaces"`
	Self               Proposer             `json:"self"`
	Topic              Topic                `json:"topic"`
}

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