Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify the Mode parameter in the on chain request using a constant, making it easier for developers to read and understand. #200

Merged
merged 1 commit into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/highload-wallet/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func main() {
for addrStr, amtStr := range receivers {
addr := address.MustParseAddr(addrStr)
messages = append(messages, &wallet.Message{
Mode: 1 + 2, // pay fee separately, ignore action errors
Mode: wallet.PayGasSeparately + wallet.IgnoreErrors, // pay fee separately, ignore action errors
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true, // disable hyper routing (currently not works in ton)
Bounce: addr.IsBounceable(),
Expand Down
2 changes: 1 addition & 1 deletion example/send-to-contract/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
log.Println("sending transaction and waiting for confirmation...")

tx, block, err := w.SendWaitTransaction(context.Background(), &wallet.Message{
Mode: 1, // pay fees separately (from balance, not from amount)
Mode: wallet.PayGasSeparately, // pay fees separately (from balance, not from amount)
InternalMessage: &tlb.InternalMessage{
Bounce: true, // return amount in case of processing error
DstAddr: address.MustParseAddr("EQCD39VS5jcptHL8vMjEXrzGaRcCVYto7HUn4bpAOg8xqB2N"),
Expand Down
2 changes: 1 addition & 1 deletion ton/wallet/highloadv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ func (s *SpecHighloadV3) packActions(queryId uint64, messages []*Message) (*Mess
}

return &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: false,
Expand Down
20 changes: 14 additions & 6 deletions ton/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ const (
Unknown Version = 0
)

const (
CarryAllRemainingBalance = 128
CarryAllRemainingIncomingValue = 64
DestroyAccountIfZero = 32
IgnoreErrors = 2
PayGasSeparately = 1
)

func (v Version) String() string {
if v == Unknown {
return "unknown"
Expand Down Expand Up @@ -343,7 +351,7 @@ func (w *Wallet) BuildTransfer(to *address.Address, amount tlb.Coins, bounce boo
}

return &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: bounce,
Expand All @@ -369,7 +377,7 @@ func (w *Wallet) BuildTransferEncrypted(ctx context.Context, to *address.Address
}

return &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: bounce,
Expand Down Expand Up @@ -710,7 +718,7 @@ func (w *Wallet) DeployContractWaitTransaction(ctx context.Context, amount tlb.C
addr := address.NewAddress(0, 0, stateCell.Hash())

tx, block, err := w.SendWaitTransaction(ctx, &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: false,
Expand Down Expand Up @@ -741,7 +749,7 @@ func (w *Wallet) DeployContract(ctx context.Context, amount tlb.Coins, msgBody,
addr := address.NewAddress(0, 0, stateCell.Hash())

if err = w.Send(ctx, &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: false,
Expand Down Expand Up @@ -769,7 +777,7 @@ func (w *Wallet) FindTransactionByInMsgHash(ctx context.Context, msgHash []byte,

func SimpleMessage(to *address.Address, amount tlb.Coins, payload *cell.Cell) *Message {
return &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: true,
Expand All @@ -783,7 +791,7 @@ func SimpleMessage(to *address.Address, amount tlb.Coins, payload *cell.Cell) *M
// SimpleMessageAutoBounce - will determine bounce flag from address
func SimpleMessageAutoBounce(to *address.Address, amount tlb.Coins, payload *cell.Cell) *Message {
return &Message{
Mode: 1 + 2,
Mode: PayGasSeparately + IgnoreErrors,
InternalMessage: &tlb.InternalMessage{
IHRDisabled: true,
Bounce: to.IsBounceable(),
Expand Down
2 changes: 1 addition & 1 deletion ton/wallet/wallet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestWallet_Send(t *testing.T) {
}

msg := &Message{
Mode: 128,
Mode: CarryAllRemainingBalance,
InternalMessage: intMsg,
}

Expand Down