diff --git a/Cargo.lock b/Cargo.lock index a4c0abd482..ba80354435 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5231,7 +5231,7 @@ dependencies = [ [[package]] name = "orml-currencies" version = "0.4.1-dev" -source = "git+https://github.com/bifrost-finance/open-runtime-module-library.git?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" +source = "git+https://github.com/bifrost-finance/open-runtime-module-library?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" dependencies = [ "frame-support", "frame-system", @@ -5247,7 +5247,7 @@ dependencies = [ [[package]] name = "orml-tokens" version = "0.4.1-dev" -source = "git+https://github.com/bifrost-finance/open-runtime-module-library.git?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" +source = "git+https://github.com/bifrost-finance/open-runtime-module-library?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" dependencies = [ "frame-support", "frame-system", @@ -5262,7 +5262,7 @@ dependencies = [ [[package]] name = "orml-traits" version = "0.4.1-dev" -source = "git+https://github.com/bifrost-finance/open-runtime-module-library.git?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" +source = "git+https://github.com/bifrost-finance/open-runtime-module-library?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" dependencies = [ "frame-support", "impl-trait-for-tuples", @@ -5279,7 +5279,7 @@ dependencies = [ [[package]] name = "orml-utilities" version = "0.4.1-dev" -source = "git+https://github.com/bifrost-finance/open-runtime-module-library.git?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" +source = "git+https://github.com/bifrost-finance/open-runtime-module-library?rev=3229e4d662b12e9a3f98a56c75a6d74e73bc204c#3229e4d662b12e9a3f98a56c75a6d74e73bc204c" dependencies = [ "frame-support", "parity-scale-codec", @@ -11871,7 +11871,7 @@ dependencies = [ [[package]] name = "zenlink-protocol" version = "0.4.2" -source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module.git?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" +source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" dependencies = [ "cumulus-primitives-core", "frame-support", @@ -11891,7 +11891,7 @@ dependencies = [ [[package]] name = "zenlink-protocol-rpc" version = "0.4.2" -source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module.git?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" +source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" dependencies = [ "jsonrpc-core", "jsonrpc-core-client", @@ -11908,7 +11908,7 @@ dependencies = [ [[package]] name = "zenlink-protocol-runtime-api" version = "0.4.2" -source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module.git?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" +source = "git+ssh://git@github.com/bifrost-finance/Zenlink-DEX-Module?branch=polkadot-v0.9.8#8e9e87081b579e950a544f33cd380b38772370a1" dependencies = [ "parity-scale-codec", "sp-api", diff --git a/node/primitives/src/traits.rs b/node/primitives/src/traits.rs index b513bfb30f..054219ab4b 100644 --- a/node/primitives/src/traits.rs +++ b/node/primitives/src/traits.rs @@ -52,25 +52,6 @@ pub trait TokenPriceHandler { fn set_token_price(asset_id: CurrencyId, price: Price); } -/// Asset redeem handler -pub trait AssetRedeem { - /// Asset redeem - fn asset_redeem( - asset_id: CurrencyId, - target: AccountId, - amount: Balance, - to_name: Option>, - ); -} - -/// Bridge asset from other blockchain to Bifrost -pub trait BridgeAssetFrom { - fn bridge_asset_from( - target: AccountId, - bridge_asset: BridgeAssetBalance, - ); -} - /// Bridge asset from Bifrost to other blockchain pub trait BridgeAssetTo { type Error; diff --git a/pallets/bridge/Cargo.toml b/pallets/bridge/Cargo.toml deleted file mode 100644 index 387409c465..0000000000 --- a/pallets/bridge/Cargo.toml +++ /dev/null @@ -1,32 +0,0 @@ -[package] -name = "bifrost-bridge" -version = "0.6.0" -authors = ["Edwin Wang "] -edition = "2018" - -[dependencies] -codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] } -frame-support = { version = "2.0.0-rc6", default-features = false } -inherents = { version = "2.0.0-rc6", package = "sp-inherents", default-features = false } -node-primitives = { path = "../../node/primitives", default-features = false } -sp-core = { version = "2.0.0-rc6", default-features = false } -sp-runtime = { version = "2.0.0-rc6", default-features = false } -sp-std = { version = "2.0.0-rc6", default-features = false } -system = { version = "2.0.0-rc6", package = "frame-system", default-features = false } - -[dev-dependencies] -sp-io = { version = "2.0.0-rc6" } -substrate-offchain = { version = "2.0.0-rc6", package = "sp-offchain" } - -[features] -default = ["std"] -std = [ - "codec/std", - "frame-support/std", - "inherents/std", - "node-primitives/std", - "sp-core/std", - "sp-runtime/std", - "sp-std/std", - "system/std", -] diff --git a/pallets/bridge/src/lib.rs b/pallets/bridge/src/lib.rs deleted file mode 100644 index a45086ad1d..0000000000 --- a/pallets/bridge/src/lib.rs +++ /dev/null @@ -1,147 +0,0 @@ -// This file is part of Bifrost. - -// Copyright (C) 2019-2021 Liebi Technologies (UK) 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 . - -// Ensure we're `no_std` when compiling for Wasm. -#![cfg_attr(not(feature = "std"), no_std)] - -use codec::{Decode, Encode}; -use frame_support::{decl_event, decl_module, decl_storage, ensure, Parameter}; -use sp_runtime::traits::{Member, AtLeast32Bit, SaturatedConversion}; -use sp_std::prelude::*; -use system::ensure_root; - -use node_primitives::{ - AssetCreate, AssetIssue, AssetRedeem, BlockchainType, - BridgeAssetBalance, BridgeAssetFrom, BridgeAssetSymbol, BridgeAssetTo -}; - -mod mock; -mod tests; - -#[derive(Encode, Decode, Default, Clone, Eq, PartialEq, Debug)] -pub struct Bank { - account: Vec, - authorities: Vec>, - threshold: u32, -} - -/// The module configuration trait. -pub trait Config: system::Config { - /// The overarching event type. - type Event: From> + Into<::Event>; - - /// The units in which we record balances. - type Balance: Member + Parameter + AtLeast32Bit + Default + Copy; - - /// The arithmetic type of asset identifier. - type AssetId: Member + Parameter + AtLeast32Bit + Default + Copy; - - /// Assets create handler - type AssetCreate: AssetCreate; - - /// Assets issue handler - type AssetIssue: AssetIssue; - - /// The units in which we record asset precision. - type Precision: Member + Parameter + AtLeast32Bit + Default + Copy; - - /// Bridge asset to another blockchain. - type BridgeAssetTo: BridgeAssetTo; -} - -decl_event!( - pub enum Event where ::AssetId { - /// Transaction from another blockchain was mapped. - BridgeTxMapped, - /// Transaction from another blockchain was received. - BridgeTxReceived, - /// Transaction received from another blockchain was confirmed. - BridgeTxReceiveConfirmed, - /// Transaction to another blockchain was sent. - BridgeTxSent, - /// Bridge asset was created. - BridgeAssetCreated(AssetId), - } -); - -decl_storage! { - trait Store for Module as Bridge { - // Associate account id in Bifrost to account in other blockchain - BridgeAccountIdToAccount get(fn bridge_account): map hasher(blake2_128_concat) T::AccountId => Vec; - - // Associate asset id in Bifrost to asset symbol in other blockchain - BridgeAssetIdToAsset get(fn bridge_asset): map hasher(blake2_128_concat) T::AssetId => BridgeAssetSymbol; - - // Associate account in other blockchain to account id in Bifrost - BridgeAccountToAccountId get(fn bridge_account_id): map hasher(blake2_128_concat) Vec => T::AccountId ; - - // Associate asset symbol in other blockchain to asset id in Bifrost - BridgeAssetToAssetId get(fn bridge_asset_id): map hasher(blake2_128_concat) BridgeAssetSymbol => T::AssetId; - } -} - -decl_module! { - pub struct Module for enum Call where origin: T::Origin { - - fn deposit_event() = default; - - pub fn bridge_asset_create( - origin, - blockchain: BlockchainType, - symbol: Vec, - precision: T::Precision, - ) { - ensure_root(origin)?; - - ensure!(symbol.len() > 0, "token symbol must great then 0"); - ensure!(symbol.len() <= 32, "token symbol cannot exceed 32 bytes"); - ensure!(precision.saturated_into::() <= 16, "token precision cannot exceed 16"); - - let (asset_id, _) = T::AssetCreate::asset_create(symbol.clone(), precision.saturated_into::()); - let asset_symbol = BridgeAssetSymbol::new(blockchain, symbol, precision); - >::insert(asset_id, asset_symbol.clone()); - >::insert(asset_symbol, asset_id); - - Self::deposit_event(RawEvent::BridgeAssetCreated(asset_id)); - } - } -} - -impl AssetRedeem for Module { - fn asset_redeem(asset_id: T::AssetId, target: T::AccountId, amount: T::Balance, to_name: Option>) { - let account = >::get(target); - let symbol = >::get(asset_id); - let bridge_asset = BridgeAssetBalance:: { - symbol, - amount, - }; - T::BridgeAssetTo::bridge_asset_to(account, bridge_asset); - } -} - -impl BridgeAssetFrom for Module { - fn bridge_asset_from(target: T::AccountId, bridge_asset: BridgeAssetBalance) { - let asset_id = >::get(bridge_asset.symbol); - T::AssetIssue::asset_issue(asset_id, TokenSymbol::VToken, target.clone(), bridge_asset.amount); - } -} - -// The main implementation block for the module. -impl Module { - -} diff --git a/pallets/bridge/src/mock.rs b/pallets/bridge/src/mock.rs deleted file mode 100644 index ade953ebaa..0000000000 --- a/pallets/bridge/src/mock.rs +++ /dev/null @@ -1,86 +0,0 @@ -// This file is part of Bifrost. - -// Copyright (C) 2019-2021 Liebi Technologies (UK) 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 . - -//! Test utilities - -#![cfg(test)] - -use crate as pallet_bridge; -use frame_support::{parameter_types, construct_runtime}; -use sp_core::H256; -use sp_runtime::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::{Header, TestXt}}; -use super::*; - -type UncheckedExtrinsic = frame_system::mocking::MockUncheckedExtrinsic; -type Block = frame_system::mocking::MockBlock; - -construct_runtime!( - pub enum Test where - Block = Block, - NodeBlock = Block, - UncheckedExtrinsic = UncheckedExtrinsic, - { - System: frame_system::{Module, Call, Config, Storage, Event}, - Bridge: pallet_bridge::{Module, Call, Storage, Event}, - } -); - -parameter_types! { - pub const BlockHashCount: u64 = 250; - pub BlockWeights: frame_system::limits::BlockWeights = - frame_system::limits::BlockWeights::simple_max(1024); -} -impl frame_system::Config for Test { - type BaseCallFilter = (); - type BlockWeights = (); - type BlockLength = (); - type DbWeight = (); - type Origin = Origin; - type Index = u64; - type BlockNumber = u64; - type Hash = H256; - type Call = Call; - type Hashing = BlakeTwo256; - type AccountId = u64; - type Lookup = IdentityLookup; - type Header = Header; - type Event = Event; - type BlockHashCount = BlockHashCount; - type Version = (); - type PalletInfo = PalletInfo; - type AccountData = (); - type OnNewAccount = (); - type OnKilledAccount = (); - type SystemWeightInfo = (); - type SS58Prefix = (); -} - -impl Config for Test { - type Event = Event; - type Balance = u64; - type AssetId = u32; - type AssetCreate = (); - type AssetIssue = (); - type Precision = u32; - type BridgeAssetTo = (); -} - -pub fn new_test_ext() -> sp_io::TestExternalities { - let t = frame_system::GenesisConfig::default().build_storage::().unwrap(); - t.into() -} diff --git a/pallets/bridge/src/tests.rs b/pallets/bridge/src/tests.rs deleted file mode 100644 index df672acfae..0000000000 --- a/pallets/bridge/src/tests.rs +++ /dev/null @@ -1,21 +0,0 @@ -// This file is part of Bifrost. - -// Copyright (C) 2019-2021 Liebi Technologies (UK) 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 . - -//! Tests for the module. - -#![cfg(test)] \ No newline at end of file