Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all 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
27 changes: 1 addition & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ members = [
"frame/conviction-voting",
"frame/democracy",
"frame/dex",
"frame/dex/rpc",
"frame/dex/rpc/runtime-api",
"frame/fast-unstake",
"frame/try-runtime",
"frame/elections-phragmen",
Expand Down
1 change: 0 additions & 1 deletion bin/node/rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jsonrpsee = { version = "0.16.2", features = ["server"] }
node-primitives = { version = "2.0.0", path = "../primitives" }
pallet-transaction-payment-rpc = { version = "4.0.0-dev", path = "../../../frame/transaction-payment/rpc/" }
mmr-rpc = { version = "4.0.0-dev", path = "../../../client/merkle-mountain-range/rpc/" }
pallet-dex-rpc = { version = "4.0.0-dev", path = "../../../frame/dex/rpc/" }
sc-chain-spec = { version = "4.0.0-dev", path = "../../../client/chain-spec" }
sc-client-api = { version = "4.0.0-dev", path = "../../../client/api" }
sc-consensus-babe = { version = "0.10.0-dev", path = "../../../client/consensus/babe" }
Expand Down
3 changes: 0 additions & 3 deletions bin/node/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: mmr_rpc::MmrRuntimeApi<Block, <Block as sp_runtime::traits::Block>::Hash, BlockNumber>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: pallet_dex_rpc::DexRuntimeApi<Block, Balance>,
C::Api: BabeApi<Block>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + 'static,
Expand All @@ -119,7 +118,6 @@ where
B::State: sc_client_api::backend::StateBackend<sp_runtime::traits::HashFor<Block>>,
{
use mmr_rpc::{Mmr, MmrApiServer};
use pallet_dex_rpc::{Dex, DexApiServer};
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use sc_consensus_babe_rpc::{Babe, BabeApiServer};
use sc_finality_grandpa_rpc::{Grandpa, GrandpaApiServer};
Expand Down Expand Up @@ -152,7 +150,6 @@ where
// These RPCs should use an asynchronous caller instead.
io.merge(Mmr::new(client.clone()).into_rpc())?;
io.merge(TransactionPayment::new(client.clone()).into_rpc())?;
io.merge(Dex::new(client.clone()).into_rpc())?;
io.merge(
Babe::new(
client.clone(),
Expand Down
3 changes: 1 addition & 2 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ pallet-uniques = { version = "4.0.0-dev", default-features = false, path = "../.
pallet-vesting = { version = "4.0.0-dev", default-features = false, path = "../../../frame/vesting" }
pallet-whitelist = { version = "4.0.0-dev", default-features = false, path = "../../../frame/whitelist" }
pallet-dex = { version = "4.0.0-dev", default-features = false, path = "../../../frame/dex" }
pallet-dex-rpc-runtime-api = { version = "4.0.0-dev", default-features = false, path = "../../../frame/dex/rpc/runtime-api/" }

[build-dependencies]
substrate-wasm-builder = { version = "5.0.0-dev", path = "../../../utils/wasm-builder" }
Expand Down Expand Up @@ -205,7 +204,6 @@ std = [
"sp-io/std",
"pallet-child-bounties/std",
"pallet-alliance/std",
"pallet-dex-rpc-runtime-api/std",
"pallet-dex/std",
]
runtime-benchmarks = [
Expand All @@ -224,6 +222,7 @@ runtime-benchmarks = [
"pallet-contracts/runtime-benchmarks",
"pallet-conviction-voting/runtime-benchmarks",
"pallet-democracy/runtime-benchmarks",
"pallet-dex/runtime-benchmarks",
"pallet-election-provider-multi-phase/runtime-benchmarks",
"pallet-election-provider-support-benchmarking/runtime-benchmarks",
"pallet-elections-phragmen/runtime-benchmarks",
Expand Down
2 changes: 1 addition & 1 deletion bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,7 @@ impl_runtime_apis! {
}
}

impl pallet_dex_rpc_runtime_api::DexApi<
impl pallet_dex::DexApi<
Block,
Balance,
> for Runtime
Expand Down
1 change: 1 addition & 0 deletions frame/dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]
[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
scale-info = { version = "2.0.0", default-features = false, features = ["derive"] }
sp-api = { version = "4.0.0-dev", default-features = false, path = "../../primitives/api" }
sp-std = { version = "5.0.0", default-features = false, path = "../../primitives/std" }
sp-runtime = { version = "7.0.0", default-features = false, path = "../../primitives/runtime" }
frame-support = { version = "4.0.0-dev", default-features = false, path = "../support" }
Expand Down
23 changes: 0 additions & 23 deletions frame/dex/rpc/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions frame/dex/rpc/README.md

This file was deleted.

28 changes: 0 additions & 28 deletions frame/dex/rpc/runtime-api/Cargo.toml

This file was deleted.

3 changes: 0 additions & 3 deletions frame/dex/rpc/runtime-api/README.md

This file was deleted.

31 changes: 0 additions & 31 deletions frame/dex/rpc/runtime-api/src/lib.rs

This file was deleted.

103 changes: 0 additions & 103 deletions frame/dex/rpc/src/lib.rs

This file was deleted.

21 changes: 20 additions & 1 deletion frame/dex/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,16 @@
//! - provide the liquidity and receive back an LP token
//! - exchange the LP token back to assets
//! - swap 2 assets if there is a pool created
//! - query for an exchange price via a new RPC endpoint
//! - query for an exchange price via a new runtime call endpoint
//!
//! Here is an example `state_call` that asks for a quote of a pool of native versus asset 1:
//!
//! ```text
//! curl -sS -H "Content-Type: application/json" -d \
//! '{"id":1, "jsonrpc":"2.0", "method": "state_call", "params": ["DexApi_quote_price", "0x0101000000000000000000000011"]}' \
//! http://localhost:9933/
//! ```

#![cfg_attr(not(feature = "std"), no_std)]
use frame_support::traits::Incrementable;

Expand All @@ -43,7 +52,9 @@ mod tests;
#[cfg(test)]
mod mock;

use codec::Codec;
pub use pallet::*;
use sp_runtime::traits::MaybeDisplay;
pub use types::*;
pub use weights::WeightInfo;

Expand Down Expand Up @@ -834,3 +845,11 @@ pub mod pallet {
}
}
}

sp_api::decl_runtime_apis! {
pub trait DexApi<Balance> where
Balance: Codec + MaybeDisplay,
{
fn quote_price(asset1: Option<u32>, asset2: Option<u32>, amount: u64) -> Option<Balance>;
}
}