-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathccipsendexecutor.go
More file actions
92 lines (74 loc) · 2.34 KB
/
ccipsendexecutor.go
File metadata and controls
92 lines (74 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package ccipsendexecutor
import (
"math/big"
"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/ccip/bindings/feequoter"
"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')
)
//go:generate go run golang.org/x/tools/cmd/stringer@v0.38.0 -type=ExitCode
type ExitCode tvm.ExitCode
var ExitCodeCodec tvm.ExitCodeCodecInt[ExitCode] = ExitCode(tvm.ExitCode(-1))
func (ExitCode) NewFrom(ec tvm.ExitCode) (ExitCode, error) {
const (
ecMin = int32(ErrorStateNotExpected)
ecMax = int32(ErrorFeeQuoterBounce)
)
return tvm.NewExitCodeInRange(ExitCode(ec), ecMin, ecMax)
}
// CCIPSend Executor exit codes
const (
ErrorStateNotExpected ExitCode = iota + 43600
ErrorUnauthorized
ErrorInsufficientFunds
ErrorInsufficientFee
ErrorFeeQuoterBounce
)
// CCIPSendExecutor_Execute message structure
type Execute struct {
_ tlb.Magic `tlb:"#AF3C62B3" json:"-"` //nolint:revive // Ignore opcode tag
OnRampSend onramp.Send `tlb:"."`
Config *cell.Cell `tlb:"^"`
}
// MessageValidated and MessageValidationFailed are reused from the feequoter package
// to ensure schema consistency with the on-chain FeeQuoter contract responses.
var TLBs = tvm.MustNewTLBMap([]any{
Execute{},
feequoter.MessageValidated{},
feequoter.MessageValidationFailed{},
}).MustWithStorageType(InitialData{})
// Metadata structure
type Metadata struct {
Sender *address.Address `tlb:"addr"`
Value *tlb.Coins `tlb:"."`
}
// CCIPSendExecutor_Config structure
type Config struct {
FeeQuoter *address.Address `tlb:"addr"`
}
// Initial data structure for CCIPSend Executor
type InitialData struct {
OnRamp *address.Address `tlb:"addr"`
MessageID *big.Int `tlb:"## 224"`
}
// Addresses structure
type Addresses struct {
OnRamp *address.Address `tlb:"addr"`
FeeQuoter *address.Address `tlb:"addr"`
}
// State structures
type StateInitialized struct {
}
type StateOnGoingFeeValidation struct {
}
// TokenAmount structure (reused from router package concept)
type TokenAmount struct {
Amount *tlb.Coins `tlb:"."`
Token *address.Address `tlb:"addr"`
}