[NONEVM-3516] Develop a custom operation which would top up (all/filtered) contracts from CLD state #10253#592
[NONEVM-3516] Develop a custom operation which would top up (all/filtered) contracts from CLD state #10253#592patricios-space wants to merge 32 commits intomainfrom
Conversation
ef1111e to
a65fa43
Compare
1adba30 to
9dbfea3
Compare
krebernisak
left a comment
There was a problem hiding this comment.
Looking pretty good!
2864e4f to
538d5fc
Compare
fix: use string instead of numbers for options
f02ec2f to
38517a1
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements a new custom operation fund-contracts for the TON deployment framework that enables automated funding of CCIP and MCMS protocol contracts from the CLD (Chainlink Deployment) state. The operation supports two funding modes: TopUp (add only the difference to reach a target balance) and ExactAmount (transfer a fixed amount regardless of current balance), with flexible targeting of specific protocols and MCMS qualifiers.
Changes:
- Added
FundContractsOpoperation with flexible YAML/JSON input parsing using a genericOneOfunmarshaler pattern - Implemented two funding modes (TopUp and ExactAmount) with automatic balance checking for TopUp mode
- Created a reusable
OneOfgeneric type for parsing configuration values that can be either simple strings or objects with nested lists
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| deployment/pkg/ops/ton/fund_contract.go | Core implementation of the fund-contracts operation with contract resolution, balance checking, and message preparation logic |
| deployment/pkg/ops/ton/fund_contract_test.go | Comprehensive unit tests covering input parsing, various target combinations, and error cases |
| deployment/pkg/ops/ton/oneof.go | Generic unmarshaler for flexible YAML/JSON parsing supporting both simple values and objects with items |
| deployment/pkg/ops/ton/fundmode_enumer.go | Generated enum marshaling code for FundMode (TopUp/ExactAmount) |
| deployment/pkg/ops/ton/targetprotocol_enumer.go | Generated enum marshaling code for TargetProtocol (CCIP/MCMS) |
| deployment/pkg/ops/index.go | Registered the new FundContractsOp in the operations registry |
| deployment/go.mod | Promoted gopkg.in/yaml.v3 from indirect to direct dependency for test usage |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
70b76b8 to
b9e4c8b
Compare
deployment/pkg/ops/ton/oneof.go
Outdated
|
|
||
| // OneOf represents a configuration value that can be either: | ||
| // - A simple value: "key" | ||
| // - An object with items: {key: [item1, item2]} |
There was a problem hiding this comment.
I really don't think an input type like this is a requirement to fund a few sets of contracts. It's more complex than it needs to be, and our tooling is already overly complex as is.
The way you describe it here it sounds like a map[string]any, not sure we need a special type
Also, why not just a simple []string input?
There was a problem hiding this comment.
btw. we need to consider we already have the TON addr input resolver implemented, so funding addresses is as easy as:
- 0035_via_mcms_test_transfer_value:
payload:
anySequenceIn:
defs:
- id: "ton/ops/send-messages"
version: "0.1.0"
inputs:
- messages:
- bounce: true
dstAddr:
resolver: "codec.resolvers.address-ref-to-ton-addr"
data:
type: "RBACTimelock"
qualifier: "RMNMCMS"
amount: "10000000" # 0.01 TON = 10000000 nanoTON
- bounce: false
dstAddr:
resolver: "codec.resolvers.address-ref-to-ton-addr"
data:
type: "Router"
amount: "10000000" # 0.01 TON = 10000000 nanoTON
plan: false # Will get executed immediately without going through MCMS
options:
chainSelector: 13879075125137744094 # TON Localnet
So we can basically just prepare funding configuration (above) and execute when we'd want to fund.
What exactly else would we need form this operation/PR?
There was a problem hiding this comment.
Yes, this was built before an TON address resolver being available. We should still be able to define a target balance and let the operation do the math.
There was a problem hiding this comment.
reworked the operation into a top-up resolver
NONEVM-3516