Skip to content

Commit

Permalink
Resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
MJLNSN committed Sep 24, 2024
2 parents 8817d17 + 394f729 commit 008bfdb
Show file tree
Hide file tree
Showing 46 changed files with 5,825 additions and 2,484 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion node/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bifrost-cli"
version = "0.13.0"
version = "0.14.0"
authors = ["Liebi Technologies <bifrost@liebi.com>"]
description = "Bifrost Parachain Node"
build = "build.rs"
Expand Down
78 changes: 78 additions & 0 deletions pallets/deprecated/salp/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
[package]
name = "bifrost-salp"
version = "0.8.0"
authors = ["Edwin Wang <lark930@gmail.com>", "Ron yang<yrong1997@gmail.com>"]
edition = "2021"

[dependencies]
parity-scale-codec = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }
log = { workspace = true }
bifrost-primitives = { workspace = true }
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-benchmarking = { workspace = true, optional = true }
sp-std = { workspace = true }
sp-io = { workspace = true }
sp-runtime = { workspace = true }
sp-arithmetic = { workspace = true }
orml-traits = { workspace = true }
orml-tokens = { workspace = true }
bifrost-xcm-interface = { workspace = true }
zenlink-protocol = { workspace = true }
cumulus-primitives-core = { workspace = true }
pallet-xcm = { workspace = true }
xcm = { workspace = true }
xcm-builder = { workspace = true }
bifrost-stable-pool = { workspace = true }
bifrost-stable-asset = { workspace = true }
bifrost-vtoken-minting = { workspace = true }

[dev-dependencies]
pallet-multisig = { workspace = true }
pallet-sudo = { workspace = true }
pallet-collective = { workspace = true }
sp-core = { workspace = true }
bifrost-currencies = { workspace = true }
orml-xtokens = { workspace = true }
pallet-balances = { workspace = true }
bifrost-asset-registry = { workspace = true }
xcm-executor = { workspace = true }


[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"scale-info/std",
"log/std",
"bifrost-primitives/std",
"frame-support/std",
"frame-system/std",
"sp-std/std",
"sp-io/std",
"sp-runtime/std",
"sp-arithmetic/std",
"orml-traits/std",
"bifrost-xcm-interface/std",
"xcm-builder/std",
"zenlink-protocol/std",
"bifrost-asset-registry/std",
"cumulus-primitives-core/std",
"pallet-xcm/std",
"pallet-sudo/std",
"xcm/std",
"pallet-multisig/std",
"pallet-collective/std",
"orml-xtokens/std",
]

runtime-benchmarks = [
"frame-benchmarking",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"xcm-builder/runtime-benchmarks",
"pallet-xcm/runtime-benchmarks",
"pallet-collective/runtime-benchmarks",
]
try-runtime = [ "frame-support/try-runtime" ]
16 changes: 16 additions & 0 deletions pallets/deprecated/salp/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[package]
name = "bifrost-salp-rpc"
version = "0.8.0"
authors = ["Ron Yang <yrong1997@gmail.com>"]
edition = "2021"

[dependencies]
parity-scale-codec = { workspace = true, features = ["derive"] }
jsonrpsee = { workspace = true, features = ["server", "macros"] }
sp-api = { workspace = true }
sp-runtime = { workspace = true }
sp-blockchain = { workspace = true }
sp-core = { workspace = true }
sp-rpc = { workspace = true }
bifrost-primitives = { workspace = true }
bifrost-salp-rpc-runtime-api = { workspace = true }
18 changes: 18 additions & 0 deletions pallets/deprecated/salp/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "bifrost-salp-rpc-runtime-api"
version = "0.8.0"
authors = ["Ron Yang<yrong1997@gmail.com>"]
edition = "2021"

[dependencies]
parity-scale-codec = { workspace = true, features = ["derive"] }
sp-api = { workspace = true }
bifrost-primitives = { workspace = true }

[features]
default = ["std"]
std = [
"parity-scale-codec/std",
"sp-api/std",
"bifrost-primitives/std",
]
35 changes: 35 additions & 0 deletions pallets/deprecated/salp/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#![cfg_attr(not(feature = "std"), no_std)]

use bifrost_primitives::{Balance, RpcContributionStatus};
use parity_scale_codec::Codec;
use sp_api::decl_runtime_apis;

decl_runtime_apis! {
pub trait SalpRuntimeApi<ParaId,AccountId> where
ParaId: Codec,
AccountId: Codec,
{
fn get_contribution(
index: ParaId,
who: AccountId
) -> (Balance,RpcContributionStatus);
}
}
101 changes: 101 additions & 0 deletions pallets/deprecated/salp/rpc/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// This file is part of Bifrost.

// Copyright (C) Liebi Technologies PTE. LTD.
// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

use std::{marker::PhantomData, sync::Arc};

use bifrost_primitives::{Balance, RpcContributionStatus};
pub use bifrost_salp_rpc_runtime_api::{self as runtime_api, SalpRuntimeApi};
use jsonrpsee::{
core::{async_trait, RpcResult},
proc_macros::rpc,
types::error::{ErrorCode, ErrorObject},
};
use parity_scale_codec::Codec;
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_rpc::number::NumberOrHex;
use sp_runtime::{sp_std::convert::TryInto, traits::Block as BlockT};

#[derive(Clone, Debug)]
pub struct SalpRpc<C, Block> {
client: Arc<C>,
_marker: PhantomData<Block>,
}

impl<C, Block> SalpRpc<C, Block> {
pub fn new(client: Arc<C>) -> Self {
Self { client, _marker: PhantomData }
}
}

fn convert_rpc_params(value: Balance) -> RpcResult<NumberOrHex> {
value.try_into().map_err(|e| {
ErrorObject::owned(
ErrorCode::InvalidParams.code(),
format!("{} doesn't fit in NumberOrHex representation", value),
Some(format!("{:?}", e)),
)
})
}

#[rpc(client, server)]
pub trait SalpRpcApi<BlockHash, ParaId, AccountId> {
/// rpc method for getting current contribution
#[method(name = "salp_getContribution")]
fn get_contribution(
&self,
index: ParaId,
who: AccountId,
at: Option<BlockHash>,
) -> RpcResult<(NumberOrHex, RpcContributionStatus)>;
}

#[async_trait]
impl<C, Block, ParaId, AccountId> SalpRpcApiServer<<Block as BlockT>::Hash, ParaId, AccountId>
for SalpRpc<C, Block>
where
Block: BlockT,
C: Send + Sync + 'static + ProvideRuntimeApi<Block> + HeaderBackend<Block>,
C::Api: SalpRuntimeApi<Block, ParaId, AccountId>,
ParaId: Codec,
AccountId: Codec,
{
fn get_contribution(
&self,
index: ParaId,
account: AccountId,
at: Option<<Block as BlockT>::Hash>,
) -> RpcResult<(NumberOrHex, RpcContributionStatus)> {
let salp_rpc_api = self.client.runtime_api();
let at = at.unwrap_or_else(|| self.client.info().best_hash);

let rs = salp_rpc_api.get_contribution(at, index, account);

match rs {
Ok((val, status)) => match convert_rpc_params(val) {
Ok(value) => Ok((value, status)),
Err(e) => Err(e),
},
Err(e) => Err(ErrorObject::owned(
ErrorCode::InternalError.code(),
"Failed to get salp contribution.",
Some(format!("{:?}", e)),
)),
}
}
}
Loading

0 comments on commit 008bfdb

Please sign in to comment.