walletconnect

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2024 License: MPL-2.0 Imports: 22 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 AddSession added in v0.179.24

func AddSession(db *sql.DB, networks []params.Network, session_json string) error

AddSession adds a new active session to the database

func DeleteSession added in v0.179.24

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

func DisconnectSession added in v0.179.24

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

func SafeSignTypedDataForDApps added in v0.181.34

func SafeSignTypedDataForDApps(typedJson string, privateKey *ecdsa.PrivateKey, chainID uint64, legacy bool) (types.HexBytes, error)

func SetupTestDB added in v0.181.32

func SetupTestDB(t *testing.T) (db *sql.DB, close func())

func UpsertSession added in v0.171.33

func UpsertSession(db *sql.DB, data DBSession) error

Types

type DBDApp added in v0.179.24

type DBDApp struct {
	URL     string `json:"url"`
	Name    string `json:"name"`
	IconURL string `json:"iconUrl"`
}

func GetActiveDapps added in v0.179.24

func GetActiveDapps(db *sql.DB, validAtTimestamp int64, testChains bool) ([]DBDApp, error)

GetActiveDapps returns all dapps in the order of last first time connected (first session creation time)

type DBSession added in v0.179.24

type DBSession struct {
	Topic            Topic  `json:"topic"`
	Disconnected     bool   `json:"disconnected"`
	SessionJSON      string `json:"sessionJson"`
	Expiry           int64  `json:"expiry"`
	CreatedTimestamp int64  `json:"createdTimestamp"`
	PairingTopic     Topic  `json:"pairingTopic"`
	TestChains       bool   `json:"testChains"`
	DBDApp
}

func GetActiveSessions added in v0.171.33

func GetActiveSessions(db *sql.DB, validAtTimestamp int64) ([]DBSession, error)

GetActiveSessions returns all active sessions (not disconnected 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)

GetSessionByTopic returns sql.ErrNoRows if no session is found.

func GetSessions added in v0.179.24

func GetSessions(db *sql.DB) ([]DBSession, error)

GetSessions returns all sessions in the ascending order of creation time

func GetSessionsByPairingTopic added in v0.171.33

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

GetSessionsByPairingTopic returns sql.ErrNoRows if no session is found.

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"`
}

Params has RequiredNamespaces entries if part of "proposal namespace" and Namespaces entries if part of "session namespace" see https://specs.walletconnect.com/2.0/specs/clients/sign/namespaces#controller-side-validation-of-incoming-proposal-namespaces-wallet

func (*Params) ValidateForProposal added in v0.179.24

func (p *Params) ValidateForProposal() bool

ValidateForProposal validates params part of the Proposal Namespace

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 Scanner added in v0.179.24

type Scanner interface {
	Scan(dest ...interface{}) 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"`
}

func (*SessionProposal) ValidateProposal added in v0.179.24

func (p *SessionProposal) ValidateProposal() bool

ValidateProposal validates params part of the Proposal Namespace https://specs.walletconnect.com/2.0/specs/clients/sign/namespaces#controller-side-validation-of-incoming-proposal-namespaces-wallet

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