@@ -59,6 +59,8 @@ type categorizedLogs struct {
5959type pendingPrompt struct {
6060 contractName string
6161 networkName string
62+ contractAddr string
63+ contractData string
6264 needsDeployment bool
6365 needsAlias bool
6466 needsUpdate bool
@@ -125,6 +127,7 @@ type DependencyInstaller struct {
125127 TargetDir string
126128 SkipDeployments bool
127129 SkipAlias bool
130+ SkipUpdatePrompts bool
128131 DeploymentAccount string
129132 Name string
130133 logs categorizedLogs
@@ -165,6 +168,7 @@ func NewDependencyInstaller(logger output.Logger, state *flowkit.State, saveStat
165168 TargetDir : targetDir ,
166169 SkipDeployments : flags .skipDeployments ,
167170 SkipAlias : flags .skipAlias ,
171+ SkipUpdatePrompts : flags .skipUpdatePrompts ,
168172 DeploymentAccount : flags .deploymentAccount ,
169173 Name : flags .name ,
170174 dependencies : make (map [string ]config.Dependency ),
@@ -620,15 +624,24 @@ func (di *DependencyInstaller) handleFoundContract(dependency config.Dependency,
620624 }
621625
622626 // Check if remote source version is different from local version
623- // If it is, defer the prompt until after the tree is displayed
627+ // If it is, defer the prompt until after the tree is displayed (unless skip flag is set)
624628 // If no hash, ignore
625629 if existingDependency != nil && existingDependency .Hash != "" && existingDependency .Hash != originalContractDataHash {
630+ // If skip update prompts flag is set, don't prompt and keep existing version
631+ if di .SkipUpdatePrompts {
632+ msg := util .MessageWithEmojiPrefix ("⏸️ " , fmt .Sprintf ("%s kept at current version (update available)" , dependency .Name ))
633+ di .logs .stateUpdates = append (di .logs .stateUpdates , msg )
634+ return nil
635+ }
636+
626637 // Find existing pending prompt for this contract or create new one
627638 found := false
628639 for i := range di .pendingPrompts {
629640 if di .pendingPrompts [i ].contractName == dependency .Name {
630641 di .pendingPrompts [i ].needsUpdate = true
631642 di .pendingPrompts [i ].updateHash = originalContractDataHash
643+ di .pendingPrompts [i ].contractAddr = contractAddr
644+ di .pendingPrompts [i ].contractData = contractData
632645 found = true
633646 break
634647 }
@@ -637,10 +650,13 @@ func (di *DependencyInstaller) handleFoundContract(dependency config.Dependency,
637650 di .pendingPrompts = append (di .pendingPrompts , pendingPrompt {
638651 contractName : dependency .Name ,
639652 networkName : networkName ,
653+ contractAddr : contractAddr ,
654+ contractData : contractData ,
640655 needsUpdate : true ,
641656 updateHash : originalContractDataHash ,
642657 })
643658 }
659+
644660 return nil
645661 }
646662
@@ -707,14 +723,29 @@ func (di *DependencyInstaller) handleAdditionalDependencyTasks(networkName, cont
707723 // If the contract is not a core contract and the user does not want to skip aliasing, then collect for prompting later
708724 needsAlias := ! di .SkipAlias && ! util .IsCoreContract (contractName ) && ! isDefiActionsContract (contractName )
709725
710- // Only add to pending prompts if we need to prompt for something
726+ // Only add/update pending prompts if we need to prompt for something
711727 if needsDeployment || needsAlias {
712- di .pendingPrompts = append (di .pendingPrompts , pendingPrompt {
713- contractName : contractName ,
714- networkName : networkName ,
715- needsDeployment : needsDeployment ,
716- needsAlias : needsAlias ,
717- })
728+ // Check if a pending prompt already exists for this contract
729+ found := false
730+ for i := range di .pendingPrompts {
731+ if di .pendingPrompts [i ].contractName == contractName {
732+ di .pendingPrompts [i ].needsDeployment = needsDeployment
733+ di .pendingPrompts [i ].needsAlias = needsAlias
734+ if di .pendingPrompts [i ].networkName == "" {
735+ di .pendingPrompts [i ].networkName = networkName
736+ }
737+ found = true
738+ break
739+ }
740+ }
741+ if ! found {
742+ di .pendingPrompts = append (di .pendingPrompts , pendingPrompt {
743+ contractName : contractName ,
744+ networkName : networkName ,
745+ needsDeployment : needsDeployment ,
746+ needsAlias : needsAlias ,
747+ })
748+ }
718749 }
719750
720751 return nil
@@ -932,9 +963,21 @@ func (di *DependencyInstaller) processPendingPrompts() error {
932963 di .Logger .Error (fmt .Sprintf ("Error updating dependency: %v" , err ))
933964 return err
934965 }
966+
967+ // Write the updated contract file
968+ err = di .handleFileSystem (pending .contractAddr , pending .contractName , pending .contractData , pending .networkName )
969+ if err != nil {
970+ di .Logger .Error (fmt .Sprintf ("Error updating contract file: %v" , err ))
971+ return err
972+ }
973+
935974 msg := util .MessageWithEmojiPrefix ("✅" , fmt .Sprintf ("%s updated to latest version" , pending .contractName ))
936975 di .logs .stateUpdates = append (di .logs .stateUpdates , msg )
937976 }
977+ } else {
978+ // User chose not to update - keep the existing file and hash as is
979+ msg := util .MessageWithEmojiPrefix ("⏸️" , fmt .Sprintf ("%s kept at current version" , pending .contractName ))
980+ di .logs .stateUpdates = append (di .logs .stateUpdates , msg )
938981 }
939982 }
940983 }
0 commit comments