Skip to content

Commit 3dcecc4

Browse files
authored
Use address book in deploy TON contracts changeset + general fixes (#226)
* add-address-book-to-deploy-chain-changeset * fix add lanes - onramp dest chain configs when empty * fix ab * fix * fx
1 parent 26be482 commit 3dcecc4

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

deployment/ccip/cs_deploy_ton_chain.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ func (cs DeployCCIPContracts) Apply(env cldf.Environment, config DeployCCIPContr
9292
s.FeeQuoter = *ccipSeqReport.Output.FeeQuoterAddress
9393
s.OffRamp = *ccipSeqReport.Output.OffRampAddress
9494

95-
// Save state
96-
err = state.SaveOnchainState(selector, s, env)
95+
// Get address book
96+
ab, err := state.GetAddressBook(selector, s)
9797
deps.CCIPOnChainState[selector] = s
9898
if err != nil {
9999
return cldf.ChangesetOutput{}, err
@@ -128,5 +128,6 @@ func (cs DeployCCIPContracts) Apply(env cldf.Environment, config DeployCCIPContr
128128
return cldf.ChangesetOutput{
129129
MCMSTimelockProposals: proposals,
130130
Reports: seqReports,
131+
AddressBook: ab,
131132
}, nil
132133
}

deployment/ccip/operation/onramp.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ var UpdateOnRampDestChainConfigsOp = operations.NewOperation(
106106
func updateOnRampDestChainConfigs(b operations.Bundle, deps TonDeps, in UpdateOnRampDestChainConfigsInput) ([][]byte, error) {
107107
addr := deps.CCIPOnChainState[deps.TonChain.Selector].OnRamp
108108

109+
if len(in.Updates) == 0 {
110+
b.Logger.Info("Skipping onramp.updateOnRampDestChainConfigs, no updates")
111+
// Nothing to update
112+
return nil, nil
113+
}
114+
109115
configs := make([]onramp.UpdateDestChainConfig, 0, len(in.Updates))
110116

111117
for selector, update := range in.Updates {

deployment/state/state.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -134,46 +134,46 @@ func (s CCIPChainState) GenerateView(e *cldf.Environment, selector uint64, chain
134134
return tonView, errGroup.Wait()
135135
}
136136

137-
func SaveOnchainState(chainSelector uint64, state CCIPChainState, e cldf.Environment) error {
137+
func GetAddressBook(chainSelector uint64, state CCIPChainState) (cldf.AddressBook, error) {
138138
// TODO: use DataStore
139-
ab := e.ExistingAddresses
139+
ab := cldf.NewMemoryAddressBook()
140140
if !state.LinkTokenAddress.IsAddrNone() {
141141
err := ab.Save(chainSelector, state.LinkTokenAddress.String(), cldf.NewTypeAndVersion(LinkToken, Version1_6_0))
142142
if err != nil {
143-
return err
143+
return nil, err
144144
}
145145
}
146146
if !state.ReceiverAddress.IsAddrNone() {
147147
err := ab.Save(chainSelector, state.ReceiverAddress.String(), cldf.NewTypeAndVersion(TonReceiver, Version1_6_0))
148148
if err != nil {
149-
return err
149+
return nil, err
150150
}
151151
}
152152
if !state.OffRamp.IsAddrNone() {
153153
err := ab.Save(chainSelector, state.OffRamp.String(), cldf.NewTypeAndVersion(OffRamp, Version1_6_0))
154154
if err != nil {
155-
return err
155+
return nil, err
156156
}
157157
}
158158
if !state.Router.IsAddrNone() {
159159
err := ab.Save(chainSelector, state.Router.String(), cldf.NewTypeAndVersion(Router, Version1_6_0))
160160
if err != nil {
161-
return err
161+
return nil, err
162162
}
163163
}
164164
if !state.OnRamp.IsAddrNone() {
165165
err := ab.Save(chainSelector, state.OnRamp.String(), cldf.NewTypeAndVersion(OnRamp, Version1_6_0))
166166
if err != nil {
167-
return err
167+
return nil, err
168168
}
169169
}
170170
if !state.FeeQuoter.IsAddrNone() {
171171
err := ab.Save(chainSelector, state.FeeQuoter.String(), cldf.NewTypeAndVersion(FeeQuoter, Version1_6_0))
172172
if err != nil {
173-
return err
173+
return nil, err
174174
}
175175
}
176-
return nil
176+
return ab, nil
177177
}
178178

179179
func LoadOnchainState(e cldf.Environment) (map[uint64]CCIPChainState, error) {

0 commit comments

Comments
 (0)