mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 18:01:04 +00:00
Rename Primitive Crates (#271)
* Rename Ethereum PoA primitives crate The "sp" prefix comes from Substrate primitives, since this crate originated in that repo. However, it is not part of Substrate anymore and its name should be updated to reflect that. * Rename currency exchange primitives * Rust Fmt * Update import in benchmarking module * Rust Fmt * Split pub and no-pub * Sort toml files. Co-authored-by: Tomasz Drwięga <tomasz@parity.io>
This commit is contained in:
committed by
Bastian Köcher
parent
868814e4b6
commit
9f6bd28384
@@ -7,9 +7,9 @@ edition = "2018"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
bp-currency-exchange = { path = "../../primitives/currency-exchange", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
sp-currency-exchange = { path = "../../primitives/currency-exchange", default-features = false }
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
[dependencies.frame-support]
|
||||
@@ -56,13 +56,13 @@ git = "https://github.com/paritytech/substrate/"
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-currency-exchange/std",
|
||||
"codec/std",
|
||||
"frame-benchmarking/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"serde",
|
||||
"sp-currency-exchange/std",
|
||||
"sp-std/std",
|
||||
"sp-runtime/std",
|
||||
"sp-std/std",
|
||||
]
|
||||
runtime-benchmarks = ["frame-benchmarking"]
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter};
|
||||
use sp_currency_exchange::{
|
||||
use bp_currency_exchange::{
|
||||
CurrencyConverter, DepositInto, Error as ExchangeError, MaybeLockFundsTransaction, RecipientsMap,
|
||||
};
|
||||
use frame_support::{decl_error, decl_module, decl_storage, ensure, Parameter};
|
||||
use sp_runtime::DispatchResult;
|
||||
|
||||
#[cfg(feature = "runtime-benchmarks")]
|
||||
@@ -221,9 +221,9 @@ fn prepare_deposit_details<T: Trait<I>, I: Instance>(
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bp_currency_exchange::LockFundsTransaction;
|
||||
use frame_support::{assert_noop, assert_ok, impl_outer_origin, parameter_types, weights::Weight};
|
||||
use sp_core::H256;
|
||||
use sp_currency_exchange::LockFundsTransaction;
|
||||
use sp_runtime::{
|
||||
testing::Header,
|
||||
traits::{BlakeTwo256, IdentityLookup},
|
||||
@@ -272,7 +272,7 @@ mod tests {
|
||||
type Recipient = AccountId;
|
||||
type Amount = u64;
|
||||
|
||||
fn parse(tx: &Self::Transaction) -> sp_currency_exchange::Result<RawTransaction> {
|
||||
fn parse(tx: &Self::Transaction) -> bp_currency_exchange::Result<RawTransaction> {
|
||||
match tx.id {
|
||||
INVALID_TRANSACTION_ID => Err(ExchangeError::InvalidTransaction),
|
||||
_ => Ok(tx.clone()),
|
||||
@@ -286,7 +286,7 @@ mod tests {
|
||||
type PeerRecipient = AccountId;
|
||||
type Recipient = AccountId;
|
||||
|
||||
fn map(peer_recipient: Self::PeerRecipient) -> sp_currency_exchange::Result<Self::Recipient> {
|
||||
fn map(peer_recipient: Self::PeerRecipient) -> bp_currency_exchange::Result<Self::Recipient> {
|
||||
match peer_recipient {
|
||||
UNKNOWN_RECIPIENT_ID => Err(ExchangeError::FailedToMapRecipients),
|
||||
_ => Ok(peer_recipient * 10),
|
||||
@@ -300,7 +300,7 @@ mod tests {
|
||||
type SourceAmount = u64;
|
||||
type TargetAmount = u64;
|
||||
|
||||
fn convert(amount: Self::SourceAmount) -> sp_currency_exchange::Result<Self::TargetAmount> {
|
||||
fn convert(amount: Self::SourceAmount) -> bp_currency_exchange::Result<Self::TargetAmount> {
|
||||
match amount {
|
||||
INVALID_AMOUNT => Err(ExchangeError::FailedToConvertCurrency),
|
||||
_ => Ok(amount * 10),
|
||||
@@ -314,7 +314,7 @@ mod tests {
|
||||
type Recipient = AccountId;
|
||||
type Amount = u64;
|
||||
|
||||
fn deposit_into(_recipient: Self::Recipient, amount: Self::Amount) -> sp_currency_exchange::Result<()> {
|
||||
fn deposit_into(_recipient: Self::Recipient, amount: Self::Amount) -> bp_currency_exchange::Result<()> {
|
||||
match amount {
|
||||
amount if amount < MAX_DEPOSIT_AMOUNT * 10 => Ok(()),
|
||||
amount if amount == MAX_DEPOSIT_AMOUNT * 10 => Err(ExchangeError::DepositPartiallyFailed),
|
||||
|
||||
@@ -7,10 +7,10 @@ edition = "2018"
|
||||
license = "GPL-3.0-or-later WITH Classpath-exception-2.0"
|
||||
|
||||
[dependencies]
|
||||
serde = { version = "1.0", optional = true }
|
||||
bp-eth-poa = { path = "../../primitives/ethereum-poa", default-features = false }
|
||||
codec = { package = "parity-scale-codec", version = "1.3.1", default-features = false }
|
||||
hex-literal = "0.3"
|
||||
primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", default-features = false }
|
||||
serde = { version = "1.0", optional = true }
|
||||
|
||||
# Substrate Based Dependencies
|
||||
[dependencies.frame-support]
|
||||
@@ -58,18 +58,17 @@ features = ["hmac"]
|
||||
|
||||
# Dev Dependencies
|
||||
[dev-dependencies]
|
||||
# TODO: Stop renaming this on import
|
||||
primitives = { package = "sp-bridge-eth-poa", path = "../../primitives/ethereum-poa", features = ["std"] }
|
||||
bp-eth-poa = { path = "../../primitives/ethereum-poa", features = ["std"] }
|
||||
libsecp256k1 = { version = "0.3.4", features = ["hmac"] }
|
||||
|
||||
[features]
|
||||
default = ["std"]
|
||||
std = [
|
||||
"bp-eth-poa/std",
|
||||
"codec/std",
|
||||
"frame-benchmarking/std",
|
||||
"frame-support/std",
|
||||
"frame-system/std",
|
||||
"primitives/std",
|
||||
"serde",
|
||||
"sp-io/std",
|
||||
"sp-runtime/std",
|
||||
|
||||
@@ -21,9 +21,9 @@ use crate::test_utils::{
|
||||
HeaderBuilder,
|
||||
};
|
||||
|
||||
use bp_eth_poa::{compute_merkle_root, U256};
|
||||
use frame_benchmarking::benchmarks_instance;
|
||||
use frame_system::RawOrigin;
|
||||
use primitives::{compute_merkle_root, U256};
|
||||
|
||||
benchmarks_instance! {
|
||||
_ { }
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::Storage;
|
||||
use bp_eth_poa::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256};
|
||||
use codec::{Decode, Encode};
|
||||
use primitives::{public_to_address, Address, Header, HeaderId, SealedEmptyStep, H256};
|
||||
use sp_io::crypto::secp256k1_ecdsa_recover;
|
||||
use sp_runtime::RuntimeDebug;
|
||||
use sp_std::collections::{
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::finality::finalize_blocks;
|
||||
use crate::validators::{Validators, ValidatorsConfiguration};
|
||||
use crate::verification::{is_importable_header, verify_aura_header};
|
||||
use crate::{AuraConfiguration, ChangeToEnact, PruningStrategy, Storage};
|
||||
use primitives::{Header, HeaderId, Receipt};
|
||||
use bp_eth_poa::{Header, HeaderId, Receipt};
|
||||
use sp_std::{collections::btree_map::BTreeMap, prelude::*};
|
||||
|
||||
/// Imports bunch of headers and updates blocks finality.
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
#![allow(clippy::large_enum_variant)]
|
||||
|
||||
use crate::finality::{CachedFinalityVotes, FinalityVotes};
|
||||
use bp_eth_poa::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256};
|
||||
use codec::{Decode, Encode};
|
||||
use frame_support::{decl_module, decl_storage, traits::Get};
|
||||
use primitives::{Address, Header, HeaderId, RawTransaction, RawTransactionReceipt, Receipt, H256, U256};
|
||||
use sp_runtime::{
|
||||
transaction_validity::{
|
||||
InvalidTransaction, TransactionLongevity, TransactionPriority, TransactionSource, TransactionValidity,
|
||||
@@ -1025,7 +1025,7 @@ pub(crate) mod tests {
|
||||
genesis, insert_header, run_test, run_test_with_genesis, validators_addresses, HeaderBuilder, TestRuntime,
|
||||
GAS_LIMIT,
|
||||
};
|
||||
use primitives::compute_merkle_root;
|
||||
use bp_eth_poa::compute_merkle_root;
|
||||
|
||||
const TOTAL_VALIDATORS: usize = 3;
|
||||
|
||||
@@ -1036,7 +1036,7 @@ pub(crate) mod tests {
|
||||
fn example_tx_receipt(success: bool) -> Vec<u8> {
|
||||
Receipt {
|
||||
// the only thing that we care of:
|
||||
outcome: primitives::TransactionOutcome::StatusCode(if success { 1 } else { 0 }),
|
||||
outcome: bp_eth_poa::TransactionOutcome::StatusCode(if success { 1 } else { 0 }),
|
||||
gas_used: Default::default(),
|
||||
log_bloom: Default::default(),
|
||||
logs: Vec::new(),
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
// along with Parity Bridges Common. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pub use crate::test_utils::{insert_header, validator_utils::*, validators_change_receipt, HeaderBuilder, GAS_LIMIT};
|
||||
pub use primitives::signatures::secret_to_address;
|
||||
pub use bp_eth_poa::signatures::secret_to_address;
|
||||
|
||||
use crate::validators::{ValidatorsConfiguration, ValidatorsSource};
|
||||
use crate::{AuraConfiguration, GenesisConfig, PruningStrategy, Trait};
|
||||
use bp_eth_poa::{Address, Header, H256, U256};
|
||||
use frame_support::{impl_outer_origin, parameter_types, weights::Weight};
|
||||
use primitives::{Address, Header, H256, U256};
|
||||
use secp256k1::SecretKey;
|
||||
use sp_runtime::{
|
||||
testing::Header as SubstrateHeader,
|
||||
|
||||
@@ -29,7 +29,7 @@ use crate::validators::CHANGE_EVENT_HASH;
|
||||
use crate::verification::calculate_score;
|
||||
use crate::{HeaderToImport, Storage, Trait};
|
||||
|
||||
use primitives::{
|
||||
use bp_eth_poa::{
|
||||
rlp_encode,
|
||||
signatures::{secret_to_address, sign, SignHeader},
|
||||
Address, Bloom, Header, Receipt, SealedEmptyStep, H256, U256,
|
||||
@@ -53,7 +53,7 @@ impl HeaderBuilder {
|
||||
Self {
|
||||
header: Header {
|
||||
gas_limit: GAS_LIMIT.into(),
|
||||
seal: vec![primitives::rlp_encode(¤t_step), vec![]],
|
||||
seal: vec![bp_eth_poa::rlp_encode(¤t_step), vec![]],
|
||||
..Default::default()
|
||||
},
|
||||
parent_header: Default::default(),
|
||||
@@ -95,7 +95,7 @@ impl HeaderBuilder {
|
||||
pub fn with_number(number: u64) -> Self {
|
||||
Self::with_parent(&Header {
|
||||
number: number - 1,
|
||||
seal: vec![primitives::rlp_encode(&(number - 1)), vec![]],
|
||||
seal: vec![bp_eth_poa::rlp_encode(&(number - 1)), vec![]],
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
@@ -109,7 +109,7 @@ impl HeaderBuilder {
|
||||
parent_hash: parent_header.compute_hash(),
|
||||
number: parent_header.number + 1,
|
||||
gas_limit: GAS_LIMIT.into(),
|
||||
seal: vec![primitives::rlp_encode(¤t_step), vec![]],
|
||||
seal: vec![bp_eth_poa::rlp_encode(¤t_step), vec![]],
|
||||
difficulty: calculate_score(parent_step, current_step, 0),
|
||||
..Default::default()
|
||||
},
|
||||
@@ -242,7 +242,7 @@ pub fn insert_header<S: Storage>(storage: &mut S, header: Header) {
|
||||
}
|
||||
|
||||
pub fn validators_change_receipt(parent_hash: H256) -> Receipt {
|
||||
use primitives::{LogEntry, TransactionOutcome};
|
||||
use bp_eth_poa::{LogEntry, TransactionOutcome};
|
||||
|
||||
Receipt {
|
||||
gas_used: 0.into(),
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::error::Error;
|
||||
use crate::{ChangeToEnact, Storage};
|
||||
use primitives::{Address, Header, HeaderId, LogEntry, Receipt, U256};
|
||||
use bp_eth_poa::{Address, Header, HeaderId, LogEntry, Receipt, U256};
|
||||
use sp_std::prelude::*;
|
||||
|
||||
/// The hash of InitiateChange event of the validators set contract.
|
||||
@@ -278,8 +278,8 @@ pub(crate) mod tests {
|
||||
use crate::mock::{run_test, validators_addresses, validators_change_receipt, TestRuntime};
|
||||
use crate::DefaultInstance;
|
||||
use crate::{BridgeStorage, Headers, ScheduledChange, ScheduledChanges, StoredHeader};
|
||||
use bp_eth_poa::compute_merkle_root;
|
||||
use frame_support::StorageMap;
|
||||
use primitives::compute_merkle_root;
|
||||
|
||||
const TOTAL_VALIDATORS: usize = 3;
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
use crate::error::Error;
|
||||
use crate::validators::{Validators, ValidatorsConfiguration};
|
||||
use crate::{AuraConfiguration, ImportContext, PoolConfiguration, ScheduledChange, Storage};
|
||||
use codec::Encode;
|
||||
use primitives::{
|
||||
use bp_eth_poa::{
|
||||
public_to_address, step_validator, Address, Header, HeaderId, Receipt, SealedEmptyStep, H256, H520, U128, U256,
|
||||
};
|
||||
use codec::Encode;
|
||||
use sp_io::crypto::secp256k1_ecdsa_recover;
|
||||
use sp_runtime::transaction_validity::TransactionTag;
|
||||
use sp_std::{vec, vec::Vec};
|
||||
@@ -366,8 +366,8 @@ mod tests {
|
||||
pool_configuration, BridgeStorage, FinalizedBlock, Headers, HeadersByNumber, NextValidatorsSetId,
|
||||
ScheduledChanges, ValidatorsSet, ValidatorsSets,
|
||||
};
|
||||
use bp_eth_poa::{compute_merkle_root, rlp_encode, TransactionOutcome, H520};
|
||||
use frame_support::{StorageMap, StorageValue};
|
||||
use primitives::{compute_merkle_root, rlp_encode, TransactionOutcome, H520};
|
||||
use secp256k1::SecretKey;
|
||||
use sp_runtime::transaction_validity::TransactionTag;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user