Skip to content
Draft
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
21 changes: 21 additions & 0 deletions pkg/bindings/jetton/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package jetton
import (
"github.com/xssnick/tonutils-go/tlb"

"github.com/smartcontractkit/chainlink-ton/pkg/ton/codec"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

Expand All @@ -18,6 +19,26 @@ const (
ErrorWrongWorkchain tvm.ExitCode = tvm.ExitCode(333)
)

var Builder = builder{
Messages: messageBuilder{
In: inMessageBuilder{
TopUp: codec.TLBCodec[TopUpMessage](),
},
},
}

type inMessageBuilder struct {
TopUp codec.CellCodec[TopUpMessage]
}

type messageBuilder struct {
In inMessageBuilder
}

type builder struct {
Messages messageBuilder
}

// For funding the contract with TON
type TopUpMessage struct {
_ tlb.Magic `tlb:"#d372158c"` //nolint:revive // (opcode) should stay uninitialized
Expand Down
88 changes: 88 additions & 0 deletions pkg/bindings/jetton/minter/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package minter

import (
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/tvm/cell"

"github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton/wallet"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/codec"
)

// JettonMinter opcodes
const (
OpcodeMinterMint = 0x642b7d07
OpcodeMinterChangeAdmin = 0x6501f354
OpcodeMinterClaimAdmin = 0xfb88e119
OpcodeMinterDropAdmin = 0x7431f221
OpcodeMinterBurnNotification = 0x7bdd97de
OpcodeMinterChangeMetadataURL = 0xcb862902
OpcodeWalletBurnNotification = 0x7bdd97de
)

var Builder = builder{
Messages: messageBuilder{
In: inMessageBuilder{
Mint: codec.TLBCodec[MintMessage](),
ChangeAdmin: codec.TLBCodec[ChangeAdminMessage](),
ClaimAdmin: codec.TLBCodec[ClaimAdminMessage](),
DropAdmin: codec.TLBCodec[DropAdminMessage](),
ChangeContent: codec.TLBCodec[ChangeContentMessage](),
Upgrade: codec.TLBCodec[UpgradeMessage](),
},
},
}

type inMessageBuilder struct {
Mint codec.CellCodec[MintMessage]
ChangeAdmin codec.CellCodec[ChangeAdminMessage]
ClaimAdmin codec.CellCodec[ClaimAdminMessage]
DropAdmin codec.CellCodec[DropAdminMessage]
ChangeContent codec.CellCodec[ChangeContentMessage]
Upgrade codec.CellCodec[UpgradeMessage]
}

type messageBuilder struct {
In inMessageBuilder
}

type builder struct {
Messages messageBuilder
}

type MintMessage struct {
_ tlb.Magic `tlb:"#642b7d07"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Destination *address.Address `tlb:"addr"`
TonAmount tlb.Coins `tlb:"."`
MasterMsg wallet.InternalTransferMessage `tlb:"^"`
}

type ChangeAdminMessage struct {
_ tlb.Magic `tlb:"#6501f354"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
NewAdmin *address.Address `tlb:"addr"`
}

type ClaimAdminMessage struct {
_ tlb.Magic `tlb:"#fb88e119"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
}

type DropAdminMessage struct {
_ tlb.Magic `tlb:"#7431f221"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
}

type ChangeContentMessage struct {
_ tlb.Magic `tlb:"#cb862902"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Content *cell.Cell `tlb:"^"`
}

type UpgradeMessage struct {
_ tlb.Magic `tlb:"#2508d66a"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
NewData *cell.Cell `tlb:"^"`
NewCode *cell.Cell `tlb:"^"`
}
49 changes: 0 additions & 49 deletions pkg/bindings/jetton/minter/minter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/xssnick/tonutils-go/tvm/cell"

"github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton"
"github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton/wallet"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/wrappers"
)

Expand All @@ -31,51 +30,3 @@ func Code() (*cell.Cell, error) {
}
return compiledContract, nil
}

// JettonMinter opcodes
const (
OpcodeMinterMint = 0x642b7d07
OpcodeMinterChangeAdmin = 0x6501f354
OpcodeMinterClaimAdmin = 0xfb88e119
OpcodeMinterDropAdmin = 0x7431f221
OpcodeMinterBurnNotification = 0x7bdd97de
OpcodeMinterChangeMetadataURL = 0xcb862902
OpcodeWalletBurnNotification = 0x7bdd97de
)

type MintMessage struct {
_ tlb.Magic `tlb:"#642b7d07"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Destination *address.Address `tlb:"addr"`
TonAmount tlb.Coins `tlb:"."`
MasterMsg wallet.InternalTransferMessage `tlb:"^"`
}

type ChangeAdminMessage struct {
_ tlb.Magic `tlb:"#6501f354"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
NewAdmin *address.Address `tlb:"addr"`
}

type ClaimAdminMessage struct {
_ tlb.Magic `tlb:"#fb88e119"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
}

type DropAdminMessage struct {
_ tlb.Magic `tlb:"#7431f221"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
}

type ChangeContentMessage struct {
_ tlb.Magic `tlb:"#cb862902"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Content *cell.Cell `tlb:"^"`
}

type UpgradeMessage struct {
_ tlb.Magic `tlb:"#2508d66a"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
NewData *cell.Cell `tlb:"^"`
NewCode *cell.Cell `tlb:"^"`
}
84 changes: 84 additions & 0 deletions pkg/bindings/jetton/wallet/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package wallet

import (
"github.com/xssnick/tonutils-go/address"
"github.com/xssnick/tonutils-go/tlb"
"github.com/xssnick/tonutils-go/tvm/cell"

"github.com/smartcontractkit/chainlink-ton/pkg/ton/codec"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// JettonWallet opcodes
const (
OpcodeWalletTransfer = 0x0f8a7ea5
OpcodeWalletTransferNotification = 0x7362d09c
OpcodeWalletInternalTransfer = 0x178d4519
OpcodeWalletExcesses = 0xd53276db
OpcodeWalletBurn = 0x595f07bc
)

const (
BalanceError tvm.ExitCode = tvm.ExitCode(47)
NotEnoughGas tvm.ExitCode = tvm.ExitCode(48)
InvalidMessage tvm.ExitCode = tvm.ExitCode(49)
)

var Builder = builder{
Messages: messageBuilder{
In: inMessageBuilder{
AskToTransfer: codec.TLBCodec[AskToTransfer](),
InternalTransfer: codec.TLBCodec[InternalTransferMessage](),
},
Out: outMessageBuilder{
TransferNotification: codec.TLBCodec[TransferNotification](),
},
},
}

type inMessageBuilder struct {
AskToTransfer codec.CellCodec[AskToTransfer]
InternalTransfer codec.CellCodec[InternalTransferMessage]
}

type outMessageBuilder struct {
TransferNotification codec.CellCodec[TransferNotification]
}

type messageBuilder struct {
In inMessageBuilder
Out outMessageBuilder
}

type builder struct {
Messages messageBuilder
}

type AskToTransfer struct {
_ tlb.Magic `tlb:"#0f8a7ea5"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"."`
Destination *address.Address `tlb:"addr"`
ResponseDestination *address.Address `tlb:"addr"`
CustomPayload *cell.Cell `tlb:"either . ^"`
ForwardTonAmount tlb.Coins `tlb:"."`
ForwardPayload *cell.Cell `tlb:"either . ^"`
}

type InternalTransferMessage struct {
_ tlb.Magic `tlb:"#178d4519"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"."`
From *address.Address `tlb:"addr"`
ResponseAddress *address.Address `tlb:"addr"`
ForwardTonAmount tlb.Coins `tlb:"."`
ForwardPayload *cell.Cell `tlb:"either . ^"`
}

type TransferNotification struct {
_ tlb.Magic `tlb:"#7362d09c"` //nolint:revive // Ignore opcode tag
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"^"`
Sender *address.Address `tlb:"addr"`
ForwardPayload *cell.Cell `tlb:"maybe ^"`
}
45 changes: 0 additions & 45 deletions pkg/bindings/jetton/wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,54 +9,9 @@ import (
"github.com/xssnick/tonutils-go/tvm/cell"

"github.com/smartcontractkit/chainlink-ton/pkg/bindings/jetton"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/wrappers"
)

// JettonWallet opcodes
const (
OpcodeWalletTransfer = 0x0f8a7ea5
OpcodeWalletTransferNotification = 0x7362d09c
OpcodeWalletInternalTransfer = 0x178d4519
OpcodeWalletExcesses = 0xd53276db
OpcodeWalletBurn = 0x595f07bc
)

const (
BalanceError tvm.ExitCode = tvm.ExitCode(47)
NotEnoughGas tvm.ExitCode = tvm.ExitCode(48)
InvalidMessage tvm.ExitCode = tvm.ExitCode(49)
)

type AskToTransfer struct {
_ tlb.Magic `tlb:"#0f8a7ea5"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"."`
Destination *address.Address `tlb:"addr"`
ResponseDestination *address.Address `tlb:"addr"`
CustomPayload *cell.Cell `tlb:"either . ^"`
ForwardTonAmount tlb.Coins `tlb:"."`
ForwardPayload *cell.Cell `tlb:"either . ^"`
}

type InternalTransferMessage struct {
_ tlb.Magic `tlb:"#178d4519"` //nolint:revive // (opcode) should stay uninitialized
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"."`
From *address.Address `tlb:"addr"`
ResponseAddress *address.Address `tlb:"addr"`
ForwardTonAmount tlb.Coins `tlb:"."`
ForwardPayload *cell.Cell `tlb:"either . ^"`
}

type TransferNotification struct {
_ tlb.Magic `tlb:"#7362d09c"` //nolint:revive // Ignore opcode tag
QueryID uint64 `tlb:"## 64"`
Amount tlb.Coins `tlb:"^"`
Sender *address.Address `tlb:"addr"`
ForwardPayload *cell.Cell `tlb:"maybe ^"`
}

var WalletContractPath = path.Join(jetton.PathToContracts, "JettonWallet.compiled.json")

type Provider struct {
Expand Down
12 changes: 0 additions & 12 deletions pkg/ccip/bindings/ccipsendexecutor/ccipsendexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,6 @@ import (

"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/common"
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/onramp"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// CCIPSend Executor opcodes
const (
OpcodeCCIPSendExecutorExecute = 0xAF3C62B3 // crc32('CCIPSendExecutor_Execute')
)

// CCIPSend Executor exit codes
const (
ErrorStateNotExpected tvm.ExitCode = tvm.ExitCode(500)
ErrorUnauthorized tvm.ExitCode = tvm.ExitCode(265) // ERROR_UNAUTHORIZED from contract
)

// CCIPSendExecutor_Execute message structure
Expand Down
37 changes: 37 additions & 0 deletions pkg/ccip/bindings/ccipsendexecutor/codec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package ccipsendexecutor

import (
"github.com/smartcontractkit/chainlink-ton/pkg/ton/codec"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// CCIPSend Executor opcodes
const (
OpcodeCCIPSendExecutorExecute = 0xAF3C62B3 // crc32('CCIPSendExecutor_Execute')
)

// CCIPSend Executor exit codes
const (
ErrorStateNotExpected tvm.ExitCode = tvm.ExitCode(500)
ErrorUnauthorized tvm.ExitCode = tvm.ExitCode(265) // ERROR_UNAUTHORIZED from contract
)

var Builder = builder{
Messages: messageBuilder{
In: inMessageBuilder{
Execute: codec.TLBCodec[Execute](),
},
},
}

type inMessageBuilder struct {
Execute codec.CellCodec[Execute]
}

type messageBuilder struct {
In inMessageBuilder
}

type builder struct {
Messages messageBuilder
}
Loading
Loading