wc

package module
v0.0.0-...-378ae37 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 22 Imported by: 4

README

tests

Example

> go run examples/e1/main.go

 ▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
 █ ▄▄▄▄▄ █▀▀▀█▀▀ ▀▀▀█▄█▀▀▀█▀▀▀▀▄▄▄█▄▀▀▀▀▀▀ █ ▄▄▄▄▄ █
 █ █   █ █▀▄▀██▀ ▄█▀█ ▄▄█▀▄▀█▄█▀▀▀▄█▀▄▀██ ▄█ █   █ █
 █ █▄▄▄█ █▀█▀▀▄▀█▄█▀ ▀█  ▄▄▄ ▀▄▄▄█▄▀▀█▀▄▀███ █▄▄▄█ █
 █▄▄▄▄▄▄▄█▄▀▄▀ ▀ ▀▄▀ █▄▀ █▄█ █ █ █ ▀▄▀▄█▄█▄█▄▄▄▄▄▄▄█
 █▄▄▄  ▀▄▄ ▀▄▄▄█▀█▄ ▄▀▄▀▄▄▄▄▄ ▀█▀ ▀█▄█  █▀▄▄▀ ▀▄█ ██
 █▄▀▀▄██▄██▀▄▀▄▀██ ▀ ▀▀▄▄▄█▀▄█▀ ▀ ▀ ▄██▀ ▄▄ ▀█▀ ▄█ █
 █ ▀███ ▄▀▄▄▄█▄▀█▄▀▀ ▀▀█ █▄▄▄▄█▀ ▄▀▀▄  ▄█▀▄▄  ██▄ ▄█
 ██▄██▄▀▄█▄█▄██▄▀▄ ▄ ▀ ▄    ▄▀▀██▀▀▀▄ ▄ ▄██▄█   ▄█▄█
 ██▄▀▀▄▄▄▄  ▀▄▄▄▀▄▄▄▄▀▄ █▀ ▄███  ██▄▄█▄██▀▄  █▀▀▄███
 █▄█  █ ▄██▀█ █▄ ▄ ▄█▄█▄▄▀▄▄ ▀▀▀▀█ ▄▄▄▄▄ ▄█▀▀▄▀██▄ █
 █▀▄ ▀▀ ▄ ▄██▀█▄▄▀█▄▀▄█ ▄▄▄██▄▀ ▀ ▀▀▄▄▄██▀▄▄ █▀  ▀██
 █▀▄ █ ▄▄▄ ▀█ ▀▀ ▀█▀▄▄█▄ ▄▄▄  ▀█▀  ▀▄▀▄▄   ▄▄▄  █▀▄█
 █▀▄ ▀ █▄█  ▀ ▄▄▀ ▄▄▄▀▄  █▄█ █▀ ▀██ ▄▀▄▀█▀ █▄█ █▄▀▄█
 █ ▀▄  ▄▄ ▄ ▄ ▄▀█▄█▀  ▄▄     █▀▀▀ ▀█▄█▄█▄▄  ▄ ▄▀█▀ █
 █ ▀▀▀█ ▄▄█▄▄█ ▀█▄▀▀ ▀▀ ▀▀▄█▀▀█▄ ▀█ █▄▄██▄█▀ ▄▄█▄█▄█
 ██▀▄▀ ▀▄ █ █ ▀ █▄  █▀ █▄▀█▄█▄▀ ▀█▀▀  ▄ ▄▄▀▀▄ ██▄ ▄█
 █▄   ▄ ▄▀▄  ██ ▀█▄▄▄ ▄█▄▀  █▄▀▄ ▄███▀ ▄█ ▀▄ ▄▄  ▄▄█
 █▀█▄▄█▄▄▄▄ ▀▀▄▄ ▀▄▄█▀  ▄█▀▀▀█▀ █ ▀▄▄██ ▄▄▄▄▄ ▄ █  █
 █▀▀█▀█ ▄▀█▀▄▄ ▄▄▀█▄▀▄█ ▄█ ▄▀▀█  ██ █  █▄▄█▀ ▄▄▀▄ ▄█
 ██ ▀▀█▄▄▀ ▀▀▄ ▀▄▀█▄█▄█▀▄▀ █▀█▀▀▀▀▀▀▄▀▄▄ ▄▄▄▄█▀▄▄▄▄█
 █▄▄▄███▄█▀▄▄▄▀▀▀▄▄▄▄█▄  ▄▄▄  █▄▀▀█▀██▄▄█▄ ▄▄▄   ▄██
 █ ▄▄▄▄▄ █▄    ▀███▀  █▀ █▄█ ▄▀▄█▄█▀▄▀▄▄▄▄ █▄█  █▄ █
 █ █   █ █ ▄ ▀▄▀█▄▀▀ ▀▀▄▄ ▄▄▄▀█▀  ▀█▄▀ ▄██ ▄   █▄▀▀█
 █ █▄▄▄█ █ ▀▄▀█ ▄▄ ▄█▀ █▀▀ ███▀▄▀█▀▄▄ ██▄ █▄▀██ ▄█▀█
 █▄▄▄▄▄▄▄█▄█▄▄███▄▄▄▄█▄██▄▄▄▄▄█▄▄▄█▄██▄███████▄█▄▄▄█

Id: 1 | Method: wc_sessionRequest
Press Enter to send test transaction..

Id: 2 | Method: algo_signTxn
Sent tx: ...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeAlgoSignResponse

func DecodeAlgoSignResponse(response AlgoSignResponse) ([][]byte, error)

func MakeIV

func MakeIV() ([]byte, error)

func MakeKey

func MakeKey() ([]byte, error)

func MakeTopic

func MakeTopic() string

func WithServerDebug

func WithServerDebug(debug bool) func(*Server)

Types

type AlgoSignParams

type AlgoSignParams struct {
	TxnBase64 string   `json:"txn"`
	AuthAddr  string   `json:"authAddr,omitempty"`
	Message   string   `json:"message,omitempty"`
	Signers   []string `json:"signers,omitempty"`
}

type AlgoSignRequest

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

type AlgoSignResponse

type AlgoSignResponse struct {
	Error  *Error   `json:"error,omitempty"`
	Result []string `json:"result"`
}

type Client

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

func (*Client) Close

func (c *Client) Close() error

func (*Client) Sign

func (c *Client) Sign(ctx context.Context, request AlgoSignRequest) (*AlgoSignResponse, error)

type ClientOption

type ClientOption func(c *Client)

func WithClientConn

func WithClientConn(conn *Conn) ClientOption

func WithClientDebug

func WithClientDebug(debug bool) ClientOption

func WithClientUrlHandler

func WithClientUrlHandler(handler func(uri Uri) error) ClientOption

type Conn

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

func MakeConn

func MakeConn(opts ...ConnOption) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) MakeUri

func (c *Conn) MakeUri(topic string) Uri

func (*Conn) Read

func (c *Conn) Read() (Incoming, error)

func (*Conn) Send

func (c *Conn) Send(topic string, v any) error

func (*Conn) Subscribe

func (c *Conn) Subscribe(topic string) error

type ConnOption

type ConnOption func(*Conn)

func WithConnDebug

func WithConnDebug(enabled bool) ConnOption

func WithConnHost

func WithConnHost(host string) ConnOption

func WithConnKey

func WithConnKey(key []byte) ConnOption

type Error

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

func (Error) Error

func (e Error) Error() string
type Header struct {
	Id      uint64 `json:"id"`
	JsonRPC string `json:"jsonrpc"`
	Method  string `json:"method,omitempty"`
	Error   *Error `json:"error,omitempty"`
}

func MakeRequestHeader

func MakeRequestHeader(id uint64, method string) Header

func MakeResponseHeader

func MakeResponseHeader(id uint64) Header

type Incoming

type Incoming struct {
	Header
	Message Message
	Result  []byte
}

type Message

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

type Msg

type Msg interface{}

type OutgoingResponse

type OutgoingResponse struct {
	Header
	Result any `json:"result"`
}

type Request

type Request struct {
	Header
	Params []interface{} `json:"params"`
}

func MakeRequestSession

func MakeRequestSession(id uint64, peer string, meta SessionRequestPeerMeta) (Request, error)

func MakeSignTransactions

func MakeSignTransactions(id uint64, req AlgoSignRequest) (Request, error)

type Server

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

func MakeServer

func MakeServer(uri Uri, signer Signer, opts ...ServerOption) (*Server, error)

func (*Server) Close

func (s *Server) Close() error

func (*Server) Run

func (s *Server) Run() error

type ServerOption

type ServerOption func(s *Server)

type SessionRequestParams

type SessionRequestParams struct {
	PeerId   string                 `json:"peerId"`
	PeerMeta SessionRequestPeerMeta `json:"peerMeta"`
	ChainId  int                    `json:"chainId"`
}

type SessionRequestPeerMeta

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

type SessionRequestRequest

type SessionRequestRequest struct {
	Params []SessionRequestParams `json:"params"`
}

type SessionRequestResponse

type SessionRequestResponse struct {
	Error  *Error                       `json:"error,omitempty"`
	Result SessionRequestResponseResult `json:"result"`
}

type SessionRequestResponseResult

type SessionRequestResponseResult struct {
	PeerId   string                 `json:"peerId"`
	PeerMeta SessionRequestPeerMeta `json:"peerMeta"`
	Approved bool                   `json:"approved"`
	ChainId  int                    `json:"chainId"`
	Accounts []string               `json:"accounts"`
}

type SessionUpdateParams

type SessionUpdateParams struct {
	Approved  bool     `json:"approved"`
	ChainId   int      `json:"chainId"`
	NetworkId int      `json:"networkId"`
	Accounts  []string `json:"accounts"`
}

type SessionUpdateRequest

type SessionUpdateRequest struct {
	Header
	Params []SessionUpdateParams `json:"params"`
}

type Signer

type Signer interface {
	Sign(AlgoSignRequest) (*AlgoSignResponse, error)
	Address() string
}

type Uri

type Uri struct {
	Version int
	Topic   string
	Url     *url.URL
	Key     []byte
	Values  url.Values
}

func MakeUri

func MakeUri(topic string, host string, key []byte) Uri

func ParseUri

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

func (Uri) String

func (u Uri) String() string

type WC

type WC struct {
}

Directories

Path Synopsis
examples
e1

Jump to

Keyboard shortcuts

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