Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
parity-signer
Commits
196b0466
Unverified
Commit
196b0466
authored
May 24, 2022
by
Vera Abramova
Browse files
feat: show specs
parent
65879e0a
Changes
4
Hide whitespace changes
Inline
Side-by-side
rust/definitions/src/error_active.rs
View file @
196b0466
...
...
@@ -378,6 +378,7 @@ impl ErrorSource for Active {
CommandNeedArgument
::
MetaDefaultFileName
=>
"`-name`"
,
CommandNeedArgument
::
MetaDefaultFileVersion
=>
"`-version`"
,
CommandNeedArgument
::
CheckFile
=>
"check_file"
,
CommandNeedArgument
::
ShowSpecsTitle
=>
"`show -specs`"
,
};
format!
(
"{} must be followed by an agrument."
,
insert
)
},
...
...
@@ -1756,6 +1757,9 @@ pub enum CommandNeedArgument {
/// Command `check_file` must be followed by the file path
CheckFile
,
/// Command `show -specs` must be followed by the network address book title
ShowSpecsTitle
,
}
/// Unsuitable argument for the key in `generate_message` command
...
...
rust/generate_message/src/lib.rs
View file @
196b0466
...
...
@@ -231,7 +231,7 @@ use parser::{Command, Show};
mod
remove
;
use
remove
::
remove_info
;
mod
show
;
use
show
::{
check_file
,
show_metadata
,
show_networks
};
use
show
::{
check_file
,
show_metadata
,
show_networks
,
show_specs
};
mod
specs
;
use
specs
::
gen_add_specs
;
...
...
@@ -242,6 +242,7 @@ pub fn full_run(command: Command) -> Result<(), ErrorActive> {
Command
::
Show
(
x
)
=>
match
x
{
Show
::
Metadata
=>
show_metadata
(),
Show
::
Networks
=>
show_networks
(),
Show
::
Specs
(
title
)
=>
show_specs
(
title
),
Show
::
CheckFile
(
path
)
=>
check_file
(
path
),
},
Command
::
Types
=>
prep_types
::
<
Active
>
(
HOT_DB_NAME
)
?
.write
(
TYLO
),
...
...
rust/generate_message/src/parser.rs
View file @
196b0466
...
...
@@ -43,6 +43,14 @@ pub enum Command {
/// - network title as it will be displayed in Signer, from
/// [`NetworkSpecsToSend`](definitions::network_specs::NetworkSpecsToSend)
///
/// # Show network specs for a network, as they are recorded in the hot database
///
/// `$ cargo run show -specs <network address book title>`
///
/// Function prints network address book title and corresponding
/// [`NetworkSpecsToSend`](definitions::network_specs::NetworkSpecsToSend)
/// from [`SPECSTREEPREP`] tree of the hot database.
///
/// # Check external file with hex-encoded metadata
///
/// `$ cargo run check_file <path>`
...
...
@@ -445,8 +453,13 @@ pub enum Show {
/// Show all hot database [`ADDRESS_BOOK`](constants::ADDRESS_BOOK) entries
Networks
,
/// Show network specs from [`SPECSTREEPREP`](constants::SPECSTREEPREP)
/// entry. Associated data is user-entered network address book title.
Specs
(
String
),
/// Check that external file is valid network metadata and search for
/// similar entry in hot database [`METATREE`](constants::METATREE)
/// similar entry in hot database [`METATREE`](constants::METATREE).
/// Associated data is user-provided path to the metadata file.
CheckFile
(
String
),
}
...
...
@@ -718,6 +731,22 @@ impl Command {
Ok
(
Command
::
Show
(
Show
::
Networks
))
}
}
"-specs"
=>
match
args
.next
()
{
Some
(
title
)
=>
{
if
args
.next
()
.is_some
()
{
Err
(
ErrorActive
::
CommandParser
(
CommandParser
::
UnexpectedKeyArgumentSequence
,
))
}
else
{
Ok
(
Command
::
Show
(
Show
::
Specs
(
title
)))
}
}
None
=>
{
Err
(
ErrorActive
::
CommandParser
(
CommandParser
::
NeedArgument
(
CommandNeedArgument
::
ShowSpecsTitle
,
)))
}
},
_
=>
Err
(
ErrorActive
::
CommandParser
(
CommandParser
::
UnexpectedKeyArgumentSequence
,
)),
...
...
rust/generate_message/src/show.rs
View file @
196b0466
...
...
@@ -8,7 +8,7 @@ use definitions::{
metadata
::
MetaValues
,
};
use
crate
::
helpers
::{
address_book_content
,
network_specs_from_entry
};
use
crate
::
helpers
::{
address_book_content
,
network_specs_from_entry
,
network_specs_from_title
};
/// Display all metadata currenty stored in the hot database
///
...
...
@@ -168,3 +168,24 @@ pub fn check_file(path: String) -> Result<(), ErrorActive> {
fn
hash_string
(
meta
:
&
[
u8
])
->
String
{
hex
::
encode
(
blake2b
(
32
,
&
[],
meta
)
.as_bytes
())
}
/// Show network specs for user-entered address book title
pub
fn
show_specs
(
title
:
String
)
->
Result
<
(),
ErrorActive
>
{
let
specs
=
network_specs_from_title
(
&
title
)
?
;
println!
(
"address book title: {}
\n
base58 prefix: {}
\n
color: {}
\n
decimals: {}
\n
encryption: {}
\n
genesis_hash: {}
\n
logo: {}
\n
name: {}
\n
path_id: {}
\n
secondary_color: {}
\n
title: {}
\n
unit: {}"
,
title
,
specs
.base58prefix
,
specs
.color
,
specs
.decimals
,
specs
.encryption
.show
(),
hex
::
encode
(
specs
.genesis_hash
),
specs
.logo
,
specs
.name
,
specs
.path_id
,
specs
.secondary_color
,
specs
.title
,
specs
.unit
);
Ok
(())
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment