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
12 changes: 6 additions & 6 deletions deployment/ccip/1_6_0/sequences/connect_chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ var ConfigureLaneLegAsSource = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -228,7 +228,7 @@ var ConfigureLaneLegAsSource = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -256,7 +256,7 @@ var ConfigureLaneLegAsSource = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -286,7 +286,7 @@ var ConfigureLaneLegAsSource = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -344,7 +344,7 @@ var ConfigureLaneLegAsDest = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand All @@ -371,7 +371,7 @@ var ConfigureLaneLegAsDest = cldf_ops.NewSequence(
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down
10 changes: 8 additions & 2 deletions deployment/ccip/1_6_0/sequences/fastcurse.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,10 @@ func (a *TonCurseAdapter) Curse() *cldf_ops.Sequence[api.CurseInput, sequences.O

out := sequences.OnChainOutput{}
meta := []types.OperationMetadata{
{ContractType: contractType, Tags: []string{}}, // TODO: add appropriate tags
{
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
}, // TODO: add appropriate tags
}

return mcms.WithOperationOutput(out, r.Output, types.ChainSelector(in.ChainSelector), meta)
Expand Down Expand Up @@ -401,7 +404,10 @@ func (a *TonCurseAdapter) Uncurse() *cldf_ops.Sequence[api.CurseInput, sequences

out := sequences.OnChainOutput{}
meta := []types.OperationMetadata{
{ContractType: contractType, Tags: []string{}}, // TODO: add appropriate tags
{
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
}, // TODO: add appropriate tags
}

return mcms.WithOperationOutput(out, r.Output, types.ChainSelector(in.ChainSelector), meta)
Expand Down
4 changes: 2 additions & 2 deletions deployment/ccip/1_6_0/sequences/transfer_ownership.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (a *TonTransferOwnershipAdapter) SequenceTransferOwnershipViaMCMS() *cldfop
plan := !deployerAddr.Equals(currentOwner)
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -218,7 +218,7 @@ func (a *TonTransferOwnershipAdapter) SequenceAcceptOwnership() *cldfops.Sequenc
plan := !sender.Equals(proposedOwner)
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down
2 changes: 1 addition & 1 deletion deployment/ccip/sequence/deploy_ccip.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func deployCCIPSequence(b operations.Bundle, dp *dep.DependencyProvider, in Depl
// Fetch the contract code using the Fully Qualified Name of the contracts instead of the types used in the datastore
retrieveContractsOpts := utils.RetrieveCompiledContractsOpts{
Package: contractsPackage,
Contracts: []string{
Contracts: []tvm.FullyQualifiedType{
bindings.TypeRouter,
bindings.TypeFeeQuoter,
bindings.TypeOffRamp,
Expand Down
10 changes: 5 additions & 5 deletions deployment/ccip/sequence/update_lanes.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func updateLanes(b cldf_ops.Bundle, dp *dep.DependencyProvider, in UpdateTonLane
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -152,7 +152,7 @@ func updateLanes(b cldf_ops.Bundle, dp *dep.DependencyProvider, in UpdateTonLane
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(opston.AsCells(r.Output.Plans), plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand All @@ -179,7 +179,7 @@ func updateLanes(b cldf_ops.Bundle, dp *dep.DependencyProvider, in UpdateTonLane
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down Expand Up @@ -207,7 +207,7 @@ func updateLanes(b cldf_ops.Bundle, dp *dep.DependencyProvider, in UpdateTonLane
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand All @@ -233,7 +233,7 @@ func updateLanes(b cldf_ops.Bundle, dp *dep.DependencyProvider, in UpdateTonLane
plan := !sender.Equals(owner) // plan if sender is not owner
_inputMCMS.Add(r.Output, plan, []types.OperationMetadata{
{
ContractType: contractType,
ContractType: string(contractType), // TODO: Is this a place where we are mixing types? Should we convert to string or map to short type?
Tags: []string{},
},
})
Expand Down
2 changes: 1 addition & 1 deletion deployment/pkg/ops/mcms/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func deployMCMSSequence(b cldfops.Bundle, dp *dep.DependencyProvider, in DeployM

retrieveContractsInput := utils.RetrieveCompiledContractsOpts{
Package: contractsPackage,
Contracts: []string{
Contracts: []tvm.FullyQualifiedType{
bindings.TypeTimelock,
bindings.TypeMCMS,
},
Expand Down
4 changes: 2 additions & 2 deletions deployment/pkg/ops/ton/send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func messageEnvelopeRoundTrip(t *testing.T, seed int64, iterations int, writeArt
}
}

func testMakeExecuteOp(t *testing.T, contract string, opcode uint64, decoded *codec.MessageEnvelope[any]) operations.Report[ton.SendMessagesInput, ton.SendMessagesOutput] {
func testMakeExecuteOp(t *testing.T, contract tvm.FullyQualifiedType, opcode uint64, decoded *codec.MessageEnvelope[any]) operations.Report[ton.SendMessagesInput, ton.SendMessagesOutput] {
t.Helper()

// Setup execution environment
Expand Down Expand Up @@ -243,7 +243,7 @@ func testMakeExecuteOp(t *testing.T, contract string, opcode uint64, decoded *co
return r
}

func testMakeExecuteSeq(t *testing.T, contract string, envelopes []*codec.MessageEnvelope[any]) {
func testMakeExecuteSeq(t *testing.T, contract tvm.FullyQualifiedType, envelopes []*codec.MessageEnvelope[any]) {
t.Helper()

n := len(envelopes)
Expand Down
5 changes: 3 additions & 2 deletions deployment/pkg/ops/ton/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/smartcontractkit/chainlink-ton/pkg/bindings"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/codec"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tlbe"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// PlannerOption is an interface an op IN type providing
Expand Down Expand Up @@ -122,8 +123,8 @@ type ContractCodeProvider interface {

// Describes a contract by its package and identifier, used to retrieve compiled code from a ContractCodeProvider.
type ContractMetadata struct {
Package string `json:"package"` // Name of the package where the contract is defined (e.g., "github.com/smartcontractkit/chainlink-ton@contracts/v1.6.3")
ID string `json:"id"` // Contract identifier within the package (indexed by fully qualified name e.g., "link.chain.ton.mcms.RBACTimelock")
Package string `json:"package"` // Name of the package where the contract is defined (e.g., "github.com/smartcontractkit/chainlink-ton@contracts/v1.6.3")
ID tvm.FullyQualifiedType `json:"id"` // Contract identifier within the package
}

func (m ContractMetadata) Key() string {
Expand Down
8 changes: 5 additions & 3 deletions deployment/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,18 @@ import (

"github.com/Masterminds/semver/v3"
"github.com/rs/zerolog/log"
ds "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
"github.com/xssnick/tonutils-go/address"
"golang.org/x/sync/errgroup"

ds "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
cldf "github.com/smartcontractkit/chainlink-deployments-framework/deployment"

"github.com/smartcontractkit/chainlink-ton/deployment/view/feequoter"
"github.com/smartcontractkit/chainlink-ton/deployment/view/offramp"
"github.com/smartcontractkit/chainlink-ton/deployment/view/onramp"
"github.com/smartcontractkit/chainlink-ton/deployment/view/router"
"github.com/smartcontractkit/chainlink-ton/pkg/bindings"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// Duplicates of chainlink/deployment/ccip/ to avoid import loops
Expand Down Expand Up @@ -47,7 +49,7 @@ var (

// TODO: Currently we cannot unify to use only the long format from pkg/bindings/index.go everywhere,
// Is there a cleaner way to manage these two types together?
var LongToShortContractType = map[string]ds.ContractType{
var LongToShortContractType = map[tvm.FullyQualifiedType]ds.ContractType{
bindings.TypeRouter: Router,
bindings.TypeFeeQuoter: FeeQuoter,
bindings.TypeOnRamp: OnRamp,
Expand Down
19 changes: 10 additions & 9 deletions deployment/utils/compiled_contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/smartcontractkit/chainlink-ton/deployment/ccip/helpers"
"github.com/smartcontractkit/chainlink-ton/deployment/pkg/ops/ton"
"github.com/smartcontractkit/chainlink-ton/pkg/bindings"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/wrappers"
)

Expand Down Expand Up @@ -47,16 +48,16 @@ type ContractEntryMetadata struct {

// ContractPackageMetadata is the schema for contracts-pkg.json bundled in each release.
type ContractPackageMetadata struct {
Version string `json:"version"`
Contracts map[string]ContractEntryMetadata `json:"contracts"`
Version string `json:"version"`
Contracts map[tvm.FullyQualifiedType]ContractEntryMetadata `json:"contracts"`
}

// defaultPackageMetadata is used as a fallback for releases prior to the introduction of
// contracts-pkg.json (before 1.6.1). All contracts are assigned version 1.6.0 with their
// original filenames.
var defaultPackageMetadata = &ContractPackageMetadata{
Version: "1.6.0",
Contracts: map[string]ContractEntryMetadata{
Contracts: map[tvm.FullyQualifiedType]ContractEntryMetadata{
bindings.TypeRouter: {Path: "Router.compiled.json", Version: "1.6.0"},
bindings.TypeFeeQuoter: {Path: "FeeQuoter.compiled.json", Version: "1.6.0"},
bindings.TypeOnRamp: {Path: "OnRamp.compiled.json", Version: "1.6.0"},
Expand All @@ -77,15 +78,15 @@ var defaultPackageMetadata = &ContractPackageMetadata{
// - local (maps to {repo-root}/contracts/build)
type RetrieveCompiledContractsOpts struct {
Package string
Contracts []string // Fully qualified contract names from pkg/bindings/index.go (e.g. bindings.TypeRouter)
PkgsDir string // optional base directory for the local package cache (passed through to DownloadArtifacts)
Contracts []tvm.FullyQualifiedType // Fully qualified contract names from pkg/bindings/index.go (e.g. bindings.TypeRouter)
PkgsDir string // optional base directory for the local package cache (passed through to DownloadArtifacts)
}

// RetrieveCompiledTONContracts resolves the package path, reads the package metadata,
// and loads each requested contract individually from disk.
// returns map[string]ton.CompiledContract, keyed by Fully Qualified Name (e.g. bindings.TypeRouter = link.chain.ton.ccip.Router)
// returns map[tvm.FullyQualifiedType]ton.CompiledContract, keyed by Fully Qualified Name (e.g. bindings.TypeRouter = link.chain.ton.ccip.Router)

func RetrieveCompiledTONContracts(ctx context.Context, log logger.Logger, in *RetrieveCompiledContractsOpts) (map[string]ton.CompiledContract, error) {
func RetrieveCompiledTONContracts(ctx context.Context, log logger.Logger, in *RetrieveCompiledContractsOpts) (map[tvm.FullyQualifiedType]ton.CompiledContract, error) {
if in == nil {
return nil, errors.New("input options cannot be nil")
}
Expand All @@ -107,13 +108,13 @@ func RetrieveCompiledTONContracts(ctx context.Context, log logger.Logger, in *Re
contractNames := in.Contracts
if len(contractNames) == 0 {
// No filter: collect all contract names from metadata.
contractNames = make([]string, 0, len(meta.Contracts))
contractNames = make([]tvm.FullyQualifiedType, 0, len(meta.Contracts))
for contractName := range meta.Contracts {
contractNames = append(contractNames, contractName)
}
}

compiledContracts := make(map[string]ton.CompiledContract, len(contractNames))
compiledContracts := make(map[tvm.FullyQualifiedType]ton.CompiledContract, len(contractNames))
for _, contractName := range contractNames {
contract, err := ReadCompiledContract(ton.ContractMetadata{Package: in.Package, ID: contractName}, pkgPath, meta)
if err != nil {
Expand Down
12 changes: 7 additions & 5 deletions deployment/utils/compiled_contracts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (

"github.com/smartcontractkit/chainlink-ton/deployment/pkg/ops/ton"
"github.com/smartcontractkit/chainlink-ton/pkg/bindings"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// Sample compiled contract JSON (minimal valid Tolk compiled contract)
Expand Down Expand Up @@ -375,9 +376,10 @@ func TestReadPackageMetadata_WithValidFile(t *testing.T) {
result, err := LoadPackageMetadata(dir)
require.NoError(t, err)
assert.Equal(t, "1.6.3", result.Version)
require.Contains(t, result.Contracts, "link.chain.ton.ccip.Router")
assert.Equal(t, "Router.compiled.json", result.Contracts["link.chain.ton.ccip.Router"].Path)
assert.Equal(t, "1.6.3", result.Contracts["link.chain.ton.ccip.Router"].Version)
const rtType = tvm.FullyQualifiedType("link.chain.ton.ccip.Router")
require.Contains(t, result.Contracts, rtType)
assert.Equal(t, "Router.compiled.json", result.Contracts[rtType].Path)
assert.Equal(t, "1.6.3", result.Contracts[rtType].Version)
}

func TestReadPackageMetadata_MissingFileUsesFallback(t *testing.T) {
Expand Down Expand Up @@ -417,7 +419,7 @@ func writePkgDir(t *testing.T, pkgMeta *ContractPackageMetadata) string {
func testReceiverMeta(version string) *ContractPackageMetadata {
return &ContractPackageMetadata{
Version: version,
Contracts: map[string]ContractEntryMetadata{
Contracts: map[tvm.FullyQualifiedType]ContractEntryMetadata{
bindings.TypeTestReceiver: {Path: "ccip.test.receiver.compiled.json", Version: version},
},
}
Expand Down Expand Up @@ -471,7 +473,7 @@ func TestReadCompiledContract_InvalidVersionInMetadata(t *testing.T) {
dir := t.TempDir()
meta := &ContractPackageMetadata{
Version: "1.6.3",
Contracts: map[string]ContractEntryMetadata{
Contracts: map[tvm.FullyQualifiedType]ContractEntryMetadata{
bindings.TypeTestReceiver: {Path: "ccip.test.receiver.compiled.json", Version: "not-a-version"},
},
}
Expand Down
4 changes: 2 additions & 2 deletions deployment/utils/operation/deploy_ton_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

type DeployContractInput struct {
Name string
Name tvm.FullyQualifiedType
Storage any
MessageBody any
ContractCode *cell.Cell
Expand All @@ -46,7 +46,7 @@ var DeployTONContractOp = cldfops.NewOperation(
)

func (i *DeployContractInput) Validate() error {
if strings.TrimSpace(i.Name) == "" {
if strings.TrimSpace(string(i.Name)) == "" {
return errors.New("name field is required")
}
if i.ContractCode == nil {
Expand Down
7 changes: 4 additions & 3 deletions integration-tests/deployment/mcms/cs_deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ import (
"github.com/xssnick/tonutils-go/tlb"

chainsel "github.com/smartcontractkit/chain-selectors"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
mcmstypes "github.com/smartcontractkit/mcms/types"

"github.com/smartcontractkit/chainlink-common/pkg/logger"

cldfchain "github.com/smartcontractkit/chainlink-deployments-framework/chain"
cldfops "github.com/smartcontractkit/chainlink-deployments-framework/operations"

Expand Down Expand Up @@ -199,7 +200,7 @@ func TestDeployMCMSWithDeployerAPI(t *testing.T) {
mcmsAddr := suiteState.Proposer
tv, err := tvm.CallGetter(ctx, chain.Client, mc, mcmsAddr, toncommon.GetTypeAndVersion)
require.NoError(t, err)
require.Equal(t, bindings.TypeMCMS, tv.Type, "MCMS contract type should match")
require.EqualValues(t, bindings.TypeMCMS, tv.Type, "MCMS contract type should match")
t.Log("Verified MCMS contract type and version")

config, err := tvm.CallGetterLatest(ctx, chain.Client, mcmsAddr, mcms.GetConfig)
Expand Down Expand Up @@ -227,7 +228,7 @@ func TestDeployMCMSWithDeployerAPI(t *testing.T) {
mcmsAddr = suiteState.Proposer
tv, err = tvm.CallGetter(ctx, chain.Client, mc, mcmsAddr, toncommon.GetTypeAndVersion)
require.NoError(t, err)
require.Equal(t, bindings.TypeMCMS, tv.Type, "MCMS contract type should match")
require.EqualValues(t, bindings.TypeMCMS, tv.Type, "MCMS contract type should match")
t.Log("Verified MCMS contract type and version")

timelockAddr = suiteState.Timelock
Expand Down
3 changes: 2 additions & 1 deletion pkg/bindings/getters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/onramp"
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/ownable2step"
"github.com/smartcontractkit/chainlink-ton/pkg/ccip/bindings/router"
"github.com/smartcontractkit/chainlink-ton/pkg/ton/tvm"
)

// GetterMap is a map of getter method names to their Getter definitions.
Expand All @@ -19,7 +20,7 @@ type GetterMap map[string]interface{}
// The outer map keys are contract type identifiers (e.g., "link.chain.ton.ccip.Router").
// The inner map keys are getter method names (e.g., "owner", "onRamp").
// The values are Getter[A, R] instances representing typed getter methods.
var TypeToGetterMap = map[string]GetterMap{
var TypeToGetterMap = map[tvm.FullyQualifiedType]GetterMap{
// CCIP contract types
TypeRouter: {
"owner": router.GetOwner,
Expand Down
Loading
Loading