bath

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 19 Imported by: 2

Documentation

Index

Constants

View Source
const (
	TonTransfer           ActionType = "TonTransfer"
	SmartContractExec     ActionType = "SmartContractExec"
	NftItemTransfer       ActionType = "NftItemTransfer"
	NftPurchase           ActionType = "NftPurchase"
	JettonTransfer        ActionType = "JettonTransfer"
	JettonMint            ActionType = "JettonMint"
	JettonBurn            ActionType = "JettonBurn"
	ContractDeploy        ActionType = "ContractDeploy"
	Subscription          ActionType = "Subscribe"
	UnSubscription        ActionType = "UnSubscribe"
	ElectionsDepositStake ActionType = "ElectionsDepositStake"
	ElectionsRecoverStake ActionType = "ElectionsRecoverStake"
	DepositStake          ActionType = "DepositStake"
	WithdrawStake         ActionType = "WithdrawStake"
	WithdrawStakeRequest  ActionType = "WithdrawStakeRequest"
	JettonSwap            ActionType = "JettonSwap"
	AuctionBid            ActionType = "AuctionBid"

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

Variables

View Source
var DedustLPJettonMintStraw = Straw[BubbleJettonMint]{
	CheckFuncs: []bubbleCheck{IsTx, Or(HasOpcode(0xb56b9598), HasOpcode(0x1674b0a0))},
	Builder: func(newAction *BubbleJettonMint, bubble *Bubble) (err error) {
		tx := bubble.Info.(BubbleTx)
		newAction.master = tx.account.Address
		return nil
	},
	Children: []Straw[BubbleJettonMint]{
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonInternalTransferMsgOp)},
			Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error {
				tx := bubble.Info.(BubbleTx)
				msg := tx.decodedBody.Value.(abi.JettonInternalTransferMsgBody)
				newAction.amount = msg.Amount
				newAction.recipientWallet = tx.account.Address
				newAction.success = tx.success
				return nil
			},
			Children: []Straw[BubbleJettonMint]{
				{
					CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp)},
					Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error {
						tx := bubble.Info.(BubbleTx)
						newAction.recipient = tx.account
						return nil
					},
				},
				{CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)}, Optional: true},
			},
		},
	},
}

DedustLPJettonMintStraw example: https://tonviewer.com/transaction/6d33487c44249d7844db8fac38a5cecf1502ec7e0c09d266e98e95a2b1be17b5

View Source
var DedustSwapStraw = Straw[BubbleJettonSwap]{
	CheckFuncs: []bubbleCheck{IsJettonTransfer, JettonTransferOperation(abi.DedustSwapJettonOp)},
	Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
		transfer := bubble.Info.(BubbleJettonTransfer)
		newAction.Dex = Dedust
		newAction.In.JettonMaster = transfer.master
		newAction.In.JettonWallet = transfer.senderWallet
		newAction.In.Amount = big.Int(transfer.amount)
		newAction.In.IsTon = transfer.isWrappedTon
		if transfer.payload.Value.(abi.DedustSwapJettonPayload).Step.Params.KindOut {
			return errors.New("dedust swap: wrong kind of limits")
		}
		newAction.Out.Amount = big.Int(transfer.payload.Value.(abi.DedustSwapJettonPayload).Step.Params.Limit)
		return nil
	},
	SingleChild: &Straw[BubbleJettonSwap]{
		CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.DedustSwapExternalMsgOp)},
		Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
			newAction.Router = bubble.Info.(BubbleTx).account.Address
			return nil
		},
		SingleChild: &Straw[BubbleJettonSwap]{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.DedustPayoutFromPoolMsgOp)},
			SingleChild: &Straw[BubbleJettonSwap]{
				CheckFuncs: []bubbleCheck{IsJettonTransfer},
				Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
					newAction.Success = true
					transfer := bubble.Info.(BubbleJettonTransfer)
					newAction.Out.JettonMaster = transfer.master
					newAction.Out.IsTon = transfer.isWrappedTon
					newAction.Out.Amount = big.Int(transfer.amount)
					newAction.Out.JettonWallet = transfer.recipientWallet
					return nil
				},
			},
		},
	},
}
View Source
var DepositLiquidStakeStraw = Straw[BubbleDepositStake]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.TonstakePoolDepositMsgOp)},
	Builder: func(newAction *BubbleDepositStake, bubble *Bubble) error {
		tx := bubble.Info.(BubbleTx)
		newAction.Pool = tx.account.Address
		newAction.Staker = tx.inputFrom.Address
		newAction.Amount = tx.inputAmount - int64(ton.OneTON)
		newAction.Success = tx.success
		newAction.Implementation = core.StakingImplementationLiquidTF
		return nil
	},
	SingleChild: &Straw[BubbleDepositStake]{
		CheckFuncs: []bubbleCheck{IsBounced},
		Optional:   true,
	},
}
View Source
var DepositTFStakeStraw = Straw[BubbleDepositStake]{
	CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.TfNominator), HasTextComment("d")},
	Builder: func(newAction *BubbleDepositStake, bubble *Bubble) error {
		tx := bubble.Info.(BubbleTx)
		newAction.Pool = tx.account.Address
		newAction.Staker = tx.inputFrom.Address
		newAction.Amount = tx.inputAmount
		newAction.Success = tx.success
		newAction.Implementation = core.StakingImplementationTF
		return nil
	},
	SingleChild: &Straw[BubbleDepositStake]{
		CheckFuncs: []bubbleCheck{IsBounced},
		Optional:   true,
	},
}
View Source
var ElectionsDepositStakeStraw = Straw[BubbleElectionsDepositStake]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ElectorNewStakeMsgOp), IsAccount(config.ElectorAddress())},
	Builder: func(newAction *BubbleElectionsDepositStake, bubble *Bubble) error {
		bubbleTx := bubble.Info.(BubbleTx)
		newAction.Amount = bubbleTx.inputAmount
		newAction.Staker = bubbleTx.inputFrom.Address
		return nil
	},
	Children: []Straw[BubbleElectionsDepositStake]{
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ElectorNewStakeConfirmationMsgOp)},
			Builder: func(newAction *BubbleElectionsDepositStake, bubble *Bubble) error {
				newAction.Success = true
				return nil
			},
		},
	},
}
View Source
var ElectionsRecoverStakeStraw = Straw[BubbleElectionsRecoverStake]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ElectorRecoverStakeRequestMsgOp), IsAccount(config.ElectorAddress())},
	Builder: func(newAction *BubbleElectionsRecoverStake, bubble *Bubble) error {
		bubbleTx := bubble.Info.(BubbleTx)
		newAction.Staker = bubbleTx.inputFrom.Address
		return nil
	},
	Children: []Straw[BubbleElectionsRecoverStake]{
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ElectorRecoverStakeResponseMsgOp)},
			Builder: func(newAction *BubbleElectionsRecoverStake, bubble *Bubble) error {
				newAction.Amount = bubble.Info.(BubbleTx).inputAmount
				newAction.Success = true
				return nil
			},
		},
	},
}
View Source
var JettonBurnStraw = Straw[BubbleJettonBurn]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonBurnMsgOp)},
	Builder: func(newAction *BubbleJettonBurn, bubble *Bubble) error {
		tx := bubble.Info.(BubbleTx)
		msg := tx.decodedBody.Value.(abi.JettonBurnMsgBody)
		newAction.amount = msg.Amount
		if tx.inputFrom != nil {
			newAction.sender = *tx.inputFrom
		}
		if tx.additionalInfo.JettonMaster != nil {

			newAction.master = *tx.additionalInfo.JettonMaster
		}
		newAction.senderWallet = tx.account.Address
		newAction.success = tx.success
		return nil
	},
	SingleChild: &Straw[BubbleJettonBurn]{
		CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonBurnNotificationMsgOp)},
		Builder: func(newAction *BubbleJettonBurn, bubble *Bubble) error {
			newAction.master = bubble.Info.(BubbleTx).account.Address
			return nil
		},
		Optional: true,
	},
}
View Source
var JettonTransfersBurnsMints = []StrawFunc{
	FindJettonTransfer,
	JettonBurnStraw.Merge,
	DedustLPJettonMintStraw.Merge,
	WtonMintStraw.Merge,
}
View Source
var MegatonFiJettonSwap = Straw[BubbleJettonSwap]{
	CheckFuncs: []bubbleCheck{IsJettonTransfer, IsJettonReceiver(abi.MegatonfiRouter)},
	Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
		tx := bubble.Info.(BubbleJettonTransfer)
		newAction.UserWallet = tx.sender.Address
		newAction.In.Amount = big.Int(tx.amount)
		newAction.In.IsTon = tx.isWrappedTon
		newAction.Router = tx.recipient.Address
		newAction.In.JettonWallet = tx.senderWallet
		newAction.In.JettonMaster = tx.master
		newAction.Dex = Megatonfi
		return nil
	},
	Children: []Straw[BubbleJettonSwap]{
		{
			CheckFuncs: []bubbleCheck{IsJettonTransfer, IsJettonReceiver(abi.MegatonfiExchange)},
			Children: []Straw[BubbleJettonSwap]{
				{
					CheckFuncs: []bubbleCheck{IsJettonTransfer, IsJettonReceiver(abi.MegatonfiRouter)},
					Children: []Straw[BubbleJettonSwap]{
						{
							CheckFuncs: []bubbleCheck{IsJettonTransfer},
							Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
								tx := bubble.Info.(BubbleJettonTransfer)
								newAction.Success = tx.success
								newAction.Out.Amount = big.Int(tx.amount)
								newAction.Out.IsTon = tx.isWrappedTon
								newAction.Out.JettonWallet = tx.recipientWallet
								newAction.Out.JettonMaster = tx.master
								return nil
							},
						},
					},
				},
			},
		},
	},
}

MegatonFiJettonSwap creates a BubbleJettonSwap if there is a jetton swap in a trace.

View Source
var NFTStraws = []StrawFunc{
	NftTransferStraw.Merge,
	NftTransferNotifyStraw.Merge,
}
View Source
var NftTransferNotifyStraw = Straw[BubbleNftTransfer]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.NftOwnershipAssignedMsgOp)},
	Builder: func(newAction *BubbleNftTransfer, bubble *Bubble) error {
		receiverTx := bubble.Info.(BubbleTx)
		transfer := receiverTx.decodedBody.Value.(abi.NftOwnershipAssignedMsgBody)
		newAction.success = true
		if receiverTx.inputFrom == nil {
			return fmt.Errorf("nft transfer notify without sender")
		}
		newAction.account = *receiverTx.inputFrom
		if newAction.sender == nil {
			newAction.sender = parseAccount(transfer.PrevOwner)
		}
		newAction.recipient = &receiverTx.account
		newAction.payload = transfer.ForwardPayload.Value
		return nil
	},
}
View Source
var NftTransferStraw = Straw[BubbleNftTransfer]{
	CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.NftTransferMsgOp)},
	Builder: func(newAction *BubbleNftTransfer, bubble *Bubble) error {
		tx := bubble.Info.(BubbleTx)
		transfer := tx.decodedBody.Value.(abi.NftTransferMsgBody)
		newAction.account = tx.account
		newAction.success = tx.success
		newAction.sender = tx.inputFrom
		newAction.payload = transfer.ForwardPayload.Value
		if newAction.recipient == nil {
			newAction.recipient = parseAccount(transfer.NewOwner)
		}
		return nil
	},
	Children: []Straw[BubbleNftTransfer]{
		Optional(NftTransferNotifyStraw),
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)},
			Optional:   true,
		},
	},
}
View Source
var StonfiMintStraw = Straw[BubbleJettonMint]{}

https://dev.tonviewer.com/transaction/e19381edd8f05922eeba3c31f4b8b4b737478b4ca7b37130bdbbfd7bfa773227 todo: add liquidity (mint lp tokens)

View Source
var StonfiSwapStraw = Straw[BubbleJettonSwap]{
	CheckFuncs: []bubbleCheck{Is(BubbleJettonTransfer{})},
	Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
		newAction.Dex = Stonfi
		jettonTx := bubble.Info.(BubbleJettonTransfer)
		newAction.UserWallet = jettonTx.sender.Address
		newAction.In.Amount = big.Int(jettonTx.amount)
		newAction.In.IsTon = jettonTx.isWrappedTon
		newAction.In.JettonMaster = jettonTx.master
		return nil
	},
	SingleChild: &Straw[BubbleJettonSwap]{
		CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.StonfiSwapMsgOp), HasInterface(abi.StonfiPool)},
		Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
			tx := bubble.Info.(BubbleTx)
			a, b := tx.additionalInfo.STONfiPool.Token0, tx.additionalInfo.STONfiPool.Token1
			body := tx.decodedBody.Value.(abi.StonfiSwapMsgBody)
			newAction.Out.Amount = big.Int(body.MinOut)
			s, err := tongo.AccountIDFromTlb(body.SenderAddress)
			if err != nil {
				return err
			}
			if s != nil && *s == b {
				a, b = b, a
			}
			newAction.In.JettonWallet = a
			newAction.Out.JettonWallet = b
			return nil
		},
		SingleChild: &Straw[BubbleJettonSwap]{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.StonfiPaymentRequestMsgOp)},
			Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
				tx := bubble.Info.(BubbleTx)
				newAction.Router = tx.account.Address
				return nil
			},
			SingleChild: &Straw[BubbleJettonSwap]{
				CheckFuncs: []bubbleCheck{Is(BubbleJettonTransfer{}), Or(JettonTransferOpCode(0xc64370e5), JettonTransferOpCode(0x5ffe1295))},
				Builder: func(newAction *BubbleJettonSwap, bubble *Bubble) error {
					jettonTx := bubble.Info.(BubbleJettonTransfer)
					if jettonTx.senderWallet != newAction.Out.JettonWallet {
						return nil
					}
					newAction.Out.JettonMaster = jettonTx.master
					newAction.Out.Amount = big.Int(jettonTx.amount)
					newAction.Out.IsTon = jettonTx.isWrappedTon
					newAction.Success = true
					return nil
				},
			},
		},
	},
}
View Source
var WithdrawLiquidStake = Straw[BubbleWithdrawStake]{
	CheckFuncs: []bubbleCheck{Is(BubbleJettonBurn{})},
	Builder: func(newAction *BubbleWithdrawStake, bubble *Bubble) error {
		newAction.Staker = bubble.Info.(BubbleJettonBurn).sender.Address
		newAction.Implementation = core.StakingImplementationLiquidTF
		amount := big.Int(bubble.Info.(BubbleJettonBurn).amount)
		newAction.Amount = amount.Int64()
		return nil
	},
	SingleChild: &Straw[BubbleWithdrawStake]{
		CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.TonstakePoolWithdrawMsgOp)},
		Builder: func(newAction *BubbleWithdrawStake, bubble *Bubble) error {
			newAction.Pool = bubble.Info.(BubbleTx).account.Address
			return nil
		},
		SingleChild: &Straw[BubbleWithdrawStake]{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.TonstakePoolWithdrawalMsgOp)},
		},
	},
}
View Source
var WithdrawStakeImmediatelyStraw = Straw[BubbleWithdrawStake]{
	CheckFuncs: []bubbleCheck{Is(BubbleWithdrawStakeRequest{})},
	Builder: func(newAction *BubbleWithdrawStake, bubble *Bubble) error {
		req := bubble.Info.(BubbleWithdrawStakeRequest)
		newAction.Pool = req.Pool
		newAction.Staker = req.Staker
		newAction.Amount = -req.attachedAmount
		newAction.Implementation = req.Implementation
		return nil
	},
	SingleChild: &Straw[BubbleWithdrawStake]{
		CheckFuncs: []bubbleCheck{IsTx, AmountInterval(int64(ton.OneTON), 1<<63-1)},
		Builder: func(newAction *BubbleWithdrawStake, bubble *Bubble) error {
			newAction.Amount += bubble.Info.(BubbleTx).inputAmount
			return nil
		},
	},
}
View Source
var WithdrawTFStakeRequestStraw = Straw[BubbleWithdrawStakeRequest]{
	CheckFuncs: []bubbleCheck{IsTx, HasInterface(abi.TfNominator), HasTextComment("w")},
	Builder: func(newAction *BubbleWithdrawStakeRequest, bubble *Bubble) error {
		tx := bubble.Info.(BubbleTx)
		newAction.Pool = tx.account.Address
		newAction.Staker = tx.inputFrom.Address
		newAction.Success = tx.success
		newAction.attachedAmount = tx.inputAmount
		newAction.Implementation = core.StakingImplementationTF
		return nil
	},
	Children: []Straw[BubbleWithdrawStakeRequest]{
		{
			Optional:   true,
			CheckFuncs: []bubbleCheck{IsTx, AmountInterval(0, int64(ton.OneTON))},
		},
	},
}
View Source
var WtonMintStraw = Straw[BubbleJettonMint]{
	CheckFuncs: []bubbleCheck{IsTx, HasOpcode(0x77a33521)},
	Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error {
		newAction.recipient = bubble.Info.(BubbleTx).account
		return nil
	},
	Children: []Straw[BubbleJettonMint]{
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonInternalTransferMsgOp)},
			Builder: func(newAction *BubbleJettonMint, bubble *Bubble) error {
				tx := bubble.Info.(BubbleTx)
				body := tx.decodedBody.Value.(abi.JettonInternalTransferMsgBody)
				newAction.amount = body.Amount
				if tx.additionalInfo != nil && tx.additionalInfo.JettonMaster != nil {
					newAction.master = *tx.additionalInfo.JettonMaster
				}
				newAction.recipientWallet = tx.account.Address
				newAction.success = tx.success
				return nil
			},
			Children: []Straw[BubbleJettonMint]{
				{
					CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.JettonNotifyMsgOp)},
					Optional:   true,
				},
				{
					CheckFuncs: []bubbleCheck{Is(BubbleContractDeploy{})},
					Optional:   true,
				},
			},
		},
		{
			CheckFuncs: []bubbleCheck{IsTx, HasOperation(abi.ExcessMsgOp)},
			Optional:   true,
		},
	},
}

Functions

func AmountInterval added in v1.1.0

func AmountInterval(min, max int64) bubbleCheck

func CollectActionsAndValueFlow

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

func FindAuctionBidFragmentSimple added in v1.1.0

func FindAuctionBidFragmentSimple(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 FindNftPurchase added in v0.1.0

func FindNftPurchase(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 HasInterface added in v1.1.0

func HasInterface(iface abi.ContractInterface) bubbleCheck

func HasOpcode added in v1.1.0

func HasOpcode(op uint32) bubbleCheck

func HasOperation added in v1.1.0

func HasOperation(name abi.MsgOpName) bubbleCheck

func HasTextComment added in v1.1.0

func HasTextComment(comment string) bubbleCheck

func Is added in v1.1.0

func Is(t actioner) bubbleCheck

func IsAccount added in v1.1.0

func IsAccount(id tongo.AccountID) bubbleCheck

func IsBounced added in v1.1.0

func IsBounced(bubble *Bubble) bool

func IsJettonReceiver added in v1.1.0

func IsJettonReceiver(iface abi.ContractInterface) bubbleCheck

func IsJettonTransfer added in v1.1.0

func IsJettonTransfer(b *Bubble) bool

func IsTx added in v1.1.0

func IsTx(b *Bubble) bool

func JettonTransferOpCode added in v1.1.0

func JettonTransferOpCode(opCode uint32) bubbleCheck

func JettonTransferOperation added in v1.1.0

func JettonTransferOperation(op abi.JettonOpName) bubbleCheck

func MergeAllBubbles

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

func Or added in v1.1.0

func Or(check1, check2 bubbleCheck) bubbleCheck

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"`
	JettonMint            *JettonMintAction            `json:",omitempty"`
	JettonBurn            *JettonBurnAction            `json:",omitempty"`
	ContractDeploy        *ContractDeployAction        `json:",omitempty"`
	Subscription          *SubscriptionAction          `json:",omitempty"`
	UnSubscription        *UnSubscriptionAction        `json:",omitempty"`
	AuctionBid            *AuctionBidAction            `json:",omitempty"`
	ElectionsDepositStake *ElectionsDepositStakeAction `json:",omitempty"`
	ElectionsRecoverStake *ElectionsRecoverStakeAction `json:",omitempty"`
	DepositStake          *DepositStakeAction          `json:",omitempty"`
	WithdrawStake         *WithdrawStakeAction         `json:",omitempty"`
	WithdrawStakeRequest  *WithdrawStakeRequestAction  `json:",omitempty"`
	JettonSwap            *JettonSwapAction            `json:",omitempty"`
	Success               bool
	Type                  ActionType
}

func (Action) ContributeToExtra

func (a Action) ContributeToExtra(account tongo.AccountID) 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) int64

type AuctionBidAction

type AuctionBidAction struct {
	Type       string
	Amount     int64
	Nft        *core.NftItem
	NftAddress *tongo.AccountID
	Bidder     tongo.AccountID
	Auction    tongo.AccountID
}

func (*AuctionBidAction) SubjectAccounts added in v1.0.0

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

type AuctionBidBubble added in v1.1.0

type AuctionBidBubble struct {
	Type           string
	Amount         int64
	Nft            *core.NftItem
	NftAddress     *tongo.AccountID
	Bidder         tongo.AccountID
	Auction        tongo.AccountID
	PreviousBidder *tongo.AccountID //maybe don't requered
	Success        bool
}

func (AuctionBidBubble) ToAction added in v1.1.0

func (a AuctionBidBubble) ToAction() *Action

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 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
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
}

func (BubbleDepositStake) ToAction added in v0.1.1

func (ds BubbleDepositStake) ToAction() *Action

type BubbleElectionsDepositStake added in v1.1.0

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

func (BubbleElectionsDepositStake) ToAction added in v1.1.0

func (ds BubbleElectionsDepositStake) ToAction() *Action

type BubbleElectionsRecoverStake added in v1.1.0

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

func (BubbleElectionsRecoverStake) ToAction added in v1.1.0

func (b BubbleElectionsRecoverStake) ToAction() *Action

type BubbleJettonBurn added in v1.1.0

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

func (BubbleJettonBurn) ToAction added in v1.1.0

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

type BubbleJettonMint added in v1.1.0

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

func (BubbleJettonMint) ToAction added in v1.1.0

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

type BubbleJettonSwap added in v1.1.0

type BubbleJettonSwap struct {
	Dex        Dex
	UserWallet tongo.AccountID
	Router     tongo.AccountID
	Out        assetTransfer
	In         assetTransfer
	Success    bool
}

BubbleJettonSwap contains information about a jetton swap operation at a dex.

func (BubbleJettonSwap) ToAction added in v1.1.0

func (b BubbleJettonSwap) 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 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 BubbleWithdrawStake added in v1.1.0

type BubbleWithdrawStake struct {
	Staker         tongo.AccountID
	Amount         int64
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
}

func (BubbleWithdrawStake) ToAction added in v1.1.0

func (ds BubbleWithdrawStake) ToAction() *Action

type BubbleWithdrawStakeRequest added in v1.1.0

type BubbleWithdrawStakeRequest struct {
	Staker         tongo.AccountID
	Amount         *int64
	Success        bool
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
	// contains filtered or unexported fields
}

func (BubbleWithdrawStakeRequest) ToAction added in v1.1.0

func (ds BubbleWithdrawStakeRequest) ToAction() *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 {
	Staker         tongo.AccountID
	Amount         int64
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
}

func (*DepositStakeAction) SubjectAccounts added in v1.0.0

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

type Dex added in v1.1.0

type Dex string
const (
	Stonfi    Dex = "stonfi"
	Megatonfi Dex = "megatonfi"
	Dedust    Dex = "dedust"
)

type ElectionsDepositStakeAction added in v1.1.0

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

func (*ElectionsDepositStakeAction) SubjectAccounts added in v1.1.0

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

type ElectionsRecoverStakeAction added in v1.1.0

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

func (*ElectionsRecoverStakeAction) SubjectAccounts added in v1.1.0

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

type EncryptedComment added in v1.0.0

type EncryptedComment struct {
	EncryptionType string
	CipherText     []byte
}

type JettonBurnAction added in v1.1.0

type JettonBurnAction struct {
	Jetton        tongo.AccountID
	Sender        tongo.AccountID
	SendersWallet tongo.AccountID
	Amount        tlb.VarUInteger16
}

func (*JettonBurnAction) SubjectAccounts added in v1.1.0

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

type JettonMintAction added in v1.1.0

type JettonMintAction struct {
	Jetton           tongo.AccountID
	Recipient        tongo.AccountID
	RecipientsWallet tongo.AccountID
	Amount           tlb.VarUInteger16
}

func (*JettonMintAction) SubjectAccounts added in v1.1.0

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

type JettonSwapAction added in v1.1.0

type JettonSwapAction struct {
	Dex        Dex
	UserWallet tongo.AccountID
	Router     tongo.AccountID
	In         assetTransfer
	Out        assetTransfer
}

func (*JettonSwapAction) SubjectAccounts added in v1.1.0

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

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
	// contains filtered or unexported fields
}

func (*JettonTransferAction) SubjectAccounts added in v1.0.0

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

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 []StrawFunc) 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) SubjectAccounts added in v1.0.0

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

type Straw

type Straw[newBubbleT actioner] struct {
	CheckFuncs  []bubbleCheck
	Builder     func(newAction *newBubbleT, bubble *Bubble) error
	SingleChild *Straw[newBubbleT]
	Children    []Straw[newBubbleT]
	Optional    bool
}

func Optional added in v1.1.0

func Optional[T actioner](s Straw[T]) Straw[T]

Optional returns copy of declarative straw but optional

func (Straw[newBubbleT]) Merge added in v1.1.0

func (s Straw[newBubbleT]) Merge(bubble *Bubble) bool

type StrawFunc added in v1.1.0

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

StrawFunc 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"
	TfProcessPendingWithdrawRequests TFCommand = "TfProcessPendingWithdrawRequests"
	TfUpdateValidatorSet             TFCommand = "TfUpdateValidatorSet"
)

type TonTransferAction

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

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, jettonMaster 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)

type WithdrawStakeAction added in v1.1.0

type WithdrawStakeAction struct {
	Staker         tongo.AccountID
	Amount         int64
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
}

func (*WithdrawStakeAction) SubjectAccounts added in v1.1.0

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

type WithdrawStakeRequestAction added in v1.1.0

type WithdrawStakeRequestAction struct {
	Staker         tongo.AccountID
	Amount         *int64
	Pool           tongo.AccountID
	Implementation core.StakingImplementation
}

func (*WithdrawStakeRequestAction) SubjectAccounts added in v1.1.0

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

Jump to

Keyboard shortcuts

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