core

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TonSymbol        = "TON"
	DefaultWorkchain = 0 // use only 0 workchain
)

Variables

View Source
var (
	ErrNotFound        = errors.New("not found")
	ErrTimeoutExceeded = errors.New("timeout exceeded")
)

Functions

func BuildJettonProxyWithdrawalMessage

func BuildJettonProxyWithdrawalMessage(
	proxy JettonProxy,
	jettonWallet, tonWallet *address.Address,
	forwardAmount tlb.Coins,
	amount *big.Int,
	comment string,
) *wallet.Message

func BuildJettonWithdrawalMessage

func BuildJettonWithdrawalMessage(
	t ExternalWithdrawalTask,
	highloadWallet *wallet.Wallet,
	fromJettonWallet *address.Address,
) *wallet.Message

func BuildTonWithdrawalMessage

func BuildTonWithdrawalMessage(t ExternalWithdrawalTask) *wallet.Message

func LoadComment

func LoadComment(cell *cell.Cell) string

func MakeJettonTransferMessage

func MakeJettonTransferMessage(
	destination, responseDest *address.Address,
	amount *big.Int,
	forwardAmount tlb.Coins,
	queryId int64,
	comment string,
) *cell.Cell

func TonutilsAddressToUserFormat

func TonutilsAddressToUserFormat(addr *address.Address) string

func WithdrawJettons

func WithdrawJettons(
	ctx context.Context,
	from, to *wallet.Wallet,
	jettonWallet *address.Address,
	forwardAmount tlb.Coins,
	amount Coins,
	comment string,
) error

func WithdrawTONs

func WithdrawTONs(ctx context.Context, from, to *wallet.Wallet, comment string) error

WithdrawTONs Send all TON from one wallet (and deploy it if needed) to another and destroy "from" wallet contract. Wallet must be not empty.

Types

type Address

type Address [32]byte // supports only MsgAddressInt addr_std$10 without anycast and 0 workchain

func AddressFromBytes

func AddressFromBytes(data []byte) (Address, error)

func AddressFromTonutilsAddress

func AddressFromTonutilsAddress(addr *address.Address) (Address, error)

func AddressMustFromTonutilsAddress

func AddressMustFromTonutilsAddress(addr *address.Address) Address

func (*Address) Scan

func (a *Address) Scan(src interface{}) error

Scan implements Scanner for database/sql.

func (Address) ToBytes

func (a Address) ToBytes() []byte

func (Address) ToTonutilsAddressStd

func (a Address) ToTonutilsAddressStd(flags byte) *address.Address

ToTonutilsAddressStd implements converter to ton-utils std Address type for default workchain !

func (Address) ToUserFormat

func (a Address) ToUserFormat() string

ToUserFormat converts to user-friendly text format with testnet and bounce flags

func (Address) Value

func (a Address) Value() (driver.Value, error)

Value implements valuer for database/sql.

type AddressInfo

type AddressInfo struct {
	Type   WalletType
	Owner  *Address
	UserID string
}

type BlockEvents

type BlockEvents struct {
	Events
	Block ShardBlockHeader
}

type BlockScanner

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

func NewBlockScanner

func NewBlockScanner(
	wg *sync.WaitGroup,
	db storage,
	blockchain blockchain,
	shard byte,
	tracker blocksTracker,
	notificators []Notificator,
) *BlockScanner

func (*BlockScanner) Start

func (s *BlockScanner) Start()

func (*BlockScanner) Stop

func (s *BlockScanner) Stop()

type Coins

type Coins = decimal.Decimal

func NewCoins

func NewCoins(int *big.Int) Coins

func ZeroCoins

func ZeroCoins() Coins

type EventName

type EventName = string
const (
	ServiceWithdrawalEvent  EventName = "service withdrawal"
	InternalWithdrawalEvent EventName = "internal withdrawal"
	ExternalWithdrawalEvent EventName = "external withdrawal"
	InitEvent               EventName = "initialization"
)

type Events

type Events struct {
	ExternalIncomes         []ExternalIncome
	InternalIncomes         []InternalIncome
	SendingConfirmations    []SendingConfirmation
	InternalWithdrawals     []InternalWithdrawal
	ExternalWithdrawals     []ExternalWithdrawal
	WithdrawalConfirmations []JettonWithdrawalConfirmation
}

func (*Events) Append

func (e *Events) Append(ae Events)

type ExternalIncome

type ExternalIncome struct {
	Utime         uint32
	Lt            uint64
	From          []byte
	FromWorkchain *int32
	To            Address
	Amount        Coins
	Comment       string
	TxHash        []byte
}

type ExternalWithdrawal

type ExternalWithdrawal struct {
	ExtMsgUuid uuid.UUID
	Utime      uint32
	Lt         uint64
	To         Address
	Amount     Coins
	Comment    string
	IsFailed   bool
}

type ExternalWithdrawalTask

type ExternalWithdrawalTask struct {
	QueryID     int64
	Currency    string
	Amount      Coins
	Destination Address
	Bounceable  bool
	Comment     string
}

type HighLoadWalletExtMsgInfo

type HighLoadWalletExtMsgInfo struct {
	UUID     uuid.UUID
	TTL      time.Time
	Messages *cell.Dictionary
}

type IncomeSide

type IncomeSide = string
const (
	SideHotWallet IncomeSide = "hot_wallet"
	SideDeposit   IncomeSide = "deposit"
)

type InternalIncome

type InternalIncome struct {
	Utime    uint32
	Lt       uint64 // will not fit in db bigint after 1.5 billion years
	From     Address
	To       Address
	Amount   Coins
	Memo     string
	IsFailed bool
	TxHash   []byte
}

type InternalWithdrawal

type InternalWithdrawal struct {
	Utime    uint32
	Lt       uint64
	From     Address
	Amount   Coins
	Memo     string // uuid from comment
	IsFailed bool
}

type InternalWithdrawalTask

type InternalWithdrawalTask struct {
	From        Address
	SubwalletID uint32
	Lt          uint64
	Currency    string
}

type JettonProxy

type JettonProxy struct {
	Owner       *address.Address
	SubwalletID uint32
	// contains filtered or unexported fields
}

JettonProxy is a special contract wrapper that allow to control jetton wallet from TON wallet. It is possible create few jetton proxies for single TON wallet (as owner) and control multiple jetton wallets. Read about JettonProxy smart contract at README.md and https://github.com/gobicycle/ton-proxy-contract

func NewJettonProxy

func NewJettonProxy(subwalletId uint32, owner *address.Address) (*JettonProxy, error)

func (*JettonProxy) Address

func (p *JettonProxy) Address() *address.Address

Address returns address of jetton proxy contract

func (*JettonProxy) BuildMessage

func (p *JettonProxy) BuildMessage(destination *address.Address, body *cell.Cell) *tlb.InternalMessage

BuildMessage wraps custom body payload to resend by proxy contract

func (*JettonProxy) StateInit

func (p *JettonProxy) StateInit() *tlb.StateInit

StateInit returns state init structure of jetton proxy contract

type JettonTransferMsg

type JettonTransferMsg struct {
	Amount      Coins
	Destination *address.Address
	Comment     string
}

func DecodeJettonTransfer

func DecodeJettonTransfer(msg *tlb.InternalMessage) (JettonTransferMsg, error)

type JettonWallet

type JettonWallet struct {
	Address  *address.Address
	Currency string
}

type JettonWithdrawalConfirmation

type JettonWithdrawalConfirmation struct {
	QueryId uint64
}

type Notificator

type Notificator interface {
	Publish(payload any) error
}

type OwnerWallet

type OwnerWallet struct {
	Address  Address
	Currency string
}

type SendingConfirmation

type SendingConfirmation struct {
	Lt   uint64 // Lt of outgoing wallet message
	From Address
	Memo string // uuid from comment
}

type ServiceWithdrawalRequest

type ServiceWithdrawalRequest struct {
	From         Address
	JettonMaster *Address
}

type ServiceWithdrawalTask

type ServiceWithdrawalTask struct {
	ServiceWithdrawalRequest
	JettonAmount Coins
	Memo         uuid.UUID
	SubwalletID  uint32
}

type ShardBlockHeader

type ShardBlockHeader struct {
	*ton.BlockIDExt
	NotMaster bool
	GenUtime  uint32
	StartLt   uint64
	EndLt     uint64
	Parent    *ton.BlockIDExt
}

ShardBlockHeader Block header for a specific shard mask attribute. Has only one parent.

type TotalIncome

type TotalIncome struct {
	Deposit  Address
	Amount   Coins
	Currency string
}

type WalletData

type WalletData struct {
	SubwalletID uint32
	UserID      string
	Currency    string
	Type        WalletType
	Address     Address
}

type WalletType

type WalletType string
const (
	TonHotWallet        WalletType = "ton_hot"
	JettonHotWallet     WalletType = "jetton_hot"
	TonDepositWallet    WalletType = "ton_deposit"
	JettonDepositWallet WalletType = "jetton_deposit"
	JettonOwner         WalletType = "owner"
)

type Wallets

type Wallets struct {
	Shard            byte
	TonHotWallet     *wallet.Wallet
	TonBasicWallet   *wallet.Wallet // basic V3 wallet to make other wallets with different subwallet_id
	JettonHotWallets map[string]JettonWallet
}

func InitWallets

func InitWallets(
	ctx context.Context,
	db storage,
	bc blockchain,
	seed string,
	jettons map[string]config.Jetton,
) (Wallets, error)

InitWallets Generates highload hot-wallet and map[currency]JettonWallet Jetton wallets, and saves to DB TON highload hot-wallet (for seed and default subwallet_id) must be already active for success initialization.

type WithdrawalRequest

type WithdrawalRequest struct {
	QueryID     string
	UserID      string
	Currency    string
	Amount      Coins
	Bounceable  bool
	IsInternal  bool
	Destination Address
	Comment     string
}

type WithdrawalStatus

type WithdrawalStatus string
const (
	PendingStatus    WithdrawalStatus = "pending"
	ProcessingStatus WithdrawalStatus = "processing"
	ProcessedStatus  WithdrawalStatus = "processed"
)

type WithdrawalsProcessor

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

func NewWithdrawalsProcessor

func NewWithdrawalsProcessor(
	wg *sync.WaitGroup,
	db storage,
	bc blockchain,
	wallets Wallets,
	coldWallet *address.Address,
) *WithdrawalsProcessor

func (*WithdrawalsProcessor) Start

func (p *WithdrawalsProcessor) Start()

func (*WithdrawalsProcessor) Stop

func (p *WithdrawalsProcessor) Stop()

Jump to

Keyboard shortcuts

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