Skip to content
This repository has been archived by the owner on May 21, 2024. It is now read-only.

feat: add asset conversion pallet #309

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,637 changes: 834 additions & 803 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ trappist-runtime = { path = "runtime/trappist" }
stout-runtime = { path = "runtime/stout" }
jsonrpsee = { version = "0.16.2" }

# External Dependencies
pallet-dex-rpc = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v1.1.0" }
pallet-dex = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v1.1.0" }
pallet-dex-rpc-runtime-api = { version = "0.0.1", git = "https://github.com/paritytech/substrate-dex.git", default-features = false, branch = "polkadot-v1.1.0" }

# Trappist Pallets
pallet-asset-registry = { default-features = false, path = "pallets/asset-registry" }
trappist-runtime-benchmarks = { default-features = false, path = "pallets/benchmarks" }
Expand Down Expand Up @@ -119,6 +114,7 @@ frame-system-benchmarking = { git = "https://github.com/paritytech/polkadot-sdk"
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }

## Substrate Pallet Dependencies
pallet-asset-conversion = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-assets = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-asset-tx-payment = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
pallet-aura = { git = "https://github.com/paritytech/polkadot-sdk", default-features = false, branch = "release-polkadot-v1.1.0" }
Expand Down
3 changes: 0 additions & 3 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ trappist-runtime = { workspace = true, optional = true }
stout-runtime = { workspace = true, optional = true }
jsonrpsee = { workspace = true, features = ["server"] }

# External Dependencies
pallet-dex-rpc = { workspace = true }

# Substrate
frame-benchmarking = { workspace = true, features = ["std"] }
frame-benchmarking-cli = { workspace = true }
Expand Down
6 changes: 4 additions & 2 deletions node/src/chain_spec/stout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ use sc_service::ChainType;
use sp_core::sr25519;
use stout_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig,
CouncilConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig,
CouncilConfig, ForeignAssetsConfig, PoolAssetsConfig, RuntimeGenesisConfig, SessionConfig,
SessionKeys, SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "stout";
Expand Down Expand Up @@ -156,6 +157,7 @@ pub fn testnet_genesis(
members: invulnerables.into_iter().map(|x| x.0).collect::<Vec<_>>(),
phantom: Default::default(),
},
dex: Default::default(),
foreign_assets: ForeignAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
pool_assets: PoolAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
}
}
9 changes: 6 additions & 3 deletions node/src/chain_spec/trappist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
use trappist_runtime::{
constants::currency::EXISTENTIAL_DEPOSIT, AccountId, AssetsConfig, AuraId, BalancesConfig,
CouncilConfig, RuntimeGenesisConfig, SessionConfig, SessionKeys, SudoConfig, SystemConfig,
CouncilConfig, ForeignAssetsConfig, PoolAssetsConfig, RuntimeGenesisConfig, SessionConfig,
SessionKeys, SudoConfig, SystemConfig,
};

const DEFAULT_PROTOCOL_ID: &str = "hop";
Expand Down Expand Up @@ -214,7 +215,8 @@ pub fn testnet_genesis(
treasury: Default::default(),
safe_mode: Default::default(),
tx_pause: Default::default(),
dex: Default::default(),
foreign_assets: ForeignAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
pool_assets: PoolAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
transaction_payment: Default::default(),
}
}
Expand Down Expand Up @@ -332,7 +334,8 @@ fn trappist_live_genesis(
treasury: Default::default(),
safe_mode: Default::default(),
tx_pause: Default::default(),
dex: Default::default(),
foreign_assets: ForeignAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
pool_assets: PoolAssetsConfig { assets: vec![], accounts: vec![], metadata: vec![] },
transaction_payment: Default::default(),
}
}
3 changes: 0 additions & 3 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,11 @@ where
C::Api: frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: BlockBuilder<Block>,
C::Api: pallet_dex_rpc::DexRuntimeApi<Block, AssetId, Balance, Balance>,
P: TransactionPool + Sync + Send + 'static,
B: sc_client_api::Backend<Block> + Send + Sync + 'static,
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashingFor<Block>>,
{
use frame_rpc_system::{System, SystemApiServer};
use pallet_dex_rpc::{Dex, DexApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use substrate_state_trie_migration_rpc::{StateMigration, StateMigrationApiServer};

Expand All @@ -73,7 +71,6 @@ where
module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(StateMigration::new(client.clone(), backend, deny_unsafe).into_rpc())?;
module.merge(Dex::new(client).into_rpc())?;

Ok(module)
}
4 changes: 0 additions & 4 deletions node/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ where
+ sp_session::SessionKeys<Block>
+ sp_api::ApiExt<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ pallet_dex_rpc::DexRuntimeApi<Block, AssetId, Balance, Balance>
+ sp_block_builder::BlockBuilder<Block>,
BIQ: FnOnce(
Arc<ParachainClient<RuntimeApi>>,
Expand Down Expand Up @@ -232,7 +231,6 @@ where
+ sp_block_builder::BlockBuilder<Block>
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>
+ pallet_dex_rpc::DexRuntimeApi<Block, AssetId, Balance, Balance>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
RB: Fn(Arc<ParachainClient<RuntimeApi>>) -> Result<jsonrpsee::RpcModule<()>, sc_service::Error>,
BIQ: FnOnce(
Expand Down Expand Up @@ -519,7 +517,6 @@ where
+ cumulus_primitives_core::CollectCollationInfo<Block>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppCrypto>::Pair as Pair>::Public>
+ pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>
+ pallet_dex_rpc::DexRuntimeApi<Block, AssetId, Balance, Balance>
+ frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
Expand Down Expand Up @@ -609,7 +606,6 @@ where
+ sp_api::ApiExt<Block>
+ sp_offchain::OffchainWorkerApi<Block>
+ sp_block_builder::BlockBuilder<Block>
+ pallet_dex_rpc::DexRuntimeApi<Block, AssetId, Balance, Balance>
+ sp_consensus_aura::AuraApi<Block, <<AuraId as AppCrypto>::Pair as Pair>::Public>,
<<AuraId as AppCrypto>::Pair as Pair>::Signature:
TryFrom<Vec<u8>> + std::hash::Hash + sp_runtime::traits::Member + Codec,
Expand Down
11 changes: 6 additions & 5 deletions runtime/stout/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ frame-system-benchmarking = { workspace = true, optional = true }
frame-system-rpc-runtime-api = { workspace = true }

## Substrate Pallet Dependencies
pallet-asset-conversion = { workspace = true }
pallet-assets = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
pallet-aura = { workspace = true }
Expand All @@ -68,6 +69,7 @@ pallet-uniques = { workspace = true }
pallet-utility = { workspace = true }

# Cumulus dependencies
assets-common = { workspace = true }
cumulus-pallet-aura-ext = { workspace = true }
cumulus-pallet-dmp-queue = { workspace = true }
cumulus-pallet-parachain-system = { workspace = true }
Expand Down Expand Up @@ -95,8 +97,6 @@ xcm-primitives = { workspace = true }
pallet-xcm-benchmarks = { workspace = true, optional = true }

# External Pallets
pallet-dex = { workspace = true }
pallet-dex-rpc-runtime-api = { workspace = true }
pallet-asset-registry = { workspace = true }

[features]
Expand All @@ -122,6 +122,7 @@ std = [
"frame-support/std",
"frame-system/std",
"frame-system-rpc-runtime-api/std",
"pallet-asset-conversion/std",
"pallet-assets/std",
"pallet-asset-tx-payment/std",
"pallet-aura/std",
Expand All @@ -131,8 +132,6 @@ std = [
"pallet-collective/std",
"pallet-contracts/std",
"pallet-contracts-primitives/std",
"pallet-dex/std",
"pallet-dex-rpc-runtime-api/std",
"pallet-identity/std",
"pallet-multisig/std",
"pallet-insecure-randomness-collective-flip/std",
Expand All @@ -145,6 +144,7 @@ std = [
"pallet-uniques/std",
"pallet-utility/std",
"pallet-xcm/std",
"assets-common/std",
"cumulus-pallet-aura-ext/std",
"cumulus-pallet-parachain-system/std",
"cumulus-pallet-xcm/std",
Expand All @@ -170,13 +170,13 @@ runtime-benchmarks = [
"frame-system-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-asset-conversion/runtime-benchmarks",
"pallet-assets/runtime-benchmarks",
"pallet-asset-registry/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"pallet-collator-selection/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
"pallet-contracts/runtime-benchmarks",
"pallet-dex/runtime-benchmarks",
"pallet-identity/runtime-benchmarks",
"pallet-multisig/runtime-benchmarks",
"pallet-scheduler/runtime-benchmarks",
Expand All @@ -187,4 +187,5 @@ runtime-benchmarks = [
"cumulus-pallet-session-benchmarking/runtime-benchmarks",
"cumulus-pallet-xcmp-queue/runtime-benchmarks",
"cumulus-pallet-parachain-system/runtime-benchmarks",
"assets-common/runtime-benchmarks",
]
Loading