Skip to content

Commit e243140

Browse files
authored
update upgrade reg ops (#370)
1 parent fd9d047 commit e243140

1 file changed

Lines changed: 92 additions & 34 deletions

File tree

deployment/ops/ccip/op_upgrade_registry.go

Lines changed: 92 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,30 @@ var blockVersionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input Bl
9999
return sui_ops.OpTxResult[BlockVersionObjects]{}, fmt.Errorf("failed to create UpgradeRegistry contract: %w", err)
100100
}
101101

102+
ref := bind.Object{Id: input.StateObjectId}
103+
ownerCap := bind.Object{Id: input.OwnerCapObjectId}
104+
encodedCall, err := contract.Encoder().BlockVersion(ref, ownerCap, input.ModuleName, input.Version)
105+
if err != nil {
106+
return sui_ops.OpTxResult[BlockVersionObjects]{}, fmt.Errorf("failed to encode BlockVersion call: %w", err)
107+
}
108+
call, err := sui_ops.ToTransactionCall(encodedCall, input.StateObjectId)
109+
if err != nil {
110+
return sui_ops.OpTxResult[BlockVersionObjects]{}, fmt.Errorf("failed to convert encoded call to TransactionCall: %w", err)
111+
}
112+
if deps.Signer == nil {
113+
b.Logger.Infow("Skipping execution of BlockVersion on UpgradeRegistry as per no Signer provided",
114+
"moduleName", input.ModuleName, "version", input.Version)
115+
return sui_ops.OpTxResult[BlockVersionObjects]{
116+
Digest: "",
117+
PackageId: input.CCIPPackageId,
118+
Objects: BlockVersionObjects{},
119+
Call: call,
120+
}, nil
121+
}
122+
102123
opts := deps.GetCallOpts()
103124
opts.Signer = deps.Signer
104-
tx, err := contract.BlockVersion(
105-
b.GetContext(),
106-
opts,
107-
bind.Object{Id: input.StateObjectId},
108-
bind.Object{Id: input.OwnerCapObjectId},
109-
input.ModuleName,
110-
input.Version,
111-
)
125+
tx, err := contract.Bound().ExecuteTransaction(b.GetContext(), opts, encodedCall)
112126
if err != nil {
113127
return sui_ops.OpTxResult[BlockVersionObjects]{}, fmt.Errorf("failed to execute BlockVersion: %w", err)
114128
}
@@ -122,6 +136,7 @@ var blockVersionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input Bl
122136
Digest: tx.Digest,
123137
PackageId: input.CCIPPackageId,
124138
Objects: BlockVersionObjects{},
139+
Call: call,
125140
}, nil
126141
}
127142

@@ -155,16 +170,30 @@ var unblockVersionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input
155170
return sui_ops.OpTxResult[UnblockVersionObjects]{}, fmt.Errorf("failed to create UpgradeRegistry contract: %w", err)
156171
}
157172

173+
ref := bind.Object{Id: input.StateObjectId}
174+
ownerCap := bind.Object{Id: input.OwnerCapObjectId}
175+
encodedCall, err := contract.Encoder().UnblockVersion(ref, ownerCap, input.ModuleName, input.Version)
176+
if err != nil {
177+
return sui_ops.OpTxResult[UnblockVersionObjects]{}, fmt.Errorf("failed to encode UnblockVersion call: %w", err)
178+
}
179+
call, err := sui_ops.ToTransactionCall(encodedCall, input.StateObjectId)
180+
if err != nil {
181+
return sui_ops.OpTxResult[UnblockVersionObjects]{}, fmt.Errorf("failed to convert encoded call to TransactionCall: %w", err)
182+
}
183+
if deps.Signer == nil {
184+
b.Logger.Infow("Skipping execution of UnblockVersion on UpgradeRegistry as per no Signer provided",
185+
"moduleName", input.ModuleName, "version", input.Version)
186+
return sui_ops.OpTxResult[UnblockVersionObjects]{
187+
Digest: "",
188+
PackageId: input.CCIPPackageId,
189+
Objects: UnblockVersionObjects{},
190+
Call: call,
191+
}, nil
192+
}
193+
158194
opts := deps.GetCallOpts()
159195
opts.Signer = deps.Signer
160-
tx, err := contract.UnblockVersion(
161-
b.GetContext(),
162-
opts,
163-
bind.Object{Id: input.StateObjectId},
164-
bind.Object{Id: input.OwnerCapObjectId},
165-
input.ModuleName,
166-
input.Version,
167-
)
196+
tx, err := contract.Bound().ExecuteTransaction(b.GetContext(), opts, encodedCall)
168197
if err != nil {
169198
return sui_ops.OpTxResult[UnblockVersionObjects]{}, fmt.Errorf("failed to execute UnblockVersion: %w", err)
170199
}
@@ -178,6 +207,7 @@ var unblockVersionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input
178207
Digest: tx.Digest,
179208
PackageId: input.CCIPPackageId,
180209
Objects: UnblockVersionObjects{},
210+
Call: call,
181211
}, nil
182212
}
183213

@@ -212,17 +242,30 @@ var blockFunctionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input B
212242
return sui_ops.OpTxResult[BlockFunctionObjects]{}, fmt.Errorf("failed to create UpgradeRegistry contract: %w", err)
213243
}
214244

245+
ref := bind.Object{Id: input.StateObjectId}
246+
ownerCap := bind.Object{Id: input.OwnerCapObjectId}
247+
encodedCall, err := contract.Encoder().BlockFunction(ref, ownerCap, input.ModuleName, input.FunctionName, input.Version)
248+
if err != nil {
249+
return sui_ops.OpTxResult[BlockFunctionObjects]{}, fmt.Errorf("failed to encode BlockFunction call: %w", err)
250+
}
251+
call, err := sui_ops.ToTransactionCall(encodedCall, input.StateObjectId)
252+
if err != nil {
253+
return sui_ops.OpTxResult[BlockFunctionObjects]{}, fmt.Errorf("failed to convert encoded call to TransactionCall: %w", err)
254+
}
255+
if deps.Signer == nil {
256+
b.Logger.Infow("Skipping execution of BlockFunction on UpgradeRegistry as per no Signer provided",
257+
"moduleName", input.ModuleName, "functionName", input.FunctionName, "version", input.Version)
258+
return sui_ops.OpTxResult[BlockFunctionObjects]{
259+
Digest: "",
260+
PackageId: input.CCIPPackageId,
261+
Objects: BlockFunctionObjects{},
262+
Call: call,
263+
}, nil
264+
}
265+
215266
opts := deps.GetCallOpts()
216267
opts.Signer = deps.Signer
217-
tx, err := contract.BlockFunction(
218-
b.GetContext(),
219-
opts,
220-
bind.Object{Id: input.StateObjectId},
221-
bind.Object{Id: input.OwnerCapObjectId},
222-
input.ModuleName,
223-
input.FunctionName,
224-
input.Version,
225-
)
268+
tx, err := contract.Bound().ExecuteTransaction(b.GetContext(), opts, encodedCall)
226269
if err != nil {
227270
return sui_ops.OpTxResult[BlockFunctionObjects]{}, fmt.Errorf("failed to execute BlockFunction: %w", err)
228271
}
@@ -237,6 +280,7 @@ var blockFunctionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input B
237280
Digest: tx.Digest,
238281
PackageId: input.CCIPPackageId,
239282
Objects: BlockFunctionObjects{},
283+
Call: call,
240284
}, nil
241285
}
242286

@@ -271,17 +315,30 @@ var unblockFunctionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input
271315
return sui_ops.OpTxResult[UnblockFunctionObjects]{}, fmt.Errorf("failed to create UpgradeRegistry contract: %w", err)
272316
}
273317

318+
ref := bind.Object{Id: input.StateObjectId}
319+
ownerCap := bind.Object{Id: input.OwnerCapObjectId}
320+
encodedCall, err := contract.Encoder().UnblockFunction(ref, ownerCap, input.ModuleName, input.FunctionName, input.Version)
321+
if err != nil {
322+
return sui_ops.OpTxResult[UnblockFunctionObjects]{}, fmt.Errorf("failed to encode UnblockFunction call: %w", err)
323+
}
324+
call, err := sui_ops.ToTransactionCall(encodedCall, input.StateObjectId)
325+
if err != nil {
326+
return sui_ops.OpTxResult[UnblockFunctionObjects]{}, fmt.Errorf("failed to convert encoded call to TransactionCall: %w", err)
327+
}
328+
if deps.Signer == nil {
329+
b.Logger.Infow("Skipping execution of UnblockFunction on UpgradeRegistry as per no Signer provided",
330+
"moduleName", input.ModuleName, "functionName", input.FunctionName, "version", input.Version)
331+
return sui_ops.OpTxResult[UnblockFunctionObjects]{
332+
Digest: "",
333+
PackageId: input.CCIPPackageId,
334+
Objects: UnblockFunctionObjects{},
335+
Call: call,
336+
}, nil
337+
}
338+
274339
opts := deps.GetCallOpts()
275340
opts.Signer = deps.Signer
276-
tx, err := contract.UnblockFunction(
277-
b.GetContext(),
278-
opts,
279-
bind.Object{Id: input.StateObjectId},
280-
bind.Object{Id: input.OwnerCapObjectId},
281-
input.ModuleName,
282-
input.FunctionName,
283-
input.Version,
284-
)
341+
tx, err := contract.Bound().ExecuteTransaction(b.GetContext(), opts, encodedCall)
285342
if err != nil {
286343
return sui_ops.OpTxResult[UnblockFunctionObjects]{}, fmt.Errorf("failed to execute UnblockFunction: %w", err)
287344
}
@@ -296,6 +353,7 @@ var unblockFunctionHandler = func(b cld_ops.Bundle, deps sui_ops.OpTxDeps, input
296353
Digest: tx.Digest,
297354
PackageId: input.CCIPPackageId,
298355
Objects: UnblockFunctionObjects{},
356+
Call: call,
299357
}, nil
300358
}
301359

0 commit comments

Comments
 (0)