Skip to content

Commit 0a19eb7

Browse files
authored
Merge pull request #335 from Concordium/limemloh/cor-2411-misc-tools-update-genesis-creator-to-use-sdk-genesis
Use genesis generate functionality from SDK
2 parents ba0322b + 8f7ddb5 commit 0a19eb7

14 files changed

Lines changed: 1589 additions & 2567 deletions

File tree

Cargo.lock

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

credential-verification-service/src/api/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::api_types::ErrorDetail;
22
use crate::types::{ServerError, ValidationError};
3-
use anyhow::{Context, Result};
3+
use anyhow::Result;
44
use concordium_rust_sdk::common::cbor;
55
use concordium_rust_sdk::common::cbor::CborSerialize;
66
use concordium_rust_sdk::types::RegisteredData;
@@ -9,7 +9,7 @@ use std::collections::HashMap;
99
pub fn anchor_to_registered_data(
1010
anchor: &impl CborSerialize,
1111
) -> Result<RegisteredData, ServerError> {
12-
let cbor = cbor::cbor_encode(anchor).context("cbor encode anchor")?;
12+
let cbor = cbor::cbor_encode(anchor);
1313
let register_data =
1414
RegisteredData::try_from(cbor).map_err(ServerError::AnchorPublicInfoTooBig)?;
1515
Ok(register_data)

credential-verification-service/tests/integration_test_rest/create_verification_request_and_verify.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,7 @@ async fn test_create_verification_request_and_verify() {
4646
verification_request.anchor_transaction_hash,
4747
fixtures::chain::transaction_status_finalized(
4848
verification_request.anchor_transaction_hash,
49-
cbor::cbor_encode(&request_anchor)
50-
.unwrap()
51-
.try_into()
52-
.unwrap(),
49+
cbor::cbor_encode(&request_anchor).try_into().unwrap(),
5350
),
5451
);
5552

credential-verification-service/tests/integration_test_rest/verify.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ async fn test_verify_account_based() {
3232
fixtures::chain::transaction_status_finalized(
3333
verify_fixture.anchor_txn_hash,
3434
cbor::cbor_encode(&verify_fixture.anchor)
35-
.unwrap()
3635
.try_into()
3736
.unwrap(),
3837
),
@@ -93,7 +92,6 @@ async fn test_verify_identity_based() {
9392
fixtures::chain::transaction_status_finalized(
9493
verify_fixture.anchor_txn_hash,
9594
cbor::cbor_encode(&verify_fixture.anchor)
96-
.unwrap()
9795
.try_into()
9896
.unwrap(),
9997
),
@@ -143,7 +141,6 @@ async fn test_verify_anchor_status_committed() {
143141
fixtures::chain::transaction_status_committed(
144142
verify_fixture.anchor_txn_hash,
145143
cbor::cbor_encode(&verify_fixture.anchor)
146-
.unwrap()
147144
.try_into()
148145
.unwrap(),
149146
),
@@ -193,7 +190,6 @@ async fn test_verify_fail() {
193190
fixtures::chain::transaction_status_finalized(
194191
verify_fixture.anchor_txn_hash,
195192
cbor::cbor_encode(&verify_fixture.anchor)
196-
.unwrap()
197193
.try_into()
198194
.unwrap(),
199195
),
@@ -332,7 +328,6 @@ async fn test_verify_account_credential_not_found() {
332328
fixtures::chain::transaction_status_finalized(
333329
verify_fixture.anchor_txn_hash,
334330
cbor::cbor_encode(&verify_fixture.anchor)
335-
.unwrap()
336331
.try_into()
337332
.unwrap(),
338333
),
@@ -374,7 +369,6 @@ async fn test_verify_identity_based_multistatement_both_invalid() {
374369
fixtures::chain::transaction_status_finalized(
375370
verify_fixture.anchor_txn_hash,
376371
cbor::cbor_encode(&verify_fixture.anchor)
377-
.unwrap()
378372
.try_into()
379373
.unwrap(),
380374
),

generator/src/generator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1021,7 +1021,7 @@ impl Generate for SponsoredTransactionGenerator {
10211021
self.expiry,
10221022
self.token_id.clone(),
10231023
[operation].into_iter().collect(),
1024-
)?
1024+
)
10251025
.extend()
10261026
.add_sponsor(self.sponsor.address, 1)
10271027
.expect("Can add sponsor account")

generator/src/plt.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use concordium_rust_sdk::{
2323
use futures::{future, stream, StreamExt, TryStreamExt};
2424
use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng};
2525
use rust_decimal::Decimal;
26-
use std::collections::HashMap;
2726
use std::{path::PathBuf, str::FromStr};
2827

2928
#[derive(Debug, Args)]
@@ -212,7 +211,7 @@ impl PltOperationGenerator {
212211

213212
async move {
214213
let hash = client_clone
215-
.send_account_transaction(txn?)
214+
.send_account_transaction(txn)
216215
.await
217216
.context("send add allow list txn")?;
218217

@@ -365,7 +364,7 @@ impl Generate for PltOperationGenerator {
365364
expiry,
366365
token_info.token_id.clone(),
367366
operations.into_iter().collect(),
368-
)?;
367+
);
369368

370369
self.nonce.next_mut();
371370

@@ -499,7 +498,6 @@ impl Generate for CreatePltGenerator {
499498
initial_supply: Some(self.initial_supply),
500499
mintable: Some(mint_burn),
501500
burnable: Some(mint_burn),
502-
additional: HashMap::new(),
503501
};
504502

505503
let create_plt = CreatePlt {
@@ -508,9 +506,7 @@ impl Generate for CreatePltGenerator {
508506
"5c5c2645db84a7026d78f2501740f60a8ccb8fae5c166dc2428077fd9a699a4a",
509507
)?,
510508
decimals: Self::DECIMALS,
511-
initialization_parameters: RawCbor::from(cbor::cbor_encode(
512-
&initialization_parameters,
513-
)?),
509+
initialization_parameters: RawCbor::from(cbor::cbor_encode(&initialization_parameters)),
514510
};
515511

516512
let payload = UpdatePayload::CreatePlt(create_plt);

genesis-creator/Cargo.toml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ anyhow.workspace = true
1717
chrono = {workspace = true, features = ["serde"] }
1818
serde = { workspace = true, features = ["derive"] }
1919
rand.workspace = true
20-
ed25519-dalek.workspace = true
21-
gcd.workspace = true
22-
rayon.workspace = true
23-
sha2.workspace = true
20+
tracing.workspace = true
21+
tracing-subscriber = { workspace = true, features = ["fmt"] }
2422

genesis-creator/src/assemble.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use concordium_rust_sdk::{common::SerdeDeserialize, id::types::AccountAddress};
33
use std::path::PathBuf;
44

5-
use crate::config::ProtocolConfig;
5+
use crate::config::ProtocolConfigToml;
66

77
/// Configuration struct for specifying protocol version, the genesis
88
/// parameters, the foundation account and where to find genesis accounts,
@@ -13,7 +13,7 @@ use crate::config::ProtocolConfig;
1313
pub struct AssembleGenesisConfig {
1414
/// Protocol specific configurations.
1515
#[serde(flatten)]
16-
pub protocol: ProtocolConfig,
16+
pub protocol: ProtocolConfigToml,
1717
/// Address of the account to set as the initial foundation account.
1818
pub foundation_account: AccountAddress,
1919
/// A file with a list of accounts that should be assembled into

0 commit comments

Comments
 (0)