bath

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 15 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 = "Subscription"
	UnSubscription    ActionType = "UnSubscribe"
	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 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 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"`
	Success           bool
	Type              ActionType
}

func (Action) ContributeToExtra

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

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
}

type Bubble

type Bubble struct {
	Info      actioner
	Accounts  []tongo.AccountID
	Children  []*Bubble
	ValueFlow *ValueFlow
}

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) String

func (b Bubble) String() string

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 BubbleSubscription

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

func (BubbleSubscription) ToAction

func (b BubbleSubscription) ToAction() (action *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 ContractDeployAction

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

type JettonTransferAction

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

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
}

type NftTransferAction

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

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 Refund

type Refund struct {
	Type   RefundType
	Origin string
}

type RefundType

type RefundType string

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

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
}

type TonTransferAction

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

func (*TonTransferAction) ContributeToExtra

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

type UnSubscriptionAction

type UnSubscriptionAction struct {
	Subscription tongo.AccountID
	Subscriber   tongo.AccountID
	Beneficiary  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