Skip to content

Commit e2e23d7

Browse files
gilescopebkchr
andauthored
Tidy + bumpt to v1.0 (#19)
* Updated readme to reflect release process * one of the benches was measuring a bit more than it should have been. (nice catch clippy) Co-authored-by: Bastian Köcher <[email protected]>
1 parent 4b6bb1b commit e2e23d7

File tree

7 files changed

+44
-22
lines changed

7 files changed

+44
-22
lines changed

.cargo/config.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#
2+
# An auto defined `clippy` feature was introduced,
3+
# but it was found to clash with user defined features,
4+
# so was renamed to `cargo-clippy`.
5+
#
6+
# If you want standard clippy run:
7+
# RUSTFLAGS= cargo clippy
8+
[target.'cfg(feature = "cargo-clippy")']
9+
rustflags = ["-Aclippy::stable_sort_primitive"]

Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
[package]
22
name = "ss58-registry"
3-
authors = [
4-
"Parity Technologies <[email protected]>",
5-
]
6-
version = "0.0.1"
3+
authors = ["Parity Technologies <[email protected]>"]
4+
version = "1.0.0"
75
edition = "2018"
86
description = "Registry of known SS58 address types"
97
license = "Apache-2.0"

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# SS58 Registry
22

3-
List of wellknown [SS58](https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)) account types as an enum.
3+
[![GitHub license](https://img.shields.io/badge/license-Apache2-green)](#LICENSE) [![GitLab Status](https://gitlab.parity.io/parity/ss58-registry/badges/master/pipeline.svg)](https://gitlab.parity.io/parity/ss58-registry/pipelines)
44

5-
This is driven from the [json data file](src/ss58-registry.json) which contains entries like this:
5+
A list of known [SS58](https://github.com/paritytech/substrate/wiki/External-Address-Format-(SS58)) account types as an enum.
6+
7+
This is driven from the [json data file](ss58-registry.json) which contains entries like this:
68

79
```js
810
{
@@ -20,7 +22,19 @@ This is driven from the [json data file](src/ss58-registry.json) which contains
2022

2123
## Process:
2224

23-
If you wish to add an additional account type then please raise a pull request adding to the json file.
25+
1. Fork and clone this repo
26+
27+
2. Add an additional account type to `ss58-registry.json` (contiguous prefixes are better)
28+
29+
3. Bump the minor (middle) version number of the `Cargo.toml` by running:
30+
```
31+
cargo install cargo-bump && cargo bump minor
32+
```
33+
4. git stage, commit, push and then raise a pull request
34+
35+
5. Once the PR has landed, one of the admins can
36+
[create a new release](https://github.com/paritytech/ss58-registry/releases/new).
37+
This will release the new version to [crates.io](https://crates.io/crates/ss58-registry)
2438

2539
## Licensing:
2640

benches/benches.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
extern crate test;
44
use std::hint::black_box;
55

6-
use ss58_registry;
76
use test::Bencher;
87
static BENCH_SIZE: u16 = 100;
98
use ss58_registry::{from_address_format, Ss58AddressFormat, Ss58AddressFormatRegistry};
@@ -21,9 +20,9 @@ fn new(b: &mut Bencher) {
2120
#[bench]
2221
fn is_custom(b: &mut Bencher) {
2322
let v: Vec<Ss58AddressFormat> =
24-
(0..BENCH_SIZE).map(|i| ss58_registry::Ss58AddressFormat::custom(i)).collect();
23+
(0..BENCH_SIZE).map(ss58_registry::Ss58AddressFormat::custom).collect();
2524
b.iter(|| {
26-
for i in v.iter() {
25+
for i in &v {
2726
let _ = i.is_custom();
2827
}
2928
})
@@ -32,9 +31,9 @@ fn is_custom(b: &mut Bencher) {
3231
#[bench]
3332
fn is_reserved(b: &mut Bencher) {
3433
let v: Vec<Ss58AddressFormat> =
35-
(0..BENCH_SIZE).map(|i| ss58_registry::Ss58AddressFormat::custom(i)).collect();
34+
(0..BENCH_SIZE).map(ss58_registry::Ss58AddressFormat::custom).collect();
3635
b.iter(|| {
37-
for i in v.iter() {
36+
for i in &v {
3837
let _ = i.is_reserved();
3938
}
4039
})
@@ -43,9 +42,9 @@ fn is_reserved(b: &mut Bencher) {
4342
#[bench]
4443
fn to_string(b: &mut Bencher) {
4544
let v: Vec<Ss58AddressFormat> =
46-
(0..BENCH_SIZE).map(|i| ss58_registry::Ss58AddressFormat::custom(i)).collect();
45+
(0..BENCH_SIZE).map(ss58_registry::Ss58AddressFormat::custom).collect();
4746
b.iter(|| {
48-
for i in v.iter() {
47+
for i in &v {
4948
let _ = i.to_string();
5049
}
5150
})
@@ -65,7 +64,8 @@ fn known_to_prefix(b: &mut Bencher) {
6564
fn name_to_enum(b: &mut Bencher) {
6665
b.iter(|| {
6766
for name in ss58_registry::Ss58AddressFormat::all_names() {
68-
let _: Ss58AddressFormatRegistry = (*name).try_into().expect(&format!("{}", name));
67+
let _: Ss58AddressFormatRegistry =
68+
(*name).try_into().unwrap_or_else(|_| panic!("{}", name));
6969
}
7070
})
7171
}

build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ fn main() {
219219

220220
let dest_path = Path::new(&out_dir).join("account_type_enum.rs");
221221
if let Err(err) = fs::write(&dest_path, result) {
222-
eprintln!("failed to write generated code to {:?}: {}", &dest_path, err);
222+
eprintln!("failed to write generated code to {}: {}", &dest_path.display(), err);
223223
std::process::exit(-1);
224224
}
225225
}

rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ match_arm_blocks = false
2020
match_block_trailing_comma = true
2121
trailing_comma = "Vertical"
2222
trailing_semicolon = false
23-
use_field_init_shorthand = true
23+
use_field_init_shorthand = true

src/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ include!(concat!(env!("OUT_DIR"), "/account_type_enum.rs"));
2424
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
2525
pub struct ParseError;
2626

27-
/// A custom address format. See also Ss58AddressFormatRegistry
27+
/// A custom address format. See also [`Ss58AddressFormatRegistry`]
2828
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
2929
pub struct Ss58AddressFormat {
3030
prefix: u16,
@@ -43,6 +43,7 @@ impl Ss58AddressFormat {
4343
pub fn all_names() -> &'static [&'static str] {
4444
&ALL_SS58_ADDRESS_FORMAT_NAMES
4545
}
46+
4647
/// All known address formats.
4748
pub fn all() -> &'static [Ss58AddressFormatRegistry] {
4849
&ALL_SS58_ADDRESS_FORMATS
@@ -89,12 +90,12 @@ impl TryFrom<Ss58AddressFormat> for Ss58AddressFormatRegistry {
8990
}
9091
}
9192

92-
/// const function to convert Ss58AddressFormat to u16
93+
/// const function to convert [`Ss58AddressFormat`] to u16
9394
pub const fn from_address_format(x: Ss58AddressFormat) -> u16 {
9495
x.prefix
9596
}
9697

97-
/// const function to convert Ss58AddressFormat to u16
98+
/// const function to convert [`Ss58AddressFormat`] to u16
9899
pub const fn from_known_address_format(x: Ss58AddressFormatRegistry) -> u16 {
99100
x as u16
100101
}
@@ -108,7 +109,7 @@ impl From<Ss58AddressFormatRegistry> for Ss58AddressFormat {
108109
impl From<u8> for Ss58AddressFormat {
109110
#[inline]
110111
fn from(x: u8) -> Ss58AddressFormat {
111-
Ss58AddressFormat::from(x as u16)
112+
Ss58AddressFormat::from(u16::from(x))
112113
}
113114
}
114115

@@ -198,7 +199,7 @@ mod tests {
198199
#[test]
199200
fn enum_to_name_and_back() {
200201
for name in Ss58AddressFormat::all_names() {
201-
let val: Ss58AddressFormatRegistry = (*name).try_into().expect(&format!("{}", name));
202+
let val: Ss58AddressFormatRegistry = (*name).try_into().expect(name);
202203
assert_eq!(name, &val.to_string());
203204
}
204205
}

0 commit comments

Comments
 (0)