@@ -45,11 +45,10 @@ pub enum PublishedAtError {
45
45
} ,
46
46
}
47
47
48
- /// Update the `Move.lock` file with automated address management info.
49
- /// Expects a wallet context, the publish or upgrade command, its response.
50
- /// The `Move.lock` principally file records the published address (i.e., package ID) of
51
- /// a package under an environment determined by the wallet context config. See the
52
- /// `ManagedPackage` type in the lock file for a complete spec.
48
+ /// Update the `Move.lock` file with automated address management info. Expects a wallet context,
49
+ /// the publish or upgrade command, and its response. The `Move.lock` file principally records the
50
+ /// published address (i.e., package ID) of a package under an environment determined by the wallet
51
+ /// context config. See the `ManagedPackage` type in the lock file for a complete spec.
53
52
pub async fn update_lock_file (
54
53
context : & WalletContext ,
55
54
command : LockCommand ,
@@ -65,7 +64,33 @@ pub async fn update_lock_file(
65
64
. get_chain_identifier ( )
66
65
. await
67
66
. context ( "Network issue: couldn't determine chain identifier for updating Move.lock" ) ?;
67
+ let env = context. config . get_active_env ( ) . context (
68
+ "Could not resolve environment from active wallet context. \
69
+ Try ensure `sui client active-env` is valid.",
70
+ ) ?;
71
+ update_lock_file_for_chain_env (
72
+ & chain_identifier,
73
+ & env. alias ,
74
+ command,
75
+ install_dir,
76
+ lock_file,
77
+ response,
78
+ )
79
+ . await
80
+ }
68
81
82
+ /// Update the `Move.lock` file with automated address management info. Expects a chain identifier,
83
+ /// env alias, the publish or upgrade command, and its response. The `Move.lock` file principally
84
+ /// records the published address (i.e., package ID) of a package under an environment in the given
85
+ /// chain. See the `ManagedPackage` type in the lock file for a complete spec.
86
+ pub async fn update_lock_file_for_chain_env (
87
+ chain_identifier : & str ,
88
+ env_alias : & str ,
89
+ command : LockCommand ,
90
+ install_dir : Option < PathBuf > ,
91
+ lock_file : Option < PathBuf > ,
92
+ response : & SuiTransactionBlockResponse ,
93
+ ) -> Result < ( ) , anyhow:: Error > {
69
94
let ( original_id, version, _) = get_new_package_obj_from_response ( response) . context (
70
95
"Expected a valid published package response but didn't see \
71
96
one when attempting to update the `Move.lock`.",
@@ -78,24 +103,20 @@ pub async fn update_lock_file(
78
103
)
79
104
} ;
80
105
let install_dir = install_dir. unwrap_or ( PathBuf :: from ( "." ) ) ;
81
- let env = context. config . get_active_env ( ) . context (
82
- "Could not resolve environment from active wallet context. \
83
- Try ensure `sui client active-env` is valid.",
84
- ) ?;
85
106
86
107
let mut lock = LockFile :: from ( install_dir. clone ( ) , & lock_file) ?;
87
108
match command {
88
109
LockCommand :: Publish => lock_file:: schema:: update_managed_address (
89
110
& mut lock,
90
- & env . alias ,
111
+ env_alias ,
91
112
lock_file:: schema:: ManagedAddressUpdate :: Published {
92
- chain_id : chain_identifier,
113
+ chain_id : chain_identifier. to_string ( ) ,
93
114
original_id : original_id. to_string ( ) ,
94
115
} ,
95
116
) ,
96
117
LockCommand :: Upgrade => lock_file:: schema:: update_managed_address (
97
118
& mut lock,
98
- & env . alias ,
119
+ env_alias ,
99
120
lock_file:: schema:: ManagedAddressUpdate :: Upgraded {
100
121
latest_id : original_id. to_string ( ) ,
101
122
version : version. into ( ) ,
0 commit comments