wc2

package module
v0.0.0-...-8dc8ab2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2023 License: MIT Imports: 24 Imported by: 0

README

Examples

Client (wallet)

go run example\e1\main.go -id "cloud.walletconnect.com project id" -mnemonic "account mnemonic" -uri "WalletConnect2 uri"

Server (dapp)

go run example\e2\main.go -id "cloud.walletconnect.com project id" -addr "Algorand account address"

Documentation

Index

Constants

View Source
const (
	MAINNET = "algorand:wGHE2Pwdvd7S12BL5FaOP20EGYesN73k"
	TESTNET = "algorand:SGO1GKSzyE7IEPItTxCByw9x8FmnrCDe"
	BETANET = "algorand:mFgazF-2uRS1tMiL9dsj01hJGySEmPN2"
)
View Source
const (
	ALGO_SIGNTXN = "algo_signTxn"
)

Variables

This section is empty.

Functions

func MakeHeader

func MakeHeader(method string) (jsonrpc.Header, error)

func MakeId

func MakeId() (json.Number, error)

func MakeKey

func MakeKey() ([]byte, error)

func MakeTopic

func MakeTopic() string

func ReadMessage

func ReadMessage(msg string, aead cipher.AEAD, priv []byte) (*jsonrpc.Header, []byte, error)

func WithDialerDebug

func WithDialerDebug(debug bool) dialerOption

func WithDialerOptions

func WithDialerOptions(d *websocket.DialOptions) dialerOption

func WithDialerPrivateKey

func WithDialerPrivateKey(sk ed25519.PrivateKey) dialerOption

func WithDialerUrl

func WithDialerUrl(url string) dialerOption

Types

type AlgoSignParams

type AlgoSignParams struct {
	TxnBase64 string `json:"txn"`
}

type AlgoSignRequest

type AlgoSignRequest struct {
	Params [][]AlgoSignParams `json:"params"`
}

type AlgoSignTxn

type AlgoSignTxn struct {
	jsonrpc.Header
	Params [][]AlgoSignParams `json:"params"`
}

type AlgoSignTxnResponse

type AlgoSignTxnResponse jsonrpc.Response[[]string]

type Client

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

func MakeClient

func MakeClient(ctx context.Context, dialer *Dialer, u Uri, opts ...ClientOption) (*Client, error)

func (*Client) Close

func (s *Client) Close() error

type ClientOption

type ClientOption func(*clientConfig)

func WithClientDebug

func WithClientDebug(debug bool) ClientOption

func WithClientMetadata

func WithClientMetadata(metadata Metadata) ClientOption

func WithClientSigner

func WithClientSigner(s Signer) ClientOption

type Conn

type Conn interface {
	Read() (*jsonrpc.Header, []byte, error)
	Send(v any) error
	Close() error
}

type Dialer

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

func MakeDialer

func MakeDialer(projectId string, opts ...dialerOption) (*Dialer, error)

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context) (Conn, error)

type FetchMessagesResponse

type FetchMessagesResponse jsonrpc.Response[IrnFetchMessagesResponseResult]

func UnmarshalFetchMessagesResponse

func UnmarshalFetchMessagesResponse(bs []byte) (FetchMessagesResponse, error)

type Irn

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

func NewIrn

func NewIrn(c Conn) (*Irn, error)

func (*Irn) Close

func (irn *Irn) Close() error

func (*Irn) FetchMessages

func (irn *Irn) FetchMessages(ctx context.Context, reqId json.Number, topic string) (*FetchMessagesResponse, error)

func (*Irn) Publish

func (irn *Irn) Publish(ctx context.Context, params IrnPublishRequestParams) (*jsonrpc.Header, []byte, error)

func (*Irn) Request

func (irn *Irn) Request(ctx context.Context, id json.Number, method string, params any) (*jsonrpc.Header, []byte, error)

func (*Irn) Subscribe

func (irn *Irn) Subscribe(ctx context.Context, reqId json.Number, topic string) (string, error)

func (*Irn) Subscriptions

func (irn *Irn) Subscriptions() <-chan IrnSubscription

func (*Irn) Unsubscribe

func (irn *Irn) Unsubscribe(ctx context.Context, reqId json.Number, topic string, subId string) error

type IrnFetchMessagesRequestParams

type IrnFetchMessagesRequestParams struct {
	Topic string `json:"topic"`
}

type IrnFetchMessagesResponseResult

type IrnFetchMessagesResponseResult struct {
	Messages []IrnReceivedMessage
	HasMode  bool `json:"hasMore"`
}

type IrnPublishRequestParams

type IrnPublishRequestParams struct {
	IrnPublishRequestParamsHeader
	Message string `json:"message"`
}

type IrnPublishRequestParamsHeader

type IrnPublishRequestParamsHeader struct {
	Prompt bool   `json:"prompt"`
	Tag    int    `json:"tag"`
	Topic  string `json:"topic"`
	Ttl    int    `json:"ttl"`
}

type IrnReceivedMessage

type IrnReceivedMessage struct {
	Topic       string      `json:"topic"`
	Message     string      `json:"message"`
	PublishedAt uint64      `json:"publishedAt"`
	Tag         interface{} `json:"tag"`
}

type IrnRequestFunc

type IrnRequestFunc func(head *jsonrpc.Header, bs []byte) error

type IrnSubscribeRequestParams

type IrnSubscribeRequestParams struct {
	Topic string `json:"topic"`
}

type IrnSubscribeResponse

type IrnSubscribeResponse jsonrpc.Response[string]

type IrnSubscription

type IrnSubscription struct {
	jsonrpc.Header
	Params IrnSubscriptionParams `json:"params"`
}

type IrnSubscriptionParams

type IrnSubscriptionParams struct {
	Id   string             `json:"id"`
	Data IrnReceivedMessage `json:"data"`
}

type IrnUnsubscribeRequestParams

type IrnUnsubscribeRequestParams struct {
	Topic string `json:"topic"`
	Id    string `json:"id"`
}

type MakeConnFunc

type MakeConnFunc func() (Conn, error)

type Message

type Message struct {
	Topic   string `json:"topic"`
	Type    string `json:"type"`
	Payload string `json:"payload"`
	Silent  bool   `json:"silent"`
}

type Metadata

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

type Namespace

type Namespace struct {
	Chains  []string `json:"chains"`
	Methods []string `json:"methods"`
	Events  []string `json:"events"`
}

type Peer

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

type Relay

type Relay struct {
	Protocol string `json:"protocol"`
	Data     string `json:"data,omitempty"`
}

type Server

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

func MakeServer

func MakeServer(ctx context.Context, dial *Dialer, network string, opts ...ServerOption) (*Server, []string, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Done

func (s *Server) Done() <-chan struct{}

func (*Server) Sign

func (s *Server) Sign(ctx context.Context, chainId string, request AlgoSignRequest) ([][]byte, error)

type ServerOption

type ServerOption func(*serverConfig)

func WithServerDebug

func WithServerDebug(debug bool) ServerOption

func WithServerMetadata

func WithServerMetadata(m Metadata) ServerOption

func WithServerUriHandler

func WithServerUriHandler(h UriHandler) ServerOption

type SessionExtendRequest

type SessionExtendRequest struct {
	jsonrpc.Header
	Expiry json.Number `json:"expiry"`
}

type SessionProposeRequest

type SessionProposeRequest struct {
	jsonrpc.Header
	Params SessionProposeRequestParams `json:"params"`
}

type SessionProposeRequestParams

type SessionProposeRequestParams struct {
	RequiredNamespaces map[string]Namespace `json:"requiredNamespaces"`
	OptionalNamespaces map[string]Namespace `json:"optionalNamespaces"`
	Relays             []Relay              `json:"relays"`
	Proposer           Peer                 `json:"proposer"`
}

type SessionProposeResponseParams

type SessionProposeResponseParams struct {
	Relay              Relay  `json:"relay"`
	ResponderPublicKey string `json:"responderPublicKey"`
}

type SessionRequestAlgoSignTxn

type SessionRequestAlgoSignTxn struct {
	jsonrpc.Header
	Params SessionRequestAlgoSignTxnParams `json:"params"`
}

type SessionRequestAlgoSignTxnParams

type SessionRequestAlgoSignTxnParams struct {
	Request AlgoSignTxn `json:"request"`
	ChainId string      `json:"chainId"`
}

type SessionRequestRequestHeader

type SessionRequestRequestHeader struct {
	jsonrpc.Header
	Params SessionRequestRequestHeaderParams `json:"params"`
}

type SessionRequestRequestHeaderParams

type SessionRequestRequestHeaderParams struct {
	Header  jsonrpc.Header `json:"request"`
	ChainId string         `json:"chainId"`
}

type SessionSettleRequest

type SessionSettleRequest struct {
	jsonrpc.Header
	Params SessionSettleRequestParams `json:"params"`
}

type SessionSettleRequestParams

type SessionSettleRequestParams struct {
	Relay      `json:"relay"`
	Controller Peer                       `json:"controller"`
	Namespaces map[string]SettleNamespace `json:"namespaces"`
	Expiry     int64                      `json:"expiry"`
}

type SettleNamespace

type SettleNamespace struct {
	Accounts []string `json:"accounts"`
	Methods  []string `json:"methods"`
	Events   []string `json:"events"`
}

type Signer

type Signer interface {
	Sign(req AlgoSignTxn) ([]string, error)
	Address() string
}

func MakeAccountSigner

func MakeAccountSigner(account crypto.Account) (Signer, error)

type Uri

type Uri struct {
	Id       string
	Version  int
	Protocol string
	Key      []byte
}

func MakeUri

func MakeUri() (*Uri, error)

func MakeUriFrom

func MakeUriFrom(id string, key []byte) Uri

func ParseUri

func ParseUri(uri string) (*Uri, error)

func (Uri) String

func (u Uri) String() string

type UriHandler

type UriHandler func(Uri) error

Directories

Path Synopsis
example
e1
e2
e3

Jump to

Keyboard shortcuts

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