Skip to content

Commit 693922f

Browse files
authored
feat: port run changeset from chainlink (#32)
1 parent 6d9010c commit 693922f

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

common/changeset/run_changeset.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package changeset
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/smartcontractkit/chainlink-deployments-framework/deployment"
7+
)
8+
9+
type WrappedChangeSet[C any] struct {
10+
operation deployment.ChangeSetV2[C]
11+
}
12+
13+
// RunChangeset is used to run a changeset in another changeset
14+
// It executes VerifyPreconditions internally to handle changeset errors.
15+
func RunChangeset[C any](
16+
operation deployment.ChangeSetV2[C],
17+
env deployment.Environment,
18+
config C,
19+
) (deployment.ChangesetOutput, error) {
20+
cs := WrappedChangeSet[C]{operation: operation}
21+
22+
err := cs.operation.VerifyPreconditions(env, config)
23+
if err != nil {
24+
return deployment.ChangesetOutput{}, fmt.Errorf("failed to run precondition: %w", err)
25+
}
26+
27+
return cs.operation.Apply(env, config)
28+
}

0 commit comments

Comments
 (0)