99 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/client"
1010 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/connection"
1111 "github.com/oasisprotocol/oasis-sdk/client-sdk/go/modules/rofl"
12+ "github.com/oasisprotocol/oasis-sdk/client-sdk/go/types"
1213
1314 buildRofl "github.com/oasisprotocol/cli/build/rofl"
1415 "github.com/oasisprotocol/cli/cmd/common"
@@ -31,7 +32,6 @@ var setAdminCmd = &cobra.Command{
3132 newAdminArg string
3233 manifest * buildRofl.Manifest
3334 deployment * buildRofl.Deployment
34- useManifest bool
3535 )
3636 switch len (args ) {
3737 case 2 :
@@ -46,7 +46,6 @@ var setAdminCmd = &cobra.Command{
4646 NeedAdmin : true ,
4747 })
4848 rawAppID = deployment .AppID
49- useManifest = true
5049 }
5150
5251 var appID rofl.AppID
@@ -70,62 +69,56 @@ var setAdminCmd = &cobra.Command{
7069 cobra .CheckErr (err )
7170 }
7271
73- // Build the update body.
72+ fmt .Printf ("App ID: %s\n " , appID )
73+
7474 updateBody := rofl.Update {
7575 ID : appID ,
7676 Admin : newAdminAddr ,
7777 }
7878
79- if useManifest {
79+ var oldAdminAddr * types.Address
80+ if manifest != nil {
8081 // Manifest mode: use local policy, metadata, secrets.
8182 if deployment .Policy == nil {
8283 cobra .CheckErr ("no policy configured in the manifest" )
8384 }
8485
85- oldAdminAddr , _ , err : = common .ResolveLocalAccountOrAddress (npa .Network , deployment .Admin )
86+ oldAdminAddr , _ , err = common .ResolveLocalAccountOrAddress (npa .Network , deployment .Admin )
8687 if err != nil {
8788 cobra .CheckErr (fmt .Errorf ("bad current administrator address: %w" , err ))
8889 }
8990
90- if * oldAdminAddr == * newAdminAddr {
91- fmt .Println ("New admin is the same as the current admin, nothing to do." )
92- return
93- }
94-
95- fmt .Printf ("Old admin: %s\n " , common .PrettyAddress (oldAdminAddr .String ()))
96-
9791 updateBody .Policy = * deployment .Policy .AsDescriptor ()
9892 updateBody .Metadata = manifest .GetMetadata (roflCommon .DeploymentName )
9993 updateBody .Secrets = buildRofl .PrepareSecrets (deployment .Secrets )
10094 } else {
101- // Direct mode: fetch current app config from chain.
95+ // Direct mode: reuse current policy, metadata, secrets from chain.
10296 if txCfg .Offline {
10397 cobra .CheckErr ("direct mode requires network access" )
10498 }
10599
106100 appCfg , err := conn .Runtime (npa .ParaTime ).ROFL .App (ctx , client .RoundLatest , appID )
107101 cobra .CheckErr (err )
108102
109- if appCfg .Admin != nil && * appCfg .Admin == * newAdminAddr {
110- fmt .Println ("New admin is the same as the current admin, nothing to do." )
111- return
112- }
113-
114- if appCfg .Admin != nil {
115- fmt .Printf ("Old admin: %s\n " , common .PrettyAddress (appCfg .Admin .String ()))
116- }
117-
103+ oldAdminAddr = appCfg .Admin
118104 updateBody .Policy = appCfg .Policy
119105 updateBody .Metadata = appCfg .Metadata
120106 updateBody .Secrets = appCfg .Secrets
121107 }
122108
109+ if oldAdminAddr != nil {
110+ if * oldAdminAddr == * newAdminAddr {
111+ fmt .Println ("New admin is the same as the current admin, nothing to do." )
112+ return
113+ }
114+ fmt .Printf ("Old admin: %s\n " , common .PrettyAddress (oldAdminAddr .String ()))
115+ }
116+
123117 newAdminStr := newAdminAddr .String ()
124118 if newAdminEthAddr != nil {
125119 newAdminStr = newAdminEthAddr .Hex ()
126120 }
127121
128- fmt .Printf ("App ID: %s\n " , appID )
129122 fmt .Printf ("New admin: %s\n " , common .PrettyAddress (newAdminStr ))
130123
131124 tx := rofl .NewUpdateTx (nil , & updateBody )
0 commit comments