Skip to content

Commit 1e8fa42

Browse files
authored
Merge branch 'main' into docs-1
2 parents 085a3e8 + 05a527c commit 1e8fa42

File tree

43 files changed

+615
-221
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+615
-221
lines changed

.github/workflows/ci_tests.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ jobs:
224224
cd src/chain-wallet-libs/bindings/wallet-js
225225
wasm-pack build --release --target=nodejs -d pkg
226226
227+
- name: Build JS package
228+
run: |
229+
cd src/chain-wallet-libs/bindings/wallet-js/js
230+
npm install
231+
227232
- name: Run JS tests
228233
run: |
229234
cd src/chain-wallet-libs/bindings/wallet-js/js-test

Cargo.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

book/src/core-vitss-doc/api/v0.yaml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ paths:
437437
description: Success
438438
"400":
439439
description: The input is malformed.
440-
440+
441441

442442
/api/v0/admin/fund:
443443
put:
@@ -642,6 +642,9 @@ components:
642642
description: URL to a web page with details on this proposal.
643643
proposal_files:
644644
type: string
645+
proposal_extra_fields:
646+
type: object
647+
description: Map of proposal's extra fields.
645648
proposer:
646649
type: object
647650
properties:
@@ -1005,7 +1008,7 @@ components:
10051008
SearchTable:
10061009
type: string
10071010
enum: [challenges, proposals]
1008-
1011+
10091012
SearchColumn:
10101013
type: string
10111014
enum: [title, type, desc, author, funds]
@@ -1182,17 +1185,17 @@ components:
11821185
voting_groups:
11831186
description: List of the assigned voting groups
11841187
type: array
1185-
items:
1188+
items:
11861189
description: Voting group id (the same as voting token id)
11871190
type: string
11881191
last_updated:
11891192
description: Date and time for the latest update to this snapshot information
11901193
type: string
11911194
format: date-time
1192-
example:
1195+
example:
11931196
{
11941197
delegators: ["f5285eeead8b5885a1420800de14b0d1960db1a990a6c2f7b517125bedc000db", "7ef044ba437057d6d944ace679b7f811335639a689064cd969dffc8b55a7cc19"],
11951198
voting_groups: ["group1", "group2"],
11961199
last_updated: "2021-02-11T10:10:27+00:00"
11971200
}
1198-
1201+

src/chain-libs/chain-impl-mockchain/src/key.rs

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,41 @@ impl<T: Clone, A: VerificationAlgorithm> Clone for Signed<T, A> {
226226
any(test, feature = "property-test-api"),
227227
derive(test_strategy::Arbitrary)
228228
)]
229-
pub struct Hash(crypto::Blake2b256);
229+
pub struct Hash {
230+
hash: crypto::Blake2b256,
231+
}
232+
230233
impl Hash {
234+
pub fn new(hash: crypto::Blake2b256) -> Self {
235+
Self { hash }
236+
}
237+
238+
pub fn get_hash(&self) -> &crypto::Blake2b256 {
239+
&self.hash
240+
}
241+
231242
/// All 0 hash used as a special hash
232243
pub fn zero_hash() -> Self {
233-
Hash(crypto::Blake2b256::from([0; crypto::Blake2b256::HASH_SIZE]))
244+
Hash {
245+
hash: crypto::Blake2b256::from([0; crypto::Blake2b256::HASH_SIZE]),
246+
}
234247
}
248+
235249
pub fn hash_bytes(bytes: &[u8]) -> Self {
236-
Hash(crypto::Blake2b256::new(bytes))
250+
Hash {
251+
hash: crypto::Blake2b256::new(bytes),
252+
}
237253
}
254+
238255
pub fn from_bytes(bytes: [u8; 32]) -> Self {
239-
Hash(crypto::Blake2b256::from(bytes))
256+
Hash {
257+
hash: crypto::Blake2b256::from(bytes),
258+
}
240259
}
241260

242261
#[inline]
243262
pub fn as_bytes(&self) -> &[u8] {
244-
self.0.as_ref()
263+
self.hash.as_ref()
245264
}
246265
}
247266

@@ -253,63 +272,69 @@ impl From<[u8; 32]> for Hash {
253272

254273
impl From<Hash> for [u8; 32] {
255274
fn from(h: Hash) -> Self {
256-
h.0.into()
275+
h.hash.into()
257276
}
258277
}
259278

260279
impl<'a> From<&'a Hash> for &'a [u8; 32] {
261280
fn from(h: &'a Hash) -> Self {
262-
(&h.0).into()
281+
(&h.hash).into()
263282
}
264283
}
265284

266285
impl Serialize for Hash {
267286
fn serialized_size(&self) -> usize {
268-
self.0.as_hash_bytes().serialized_size()
287+
self.hash.as_hash_bytes().serialized_size()
269288
}
270289

271290
fn serialize<W: std::io::Write>(&self, codec: &mut Codec<W>) -> Result<(), WriteError> {
272-
codec.put_bytes(self.0.as_hash_bytes())
291+
codec.put_bytes(self.hash.as_hash_bytes())
273292
}
274293
}
275294

276295
impl Deserialize for Hash {
277296
fn deserialize<R: std::io::Read>(codec: &mut Codec<R>) -> Result<Self, ReadError> {
278297
let bytes = <[u8; crypto::Blake2b256::HASH_SIZE]>::deserialize(codec)?;
279-
Ok(Hash(crypto::Blake2b256::from(bytes)))
298+
Ok(Hash {
299+
hash: crypto::Blake2b256::from(bytes),
300+
})
280301
}
281302
}
282303

283304
impl BlockId for Hash {
284305
fn zero() -> Hash {
285-
Hash(crypto::Blake2b256::from([0; crypto::Blake2b256::HASH_SIZE]))
306+
Hash {
307+
hash: crypto::Blake2b256::from([0; crypto::Blake2b256::HASH_SIZE]),
308+
}
286309
}
287310
}
288311

289312
impl FragmentId for Hash {}
290313

291314
impl AsRef<[u8]> for Hash {
292315
fn as_ref(&self) -> &[u8] {
293-
self.0.as_ref()
316+
self.hash.as_ref()
294317
}
295318
}
296319

297320
impl From<crypto::Blake2b256> for Hash {
298321
fn from(hash: crypto::Blake2b256) -> Self {
299-
Hash(hash)
322+
Hash { hash }
300323
}
301324
}
302325

303326
impl std::fmt::Display for Hash {
304327
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
305-
write!(f, "{}", self.0)
328+
write!(f, "{}", self.hash)
306329
}
307330
}
308331

309332
impl FromStr for Hash {
310333
type Err = crypto::hash::Error;
311334
fn from_str(s: &str) -> Result<Self, Self::Err> {
312-
Ok(Hash(crypto::Blake2b256::from_str(s)?))
335+
Ok(Hash {
336+
hash: crypto::Blake2b256::from_str(s)?,
337+
})
313338
}
314339
}
315340

@@ -408,7 +433,9 @@ mod tests {
408433

409434
impl Arbitrary for Hash {
410435
fn arbitrary<G: Gen>(g: &mut G) -> Self {
411-
Hash(Arbitrary::arbitrary(g))
436+
Hash {
437+
hash: Arbitrary::arbitrary(g),
438+
}
412439
}
413440
}
414441
impl Arbitrary for EitherEd25519SecretKey {

src/chain-libs/chain-time/src/era.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ impl TimeEra {
8585
}
8686
}
8787

88+
/// retrieve the epoch start during a given Era
89+
pub fn epoch_start(&self) -> Epoch {
90+
self.epoch_start
91+
}
92+
93+
/// retrieve the slot start of an epoch during a given Era
94+
pub fn slot_start(&self) -> Slot {
95+
self.slot_start
96+
}
97+
8898
/// retrieve the number of slots in an epoch during a given Era
8999
pub fn slots_per_epoch(&self) -> u32 {
90100
self.slots_per_epoch

src/chain-libs/chain-time/src/timeframe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::time::{Duration, SystemTime};
1313
any(test, feature = "property-test-api"),
1414
derive(test_strategy::Arbitrary)
1515
)]
16-
pub struct Slot(pub(crate) u64);
16+
pub struct Slot(pub u64);
1717

1818
impl From<u64> for Slot {
1919
fn from(slot_number: u64) -> Slot {

src/chain-wallet-libs/bindings/wallet-core/src/wallet.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ impl Wallet {
3232
self.account.account_id()
3333
}
3434

35-
/// Retrieve a wallet from a list of free keys used as utxo's
35+
/// Retrieve a wallet from a key used as utxo's
3636
///
3737
/// You can also use this function to recover a wallet even after you have
3838
/// transferred all the funds to the new format
3939
///
4040
/// Parameters
4141
///
4242
/// * `account_key`: the private key used for voting
43-
/// * `keys`: unused
4443
///
4544
/// # Errors
4645
///

src/chain-wallet-libs/bindings/wallet-js/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ wallet-core = {path = "../wallet-core"}
3030
wasm-bindgen = "0.2"
3131
js-sys = "0.3.40"
3232
bech32 = "0.7.2"
33+
serde_json = "1.0"
3334

3435
# The `console_error_panic_hook` crate provides better debugging of panics by
3536
# logging them with `console.error`. This is great for development, but requires

src/chain-wallet-libs/bindings/wallet-js/js-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@
1313
],
1414
"devDependencies": {
1515
"mocha": "^10.1.0",
16-
"wallet-js": "file:../pkg"
16+
"wallet-js": "file:../js"
1717
}
1818
}

0 commit comments

Comments
 (0)