@@ -15,6 +15,7 @@ import (
1515 "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
1616 cldf_deployment "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
1717 "github.com/smartcontractkit/chainlink-deployments-framework/operations"
18+ "github.com/smartcontractkit/mcms/types"
1819)
1920
2021var ContractType cldf_deployment.ContractType = "FeeQuoter"
@@ -51,17 +52,19 @@ var Initialize = operations.NewOperation(
5152 Version ,
5253 "Initializes the FeeQuoter 1.6.0 contract" ,
5354 func (b operations.Bundle , chain cldf_solana.Chain , input Params ) (sequences.OnChainOutput , error ) {
55+ fee_quoter .SetProgramID (input .FeeQuoter )
5456 programData , err := utils .GetSolProgramData (chain , input .FeeQuoter )
5557 if err != nil {
5658 return sequences.OnChainOutput {}, fmt .Errorf ("failed to get program data: %w" , err )
5759 }
60+ authority := GetAuthority (chain , input .FeeQuoter )
5861 feeQuoterConfigPDA , _ , _ := state .FindFqConfigPDA (input .FeeQuoter )
5962 instruction , err := fee_quoter .NewInitializeInstruction (
6063 input .MaxFeeJuelsPerMsg ,
6164 input .Router ,
6265 feeQuoterConfigPDA ,
6366 input .LinkToken ,
64- chain . DeployerKey . PublicKey () ,
67+ authority ,
6568 solana .SystemProgramID ,
6669 input .FeeQuoter ,
6770 programData .Address ,
@@ -82,6 +85,7 @@ var AddPriceUpdater = operations.NewOperation(
8285 Version ,
8386 "Adds a price updater to the FeeQuoter 1.6.0 contract" ,
8487 func (b operations.Bundle , chain cldf_solana.Chain , input Params ) (sequences.OnChainOutput , error ) {
88+ fee_quoter .SetProgramID (input .FeeQuoter )
8589 authority := GetAuthority (chain , input .FeeQuoter )
8690 feeQuoterConfigPDA , _ , _ := state .FindFqConfigPDA (input .FeeQuoter )
8791 offRampBillingSignerPDA , _ , _ := state .FindOfframpBillingSignerPDA (input .OffRamp )
@@ -109,6 +113,7 @@ var ConnectChains = operations.NewOperation(
109113 Version ,
110114 "Connects the FeeQuoter 1.6.0 contract to other chains" ,
111115 func (b operations.Bundle , chain cldf_solana.Chain , input ConnectChainsParams ) (sequences.OnChainOutput , error ) {
116+ fee_quoter .SetProgramID (input .FeeQuoter )
112117 isUpdate := false
113118 authority := GetAuthority (chain , input .FeeQuoter )
114119 feeQuoterConfigPDA , _ , _ := state .FindFqConfigPDA (input .FeeQuoter )
@@ -126,7 +131,7 @@ var ConnectChains = operations.NewOperation(
126131 input .DestChainConfig ,
127132 feeQuoterConfigPDA ,
128133 fqRemoteChainPDA ,
129- chain . DeployerKey . PublicKey () ,
134+ authority ,
130135 ).ValidateAndBuild ()
131136 if err != nil {
132137 return sequences.OnChainOutput {}, fmt .Errorf ("failed to build update dest chain instruction: %w" , err )
@@ -156,8 +161,89 @@ var ConnectChains = operations.NewOperation(
156161 },
157162)
158163
164+ var TransferOwnership = operations .NewOperation (
165+ "fee-quoter:transfer-ownership" ,
166+ Version ,
167+ "Transfers ownership of the FeeQuoter 1.6.0 contract to a new authority" ,
168+ func (b operations.Bundle , chain cldf_solana.Chain , input utils.TransferOwnershipParams ) (sequences.OnChainOutput , error ) {
169+ fee_quoter .SetProgramID (input .Program )
170+ authority := GetAuthority (chain , input .Program )
171+ if authority != input .CurrentOwner {
172+ return sequences.OnChainOutput {}, fmt .Errorf ("current owner %s does not match on-chain authority %s" , input .CurrentOwner .String (), authority .String ())
173+ }
174+ configPDA , _ , _ := state .FindConfigPDA (input .Program )
175+ ixn , err := fee_quoter .NewTransferOwnershipInstruction (
176+ input .NewOwner ,
177+ configPDA ,
178+ authority ,
179+ ).ValidateAndBuild ()
180+ if err != nil {
181+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to build add dest chain instruction: %w" , err )
182+ }
183+ if authority != chain .DeployerKey .PublicKey () {
184+ batches , err := utils .BuildMCMSBatchOperation (
185+ chain .Selector ,
186+ []solana.Instruction {ixn },
187+ input .Program .String (),
188+ ContractType .String (),
189+ )
190+ if err != nil {
191+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to execute or create batch: %w" , err )
192+ }
193+ return sequences.OnChainOutput {BatchOps : []types.BatchOperation {batches }}, nil
194+ }
195+
196+ err = chain .Confirm ([]solana.Instruction {ixn })
197+ if err != nil {
198+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to confirm add price updater: %w" , err )
199+ }
200+ return sequences.OnChainOutput {}, nil
201+ },
202+ )
203+
204+ var AcceptOwnership = operations .NewOperation (
205+ "fee-quoter:accept-ownership" ,
206+ Version ,
207+ "Accepts ownership of the FeeQuoter 1.6.0 contract" ,
208+ func (b operations.Bundle , chain cldf_solana.Chain , input utils.TransferOwnershipParams ) (sequences.OnChainOutput , error ) {
209+ fee_quoter .SetProgramID (input .Program )
210+ configPDA , _ , _ := state .FindConfigPDA (input .Program )
211+ ixn , err := fee_quoter .NewAcceptOwnershipInstruction (
212+ configPDA ,
213+ input .NewOwner ,
214+ ).ValidateAndBuild ()
215+ if err != nil {
216+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to build add dest chain instruction: %w" , err )
217+ }
218+ if input .NewOwner != chain .DeployerKey .PublicKey () {
219+ batches , err := utils .BuildMCMSBatchOperation (
220+ chain .Selector ,
221+ []solana.Instruction {ixn },
222+ input .Program .String (),
223+ ContractType .String (),
224+ )
225+ if err != nil {
226+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to execute or create batch: %w" , err )
227+ }
228+ return sequences.OnChainOutput {BatchOps : []types.BatchOperation {batches }}, nil
229+ }
230+
231+ err = chain .Confirm ([]solana.Instruction {ixn })
232+ if err != nil {
233+ return sequences.OnChainOutput {}, fmt .Errorf ("failed to confirm add price updater: %w" , err )
234+ }
235+ return sequences.OnChainOutput {}, nil
236+ },
237+ )
238+
159239func GetAuthority (chain cldf_solana.Chain , program solana.PublicKey ) solana.PublicKey {
160- return chain .DeployerKey .PublicKey ()
240+ programData := fee_quoter.Config {}
241+ feeQuoterConfigPDA , _ , _ := state .FindFqConfigPDA (program )
242+ err := chain .GetAccountDataBorshInto (context .Background (), feeQuoterConfigPDA , & programData )
243+ if err != nil {
244+ return chain .DeployerKey .PublicKey ()
245+ }
246+ return programData .Owner
161247}
162248
163249type Params struct {
0 commit comments