Skip to content

Commit ca172ef

Browse files
authored
Merge pull request #5268 from zajko/fixing_compilation_warnings
Fixing import macros to get rid of warning messages
2 parents 4c7068d + 170594e commit ca172ef

File tree

8 files changed

+81
-62
lines changed

8 files changed

+81
-62
lines changed

node/src/types/transaction/initiator_addr_and_secret_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) enum InitiatorAddrAndSecretKey<'a> {
2323

2424
impl InitiatorAddrAndSecretKey<'_> {
2525
/// The address of the initiator of a `TransactionV1`.
26-
pub fn initiator_addr(&self) -> InitiatorAddr {
26+
pub(crate) fn initiator_addr(&self) -> InitiatorAddr {
2727
match self {
2828
InitiatorAddrAndSecretKey::Both { initiator_addr, .. }
2929
| InitiatorAddrAndSecretKey::InitiatorAddr(initiator_addr) => initiator_addr.clone(),
@@ -34,7 +34,7 @@ impl InitiatorAddrAndSecretKey<'_> {
3434
}
3535

3636
/// The secret key of the initiator of a `TransactionV1`.
37-
pub fn secret_key(&self) -> Option<&SecretKey> {
37+
pub(crate) fn secret_key(&self) -> Option<&SecretKey> {
3838
match self {
3939
InitiatorAddrAndSecretKey::Both { secret_key, .. }
4040
| InitiatorAddrAndSecretKey::SecretKey(secret_key) => Some(secret_key),

types/src/chainspec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ pub use accounts_config::{
4242
};
4343
pub use activation_point::ActivationPoint;
4444
pub use chainspec_raw_bytes::ChainspecRawBytes;
45+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
46+
pub use core_config::DEFAULT_FEE_HANDLING;
4547
pub use core_config::{
4648
ConsensusProtocolName, CoreConfig, LegacyRequiredFinality, DEFAULT_GAS_HOLD_INTERVAL,
4749
DEFAULT_MINIMUM_BID_AMOUNT,
4850
};
4951
#[cfg(any(feature = "std", test))]
50-
pub use core_config::{
51-
DEFAULT_BASELINE_MOTES_AMOUNT, DEFAULT_FEE_HANDLING, DEFAULT_REFUND_HANDLING,
52-
};
52+
pub use core_config::{DEFAULT_BASELINE_MOTES_AMOUNT, DEFAULT_REFUND_HANDLING};
5353
pub use fee_handling::FeeHandling;
5454
#[cfg(any(feature = "std", test))]
5555
pub use genesis_config::GenesisConfig;

types/src/transaction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ mod deploy;
55
mod error;
66
mod execution_info;
77
mod initiator_addr;
8-
#[cfg(any(feature = "std", test, feature = "testing"))]
8+
#[cfg(any(test, feature = "testing"))]
99
mod initiator_addr_and_secret_key;
1010
mod package_identifier;
1111
mod pricing_mode;
@@ -73,7 +73,7 @@ pub use deploy::{
7373
pub use error::InvalidTransaction;
7474
pub use execution_info::ExecutionInfo;
7575
pub use initiator_addr::InitiatorAddr;
76-
#[cfg(any(feature = "std", feature = "testing", test))]
76+
#[cfg(any(feature = "testing", test))]
7777
pub(crate) use initiator_addr_and_secret_key::InitiatorAddrAndSecretKey;
7878
pub use package_identifier::PackageIdentifier;
7979
pub use pricing_mode::{PricingMode, PricingModeError};
@@ -86,7 +86,7 @@ pub use transaction_scheduling::TransactionScheduling;
8686
pub use transaction_target::{TransactionRuntimeParams, TransactionTarget};
8787
#[cfg(feature = "json-schema")]
8888
pub(crate) use transaction_v1::arg_handling;
89-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
89+
#[cfg(any(feature = "testing", feature = "gens", test))]
9090
pub(crate) use transaction_v1::fields_container::FieldsContainer;
9191
pub use transaction_v1::{
9292
InvalidTransactionV1, TransactionArgs, TransactionV1, TransactionV1DecodeFromJsonError,

types/src/transaction/deploy.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,10 @@ use core::{
1515
#[cfg(any(feature = "std", test))]
1616
use std::convert::TryFrom;
1717

18-
#[cfg(feature = "datasize")]
19-
use datasize::DataSize;
2018
#[cfg(any(feature = "std", test))]
21-
use itertools::Itertools;
22-
#[cfg(feature = "json-schema")]
23-
use once_cell::sync::Lazy;
24-
#[cfg(any(feature = "once_cell", test))]
25-
use once_cell::sync::OnceCell;
19+
use super::{get_lane_for_non_install_wasm, PricingMode};
2620
#[cfg(any(all(feature = "std", feature = "testing"), test))]
27-
use rand::Rng;
28-
#[cfg(feature = "json-schema")]
29-
use schemars::JsonSchema;
30-
#[cfg(any(feature = "std", test))]
31-
use serde::{Deserialize, Serialize};
32-
#[cfg(any(all(feature = "std", feature = "testing"), test))]
33-
use tracing::{debug, warn};
34-
35-
#[cfg(any(feature = "std", test))]
36-
use super::{get_lane_for_non_install_wasm, InitiatorAddr, InitiatorAddrAndSecretKey, PricingMode};
21+
use super::{InitiatorAddr, InitiatorAddrAndSecretKey};
3722
#[cfg(any(
3823
all(feature = "std", feature = "testing"),
3924
feature = "json-schema",
@@ -58,6 +43,22 @@ use crate::{
5843
transaction::{Approval, ApprovalsHash},
5944
Digest, DisplayIter, PublicKey, SecretKey, TimeDiff, Timestamp,
6045
};
46+
#[cfg(feature = "datasize")]
47+
use datasize::DataSize;
48+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
49+
use itertools::Itertools;
50+
#[cfg(feature = "json-schema")]
51+
use once_cell::sync::Lazy;
52+
#[cfg(any(feature = "once_cell", test))]
53+
use once_cell::sync::OnceCell;
54+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
55+
use rand::Rng;
56+
#[cfg(feature = "json-schema")]
57+
use schemars::JsonSchema;
58+
#[cfg(any(feature = "std", test))]
59+
use serde::{Deserialize, Serialize};
60+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
61+
use tracing::{debug, warn};
6162

6263
#[cfg(any(feature = "std", test))]
6364
use crate::{chainspec::PricingHandling, Chainspec, Phase, TransactionV1Config, MINT_LANE_ID};
@@ -197,7 +198,7 @@ impl Deploy {
197198
)
198199
}
199200

200-
#[cfg(any(feature = "std", test))]
201+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
201202
#[allow(clippy::too_many_arguments)]
202203
fn build(
203204
timestamp: Timestamp,

types/src/transaction/initiator_addr_and_secret_key.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pub(crate) enum InitiatorAddrAndSecretKey<'a> {
2323

2424
impl InitiatorAddrAndSecretKey<'_> {
2525
/// The address of the initiator of a `TransactionV1`.
26-
pub fn initiator_addr(&self) -> InitiatorAddr {
26+
pub(crate) fn initiator_addr(&self) -> InitiatorAddr {
2727
match self {
2828
InitiatorAddrAndSecretKey::Both { initiator_addr, .. }
2929
| InitiatorAddrAndSecretKey::InitiatorAddr(initiator_addr) => initiator_addr.clone(),
@@ -34,7 +34,7 @@ impl InitiatorAddrAndSecretKey<'_> {
3434
}
3535

3636
/// The secret key of the initiator of a `TransactionV1`.
37-
pub fn secret_key(&self) -> Option<&SecretKey> {
37+
pub(crate) fn secret_key(&self) -> Option<&SecretKey> {
3838
match self {
3939
InitiatorAddrAndSecretKey::Both { secret_key, .. }
4040
| InitiatorAddrAndSecretKey::SecretKey(secret_key) => Some(secret_key),

types/src/transaction/transaction_v1.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,34 @@ mod transaction_args;
66
mod transaction_v1_hash;
77
pub mod transaction_v1_payload;
88

9-
#[cfg(any(feature = "std", feature = "testing", test))]
9+
#[cfg(any(feature = "testing", test))]
1010
use super::InitiatorAddrAndSecretKey;
11+
#[cfg(any(feature = "testing", test))]
12+
use crate::testing::TestRng;
13+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
14+
use crate::LARGE_WASM_LANE_ID;
1115
use crate::{
1216
bytesrepr::{self, Error, FromBytes, ToBytes},
1317
crypto,
1418
};
15-
#[cfg(any(all(feature = "std", feature = "testing"), test))]
16-
use crate::{testing::TestRng, TransactionConfig, LARGE_WASM_LANE_ID};
1719
#[cfg(any(feature = "std", test))]
1820
use crate::{
1921
TransactionEntryPoint, TransactionTarget, TransactionV1Config, AUCTION_LANE_ID,
2022
INSTALL_UPGRADE_LANE_ID, MINT_LANE_ID,
2123
};
22-
#[cfg(any(feature = "std", test, feature = "testing"))]
24+
#[cfg(any(test, feature = "testing"))]
2325
use alloc::collections::BTreeMap;
2426
use alloc::{collections::BTreeSet, vec::Vec};
2527
#[cfg(feature = "datasize")]
2628
use datasize::DataSize;
2729
use errors_v1::FieldDeserializationError;
28-
#[cfg(any(all(feature = "std", feature = "testing"), test))]
30+
#[cfg(any(feature = "testing", test))]
2931
use fields_container::FieldsContainer;
3032
#[cfg(any(all(feature = "std", feature = "testing"), test))]
3133
use fields_container::{ENTRY_POINT_MAP_KEY, TARGET_MAP_KEY};
3234
#[cfg(any(feature = "once_cell", test))]
3335
use once_cell::sync::OnceCell;
34-
#[cfg(any(all(feature = "std", feature = "testing"), test))]
36+
#[cfg(any(feature = "testing", test))]
3537
use rand::Rng;
3638
#[cfg(feature = "json-schema")]
3739
use schemars::JsonSchema;
@@ -48,7 +50,7 @@ use super::{
4850
serialization::{CalltableSerializationEnvelope, CalltableSerializationEnvelopeBuilder},
4951
Approval, ApprovalsHash, InitiatorAddr, PricingMode,
5052
};
51-
#[cfg(any(feature = "std", feature = "testing", test))]
53+
#[cfg(any(feature = "testing", test))]
5254
use crate::bytesrepr::Bytes;
5355
use crate::{Digest, DisplayIter, SecretKey, TimeDiff, Timestamp};
5456

@@ -170,7 +172,7 @@ impl TransactionV1 {
170172
}
171173
}
172174

173-
#[cfg(any(feature = "std", test, feature = "testing"))]
175+
#[cfg(any(test, feature = "testing"))]
174176
pub(crate) fn build(
175177
chain_name: String,
176178
timestamp: Timestamp,
@@ -282,10 +284,10 @@ impl TransactionV1 {
282284
}
283285

284286
/// Returns a random, valid but possibly expired transaction.
285-
#[cfg(any(all(feature = "std", feature = "testing"), test))]
287+
#[cfg(any(feature = "testing", test))]
286288
pub fn random(rng: &mut TestRng) -> Self {
287289
let secret_key = SecretKey::random(rng);
288-
let ttl_millis = rng.gen_range(60_000..TransactionConfig::default().max_ttl.millis());
290+
let ttl_millis = rng.gen_range(60_000..TimeDiff::from_seconds(2 * 60 * 60).millis());
289291
let timestamp = Timestamp::random(rng);
290292
let container = FieldsContainer::random(rng);
291293
let initiator_addr_and_secret_key = InitiatorAddrAndSecretKey::SecretKey(&secret_key);
@@ -313,7 +315,7 @@ impl TransactionV1 {
313315
let secret_key = SecretKey::random(rng);
314316
let timestamp = maybe_timestamp.unwrap_or_else(Timestamp::now);
315317
let ttl_millis = ttl.map_or(
316-
rng.gen_range(60_000..TransactionConfig::default().max_ttl.millis()),
318+
rng.gen_range(60_000..TimeDiff::from_seconds(2 * 60 * 60).millis()),
317319
|ttl| ttl.millis(),
318320
);
319321
let container = FieldsContainer::random_of_lane(rng, lane);

types/src/transaction/transaction_v1/arg_handling.rs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,55 @@ use crate::TransferTarget;
44

55
use crate::{bytesrepr::ToBytes, CLTyped, CLValueError, PublicKey, RuntimeArgs, URef, U512};
66

7+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
78
const TRANSFER_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
8-
9+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
910
const TRANSFER_ARG_SOURCE: OptionalArg<URef> = OptionalArg::new("source");
11+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1012
const TRANSFER_ARG_TARGET: &str = "target";
13+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1114
// "id" for legacy reasons, if the argument is passed it is [Option]
1215
const TRANSFER_ARG_ID: OptionalArg<Option<u64>> = OptionalArg::new("id");
1316

17+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1418
const ADD_BID_ARG_PUBLIC_KEY: RequiredArg<PublicKey> = RequiredArg::new("public_key");
19+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1520
const ADD_BID_ARG_DELEGATION_RATE: RequiredArg<u8> = RequiredArg::new("delegation_rate");
21+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1622
const ADD_BID_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
17-
23+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
1824
const ADD_BID_ARG_MINIMUM_DELEGATION_AMOUNT: OptionalArg<u64> =
1925
OptionalArg::new("minimum_delegation_amount");
20-
26+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
2127
const ADD_BID_ARG_MAXIMUM_DELEGATION_AMOUNT: OptionalArg<u64> =
2228
OptionalArg::new("maximum_delegation_amount");
23-
29+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
2430
const ADD_BID_ARG_RESERVED_SLOTS: OptionalArg<u32> = OptionalArg::new("reserved_slots");
25-
31+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
2632
const WITHDRAW_BID_ARG_PUBLIC_KEY: RequiredArg<PublicKey> = RequiredArg::new("public_key");
33+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
2734
const WITHDRAW_BID_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
28-
35+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
2936
const DELEGATE_ARG_DELEGATOR: RequiredArg<PublicKey> = RequiredArg::new("delegator");
37+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3038
const DELEGATE_ARG_VALIDATOR: RequiredArg<PublicKey> = RequiredArg::new("validator");
39+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3140
const DELEGATE_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
3241

42+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3343
const UNDELEGATE_ARG_DELEGATOR: RequiredArg<PublicKey> = RequiredArg::new("delegator");
44+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3445
const UNDELEGATE_ARG_VALIDATOR: RequiredArg<PublicKey> = RequiredArg::new("validator");
46+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3547
const UNDELEGATE_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
3648

49+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3750
const REDELEGATE_ARG_DELEGATOR: RequiredArg<PublicKey> = RequiredArg::new("delegator");
51+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3852
const REDELEGATE_ARG_VALIDATOR: RequiredArg<PublicKey> = RequiredArg::new("validator");
53+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
3954
const REDELEGATE_ARG_AMOUNT: RequiredArg<U512> = RequiredArg::new("amount");
55+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
4056
const REDELEGATE_ARG_NEW_VALIDATOR: RequiredArg<PublicKey> = RequiredArg::new("new_validator");
4157

4258
struct RequiredArg<T> {
@@ -81,6 +97,7 @@ impl<T> OptionalArg<T> {
8197
}
8298
}
8399

100+
#[cfg(any(feature = "json-schema", feature = "testing", test))]
84101
/// Creates a `RuntimeArgs` suitable for use in a transfer transaction.
85102
pub(crate) fn new_transfer_args<A: Into<U512>, T: Into<TransferTarget>>(
86103
amount: A,

types/src/transaction/transaction_v1/fields_container.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,44 @@
11
#[cfg(any(feature = "testing", test))]
22
use crate::testing::TestRng;
3-
#[cfg(any(feature = "std", feature = "testing", test))]
3+
#[cfg(any(feature = "testing", test))]
44
use crate::{
55
bytesrepr::{Bytes, ToBytes},
66
transaction::transaction_v1::*,
77
TransactionEntryPoint, TransactionScheduling, TransactionTarget,
88
};
99
#[cfg(any(feature = "testing", test))]
10-
use crate::{
11-
PublicKey, RuntimeArgs, TransactionInvocationTarget, TransferTarget, AUCTION_LANE_ID,
12-
INSTALL_UPGRADE_LANE_ID, MINT_LANE_ID,
13-
};
14-
#[cfg(any(feature = "std", feature = "testing", test))]
10+
use crate::{PublicKey, RuntimeArgs, TransactionInvocationTarget, TransferTarget};
11+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
12+
use crate::{AUCTION_LANE_ID, INSTALL_UPGRADE_LANE_ID, MINT_LANE_ID};
13+
#[cfg(any(feature = "testing", test))]
1514
use alloc::collections::BTreeMap;
1615
#[cfg(any(feature = "testing", test))]
1716
use rand::{Rng, RngCore};
1817

19-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
18+
#[cfg(any(feature = "testing", feature = "gens", test))]
2019
pub(crate) const ARGS_MAP_KEY: u16 = 0;
21-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
20+
#[cfg(any(feature = "testing", feature = "gens", test))]
2221
pub(crate) const TARGET_MAP_KEY: u16 = 1;
23-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
22+
#[cfg(any(feature = "testing", feature = "gens", test))]
2423
pub(crate) const ENTRY_POINT_MAP_KEY: u16 = 2;
25-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
24+
#[cfg(any(feature = "testing", feature = "gens", test))]
2625
pub(crate) const SCHEDULING_MAP_KEY: u16 = 3;
2726

28-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
27+
#[cfg(any(feature = "testing", feature = "gens", test))]
2928
#[derive(Clone, Eq, PartialEq, Debug)]
3029
pub(crate) enum FieldsContainerError {
3130
CouldNotSerializeField { field_index: u16 },
3231
}
3332

34-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
33+
#[cfg(any(feature = "testing", feature = "gens", test))]
3534
pub(crate) struct FieldsContainer {
3635
pub(super) args: TransactionArgs,
3736
pub(super) target: TransactionTarget,
3837
pub(super) entry_point: TransactionEntryPoint,
3938
pub(super) scheduling: TransactionScheduling,
4039
}
4140

42-
#[cfg(any(feature = "std", feature = "testing", feature = "gens", test))]
41+
#[cfg(any(feature = "testing", feature = "gens", test))]
4342
impl FieldsContainer {
4443
pub(crate) fn new(
4544
args: TransactionArgs,
@@ -208,7 +207,7 @@ impl FieldsContainer {
208207
}
209208

210209
/// Returns a random `FieldsContainer`.
211-
#[cfg(any(feature = "testing", test))]
210+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
212211
pub fn random_of_lane(rng: &mut TestRng, lane_id: u8) -> Self {
213212
match lane_id {
214213
MINT_LANE_ID => Self::random_transfer(rng),
@@ -218,7 +217,7 @@ impl FieldsContainer {
218217
}
219218
}
220219

221-
#[cfg(any(feature = "testing", test))]
220+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
222221
fn random_transfer(rng: &mut TestRng) -> Self {
223222
let amount = rng.gen_range(2_500_000_000..=u64::MAX);
224223
let maybe_source = if rng.gen() { Some(rng.gen()) } else { None };
@@ -233,7 +232,7 @@ impl FieldsContainer {
233232
)
234233
}
235234

236-
#[cfg(any(feature = "testing", test))]
235+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
237236
fn random_install_upgrade(rng: &mut TestRng) -> Self {
238237
let target = TransactionTarget::Session {
239238
module_bytes: Bytes::from(rng.random_vec(0..100)),
@@ -248,7 +247,7 @@ impl FieldsContainer {
248247
)
249248
}
250249

251-
#[cfg(any(feature = "testing", test))]
250+
#[cfg(any(all(feature = "std", feature = "testing"), test))]
252251
fn random_staking(rng: &mut TestRng) -> Self {
253252
let public_key = PublicKey::random(rng);
254253
let delegation_rate = rng.gen();

0 commit comments

Comments
 (0)