Skip to content

Commit c7465a0

Browse files
fix: review feedback
1 parent 2e5dc6f commit c7465a0

File tree

4 files changed

+27
-39
lines changed

4 files changed

+27
-39
lines changed

cmd/rofl/set_admin.go

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
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)

docs/rofl.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,9 @@ their latest versions. This includes:
328328
### Change ROFL app administrator {#set-admin}
329329

330330
Run `rofl set-admin` to transfer ownership of a ROFL app to a new
331-
administrator. The transaction must be signed by the current admin.
331+
administrator. The ROFL app administrator owns the application, including
332+
upgrades, policy changes and removal. The transaction must be signed by the
333+
current admin.
332334

333335
If the current directory contains a ROFL manifest, the manifest is updated with
334336
the new admin after a successful transaction.
@@ -338,30 +340,21 @@ the new admin after a successful transaction.
338340
To change the administrator directly on an existing app without a local
339341
manifest, run:
340342

341-
```bash
342-
oasis rofl set-admin <app-id> <new-admin>
343-
```
343+
![code shell](../examples/rofl/set-admin-address.in.static)
344344

345-
This mode requires network access and does not modify local files.
345+
This mode requires network access and does not modify the manifest.
346346

347347
### Change ROFL machine administrator {#machine-set-admin}
348348

349349
Run `rofl machine set-admin` to change the administrator of an individual
350-
machine instance.
350+
machine instance. This is independent of the ROFL app administrator and only
351+
affects management of the specific machine instance.
351352

352353
![code shell](../examples/rofl/machine-set-admin.in.static)
353354

354-
:::info ROFL admin vs machine admin
355-
356-
The **ROFL admin** (changed via `oasis rofl set-admin`) owns the
357-
application — transfer ownership, upgrades, policy changes, removal.
355+
To change the administrator of the machine without a local manifest, run:
358356

359-
The **machine admin** (changed via `oasis rofl machine set-admin`) manages
360-
an individual machine instance — execution, restarts, stops.
361-
362-
These are independent roles.
363-
364-
:::
357+
![code shell](../examples/rofl/machine-set-admin-address.in.static)
365358

366359
### Remove ROFL app from the network {#remove}
367360

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oasis rofl machine set-admin oasis1qp2ens0hsp7gh23wajxa4hpetkdek3swyyulyrmz:000000000000055c bob
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
oasis rofl set-admin rofl1qpw7gxp7dqq72sdtpv4jrmdfys9nsp73wysglhue bob

0 commit comments

Comments
 (0)