@@ -17,12 +17,13 @@ import (
1717 "github.com/spf13/cobra"
1818
1919 "github.com/smartcontractkit/chainlink-deployments-framework/datastore"
20+ "github.com/smartcontractkit/chainlink-deployments-framework/deployment"
2021 "github.com/smartcontractkit/chainlink-testing-framework/framework/components/blockchain"
2122 "github.com/smartcontractkit/chainlink-testing-framework/seth"
2223
2324 keystone_changeset "github.com/smartcontractkit/chainlink/deployment/keystone/changeset"
24- "github.com/smartcontractkit/chainlink/system-tests/lib/cre/contracts"
2525 "github.com/smartcontractkit/chainlink/system-tests/lib/cre/environment"
26+ envconfig "github.com/smartcontractkit/chainlink/system-tests/lib/cre/environment/config"
2627 creworkflow "github.com/smartcontractkit/chainlink/system-tests/lib/cre/workflow"
2728)
2829
@@ -166,7 +167,7 @@ func deployWorkflowCmd() *cobra.Command {
166167 if workflowRegistryAddressFlag != "" {
167168 workflowRegistryAddress = workflowRegistryAddressFlag
168169 } else {
169- addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry . String () )
170+ addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry )
170171 if addrErr != nil {
171172 return errors .Wrap (addrErr , "❌ failed to get workflow registry address from state file" )
172173 }
@@ -179,7 +180,7 @@ func deployWorkflowCmd() *cobra.Command {
179180 if capabilitiesRegistryAddressFlag != "" {
180181 capabilitiesRegistryAddress = capabilitiesRegistryAddressFlag
181182 } else {
182- addrRef , addrErr := addressRefFromStateFile (keystone_changeset .CapabilitiesRegistry . String () )
183+ addrRef , addrErr := addressRefFromStateFile (keystone_changeset .CapabilitiesRegistry )
183184 if addrErr != nil {
184185 return errors .Wrap (addrErr , "❌ failed to get capabilities registry address from state file" )
185186 }
@@ -259,7 +260,7 @@ func deleteWorkflowCmd() *cobra.Command {
259260 workflowRegistryAddress = workflowRegistryAddressFlag
260261 contractsVersion = semver .MustParse (contractsVersionFlag )
261262 } else {
262- addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry . String () )
263+ addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry )
263264 if addrErr != nil {
264265 return errors .Wrap (addrErr , "❌ failed to get workflow registry address from state file" )
265266 }
@@ -340,7 +341,7 @@ func deleteAllWorkflowsCmd() *cobra.Command {
340341 workflowRegistryAddress = workflowRegistryAddressFlag
341342 contractsVersion = semver .MustParse (contractsVersionFlag )
342343 } else {
343- addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry . String () )
344+ addrRef , addrErr := addressRefFromStateFile (keystone_changeset .WorkflowRegistry )
344345 if addrErr != nil {
345346 return errors .Wrap (addrErr , "❌ failed to get workflow registry address from state file" )
346347 }
@@ -541,24 +542,23 @@ func isBase64Content(content string) bool {
541542 return err == nil
542543}
543544
544- func addressRefFromStateFile (contractType string ) (datastore.AddressRef , error ) {
545- envArtifact , artErr := environment .ReadEnvArtifact (environment .MustEnvArtifactAbsPath (relativePathToRepoRoot ))
546- if artErr != nil {
547- return datastore.AddressRef {}, errors .Wrap (artErr , "failed to read environment artifact" )
545+ func addressRefFromStateFile (contractType deployment.ContractType ) (* datastore.AddressRef , error ) {
546+ in := & envconfig.Config {}
547+ err := in .Load (envconfig .MustLocalCREStateFileAbsPath (relativePathToRepoRoot ))
548+ if err != nil {
549+ return nil , errors .Wrap (err , "failed to load state file" )
548550 }
549551
550- ds := datastore .NewMemoryDataStore ()
551- for _ , addrRef := range envArtifact .AddressRefs {
552- addErr := ds .AddressRefStore .Add (addrRef )
553- if addErr != nil {
554- return datastore.AddressRef {}, fmt .Errorf ("failed to add address ref to datastore %v: %w" , addrRef , addErr )
555- }
552+ addresses , aErr := in .GetAddresses ()
553+ if aErr != nil {
554+ return nil , errors .Wrap (aErr , "failed to get addresses from cached input" )
556555 }
557556
558- contractVersion , ok := envArtifact .ContractVersions [contractType ]
559- if ! ok {
560- return datastore.AddressRef {}, fmt .Errorf ("no contract version for contract type %s found in environment artifact" , contractType )
557+ for _ , addrRef := range addresses {
558+ if datastore .ContractType (contractType ) == addrRef .Type {
559+ return & addrRef , nil
560+ }
561561 }
562562
563- return contracts . MustGetAddressRefFromDataStore ( ds . Seal (), envArtifact . RegistryChainSelector , contractType , contractVersion , "" ), nil
563+ return nil , fmt . Errorf ( "did not find any address for %s contract" , contractType )
564564}
0 commit comments