Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Ğ
Ğcli-v2s
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
Rust
Ğcli-v2s
Commits
f132287f
Commit
f132287f
authored
3 months ago
by
Nicolas80
Browse files
Options
Downloads
Patches
Plain Diff
Small refactorings from MR comments
parent
a5069df9
No related branches found
No related tags found
1 merge request
!41
Adding db persistence for all SecretFormat of vault keys as well as supporting derivations
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/commands/vault.rs
+2
-2
2 additions, 2 deletions
src/commands/vault.rs
src/entities/vault_derivation.rs
+13
-13
13 additions, 13 deletions
src/entities/vault_derivation.rs
with
15 additions
and
15 deletions
src/commands/vault.rs
+
2
−
2
View file @
f132287f
...
@@ -11,7 +11,7 @@ use sea_orm::{ConnectionTrait, TransactionTrait};
...
@@ -11,7 +11,7 @@ use sea_orm::{ConnectionTrait, TransactionTrait};
use
std
::
io
::{
Read
,
Write
};
use
std
::
io
::{
Read
,
Write
};
use
std
::
path
::
PathBuf
;
use
std
::
path
::
PathBuf
;
///
define universal dividends
subcommands
///
vault
subcommands
#[derive(Clone,
Debug,
clap::Parser)]
#[derive(Clone,
Debug,
clap::Parser)]
pub
enum
Subcommand
{
pub
enum
Subcommand
{
/// List available SS58 Addresses in the vault
/// List available SS58 Addresses in the vault
...
@@ -115,7 +115,7 @@ fn decrypt(input: &[u8], passphrase: String) -> Result<Vec<u8>, age::DecryptErro
...
@@ -115,7 +115,7 @@ fn decrypt(input: &[u8], passphrase: String) -> Result<Vec<u8>, age::DecryptErro
Ok
(
decrypted
)
Ok
(
decrypted
)
}
}
/// handle
ud
commands
/// handle
vault
commands
pub
async
fn
handle_command
(
data
:
Data
,
command
:
Subcommand
)
->
Result
<
(),
GcliError
>
{
pub
async
fn
handle_command
(
data
:
Data
,
command
:
Subcommand
)
->
Result
<
(),
GcliError
>
{
// match subcommand
// match subcommand
match
command
{
match
command
{
...
...
This diff is collapsed.
Click to expand it.
src/entities/vault_derivation.rs
+
13
−
13
View file @
f132287f
...
@@ -112,8 +112,10 @@ pub async fn fetch_vault_derivation<C>(db: &C, address: &str) -> Result<Option<M
...
@@ -112,8 +112,10 @@ pub async fn fetch_vault_derivation<C>(db: &C, address: &str) -> Result<Option<M
where
where
C
:
ConnectionTrait
,
C
:
ConnectionTrait
,
{
{
let
derivation
=
Entity
::
find_by_id
(
address
.to_owned
())
.one
(
db
)
.await
?
;
Entity
::
find_by_id
(
address
.to_owned
())
Ok
(
derivation
)
.one
(
db
)
.await
.map_err
(
GcliError
::
from
)
}
}
pub
async
fn
fetch_all_linked_derivations_in_order
<
C
>
(
pub
async
fn
fetch_all_linked_derivations_in_order
<
C
>
(
...
@@ -123,36 +125,34 @@ pub async fn fetch_all_linked_derivations_in_order<C>(
...
@@ -123,36 +125,34 @@ pub async fn fetch_all_linked_derivations_in_order<C>(
where
where
C
:
ConnectionTrait
,
C
:
ConnectionTrait
,
{
{
let
linked_derivations
=
Entity
::
find
()
Entity
::
find
()
.filter
(
Column
::
RootAddress
.eq
(
root_address
.to_owned
()))
.filter
(
Column
::
RootAddress
.eq
(
root_address
.to_owned
()))
.order_by_with_nulls
(
Column
::
Path
,
Order
::
Asc
,
NullOrdering
::
First
)
.order_by_with_nulls
(
Column
::
Path
,
Order
::
Asc
,
NullOrdering
::
First
)
.all
(
db
)
.all
(
db
)
.await
?
;
.await
Ok
(
linked_derivations
)
.map_err
(
GcliError
::
from
)
}
}
pub
async
fn
list_all_derivations_in_order
<
C
>
(
db
:
&
C
)
->
Result
<
Vec
<
Model
>
,
GcliError
>
pub
async
fn
list_all_derivations_in_order
<
C
>
(
db
:
&
C
)
->
Result
<
Vec
<
Model
>
,
GcliError
>
where
where
C
:
ConnectionTrait
,
C
:
ConnectionTrait
,
{
{
let
derivations
=
Entity
::
find
()
Entity
::
find
()
.order_by_asc
(
Column
::
RootAddress
)
.order_by_asc
(
Column
::
RootAddress
)
.order_by_with_nulls
(
Column
::
Path
,
Order
::
Asc
,
NullOrdering
::
First
)
.order_by_with_nulls
(
Column
::
Path
,
Order
::
Asc
,
NullOrdering
::
First
)
.all
(
db
)
.all
(
db
)
.await
?
;
.await
.map_err
(
GcliError
::
from
)
Ok
(
derivations
)
}
}
pub
async
fn
list_all_root_derivations_in_order
<
C
>
(
db
:
&
C
)
->
Result
<
Vec
<
Model
>
,
GcliError
>
pub
async
fn
list_all_root_derivations_in_order
<
C
>
(
db
:
&
C
)
->
Result
<
Vec
<
Model
>
,
GcliError
>
where
where
C
:
ConnectionTrait
,
C
:
ConnectionTrait
,
{
{
let
derivations
=
Entity
::
find
()
Entity
::
find
()
.filter
(
Column
::
Path
.is_null
())
.filter
(
Column
::
Path
.is_null
())
.order_by_asc
(
Column
::
RootAddress
)
.order_by_asc
(
Column
::
RootAddress
)
.all
(
db
)
.all
(
db
)
.await
?
;
.await
.map_err
(
GcliError
::
from
)
Ok
(
derivations
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment