Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
DaviRain-Su committed Feb 26, 2024
1 parent 0f9fc0c commit ddd17df
Show file tree
Hide file tree
Showing 14 changed files with 194 additions and 176 deletions.
7 changes: 2 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[workspace]
members = [
"app/transfer",
"ibc-support",
"core",
]
members = ["app/transfer", "ibc-support", "core"]
resolver = "2"
89 changes: 50 additions & 39 deletions app/transfer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,61 +14,72 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
# substrate crates
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
] }
frame-benchmarking = { version = "28.0.0", default-features = false, optional = true, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
frame-support = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
frame-system = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
hex = { version = "0.4.0", default-features = false }
ibc-support = { version = "0.1.0", default-features = false, path = "../../ibc-support" }
log = { version = "0.4", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
primitive-types = { version = "0.12.0", default-features = false, features = ["serde_no_std"] }
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
scale-info = { version = "2.10.0", default-features = false, features = [
"derive",
] }
sp-io = { version = "30.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-runtime = { version = "31.0.1", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-std = { version = "14.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
primitive-types = { version = "0.12.0", default-features = false, features = [
"serde_no_std",
] }
pallet-timestamp = { version = "27.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }

ibc = { version = "0.41.0", default-features = false, features = ["parity-scale-codec", "serde"] }
ibc-proto = { version = "0.30.0", default-features = false, features = ["parity-scale-codec"] }
ibc = { version = "0.41.0", default-features = false, features = [
"parity-scale-codec",
"serde",
] }
ibc-proto = { version = "0.30.0", default-features = false, features = [
"parity-scale-codec",
] }
pallet-ibc = { version = "4.0.0-dev", default-features = false, path = "../../core" }

[dev-dependencies]
chrono = "0.4.19"
frame-support = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-support = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
hex = '0.4.0'
pallet-assets = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-babe = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-balances = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-assets = { version = "29.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-babe = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-balances = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-ibc = { version = "4.0.0-dev", path = "../../core" }
pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
serde = "1.0.142"
pallet-timestamp = { version = "27.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
serde = "1.0"
serde_json = { version = "1.0" }
sha2 = '0.10.2'
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-keyring = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-std = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-version = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-core = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-io = { version = "30.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-keyring = { version = "31.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-runtime = { version = "31.0.1", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-std = { version = "14.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-version = { version = "29.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }

[features]
default = ["std"]
std = [
"hex/std",
"codec/std",
"log/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"ibc/std",
"ibc-proto/std",
"ibc-support/std",
"sp-runtime/std",
"sp-io/std",
"sp-std/std",
"primitive-types/std",
"pallet-timestamp/std",
"hex/std",
"codec/std",
"log/std",
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"scale-info/std",
"ibc/std",
"ibc-proto/std",
"ibc-support/std",
"sp-runtime/std",
"sp-io/std",
"sp-std/std",
"primitive-types/std",
"pallet-timestamp/std",
]
runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"]
try-runtime = ["frame-support/try-runtime"]
4 changes: 2 additions & 2 deletions app/transfer/src/callback.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::Config;
use alloc::string::ToString;
use frame_system::pallet_prelude::BlockNumberFor;
use ibc::{
core::{
ics04_channel::{
Expand Down Expand Up @@ -29,8 +30,7 @@ impl<T: Config> IbcTransferModule<T> {

impl<T: Config> Module for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
fn on_chan_open_init_validate(
&self,
Expand Down
10 changes: 4 additions & 6 deletions app/transfer/src/context_channel.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::{callback::IbcTransferModule, *};
use frame_system::pallet_prelude::BlockNumberFor;
use ibc::{
core::{
ics02_client::{client_state::ClientState, consensus_state::ConsensusState},
Expand All @@ -20,8 +21,7 @@ use sp_std::{boxed::Box, time::Duration};

impl<T: Config> ValidationContext for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
fn client_state(
&self,
Expand Down Expand Up @@ -186,8 +186,7 @@ where

impl<T: Config> ExecutionContext for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
fn store_client_state(
&mut self,
Expand Down Expand Up @@ -366,8 +365,7 @@ where

impl<T: Config> ibc::core::router::Router for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
fn get_route(
&self,
Expand Down
14 changes: 7 additions & 7 deletions app/transfer/src/impl.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use crate::{callback::IbcTransferModule, utils::get_channel_escrow_address, *};
use codec::{Decode, Encode};
use frame_support::traits::GenesisBuild;
use frame_support::traits::{
fungibles::Mutate,
tokens::{Fortitude, Precision, Preservation},
ExistenceRequirement::AllowDeath,
};
use frame_system::pallet_prelude::BlockNumberFor;
use ibc::{
applications::transfer::{
context::{TokenTransferExecutionContext, TokenTransferValidationContext},
Expand All @@ -26,8 +28,7 @@ use sp_std::str::FromStr;

impl<T: Config> TokenTransferExecutionContext for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
// type AccountId = <Self as TokenTransferContext>::AccountId;

Expand Down Expand Up @@ -97,7 +98,7 @@ where
},
Err(_error) => {
error!("❌ [send_coins]: denom: ({:?})", denom);
return Err(TokenTransferError::InvalidToken)
return Err(TokenTransferError::InvalidToken);
},
}
},
Expand Down Expand Up @@ -135,7 +136,7 @@ where
},
Err(_error) => {
error!("❌ [mint_coins]: denom: ({:?})", denom);
return Err(TokenTransferError::InvalidToken)
return Err(TokenTransferError::InvalidToken);
},
}
Ok(())
Expand Down Expand Up @@ -172,7 +173,7 @@ where
},
Err(_error) => {
error!("❌ [burn_coins]: denom: ({:?})", denom);
return Err(TokenTransferError::InvalidToken)
return Err(TokenTransferError::InvalidToken);
},
}
Ok(())
Expand All @@ -181,8 +182,7 @@ where

impl<T: Config> TokenTransferValidationContext for IbcTransferModule<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
type AccountId = <T as Config>::AccountIdConversion;

Expand Down
6 changes: 3 additions & 3 deletions app/transfer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extern crate alloc;

use frame_support::traits::Currency;
use frame_system::pallet_prelude::BlockNumberFor;
/// Edit this file to define custom logic or remove it if it is not needed.
/// Learn more about FRAME and the core library of Substrate FRAME pallets:
/// <https://docs.substrate.io/reference/frame-pallets/>
Expand Down Expand Up @@ -113,7 +114,7 @@ pub mod pallet {
}

#[pallet::genesis_build]
impl<T: Config> GenesisBuild<T> for GenesisConfig<T> {
impl<T: Config> BuildGenesisConfig for GenesisConfig<T> {
fn build(&self) {
for (token_id, id) in self.asset_id_by_name.iter() {
<AssetIdByName<T>>::insert(token_id.as_bytes(), id);
Expand Down Expand Up @@ -163,8 +164,7 @@ pub mod pallet {
#[pallet::call]
impl<T: Config> Pallet<T>
where
u64: From<<T as pallet_timestamp::Config>::Moment>
+ From<<T as frame_system::Config>::BlockNumber>,
u64: From<<T as pallet_timestamp::Config>::Moment> + From<BlockNumberFor<T>>,
{
/// ICS20 fungible token transfer.
/// Handling transfer request as sending chain or receiving chain.
Expand Down
108 changes: 59 additions & 49 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,82 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
# substate crates
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = ["derive"] }
frame-benchmarking = { version = "4.0.0-dev", default-features = false, optional = true, git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
frame-system = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
codec = { package = "parity-scale-codec", version = "3.2.2", default-features = false, features = [
"derive",
] }
frame-benchmarking = { version = "28.0.0", default-features = false, optional = true, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
frame-support = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
frame-system = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
ibc-support = { version = "0.1.0", default-features = false, path = "../ibc-support" }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }
sp-core = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-io = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "7.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-std = { version = "5.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-tracing = { version = "6.0.0", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-timestamp = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master" }
scale-info = { version = "2.1.1", default-features = false, features = [
"derive",
] }
sp-core = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-io = { version = "30.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-runtime = { version = "31.0.1", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-std = { version = "14.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-tracing = { version = "16.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-timestamp = { version = "27.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }

## for ibc protocl
ibc = { version = "0.41.0", default-features = false, features = ["parity-scale-codec", "mocks-no-std", "serde"] }
ibc-proto = { version = "0.30.0", default-features = false, features = ["parity-scale-codec"] }
ibc = { version = "0.41.0", default-features = false, features = [
"parity-scale-codec",
"mocks-no-std",
"serde",
] }
ibc-proto = { version = "0.30.0", default-features = false, features = [
"parity-scale-codec",
] }
log = { version = "0.4.0", default-features = false }
serde = { version = "1.0", default-features = false }
serde_json = { version = "1.0", default-features = false }

## optional
pallet-balances = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", branch = "master", optional = true }
pallet-balances = { version = "28.0.0", default-features = false, git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0", optional = true }

[dev-dependencies]
chrono = "0.4.19"
frame-support = { git = "https://github.com/paritytech/substrate.git", branch = "master" }
hex = '0.4.0'
pallet-assets = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-babe = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-balances = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
pallet-timestamp = { version = "4.0.0-dev", git = "https://github.com/paritytech/substrate.git", branch = "master" }
serde = "1.0"
sha2 = '0.10.2'
sp-core = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-io = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-keyring = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-runtime = { version = "7.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-std = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sp-version = { version = "5.0.0", git = "https://github.com/paritytech/substrate.git", branch = "master" }
sha2 = "0.10.2"
hex = "0.4.0"
frame-support = { git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-assets = { version = "29.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-babe = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-balances = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
pallet-timestamp = { version = "27.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-core = { version = "28.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-io = { version = "30.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-keyring = { version = "31.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-runtime = { version = "31.0.1", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-std = { version = "14.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }
sp-version = { version = "29.0.0", git = "https://github.com/paritytech/polkadot-sdk.git", tag = "polkadot-v1.7.0" }

[features]
default = ['std']
std = [
"ibc-support/std",
"codec/std",
"log/std",
"scale-info/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"sp-tracing/std",
"ibc/std",
"ibc-proto/std",
"serde_json/std",
"serde/std",
"pallet-timestamp/std",
"pallet-balances?/std",
"ibc-support/std",
"codec/std",
"log/std",
"scale-info/std",
"frame-benchmarking?/std",
"frame-support/std",
"frame-system/std",
"sp-core/std",
"sp-runtime/std",
"sp-std/std",
"sp-io/std",
"sp-tracing/std",
"ibc/std",
"ibc-proto/std",
"serde_json/std",
"serde/std",
"pallet-timestamp/std",
"pallet-balances?/std",
]
runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
"frame-benchmarking/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-timestamp/runtime-benchmarks",
"pallet-balances/runtime-benchmarks",
]
try-runtime = ["frame-support/try-runtime"]
Loading

0 comments on commit ddd17df

Please sign in to comment.