@@ -10,12 +10,53 @@ import (
1010
1111 "github.com/smartcontractkit/chainlink-common/pkg/logger"
1212 cldf_evm "github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
13+ "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
1314 "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1415 deploy "github.com/smartcontractkit/chainlink/deployment"
1516
1617 firedrill_entrypoint_v1_5 "github.com/smartcontractkit/ccip-firedrill-deployment/chains/evm/generated/v1_5/gethwrappers/firedrill_entrypoint"
1718 "github.com/smartcontractkit/ccip-firedrill-deployment/chains/evm/generated/v1_6/gethwrappers/firedrill_entrypoint"
1819 "github.com/smartcontractkit/ccip-firedrill-deployment/deployment/shared"
20+
21+ "github.com/smartcontractkit/chainlink-deployments-framework/operations"
22+ "github.com/smartcontractkit/chainlink/deployment/common/opsutils"
23+ )
24+
25+ type DeployFiredrillInput struct {
26+ ChainSelector uint64
27+ }
28+
29+ var (
30+ DeployFiredrillV1_5 = opsutils .NewEVMDeployOperation [DeployFiredrillInput ](
31+ "DeployFiredrill" ,
32+ & deploy .Version1_5_0 ,
33+ "" ,
34+ shared .FiredrillEntrypointType ,
35+ firedrill_entrypoint_v1_5 .FiredrillEntrypointMetaData ,
36+ & opsutils.ContractOpts {
37+ Version : & deploy .Version1_5_0 ,
38+ EVMBytecode : common .FromHex (firedrill_entrypoint_v1_5 .FiredrillEntrypointMetaData .Bin ),
39+ ZkSyncVMBytecode : []byte {},
40+ },
41+ func (input DeployFiredrillInput ) []any {
42+ return []any {input .ChainSelector }
43+ },
44+ )
45+ DeployFiredrillV1_6 = opsutils .NewEVMDeployOperation [DeployFiredrillInput ](
46+ "DeployFiredrill" ,
47+ & deploy .Version1_6_0 ,
48+ "" ,
49+ shared .FiredrillEntrypointType ,
50+ firedrill_entrypoint .FiredrillEntrypointMetaData ,
51+ & opsutils.ContractOpts {
52+ Version : & deploy .Version1_6_0 ,
53+ EVMBytecode : common .FromHex (firedrill_entrypoint .FiredrillEntrypointMetaData .Bin ),
54+ ZkSyncVMBytecode : []byte {},
55+ },
56+ func (input DeployFiredrillInput ) []any {
57+ return []any {input .ChainSelector }
58+ },
59+ )
1960)
2061
2162type FiredrillEntrypoint interface {
@@ -31,15 +72,11 @@ var _ deployment.ChangeSetV2[shared.FiredrillConfig] = FiredrillDeployRegisterCh
3172type FiredrillDeployRegisterChangeSet struct {}
3273
3374func (c FiredrillDeployRegisterChangeSet ) Apply (e deployment.Environment , config shared.FiredrillConfig ) (deployment.ChangesetOutput , error ) {
34- changesetOutput , err := DeployFiredrillContracts (e , config )
75+ firedrillRef , changesetOutput , err := DeployFiredrillContracts (e , config )
3576 if err != nil {
3677 return deployment.ChangesetOutput {}, err
3778 }
38- err = e .ExistingAddresses .Merge (changesetOutput .AddressBook )
39- if err != nil {
40- return deployment.ChangesetOutput {}, err
41- }
42- err = FiredrillRegisterContracts (e .Logger , changesetOutput .AddressBook , e .BlockChains .EVMChains ()[config .ChainSelector ])
79+ err = FiredrillRegisterContracts (e .Logger , firedrillRef , e .BlockChains .EVMChains ()[config .ChainSelector ])
4380 if err != nil {
4481 return deployment.ChangesetOutput {}, err
4582 }
@@ -67,56 +104,66 @@ func (c FiredrillDeployRegisterChangeSet) VerifyPreconditions(e deployment.Envir
67104 return nil
68105}
69106
70- func DeployFiredrillContracts (e deployment.Environment , config shared.FiredrillConfig ) (deployment.ChangesetOutput , error ) {
71- ds := deployment . NewMemoryAddressBook ()
72- evmChains := e . BlockChains . EVMChains ()
107+ func DeployFiredrillContracts (e deployment.Environment , config shared.FiredrillConfig ) (datastore. AddressRef , deployment.ChangesetOutput , error ) {
108+ ds := datastore . NewMemoryDataStore ()
109+ var ref datastore. AddressRef
73110 switch config .Version {
74111 case deploy .Version1_5_0 :
75- _ , err := deployment .DeployContract (e .Logger , evmChains [config .ChainSelector ], ds , deployFiredrillEntrypointV1_5 )
112+ op , err := operations .ExecuteOperation (
113+ e .OperationsBundle ,
114+ DeployFiredrillV1_5 ,
115+ e .BlockChains .EVMChains ()[config .ChainSelector ],
116+ opsutils.EVMDeployInput [DeployFiredrillInput ]{
117+ ChainSelector : config .ChainSelector ,
118+ DeployInput : DeployFiredrillInput {
119+ ChainSelector : config .ChainSelector ,
120+ },
121+ },
122+ )
76123 if err != nil {
77- return deployment.ChangesetOutput {}, err
124+ return datastore.AddressRef {}, deployment.ChangesetOutput {}, err
125+ }
126+ ref = datastore.AddressRef {
127+ Address : op .Output .Address .Hex (),
128+ ChainSelector : config .ChainSelector ,
129+ Type : datastore .ContractType (shared .FiredrillEntrypointType ),
130+ Version : & deploy .Version1_5_0 ,
78131 }
79132 case deploy .Version1_6_0 :
80- _ , err := deployment .DeployContract (e .Logger , evmChains [config .ChainSelector ], ds , deployFiredrillEntrypoint )
133+ op , err := operations .ExecuteOperation (
134+ e .OperationsBundle ,
135+ DeployFiredrillV1_6 ,
136+ e .BlockChains .EVMChains ()[config .ChainSelector ],
137+ opsutils.EVMDeployInput [DeployFiredrillInput ]{
138+ ChainSelector : config .ChainSelector ,
139+ DeployInput : DeployFiredrillInput {
140+ ChainSelector : config .ChainSelector ,
141+ },
142+ },
143+ )
81144 if err != nil {
82- return deployment.ChangesetOutput {}, err
145+ return datastore.AddressRef {}, deployment.ChangesetOutput {}, err
146+ }
147+ ref = datastore.AddressRef {
148+ Address : op .Output .Address .Hex (),
149+ ChainSelector : config .ChainSelector ,
150+ Type : datastore .ContractType (shared .FiredrillEntrypointType ),
151+ Version : & deploy .Version1_6_0 ,
83152 }
84153 default :
85- return deployment.ChangesetOutput {}, fmt .Errorf ("unknown version %s" , config .Version .String ())
154+ return datastore. AddressRef {}, deployment.ChangesetOutput {}, fmt .Errorf ("unknown version %s" , config .Version .String ())
86155 }
87- return deployment.ChangesetOutput {
88- AddressBook : ds ,
89- }, nil
90- }
91-
92- func deployFiredrillEntrypointV1_5 (chain cldf_evm.Chain ) deployment.ContractDeploy [* firedrill_entrypoint_v1_5.FiredrillEntrypoint ] {
93- address , tx , inst , err := firedrill_entrypoint_v1_5 .DeployFiredrillEntrypoint (chain .DeployerKey , chain .Client , chain .Selector )
94- return deployment.ContractDeploy [* firedrill_entrypoint_v1_5.FiredrillEntrypoint ]{
95- Address : address ,
96- Contract : inst ,
97- Tx : tx ,
98- Tv : deployment .NewTypeAndVersion (shared .FiredrillEntrypointType , deploy .Version1_5_0 ),
99- Err : err ,
100- }
101- }
102-
103- func deployFiredrillEntrypoint (chain cldf_evm.Chain ) deployment.ContractDeploy [* firedrill_entrypoint.FiredrillEntrypoint ] {
104- address , tx , inst , err := firedrill_entrypoint .DeployFiredrillEntrypoint (chain .DeployerKey , chain .Client , chain .Selector )
105- return deployment.ContractDeploy [* firedrill_entrypoint.FiredrillEntrypoint ]{
106- Address : address ,
107- Contract : inst ,
108- Tx : tx ,
109- Tv : deployment .NewTypeAndVersion (shared .FiredrillEntrypointType , deploy .Version1_6_0 ),
110- Err : err ,
156+ err := ds .AddressRefStore .Add (ref )
157+ if err != nil {
158+ return datastore.AddressRef {}, deployment.ChangesetOutput {}, err
111159 }
160+ return ref , deployment.ChangesetOutput {
161+ DataStore : ds ,
162+ }, nil
112163}
113164
114- func FiredrillRegisterContracts (lggr logger.Logger , addressBook deployment.AddressBook , chain cldf_evm.Chain ) error {
115- firedrillEntrypointAddr , err := deployment .SearchAddressBook (addressBook , chain .Selector , shared .FiredrillEntrypointType )
116- if err != nil {
117- return err
118- }
119- firedrillEntrypoint , err := firedrill_entrypoint .NewFiredrillEntrypoint (common .HexToAddress (firedrillEntrypointAddr ), chain .Client )
165+ func FiredrillRegisterContracts (lggr logger.Logger , firedrillRef datastore.AddressRef , chain cldf_evm.Chain ) error {
166+ firedrillEntrypoint , err := firedrill_entrypoint .NewFiredrillEntrypoint (common .HexToAddress (firedrillRef .Address ), chain .Client )
120167 if err != nil {
121168 return err
122169 }
@@ -150,6 +197,6 @@ func FiredrillRegisterContracts(lggr logger.Logger, addressBook deployment.Addre
150197 if err != nil {
151198 return err
152199 }
153- lggr .Infof ("FiredrillEntrypoint register events mined. Address: %s, tx: %s, blockNum: %d" , firedrillEntrypointAddr , tx .Hash (), blockNum )
200+ lggr .Infof ("FiredrillEntrypoint register events mined. Address: %s, tx: %s, blockNum: %d" , firedrillRef . Address , tx .Hash (), blockNum )
154201 return nil
155202}
0 commit comments