Skip to content

chore: refactor aptos curse converter constructor as a func. option#673

Draft
gustavogama-cll wants to merge 1 commit intomainfrom
ggama/chore/refactor-aptos-curse-converters-constructor-as-func-option
Draft

chore: refactor aptos curse converter constructor as a func. option#673
gustavogama-cll wants to merge 1 commit intomainfrom
ggama/chore/refactor-aptos-curse-converters-constructor-as-func-option

Conversation

@gustavogama-cll
Copy link
Copy Markdown
Contributor

No description provided.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 12, 2026

🦋 Changeset detected

Latest commit: fc0d2f7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smartcontractkit/mcms Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gustavogama-cll gustavogama-cll marked this pull request as draft March 12, 2026 19:17
@gustavogama-cll gustavogama-cll requested a review from Copilot March 12, 2026 19:17
@gustavogama-cll gustavogama-cll force-pushed the ggama/chore/refactor-aptos-curse-converters-constructor-as-func-option branch from 0162e04 to e86d0c0 Compare March 12, 2026 19:18
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the Aptos timelock converter construction to use a functional-options pattern (allowing selection of MCMS contract variant) and updates call sites accordingly.

Changes:

  • Replaced the dedicated NewCurseTimelockConverter constructor with NewTimelockConverter(...TimelockConverterOption) plus WithMCMSType(...).
  • Updated chainwrapper Aptos converter creation to pass the new option when mcmsType indicates Curse.
  • Adjusted Aptos converter tests to use the new option-based constructor.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
sdk/aptos/timelock_converter_test.go Updates constructor test coverage to use the new option-based API for Curse.
sdk/aptos/timelock_converter.go Introduces TimelockConverterOption / WithMCMSType and routes encoder binding based on selected MCMS type.
chainwrappers/converters.go Switches Aptos converter construction to pass WithMCMSType(MCMSTypeCurse) when indicated by metadata.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +48 to +60
func NewTimelockConverter(opts ...TimelockConverterOption) *TimelockConverter {
converterOptions := timelockConverterOptions{mcmsType: MCMSTypeRegular}
for _, opt := range opts {
opt(&converterOptions)
}

if converterOptions.mcmsType == MCMSTypeCurse {
return &TimelockConverter{
encoderFn: func(address aptos.AccountAddress, client aptos.AptosRpcClient) timelockEncoder {
return curse_mcms.Bind(address, client).CurseMCMS().Encoder()
},
}
}
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change removes the exported NewCurseTimelockConverter constructor entirely. If sdk/aptos is consumed as a library, that’s a breaking API change; consider keeping NewCurseTimelockConverter as a thin wrapper around NewTimelockConverter(WithMCMSType(MCMSTypeCurse)) (optionally marked deprecated) to preserve backward compatibility.

Copilot uses AI. Check for mistakes.
Comment thread sdk/aptos/timelock_converter.go Outdated
},
type TimelockConverterOption func(*timelockConverterOptions)

type timelockConverterOptions struct{
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type timelockConverterOptions struct{ is not gofmt-formatted (missing space before {). CI appears to enforce gofmt/goimports (see .golangci.yml), so this will likely fail formatting checks. Run gofmt on this file (or adjust the declaration) before merging.

Suggested change
type timelockConverterOptions struct{
type timelockConverterOptions struct {

Copilot uses AI. Check for mistakes.
@gustavogama-cll gustavogama-cll requested a review from Copilot March 12, 2026 21:07
@gustavogama-cll gustavogama-cll force-pushed the ggama/chore/refactor-aptos-curse-converters-constructor-as-func-option branch from e86d0c0 to fc0d2f7 Compare March 12, 2026 21:08
@cl-sonarqube-production
Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants