Skip to content

Commit

Permalink
bump mainnet-159 (#74)
Browse files Browse the repository at this point in the history
* bump mainnet-159

* resort xtoken
  • Loading branch information
StewartYe authored May 7, 2023
1 parent d4f3fdc commit ff7914f
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# v0.9.30-mainnet.159

- enable polygon chain bridge
- fix node rpc compile error

# v0.9.30-node.158

- release-sidecar
Expand Down
2 changes: 2 additions & 0 deletions pallets/chainbridge-handler/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId = 3;
pub const NativeChainId: ChainId = 42;
pub const BurnTAOwhenIssue: Balance =10_000_000_000_000_000_000;
}
Expand All @@ -143,6 +144,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
2 changes: 2 additions & 0 deletions pallets/chainbridge/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId = 3;
pub const NativeChainId: ChainId = 42;
pub NativeResourceId: ResourceId = derive_resource_id(42, 0, b"TAO").unwrap(); // native token id
pub const TreasuryAccount: AccountId = AccountId::new([5u8; 32]);
Expand All @@ -113,6 +114,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
4 changes: 4 additions & 0 deletions pallets/fuso-support/src/external_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ pub enum XToken<Balance> {
BEP20(Vec<u8>, Vec<u8>, Balance, bool, u8),
// symbol, total
FND10(Vec<u8>, Balance),
POLYGON(Vec<u8>, Vec<u8>, Balance, bool, u8),
}

impl<Balance> XToken<Balance> {
pub fn is_stable(&self) -> bool {
match self {
XToken::NEP141(_, _, _, stable, _)
| XToken::ERC20(_, _, _, stable, _)
| XToken::POLYGON(_, _, _, stable, _)
| XToken::BEP20(_, _, _, stable, _) => *stable,
XToken::FND10(_, _) => false,
}
Expand All @@ -42,6 +44,7 @@ impl<Balance> XToken<Balance> {
match self {
XToken::NEP141(symbol, _, _, _, _)
| XToken::ERC20(symbol, _, _, _, _)
| XToken::POLYGON(symbol, _, _, _, _)
| XToken::BEP20(symbol, _, _, _, _)
| XToken::FND10(symbol, _) => symbol.clone(),
}
Expand All @@ -51,6 +54,7 @@ impl<Balance> XToken<Balance> {
match self {
XToken::NEP141(_, contract, _, _, _)
| XToken::ERC20(_, contract, _, _, _)
| XToken::POLYGON(_, contract, _, _, _)
| XToken::BEP20(_, contract, _, _, _) => contract.clone(),
XToken::FND10(_, _) => Vec::new(),
}
Expand Down
2 changes: 2 additions & 0 deletions pallets/market/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId =3;
pub const NativeChainId: ChainId = 42;
pub const BurnTAOwhenIssue: Balance = 10000000000000000;
}
Expand All @@ -108,6 +109,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
2 changes: 2 additions & 0 deletions pallets/reward/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId = 3;
pub const NativeChainId: ChainId = 42;
pub const BurnTAOwhenIssue: Balance = 10_000_000_000_000_000_000;
}
Expand All @@ -105,6 +106,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
17 changes: 17 additions & 0 deletions pallets/token/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ pub mod pallet {
#[pallet::constant]
type NativeTokenId: Get<Self::TokenId>;

#[pallet::constant]
type PolygonChainId: Get<ChainId>;

type Weight: WeightInfo;

#[pallet::constant]
Expand Down Expand Up @@ -196,6 +199,7 @@ pub mod pallet {
match token_info {
XToken::NEP141(_, _, _, ref mut stable, _) => *stable = true,
XToken::ERC20(_, _, _, ref mut stable, _) => *stable = true,
XToken::POLYGON(_, _, _, ref mut stable, _) => *stable = true,
XToken::BEP20(_, _, _, ref mut stable, _) => *stable = true,
XToken::FND10(_, _) => return Err(Error::<T>::TokenNotFound.into()),
}
Expand Down Expand Up @@ -254,6 +258,7 @@ pub mod pallet {
let unified_amount = match info {
XToken::NEP141(_, _, ref mut total, _, decimals)
| XToken::ERC20(_, _, ref mut total, _, decimals)
| XToken::POLYGON(_, _, ref mut total, _, decimals)
| XToken::BEP20(_, _, ref mut total, _, decimals) => {
let unified_amount = Self::transform_decimals_to_standard(amount, decimals);
*total = total
Expand Down Expand Up @@ -300,6 +305,7 @@ pub mod pallet {
let unified_amount = match info {
XToken::NEP141(_, _, ref mut total, _, decimals)
| XToken::ERC20(_, _, ref mut total, _, decimals)
| XToken::POLYGON(_, _, ref mut total, _, decimals)
| XToken::BEP20(_, _, ref mut total, _, decimals) => {
let unified_amount = Self::transform_decimals_to_standard(amount, decimals);
*total = total
Expand Down Expand Up @@ -455,6 +461,13 @@ pub mod pallet {
ref mut stable,
decimals,
)
| XToken::POLYGON(
ref symbol,
ref contract,
ref mut total,
ref mut stable,
decimals,
)
| XToken::BEP20(
ref symbol,
ref contract,
Expand Down Expand Up @@ -625,6 +638,7 @@ pub mod pallet {
match token {
XToken::NEP141(_, _, total, _, _)
| XToken::ERC20(_, _, total, _, _)
| XToken::POLYGON(_, _, total, _, _)
| XToken::BEP20(_, _, total, _, _) => total,
XToken::FND10(_, total) => total,
}
Expand All @@ -643,6 +657,7 @@ pub mod pallet {
match token {
XToken::NEP141(_, _, _, _, decimals)
| XToken::ERC20(_, _, _, _, decimals)
| XToken::POLYGON(_, _, _, _, decimals)
| XToken::BEP20(_, _, _, _, decimals) => Ok(decimals),
XToken::FND10(_, _) => Err(Error::<T>::TokenNotFound.into()),
}
Expand Down Expand Up @@ -895,6 +910,7 @@ pub mod pallet {
.map(|info| match info {
XToken::NEP141(_, _, _, _, decimals)
| XToken::ERC20(_, _, _, _, decimals)
| XToken::POLYGON(_, _, _, _, decimals)
| XToken::BEP20(_, _, _, _, decimals) => {
Self::transform_decimals_to_standard(balance, decimals)
}
Expand All @@ -910,6 +926,7 @@ pub mod pallet {
match token_info {
XToken::NEP141(..) => T::NearChainId::get(),
XToken::ERC20(..) => T::EthChainId::get(),
XToken::POLYGON(..) => T::PolygonChainId::get(),
XToken::BEP20(..) => T::BnbChainId::get(),
XToken::FND10(..) => T::NativeChainId::get(),
}
Expand Down
2 changes: 2 additions & 0 deletions pallets/token/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId = 3;
pub const NativeChainId: ChainId = 42;
pub const BurnTAOwhenIssue: Balance = 10_000_000_000_000_000_000;
}
Expand All @@ -103,6 +104,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
2 changes: 2 additions & 0 deletions pallets/verifier/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ parameter_types! {
pub const NearChainId: ChainId = 255;
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 2;
pub const PolygonChainId: ChainId = 3;
pub const NativeChainId: ChainId = 42;
pub const BurnTAOwhenIssue: Balance = 10000000000000000;
}
Expand All @@ -105,6 +106,7 @@ impl pallet_fuso_token::Config for Test {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = u32;
type Weight = ();
Expand Down
6 changes: 1 addition & 5 deletions rpc/src/broker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,6 @@ where
async move {
let key = get_broker_public(keystore)
.await
.inspect_err(|e| log::error!("{:?}", e))
.map_err(|_| rpc_error!(-32102, "The broker key is not registered."))?;
let r = session
.relay(
Expand Down Expand Up @@ -412,10 +411,7 @@ where
"broker-prover-connector",
Some("fusotao-rpc"),
async move {
if let Ok(relayer) = get_broker_public(keystore)
.await
.inspect_err(|e| log::error!("{:?}", e))
{
if let Ok(relayer) = get_broker_public(keystore).await {
let _ = session
.multiplex(account_id, signature, nonce, relayer.to_ss58check(), sink)
.await;
Expand Down
2 changes: 0 additions & 2 deletions rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#![feature(result_option_inspect)]
#![feature(result_flattening)]
pub mod broker;
pub mod token;
pub mod verifier;
Expand Down
4 changes: 3 additions & 1 deletion runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
// `spec_version`, and `authoring_version` are the same between Wasm and native.
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
// the compatible custom types.
spec_version: 158,
spec_version: 159,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 3,
Expand Down Expand Up @@ -644,6 +644,7 @@ parameter_types! {
pub const EthChainId: ChainId = 1;
pub const BnbChainId: ChainId = 56;
pub const NativeChainId: ChainId = 42;
pub const PolygonChainId: ChainId = 137;
pub const BurnTAOwhenIssue: Balance = 10 * TAO;
}

Expand All @@ -657,6 +658,7 @@ impl pallet_fuso_token::Config for Runtime {
type NativeChainId = NativeChainId;
type NativeTokenId = NativeTokenId;
type NearChainId = NearChainId;
type PolygonChainId = PolygonChainId;
type RuntimeEvent = RuntimeEvent;
type TokenId = TokenId;
type Weight = pallet_fuso_token::weights::SubstrateWeight<Runtime>;
Expand Down

0 comments on commit ff7914f

Please sign in to comment.