diff --git a/.changes/db-migration.md b/.changes/db-migration.md deleted file mode 100644 index 9d324dc0d8..0000000000 --- a/.changes/db-migration.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Fixed migration mismatch from `iota-rs` version. \ No newline at end of file diff --git a/.changes/ledger-nano-events.md b/.changes/ledger-nano-events.md deleted file mode 100644 index 95dbdf5700..0000000000 --- a/.changes/ledger-nano-events.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Ledger Nano events properly created when preparing transactions; diff --git a/.changes/missing-production-profile.md b/.changes/missing-production-profile.md deleted file mode 100644 index a3262e3c49..0000000000 --- a/.changes/missing-production-profile.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Fixed missing production profile when no prebuild binary is available; \ No newline at end of file diff --git a/.changes/prepare-output.md b/.changes/prepare-output.md deleted file mode 100644 index 66cd176c8e..0000000000 --- a/.changes/prepare-output.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Fixed `Account::prepareOutput()` when `ReturnStrategy::Gift` is used with an existing NFT output; \ No newline at end of file diff --git a/.changes/restore-backup.md b/.changes/restore-backup.md deleted file mode 100644 index 5b3fcb0f17..0000000000 --- a/.changes/restore-backup.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Fixed `Wallet::restoreBackup()` when no secret manager data is stored inside; \ No newline at end of file diff --git a/.changes/stronghold-2.0.md b/.changes/stronghold-2.0.md deleted file mode 100644 index 94cc09b5e7..0000000000 --- a/.changes/stronghold-2.0.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"wallet-nodejs-binding": patch ---- - -Bump stronghold to 2.0. \ No newline at end of file diff --git a/bindings/core/src/method/wallet.rs b/bindings/core/src/method/wallet.rs index 2ec7164221..bd3ec1bfae 100644 --- a/bindings/core/src/method/wallet.rs +++ b/bindings/core/src/method/wallet.rs @@ -52,11 +52,6 @@ pub enum WalletMethod { /// Read accounts. /// Expected response: [`Accounts`](crate::Response::Accounts) GetAccounts, - /// Get historic chrysalis data. - /// Expected response: [`ChrysalisData`](crate::Response::ChrysalisData) - #[cfg(feature = "storage")] - #[cfg_attr(docsrs, doc(cfg(feature = "storage")))] - GetChrysalisData, /// Consume an account method. /// Returns [`Response`](crate::Response) #[serde(rename_all = "camelCase")] diff --git a/bindings/core/src/method_handler/wallet.rs b/bindings/core/src/method_handler/wallet.rs index 7673a1b2df..01510cace4 100644 --- a/bindings/core/src/method_handler/wallet.rs +++ b/bindings/core/src/method_handler/wallet.rs @@ -63,7 +63,6 @@ pub(crate) async fn call_wallet_method_internal(wallet: &Wallet, method: WalletM } Response::Accounts(account_dtos) } - WalletMethod::GetChrysalisData => Response::ChrysalisData(wallet.get_chrysalis_data().await?), WalletMethod::CallAccountMethod { account_id, method } => { let account = wallet.get_account(account_id).await?; call_account_method_internal(&account, method).await? diff --git a/bindings/core/src/response.rs b/bindings/core/src/response.rs index 7de8abd947..5d631971c3 100644 --- a/bindings/core/src/response.rs +++ b/bindings/core/src/response.rs @@ -1,7 +1,6 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use std::collections::HashMap; #[cfg(not(target_family = "wasm"))] use std::collections::HashSet; @@ -44,6 +43,7 @@ use serde::Serialize; use { iota_sdk::types::api::plugins::participation::types::{ParticipationEventId, ParticipationEventStatus}, iota_sdk::wallet::account::{AccountParticipationOverview, ParticipationEventWithNodes}, + std::collections::HashMap, }; use crate::{error::Error, OmittedDebug}; @@ -260,9 +260,6 @@ pub enum Response { /// - [`AddressesWithUnspentOutputs`](crate::method::AccountMethod::AddressesWithUnspentOutputs) AddressesWithUnspentOutputs(Vec), /// Response for: - /// - [`GetChrysalisData`](crate::method::WalletMethod::GetChrysalisData) - ChrysalisData(Option>), - /// Response for: /// - [`MinimumRequiredStorageDeposit`](crate::method::ClientMethod::MinimumRequiredStorageDeposit) /// - [`ComputeStorageDeposit`](crate::method::UtilsMethod::ComputeStorageDeposit) MinimumRequiredStorageDeposit(String), diff --git a/bindings/nodejs/examples/wallet/migrate-db-chrysalis-to-stardust.ts b/bindings/nodejs/examples/wallet/migrate-db-chrysalis-to-stardust.ts deleted file mode 100644 index f33a29de93..0000000000 --- a/bindings/nodejs/examples/wallet/migrate-db-chrysalis-to-stardust.ts +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright 2023 IOTA Stiftung -// SPDX-License-Identifier: Apache-2.0 - -import { WalletOptions, Wallet, migrateDbChrysalisToStardust } from '@iota/sdk'; -require('dotenv').config({ path: '.env' }); - -// Run with command: -// yarn run-example wallet/migrate-db-chrysalis-to-stardust.ts - -const walletDbPath = './chrysalis-db'; - -async function run() { - const { initLogger } = require('@iota/sdk'); - initLogger({ - name: './wallet.log', - levelFilter: 'debug', - targetExclusions: ['h2', 'hyper', 'rustls'], - }); - if (!process.env.NODE_URL) { - throw new Error('.env NODE_URL is undefined, see .env.example'); - } - if (!process.env.STRONGHOLD_PASSWORD) { - throw new Error( - '.env STRONGHOLD_PASSWORD is undefined, see .env.example', - ); - } - - migrateDbChrysalisToStardust(walletDbPath, 'password'); - - const walletOptions: WalletOptions = { - storagePath: walletDbPath, - clientOptions: { - nodes: [process.env.NODE_URL], - }, - secretManager: { - stronghold: { - snapshotPath: walletDbPath + 'wallet.stronghold', - password: process.env.STRONGHOLD_PASSWORD, - }, - }, - }; - console.log(walletOptions); - const wallet = new Wallet(walletOptions); - - // Accounts migrated from the Chrysalis db - const accounts = await wallet.getAccounts(); - console.log(accounts); - - const historicChrysalisData = await wallet.getChrysalisData(); - console.log(historicChrysalisData); -} - -run().then(() => process.exit()); diff --git a/bindings/nodejs/lib/bindings.ts b/bindings/nodejs/lib/bindings.ts index 55b5dbba1f..86e960f1c5 100644 --- a/bindings/nodejs/lib/bindings.ts +++ b/bindings/nodejs/lib/bindings.ts @@ -27,7 +27,6 @@ const { getClientFromWallet, getSecretManagerFromWallet, migrateStrongholdSnapshotV2ToV3, - migrateDbChrysalisToStardust, } = addon; const callClientMethodAsync = ( @@ -117,5 +116,4 @@ export { getSecretManagerFromWallet, listenMqtt, migrateStrongholdSnapshotV2ToV3, - migrateDbChrysalisToStardust, }; diff --git a/bindings/nodejs/lib/types/wallet/bridge/index.ts b/bindings/nodejs/lib/types/wallet/bridge/index.ts index 4d5d28a34c..eb3898b6d3 100644 --- a/bindings/nodejs/lib/types/wallet/bridge/index.ts +++ b/bindings/nodejs/lib/types/wallet/bridge/index.ts @@ -60,7 +60,6 @@ import type { __GetAccountMethod__, __GetAccountIndexesMethod__, __GetAccountsMethod__, - __GetChrysalisDataMethod__, __GetLedgerNanoStatusMethod__, __GenerateEd25519AddressMethod__, __IsStrongholdPasswordAvailableMethod__, @@ -146,7 +145,6 @@ export type __Method__ = | __GetAccountMethod__ | __GetAccountIndexesMethod__ | __GetAccountsMethod__ - | __GetChrysalisDataMethod__ | __GetLedgerNanoStatusMethod__ | __GenerateEd25519AddressMethod__ | __IsStrongholdPasswordAvailableMethod__ diff --git a/bindings/nodejs/lib/types/wallet/bridge/wallet.ts b/bindings/nodejs/lib/types/wallet/bridge/wallet.ts index 6ed07d0a00..473050a7cb 100644 --- a/bindings/nodejs/lib/types/wallet/bridge/wallet.ts +++ b/bindings/nodejs/lib/types/wallet/bridge/wallet.ts @@ -59,10 +59,6 @@ export type __GetAccountMethod__ = { data: { accountId: AccountIdentifier }; }; -export type __GetChrysalisDataMethod__ = { - name: 'getChrysalisData'; -}; - export type __GetLedgerNanoStatusMethod__ = { name: 'getLedgerNanoStatus'; }; diff --git a/bindings/nodejs/lib/utils/utils.ts b/bindings/nodejs/lib/utils/utils.ts index 7f84c02acb..43fd5ca4d1 100644 --- a/bindings/nodejs/lib/utils/utils.ts +++ b/bindings/nodejs/lib/utils/utils.ts @@ -14,6 +14,7 @@ import { Output, IRent, OutputId, + u64, } from '../types'; import { AccountId, @@ -142,7 +143,7 @@ export class Utils { * @param rent Rent cost of objects which take node resources. * @returns The required storage deposit. */ - static computeStorageDeposit(output: Output, rent: IRent): bigint { + static computeStorageDeposit(output: Output, rent: IRent): u64 { const minStorageDepositAmount = callUtilsMethod({ name: 'computeStorageDeposit', data: { diff --git a/bindings/nodejs/lib/wallet/index.ts b/bindings/nodejs/lib/wallet/index.ts index 860fa4497c..8b1189339e 100644 --- a/bindings/nodejs/lib/wallet/index.ts +++ b/bindings/nodejs/lib/wallet/index.ts @@ -5,4 +5,3 @@ export * from './account'; export * from './wallet'; export * from './wallet-method-handler'; export * from '../types/wallet'; -export { migrateDbChrysalisToStardust } from '../bindings'; diff --git a/bindings/nodejs/lib/wallet/wallet.ts b/bindings/nodejs/lib/wallet/wallet.ts index 17709ad2f2..be7951086f 100644 --- a/bindings/nodejs/lib/wallet/wallet.ts +++ b/bindings/nodejs/lib/wallet/wallet.ts @@ -148,17 +148,6 @@ export class Wallet { return this.methodHandler.getClient(); } - /** - * Get chrysalis data. - */ - async getChrysalisData(): Promise> { - const response = await this.methodHandler.callMethod({ - name: 'getChrysalisData', - }); - - return JSON.parse(response).payload; - } - /** * Get secret manager. */ diff --git a/bindings/wasm/lib/bindings.ts b/bindings/wasm/lib/bindings.ts index 295583d6fc..fded283753 100644 --- a/bindings/wasm/lib/bindings.ts +++ b/bindings/wasm/lib/bindings.ts @@ -9,7 +9,7 @@ import { __UtilsMethods__ } from './utils'; // Import needs to be in a single line, otherwise it breaks // prettier-ignore // @ts-ignore: path is set to match runtime transpiled js path when bundled. -import { initLogger, createClient, destroyClient, createSecretManager, createWallet, callClientMethodAsync, callSecretManagerMethodAsync, callUtilsMethodRust, callWalletMethodAsync, destroyWallet, listenWalletAsync, getClientFromWallet, getSecretManagerFromWallet, listenMqtt, migrateStrongholdSnapshotV2ToV3, migrateDbChrysalisToStardust } from '../wasm/iota_sdk_wasm'; +import { initLogger, createClient, destroyClient, createSecretManager, createWallet, callClientMethodAsync, callSecretManagerMethodAsync, callUtilsMethodRust, callWalletMethodAsync, destroyWallet, listenWalletAsync, getClientFromWallet, getSecretManagerFromWallet, listenMqtt, migrateStrongholdSnapshotV2ToV3 } from '../wasm/iota_sdk_wasm'; const callUtilsMethod = (method: __UtilsMethods__): any => { const response = JSON.parse(callUtilsMethodRust(JSON.stringify(method))); @@ -36,5 +36,4 @@ export { getSecretManagerFromWallet, listenMqtt, migrateStrongholdSnapshotV2ToV3, - migrateDbChrysalisToStardust, }; diff --git a/bindings/wasm/src/wallet.rs b/bindings/wasm/src/wallet.rs index 0f4890af73..891065368b 100644 --- a/bindings/wasm/src/wallet.rs +++ b/bindings/wasm/src/wallet.rs @@ -141,14 +141,3 @@ pub async fn listen_wallet( Ok(JsValue::UNDEFINED) } - -/// Rocksdb chrysalis migration is not supported for WebAssembly bindings. -/// -/// Throws an error if called, only included for compatibility -/// with the Node.js bindings TypeScript definitions. -#[wasm_bindgen(js_name = migrateDbChrysalisToStardust)] -pub fn migrate_db_chrysalis_to_stardust(_storage_path: String, _password: Option) -> Result<(), JsValue> { - let js_error = js_sys::Error::new("Rocksdb chrysalis migration is not supported for WebAssembly"); - - Err(JsValue::from(js_error)) -} diff --git a/sdk/src/types/api/core/response.rs b/sdk/src/types/api/core/response.rs index 84b5835e3e..3d94c17c62 100644 --- a/sdk/src/types/api/core/response.rs +++ b/sdk/src/types/api/core/response.rs @@ -71,12 +71,8 @@ pub struct StatusResponse { /// Returned in [`InfoResponse`]. /// Metric information about the node. -#[derive(Clone, Debug, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct MetricsResponse { #[serde(with = "crate::utils::serde::string")] pub blocks_per_second: f64, @@ -86,12 +82,8 @@ pub struct MetricsResponse { pub confirmation_rate: f64, } -#[derive(Clone, Debug, PartialEq, Eq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct ProtocolParametersResponse { pub parameters: ProtocolParameters, pub start_epoch: EpochIndex, @@ -125,7 +117,6 @@ impl ProtocolParametersMap { } } -#[cfg(feature = "serde")] mod serde_protocol_params_response { use serde::{Deserialize, Deserializer, Serialize, Serializer}; @@ -176,12 +167,8 @@ pub struct BaseTokenResponse { /// Response of GET /api/core/v3/committee /// The validator information of the committee. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct CommitteeResponse { /// The epoch index of the committee. pub epoch_index: EpochIndex, @@ -196,12 +183,8 @@ pub struct CommitteeResponse { } /// Validator information. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct CommitteeMember { /// The account identifier of the validator pub account_id: AccountId, @@ -218,12 +201,8 @@ pub struct CommitteeMember { /// Response of GET /api/core/v3/blocks/issuance /// Information that is ideal for attaching a block in the network. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct IssuanceBlockHeaderResponse { /// Blocks that are strongly directly approved. pub strong_parents: StrongParents, @@ -246,12 +225,8 @@ pub struct SubmitBlockResponse { } /// Describes the state of a block. -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub enum BlockState { // Stored but not confirmed. Pending, @@ -266,12 +241,8 @@ pub enum BlockState { } /// Describes the state of a transaction. -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub enum TransactionState { // Stored but not confirmed. Pending, @@ -284,12 +255,8 @@ pub enum TransactionState { } /// Describes the reason of a block failure. -#[derive(Clone, Copy, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde_repr::Serialize_repr, serde_repr::Deserialize_repr), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Copy, Debug, Eq, PartialEq, serde_repr::Serialize_repr, serde_repr::Deserialize_repr)] +#[serde(rename_all = "camelCase")] #[non_exhaustive] #[repr(u8)] pub enum BlockFailureReason { @@ -419,12 +386,8 @@ pub struct RoutesResponse { /// - GET /api/core/v3/commitments/{commitmentId}/utxo-changes /// - GET /api/core/v3/commitments/by-index/{index}/utxo-changes /// Returns all UTXO changes that happened at a specific slot. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct UtxoChangesResponse { pub index: u32, pub created_outputs: Vec, @@ -433,12 +396,8 @@ pub struct UtxoChangesResponse { /// Response of GET /api/core/v3/accounts/{accountId}/congestion. /// Provides the cost and readiness to issue estimates. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct CongestionResponse { /// The slot index for which the congestion estimate is provided. pub slot_index: SlotIndex, @@ -454,12 +413,8 @@ pub struct CongestionResponse { /// Response of GET /api/core/v3/rewards/{outputId}. /// Returns the mana rewards of an account or delegation output. -#[derive(Clone, Debug, Eq, PartialEq)] -#[cfg_attr( - feature = "serde", - derive(serde::Serialize, serde::Deserialize), - serde(rename_all = "camelCase") -)] +#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] pub struct ManaRewardsResponse { /// The starting epoch index for which the mana rewards are returned. pub epoch_start: u64, // TODO: replace with `EpochIndex` diff --git a/sdk/src/types/block/address/account.rs b/sdk/src/types/block/address/account.rs index 91483b2980..2406576371 100644 --- a/sdk/src/types/block/address/account.rs +++ b/sdk/src/types/block/address/account.rs @@ -57,6 +57,7 @@ impl core::fmt::Debug for AccountAddress { } } +#[cfg(feature = "serde")] mod dto { use serde::{Deserialize, Serialize}; diff --git a/sdk/src/types/block/basic.rs b/sdk/src/types/block/basic.rs index 092a4577aa..c52405f0a0 100644 --- a/sdk/src/types/block/basic.rs +++ b/sdk/src/types/block/basic.rs @@ -248,6 +248,7 @@ impl Packable for BasicBlock { } } +#[cfg(feature = "serde")] pub(crate) mod dto { use alloc::collections::BTreeSet; diff --git a/sdk/src/types/block/context_input/block_issuance_credit.rs b/sdk/src/types/block/context_input/block_issuance_credit.rs index 843b0fea8b..e515c7c030 100644 --- a/sdk/src/types/block/context_input/block_issuance_credit.rs +++ b/sdk/src/types/block/context_input/block_issuance_credit.rs @@ -25,6 +25,7 @@ impl BlockIssuanceCreditContextInput { } } +#[cfg(feature = "serde")] mod dto { use serde::{Deserialize, Serialize}; diff --git a/sdk/src/types/block/context_input/commitment.rs b/sdk/src/types/block/context_input/commitment.rs index d632869a3f..62503b3cbb 100644 --- a/sdk/src/types/block/context_input/commitment.rs +++ b/sdk/src/types/block/context_input/commitment.rs @@ -24,6 +24,7 @@ impl CommitmentContextInput { } } +#[cfg(feature = "serde")] mod dto { use serde::{Deserialize, Serialize}; diff --git a/sdk/src/types/block/context_input/reward.rs b/sdk/src/types/block/context_input/reward.rs index 2f90e3fb30..1c405784d0 100644 --- a/sdk/src/types/block/context_input/reward.rs +++ b/sdk/src/types/block/context_input/reward.rs @@ -35,6 +35,7 @@ impl core::fmt::Display for RewardContextInput { } } +#[cfg(feature = "serde")] mod dto { use serde::{Deserialize, Serialize}; diff --git a/sdk/src/types/block/mana/allotment.rs b/sdk/src/types/block/mana/allotment.rs index 7c92292dc9..01444aef37 100644 --- a/sdk/src/types/block/mana/allotment.rs +++ b/sdk/src/types/block/mana/allotment.rs @@ -17,7 +17,7 @@ use crate::types::block::{output::AccountId, Error}; #[cfg_attr(feature = "serde", derive(serde::Serialize), serde(rename_all = "camelCase"))] pub struct ManaAllotment { pub(crate) account_id: AccountId, - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] pub(crate) mana: u64, } diff --git a/sdk/src/types/block/output/delegation.rs b/sdk/src/types/block/output/delegation.rs index f3a1ff8520..769f5998a6 100644 --- a/sdk/src/types/block/output/delegation.rs +++ b/sdk/src/types/block/output/delegation.rs @@ -1,7 +1,7 @@ // Copyright 2023 IOTA Stiftung // SPDX-License-Identifier: Apache-2.0 -use alloc::{collections::BTreeSet, vec::Vec}; +use alloc::collections::BTreeSet; use packable::{ error::{UnpackError, UnpackErrorExt}, @@ -413,7 +413,10 @@ fn verify_unlock_conditions(unlock_conditions: &UnlockCondit } } +#[cfg(feature = "serde")] pub(crate) mod dto { + use alloc::vec::Vec; + use serde::{Deserialize, Serialize}; use super::*; diff --git a/sdk/src/types/block/output/feature/block_issuer.rs b/sdk/src/types/block/output/feature/block_issuer.rs index e7f8bad8c2..d5887a8a25 100644 --- a/sdk/src/types/block/output/feature/block_issuer.rs +++ b/sdk/src/types/block/output/feature/block_issuer.rs @@ -48,6 +48,7 @@ impl BlockIssuerFeature { } } +#[cfg(feature = "serde")] mod dto { use alloc::vec::Vec; diff --git a/sdk/src/types/block/output/feature/staking.rs b/sdk/src/types/block/output/feature/staking.rs index 11742f69df..c7087d5fac 100644 --- a/sdk/src/types/block/output/feature/staking.rs +++ b/sdk/src/types/block/output/feature/staking.rs @@ -56,7 +56,8 @@ impl StakingFeature { } } -mod dto { +#[cfg(feature = "serde")] +pub(crate) mod dto { use serde::{Deserialize, Serialize}; use super::*; diff --git a/sdk/src/types/block/output/unlock_condition/immutable_account_address.rs b/sdk/src/types/block/output/unlock_condition/immutable_account_address.rs index 86c71de764..5277aec2df 100644 --- a/sdk/src/types/block/output/unlock_condition/immutable_account_address.rs +++ b/sdk/src/types/block/output/unlock_condition/immutable_account_address.rs @@ -26,6 +26,7 @@ impl ImmutableAccountAddressUnlockCondition { } } +#[cfg(feature = "serde")] mod dto { use serde::{Deserialize, Serialize}; diff --git a/sdk/src/types/block/output/unlock_condition/storage_deposit_return.rs b/sdk/src/types/block/output/unlock_condition/storage_deposit_return.rs index f85d059842..3bc031635f 100644 --- a/sdk/src/types/block/output/unlock_condition/storage_deposit_return.rs +++ b/sdk/src/types/block/output/unlock_condition/storage_deposit_return.rs @@ -60,6 +60,8 @@ fn verify_amount_packable( #[cfg(feature = "serde")] pub(crate) mod dto { + use alloc::format; + use serde::{Deserialize, Serialize}; use super::*; diff --git a/sdk/src/types/block/protocol.rs b/sdk/src/types/block/protocol.rs index a8de2797ce..df6813fc45 100644 --- a/sdk/src/types/block/protocol.rs +++ b/sdk/src/types/block/protocol.rs @@ -31,7 +31,7 @@ pub struct ProtocolParameters { pub(crate) version: u8, /// The human friendly name of the network. #[packable(unpack_error_with = |err| Error::InvalidNetworkName(err.into_item_err()))] - #[serde(with = "crate::utils::serde::string_prefix")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string_prefix"))] #[getset(skip)] pub(crate) network_name: StringPrefix, /// The HRP prefix used for Bech32 addresses in the network. @@ -41,10 +41,10 @@ pub struct ProtocolParameters { /// The work score structure used by the node/network. pub(crate) work_score_structure: WorkScoreStructure, /// TokenSupply defines the current token supply on the network. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] pub(crate) token_supply: u64, /// Genesis timestamp at which the slots start to count. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] pub(crate) genesis_unix_timestamp: u64, /// Duration of each slot in seconds. pub(crate) slot_duration_in_seconds: u8, @@ -251,13 +251,13 @@ impl Default for WorkScoreStructure { #[getset(get_copy = "pub")] pub struct CongestionControlParameters { /// Minimum value of the RMC. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] rmc_min: u64, /// Increase step size of the RMC. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] increase: u64, /// Decrease step size of the RMC. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] decrease: u64, /// Threshold for increasing the RMC. increase_threshold: u32, @@ -266,7 +266,7 @@ pub struct CongestionControlParameters { /// Rate at which the scheduler runs (in workscore units per second). scheduler_rate: u32, /// Minimum amount of Mana that an account must have to schedule a block. - #[serde(with = "crate::utils::serde::string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] min_mana: u64, /// Maximum size of the buffer. TODO what buffer? max_buffer_size: u32, diff --git a/sdk/src/types/block/slot/commitment.rs b/sdk/src/types/block/slot/commitment.rs index 4e6ead2c3b..19dd7da10e 100644 --- a/sdk/src/types/block/slot/commitment.rs +++ b/sdk/src/types/block/slot/commitment.rs @@ -4,10 +4,7 @@ use crypto::hashes::{blake2b::Blake2b256, Digest}; use packable::{packer::SlicePacker, Packable, PackableExt}; -use crate::{ - types::block::slot::{RootsId, SlotCommitmentId, SlotIndex}, - utils::serde::string, -}; +use crate::types::block::slot::{RootsId, SlotCommitmentId, SlotIndex}; /// Contains a summary of a slot. /// It is linked to the commitment of the previous slot, which forms a commitment chain. @@ -19,23 +16,23 @@ use crate::{ )] pub struct SlotCommitment { // The version of the protocol running. - #[serde(rename = "version")] + #[cfg_attr(feature = "serde", serde(rename = "version"))] protocol_version: u8, /// The slot index of this commitment. /// It is calculated based on genesis timestamp and the duration of a slot. index: SlotIndex, /// The commitment ID of the previous slot. - #[serde(rename = "prevId")] + #[cfg_attr(feature = "serde", serde(rename = "prevId"))] previous_slot_commitment_id: SlotCommitmentId, /// A BLAKE2b-256 hash of concatenating multiple sparse merkle tree roots of a slot. roots_id: RootsId, /// The sum of previous slot commitment cumulative weight and weight of issuers of accepted blocks within this /// slot. It is just an indication of "committed into" this slot, and can not strictly be used for evaluating /// the switching of a chain. - #[serde(with = "string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] cumulative_weight: u64, /// Reference Mana Cost (RMC) to be used in the slot with index at `index + Max Committable Age`. - #[serde(with = "string")] + #[cfg_attr(feature = "serde", serde(with = "crate::utils::serde::string"))] reference_mana_cost: u64, } diff --git a/sdk/src/types/block/validation.rs b/sdk/src/types/block/validation.rs index 92d4370220..ea0cadef11 100644 --- a/sdk/src/types/block/validation.rs +++ b/sdk/src/types/block/validation.rs @@ -254,6 +254,7 @@ fn validate_protocol_params_hash(hash: &ProtocolParametersHash, params: &Protoco Ok(()) } +#[cfg(feature = "serde")] pub(crate) mod dto { use alloc::collections::BTreeSet; diff --git a/sdk/src/wallet/core/operations/storage.rs b/sdk/src/wallet/core/operations/storage.rs index 282e421769..9eb6db79a7 100644 --- a/sdk/src/wallet/core/operations/storage.rs +++ b/sdk/src/wallet/core/operations/storage.rs @@ -13,8 +13,8 @@ mod storage_stub { }, wallet::{ core::builder::dto::WalletBuilderDto, - storage::constants::{CHRYSALIS_STORAGE_KEY, SECRET_MANAGER_KEY, WALLET_INDEXATION_KEY}, - Wallet, WalletBuilder, + storage::constants::{SECRET_MANAGER_KEY, WALLET_INDEXATION_KEY}, + WalletBuilder, }, }; @@ -84,14 +84,6 @@ mod storage_stub { Ok(res.map(Into::into)) } } - - impl Wallet { - pub async fn get_chrysalis_data( - &self, - ) -> crate::wallet::Result>> { - self.storage_manager.read().await.get(CHRYSALIS_STORAGE_KEY).await - } - } } #[cfg(not(feature = "storage"))] mod storage_stub { diff --git a/sdk/src/wallet/storage/constants.rs b/sdk/src/wallet/storage/constants.rs index 29d9fd973c..ae75d94881 100644 --- a/sdk/src/wallet/storage/constants.rs +++ b/sdk/src/wallet/storage/constants.rs @@ -31,5 +31,3 @@ pub(crate) const DATABASE_SCHEMA_VERSION_KEY: &str = "database-schema-version"; pub(crate) const PARTICIPATION_EVENTS: &str = "participation-events"; #[cfg(feature = "participation")] pub(crate) const PARTICIPATION_CACHED_OUTPUTS: &str = "participation-cached-outputs"; - -pub(crate) const CHRYSALIS_STORAGE_KEY: &str = "chrysalis-data"; diff --git a/sdk/tests/wallet/fixtures/no_secret_manager_data.stronghold b/sdk/tests/wallet/fixtures/no_secret_manager_data.stronghold new file mode 100644 index 0000000000..8595f9ce7f Binary files /dev/null and b/sdk/tests/wallet/fixtures/no_secret_manager_data.stronghold differ