tonconnect

package module
v0.0.0-...-616a647 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 18 Imported by: 1

README

TON Connect

Go Report Card

Getting Started

go get github.com/cameo-engineering/tonconnect

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Wallets = map[string]Wallet{
	"telegram-wallet": {
		Name:         "Wallet",
		UniversalURL: "https://t.me/wallet/start?startapp=",
		BridgeURL:    "https://bridge.ton.space/bridge",
	},
	"tonkeeper": {
		Name:         "Tonkeeper",
		UniversalURL: "https://app.tonkeeper.com/ton-connect",
		BridgeURL:    "https://bridge.tonapi.io/bridge",
	},
	"mytonwallet": {
		Name:         "MyTonWallet",
		UniversalURL: "https://connect.mytonwallet.org/",
		BridgeURL:    "https://tonconnectbridge.mytonwallet.org/bridge",
	},
	"tonhub": {
		Name:         "Tonhub",
		UniversalURL: "https://tonhub.com/ton-connect",
		BridgeURL:    "https://connect.tonhubapi.com/tonconnect",
	},
	"dewallet": {
		Name:         "DeWallet",
		UniversalURL: "https://t.me/dewallet?attach=wallet",
		BridgeURL:    "https://sse-bridge.delab.team/bridge",
	},
	"bitgetTonWallet": {
		Name:         "Bitget Wallet",
		UniversalURL: "https://bkcode.vip/ton-connect",
		BridgeURL:    "https://bridge.tonapi.io/bridge",
	},
	"safepalwallet": {
		Name:         "SafePal",
		UniversalURL: "https://link.safepal.io/ton-connect",
		BridgeURL:    "https://ton-bridge.safepal.com/tonbridge/v1/bridge",
	},
}

Functions

func WithBackReturnStrategy

func WithBackReturnStrategy() linkOption

func WithFrom

func WithFrom(from string) txOpt

func WithMainnet

func WithMainnet() txOpt

func WithMessage

func WithMessage(msg Message) txOpt

func WithNoneReturnStrategy

func WithNoneReturnStrategy() linkOption

func WithPayload

func WithPayload(payload []byte) msgOpt

func WithProofRequest

func WithProofRequest(payload string) connReqOpt

func WithPublicKey

func WithPublicKey(pubkey string) signDataOpt

func WithStateInit

func WithStateInit(stateInit []byte) msgOpt

func WithTTL

func WithTTL(ttl uint64) bridgeMessageOption

func WithTestnet

func WithTestnet() txOpt

func WithTimeout

func WithTimeout(timeout time.Duration) txOpt

func WithURLReturnStrategy

func WithURLReturnStrategy(url string) linkOption
func WrapDeeplink(link string) string

Types

type ConnectItem

type ConnectItem struct {
	Name    string `json:"name"`
	Payload string `json:"payload,omitempty"`
}

type ConnectRequest

type ConnectRequest struct {
	ManifestURL string        `json:"manifestUrl"`
	Items       []ConnectItem `json:"items"`
}

func NewConnectRequest

func NewConnectRequest(manifestURL string, options ...connReqOpt) (*ConnectRequest, error)

type Message

type Message struct {
	Address   string `json:"address"`
	Amount    string `json:"amount"`
	Payload   []byte `json:"payload,omitempty"`
	StateInit []byte `json:"stateInit,omitempty"`
}

func NewMessage

func NewMessage(address string, amount string, options ...msgOpt) (*Message, error)

type Session

type Session struct {
	ID            nacl.Key `json:"id"`
	PrivateKey    nacl.Key `json:"private_key"`
	ClientID      nacl.Key `json:"client_id,omitempty"`
	BridgeURL     string   `json:"brdige_url,omitempty"`
	LastEventID   uint64   `json:"last_event_id,string,omitempty"`
	LastRequestID uint64   `json:"last_request_id,string,omitempty"`
}

func NewSession

func NewSession() (*Session, error)

func (*Session) Connect

func (s *Session) Connect(ctx context.Context, wallets ...Wallet) (*connectResponse, error)

func (*Session) Disconnect

func (s *Session) Disconnect(ctx context.Context, options ...bridgeMessageOption) error
func (s *Session) GenerateDeeplink(connreq ConnectRequest, options ...linkOption) (string, error)
func (s *Session) GenerateUniversalLink(wallet Wallet, connreq ConnectRequest, options ...linkOption) (string, error)

func (*Session) MarshalJSON

func (s *Session) MarshalJSON() ([]byte, error)

func (*Session) SendTransaction

func (s *Session) SendTransaction(ctx context.Context, tx Transaction, options ...bridgeMessageOption) ([]byte, error)

func (*Session) SignData

func (s *Session) SignData(ctx context.Context, data SignData, options ...bridgeMessageOption) (*signDataResult, error)

func (*Session) UnmarshalJSON

func (s *Session) UnmarshalJSON(data []byte) error

type SignData

type SignData struct {
	SchemaCRC uint32 `json:"schema_crc"`
	Cell      []byte `json:"cell"`
	PublicKey string `json:"publicKey,omitempty"`
}

func NewSignDataRequest

func NewSignDataRequest(schemaCRC uint32, cell []byte, options ...signDataOpt) (*SignData, error)

type Transaction

type Transaction struct {
	ValidUntil uint64    `json:"valid_until,omitempty"`
	Network    string    `json:"network,omitempty"`
	From       string    `json:"from,omitempty"`
	Messages   []Message `json:"messages"`
}

func NewTransaction

func NewTransaction(options ...txOpt) (*Transaction, error)

type Wallet

type Wallet struct {
	Name         string `json:"name"`
	UniversalURL string `json:"universal_url"`
	BridgeURL    string `json:"bridge_url"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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