Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dfx-orbit): dfx-orbit version 0.4 #337

Merged
merged 76 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
1216364
Fix test issue
Sawchord Jul 31, 2024
d6ee0b4
Update dependencies
Sawchord Aug 2, 2024
6dbd40e
Move logger up a layer
Sawchord Aug 2, 2024
52b9415
WIP refactoring asset upload into multiple smaller methods
Sawchord Aug 2, 2024
9926c6b
WIP factoring out asset functionality into it's own methods
Sawchord Aug 2, 2024
2c9629d
WIP refactoring asset upload
Sawchord Aug 2, 2024
8eb7f74
Remove unused mut
Sawchord Aug 2, 2024
8a953af
Implement check evidence method
Sawchord Aug 2, 2024
84ea59e
Implement request_commit_batch method
Sawchord Aug 2, 2024
c1710c7
WIP improve UX around asset
Sawchord Aug 2, 2024
c2a7737
WIP improving UX around assets
Sawchord Aug 2, 2024
0d54940
WIP UX in assets improvements
Sawchord Aug 5, 2024
ea13a3d
WIP implement asset check
Sawchord Aug 5, 2024
1df44ee
Test asset check
Sawchord Aug 5, 2024
552da41
Update README
Sawchord Aug 5, 2024
fcd6211
Update version and readme
Sawchord Aug 5, 2024
929d4af
Update approval UX
Sawchord Aug 5, 2024
32a8423
Implement a request_prepare_permission method
Sawchord Aug 5, 2024
cbf9848
Functionality to request prepare permission
Sawchord Aug 5, 2024
977d4dc
WIP Implement lookup for sources
Sawchord Aug 6, 2024
834c07c
Test the new functionality
Sawchord Aug 6, 2024
a75ab04
Merge branch 'main' into leon/dfx-orbitv0.2
Sawchord Aug 6, 2024
4d5259d
Settable verbosity levels
Sawchord Aug 7, 2024
25c5e87
Merge branch 'main' into leon/dfx-orbitv0.3
Sawchord Aug 8, 2024
9a3cea2
Settable --station
Sawchord Aug 8, 2024
301f362
WIP improve review UX
Sawchord Aug 9, 2024
acb49eb
Some renaming
Sawchord Aug 9, 2024
8b1aef0
WIP implement display for review list
Sawchord Aug 9, 2024
ff10355
Small improvements to the list arg parsing
Sawchord Aug 13, 2024
f5f0322
Improve review list output
Sawchord Aug 13, 2024
6dce4a2
Updating TODOs
Sawchord Aug 13, 2024
ed5eaff
Bump version
Sawchord Aug 13, 2024
4525d06
Update TODOs, remove unused code
Sawchord Aug 14, 2024
f6fe738
Refactor candid loading
Sawchord Aug 14, 2024
e9c3789
Clippy
Sawchord Aug 14, 2024
40b7471
Add canister lookup functionality
Sawchord Aug 14, 2024
d35f441
Better display functionality
Sawchord Aug 14, 2024
589b288
Implement detailed view for change canister
Sawchord Aug 14, 2024
09dae7e
Filter by external canister by default
Sawchord Aug 15, 2024
3bf0ab9
WIP display for call canister
Sawchord Aug 15, 2024
18e49fd
Display call external cansiter w/o types
Sawchord Aug 15, 2024
58d3199
More UX improvements for the CanisterCall functionality
Sawchord Aug 15, 2024
bbbaf83
Refactor
Sawchord Aug 15, 2024
878310f
Small refactors
Sawchord Aug 15, 2024
068fe55
Merge branch 'main' into leon/dfx-orbitv0.3
Sawchord Aug 16, 2024
59893f1
Refactor asset execution
Sawchord Aug 16, 2024
685dd44
WIP moving to new cli layout
Sawchord Aug 16, 2024
c251054
Flatten arg modules
Sawchord Aug 16, 2024
08745b2
request asset commands are complete
Sawchord Aug 16, 2024
58ad72a
WIP sketch out the verify arguments
Sawchord Aug 16, 2024
237c90b
WIP implement new verify interface
Sawchord Aug 19, 2024
e7ca08c
Use verify
Sawchord Aug 19, 2024
49ce38e
Remove old asset flows
Sawchord Aug 19, 2024
0129c24
Implement verify on canister call
Sawchord Aug 19, 2024
ff9ea05
WIP implement verification of change canister argument
Sawchord Aug 19, 2024
233e3d0
WIP checking update
Sawchord Aug 21, 2024
3996197
Verify command for canister call
Sawchord Aug 22, 2024
f6c78fb
Implement and-approve and or-reject
Sawchord Aug 23, 2024
ea33ad6
Factor out submit into approve and request
Sawchord Aug 23, 2024
6160981
Update some TODOs readme etc
Sawchord Aug 26, 2024
f4151b3
Merge branch 'main' into leon/dfx-orbitv0.4
Sawchord Aug 26, 2024
50baa25
Add goup and user to request
Sawchord Aug 27, 2024
ecc7edc
Improvements around verify
Sawchord Aug 27, 2024
2631cd1
Add CallCanisters request permission
Sawchord Aug 27, 2024
f2f465d
Small UX improvements
Sawchord Aug 29, 2024
4435ee5
Update todos
Sawchord Aug 29, 2024
4ab1881
Display for dfx-me
Sawchord Aug 29, 2024
2f2cfd2
Implement edit station
Sawchord Aug 30, 2024
c79162b
Implement --identity
Sawchord Aug 30, 2024
9d62774
Remove unwraps from dfx-orbit
Sawchord Aug 30, 2024
a177d53
Display for station config
Sawchord Aug 30, 2024
03857e3
Station add no longer requieres --url
Sawchord Aug 30, 2024
7a48233
Bump version
Sawchord Sep 3, 2024
62e38c0
Merge branch 'main' into leon/dfx-orbitv0.4
Sawchord Sep 3, 2024
aab50e2
Merge branch 'main' into leon/dfx-orbitv0.4
Sawchord Sep 5, 2024
fccce33
Merge branch 'main' into leon/dfx-orbitv0.4
Sawchord Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release.json
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@
"newVersion": null
},
"dfx-orbit": {
"currentVersion": "0.3.0",
"currentVersion": "0.4.0",
"dependentProjects": [
{
"source": "integration-tests",
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ edition = '2021'
[dependencies]
candid = { workspace = true }
candid_parser = { workspace = true }
dfx-orbit = { path = '../../tools/dfx-orbit', version = '0.3.0' }
dfx-orbit = { path = '../../tools/dfx-orbit', version = '0.4.0' }
flate2 = { workspace = true }
hex = { workspace = true }
orbit-essentials = { path = '../../libs/orbit-essentials', version = '0.0.2-alpha.4' }
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/src/dfx_orbit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,9 @@ async fn setup_dfx_orbit(station_id: Principal) -> DfxOrbit {
network: String::from("test"),
url: format!("http://localhost:{}", port),
};
DfxOrbit::new(orbit_agent, config, logger).await.unwrap()
DfxOrbit::new(orbit_agent, config, None, logger)
.await
.unwrap()
}

/// Create the dfx user's identities and add them to the station
Expand Down
51 changes: 33 additions & 18 deletions tests/integration/src/dfx_orbit/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ use crate::{
utils::execute_request,
CanisterIds, TestEnv,
};
use dfx_orbit::DfxOrbit;
use pocket_ic::PocketIc;
use rand::{thread_rng, Rng};
use station_api::{
AddRequestPolicyOperationInput, CallExternalCanisterResourceTargetDTO,
ExecutionMethodResourceTargetDTO, RequestOperationInput, RequestPolicyRuleDTO,
AddRequestPolicyOperationInput, CallExternalCanisterResourceTargetDTO, CreateRequestInput,
ExecutionMethodResourceTargetDTO, GetRequestInput, RequestOperationInput, RequestPolicyRuleDTO,
RequestSpecifierDTO, ValidationMethodResourceTargetDTO,
};
use std::{
Expand All @@ -30,7 +31,7 @@ fn assets_upload() {
..
} = setup_new_env();

let (_dfx_principal, _dfx_user) = setup_dfx_user(&env, &canister_ids);
let (dfx_principal, _dfx_user) = setup_dfx_user(&env, &canister_ids);

// Install the assets canister under orbit control
let asset_canister = create_canister(&mut env, canister_ids.station);
Expand Down Expand Up @@ -83,9 +84,17 @@ fn assets_upload() {

// As dfx user: Request to have Prepare permission for asset_canister
let _response = dfx_orbit
.request_prepare_permission(asset_canister, None, None)
.station
.request(CreateRequestInput {
operation: DfxOrbit::grant_permission_request(asset_canister, dfx_principal)
.unwrap(),
title: None,
summary: None,
execution_plan: None,
})
.await
.unwrap();

tokio::time::sleep(Duration::from_secs(1)).await;

// Test that we can retreive the sources from `dfx.json`
Expand All @@ -100,27 +109,33 @@ fn assets_upload() {
.upload(asset_canister, &sources_path, false)
.await
.unwrap();

let response = dfx_orbit
.request_commit_batch(
asset_canister,
batch_id.clone(),
evidence.clone(),
None,
None,
)
.station
.request(CreateRequestInput {
operation: DfxOrbit::commit_batch_input(
asset_canister,
batch_id.clone(),
evidence.clone(),
)
.unwrap(),
title: None,
summary: None,
execution_plan: None,
})
.await
.unwrap();

// Check whether the request passes the asset check
dfx_orbit
.check_evidence(
asset_canister,
response.request.id,
batch_id,
hex::encode(evidence),
)
let response = dfx_orbit
.station
.review_id(GetRequestInput {
request_id: response.request.id,
})
.await
.unwrap();
DfxOrbit::check_evidence(&response, asset_canister, batch_id, hex::encode(evidence))
.unwrap();

// NOTE: We need to wait until the certified state becomes available.
// Since we are in live mode, we can not simply advance pocketIC by some
Expand Down
12 changes: 4 additions & 8 deletions tests/integration/src/dfx_orbit/review.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use pocket_ic::PocketIc;
use station_api::{
AuthScopeDTO, CallExternalCanisterOperationInput, CanisterMethodDTO,
EditPermissionOperationInput, GetNextApprovableRequestInput, GetRequestInput,
ListRequestsInput, ListRequestsOperationTypeDTO, RequestApprovalStatusDTO,
RequestOperationInput, RequestResourceActionDTO, ResourceDTO, SubmitRequestApprovalInput,
ListRequestsInput, ListRequestsOperationTypeDTO, RequestOperationInput,
RequestResourceActionDTO, ResourceDTO,
};

use crate::{
Expand Down Expand Up @@ -123,13 +123,9 @@ fn review() {
assert_eq!(next_request.request.id, id_request.request.id);

// Approve the request
let _response = dfx_orbit
dfx_orbit
.station
.submit(SubmitRequestApprovalInput {
decision: RequestApprovalStatusDTO::Approved,
request_id: submitted_request.id,
reason: None,
})
.approve(submitted_request.id, None)
.await
.unwrap();
});
Expand Down
2 changes: 1 addition & 1 deletion tools/dfx-orbit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

[package]
name = 'dfx-orbit'
version = '0.3.0'
version = '0.4.0'
description = 'Command line tool for interacting with the Orbit digital asset manager on the ICP blockchain.'
authors.workspace = true
edition.workspace = true
Expand Down
20 changes: 4 additions & 16 deletions tools/dfx-orbit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Tell the command line tool where to find the orbit station:
- Copy the wallet ID
- Store the station details locally. If your wallet is called `shiny` and is running locally, the command is:
```
dfx-orbit station add shiny --station-id "$WALLET_ID" --network local --url https://orbitwallet.io
dfx-orbit station add shiny --station-id "$WALLET_ID" --network ic
```
- Verify that the station is in your list of stations:
```
Expand Down Expand Up @@ -104,15 +104,6 @@ Initially you are likely to have only permission to see your own profile:
]
```

Without permission to make and view requests, you will not be able to do much. It is recommended to make a `Developer` group with the following permissions:

| Name in UI | Privilege in `dfx-orbit me` | Name in error messages | Used for |
| ------------ | --------------------------- | ---------------------- | -------------------------------- |
| Request/List | `ListRequests` | `Request(List)` | `dfx-orbit review list` |
| Request/Read | Not Shown | `Request(Read(Id))` | `dfx-orbit review id REQUEST_ID` |

TODO: It would be nice to be able to link directly to a permission. E.g. this could open the permissions page and focus on one specific permission: https://orbitwallet.io/en/settings/user-groups/permissions#Request/List

## Make canister calls with Orbit

Instead of using `dfx canister call CANISTER METHOD ARGUMENTS` use `dfx-orbit request canister call CANISTER METHOD ARGUMENTS`.
Expand Down Expand Up @@ -180,7 +171,7 @@ If not, please transfer the control of the canister to the orbit station.
Note: Uploaded assets are not published. They are only prepared for release.

```
dfx-orbit asset request-prepare-permission frontend
dfx-orbit request asset prepare-permission frontend
```

In case you want to verify, whether you have the `Prepare` permission on the asset canister,
Expand All @@ -202,7 +193,7 @@ dfx identity get-principal
A developer may upload one or more directories of HTTP assets with:

```
dfx-orbit asset upload CANISTER_NAME SOME_DIR/ OTHER_DIR/
dfx-orbit request asset upload CANISTER_NAME SOME_DIR/ OTHER_DIR/
```

This will upload the assets to the asset canister and then request the orbit station to publish
Expand All @@ -213,12 +204,9 @@ the assets.
After the request has been made, the reviewers can locally verify the request:

```
dfx-orbit asset check --then-approve CANISTER REQUEST_ID BATCH_ID SOME_DIR/ OTHER_DIR/
dfx-orbit verify asset upload CANISTER REQUEST_ID BATCH_ID SOME_DIR/ OTHER_DIR/
```

The exact command is printed in the output of `dfx-orbit asset upload` and must be distributed
from the proposer to the verifiers.

> The verifiers needs to have the same set of data as was used in the request.
> How the verifier accomplishes this is outside the scope of this document.
>
Expand Down
25 changes: 18 additions & 7 deletions tools/dfx-orbit/src/args.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
//! Command line interface for `dfx-orbit`.
pub mod asset;
pub mod request;
pub mod review;
pub mod station;
pub mod verify;

use asset::AssetArgs;
use clap::{Parser, Subcommand};
use request::RequestArgs;
use review::ReviewArgs;
use station::StationArgs;
use verify::VerifyArgs;

/// Manages Orbit on the Internet Computer.
// TODO: Better version information
#[derive(Parser, Debug)]
#[clap(version, about, long_about = None)]
#[clap(version, about)]
pub struct DfxOrbitArgs {
/// Increase verbosity level
#[clap(short, long, action = clap::ArgAction::Count, conflicts_with = "quiet")]
Expand All @@ -27,6 +26,11 @@ pub struct DfxOrbitArgs {
#[clap(short, long)]
pub(crate) station: Option<String>,

// TODO: Allow to specify --network, to overwrite the network specified by the station
/// The user identity to run this command as
#[clap(short, long)]
pub(crate) identity: Option<String>,

/// Manage Orbit stations.
#[clap(subcommand)]
pub(crate) command: DfxOrbitSubcommands,
Expand All @@ -41,10 +45,17 @@ pub enum DfxOrbitSubcommands {
Station(StationArgs),
/// Make requests to Orbit
Request(RequestArgs),
/// Verify requests
Verify(VerifyArgs),
/// View and decide on requests.
Review(ReviewArgs),
/// Manage assets stored in an asset canister through Orbit
Asset(AssetArgs),
/// Gets the caller's profile on an Orbit station.
Me,
Me(MeArgs),
}

#[derive(Debug, Clone, Parser)]
pub struct MeArgs {
/// Return output as JSON
#[clap(short, long)]
pub(crate) json: bool,
}
84 changes: 0 additions & 84 deletions tools/dfx-orbit/src/args/asset.rs

This file was deleted.

Loading
Loading