Skip to content

Commit 46ec0cd

Browse files
committed
some more cleanup
1 parent 8c2bd72 commit 46ec0cd

4 files changed

Lines changed: 30 additions & 18 deletions

File tree

cmd/chainlink-ton/lock.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Notice: `pkgs.lib.fakeHash` can be used as a placeholder,
22
# but `nix-lock-tidy` will only replace actual hashes.
33
{pkgs}: {
4-
chainlink-ton = "sha256-tqXbFO/Xe+4ySlEMFjDzsnvJJ1JKGxAPnWQGuRBIKrw=";
4+
chainlink-ton = "sha256-u8GR1FCnDYy32On/hpVoMzuWrJuZO3Jmjh7TFmbV8kU=";
55
}

pkg/ccip/chainaccessor/ton_accessor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (a *TONAccessor) LatestMessageTo(ctx context.Context, dest ccipocr3.ChainSe
263263
SkipBytes(40). // Skip to DestChainSelector
264264
FilterBytes(8, query.EQ(binary.BigEndian.AppendUint64(nil, uint64(dest)))).
265265
OrderBy(query.SortByTxLT, query.DESC). // sort by transaction LT new to old
266-
Limit(1). // only get the last one
266+
Limit(1). // only get the last one
267267
Execute(ctx, a.logPoller.GetStore())
268268

269269
if err != nil {

pkg/ccip/provider/provider.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55
"fmt"
66
"sync"
77

8+
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
9+
"github.com/xssnick/tonutils-go/ton"
10+
811
"github.com/smartcontractkit/chainlink-common/pkg/logger"
912
"github.com/smartcontractkit/chainlink-common/pkg/services"
1013
commontypes "github.com/smartcontractkit/chainlink-common/pkg/types"
1114
"github.com/smartcontractkit/chainlink-common/pkg/types/ccipocr3"
12-
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
13-
"github.com/xssnick/tonutils-go/ton"
1415

1516
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/chainaccessor"
1617
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/codec"
@@ -37,37 +38,41 @@ type Provider struct {
3738
services.StateMachine
3839
}
3940

40-
func NewCCIPProvider(lggr logger.Logger,
41+
func NewCCIPProvider(
42+
lggr logger.Logger,
4143
chainSelector ccipocr3.ChainSelector,
4244
client ton.APIClientWrapped,
4345
txm txm.TxManager,
4446
logPoller logpoller.Service,
45-
offRampAddr string,
46-
pluginType uint32) (*Provider, error) {
47-
var err error
47+
cargs commontypes.CCIPProviderArgs,
48+
) (*Provider, error) {
49+
addressCodec := codec.NewAddressCodec()
50+
offRampAddrStr, err := addressCodec.AddressBytesToString(cargs.OffRampAddress)
51+
if err != nil {
52+
return nil, fmt.Errorf("failed to decode offRamp address: %w", err)
53+
}
54+
4855
var ct ocr3types.ContractTransmitter[[]byte]
49-
switch pluginType {
56+
switch cargs.PluginType {
5057
case CCIPPluginTypeCommit:
51-
ct, err = ocr.NewCCIPTransmitter(txm, lggr, offRampAddr, ocr.CommitCallData)
58+
ct, err = ocr.NewCCIPTransmitter(txm, lggr, offRampAddrStr, ocr.CommitCallData)
5259
if err != nil {
5360
return nil, fmt.Errorf("failed to create a CCIP ContractTransmitter for commit plugin: %w", err)
5461
}
5562

5663
case CCIPPluginTypeExecute:
57-
ct, err = ocr.NewCCIPTransmitter(txm, lggr, offRampAddr, ocr.ExecuteCallData)
64+
ct, err = ocr.NewCCIPTransmitter(txm, lggr, offRampAddrStr, ocr.ExecuteCallData)
5865
if err != nil {
5966
return nil, fmt.Errorf("failed to create a CCIP ContractTransmitter for execute plugin: %w", err)
6067
}
6168
default:
62-
return nil, fmt.Errorf("unknown plugin type: %d", pluginType)
69+
return nil, fmt.Errorf("unknown plugin type: %d", cargs.PluginType)
6370
}
6471

65-
// TODO this is pretty much ignored in the core, we need to redesign core to resolve the extraDataCodec map issue if we want to use
66-
// this codec
6772
c := ccipocr3.Codec{
68-
ChainSpecificAddressCodec: codec.NewAddressCodec(),
73+
ChainSpecificAddressCodec: addressCodec,
6974
CommitPluginCodec: codec.NewCommitPluginCodecV1(),
70-
ExecutePluginCodec: codec.NewExecutePluginCodecV1(nil), // TODO extraDataCodec map can't be empty
75+
ExecutePluginCodec: codec.NewExecutePluginCodecV1(cargs.ExtraDataCodecBundle),
7176
TokenDataEncoder: codec.NewTokenDataEncoder(),
7277
SourceChainExtraDataCodec: codec.NewExtraDataDecoder(),
7378
}

pkg/relay/relay.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func (r *Relayer) TON() (commontypes.TONService, error) {
114114
return &r.tonService, nil
115115
}
116116

117-
func (r *Relayer) NewCCIPProvider(ctx context.Context, rargs commontypes.CCIPProviderArgs) (commontypes.CCIPProvider, error) {
117+
func (r *Relayer) NewCCIPProvider(ctx context.Context, cargs commontypes.CCIPProviderArgs) (commontypes.CCIPProvider, error) {
118118
// TODO: store chainSelector within Chain
119119
chainID, err := strconv.ParseInt(r.chain.ID(), 10, 16)
120120
if err != nil {
@@ -133,5 +133,12 @@ func (r *Relayer) NewCCIPProvider(ctx context.Context, rargs commontypes.CCIPPro
133133
}
134134

135135
// TODO: check if rargs.ContractID is offramp address ?
136-
return provider.NewCCIPProvider(r.lggr, ccipocr3.ChainSelector(chainSelector), client, r.chain.TxManager(), r.chain.LogPoller(), rargs.OffRampAddress, rargs.PluginType)
136+
return provider.NewCCIPProvider(
137+
r.lggr,
138+
ccipocr3.ChainSelector(chainSelector),
139+
client,
140+
r.chain.TxManager(),
141+
r.chain.LogPoller(),
142+
cargs,
143+
)
137144
}

0 commit comments

Comments
 (0)