bath

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	Empty             ActionType = "Empty"
	TonTransfer       ActionType = "TonTransfer"
	SmartContractExec ActionType = "SmartContractExec"
	NftItemTransfer   ActionType = "NftItemTransfer"
	NftPurchase       ActionType = "NftPurchase"
	JettonTransfer    ActionType = "JettonTransfer"
	ContractDeploy    ActionType = "ContractDeploy"
	Subscription      ActionType = "Subscribe"
	UnSubscription    ActionType = "UnSubscribe"
	DepositStake      ActionType = "DepositStake"
	RecoverStake      ActionType = "RecoverStake"
	STONfiSwap        ActionType = "STONfiSwap"
	AuctionBid        ActionType = "AuctionBid"
	AuctionTgInitBid  ActionType = "AuctionTgInitBid"

	RefundDnsTg   RefundType = "DNS.tg"
	RefundDnsTon  RefundType = "DNS.ton"
	RefundGetGems RefundType = "GetGems"
	RefundUnknown RefundType = "unknown"
)

Variables

View Source
var GetGemsSale = Matcher{
	CheckFunc: func(bubble Bubble) bool {
		txBubble, ok := bubble.Info.(BubbleTx)
		if !ok {
			return false
		}
		if !txBubble.account.Is(abi.NftSaleGetgems) && !txBubble.account.Is(abi.NftSale) {
			return false
		}
		return true
	},
	Children: []Matcher{
		{
			CheckFunc: func(bubble Bubble) bool {
				_, ok := bubble.Info.(BubbleNftTransfer)
				return ok
			},
		},
	},
}

Functions

func CollectActionsAndValueFlow

func CollectActionsAndValueFlow(bubble *Bubble, forAccount *tongo.AccountID) ([]Action, *ValueFlow)

func FindContractDeploy added in v1.0.0

func FindContractDeploy(bubble *Bubble) bool

FindContractDeploy looks for contract deployments in the given bubble and creates a new ContractDeploy action for each. So at the end the bubble will look like: bubble -> ContractDeploy -> ContractDeploy -> bubble.children.

func FindDepositStake added in v0.1.1

func FindDepositStake(bubble *Bubble) bool

func FindExtendedSubscription

func FindExtendedSubscription(bubble *Bubble) bool

func FindInitialSubscription

func FindInitialSubscription(bubble *Bubble) bool

func FindJettonTransfer

func FindJettonTransfer(bubble *Bubble) bool

func FindNFTTransfer

func FindNFTTransfer(bubble *Bubble) bool

func FindNftPurchase added in v0.1.0

func FindNftPurchase(bubble *Bubble) bool

func FindRecoverStake added in v0.1.1

func FindRecoverStake(bubble *Bubble) bool

func FindSTONfiSwap added in v1.0.0

func FindSTONfiSwap(bubble *Bubble) bool

func FindTFNominatorAction added in v1.0.0

func FindTFNominatorAction(bubble *Bubble) bool

func FindUnSubscription added in v1.0.0

func FindUnSubscription(bubble *Bubble) bool

func MergeAllBubbles

func MergeAllBubbles(bubble *Bubble, straws []Straw)

Types

type Account

type Account struct {
	Address    tongo.AccountID
	Interfaces []abi.ContractInterface
}

func (*Account) Addr

func (a *Account) Addr() *tongo.AccountID

func (Account) Is

type AccountValueFlow

type AccountValueFlow struct {
	Ton     int64
	Fees    int64
	Jettons map[tongo.AccountID]big.Int
}

AccountValueFlow contains a change of assets for a particular account.

type Action

type Action struct {
	TonTransfer       *TonTransferAction    `json:",omitempty"`
	SmartContractExec *SmartContractAction  `json:",omitempty"`
	NftItemTransfer   *NftTransferAction    `json:",omitempty"`
	NftPurchase       *NftPurchaseAction    `json:",omitempty"`
	JettonTransfer    *JettonTransferAction `json:",omitempty"`
	ContractDeploy    *ContractDeployAction `json:",omitempty"`
	Subscription      *SubscriptionAction   `json:",omitempty"`
	UnSubscription    *UnSubscriptionAction `json:",omitempty"`
	AuctionBid        *AuctionBidAction     `json:",omitempty"`
	DepositStake      *DepositStakeAction   `json:",omitempty"`
	RecoverStake      *RecoverStakeAction   `json:",omitempty"`
	STONfiSwap        *STONfiSwapAction     `json:",omitempty"`
	Success           bool
	Type              ActionType
}

func (Action) ContributeToExtra

func (a Action) ContributeToExtra(account tongo.AccountID, extra int64) int64

func (Action) IsSubject added in v1.0.0

func (a Action) IsSubject(account tongo.AccountID) bool

func (Action) String

func (a Action) String() string

type ActionType

type ActionType string

type ActionsList

type ActionsList struct {
	Actions   []Action
	ValueFlow *ValueFlow
}

func FindActions

func FindActions(ctx context.Context, trace *core.Trace, opts ...Option) (*ActionsList, error)

FindActions finds known action patterns in the given trace and returns a list of actions.

func (*ActionsList) Extra

func (l *ActionsList) Extra(account tongo.AccountID, fullTrace *core.Trace) int64

type AuctionBidAction

type AuctionBidAction struct {
	Bidder         tongo.AccountID
	PreviousBidder *tongo.AccountID
	Bid            int64
	Item           *core.NftItem
	AuctionType    string
}

func (*AuctionBidAction) SubjectAccounts added in v1.0.0

func (a *AuctionBidAction) SubjectAccounts() []tongo.AccountID

type Bubble

type Bubble struct {
	Info      actioner
	Accounts  []tongo.AccountID
	Children  []*Bubble
	ValueFlow *ValueFlow
	// ContractDeployments specifies a list of contracts initialized by this bubble.
	ContractDeployments map[tongo.AccountID]ContractDeployment
}

Bubble represents a transaction in the beginning. But we can merge neighbour bubbles together if we find a known action pattern like an NFT Transfer or a SmartContractExecution in a trace.

func FromTrace

func FromTrace(trace *core.Trace) *Bubble

func ProcessChildren

func ProcessChildren(children []*Bubble, fns ...func(child *Bubble) *Merge) []*Bubble

func (*Bubble) MergeContractDeployments added in v1.0.0

func (b *Bubble) MergeContractDeployments(other *Bubble)

MergeContractDeployments copies contract deployments from other bubble.

func (Bubble) String

func (b Bubble) String() string

type BubbleContractDeploy added in v1.0.0

type BubbleContractDeploy struct {
	Contract tongo.AccountID
	// AccountInitInterfaces is a list of interfaces implemented by the stateInit.Code.
	// This list can differ from the current list of interfaces.
	// TODO: AccountInitInterfaces is an empty list in opentonapi, fix.
	AccountInitInterfaces []abi.ContractInterface
	Success               bool
}

func (BubbleContractDeploy) ToAction added in v1.0.0

func (b BubbleContractDeploy) ToAction() *Action

type BubbleDepositStake added in v0.1.1

type BubbleDepositStake struct {
	Staker  tongo.AccountID
	Amount  int64
	Success bool
}

func (BubbleDepositStake) ToAction added in v0.1.1

func (ds BubbleDepositStake) ToAction() *Action

type BubbleJettonTransfer

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

func (BubbleJettonTransfer) ToAction

func (b BubbleJettonTransfer) ToAction() (action *Action)

type BubbleNftPurchase added in v0.1.0

type BubbleNftPurchase struct {
	Success     bool
	Buyer       tongo.AccountID
	Seller      tongo.AccountID
	Nft         tongo.AccountID
	AuctionType NftAuctionType
	Price       int64
}

func (BubbleNftPurchase) ToAction added in v0.1.0

func (b BubbleNftPurchase) ToAction() *Action

type BubbleNftTransfer

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

func (BubbleNftTransfer) ToAction

func (b BubbleNftTransfer) ToAction() (action *Action)

type BubbleRecoverStake added in v0.1.1

type BubbleRecoverStake struct {
	Staker  tongo.AccountID
	Amount  int64
	Success bool
}

func (BubbleRecoverStake) ToAction added in v0.1.1

func (b BubbleRecoverStake) ToAction() *Action

type BubbleSTONfiSwap added in v1.0.0

type BubbleSTONfiSwap struct {
	AmountIn        uint64
	AmountOut       uint64
	UserWallet      tongo.AccountID
	STONfiRouter    tongo.AccountID
	JettonWalletIn  tongo.AccountID
	JettonMasterIn  tongo.AccountID
	JettonWalletOut tongo.AccountID
	JettonMasterOut tongo.AccountID
	Success         bool
}

BubbleSTONfiSwap contains information about a swap operation at the STONfi dex.

func (BubbleSTONfiSwap) ToAction added in v1.0.0

func (b BubbleSTONfiSwap) ToAction() *Action

type BubbleSubscription

type BubbleSubscription struct {
	Subscription, Subscriber, Beneficiary Account
	Amount                                int64
	Success                               bool
	First                                 bool
}

func (BubbleSubscription) ToAction

func (b BubbleSubscription) ToAction() (action *Action)

type BubbleTFNominator added in v1.0.0

type BubbleTFNominator struct {
	Command  TFCommand
	Amount   int64
	Actor    tongo.AccountID
	Contract tongo.AccountID
	Success  bool
}

func (BubbleTFNominator) ToAction added in v1.0.0

func (b BubbleTFNominator) ToAction() *Action

type BubbleTx

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

func (BubbleTx) String

func (b BubbleTx) String() string

func (BubbleTx) ToAction

func (b BubbleTx) ToAction() *Action

type BubbleUnSubscription added in v1.0.0

type BubbleUnSubscription struct {
	Subscription, Subscriber, Beneficiary Account
	Success                               bool
}

func (BubbleUnSubscription) ToAction added in v1.0.0

func (b BubbleUnSubscription) ToAction() (action *Action)

type ContractDeployAction

type ContractDeployAction struct {
	Address    tongo.AccountID
	Interfaces []abi.ContractInterface
}

func (*ContractDeployAction) SubjectAccounts added in v1.0.0

func (a *ContractDeployAction) SubjectAccounts() []tongo.AccountID

type ContractDeployment added in v1.0.0

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

ContractDeployment holds information about initialization of a contract. TODO: should ContractDeployment contains LT/time of a deployment so we can sort several ContractDeploy actions?

type DepositStakeAction added in v0.1.1

type DepositStakeAction struct {
	Amount  int64
	Elector tongo.AccountID
	Staker  tongo.AccountID
}

func (*DepositStakeAction) SubjectAccounts added in v1.0.0

func (a *DepositStakeAction) SubjectAccounts() []tongo.AccountID

type EncryptedComment added in v1.0.0

type EncryptedComment struct {
	EncryptionType string
	CipherText     []byte
}

type JettonTransferAction

type JettonTransferAction struct {
	Comment          *string
	EncryptedComment *EncryptedComment
	Jetton           tongo.AccountID
	Recipient        *tongo.AccountID
	Sender           *tongo.AccountID
	RecipientsWallet tongo.AccountID
	SendersWallet    tongo.AccountID
	Amount           tlb.VarUInteger16
	Refund           *Refund
}

func (*JettonTransferAction) SubjectAccounts added in v1.0.0

func (a *JettonTransferAction) SubjectAccounts() []tongo.AccountID

type Matcher added in v0.1.0

type Matcher struct {
	CheckFunc func(bubble Bubble) bool
	Children  []Matcher
}

func (Matcher) Match added in v0.1.0

func (m Matcher) Match(bubble Bubble)

type Merge

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

type NftAuctionType added in v0.1.0

type NftAuctionType string
const (
	GetGemsAuction NftAuctionType = "getgems"
	BasicAuction   NftAuctionType = "basic"
)

type NftPurchaseAction added in v0.1.0

type NftPurchaseAction struct {
	Nft         tongo.AccountID
	Buyer       tongo.AccountID
	Seller      tongo.AccountID
	AuctionType NftAuctionType
	Price       int64
}

func (*NftPurchaseAction) SubjectAccounts added in v1.0.0

func (a *NftPurchaseAction) SubjectAccounts() []tongo.AccountID

type NftTransferAction

type NftTransferAction struct {
	Comment          *string
	EncryptedComment *EncryptedComment
	Recipient        *tongo.AccountID
	Sender           *tongo.AccountID
	Nft              tongo.AccountID
	Refund           *Refund
}

func (*NftTransferAction) SubjectAccounts added in v1.0.0

func (a *NftTransferAction) SubjectAccounts() []tongo.AccountID

type Option

type Option func(*Options)

func ForAccount

func ForAccount(a tongo.AccountID) Option

func WithInformationSource added in v0.1.0

func WithInformationSource(source core.InformationSource) Option

func WithStraws

func WithStraws(straws []Straw) Option

WithStraws provides functions to find actions in a trace.

type Options

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

type RecoverStakeAction added in v0.1.1

type RecoverStakeAction struct {
	Amount  int64
	Elector tongo.AccountID
	Staker  tongo.AccountID
}

func (*RecoverStakeAction) SubjectAccounts added in v1.0.0

func (a *RecoverStakeAction) SubjectAccounts() []tongo.AccountID

type Refund

type Refund struct {
	Type   RefundType
	Origin string
}

type RefundType

type RefundType string

type STONfiSwapAction added in v1.0.0

type STONfiSwapAction struct {
	UserWallet      tongo.AccountID
	STONfiRouter    tongo.AccountID
	JettonWalletIn  tongo.AccountID
	JettonMasterIn  tongo.AccountID
	JettonWalletOut tongo.AccountID
	JettonMasterOut tongo.AccountID
	AmountIn        uint64
	AmountOut       uint64
}

func (*STONfiSwapAction) SubjectAccounts added in v1.0.0

func (a *STONfiSwapAction) SubjectAccounts() []tongo.AccountID

type SmartContractAction

type SmartContractAction struct {
	TonAttached int64
	Executor    tongo.AccountID
	Contract    tongo.AccountID
	Operation   string
	Payload     string
}

func (*SmartContractAction) ContributeToExtra

func (a *SmartContractAction) ContributeToExtra(account tongo.AccountID, extra int64) int64

func (*SmartContractAction) SubjectAccounts added in v1.0.0

func (a *SmartContractAction) SubjectAccounts() []tongo.AccountID

type Straw

type Straw func(bubble *Bubble) (success bool)

Straw extracts information from the given bubble and its children and modifies the bubble if needed. If the bubble is modified this function return true.

type SubscriptionAction

type SubscriptionAction struct {
	Subscription tongo.AccountID
	Subscriber   tongo.AccountID
	Beneficiary  tongo.AccountID
	Amount       int64
	First        bool
}

func (*SubscriptionAction) SubjectAccounts added in v1.0.0

func (a *SubscriptionAction) SubjectAccounts() []tongo.AccountID

type TFCommand added in v1.0.0

type TFCommand string
const (
	TfDepositStakeRequest            TFCommand = "TfDepositStakeRequest"
	TfRecoverStakeRequest            TFCommand = "TfRecoverStakeRequest"
	TfRequestWithdraw                TFCommand = "TfRequestWithdraw"
	TfProcessPendingWithdrawRequests TFCommand = "TfProcessPendingWithdrawRequests"
	TfDeposit                        TFCommand = "TfDeposit"
	TfUpdateValidatorSet             TFCommand = "TfUpdateValidatorSet"
)

type TonTransferAction

type TonTransferAction struct {
	Amount           int64
	Comment          *string
	EncryptedComment *EncryptedComment
	Recipient        tongo.AccountID
	Sender           tongo.AccountID
	Refund           *Refund
}

func (*TonTransferAction) ContributeToExtra

func (a *TonTransferAction) ContributeToExtra(account tongo.AccountID, extra int64) int64

func (*TonTransferAction) SubjectAccounts added in v1.0.0

func (a *TonTransferAction) SubjectAccounts() []tongo.AccountID

type UnSubscriptionAction

type UnSubscriptionAction struct {
	Subscription tongo.AccountID
	Subscriber   tongo.AccountID
	Beneficiary  tongo.AccountID
}

func (*UnSubscriptionAction) SubjectAccounts added in v1.0.0

func (a *UnSubscriptionAction) SubjectAccounts() []tongo.AccountID

type ValueFlow

type ValueFlow struct {
	Accounts map[tongo.AccountID]*AccountValueFlow
}

ValueFlow contains a change of assets for each account involved in a trace.

func (*ValueFlow) AddFee

func (flow *ValueFlow) AddFee(accountID tongo.AccountID, amount int64)

func (*ValueFlow) AddJettons

func (flow *ValueFlow) AddJettons(accountID tongo.AccountID, jetton tongo.AccountID, value big.Int)

func (*ValueFlow) AddTons

func (flow *ValueFlow) AddTons(accountID tongo.AccountID, amount int64)

func (*ValueFlow) Merge

func (flow *ValueFlow) Merge(other *ValueFlow)

Jump to

Keyboard shortcuts

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