-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* connectors: POC v0 * fixup! Use orml 0.9.29 * nix
- Loading branch information
1 parent
1394d5b
commit f93e208
Showing
22 changed files
with
2,673 additions
and
459 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
[package] | ||
authors = ["Centrifuge <[email protected]>"] | ||
description = 'Centrifuge Connectors Pallet' | ||
edition = '2018' | ||
license = "LGPL-3.0" | ||
name = 'pallet-connectors' | ||
repository = "https://github.com/centrifuge/centrifuge-chain/pallets/connectors" | ||
version = '0.0.1' | ||
|
||
[package.metadata.docs.rs] | ||
targets = ['x86_64-unknown-linux-gnu'] | ||
|
||
[dependencies] | ||
codec = { package = 'parity-scale-codec', version = '3.0.0', features = ['derive'], default-features = false } | ||
ethabi = { version = "16.0", default-features = false } | ||
frame-support = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29" } | ||
frame-system = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29" } | ||
hex = { version = "0.4.3", default_features = false } | ||
scale-info = { version = "2.0", default-features = false, features = ["derive"] } | ||
sp-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29" } | ||
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29" } | ||
|
||
# Substrate crates | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.29" } | ||
|
||
# Optional dependencies for benchmarking | ||
frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.29" } | ||
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, optional = true, branch = "polkadot-v0.9.29" } | ||
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = false, optional = true, branch = "polkadot-v0.9.29" } | ||
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.29" } | ||
pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = false, optional = true, branch = "polkadot-v0.9.29" } | ||
|
||
# Our custom pallets | ||
cfg-primitives = { path = "../../libs/primitives", default-features = false } | ||
cfg-traits = { path = "../../libs/traits", default-features = false } | ||
cfg-types = { path = "../../libs/types", default-features = false } | ||
runtime-common = { path = "../../runtime/common", default-features = false } | ||
|
||
# Polkadot | ||
xcm = { git = "https://github.com/paritytech/polkadot", default-features = false, branch = "release-v0.9.29" } | ||
|
||
pallet-ethereum = { git = "https://github.com/NunoAlexandre/frontier", branch = "unfork-v0.9.29", default-features = false } | ||
pallet-ethereum-xcm = { git = "https://github.com/NunoAlexandre/moonbeam", default-features = false, branch = "unfork-v0.9.29" } | ||
pallet-xcm-transactor = { git = "https://github.com/NunoAlexandre/moonbeam", default-features = false, branch = "unfork-v0.9.29" } | ||
xcm-primitives = { git = "https://github.com/NunoAlexandre/moonbeam", default-features = false, branch = "unfork-v0.9.29" } | ||
|
||
[dev-dependencies] | ||
hex = "0.4.3" | ||
serde = { version = "1.0.102" } | ||
|
||
# Our pallets | ||
pallet-interest-accrual = { path = "../interest-accrual", default-features = true } | ||
pallet-loans = { path = "../loans", default-features = true } | ||
pallet-permissions = { path = "../permissions", default-features = true } | ||
pallet-pools = { path = "../pools", default-features = true } | ||
|
||
# Substrate crates & pallets | ||
pallet-balances = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.29" } | ||
pallet-timestamp = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.29" } | ||
pallet-uniques = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.29" } | ||
sp-core = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.29" } | ||
sp-io = { git = "https://github.com/paritytech/substrate", default-features = true, branch = "polkadot-v0.9.29" } | ||
|
||
# Orml crates | ||
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.29" } | ||
orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-library", default-features = true, branch = "polkadot-v0.9.29" } | ||
|
||
# Local crates | ||
runtime-common = { path = "../../runtime/common", default-features = true } | ||
|
||
[features] | ||
default = ['std'] | ||
runtime-benchmarks = [ | ||
"frame-benchmarking", | ||
"pallet-balances", | ||
"orml-tokens", | ||
"orml-traits", | ||
] | ||
std = [ | ||
'codec/std', | ||
'cfg-types/std', | ||
'cfg-traits/std', | ||
'frame-support/std', | ||
'frame-system/std', | ||
'sp-std/std', | ||
'sp-runtime/std', | ||
'orml-tokens/std', | ||
'orml-traits/std', | ||
'pallet-balances/std', | ||
'runtime-common/std', | ||
'xcm/std', | ||
'pallet-xcm-transactor/std', | ||
'pallet-ethereum-xcm/std', | ||
'pallet-ethereum/std', | ||
'xcm-primitives/std', | ||
'ethabi/std', | ||
'pallet-interest-accrual/std', | ||
'pallet-permissions/std', | ||
'pallet-loans/std', | ||
'pallet-pools/std', | ||
'pallet-uniques/std', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
// Copyright 2022 Centrifuge Foundation (centrifuge.io). | ||
// This file is part of Centrifuge chain project. | ||
|
||
// Centrifuge 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 (see http://www.gnu.org/licenses). | ||
|
||
// Centrifuge 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. | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
use ethabi::{Bytes, Contract}; | ||
use sp_std::{vec, vec::Vec}; | ||
|
||
/// The ConnectorsXcmContract handle function name | ||
static HANDLE_FUNCTION: &str = "handle"; | ||
|
||
/// Return the encoded contract call, i.e, ConnectorsXcmRouter::handle(encoded_msg). | ||
pub fn encoded_contract_call(encoded_msg: Vec<u8>) -> Bytes { | ||
let contract = xcm_router_contract(); | ||
let encoded_contract_call = contract | ||
.function(HANDLE_FUNCTION) | ||
.expect("Known at compilation time") | ||
.encode_input(&[ethabi::Token::Bytes(encoded_msg)]) | ||
.expect("Known at compilation time"); | ||
|
||
encoded_contract_call | ||
} | ||
|
||
/// The ConnectorsXcmRouter Abi as in ethabi::Contract | ||
/// Note: We only concern ourselves with the `handle` function of the contract | ||
/// since that's all we need to build the calls for remote EVM execution. | ||
pub fn xcm_router_contract() -> Contract { | ||
use sp_std::collections::btree_map::BTreeMap; | ||
|
||
let mut functions = BTreeMap::new(); | ||
#[allow(deprecated)] | ||
functions.insert( | ||
"handle".into(), | ||
vec![ethabi::Function { | ||
name: HANDLE_FUNCTION.into(), | ||
inputs: vec![ethabi::Param { | ||
name: "message".into(), | ||
kind: ethabi::ParamType::Bytes, | ||
internal_type: None, | ||
}], | ||
outputs: vec![], | ||
constant: false, | ||
state_mutability: Default::default(), | ||
}], | ||
); | ||
|
||
ethabi::Contract { | ||
constructor: None, | ||
functions, | ||
events: Default::default(), | ||
errors: Default::default(), | ||
receive: false, | ||
fallback: false, | ||
} | ||
} |
Oops, something went wrong.