From f6e85237624c2c1c24ebe30644a18ceb19e760ad Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Sat, 9 Mar 2024 23:38:02 +0800 Subject: [PATCH 1/9] Update TODO TOC --- blockchain/modules/airdrop/TODO.md | 2 +- blockchain/modules/asset-registry/TODO.md | 2 +- blockchain/modules/currencies/TODO.md | 2 +- blockchain/modules/ecdp-auctions/TODO.md | 2 +- blockchain/modules/ecdp-emergency-shutdown/TODO.md | 2 +- blockchain/modules/ecdp-setr-engine/TODO.md | 2 +- blockchain/modules/ecdp-setr-loans/TODO.md | 2 +- blockchain/modules/ecdp-setr-treasury/TODO.md | 2 +- blockchain/modules/ecdp-ussd-engine/TODO.md | 2 +- blockchain/modules/ecdp-ussd-loans/TODO.md | 2 +- blockchain/modules/ecdp-ussd-treasury/TODO.md | 2 +- blockchain/modules/ecdp/TODO.md | 2 +- blockchain/modules/edfis-launchpad/TODO.md | 2 +- blockchain/modules/edfis-launchpool/TODO.md | 2 +- blockchain/modules/edfis-oracle/TODO.md | 2 +- blockchain/modules/edfis-swap-legacy/TODO.md | 2 +- blockchain/modules/edfis-swap/TODO.md | 2 +- blockchain/modules/evm-bridge/TODO.md | 2 +- blockchain/modules/evm-utility/TODO.md | 2 +- blockchain/modules/evm/TODO.md | 2 +- blockchain/modules/idle-scheduler/TODO.md | 2 +- blockchain/modules/lockdrop/TODO.md | 2 +- blockchain/modules/moya-liquid-edf-earn/TODO.md | 2 +- blockchain/modules/moya-liquid-edf-validators/TODO.md | 2 +- blockchain/modules/moya-liquid-edf/TODO.md | 2 +- blockchain/modules/moya-liquid-see-earn/TODO.md | 2 +- blockchain/modules/moya-liquid-see-validators/TODO.md | 2 +- blockchain/modules/moya-liquid-see/TODO.md | 2 +- blockchain/modules/nft/TODO.md | 2 +- blockchain/modules/prices/TODO.md | 2 +- blockchain/modules/support/TODO.md | 2 +- blockchain/modules/transaction-pause/TODO.md | 2 +- blockchain/modules/transaction-payment/TODO.md | 2 +- blockchain/modules/unified-accounts/TODO.md | 2 +- blockchain/modules/vesting/TODO.md | 2 +- 35 files changed, 35 insertions(+), 35 deletions(-) diff --git a/blockchain/modules/airdrop/TODO.md b/blockchain/modules/airdrop/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/airdrop/TODO.md +++ b/blockchain/modules/airdrop/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/asset-registry/TODO.md b/blockchain/modules/asset-registry/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/asset-registry/TODO.md +++ b/blockchain/modules/asset-registry/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/currencies/TODO.md b/blockchain/modules/currencies/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/currencies/TODO.md +++ b/blockchain/modules/currencies/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-auctions/TODO.md b/blockchain/modules/ecdp-auctions/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-auctions/TODO.md +++ b/blockchain/modules/ecdp-auctions/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-emergency-shutdown/TODO.md b/blockchain/modules/ecdp-emergency-shutdown/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-emergency-shutdown/TODO.md +++ b/blockchain/modules/ecdp-emergency-shutdown/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-setr-engine/TODO.md b/blockchain/modules/ecdp-setr-engine/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-setr-engine/TODO.md +++ b/blockchain/modules/ecdp-setr-engine/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-setr-loans/TODO.md b/blockchain/modules/ecdp-setr-loans/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-setr-loans/TODO.md +++ b/blockchain/modules/ecdp-setr-loans/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-setr-treasury/TODO.md b/blockchain/modules/ecdp-setr-treasury/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-setr-treasury/TODO.md +++ b/blockchain/modules/ecdp-setr-treasury/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-ussd-engine/TODO.md b/blockchain/modules/ecdp-ussd-engine/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-ussd-engine/TODO.md +++ b/blockchain/modules/ecdp-ussd-engine/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-ussd-loans/TODO.md b/blockchain/modules/ecdp-ussd-loans/TODO.md index 35e42ffa..b072836a 100644 --- a/blockchain/modules/ecdp-ussd-loans/TODO.md +++ b/blockchain/modules/ecdp-ussd-loans/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp-ussd-treasury/TODO.md b/blockchain/modules/ecdp-ussd-treasury/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp-ussd-treasury/TODO.md +++ b/blockchain/modules/ecdp-ussd-treasury/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/ecdp/TODO.md b/blockchain/modules/ecdp/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/ecdp/TODO.md +++ b/blockchain/modules/ecdp/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/edfis-launchpad/TODO.md b/blockchain/modules/edfis-launchpad/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/edfis-launchpad/TODO.md +++ b/blockchain/modules/edfis-launchpad/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/edfis-launchpool/TODO.md b/blockchain/modules/edfis-launchpool/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/edfis-launchpool/TODO.md +++ b/blockchain/modules/edfis-launchpool/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/edfis-oracle/TODO.md b/blockchain/modules/edfis-oracle/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/edfis-oracle/TODO.md +++ b/blockchain/modules/edfis-oracle/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/edfis-swap-legacy/TODO.md b/blockchain/modules/edfis-swap-legacy/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/edfis-swap-legacy/TODO.md +++ b/blockchain/modules/edfis-swap-legacy/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/edfis-swap/TODO.md b/blockchain/modules/edfis-swap/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/edfis-swap/TODO.md +++ b/blockchain/modules/edfis-swap/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/evm-bridge/TODO.md b/blockchain/modules/evm-bridge/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/evm-bridge/TODO.md +++ b/blockchain/modules/evm-bridge/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/evm-utility/TODO.md b/blockchain/modules/evm-utility/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/evm-utility/TODO.md +++ b/blockchain/modules/evm-utility/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/evm/TODO.md b/blockchain/modules/evm/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/evm/TODO.md +++ b/blockchain/modules/evm/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/idle-scheduler/TODO.md b/blockchain/modules/idle-scheduler/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/idle-scheduler/TODO.md +++ b/blockchain/modules/idle-scheduler/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/lockdrop/TODO.md b/blockchain/modules/lockdrop/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/lockdrop/TODO.md +++ b/blockchain/modules/lockdrop/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-edf-earn/TODO.md b/blockchain/modules/moya-liquid-edf-earn/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-edf-earn/TODO.md +++ b/blockchain/modules/moya-liquid-edf-earn/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-edf-validators/TODO.md b/blockchain/modules/moya-liquid-edf-validators/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-edf-validators/TODO.md +++ b/blockchain/modules/moya-liquid-edf-validators/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-edf/TODO.md b/blockchain/modules/moya-liquid-edf/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-edf/TODO.md +++ b/blockchain/modules/moya-liquid-edf/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-see-earn/TODO.md b/blockchain/modules/moya-liquid-see-earn/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-see-earn/TODO.md +++ b/blockchain/modules/moya-liquid-see-earn/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-see-validators/TODO.md b/blockchain/modules/moya-liquid-see-validators/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-see-validators/TODO.md +++ b/blockchain/modules/moya-liquid-see-validators/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/moya-liquid-see/TODO.md b/blockchain/modules/moya-liquid-see/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/moya-liquid-see/TODO.md +++ b/blockchain/modules/moya-liquid-see/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/nft/TODO.md b/blockchain/modules/nft/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/nft/TODO.md +++ b/blockchain/modules/nft/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/prices/TODO.md b/blockchain/modules/prices/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/prices/TODO.md +++ b/blockchain/modules/prices/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/support/TODO.md b/blockchain/modules/support/TODO.md index 9150f0e1..e2a55c68 100644 --- a/blockchain/modules/support/TODO.md +++ b/blockchain/modules/support/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/transaction-pause/TODO.md b/blockchain/modules/transaction-pause/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/transaction-pause/TODO.md +++ b/blockchain/modules/transaction-pause/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/transaction-payment/TODO.md b/blockchain/modules/transaction-payment/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/transaction-payment/TODO.md +++ b/blockchain/modules/transaction-payment/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/unified-accounts/TODO.md b/blockchain/modules/unified-accounts/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/unified-accounts/TODO.md +++ b/blockchain/modules/unified-accounts/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) diff --git a/blockchain/modules/vesting/TODO.md b/blockchain/modules/vesting/TODO.md index 3e9cd565..c8c94c13 100644 --- a/blockchain/modules/vesting/TODO.md +++ b/blockchain/modules/vesting/TODO.md @@ -8,7 +8,7 @@ This list contains all TODOs in the Repo - [1. Introduction](#1-guidelines) - [2. Contribution](#2-contribution) - [3. Lists](#3-lists) - - [4. Tasks](#3-tasks) + - [4. Tasks](#4-tasks) From 7d0b286c67d5ee5106b4f34ca1c36a11afe4cdb1 Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Sat, 9 Mar 2024 23:39:50 +0800 Subject: [PATCH 2/9] Add Incentives Module --- blockchain/modules/ecdp-auctions/src/mock.rs | 8 +- .../modules/ecdp-ussd-engine/src/mock.rs | 12 +- .../modules/ecdp-ussd-engine/src/tests.rs | 10 +- .../modules/ecdp-ussd-loans/src/mock.rs | 6 +- .../modules/ecdp-ussd-loans/src/tests.rs | 2 +- .../modules/ecdp-ussd-treasury/src/mock.rs | 6 +- blockchain/modules/ecdp/src/lib.rs | 2 +- blockchain/modules/ecdp/src/mock.rs | 10 +- blockchain/modules/ecdp/src/tests.rs | 2 +- blockchain/modules/edfis-launchpad/README.md | 2 + .../modules/edfis-swap-legacy/README.md | 2 +- .../modules/edfis-swap-legacy/src/lib.rs | 12 +- .../modules/edfis-swap-legacy/src/mock.rs | 6 +- blockchain/modules/edfis-swap/README.md | 2 +- blockchain/modules/edfis-swap/src/lib.rs | 10 +- blockchain/modules/edfis-swap/src/mock.rs | 6 +- blockchain/modules/edfis-x/Cargo.toml | 47 ++ blockchain/modules/edfis-x/README.md | 6 + blockchain/modules/edfis-x/TODO.md | 56 ++ blockchain/modules/evm/src/bench/mock.rs | 8 +- blockchain/modules/evm/src/lib.rs | 2 +- blockchain/modules/incentives/Cargo.toml | 44 ++ blockchain/modules/incentives/README.md | 19 + blockchain/modules/incentives/TODO.md | 58 ++ blockchain/modules/incentives/src/lib.rs | 604 ++++++++++++++++ blockchain/modules/incentives/src/mock.rs | 173 +++++ blockchain/modules/incentives/src/tests.rs | 683 ++++++++++++++++++ blockchain/modules/incentives/src/weights.rs | 309 ++++++++ blockchain/modules/prices/src/lib.rs | 6 +- blockchain/modules/prices/src/mock.rs | 6 +- blockchain/modules/prices/src/tests.rs | 4 +- blockchain/modules/support/src/incentives.rs | 149 ++-- blockchain/modules/support/src/lib.rs | 8 +- .../modules/transaction-payment/src/mock.rs | 2 +- 34 files changed, 2149 insertions(+), 133 deletions(-) create mode 100644 blockchain/modules/edfis-x/Cargo.toml create mode 100644 blockchain/modules/edfis-x/README.md create mode 100644 blockchain/modules/edfis-x/TODO.md create mode 100644 blockchain/modules/incentives/Cargo.toml create mode 100644 blockchain/modules/incentives/README.md create mode 100644 blockchain/modules/incentives/TODO.md create mode 100644 blockchain/modules/incentives/src/lib.rs create mode 100644 blockchain/modules/incentives/src/mock.rs create mode 100644 blockchain/modules/incentives/src/tests.rs create mode 100644 blockchain/modules/incentives/src/weights.rs diff --git a/blockchain/modules/ecdp-auctions/src/mock.rs b/blockchain/modules/ecdp-auctions/src/mock.rs index 02c4ae1d..a9868352 100644 --- a/blockchain/modules/ecdp-auctions/src/mock.rs +++ b/blockchain/modules/ecdp-auctions/src/mock.rs @@ -99,8 +99,8 @@ ord_parameter_types! { parameter_types! { pub const GetUSSDCurrencyId: CurrencyId = USSD; pub const MaxAuctionsCount: u32 = 10_000; - pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt"); - pub TreasuryAccount: AccountId = PalletId(*b"aca/hztr").into_account_truncating(); + pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"set/ussdtrsymod"); + pub TreasuryAccount: AccountId = PalletId(*b"set/ussdtrsyacc").into_account_truncating(); pub AlternativeSwapPathJointList: Vec> = vec![ vec![EDF], ]; @@ -141,7 +141,7 @@ impl PriceProvider for MockPriceSource { } parameter_types! { - pub const EdfisSwapPalletId: PalletId = PalletId(*b"aca/dexm"); + pub const EdfisSwapPalletId: PalletId = PalletId(*b"set/edfis"); pub const GetExchangeFee: (u32, u32) = (0, 100); pub EnabledTradingPairs: Vec = vec![ TradingPair::from_currency_ids(USSD, BTC).unwrap(), @@ -157,7 +157,7 @@ impl module_edfis_swap_legacy::Config for Runtime { type TradingPathLimit = ConstU32<4>; type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = (); - type SwapDexIncentives = (); + type Incentives = (); type WeightInfo = (); type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<0>; diff --git a/blockchain/modules/ecdp-ussd-engine/src/mock.rs b/blockchain/modules/ecdp-ussd-engine/src/mock.rs index ad5ba161..4bc64646 100644 --- a/blockchain/modules/ecdp-ussd-engine/src/mock.rs +++ b/blockchain/modules/ecdp-ussd-engine/src/mock.rs @@ -117,7 +117,7 @@ impl orml_currencies::Config for Runtime { } parameter_types! { - pub const EcdpUssdLoansPalletId: PalletId = PalletId(*b"aca/loan"); + pub const EcdpUssdLoansPalletId: PalletId = PalletId(*b"set/ussdloan"); } impl module_ecdp_ussd_loans::Config for Runtime { @@ -205,8 +205,8 @@ impl EcdpAuctionsManager for MockEcdpAuctionsManager { parameter_types! { pub const GetUSSDCurrencyId: CurrencyId = USSD; - pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt"); - pub TreasuryAccount: AccountId = PalletId(*b"aca/hztr").into_account_truncating(); + pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"set/ussdtrsymod"); + pub TreasuryAccount: AccountId = PalletId(*b"set/ussdtrsyacc").into_account_truncating(); pub AlternativeSwapPathJointList: Vec> = vec![ vec![SEE], ]; @@ -227,7 +227,7 @@ impl module_ecdp_ussd_treasury::Config for Runtime { } parameter_types! { - pub const EdfisSwapPalletId: PalletId = PalletId(*b"aca/dexm"); + pub const EdfisSwapPalletId: PalletId = PalletId(*b"set/edfis"); pub const GetExchangeFee: (u32, u32) = (0, 100); pub EnabledTradingPairs: Vec = vec![ TradingPair::from_currency_ids(USSD, BTC).unwrap(), @@ -245,7 +245,7 @@ impl module_edfis_swap_legacy::Config for Runtime { type TradingPathLimit = ConstU32<4>; type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = (); - type SwapDexIncentives = (); + type Incentives = (); type WeightInfo = (); type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<0>; @@ -402,7 +402,7 @@ parameter_types! { pub DefaultLiquidationPenalty: FractionalRate = FractionalRate::try_from(Rate::saturating_from_rational(10, 100)).unwrap(); pub MaxSwapSlippageCompareToOracle: Ratio = Ratio::saturating_from_rational(50, 100); pub MaxLiquidationContractSlippage: Ratio = Ratio::saturating_from_rational(80, 100); - pub const EcdpUssdEnginePalletId: PalletId = PalletId(*b"aca/cdpe"); + pub const EcdpUssdEnginePalletId: PalletId = PalletId(*b"set/ussde"); pub const SettleErc20EvmOrigin: AccountId = AccountId32::new([255u8; 32]); } diff --git a/blockchain/modules/ecdp-ussd-engine/src/tests.rs b/blockchain/modules/ecdp-ussd-engine/src/tests.rs index 12cfe36b..4ce75c57 100644 --- a/blockchain/modules/ecdp-ussd-engine/src/tests.rs +++ b/blockchain/modules/ecdp-ussd-engine/src/tests.rs @@ -533,7 +533,7 @@ fn expand_position_collateral_work() { } #[test] -fn expand_position_collateral_for_lp_ausd_dot_work() { +fn expand_position_collateral_for_lp_ussd_edf_work() { ExtBuilder::default().build().execute_with(|| { assert_ok!(EdfisSwapModule::add_liquidity( RuntimeOrigin::signed(CAROL), @@ -698,7 +698,7 @@ fn shrink_position_debit_work() { } #[test] -fn shrink_position_debit_for_lp_ausd_dot_work() { +fn shrink_position_debit_for_lp_ussd_edf_work() { ExtBuilder::default().build().execute_with(|| { MockPriceSource::set_price(LP_USSD_EDF, Some(Price::saturating_from_rational(1, 1))); assert_ok!(EdfisSwapModule::add_liquidity( @@ -997,7 +997,7 @@ fn liquidate_unsafe_cdp_by_swap() { } #[test] -fn liquidate_unsafe_cdp_of_lp_ausd_dot_and_swap_dot() { +fn liquidate_unsafe_cdp_of_lp_ussd_edf_and_swap_edf() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); assert_ok!(EcdpUssdEngineModule::set_collateral_params( @@ -1095,7 +1095,7 @@ fn liquidate_unsafe_cdp_of_lp_ausd_dot_and_swap_dot() { } #[test] -fn liquidate_unsafe_cdp_of_lp_ausd_dot_and_ausd_take_whole_target() { +fn liquidate_unsafe_cdp_of_lp_ussd_edf_and_ussd_take_whole_target() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); assert_ok!(EcdpUssdEngineModule::set_collateral_params( @@ -1193,7 +1193,7 @@ fn liquidate_unsafe_cdp_of_lp_ausd_dot_and_ausd_take_whole_target() { } #[test] -fn liquidate_unsafe_cdp_of_lp_ausd_dot_and_create_dot_auction() { +fn liquidate_unsafe_cdp_of_lp_ussd_edf_and_create_edf_auction() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); assert_ok!(EcdpUssdEngineModule::set_collateral_params( diff --git a/blockchain/modules/ecdp-ussd-loans/src/mock.rs b/blockchain/modules/ecdp-ussd-loans/src/mock.rs index c893b024..7b487064 100644 --- a/blockchain/modules/ecdp-ussd-loans/src/mock.rs +++ b/blockchain/modules/ecdp-ussd-loans/src/mock.rs @@ -145,8 +145,8 @@ ord_parameter_types! { parameter_types! { pub const GetUSSDCurrencyId: CurrencyId = USSD; - pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt"); - pub TreasuryAccount: AccountId = PalletId(*b"aca/hztr").into_account_truncating(); + pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"set/ussdtrsymod"); + pub TreasuryAccount: AccountId = PalletId(*b"set/ussdtrsyacc").into_account_truncating(); pub AlternativeSwapPathJointList: Vec> = vec![]; } @@ -228,7 +228,7 @@ thread_local! { // } parameter_types! { - pub const EcdpUssdLoansPalletId: PalletId = PalletId(*b"aca/loan"); + pub const EcdpUssdLoansPalletId: PalletId = PalletId(*b"set/ussdloan"); } impl Config for Runtime { diff --git a/blockchain/modules/ecdp-ussd-loans/src/tests.rs b/blockchain/modules/ecdp-ussd-loans/src/tests.rs index 7a379d24..7bb047e5 100644 --- a/blockchain/modules/ecdp-ussd-loans/src/tests.rs +++ b/blockchain/modules/ecdp-ussd-loans/src/tests.rs @@ -147,7 +147,7 @@ fn update_loan_should_work() { let alice_ref_count_1 = System::consumers(&ALICE); assert_eq!(alice_ref_count_1, alice_ref_count_0 + 1); - // dot not manipulate balance + // does not manipulate balance assert_eq!(Currencies::free_balance(BTC, &EcdpUssdLoansModule::account_id()), 0); assert_eq!(Currencies::free_balance(BTC, &ALICE), 1000); diff --git a/blockchain/modules/ecdp-ussd-treasury/src/mock.rs b/blockchain/modules/ecdp-ussd-treasury/src/mock.rs index 288104e0..a17c920c 100644 --- a/blockchain/modules/ecdp-ussd-treasury/src/mock.rs +++ b/blockchain/modules/ecdp-ussd-treasury/src/mock.rs @@ -118,7 +118,7 @@ parameter_types! { TradingPair::from_currency_ids(USSD, EDF).unwrap(), TradingPair::from_currency_ids(BTC, EDF).unwrap(), ]; - pub const EdfisSwapPalletId: PalletId = PalletId(*b"aca/dexm"); + pub const EdfisSwapPalletId: PalletId = PalletId(*b"set/edfis"); } impl module_edfis_swap_legacy::Config for Runtime { @@ -128,7 +128,7 @@ impl module_edfis_swap_legacy::Config for Runtime { type TradingPathLimit = ConstU32<4>; type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = (); - type SwapDexIncentives = (); + type Incentives = (); type WeightInfo = (); type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<0>; @@ -175,7 +175,7 @@ ord_parameter_types! { } parameter_types! { - pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt"); + pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"set/ussdtrsymod"); pub const TreasuryAccount: AccountId = 10; pub AlternativeSwapPathJointList: Vec> = vec![ vec![EDF], diff --git a/blockchain/modules/ecdp/src/lib.rs b/blockchain/modules/ecdp/src/lib.rs index 47ed456b..7dee45af 100644 --- a/blockchain/modules/ecdp/src/lib.rs +++ b/blockchain/modules/ecdp/src/lib.rs @@ -358,7 +358,7 @@ pub mod module { let who = ensure_signed(origin)?; let debit_amount: Amount = debit_transfer.try_into().map_err(|_| ArithmeticError::Overflow)?; let negative_debit = debit_amount.checked_neg().ok_or(ArithmeticError::Overflow)?; - // Adds ausd to user account momentarily to adjust loan + // Adds USSD to user account momentarily to adjust loan ::EcdpUssdTreasury::issue_debit(&who, debit_transfer, true)?; >::adjust_position(&who, from_currency, Zero::zero(), negative_debit)?; diff --git a/blockchain/modules/ecdp/src/mock.rs b/blockchain/modules/ecdp/src/mock.rs index dabe6e46..13d2827c 100644 --- a/blockchain/modules/ecdp/src/mock.rs +++ b/blockchain/modules/ecdp/src/mock.rs @@ -120,7 +120,7 @@ impl orml_currencies::Config for Runtime { } parameter_types! { - pub const LoansPalletId: PalletId = PalletId(*b"aca/loan"); + pub const EcdpUssdLoansPalletId: PalletId = PalletId(*b"set/ussdloan"); } impl module_ecdp_ussd_loans::Config for Runtime { @@ -128,7 +128,7 @@ impl module_ecdp_ussd_loans::Config for Runtime { type Currency = Tokens; type RiskManager = EcdpUssdEngineModule; type EcdpUssdTreasury = EcdpUssdTreasuryModule; - type PalletId = LoansPalletId; + type PalletId = EcdpUssdLoansPalletId; type OnUpdateLoan = (); } @@ -192,8 +192,8 @@ ord_parameter_types! { parameter_types! { pub const GetUSSDCurrencyId: CurrencyId = USSD; - pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"aca/cdpt"); - pub TreasuryAccount: AccountId = PalletId(*b"aca/hztr").into_account_truncating(); + pub const EcdpUssdTreasuryPalletId: PalletId = PalletId(*b"set/ussdtrsymod"); + pub TreasuryAccount: AccountId = PalletId(*b"set/ussdtrsyacc").into_account_truncating(); pub AlternativeSwapPathJointList: Vec> = vec![ vec![USSD], ]; @@ -282,7 +282,7 @@ parameter_types! { pub DefaultLiquidationPenalty: FractionalRate = FractionalRate::try_from(Rate::saturating_from_rational(10, 100)).unwrap(); pub MaxSwapSlippageCompareToOracle: Ratio = Ratio::saturating_from_rational(50, 100); pub MaxLiquidationContractSlippage: Ratio = Ratio::saturating_from_rational(80, 100); - pub const EcdpUssdEnginePalletId: PalletId = PalletId(*b"aca/cdpe"); + pub const EcdpUssdEnginePalletId: PalletId = PalletId(*b"set/ussde"); pub const SettleErc20EvmOrigin: AccountId = AccountId32::new([255u8; 32]); } diff --git a/blockchain/modules/ecdp/src/tests.rs b/blockchain/modules/ecdp/src/tests.rs index f3c86ef0..6745b6bd 100644 --- a/blockchain/modules/ecdp/src/tests.rs +++ b/blockchain/modules/ecdp/src/tests.rs @@ -305,7 +305,7 @@ fn transfer_debit_works() { } #[test] -fn transfer_debit_no_ausd() { +fn transfer_debit_no_ussd() { ExtBuilder::default().build().execute_with(|| { System::set_block_number(1); assert_ok!(EcdpUssdEngineModule::set_collateral_params( diff --git a/blockchain/modules/edfis-launchpad/README.md b/blockchain/modules/edfis-launchpad/README.md index 68380c00..bd6a2c4f 100644 --- a/blockchain/modules/edfis-launchpad/README.md +++ b/blockchain/modules/edfis-launchpad/README.md @@ -20,6 +20,8 @@ The protocol uses `MultiCurrency` to let the Campaign Creator choose which curre There is a `goal` that is set by the Campaign Creator, the beneficiary of the fund and the Period (campaign period - amount of blocks a campaign should stay active) of the campaign and other information that describes the campaign. +In order to be eligible to buy into a launchpad offering (Launch), one needs to have the `LaunchpadEligibilityAmount` in the `raise_currency` of the Launch in their `slick-wallet` (Slick Wallet is an on-chain cross-chain multichain wallet built on Setheum). This allows cross-chain and multichain participation in Edfis Launchpad. + ### The Lifecycle of a Campaign A Launchpad Campaign has three stages in its lifecycle, they are as follows: diff --git a/blockchain/modules/edfis-swap-legacy/README.md b/blockchain/modules/edfis-swap-legacy/README.md index 6d92dfe7..d5c2ae27 100644 --- a/blockchain/modules/edfis-swap-legacy/README.md +++ b/blockchain/modules/edfis-swap-legacy/README.md @@ -4,4 +4,4 @@ ## Overview -Ethical DeFi's Built-in decentralized exchange `SwapDex` (Swap Exchange) module, the swap mechanism refers to the design of `Uniswap V2` with additional features and functionalities. In addition to being used for trading, DEX also participates in `ECDP liquidation`, which is faster than Liquidation By Auction when the liquidity is sufficient. +Ethical DeFi's Built-in decentralized exchange module, the swap mechanism refers to the design of `Uniswap V2` with additional features and functionalities. In addition to being used for trading, DEX also participates in `ECDP liquidation`, which is faster than Liquidation By Auction when the liquidity is sufficient. diff --git a/blockchain/modules/edfis-swap-legacy/src/lib.rs b/blockchain/modules/edfis-swap-legacy/src/lib.rs index 691cac57..71c9fb80 100644 --- a/blockchain/modules/edfis-swap-legacy/src/lib.rs +++ b/blockchain/modules/edfis-swap-legacy/src/lib.rs @@ -22,7 +22,7 @@ //! //! ## Overview //! -//! Ethical DeFi's Built-in decentralized exchange `SwapDex` (Swap Exchange) module, the swap +//! Ethical DeFi's Built-in decentralized exchange module, the swap //! mechanism refers to the design of `Uniswap V2` with additional features and functionalities. //! In addition to being used for trading, DEX also participates in `ECDP liquidation`, //! which is faster than Liquidation By Auction when the liquidity is sufficient. @@ -35,7 +35,7 @@ use frame_support::{pallet_prelude::*, transactional, PalletId}; use frame_system::pallet_prelude::*; -use module_support::{SwapDexIncentives, SwapManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; +use module_support::{Incentives, SwapManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; use orml_traits::{Happened, MultiCurrency, MultiCurrencyExtended}; use parity_scale_codec::MaxEncodedLen; use primitives::{Balance, CurrencyId, TradingPair}; @@ -121,8 +121,8 @@ pub mod module { /// Weight information for the extrinsics in this module. type WeightInfo: WeightInfo; - /// DEX incentives - type SwapDexIncentives: SwapDexIncentives; + /// Edfis Liquidity Rewards Incentives + type Incentives: Incentives; /// The origin which may list, enable or disable trading pairs. type ListingOrigin: EnsureOrigin; @@ -1081,7 +1081,7 @@ impl Pallet { *pool_1 = pool_1.checked_add(pool_1_increment).ok_or(ArithmeticError::Overflow)?; if stake_increment_share { - T::SwapDexIncentives::do_deposit_dex_share(who, dex_share_currency_id, share_increment)?; + T::Incentives::do_deposit_dex_share(who, dex_share_currency_id, share_increment)?; } Self::deposit_event(Event::AddLiquidity { @@ -1140,7 +1140,7 @@ impl Pallet { ); if by_unstake { - T::SwapDexIncentives::do_withdraw_dex_share(who, dex_share_currency_id, remove_share)?; + T::Incentives::do_withdraw_dex_share(who, dex_share_currency_id, remove_share)?; } T::Currency::withdraw(dex_share_currency_id, who, remove_share)?; T::Currency::transfer(trading_pair.first(), &module_account_id, who, pool_0_decrement)?; diff --git a/blockchain/modules/edfis-swap-legacy/src/mock.rs b/blockchain/modules/edfis-swap-legacy/src/mock.rs index c1c67061..192570ed 100644 --- a/blockchain/modules/edfis-swap-legacy/src/mock.rs +++ b/blockchain/modules/edfis-swap-legacy/src/mock.rs @@ -83,8 +83,8 @@ impl orml_tokens::Config for Runtime { type DustRemovalWhitelist = Nothing; } -pub struct MockSwapDexIncentives; -impl SwapDexIncentives for MockSwapDexIncentives { +pub struct MockIncentives; +impl Incentives for MockIncentives { fn do_deposit_dex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { Tokens::reserve(lp_currency_id, who, amount) } @@ -129,7 +129,7 @@ impl Config for Runtime { type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = MockErc20InfoMapping; type WeightInfo = (); - type SwapDexIncentives = MockSwapDexIncentives; + type Incentives = MockIncentives; type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<2000>; type OnLiquidityPoolUpdated = MockOnLiquidityPoolUpdated; diff --git a/blockchain/modules/edfis-swap/README.md b/blockchain/modules/edfis-swap/README.md index e04f3f8f..422c81e8 100644 --- a/blockchain/modules/edfis-swap/README.md +++ b/blockchain/modules/edfis-swap/README.md @@ -4,4 +4,4 @@ ## Overview -Ethical DeFi's Built-in decentralized exchange `SwapDex` (Swap Exchange) module, the swap mechanism refers to the design of `Uniswap V3` with additional features and functionalities that makes Edfis unique. In addition to being used for trading, DEX also participates in `ECDP liquidation`, which is faster than Liquidation By Auction when the liquidity is sufficient. +Ethical DeFi's Built-in decentralized exchange module, the swap mechanism refers to the design of `Uniswap V3` with additional features and functionalities that makes Edfis unique. In addition to being used for trading, DEX also participates in `ECDP liquidation`, which is faster than Liquidation By Auction when the liquidity is sufficient. diff --git a/blockchain/modules/edfis-swap/src/lib.rs b/blockchain/modules/edfis-swap/src/lib.rs index b2c52cd4..cd4cef49 100644 --- a/blockchain/modules/edfis-swap/src/lib.rs +++ b/blockchain/modules/edfis-swap/src/lib.rs @@ -22,7 +22,7 @@ //! //! ## Overview //! -//! Ethical DeFi's Built-in decentralized exchange `SwapDex` (Swap Exchange) module, the swap +//! Ethical DeFi's Built-in decentralized exchange module, the swap //! mechanism refers to the design of `Uniswap V3` with additional features and functionalities //! that makes Edfis unique. In addition to being used for trading, DEX also participates //! in `ECDP liquidation`, which is faster than Liquidation By Auction when the liquidity is sufficient. @@ -35,7 +35,7 @@ use frame_support::{pallet_prelude::*, transactional, PalletId}; use frame_system::pallet_prelude::*; -use module_support::{SwapDexIncentives, SwapManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; +use module_support::{Incentives, SwapManager, Erc20InfoMapping, ExchangeRate, Ratio, SwapLimit}; use orml_traits::{Happened, MultiCurrency, MultiCurrencyExtended}; use parity_scale_codec::MaxEncodedLen; use primitives::{Balance, CurrencyId, Fees, TradingPair}; @@ -123,8 +123,8 @@ pub mod module { /// Weight information for the extrinsics in this module. type WeightInfo: WeightInfo; - /// DEX incentives - type SwapDexIncentives: SwapDexIncentives; + /// Edfis Liquidity Rewards Incentives + type Incentives: Incentives; /// The origin which may list, enable or disable trading pairs. type ListingOrigin: EnsureOrigin; @@ -1129,7 +1129,7 @@ impl Pallet { ); if by_unstake { - T::SwapDexIncentives::do_withdraw_dex_share(who, dex_share_currency_id, remove_share)?; + T::Incentives::do_withdraw_dex_share(who, dex_share_currency_id, remove_share)?; } T::Currency::withdraw(dex_share_currency_id, who, remove_share)?; T::Currency::transfer(trading_pair.first(), &module_account_id, who, pool_0_decrement)?; diff --git a/blockchain/modules/edfis-swap/src/mock.rs b/blockchain/modules/edfis-swap/src/mock.rs index d078455f..bde9d8d9 100644 --- a/blockchain/modules/edfis-swap/src/mock.rs +++ b/blockchain/modules/edfis-swap/src/mock.rs @@ -84,8 +84,8 @@ impl orml_tokens::Config for Runtime { type DustRemovalWhitelist = Nothing; } -pub struct MockSwapDexIncentives; -impl SwapDexIncentives for MockSwapDexIncentives { +pub struct MockIncentives; +impl Incentives for MockIncentives { fn do_deposit_dex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { Tokens::reserve(lp_currency_id, who, amount) } @@ -130,7 +130,7 @@ impl Config for Runtime { type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = MockErc20InfoMapping; type WeightInfo = (); - type SwapDexIncentives = MockSwapDexIncentives; + type Incentives = MockIncentives; type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<2000>; type OnLiquidityPoolUpdated = MockOnLiquidityPoolUpdated; diff --git a/blockchain/modules/edfis-x/Cargo.toml b/blockchain/modules/edfis-x/Cargo.toml new file mode 100644 index 00000000..c58a4b51 --- /dev/null +++ b/blockchain/modules/edfis-x/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "module-edfis-x" +description = "Provides cross-chain multichain Swaps on Edfis Exchange." +version = "0.9.81-dev" +authors = ["Setheum Labs"] +edition = "2021" + +[dependencies] +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +sp-runtime = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } +support = { package = "module-support", path = "../support", default-features = false } +orml-traits = { path = "../submodules/orml/traits", default-features = false } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true } +orml-tokens = { workspace = true } + +[features] +default = ["std"] +std = [ + "parity-scale-codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "primitives/std", + "support/std", + "orml-traits/std", +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/blockchain/modules/edfis-x/README.md b/blockchain/modules/edfis-x/README.md new file mode 100644 index 00000000..75b02613 --- /dev/null +++ b/blockchain/modules/edfis-x/README.md @@ -0,0 +1,6 @@ +# Edfis X Module +Provides cross-chain multichain Swaps on Edfis Exchange. + +## Overview + +This module is used to build a cross-chain multichain swap protocol on Edfis Exchange. Built on `Slick Bridge`. diff --git a/blockchain/modules/edfis-x/TODO.md b/blockchain/modules/edfis-x/TODO.md new file mode 100644 index 00000000..c8c94c13 --- /dev/null +++ b/blockchain/modules/edfis-x/TODO.md @@ -0,0 +1,56 @@ +# To-Do List + +This list contains all TODOs in the Repo + + + +- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list) + - [1. Introduction](#1-guidelines) + - [2. Contribution](#2-contribution) + - [3. Lists](#3-lists) + - [4. Tasks](#4-tasks) + + + +## 1. Guidelines + +Note: Before you write a ToDo in this repo, please read the below guidelines carefully. + +Whenever you write a ToDo, you need to follow this standard syntax + +```rust +//TODO:[file_name:task_number] - task_details +``` + +for example: + +```rust +//TODO:[TODO.md:0] - Add Todo Guidelines +``` + +Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. + +Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. + +Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. + +Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: + +```rust +//TODO:[TODO.md-C:0] - Add Todo Guidelines +``` + +## 2. Contribution + +You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. + +## 3. Lists + +Each package/module/directory has its own `TODO.md`. + +## 4. Tasks + +These tasks are just for this file specifically. + +- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. +- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. diff --git a/blockchain/modules/evm/src/bench/mock.rs b/blockchain/modules/evm/src/bench/mock.rs index 0237698d..b210467f 100644 --- a/blockchain/modules/evm/src/bench/mock.rs +++ b/blockchain/modules/evm/src/bench/mock.rs @@ -31,7 +31,7 @@ use frame_support::{ use frame_system::EnsureSignedBy; use module_support::{ mocks::{MockAddressMapping, MockErc20InfoMapping}, - SwapDexIncentives, Price, PriceProvider, SpecificJointsSwap, + Incentives, Price, PriceProvider, SpecificJointsSwap, }; use orml_traits::{parameter_type_with_key, MultiReservableCurrency}; pub use primitives::{Address, Amount, BlockNumber, CurrencyId, Header, Multiplier, ReserveIdentifier, Signature, @@ -224,8 +224,8 @@ impl module_transaction_payment::Config for Runtime { type DefaultFeeTokens = DefaultFeeTokens; } -pub struct MockSwapDexIncentives; -impl SwapDexIncentives for MockSwapDexIncentives { +pub struct MockIncentives; +impl Incentives for MockIncentives { fn do_deposit_dex_share(who: &AccountId32, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { Tokens::reserve(lp_currency_id, who, amount) } @@ -249,7 +249,7 @@ impl edfis_swap_legacy_module::Config for Runtime { type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = MockErc20InfoMapping; type WeightInfo = (); - type SwapDexIncentives = MockSwapDexIncentives; + type Incentives = MockIncentives; type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU32<0>; type OnLiquidityPoolUpdated = (); diff --git a/blockchain/modules/evm/src/lib.rs b/blockchain/modules/evm/src/lib.rs index ce2b4f02..893754c3 100644 --- a/blockchain/modules/evm/src/lib.rs +++ b/blockchain/modules/evm/src/lib.rs @@ -365,7 +365,7 @@ pub mod module { fn build(&self) { use sp_std::rc::Rc; - // NOTE: Only applicable for mandala testnet, unit test and integration test. + // NOTE: Only applicable for Qingdao Devnet, unit test and integration test. // Use create_predeploy_contract to deploy predeploy contracts on the mainnet. let source = T::NetworkContractSource::get(); diff --git a/blockchain/modules/incentives/Cargo.toml b/blockchain/modules/incentives/Cargo.toml new file mode 100644 index 00000000..f73b62ce --- /dev/null +++ b/blockchain/modules/incentives/Cargo.toml @@ -0,0 +1,44 @@ +[package] +name = "module-incentives" +version = "0.9.81-dev" +authors = ["Setheum Labs"] +edition = "2021" + +[dependencies] +log = { workspace = true } +parity-scale-codec = { workspace = true } +scale-info = { workspace = true } +sp-runtime = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } +sp-std = { workspace = true } +orml-traits = { workspace = true } +orml-rewards = { workspace = true } +module-support = { workspace = true } +primitives = { workspace = true } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +sp-io = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true, features = ["std"] } +orml-tokens = { workspace = true, features = ["std"] } +orml-rewards = { workspace = true, features = ["std"] } + +[features] +default = ["std"] +std = [ + "parity-scale-codec/std", + "frame-support/std", + "frame-system/std", + "orml-rewards/std", + "orml-traits/std", + "primitives/std", + "scale-info/std", + "sp-runtime/std", + "sp-std/std", + "module-support/std", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", +] diff --git a/blockchain/modules/incentives/README.md b/blockchain/modules/incentives/README.md new file mode 100644 index 00000000..f4306f20 --- /dev/null +++ b/blockchain/modules/incentives/README.md @@ -0,0 +1,19 @@ +# Incentives Module + +Provides Incentive mechanisms for Ethical DeFi Protocols. + +## Overview + +Edfis Exchange needs to support multiple open liquidity reward mechanisms. Each Pool has its own multi currencies rewards and reward accumulation mechanism. ORML rewards module records the total shares, total multi currencies rewards and user shares of specific pool. Incentives module provides hooks to other protocals to manage shares, accumulates rewards and distributes rewards to users based on their shares. + +## Pool types: + +1. EcdpSetrLiquidityRewards: record the shares and rewards for Setter (SETR) ECDP users who are staking LP tokens. +2. EcdpUssdLiquidityRewards: record the shares and rewards for Slick USD (USSD) ECDP users who are staking LP tokens. +3. EdfisLiquidityRewards: record the shares and rewards for Edfis makers who are staking LP token. +4. EdfisXLiquidityRewards: record the shares and rewards for Edfis X (Cross-chain) makers who are staking XLP token. +5. MoyaEarnRewards: record the shares and rewards for users of Moya Earn (Moya Liquid Staking Protocol). + +## Rewards accumulation: + +Rewards: periodicly(AccumulatePeriod), accumulate fixed amount according to Rewards. Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before start Rewards plan. diff --git a/blockchain/modules/incentives/TODO.md b/blockchain/modules/incentives/TODO.md new file mode 100644 index 00000000..d70326b9 --- /dev/null +++ b/blockchain/modules/incentives/TODO.md @@ -0,0 +1,58 @@ +# To-Do List + +This list contains all TODOs in the Repo + + + +- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list) + - [1. Introduction](#1-guidelines) + - [2. Contribution](#2-contribution) + - [3. Lists](#3-lists) + - [4. Tasks](#4-tasks) + + + +## 1. Guidelines + +Note: Before you write a ToDo in this repo, please read the below guidelines carefully. + +Whenever you write a ToDo, you need to follow this standard syntax + +```rust +//TODO:[file_name:task_number] - task_details +``` + +for example: + +```rust +//TODO:[TODO.md:0] - Add Todo Guidelines +``` + +Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. + +Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. + +Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. + +Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: + +```rust +//TODO:[TODO.md-C:0] - Add Todo Guidelines +``` + +## 2. Contribution + +You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. + +## 3. Lists + +Each package/module/directory has its own `TODO.md`. + +## 4. Tasks + +These tasks are just for this file specifically. + +- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. +- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. + +- [x] [[src/lib.rs:0] - Update to support `EcdpSetrLiquidityRewards` and `EcdpUssdLiquidityRewards`](/blockchain/modules/edfis-liquidity-rewards/src/lib.rs): Update to support `EcdpSetrLiquidityRewards` and `EcdpUssdLiquidityRewards` such that if has `EcdpPosition` and is an LP for a pool with ECDP Stablecoin, then make it `EcdpSetrLiquidityRewards` or `EcdpUssdLiquidityRewards` respectively. diff --git a/blockchain/modules/incentives/src/lib.rs b/blockchain/modules/incentives/src/lib.rs new file mode 100644 index 00000000..3132fc60 --- /dev/null +++ b/blockchain/modules/incentives/src/lib.rs @@ -0,0 +1,604 @@ +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +//! # Incentives Module +//! +//! ## Overview +//! +//! Edfis Exchange needs to support multiple open liquidity reward mechanisms. Each Pool has +//! its own multi currencies rewards and reward accumulation mechanism. ORML rewards module +//! records the total shares, total multi currencies rewards and user shares of specific pool. +//! Incentives module provides hooks to other protocals to manage shares, +//! accumulates rewards and distributes rewards to users based on their shares. +//! +//! Pool types: +//! 1. EcdpSetrLiquidityRewards: record the shares and rewards for Setter (SETR) ECDP users who are staking LP tokens. +//! 2. EcdpUssdLiquidityRewards: record the shares and rewards for Slick USD (USSD) ECDP users who are staking LP tokens. +//! 3. EdfisLiquidityRewards: record the shares and rewards for Edfis makers who are staking LP token. +//! 4. EdfisXLiquidityRewards: record the shares and rewards for Edfis X (Cross-chain) makers who are staking XLP token. +//! 5. MoyaEarnRewards: record the shares and rewards for users of Moya Earn (Moya Liquid Staking Protocol). +//! +//! Rewards accumulation: +//! 1. Rewards: periodicly(AccumulatePeriod), accumulate fixed amount according to Rewards. +//! Rewards come from RewardsSource, please transfer enough tokens to RewardsSource before +//! start Rewards plan. + +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::unused_unit)] +#![allow(clippy::upper_case_acronyms)] + +use frame_support::{pallet_prelude::*, transactional, PalletId}; +use frame_system::pallet_prelude::*; +use module_support::{Incentives, EmergencyShutdown, FractionalRate, IncentivesManager, PoolId, Rate}; +use orml_traits::{Happened, MultiCurrency, RewardHandler}; +use primitives::{Amount, Balance, CurrencyId}; +use sp_runtime::{ + traits::{AccountIdConversion, UniqueSaturatedInto, Zero}, + DispatchResult, FixedPointNumber, +}; +use sp_std::{collections::btree_map::BTreeMap, prelude::*}; + +mod mock; +mod tests; +pub mod weights; + +pub use module::*; +pub use weights::WeightInfo; + +#[frame_support::pallet] +pub mod module { + use super::*; + + #[pallet::config] + pub trait Config: + frame_system::Config + + orml_rewards::Config + { + type RuntimeEvent: From> + IsType<::RuntimeEvent>; + + /// The period to accumulate rewards + #[pallet::constant] + type AccumulatePeriod: Get>; + + /// The native currency for earning staking + #[pallet::constant] + type NativeCurrencyId: Get; + + /// The source account for native token rewards. + #[pallet::constant] + type RewardsSource: Get; + + /// The origin which may update incentive related params + type UpdateOrigin: EnsureOrigin; + + /// Currency for transfer assets + type Currency: MultiCurrency; + + /// Emergency shutdown. + type EmergencyShutdown: EmergencyShutdown; + + /// The module id, keep DexShare LP. + #[pallet::constant] + type PalletId: Get; + + /// Weight information for the extrinsics in this module. + type WeightInfo: WeightInfo; + } + + #[pallet::error] + pub enum Error { + /// Share amount is not enough + NotEnough, + /// Invalid currency id + InvalidCurrencyId, + /// Invalid pool id + InvalidPoolId, + /// Invalid rate + InvalidRate, + } + + #[pallet::event] + #[pallet::generate_deposit(pub(crate) fn deposit_event)] + pub enum Event { + /// Deposit DEX share. + DepositDexShare { + who: T::AccountId, + dex_share_type: CurrencyId, + deposit: Balance, + }, + /// Withdraw DEX share. + WithdrawDexShare { + who: T::AccountId, + dex_share_type: CurrencyId, + withdraw: Balance, + }, + /// Claim rewards. + ClaimRewards { + who: T::AccountId, + pool: PoolId, + reward_currency_id: CurrencyId, + actual_amount: Balance, + deduction_amount: Balance, + }, + /// Incentive reward amount updated. + IncentiveRewardAmountUpdated { + pool: PoolId, + reward_currency_id: CurrencyId, + reward_amount_per_period: Balance, + }, + /// Payout deduction rate updated. + ClaimRewardDeductionRateUpdated { pool: PoolId, deduction_rate: Rate }, + /// Payout deduction currency updated. + ClaimRewardDeductionCurrencyUpdated { pool: PoolId, currency: Option }, + } + + /// Mapping from pool to its fixed incentive amounts of multi currencies per period. + /// + /// IncentiveRewardAmounts: double_map Pool, RewardCurrencyId => RewardAmountPerPeriod + #[pallet::storage] + #[pallet::getter(fn incentive_reward_amounts)] + pub type IncentiveRewardAmounts = + StorageDoubleMap<_, Twox64Concat, PoolId, Twox64Concat, CurrencyId, Balance, ValueQuery>; + + /// Mapping from pool to its claim reward deduction rate. + /// + /// ClaimRewardDeductionRates: map Pool => DeductionRate + #[pallet::storage] + pub type ClaimRewardDeductionRates = StorageMap<_, Twox64Concat, PoolId, FractionalRate, ValueQuery>; + + /// If specified, ClaimRewardDeductionRates only apply to this currency. + /// + /// ClaimRewardDeductionCurrency: map Pool => Option + #[pallet::storage] + pub type ClaimRewardDeductionCurrency = StorageMap<_, Twox64Concat, PoolId, CurrencyId, OptionQuery>; + + /// The pending rewards amount, actual available rewards amount may be deducted + /// + /// PendingMultiRewards: double_map PoolId, AccountId => BTreeMap + #[pallet::storage] + #[pallet::getter(fn pending_multi_rewards)] + pub type PendingMultiRewards = StorageDoubleMap< + _, + Twox64Concat, + PoolId, + Twox64Concat, + T::AccountId, + BTreeMap, + ValueQuery, + >; + + #[pallet::pallet] + #[pallet::without_storage_info] + pub struct Pallet(_); + + #[pallet::hooks] + impl Hooks> for Pallet { + fn on_initialize(now: BlockNumberFor) -> Weight { + // accumulate reward periodically + if now % T::AccumulatePeriod::get() == Zero::zero() { + let mut count: u32 = 0; + + for (pool_id, pool_info) in orml_rewards::PoolInfos::::iter() { + if !pool_info.total_shares.is_zero() { + match pool_id { + // TODO:[src/lib.rs:0] - Update to support `EcdpSetrLiquidityRewards` and `EcdpUssdLiquidityRewards` + // [src/lib.rs:0-1] - such that if has `EcdpPosition` and is an LP for a pool with ECDP Stablecoin, + // [src/lib.rs:0-1] - then make it `EcdpSetrLiquidityRewards` or `EcdpUssdLiquidityRewards` respectively. + _ => { + count += 1; + Self::accumulate_incentives(pool_id); + } + } + } + } + + T::WeightInfo::on_initialize(count) + } else { + Weight::zero() + } + } + } + + #[pallet::call] + impl Pallet { + /// Stake LP token to add shares of Pool::Dex + /// + /// The dispatch origin of this call must be `Signed` by the transactor. + /// + /// - `lp_currency_id`: LP token type + /// - `amount`: amount to stake + #[pallet::call_index(0)] + #[pallet::weight(::WeightInfo::deposit_dex_share())] + pub fn deposit_dex_share( + origin: OriginFor, + lp_currency_id: CurrencyId, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + Self::do_deposit_dex_share(&who, lp_currency_id, amount)?; + Ok(()) + } + + /// Unstake LP token to remove shares of Pool::Dex + /// + /// The dispatch origin of this call must be `Signed` by the transactor. + /// + /// - `lp_currency_id`: LP token type + /// - `amount`: amount to unstake + #[pallet::call_index(1)] + #[pallet::weight(::WeightInfo::withdraw_dex_share())] + pub fn withdraw_dex_share( + origin: OriginFor, + lp_currency_id: CurrencyId, + #[pallet::compact] amount: Balance, + ) -> DispatchResult { + let who = ensure_signed(origin)?; + Self::do_withdraw_dex_share(&who, lp_currency_id, amount)?; + Ok(()) + } + + /// Claim all avalible multi currencies rewards for specific PoolId. + /// + /// The dispatch origin of this call must be `Signed` by the transactor. + /// + /// - `pool_id`: pool type + #[pallet::call_index(2)] + #[pallet::weight(::WeightInfo::claim_rewards())] + pub fn claim_rewards(origin: OriginFor, pool_id: PoolId) -> DispatchResult { + let who = ensure_signed(origin)?; + + Self::do_claim_rewards(who, pool_id) + } + + /// Update incentive reward amount for specific PoolId + /// + /// The dispatch origin of this call must be `UpdateOrigin`. + /// + /// - `updates`: Vec<(PoolId, Vec<(RewardCurrencyId, FixedAmountPerPeriod)>)> + #[pallet::call_index(3)] + #[pallet::weight(::WeightInfo::update_incentive_rewards( + updates.iter().fold(0, |count, x| count + x.1.len()) as u32 + ))] + pub fn update_incentive_rewards( + origin: OriginFor, + updates: Vec<(PoolId, Vec<(CurrencyId, Balance)>)>, + ) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + for (pool_id, update_list) in updates { + if let PoolId::EdfisLiquidityRewards(currency_id) = pool_id { + ensure!(currency_id.is_dex_share_currency_id(), Error::::InvalidPoolId); + } + + for (currency_id, amount) in update_list { + IncentiveRewardAmounts::::mutate_exists(pool_id, currency_id, |maybe_amount| { + let mut v = maybe_amount.unwrap_or_default(); + if amount != v { + v = amount; + Self::deposit_event(Event::IncentiveRewardAmountUpdated { + pool: pool_id, + reward_currency_id: currency_id, + reward_amount_per_period: amount, + }); + } + + if v.is_zero() { + *maybe_amount = None; + } else { + *maybe_amount = Some(v); + } + }); + } + } + Ok(()) + } + + /// Update claim rewards deduction rates for all rewards currencies of specific PoolId + /// + /// The dispatch origin of this call must be `UpdateOrigin`. + /// + /// - `updates`: Vec<(PoolId, DecutionRate>)> + #[pallet::call_index(4)] + #[pallet::weight(::WeightInfo::update_claim_reward_deduction_rates(updates.len() as u32))] + pub fn update_claim_reward_deduction_rates( + origin: OriginFor, + updates: Vec<(PoolId, Rate)>, + ) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + for (pool_id, deduction_rate) in updates { + if let PoolId::EdfisLiquidityRewards(currency_id) = pool_id { + ensure!(currency_id.is_dex_share_currency_id(), Error::::InvalidPoolId); + } + ClaimRewardDeductionRates::::mutate_exists(pool_id, |maybe_rate| -> DispatchResult { + let mut v = maybe_rate.unwrap_or_default(); + if deduction_rate != *v.inner() { + v.try_set(deduction_rate).map_err(|_| Error::::InvalidRate)?; + Self::deposit_event(Event::ClaimRewardDeductionRateUpdated { + pool: pool_id, + deduction_rate, + }); + } + + if v.inner().is_zero() { + *maybe_rate = None; + } else { + *maybe_rate = Some(v); + } + Ok(()) + })?; + } + Ok(()) + } + + /// Update claim rewards deduction rates currency + /// + /// The dispatch origin of this call must be `UpdateOrigin`. + #[pallet::call_index(5)] + #[pallet::weight(::WeightInfo::update_claim_reward_deduction_currency())] + pub fn update_claim_reward_deduction_currency( + origin: OriginFor, + pool_id: PoolId, + currency_id: Option, + ) -> DispatchResult { + T::UpdateOrigin::ensure_origin(origin)?; + ClaimRewardDeductionCurrency::::mutate_exists(pool_id, |c| *c = currency_id); + Self::deposit_event(Event::ClaimRewardDeductionCurrencyUpdated { + pool: pool_id, + currency: currency_id, + }); + Ok(()) + } + } +} + +impl Pallet { + pub fn account_id() -> T::AccountId { + T::PalletId::get().into_account_truncating() + } + + pub(crate) fn claim_reward_deduction_rates(pool_id: &PoolId) -> Rate { + ClaimRewardDeductionRates::::get(pool_id).into_inner() + } + + // accumulate incentive rewards of multi currencies + fn accumulate_incentives(pool_id: PoolId) { + for (reward_currency_id, reward_amount) in IncentiveRewardAmounts::::iter_prefix(pool_id) { + if reward_amount.is_zero() { + continue; + } + + // ignore result so that failure will not block accumulate other type reward for the pool + let _ = + Self::transfer_rewards_and_update_records(pool_id, reward_currency_id, reward_amount).map_err(|e| { + log::warn!( + target: "incentives", + "accumulate_incentives: failed to accumulate {:?} {:?} rewards for pool {:?} : {:?}", + reward_amount, reward_currency_id, pool_id, e + ); + }); + } + } + + /// Ensure atomic + #[transactional] + fn transfer_rewards_and_update_records( + pool_id: PoolId, + reward_currency_id: CurrencyId, + reward_amount: Balance, + ) -> DispatchResult { + T::Currency::transfer( + reward_currency_id, + &T::RewardsSource::get(), + &Self::account_id(), + reward_amount, + )?; + >::accumulate_reward(&pool_id, reward_currency_id, reward_amount)?; + Ok(()) + } + + fn do_claim_rewards(who: T::AccountId, pool_id: PoolId) -> DispatchResult { + // orml_rewards will claim rewards for all currencies rewards + >::claim_rewards(&who, &pool_id); + + PendingMultiRewards::::mutate_exists(pool_id, &who, |maybe_pending_multi_rewards| { + if let Some(pending_multi_rewards) = maybe_pending_multi_rewards { + let deduction_rate = Self::claim_reward_deduction_rates(&pool_id); + let deduction_currency = ClaimRewardDeductionCurrency::::get(pool_id); + + for (currency_id, pending_reward) in pending_multi_rewards.iter_mut() { + if pending_reward.is_zero() { + continue; + } + + let deduction_rate = if let Some(deduction_currency) = deduction_currency { + // only apply deduction rate to specified currency + if deduction_currency == *currency_id { + deduction_rate + } else { + Zero::zero() + } + } else { + // apply deduction rate to all currencies + deduction_rate + }; + + let (payout_amount, deduction_amount) = { + let should_deduction_amount = deduction_rate.saturating_mul_int(*pending_reward); + ( + pending_reward.saturating_sub(should_deduction_amount), + should_deduction_amount, + ) + }; + + // payout reward to claimer and re-accumuated reward. + match Self::payout_reward_and_reaccumulate_reward( + pool_id, + &who, + *currency_id, + payout_amount, + deduction_amount, + ) { + Ok(_) => { + // update state + *pending_reward = Zero::zero(); + + Self::deposit_event(Event::ClaimRewards { + who: who.clone(), + pool: pool_id, + reward_currency_id: *currency_id, + actual_amount: payout_amount, + deduction_amount, + }); + } + Err(e) => { + log::error!( + target: "incentives", + "payout_reward_and_reaccumulate_reward: failed to payout {:?} to {:?} and re-accumulate {:?} {:?} to pool {:?}: {:?}", + payout_amount, who, deduction_amount, currency_id, pool_id, e + ); + } + }; + } + + // clear zero value item of BTreeMap + pending_multi_rewards.retain(|_, v| *v != 0); + + // if pending_multi_rewards is default, clear the storage + if pending_multi_rewards.is_empty() { + *maybe_pending_multi_rewards = None; + } + } + }); + + Ok(()) + } + + /// Ensure atomic + #[transactional] + fn payout_reward_and_reaccumulate_reward( + pool_id: PoolId, + who: &T::AccountId, + reward_currency_id: CurrencyId, + payout_amount: Balance, + reaccumulate_amount: Balance, + ) -> DispatchResult { + if !reaccumulate_amount.is_zero() { + >::accumulate_reward(&pool_id, reward_currency_id, reaccumulate_amount)?; + } + T::Currency::transfer(reward_currency_id, &Self::account_id(), who, payout_amount)?; + Ok(()) + } +} + +impl Incentives for Pallet { + fn do_deposit_dex_share(who: &T::AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + ensure!(lp_currency_id.is_dex_share_currency_id(), Error::::InvalidCurrencyId); + + T::Currency::transfer(lp_currency_id, who, &Self::account_id(), amount)?; + >::add_share(who, &PoolId::EdfisLiquidityRewards(lp_currency_id), amount.unique_saturated_into()); + + Self::deposit_event(Event::DepositDexShare { + who: who.clone(), + dex_share_type: lp_currency_id, + deposit: amount, + }); + Ok(()) + } + + fn do_withdraw_dex_share(who: &T::AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + ensure!(lp_currency_id.is_dex_share_currency_id(), Error::::InvalidCurrencyId); + ensure!( + >::shares_and_withdrawn_rewards(&PoolId::EdfisLiquidityRewards(lp_currency_id), &who).0 >= amount, + Error::::NotEnough, + ); + + T::Currency::transfer(lp_currency_id, &Self::account_id(), who, amount)?; + >::remove_share(who, &PoolId::EdfisLiquidityRewards(lp_currency_id), amount.unique_saturated_into()); + + Self::deposit_event(Event::WithdrawDexShare { + who: who.clone(), + dex_share_type: lp_currency_id, + withdraw: amount, + }); + Ok(()) + } +} + +impl IncentivesManager for Pallet { + fn get_incentive_reward_amount(pool_id: PoolId, currency_id: CurrencyId) -> Balance { + IncentiveRewardAmounts::::get(pool_id, currency_id) + } + + fn deposit_dex_share(who: &T::AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + Self::do_deposit_dex_share(who, lp_currency_id, amount) + } + + fn withdraw_dex_share(who: &T::AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult { + Self::do_withdraw_dex_share(who, lp_currency_id, amount) + } + + fn claim_rewards(who: T::AccountId, pool_id: PoolId) -> DispatchResult { + Self::do_claim_rewards(who, pool_id) + } + + fn get_claim_reward_deduction_rate(pool_id: PoolId) -> Rate { + Self::claim_reward_deduction_rates(&pool_id) + } + + fn get_pending_rewards(pool_id: PoolId, who: T::AccountId, reward_currencies: Vec) -> Vec { + let rewards_map = PendingMultiRewards::::get(pool_id, who); + let mut reward_balances = Vec::new(); + for reward_currency in reward_currencies { + let reward_amount = rewards_map.get(&reward_currency).copied().unwrap_or_default(); + reward_balances.push(reward_amount); + } + reward_balances + } +} + +impl RewardHandler for Pallet { + type Balance = Balance; + type PoolId = PoolId; + + fn payout(who: &T::AccountId, pool_id: &Self::PoolId, currency_id: CurrencyId, payout_amount: Self::Balance) { + if payout_amount.is_zero() { + return; + } + PendingMultiRewards::::mutate(pool_id, who, |rewards| { + rewards + .entry(currency_id) + .and_modify(|current| *current = current.saturating_add(payout_amount)) + .or_insert(payout_amount); + }); + } +} + +pub struct OnMoyaEarnBonded(sp_std::marker::PhantomData); +impl Happened<(T::AccountId, Balance)> for OnMoyaEarnBonded { + fn happened((who, amount): &(T::AccountId, Balance)) { + >::add_share(who, &PoolId::MoyaEarnRewards(T::NativeCurrencyId::get()), *amount); + } +} + +pub struct OnMoyaEarnUnbonded(sp_std::marker::PhantomData); +impl Happened<(T::AccountId, Balance)> for OnMoyaEarnUnbonded { + fn happened((who, amount): &(T::AccountId, Balance)) { + >::remove_share(who, &PoolId::MoyaEarnRewards(T::NativeCurrencyId::get()), *amount); + } +} diff --git a/blockchain/modules/incentives/src/mock.rs b/blockchain/modules/incentives/src/mock.rs new file mode 100644 index 00000000..8f458b33 --- /dev/null +++ b/blockchain/modules/incentives/src/mock.rs @@ -0,0 +1,173 @@ +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +//! Mocks for the incentives module. + +#![cfg(test)] + +use super::*; +use frame_support::{ + construct_runtime, derive_impl, ord_parameter_types, parameter_types, + traits::{ConstU64, Nothing}, +}; +use frame_system::EnsureSignedBy; +pub use module_support::{Price, Ratio, SwapLimit}; +use orml_traits::parameter_type_with_key; +use primitives::{DexShare, TokenSymbol}; +use sp_runtime::{traits::IdentityLookup, AccountId32, BuildStorage}; +use sp_std::cell::RefCell; + +pub type AccountId = AccountId32; + +pub const SEE: CurrencyId = CurrencyId::Token(TokenSymbol::SEE); +pub const USSD: CurrencyId = CurrencyId::Token(TokenSymbol::USSD); +pub const LEDF: CurrencyId = CurrencyId::Token(TokenSymbol::LEDF); +pub const BTC: CurrencyId = CurrencyId::ForeignAsset(255); +pub const EDF: CurrencyId = CurrencyId::Token(TokenSymbol::EDF); +pub const BTC_USSD_LP: CurrencyId = + CurrencyId::DexShare(DexShare::ForeignAsset(255), DexShare::Token(TokenSymbol::USSD)); +pub const EDF_USSD_LP: CurrencyId = + CurrencyId::DexShare(DexShare::Token(TokenSymbol::EDF), DexShare::Token(TokenSymbol::USSD)); + +mod incentives { + pub use super::super::*; +} + +ord_parameter_types! { + pub const ALICE: AccountId = AccountId::from([1u8; 32]); + pub const BOB: AccountId = AccountId::from([2u8; 32]); + pub const VAULT: AccountId = IncentivesModule::account_id(); + pub const RewardsSource: AccountId = AccountId::from([3u8; 32]); + pub const ROOT: AccountId = AccountId32::new([255u8; 32]); +} + +#[derive_impl(frame_system::config_preludes::TestDefaultConfig as frame_system::DefaultConfig)] +impl frame_system::Config for Runtime { + type AccountId = AccountId; + type Lookup = IdentityLookup; + type Block = Block; + type AccountData = pallet_balances::AccountData; +} + +parameter_type_with_key! { + pub ExistentialDeposits: |currency_id: CurrencyId| -> Balance { + + match currency_id { + CurrencyId::Token(TokenSymbol::USSD) => 10, + _ => Default::default() + } + }; +} + +impl orml_tokens::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Balance = Balance; + type Amount = Amount; + type CurrencyId = CurrencyId; + type WeightInfo = (); + type ExistentialDeposits = ExistentialDeposits; + type CurrencyHooks = (); + type MaxLocks = (); + type MaxReserves = (); + type ReserveIdentifier = [u8; 8]; + type DustRemovalWhitelist = Nothing; +} + +thread_local! { + static IS_SHUTDOWN: RefCell = RefCell::new(false); +} + +pub fn mock_shutdown() { + IS_SHUTDOWN.with(|v| *v.borrow_mut() = true) +} + +pub struct MockEmergencyShutdown; +impl EmergencyShutdown for MockEmergencyShutdown { + fn is_shutdown() -> bool { + IS_SHUTDOWN.with(|v| *v.borrow_mut()) + } +} + +impl orml_rewards::Config for Runtime { + type Share = Balance; + type Balance = Balance; + type PoolId = PoolId; + type CurrencyId = CurrencyId; + type Handler = IncentivesModule; +} + +parameter_types! { + pub const GetNativeCurrencyId: CurrencyId = SEE; + pub const IncentivesPalletId: PalletId = PalletId(*b"set/inct"); +} + +ord_parameter_types! { + pub const Root: AccountId = ROOT::get(); +} + +impl Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type RewardsSource = RewardsSource; + type AccumulatePeriod = ConstU64<10>; + type NativeCurrencyId = GetNativeCurrencyId; + type UpdateOrigin = EnsureSignedBy; + type Currency = TokensModule; + type EmergencyShutdown = MockEmergencyShutdown; + type PalletId = IncentivesPalletId; + type WeightInfo = (); +} + +type Block = frame_system::mocking::MockBlock; + +construct_runtime!( + pub enum Runtime { + System: frame_system, + IncentivesModule: incentives, + TokensModule: orml_tokens, + RewardsModule: orml_rewards, + } +); + +pub struct ExtBuilder { + balances: Vec<(AccountId, CurrencyId, Balance)>, +} + +impl Default for ExtBuilder { + fn default() -> Self { + Self { balances: vec![] } + } +} + +impl ExtBuilder { + pub fn build(self) -> sp_io::TestExternalities { + let mut t = frame_system::GenesisConfig::::default() + .build_storage() + .unwrap(); + orml_tokens::GenesisConfig:: { + balances: self.balances, + } + .assimilate_storage(&mut t) + .unwrap(); + + let mut ext = sp_io::TestExternalities::new(t); + ext.execute_with(|| System::set_block_number(1)); + ext + } +} diff --git a/blockchain/modules/incentives/src/tests.rs b/blockchain/modules/incentives/src/tests.rs new file mode 100644 index 00000000..36615333 --- /dev/null +++ b/blockchain/modules/incentives/src/tests.rs @@ -0,0 +1,683 @@ +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +//! Unit tests for the incentives module. + +#![cfg(test)] + +use super::*; +use frame_support::{assert_noop, assert_ok}; +use mock::{RuntimeEvent, *}; +use orml_rewards::PoolInfo; +use orml_traits::MultiCurrency; +use sp_runtime::{traits::BadOrigin, FixedPointNumber}; + +#[test] +fn deposit_dex_share_works() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(TokensModule::deposit(BTC_USSD_LP, &ALICE::get(), 10000)); + assert_eq!(TokensModule::free_balance(BTC_USSD_LP, &ALICE::get()), 10000); + assert_eq!( + TokensModule::free_balance(BTC_USSD_LP, &IncentivesModule::account_id()), + 0 + ); + assert_eq!(RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), PoolInfo::default(),); + + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::Dex(BTC_USSD_LP), ALICE::get()), + Default::default(), + ); + + assert_ok!(IncentivesModule::deposit_dex_share( + RuntimeOrigin::signed(ALICE::get()), + BTC_USSD_LP, + 10000 + )); + System::assert_last_event(RuntimeEvent::IncentivesModule(crate::Event::DepositDexShare { + who: ALICE::get(), + dex_share_type: BTC_USSD_LP, + deposit: 10000, + })); + assert_eq!(TokensModule::free_balance(BTC_USSD_LP, &ALICE::get()), 0); + assert_eq!( + TokensModule::free_balance(BTC_USSD_LP, &IncentivesModule::account_id()), + 10000 + ); + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 10000, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::Dex(BTC_USSD_LP), ALICE::get()), + (10000, Default::default()) + ); + }); +} + +#[test] +fn withdraw_dex_share_works() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(TokensModule::deposit(BTC_USSD_LP, &ALICE::get(), 10000)); + + assert_noop!( + IncentivesModule::withdraw_dex_share(RuntimeOrigin::signed(BOB::get()), BTC_USSD_LP, 10000), + Error::::NotEnough, + ); + + assert_ok!(IncentivesModule::deposit_dex_share( + RuntimeOrigin::signed(ALICE::get()), + BTC_USSD_LP, + 10000 + )); + assert_eq!(TokensModule::free_balance(BTC_USSD_LP, &ALICE::get()), 0); + assert_eq!( + TokensModule::free_balance(BTC_USSD_LP, &IncentivesModule::account_id()), + 10000 + ); + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 10000, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::Dex(BTC_USSD_LP), ALICE::get()), + (10000, Default::default()) + ); + + assert_ok!(IncentivesModule::withdraw_dex_share( + RuntimeOrigin::signed(ALICE::get()), + BTC_USSD_LP, + 8000 + )); + System::assert_last_event(RuntimeEvent::IncentivesModule(crate::Event::WithdrawDexShare { + who: ALICE::get(), + dex_share_type: BTC_USSD_LP, + withdraw: 8000, + })); + assert_eq!(TokensModule::free_balance(BTC_USSD_LP, &ALICE::get()), 8000); + assert_eq!( + TokensModule::free_balance(BTC_USSD_LP, &IncentivesModule::account_id()), + 2000 + ); + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 2000, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::Dex(BTC_USSD_LP), ALICE::get()), + (2000, Default::default()) + ); + }); +} + +#[test] +fn update_incentive_rewards_works() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + IncentivesModule::update_incentive_rewards(RuntimeOrigin::signed(ALICE::get()), vec![]), + BadOrigin + ); + assert_noop!( + IncentivesModule::update_incentive_rewards( + RuntimeOrigin::signed(ROOT::get()), + vec![(PoolId::Dex(EDF), vec![])] + ), + Error::::InvalidPoolId + ); + + assert_eq!( + IncentivesModule::incentive_reward_amounts(PoolId::Dex(EDF_USSD_LP), SEE), + 0 + ); + assert_eq!( + IncentivesModule::incentive_reward_amounts(PoolId::Dex(EDF_USSD_LP), EDF), + 0 + ); + + assert_ok!(IncentivesModule::update_incentive_rewards( + RuntimeOrigin::signed(ROOT::get()), + vec![ + (PoolId::Dex(EDF_USSD_LP), vec![(SEE, 1000), (EDF, 100)]), + ], + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::IncentiveRewardAmountUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + reward_currency_id: SEE, + reward_amount_per_period: 1000, + }, + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::IncentiveRewardAmountUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + reward_currency_id: EDF, + reward_amount_per_period: 100, + }, + )); + assert_eq!( + IncentivesModule::incentive_reward_amounts(PoolId::Dex(EDF_USSD_LP), SEE), + 1000 + ); + assert_eq!( + IncentiveRewardAmounts::::contains_key(PoolId::Dex(EDF_USSD_LP), EDF), + true + ); + assert_eq!( + IncentivesModule::incentive_reward_amounts(PoolId::Dex(EDF_USSD_LP), EDF), + 100 + ); + + assert_ok!(IncentivesModule::update_incentive_rewards( + RuntimeOrigin::signed(ROOT::get()), + vec![(PoolId::Dex(EDF_USSD_LP), vec![(SEE, 200), (EDF, 0)])], + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::IncentiveRewardAmountUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + reward_currency_id: SEE, + reward_amount_per_period: 200, + }, + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::IncentiveRewardAmountUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + reward_currency_id: EDF, + reward_amount_per_period: 0, + }, + )); + assert_eq!( + IncentivesModule::incentive_reward_amounts(PoolId::Dex(EDF_USSD_LP), SEE), + 200 + ); + assert_eq!( + IncentiveRewardAmounts::::contains_key(PoolId::Dex(EDF_USSD_LP), EDF), + false + ); + }); +} + +#[test] +fn update_claim_reward_deduction_rates_works() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + IncentivesModule::update_claim_reward_deduction_rates(RuntimeOrigin::signed(ALICE::get()), vec![]), + BadOrigin + ); + assert_noop!( + IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![(PoolId::Dex(EDF), Rate::zero())] + ), + Error::::InvalidPoolId + ); + assert_noop!( + IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![(PoolId::Dex(EDF_USSD_LP), Rate::saturating_from_rational(101, 100)),] + ), + Error::::InvalidRate, + ); + + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(EDF_USSD_LP)), + Rate::zero() + ); + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(BTC_USSD_LP)), + Rate::zero() + ); + + assert_ok!(IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![ + (PoolId::Dex(EDF_USSD_LP), Rate::saturating_from_rational(1, 100)), + (PoolId::Dex(BTC_USSD_LP), Rate::saturating_from_rational(2, 100)) + ] + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::ClaimRewardDeductionRateUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + deduction_rate: Rate::saturating_from_rational(1, 100), + }, + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::ClaimRewardDeductionRateUpdated { + pool: PoolId::Dex(BTC_USSD_LP), + deduction_rate: Rate::saturating_from_rational(2, 100), + }, + )); + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(EDF_USSD_LP)), + Rate::saturating_from_rational(1, 100) + ); + assert_eq!( + ClaimRewardDeductionRates::::contains_key(PoolId::Dex(BTC_USSD_LP)), + true + ); + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(BTC_USSD_LP)), + Rate::saturating_from_rational(2, 100) + ); + + assert_ok!(IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![ + (PoolId::Dex(EDF_USSD_LP), Rate::saturating_from_rational(5, 100)), + (PoolId::Dex(BTC_USSD_LP), Rate::zero()) + ] + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::ClaimRewardDeductionRateUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + deduction_rate: Rate::saturating_from_rational(5, 100), + }, + )); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::ClaimRewardDeductionRateUpdated { + pool: PoolId::Dex(BTC_USSD_LP), + deduction_rate: Rate::zero(), + }, + )); + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(EDF_USSD_LP)), + Rate::saturating_from_rational(5, 100) + ); + assert_eq!( + ClaimRewardDeductionRates::::contains_key(PoolId::Dex(BTC_USSD_LP)), + false + ); + assert_eq!( + IncentivesModule::claim_reward_deduction_rates(&PoolId::Dex(BTC_USSD_LP)), + Rate::zero() + ); + }); +} + +#[test] +fn payout_works() { + ExtBuilder::default().build().execute_with(|| { + + }); +} + +#[test] +fn transfer_failed_when_claim_rewards() { + ExtBuilder::default().build().execute_with(|| { + + }); +} + +#[test] +fn claim_rewards_works() { + ExtBuilder::default().build().execute_with(|| { + + }); +} + +#[test] +fn on_initialize_should_work() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(TokensModule::deposit(SEE, &RewardsSource::get(), 10000)); + assert_ok!(TokensModule::deposit(USSD, &RewardsSource::get(), 10000)); + assert_ok!(TokensModule::deposit(LEDF, &RewardsSource::get(), 10000)); + + assert_ok!(IncentivesModule::update_incentive_rewards( + RuntimeOrigin::signed(ROOT::get()), + vec![ + (PoolId::Dex(BTC_USSD_LP), vec![(SEE, 100)]), + (PoolId::Dex(EDF_USSD_LP), vec![(SEE, 200)]), + (PoolId::MoyaEarnRewards(SEE), vec![(SEE, 100)]), + ], + )); + + RewardsModule::add_share(&ALICE::get(), &PoolId::Dex(BTC_USSD_LP), 1); + RewardsModule::add_share(&ALICE::get(), &PoolId::Dex(EDF_USSD_LP), 1); + RewardsModule::add_share(&ALICE::get(), &PoolId::MoyaEarnRewards(SEE), 1); + + assert_eq!(TokensModule::free_balance(SEE, &RewardsSource::get()), 10000); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 10000); + assert_eq!(TokensModule::free_balance(LEDF, &RewardsSource::get()), 10000); + + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 1, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(EDF_USSD_LP)), + PoolInfo { + total_shares: 1, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 1, + ..Default::default() + } + ); + + // per 10 blocks will accumulate rewards, nothing happened when on_initialize(9) + IncentivesModule::on_initialize(9); + + IncentivesModule::on_initialize(10); + assert_eq!( + TokensModule::free_balance(SEE, &RewardsSource::get()), + 10000 - (1000 + 200 + 100 + 100) + ); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 10000 - 500); + assert_eq!(TokensModule::free_balance(LEDF, &RewardsSource::get()), 10000); + + // 100 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (100, 0))].into_iter().collect(), + } + ); + // 200 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(EDF_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (200, 0))].into_iter().collect(), + } + ); + // 100 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (100, 0))].into_iter().collect(), + } + ); + + IncentivesModule::on_initialize(20); + assert_eq!( + TokensModule::free_balance(SEE, &RewardsSource::get()), + 8600 - (1000 + 2000 + 100 + 200 + 100) + ); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 9500 - 500); + assert_eq!(TokensModule::free_balance(LEDF, &RewardsSource::get()), 10000 - 50); + + // 100 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (200, 0))].into_iter().collect(), + } + ); + // 200 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(EDF_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (400, 0))].into_iter().collect(), + } + ); + // 100 SEE is incentive reward + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (200, 0))].into_iter().collect(), + } + ); + + mock_shutdown(); + IncentivesModule::on_initialize(30); + assert_eq!( + TokensModule::free_balance(SEE, &RewardsSource::get()), + 5200 - (100 + 200 + 100) + ); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 9000); + assert_eq!(TokensModule::free_balance(LEDF, &RewardsSource::get()), 9950); + + // after shutdown, PoolId::Dex will accumulate incentive rewards + // reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(BTC_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (300, 0))].into_iter().collect(), + } + ); + // after shutdown, PoolId::Dex will accumulate incentive rewards + // reward + assert_eq!( + RewardsModule::pool_infos(PoolId::Dex(EDF_USSD_LP)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (600, 0))].into_iter().collect(), + } + ); + // after shutdown, PoolId::MoyaEarnRewards will accumulate incentive rewards + // reward + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 1, + rewards: vec![(SEE, (300, 0))].into_iter().collect(), + } + ); + }); +} + +#[test] +fn earning_should_work() { + ExtBuilder::default().build().execute_with(|| { + OnEarnBonded::::happened(&(ALICE::get(), 80)); + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 80, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::MoyaEarnRewards(SEE), ALICE::get()), + (80, Default::default()) + ); + + OnEarnUnbonded::::happened(&(ALICE::get(), 20)); + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { + total_shares: 60, + ..Default::default() + } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::MoyaEarnRewards(SEE), ALICE::get()), + (60, Default::default()) + ); + + OnEarnUnbonded::::happened(&(ALICE::get(), 60)); + assert_eq!( + RewardsModule::pool_infos(PoolId::MoyaEarnRewards(SEE)), + PoolInfo { ..Default::default() } + ); + assert_eq!( + RewardsModule::shares_and_withdrawn_rewards(PoolId::MoyaEarnRewards(SEE), ALICE::get()), + (0, Default::default()) + ); + }); +} + +#[test] +fn transfer_reward_and_update_rewards_storage_atomically_when_accumulate_incentives_work() { + ExtBuilder::default().build().execute_with(|| { + assert_ok!(TokensModule::deposit(USSD, &RewardsSource::get(), 100)); + assert_ok!(TokensModule::deposit(SEE, &RewardsSource::get(), 100)); + assert_eq!(TokensModule::free_balance(SEE, &RewardsSource::get()), 100); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 100); + assert_eq!( + orml_rewards::PoolInfos::::contains_key(PoolId::Dex(LEDF)), + false + ); + + assert_eq!(TokensModule::free_balance(SEE, &RewardsSource::get()), 100); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 100); + + // accumulate SEE and USSD rewards succeeded + assert_eq!(TokensModule::free_balance(SEE, &RewardsSource::get()), 70); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 10); + + // accumulate SEE reward succeeded, accumulate USSD reward failed + assert_eq!(TokensModule::free_balance(SEE, &RewardsSource::get()), 40); + assert_eq!(TokensModule::free_balance(USSD, &RewardsSource::get()), 10); + }); +} + +#[test] +fn update_claim_reward_deduction_currency() { + ExtBuilder::default().build().execute_with(|| { + assert_noop!( + IncentivesModule::update_claim_reward_deduction_currency( + RuntimeOrigin::signed(ALICE::get()), + PoolId::Dex(EDF_USSD_LP), + Some(SEE) + ), + BadOrigin + ); + + assert_ok!(IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![(PoolId::Dex(EDF_USSD_LP), Rate::saturating_from_rational(10, 100)),] + )); + assert_ok!(IncentivesModule::update_claim_reward_deduction_currency( + RuntimeOrigin::signed(ROOT::get()), + PoolId::Dex(EDF_USSD_LP), + Some(SEE) + ),); + System::assert_has_event(RuntimeEvent::IncentivesModule( + crate::Event::ClaimRewardDeductionCurrencyUpdated { + pool: PoolId::Dex(EDF_USSD_LP), + currency: Some(SEE), + }, + )); + + assert_eq!( + ClaimRewardDeductionCurrency::::get(PoolId::Dex(EDF_USSD_LP)), + Some(SEE) + ); + }); +} + +#[test] +fn claim_reward_deduction_currency_works() { + ExtBuilder::default().build().execute_with(|| { + let pool_id = PoolId::Dex(EDF_USSD_LP); + + assert_ok!(IncentivesModule::update_claim_reward_deduction_rates( + RuntimeOrigin::signed(ROOT::get()), + vec![(pool_id, Rate::saturating_from_rational(10, 100)),] + )); + assert_ok!(IncentivesModule::update_claim_reward_deduction_currency( + RuntimeOrigin::signed(ROOT::get()), + pool_id, + Some(SEE) + )); + + // alice add shares before accumulate rewards + RewardsModule::add_share(&ALICE::get(), &pool_id, 100); + + // bob add shares before accumulate rewards + RewardsModule::add_share(&BOB::get(), &pool_id, 100); + + // accumulate rewards + assert_ok!(RewardsModule::accumulate_reward(&pool_id, SEE, 1000)); + assert_ok!(RewardsModule::accumulate_reward(&pool_id, USSD, 2000)); + + // alice claim rewards + assert_ok!(IncentivesModule::claim_rewards( + RuntimeOrigin::signed(ALICE::get()), + pool_id + )); + + System::assert_has_event(RuntimeEvent::IncentivesModule(crate::Event::ClaimRewards { + who: ALICE::get(), + pool: pool_id, + reward_currency_id: SEE, + actual_amount: 450, + deduction_amount: 50, + })); + System::assert_has_event(RuntimeEvent::IncentivesModule(crate::Event::ClaimRewards { + who: ALICE::get(), + pool: pool_id, + reward_currency_id: USSD, + actual_amount: 1000, + deduction_amount: 0, + })); + + System::reset_events(); + + assert_eq!(TokensModule::free_balance(SEE, &ALICE::get()), 450); + assert_eq!(TokensModule::free_balance(USSD, &ALICE::get()), 1000); + + // apply deduction currency to all rewards + assert_ok!(IncentivesModule::update_claim_reward_deduction_currency( + RuntimeOrigin::signed(ROOT::get()), + pool_id, + None + )); + + // accumulate rewards + assert_ok!(RewardsModule::accumulate_reward(&pool_id, SEE, 1000)); + assert_ok!(RewardsModule::accumulate_reward(&pool_id, USSD, 2000)); + + // alice claim rewards + assert_ok!(IncentivesModule::claim_rewards( + RuntimeOrigin::signed(ALICE::get()), + pool_id + )); + + System::assert_has_event(RuntimeEvent::IncentivesModule(crate::Event::ClaimRewards { + who: ALICE::get(), + pool: pool_id, + reward_currency_id: SEE, + actual_amount: 473, + deduction_amount: 52, + })); + System::assert_has_event(RuntimeEvent::IncentivesModule(crate::Event::ClaimRewards { + who: ALICE::get(), + pool: pool_id, + reward_currency_id: USSD, + actual_amount: 900, + deduction_amount: 100, + })); + + assert_eq!(TokensModule::free_balance(SEE, &ALICE::get()), 923); + assert_eq!(TokensModule::free_balance(USSD, &ALICE::get()), 1900); + }); +} diff --git a/blockchain/modules/incentives/src/weights.rs b/blockchain/modules/incentives/src/weights.rs new file mode 100644 index 00000000..abec2e18 --- /dev/null +++ b/blockchain/modules/incentives/src/weights.rs @@ -0,0 +1,309 @@ +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +//! Autogenerated weights for module_incentives +//! +//! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev +//! DATE: 2023-10-05, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! HOSTNAME: `ip-172-31-47-44`, CPU: `Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz` +//! WASM-EXECUTION: Compiled, CHAIN: Some("dev"), DB CACHE: 1024 + +// Executed Command: +// target/release/setheum-node +// benchmark +// pallet +// --chain=dev +// --steps=50 +// --repeat=20 +// --pallet=module_incentives +// --extrinsic=* +// --wasm-execution=compiled +// --heap-pages=4096 +// --output=./blockchain/modules/edfis_mining/src/weights.rs +// --template=.maintain/module-weight-template.hbs + +#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_parens)] +#![allow(unused_imports)] + +use frame_support::{traits::Get, weights::{Weight, constants::RocksDbWeight}}; +use sp_std::marker::PhantomData; + +/// Weight functions needed for module_incentives. +pub trait WeightInfo { + fn on_initialize(c: u32, ) -> Weight; + fn deposit_dex_share() -> Weight; + fn withdraw_dex_share() -> Weight; + fn claim_rewards() -> Weight; + fn update_incentive_rewards(c: u32, ) -> Weight; + fn update_claim_reward_deduction_rates(c: u32, ) -> Weight; + fn update_claim_reward_deduction_currency() -> Weight; +} + +/// Weights for module_incentives using the Setheum node and recommended hardware. +pub struct SetheumWeight(PhantomData); +impl WeightInfo for SetheumWeight { + // Storage: `EmergencyShutdown::IsShutdown` (r:1 w:0) + // Proof: `EmergencyShutdown::IsShutdown` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:5 w:0) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::IncentiveRewardAmounts` (r:8 w:0) + // Proof: `Incentives::IncentiveRewardAmounts` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:0) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `c` is `[0, 4]`. + fn on_initialize(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1476 + c * (384 ±0)` + // Estimated: `5007 + c * (5027 ±13)` + // Minimum execution time: 13_440 nanoseconds. + Weight::from_parts(19_271_096, 5007) + // Standard Error: 190_479 + .saturating_add(Weight::from_parts(24_655_412, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads(2)) + .saturating_add(T::DbWeight::get().reads((3_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 5027).saturating_mul(c.into())) + } + // Storage: `Tokens::Accounts` (r:2 w:2) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `EvmAccounts::EvmAddresses` (r:1 w:0) + // Proof: `EvmAccounts::EvmAddresses` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn deposit_dex_share() -> Weight { + // Proof Size summary in bytes: + // Measured: `2855` + // Estimated: `6320` + // Minimum execution time: 98_848 nanoseconds. + Weight::from_parts(100_717_000, 6320) + .saturating_add(T::DbWeight::get().reads(6)) + .saturating_add(T::DbWeight::get().writes(5)) + } + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:2 w:2) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:1 w:0) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn withdraw_dex_share() -> Weight { + // Proof Size summary in bytes: + // Measured: `2945` + // Estimated: `6410` + // Minimum execution time: 97_599 nanoseconds. + Weight::from_parts(99_107_000, 6410) + .saturating_add(T::DbWeight::get().reads(5)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::PendingMultiRewards` (r:1 w:1) + // Proof: `Incentives::PendingMultiRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::ClaimRewardDeductionRates` (r:1 w:0) + // Proof: `Incentives::ClaimRewardDeductionRates` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::ClaimRewardDeductionCurrency` (r:1 w:0) + // Proof: `Incentives::ClaimRewardDeductionCurrency` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `EvmAccounts::EvmAddresses` (r:1 w:0) + // Proof: `EvmAccounts::EvmAddresses` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) + fn claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `2633` + // Estimated: `6098` + // Minimum execution time: 143_679 nanoseconds. + Weight::from_parts(146_283_000, 6098) + .saturating_add(T::DbWeight::get().reads(7)) + .saturating_add(T::DbWeight::get().writes(4)) + } + // Storage: `Incentives::IncentiveRewardAmounts` (r:4 w:4) + // Proof: `Incentives::IncentiveRewardAmounts` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 4]`. + fn update_incentive_rewards(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `760 + c * (94 ±0)` + // Estimated: `2033 + c * (2475 ±0)` + // Minimum execution time: 6_569 nanoseconds. + Weight::from_parts(10_367_012, 2033) + // Standard Error: 121_237 + .saturating_add(Weight::from_parts(11_986_144, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2475).saturating_mul(c.into())) + } + // Storage: `Incentives::ClaimRewardDeductionRates` (r:4 w:4) + // Proof: `Incentives::ClaimRewardDeductionRates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 4]`. + fn update_claim_reward_deduction_rates(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `676 + c * (10 ±0)` + // Estimated: `1698 + c * (2475 ±0)` + // Minimum execution time: 6_582 nanoseconds. + Weight::from_parts(7_678_403, 1698) + // Standard Error: 25_846 + .saturating_add(Weight::from_parts(3_067_233, 0).saturating_mul(c.into())) + .saturating_add(T::DbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(T::DbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2475).saturating_mul(c.into())) + } + // Storage: `Incentives::ClaimRewardDeductionCurrency` (r:1 w:1) + // Proof: `Incentives::ClaimRewardDeductionCurrency` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn update_claim_reward_deduction_currency() -> Weight { + // Proof Size summary in bytes: + // Measured: `1043` + // Estimated: `4508` + // Minimum execution time: 24_712 nanoseconds. + Weight::from_parts(25_404_000, 4508) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } +} + +// For backwards compatibility and tests +impl WeightInfo for () { + // Storage: `EmergencyShutdown::IsShutdown` (r:1 w:0) + // Proof: `EmergencyShutdown::IsShutdown` (`max_values`: Some(1), `max_size`: Some(1), added: 496, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:5 w:0) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::IncentiveRewardAmounts` (r:8 w:0) + // Proof: `Incentives::IncentiveRewardAmounts` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:0) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + /// The range of component `c` is `[0, 4]`. + fn on_initialize(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `1476 + c * (384 ±0)` + // Estimated: `5007 + c * (5027 ±13)` + // Minimum execution time: 13_440 nanoseconds. + Weight::from_parts(19_271_096, 5007) + // Standard Error: 190_479 + .saturating_add(Weight::from_parts(24_655_412, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads(2)) + .saturating_add(RocksDbWeight::get().reads((3_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 5027).saturating_mul(c.into())) + } + // Storage: `Tokens::Accounts` (r:2 w:2) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `EvmAccounts::EvmAddresses` (r:1 w:0) + // Proof: `EvmAccounts::EvmAddresses` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn deposit_dex_share() -> Weight { + // Proof Size summary in bytes: + // Measured: `2855` + // Estimated: `6320` + // Minimum execution time: 98_848 nanoseconds. + Weight::from_parts(100_717_000, 6320) + .saturating_add(RocksDbWeight::get().reads(6)) + .saturating_add(RocksDbWeight::get().writes(5)) + } + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Tokens::Accounts` (r:2 w:2) + // Proof: `Tokens::Accounts` (`max_values`: None, `max_size`: Some(147), added: 2622, mode: `MaxEncodedLen`) + // Storage: `System::Account` (r:1 w:0) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn withdraw_dex_share() -> Weight { + // Proof Size summary in bytes: + // Measured: `2945` + // Estimated: `6410` + // Minimum execution time: 97_599 nanoseconds. + Weight::from_parts(99_107_000, 6410) + .saturating_add(RocksDbWeight::get().reads(5)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + // Storage: `Rewards::SharesAndWithdrawnRewards` (r:1 w:1) + // Proof: `Rewards::SharesAndWithdrawnRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Rewards::PoolInfos` (r:1 w:1) + // Proof: `Rewards::PoolInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::PendingMultiRewards` (r:1 w:1) + // Proof: `Incentives::PendingMultiRewards` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::ClaimRewardDeductionRates` (r:1 w:0) + // Proof: `Incentives::ClaimRewardDeductionRates` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `Incentives::ClaimRewardDeductionCurrency` (r:1 w:0) + // Proof: `Incentives::ClaimRewardDeductionCurrency` (`max_values`: None, `max_size`: None, mode: `Measured`) + // Storage: `System::Account` (r:1 w:1) + // Proof: `System::Account` (`max_values`: None, `max_size`: Some(128), added: 2603, mode: `MaxEncodedLen`) + // Storage: `EvmAccounts::EvmAddresses` (r:1 w:0) + // Proof: `EvmAccounts::EvmAddresses` (`max_values`: None, `max_size`: Some(60), added: 2535, mode: `MaxEncodedLen`) + fn claim_rewards() -> Weight { + // Proof Size summary in bytes: + // Measured: `2633` + // Estimated: `6098` + // Minimum execution time: 143_679 nanoseconds. + Weight::from_parts(146_283_000, 6098) + .saturating_add(RocksDbWeight::get().reads(7)) + .saturating_add(RocksDbWeight::get().writes(4)) + } + // Storage: `Incentives::IncentiveRewardAmounts` (r:4 w:4) + // Proof: `Incentives::IncentiveRewardAmounts` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 4]`. + fn update_incentive_rewards(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `760 + c * (94 ±0)` + // Estimated: `2033 + c * (2475 ±0)` + // Minimum execution time: 6_569 nanoseconds. + Weight::from_parts(10_367_012, 2033) + // Standard Error: 121_237 + .saturating_add(Weight::from_parts(11_986_144, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2475).saturating_mul(c.into())) + } + // Storage: `Incentives::ClaimRewardDeductionRates` (r:4 w:4) + // Proof: `Incentives::ClaimRewardDeductionRates` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// The range of component `c` is `[0, 4]`. + fn update_claim_reward_deduction_rates(c: u32, ) -> Weight { + // Proof Size summary in bytes: + // Measured: `676 + c * (10 ±0)` + // Estimated: `1698 + c * (2475 ±0)` + // Minimum execution time: 6_582 nanoseconds. + Weight::from_parts(7_678_403, 1698) + // Standard Error: 25_846 + .saturating_add(Weight::from_parts(3_067_233, 0).saturating_mul(c.into())) + .saturating_add(RocksDbWeight::get().reads((1_u64).saturating_mul(c.into()))) + .saturating_add(RocksDbWeight::get().writes((1_u64).saturating_mul(c.into()))) + .saturating_add(Weight::from_parts(0, 2475).saturating_mul(c.into())) + } + // Storage: `Incentives::ClaimRewardDeductionCurrency` (r:1 w:1) + // Proof: `Incentives::ClaimRewardDeductionCurrency` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn update_claim_reward_deduction_currency() -> Weight { + // Proof Size summary in bytes: + // Measured: `1043` + // Estimated: `4508` + // Minimum execution time: 24_712 nanoseconds. + Weight::from_parts(25_404_000, 4508) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } +} diff --git a/blockchain/modules/prices/src/lib.rs b/blockchain/modules/prices/src/lib.rs index b9bce348..4201d5ae 100644 --- a/blockchain/modules/prices/src/lib.rs +++ b/blockchain/modules/prices/src/lib.rs @@ -92,8 +92,8 @@ pub mod module { /// staking currency. type LiquidStakingExchangeRateProvider: ExchangeRateProvider; - /// SwapDex provide liquidity info. - type SwapDex: SwapManager; + /// SwapManager provide liquidity info. + type SwapManager: SwapManager; /// Currency provide the total insurance of LPToken. type Currency: MultiCurrency; @@ -206,7 +206,7 @@ impl Pallet { // directly return the fair price return { if let (Some(price_0), Some(price_1)) = (Self::access_price(token_0), Self::access_price(token_1)) { - let (pool_0, pool_1) = T::SwapDex::get_liquidity_pool(token_0, token_1); + let (pool_0, pool_1) = T::SwapManager::get_liquidity_pool(token_0, token_1); let total_shares = T::Currency::total_issuance(currency_id); lp_token_fair_price(total_shares, pool_0, pool_1, price_0, price_1) } else { diff --git a/blockchain/modules/prices/src/mock.rs b/blockchain/modules/prices/src/mock.rs index a5e18777..824a5d7a 100644 --- a/blockchain/modules/prices/src/mock.rs +++ b/blockchain/modules/prices/src/mock.rs @@ -127,8 +127,8 @@ impl ExchangeRateProvider for MockLiquidStakingExchangeProvider { } } -pub struct MockSwapDex; -impl SwapManager for MockSwapDex { +pub struct MockSwapManager; +impl SwapManager for MockSwapManager { fn get_liquidity_pool(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance) { match (currency_id_a, currency_id_b) { (USSD, SEE) => (10000, 200), @@ -235,7 +235,7 @@ impl Config for Runtime { type GetLiquidSEECurrencyId = GetLiquidSEECurrencyId; type LockOrigin = EnsureSignedBy; type LiquidStakingExchangeRateProvider = MockLiquidStakingExchangeProvider; - type SwapDex = MockSwapDex; + type SwapManager = MockSwapManager; type Currency = Tokens; type Erc20InfoMapping = MockErc20InfoMapping; type BlockNumber = MockBlockNumberProvider; diff --git a/blockchain/modules/prices/src/tests.rs b/blockchain/modules/prices/src/tests.rs index 8d34cc24..95d9410f 100644 --- a/blockchain/modules/prices/src/tests.rs +++ b/blockchain/modules/prices/src/tests.rs @@ -144,7 +144,7 @@ fn access_price_of_liquid_currency() { assert_eq!( PricesModule::access_price(LSEE), Some(Price::saturating_from_integer(5000000000u128)) - ); // dot_price * 1/2 + ); // see_price * 1/2 mock_oracle_update(); assert_eq!( @@ -154,7 +154,7 @@ fn access_price_of_liquid_currency() { assert_eq!( PricesModule::access_price(LSEE), Some(Price::saturating_from_integer(600000000u128)) - ); // dot_price * 3/5 + ); // see_price * 3/5 }); } diff --git a/blockchain/modules/support/src/incentives.rs b/blockchain/modules/support/src/incentives.rs index 06bf8da5..4174e08e 100644 --- a/blockchain/modules/support/src/incentives.rs +++ b/blockchain/modules/support/src/incentives.rs @@ -1,67 +1,82 @@ -// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم - -// This file is part of Setheum. - -// Copyright (C) 2019-Present Setheum Labs. -// 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 . - -use crate::Rate; -use parity_scale_codec::{Decode, Encode}; -use primitives::CurrencyId; -use scale_info::TypeInfo; -use sp_runtime::{DispatchResult, RuntimeDebug}; -use sp_std::prelude::*; - -/// PoolId for various rewards pools -#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] -pub enum PoolId { - /// Rewards and shares pool for Swap market makers who stake LP token(LPCurrencyId) - SwapDex(CurrencyId), - - /// Rewards and shares pool for Orderbook market makers - OrderBookDex(CurrencyId), -} - -pub trait IncentivesManager { - /// Gets reward amount for the given reward currency added per period - fn get_incentive_reward_amount(pool_id: PoolId, currency_id: CurrencyId) -> Balance; - /// Stake LP token to add shares to pool - fn deposit_swapdex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; - /// Unstake LP token to remove shares from pool - fn withdraw_swapdex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; - /// Claim all available rewards for specific `PoolId` - fn claim_rewards(who: AccountId, pool_id: PoolId) -> DispatchResult; - /// Gets deduction reate for claiming reward early - fn get_claim_reward_deduction_rate(pool_id: PoolId) -> Rate; - /// Gets the pending rewards for a pool, for an account - fn get_pending_rewards(pool_id: PoolId, who: AccountId, reward_currency: Vec) -> Vec; -} - -pub trait SwapDexIncentives { - fn do_deposit_swapdex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; - fn do_withdraw_swapdex_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; -} - -#[cfg(feature = "std")] -impl SwapDexIncentives for () { - fn do_deposit_swapdex_share(_: &AccountId, _: CurrencyId, _: Balance) -> DispatchResult { - Ok(()) - } - - fn do_withdraw_swapdex_share(_: &AccountId, _: CurrencyId, _: Balance) -> DispatchResult { - Ok(()) - } -} +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +use crate::Rate; +use parity_scale_codec::{Decode, Encode}; +use primitives::CurrencyId; +use scale_info::TypeInfo; +use sp_runtime::{DispatchResult, RuntimeDebug}; +use sp_std::prelude::*; + +/// PoolId for various rewards pools +// Pool types: +// 1. EcdpSetrLiquidityRewards: record the shares and rewards for Setter (SETR)) ECDP users who are staking LP tokens. +// 2. EcdpUssdLiquidityRewards: record the shares and rewards for Slick USD (USSD) ECDP users who are staking LP tokens. +// 3. EdfisLiquidityRewards: record the shares and rewards for Edfis makers who are staking LP token. +// 4. EdfisXLiquidityRewards: record the shares and rewards for Edfis X (Cross-chain) makers who are staking LP token. +// 5. MoyaEarnRewards: record the shares and rewards for users of Moya Earn (Moya Liquid Staking Protocol). +#[derive(Encode, Decode, Clone, Copy, PartialEq, Eq, RuntimeDebug, TypeInfo)] +pub enum PoolId { + /// Rewards and shares pool for Setter (SETR)) ECDP users who are staking LP token(LPCurrencyId) + EcdpSetrLiquidityRewards(CurrencyId), + + /// Rewards and shares pool for Slick USD (USSD) ECDP users who are staking LP token(LPCurrencyId) + EcdpUssdLiquidityRewards(CurrencyId), + + /// Rewards and shares pool for Edfis market makers who stake LP token(LPCurrencyId) + EdfisLiquidityRewards(CurrencyId), + + /// Rewards and shares pool for Edfis X (Cross-chain) market makers who stake LP token(LPCurrencyId) + EdfisXLiquidityRewards(CurrencyId), + + /// Rewards and shares pool for Moya Earn + MoyaEarnRewards(CurrencyId), +} + +pub trait IncentivesManager { + /// Gets reward amount for the given reward currency added per period + fn get_incentive_reward_amount(pool_id: PoolId, currency_id: CurrencyId) -> Balance; + /// Stake LP token to add shares to pool + fn deposit_edfis_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; + /// Unstake LP token to remove shares from pool + fn withdraw_edfis_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; + /// Claim all available rewards for specific `PoolId` + fn claim_rewards(who: AccountId, pool_id: PoolId) -> DispatchResult; + /// Gets deduction reate for claiming reward early + fn get_claim_reward_deduction_rate(pool_id: PoolId) -> Rate; + /// Gets the pending rewards for a pool, for an account + fn get_pending_rewards(pool_id: PoolId, who: AccountId, reward_currency: Vec) -> Vec; +} + +pub trait Incentives { + fn do_deposit_edfis_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; + fn do_withdraw_edfis_share(who: &AccountId, lp_currency_id: CurrencyId, amount: Balance) -> DispatchResult; +} + +#[cfg(feature = "std")] +impl Incentives for () { + fn do_deposit_edfis_share(_: &AccountId, _: CurrencyId, _: Balance) -> DispatchResult { + Ok(()) + } + + fn do_withdraw_edfis_share(_: &AccountId, _: CurrencyId, _: Balance) -> DispatchResult { + Ok(()) + } +} diff --git a/blockchain/modules/support/src/lib.rs b/blockchain/modules/support/src/lib.rs index 6b4ef3eb..84e575ea 100644 --- a/blockchain/modules/support/src/lib.rs +++ b/blockchain/modules/support/src/lib.rs @@ -32,23 +32,23 @@ use sp_std::{prelude::*, result::Result}; use xcm::prelude::*; pub mod bounded; +pub mod ecdp; pub mod edfis_launchpad; +pub mod edfis_mining; pub mod edfis_swap; pub mod edfis_swap_legacy; pub mod evm; pub mod liquid_staking; -pub mod ecdp; -pub mod incentives; pub mod mocks; pub use crate::bounded::*; +pub use crate::ecdp::*; pub use crate::edfis_launchpad::*; +pub use crate::edfis_mining::*; pub use crate::edfis_swap::*; pub use crate::edfis_swap_legacy::*; pub use crate::evm::*; pub use crate::liquid_staking::*; -pub use crate::ecdp::*; -pub use crate::incentives::*; pub type Price = FixedU128; pub type ExchangeRate = FixedU128; diff --git a/blockchain/modules/transaction-payment/src/mock.rs b/blockchain/modules/transaction-payment/src/mock.rs index e390bb9d..823b6dd1 100644 --- a/blockchain/modules/transaction-payment/src/mock.rs +++ b/blockchain/modules/transaction-payment/src/mock.rs @@ -177,7 +177,7 @@ impl edfis_swap_legacy_module::Config for Runtime { type TradingPathLimit = TradingPathLimit; type PalletId = EdfisSwapPalletId; type Erc20InfoMapping = (); - type SwapDexIncentives = (); + type Incentives = (); type WeightInfo = (); type ListingOrigin = EnsureSignedBy; type ExtendedProvisioningBlocks = ConstU64<0>; From f14d7814daeaa7215d5c56034948492e19183b29 Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Sun, 10 Mar 2024 00:09:58 +0800 Subject: [PATCH 3/9] Init Setheum Bridge --- blockchain/modules/setheum-bridge/Cargo.toml | 47 ++++++++++++++++ blockchain/modules/setheum-bridge/README.md | 6 +++ blockchain/modules/setheum-bridge/TODO.md | 56 ++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 blockchain/modules/setheum-bridge/Cargo.toml create mode 100644 blockchain/modules/setheum-bridge/README.md create mode 100644 blockchain/modules/setheum-bridge/TODO.md diff --git a/blockchain/modules/setheum-bridge/Cargo.toml b/blockchain/modules/setheum-bridge/Cargo.toml new file mode 100644 index 00000000..a2b1191b --- /dev/null +++ b/blockchain/modules/setheum-bridge/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "module-setheum-bridge" +description = "Provides a cross-chain bridge network on the Setheum Network." +version = "0.9.81-dev" +authors = ["Setheum Labs"] +edition = "2021" + +[dependencies] +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +sp-runtime = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } +support = { package = "module-support", path = "../support", default-features = false } +orml-traits = { path = "../submodules/orml/traits", default-features = false } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true } +orml-tokens = { workspace = true } + +[features] +default = ["std"] +std = [ + "parity-scale-codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "primitives/std", + "support/std", + "orml-traits/std", +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/blockchain/modules/setheum-bridge/README.md b/blockchain/modules/setheum-bridge/README.md new file mode 100644 index 00000000..29b3c8f5 --- /dev/null +++ b/blockchain/modules/setheum-bridge/README.md @@ -0,0 +1,6 @@ +# Setheum Bridge Module +Provides a cross-chain bridge network on the Setheum Network. + +## Overview + +This module is used to build a cross-chain bridge network on the Setheum Network.. Built with `Sygma Protocol`. diff --git a/blockchain/modules/setheum-bridge/TODO.md b/blockchain/modules/setheum-bridge/TODO.md new file mode 100644 index 00000000..c8c94c13 --- /dev/null +++ b/blockchain/modules/setheum-bridge/TODO.md @@ -0,0 +1,56 @@ +# To-Do List + +This list contains all TODOs in the Repo + + + +- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list) + - [1. Introduction](#1-guidelines) + - [2. Contribution](#2-contribution) + - [3. Lists](#3-lists) + - [4. Tasks](#4-tasks) + + + +## 1. Guidelines + +Note: Before you write a ToDo in this repo, please read the below guidelines carefully. + +Whenever you write a ToDo, you need to follow this standard syntax + +```rust +//TODO:[file_name:task_number] - task_details +``` + +for example: + +```rust +//TODO:[TODO.md:0] - Add Todo Guidelines +``` + +Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. + +Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. + +Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. + +Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: + +```rust +//TODO:[TODO.md-C:0] - Add Todo Guidelines +``` + +## 2. Contribution + +You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. + +## 3. Lists + +Each package/module/directory has its own `TODO.md`. + +## 4. Tasks + +These tasks are just for this file specifically. + +- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. +- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. From 9144e2feafc5082dea091d24ead0993ca1fe6e0e Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Sun, 10 Mar 2024 00:10:21 +0800 Subject: [PATCH 4/9] Init X Wallet --- blockchain/modules/x-wallet/Cargo.toml | 47 +++++++++++++++++++++ blockchain/modules/x-wallet/README.md | 6 +++ blockchain/modules/x-wallet/TODO.md | 56 ++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 blockchain/modules/x-wallet/Cargo.toml create mode 100644 blockchain/modules/x-wallet/README.md create mode 100644 blockchain/modules/x-wallet/TODO.md diff --git a/blockchain/modules/x-wallet/Cargo.toml b/blockchain/modules/x-wallet/Cargo.toml new file mode 100644 index 00000000..8ec567dc --- /dev/null +++ b/blockchain/modules/x-wallet/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "module-x-wallet" +description = "Provides a Cross-chain Multichain Wallet on the Setheum Network." +version = "0.9.81-dev" +authors = ["Setheum Labs"] +edition = "2021" + +[dependencies] +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +sp-runtime = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } +support = { package = "module-support", path = "../support", default-features = false } +orml-traits = { path = "../submodules/orml/traits", default-features = false } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true } +orml-tokens = { workspace = true } + +[features] +default = ["std"] +std = [ + "parity-scale-codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "primitives/std", + "support/std", + "orml-traits/std", +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/blockchain/modules/x-wallet/README.md b/blockchain/modules/x-wallet/README.md new file mode 100644 index 00000000..2233159c --- /dev/null +++ b/blockchain/modules/x-wallet/README.md @@ -0,0 +1,6 @@ +# X Wallet Module +Provides a Cross-chain Multichain Wallet on the Setheum Network. + +## Overview + +This module is used to abstract cross-chain multichain accounts by aggregating them on the Setheum network. Built on `Setheum Bridge`. diff --git a/blockchain/modules/x-wallet/TODO.md b/blockchain/modules/x-wallet/TODO.md new file mode 100644 index 00000000..c8c94c13 --- /dev/null +++ b/blockchain/modules/x-wallet/TODO.md @@ -0,0 +1,56 @@ +# To-Do List + +This list contains all TODOs in the Repo + + + +- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list) + - [1. Introduction](#1-guidelines) + - [2. Contribution](#2-contribution) + - [3. Lists](#3-lists) + - [4. Tasks](#4-tasks) + + + +## 1. Guidelines + +Note: Before you write a ToDo in this repo, please read the below guidelines carefully. + +Whenever you write a ToDo, you need to follow this standard syntax + +```rust +//TODO:[file_name:task_number] - task_details +``` + +for example: + +```rust +//TODO:[TODO.md:0] - Add Todo Guidelines +``` + +Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. + +Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. + +Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. + +Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: + +```rust +//TODO:[TODO.md-C:0] - Add Todo Guidelines +``` + +## 2. Contribution + +You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. + +## 3. Lists + +Each package/module/directory has its own `TODO.md`. + +## 4. Tasks + +These tasks are just for this file specifically. + +- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. +- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. From 64b3c07d74d6313443da7c695ac859e006dd0422 Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Sun, 10 Mar 2024 00:10:41 +0800 Subject: [PATCH 5/9] Init XNFT --- blockchain/modules/x-nft/Cargo.toml | 47 ++++++++++++++++++++++++ blockchain/modules/x-nft/README.md | 6 ++++ blockchain/modules/x-nft/TODO.md | 56 +++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+) create mode 100644 blockchain/modules/x-nft/Cargo.toml create mode 100644 blockchain/modules/x-nft/README.md create mode 100644 blockchain/modules/x-nft/TODO.md diff --git a/blockchain/modules/x-nft/Cargo.toml b/blockchain/modules/x-nft/Cargo.toml new file mode 100644 index 00000000..0b07feac --- /dev/null +++ b/blockchain/modules/x-nft/Cargo.toml @@ -0,0 +1,47 @@ +[package] +name = "module-x-nft" +description = "Provides Cross-chain Multichain NFTs on the Setheum Network." +version = "0.9.81-dev" +authors = ["Setheum Labs"] +edition = "2021" + +[dependencies] +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +sp-runtime = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } +support = { package = "module-support", path = "../support", default-features = false } +orml-traits = { path = "../submodules/orml/traits", default-features = false } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true } +orml-tokens = { workspace = true } + +[features] +default = ["std"] +std = [ + "parity-scale-codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "primitives/std", + "support/std", + "orml-traits/std", +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/blockchain/modules/x-nft/README.md b/blockchain/modules/x-nft/README.md new file mode 100644 index 00000000..cd10b636 --- /dev/null +++ b/blockchain/modules/x-nft/README.md @@ -0,0 +1,6 @@ +# Slick Bridge Module +Provides Cross-chain Multichain NFTs on the Setheum Network. + +## Overview + +This module is used to provide cross-chain multichain NFTs. Built on `Setheum Bridge`. \ No newline at end of file diff --git a/blockchain/modules/x-nft/TODO.md b/blockchain/modules/x-nft/TODO.md new file mode 100644 index 00000000..c8c94c13 --- /dev/null +++ b/blockchain/modules/x-nft/TODO.md @@ -0,0 +1,56 @@ +# To-Do List + +This list contains all TODOs in the Repo + + + +- [ToDo List - The Monofile for Setheum Repo ToDos](#to-do-list) + - [1. Introduction](#1-guidelines) + - [2. Contribution](#2-contribution) + - [3. Lists](#3-lists) + - [4. Tasks](#4-tasks) + + + +## 1. Guidelines + +Note: Before you write a ToDo in this repo, please read the below guidelines carefully. + +Whenever you write a ToDo, you need to follow this standard syntax + +```rust +//TODO:[file_name:task_number] - task_details +``` + +for example: + +```rust +//TODO:[TODO.md:0] - Add Todo Guidelines +``` + +Note > the `//TODO:[filename:task_number] - ` is what we call the `task_prefix`. + +Whenever adding/writing a Task/ToDo, you need to describe the task on this list. Whenever you write a TODO in any file, add a reference to it here. Please make sure the task reference here is titled correctly and as detailed as possible\. + +Whenever you `complete` a task/TODO from any file, please tick/complete its reference here and make sure you do it in the same `commit` that completes the task. + +Whenever a task is cancelled (discontinued or not needed for w/e reason), please note in the details why it is cancelled, make sure you do it in the same `commit` that removes/cancels the TODO, and add this `-C` as a suffix to its `file_name` in the list here, for example: + +```rust +//TODO:[TODO.md-C:0] - Add Todo Guidelines +``` + +## 2. Contribution + +You can contribute to this list by completing tasks or by adding tasks(TODOs) that are currently in the repo but not on the list. You can also contribute by updating old tasks to the new Standard. + +## 3. Lists + +Each package/module/directory has its own `TODO.md`. + +## 4. Tasks + +These tasks are just for this file specifically. + +- [x] [[TODO.md:0] - Add TODO.md File](TODO.md): Add a TODO.md file to organise TODOs in the repo. +- [x] [[TODO.md:1] - Add a `task_title`](/TODO.md/#tasks): Adda `task_title`. From 0663fda7ab8eb8d0c7c13d6bde5e476b6e7fb35d Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Thu, 14 Mar 2024 00:56:55 +0800 Subject: [PATCH 6/9] Update License --- LICENSE.md => LICENSE | 1352 ++++++++++++++++++++--------------------- 1 file changed, 676 insertions(+), 676 deletions(-) rename LICENSE.md => LICENSE (98%) diff --git a/LICENSE.md b/LICENSE similarity index 98% rename from LICENSE.md rename to LICENSE index f9c71f04..634cb324 100644 --- a/LICENSE.md +++ b/LICENSE @@ -1,676 +1,676 @@ -بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم - - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - 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 . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. +بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. From 81b5b94efcbfdd717721502c6abfcf11d65eb46c Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Thu, 14 Mar 2024 00:57:32 +0800 Subject: [PATCH 7/9] Add Aleph Primitives --- blockchain/primitives/Cargo.toml | 34 ++- blockchain/primitives/src/aleph.rs | 389 ++++++++++++++++++++++++++++ blockchain/primitives/src/lib.rs | 14 +- blockchain/runtime/src/constants.rs | 189 ++++++-------- 4 files changed, 506 insertions(+), 120 deletions(-) create mode 100644 blockchain/primitives/src/aleph.rs diff --git a/blockchain/primitives/Cargo.toml b/blockchain/primitives/Cargo.toml index 3ef2c526..5f1755f4 100644 --- a/blockchain/primitives/Cargo.toml +++ b/blockchain/primitives/Cargo.toml @@ -5,21 +5,24 @@ authors = ["Setheum Labs"] edition = "2021" [dependencies] -log = { workspace = true } -hex-literal = { workspace = true } bstringify = { workspace = true } -serde = { workspace = true, features = ["alloc", "derive"] } -parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } -num_enum = { workspace = true } -scale-info = { workspace = true } enumflags2 = { workspace = true, features = ["serde"] } +hex-literal = { workspace = true } +log = { workspace = true } +num_enum = { workspace = true } +parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } paste = { workspace = true } +scale-info = { workspace = true } +serde = { workspace = true, features = ["alloc", "derive"] } +sp-api = { workspace = true } +sp-application-crypto = { workspace = true } sp-core = { workspace = true } +sp-io = { workspace = true } sp-runtime = { workspace = true } sp-std = { workspace = true } -sp-io = { workspace = true } -sp-api = { workspace = true } +sp-staking = { workspace = true } +sp-consensus-aura = { workspace = true } frame-support = { workspace = true } @@ -35,21 +38,24 @@ serde_json = { workspace = true, features = ["std"] } [features] default = ["std"] std = [ - "serde/std", - "parity-scale-codec/std", + "enumflags2/serde", "num_enum/std", + "parity-scale-codec/std", "scale-info/std", - "enumflags2/serde", - "sp-runtime/std", + "serde/std", + + "sp-api/std", "sp-core/std", - "sp-std/std", "sp-io/std", - "sp-api/std", + "sp-runtime/std", + "sp-std/std", "frame-support/std", "orml-traits/std", + "module-evm-utility/std", ] evm-tests = [] +short_session = [] try-runtime = [] diff --git a/blockchain/primitives/src/aleph.rs b/blockchain/primitives/src/aleph.rs new file mode 100644 index 00000000..5a7165d1 --- /dev/null +++ b/blockchain/primitives/src/aleph.rs @@ -0,0 +1,389 @@ +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +#![cfg_attr(not(feature = "std"), no_std)] + +use parity_scale_codec::{Decode, Encode}; +use scale_info::TypeInfo; +use serde::{Deserialize, Serialize}; +pub use sp_consensus_aura::sr25519::AuthorityId as AuraId; +use sp_core::crypto::KeyTypeId; +pub use sp_runtime::{ + generic, + traits::ConstU32, + BoundedVec, ConsensusEngineId, OpaqueExtrinsic as UncheckedExtrinsic, Perbill, +}; +use sp_runtime::{ + traits::{IdentifyAccount, Verify}, + MultiSignature, Perquintill, +}; +pub use sp_staking::{EraIndex, SessionIndex}; +use sp_std::vec::Vec; + +use crate::{AuthorityId, BlockNumber, SessionCount}; + +pub const KEY_TYPE: KeyTypeId = KeyTypeId(*b"set"); + +// Same as GRANDPA_ENGINE_ID because as of right now substrate sends only +// grandpa justifications over the network. +// TODO: change this once https://github.com/paritytech/substrate/issues/8172 will be resolved. +pub const ALEPH_ENGINE_ID: ConsensusEngineId = *b"FRNK"; + +mod app { + use sp_application_crypto::{app_crypto, ed25519}; + app_crypto!(ed25519, crate::KEY_TYPE); +} + +sp_application_crypto::with_pair! { + pub type AuthorityPair = app::Pair; +} + +/// Authority Signature +pub type AuthoritySignature = app::Signature; + +/// Authority ID +pub type AuthorityId = app::Public; + +// Default number of heap pages that gives limit of 256MB for a runtime instance since each page is 64KB +pub const HEAP_PAGES: u64 = 4096; + +pub const MILLISECS_PER_BLOCK: u64 = 1000; +// We agreed to 5MB as the block size limit. +pub const MAX_BLOCK_SIZE: u32 = 5 * 1024 * 1024; + +// Quick sessions for testing purposes +#[cfg(feature = "short_session")] +pub const DEFAULT_SESSION_PERIOD: u32 = 30; +#[cfg(feature = "short_session")] +pub const DEFAULT_SESSIONS_PER_ERA: SessionIndex = 3; + +// Default values outside testing +#[cfg(not(feature = "short_session"))] +pub const DEFAULT_SESSION_PERIOD: u32 = 900; +#[cfg(not(feature = "short_session"))] +pub const DEFAULT_SESSIONS_PER_ERA: SessionIndex = 96; + + + +/// Address Encoding (SS58Prefix - 42 is the basic substrate standard - 258 is Setheum's registry proposal) +pub const ADDRESSES_ENCODING: u8 = 42; +pub const DEFAULT_UNIT_CREATION_DELAY: u64 = 300; + +pub const DEFAULT_COMMITTEE_SIZE: u32 = 4; + +pub const DEFAULT_BAN_MINIMAL_EXPECTED_PERFORMANCE: Perbill = Perbill::from_percent(0); +pub const DEFAULT_BAN_SESSION_COUNT_THRESHOLD: SessionCount = 3; +pub const DEFAULT_BAN_REASON_LENGTH: u32 = 300; +pub const DEFAULT_MAX_WINNERS: u32 = u32::MAX; + +pub const DEFAULT_CLEAN_SESSION_COUNTER_DELAY: SessionCount = 960; +pub const DEFAULT_BAN_PERIOD: EraIndex = 10; + +/// Version returned when no version has been set. +pub const DEFAULT_FINALITY_VERSION: Version = 0; +/// Current version of abft. +pub const CURRENT_FINALITY_VERSION: u16 = 1; +pub const LENIENT_THRESHOLD: Perquintill = Perquintill::from_percent(90); + +pub const DEFAULT_MAX_NON_FINALIZED_BLOCKS: u32 = 20; + +/// Hold set of validators that produce blocks and set of validators that participate in finality +/// during session. +#[derive(Decode, Encode, TypeInfo, Debug, Clone, PartialEq, Eq)] +pub struct SessionCommittee { + pub finality_committee: Vec, + pub block_producers: Vec, +} + +/// Openness of the process of the elections +#[derive(Decode, Encode, TypeInfo, Debug, Clone, PartialEq, Eq)] +pub enum ElectionOpenness { + Permissioned, + Permissionless, +} + +/// Represent desirable size of a committee in a session +#[derive(Decode, Encode, TypeInfo, Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +pub struct CommitteeSeats { + /// Size of reserved validators in a session + pub reserved_seats: u32, + /// Size of non reserved validators in a session + pub non_reserved_seats: u32, + /// Size of non reserved validators participating in the finality in a session. + /// A subset of the non reserved validators. + pub non_reserved_finality_seats: u32, +} + +impl CommitteeSeats { + pub fn size(&self) -> u32 { + self.reserved_seats.saturating_add(self.non_reserved_seats) + } +} + +impl Default for CommitteeSeats { + fn default() -> Self { + CommitteeSeats { + reserved_seats: DEFAULT_COMMITTEE_SIZE, + non_reserved_seats: 0, + non_reserved_finality_seats: 0, + } + } +} + +pub trait FinalityCommitteeManager { + /// `committee` is the set elected for finality committee for the next session + fn on_next_session_finality_committee(committee: Vec); +} + +/// Configurable parameters for ban validator mechanism +#[derive(Decode, Encode, TypeInfo, Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] +pub struct BanConfig { + /// performance ratio threshold in a session + /// calculated as ratio of number of blocks produced to expected number of blocks for a single validator + pub minimal_expected_performance: Perbill, + /// how many bad uptime sessions force validator to be removed from the committee + pub underperformed_session_count_threshold: SessionCount, + /// underperformed session counter is cleared every subsequent `clean_session_counter_delay` sessions + pub clean_session_counter_delay: SessionCount, + /// how many eras a validator is banned for + pub ban_period: EraIndex, +} + +impl Default for BanConfig { + fn default() -> Self { + BanConfig { + minimal_expected_performance: DEFAULT_BAN_MINIMAL_EXPECTED_PERFORMANCE, + underperformed_session_count_threshold: DEFAULT_BAN_SESSION_COUNT_THRESHOLD, + clean_session_counter_delay: DEFAULT_CLEAN_SESSION_COUNTER_DELAY, + ban_period: DEFAULT_BAN_PERIOD, + } + } +} + +/// Represent any possible reason a validator can be removed from the committee due to +#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, Debug)] +pub enum BanReason { + /// Validator has been removed from the committee due to insufficient uptime in a given number + /// of sessions + InsufficientUptime(u32), + + /// Any arbitrary reason + OtherReason(BoundedVec>), +} + +/// Details of why and for how long a validator is removed from the committee +#[derive(PartialEq, Eq, Clone, Encode, Decode, TypeInfo, Debug)] +pub struct BanInfo { + /// reason for banning a validator + pub reason: BanReason, + /// index of the first era when a ban starts + pub start: EraIndex, +} + +/// Represent committee, ie set of nodes that produce and finalize blocks in the session +#[derive(Eq, PartialEq, Decode, Encode, TypeInfo)] +pub struct EraValidators { + /// Validators that are chosen to be in committee every single session. + pub reserved: Vec, + /// Validators that can be banned out from the committee, under the circumstances + pub non_reserved: Vec, +} + +impl Default for EraValidators { + fn default() -> Self { + Self { + reserved: Vec::new(), + non_reserved: Vec::new(), + } + } +} + +#[derive(Encode, Decode, TypeInfo, PartialEq, Eq, Debug)] +pub enum ApiError { + DecodeKey, +} + +#[derive(Encode, Decode, TypeInfo, PartialEq, Eq, Debug)] +pub enum SessionValidatorError { + SessionNotWithinRange { + lower_limit: SessionIndex, + upper_limit: SessionIndex, + }, + Other(Vec), +} + +/// All the data needed to verify block finalization justifications. +#[derive(Clone, Debug, TypeInfo, Encode, Decode, PartialEq, Eq)] +pub struct SessionAuthorityData { + authorities: Vec, + emergency_finalizer: Option, +} + +impl SessionAuthorityData { + pub fn new(authorities: Vec, emergency_finalizer: Option) -> Self { + SessionAuthorityData { + authorities, + emergency_finalizer, + } + } + + pub fn authorities(&self) -> &Vec { + &self.authorities + } + + pub fn emergency_finalizer(&self) -> &Option { + &self.emergency_finalizer + } +} + +#[derive(Clone, Debug, Decode, Encode, PartialEq, Eq, TypeInfo)] +pub struct VersionChange { + pub version_incoming: Version, + pub session: SessionIndex, +} + +sp_api::decl_runtime_apis! { + pub trait AlephSessionApi { + fn next_session_authorities() -> Result, ApiError>; + fn authorities() -> Vec; + fn next_session_authority_data() -> Result; + fn authority_data() -> SessionAuthorityData; + fn session_period() -> u32; + fn millisecs_per_block() -> u64; + fn finality_version() -> Version; + fn next_session_finality_version() -> Version; + /// Predict finality committee and block producers for the given session. `session` must be + /// within the current era (current, in the staking context). + /// + /// If the active era `E` starts in the session `a`, and ends in session `b` then from + /// session `a` to session `b-1` this function can answer question who will be in the + /// committee in the era `E`. In the last session of the era `E` (`b`) this can be used to + /// determine all of the sessions in the era `E+1`. + fn predict_session_committee( + session: SessionIndex + ) -> Result, SessionValidatorError>; + fn next_session_aura_authorities() -> Vec<(AccountId, AuraId)>; + /// Returns owner (`AccountId`) corresponding to an AuthorityId (in some contexts referenced + /// also as `aleph_key` - consensus engine's part of session keys) in the current session + /// of AlephBFT (finalisation committee). + fn key_owner(key: AuthorityId) -> Option; + } +} + +pub trait BanHandler { + type AccountId; + /// returns whether the account can be banned + fn can_ban(who: &Self::AccountId) -> bool; +} + +pub trait ValidatorProvider { + type AccountId; + /// returns validators for the current era. + fn current_era_validators() -> EraValidators; + /// returns committee seats for the current era. + fn current_era_committee_size() -> CommitteeSeats; +} + +#[derive(Decode, Encode, TypeInfo, Clone, Serialize, Deserialize)] +pub struct SessionValidators { + pub committee: Vec, + pub non_committee: Vec, +} + +impl Default for SessionValidators { + fn default() -> Self { + Self { + committee: Vec::new(), + non_committee: Vec::new(), + } + } +} + +/// Information provider from `pallet_session`. Loose pallet coupling via traits. +pub trait SessionInfoProvider { + fn current_session() -> SessionIndex; + fn next_session_block_number(current_block: T) -> Option; +} + +pub trait BannedValidators { + type AccountId; + /// returns currently banned validators + fn banned() -> Vec; +} + +pub trait EraManager { + /// new era has been planned + fn on_new_era(era: EraIndex); +} + +pub mod staking { + use sp_runtime::Perbill; + + use super::Balance; + use crate::TOKEN; + + pub const MIN_VALIDATOR_BOND: u128 = 25_000 * TOKEN; + pub const MIN_NOMINATOR_BOND: u128 = 100 * TOKEN; + pub const MAX_NOMINATORS_REWARDED_PER_VALIDATOR: u32 = 1024; + pub const YEARLY_INFLATION: Balance = 30_000_000 * TOKEN; + pub const VALIDATOR_REWARD: Perbill = Perbill::from_percent(90); + + pub fn era_payout(miliseconds_per_era: u64) -> (Balance, Balance) { + // Milliseconds per year for the Julian year (365.25 days). + const MILLISECONDS_PER_YEAR: u64 = 1000 * 3600 * 24 * 36525 / 100; + + let portion = Perbill::from_rational(miliseconds_per_era, MILLISECONDS_PER_YEAR); + let total_payout = portion * YEARLY_INFLATION; + let validators_payout = VALIDATOR_REWARD * total_payout; + let rest = total_payout - validators_payout; + + (validators_payout, rest) + } + + /** + * Macro for making a default implementation of non-self methods from given class. + * As an input it expects list of tuples of form + * `(method_name(arg1: type1, arg2: type2, ...), class_name, return_type)` + * where + * `method_name`is a wrapee method, + * `arg1: type1, arg2: type,...`is a list of arguments and will be passed as is, can be empty + * `class_name`is a class that has non-self `method-name`,ie symbol `class_name::method_name` exists, + * `return_type` is type returned from `method_name` + * Example + * ```ignore + * wrap_methods!( + * (bond(), SubstrateStakingWeights, Weight), + * (bond_extra(), SubstrateStakingWeights, Weight) + * ); + * ``` + * + * @var mixed #[macro_export] + */ + #[macro_export] + macro_rules! wrap_methods { + ($(($wrapped_method:ident( $($arg_name:ident: $argument_type:ty), *), $wrapped_class:ty, $return_type:ty)), *) => { + $( + fn $wrapped_method($($arg_name: $argument_type), *) -> $return_type { + <$wrapped_class>::$wrapped_method($($arg_name), *) + } + )* + }; + } +} diff --git a/blockchain/primitives/src/lib.rs b/blockchain/primitives/src/lib.rs index 10bc0096..218d8649 100644 --- a/blockchain/primitives/src/lib.rs +++ b/blockchain/primitives/src/lib.rs @@ -22,6 +22,7 @@ #![allow(clippy::unnecessary_cast)] #![allow(clippy::upper_case_acronyms)] +pub mod aleph; pub mod bonding; pub mod currency; pub mod edfis_launchpad; @@ -33,7 +34,6 @@ pub mod testing; pub mod unchecked_extrinsic; pub use testing::*; -pub use edfis_launchpad::*; use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; use scale_info::TypeInfo; @@ -111,6 +111,18 @@ pub type Block = generic::Block; /// Block ID. pub type BlockId = generic::BlockId; +/// Block Count +pub type BlockCount = u32; + +/// BlockHash +pub type BlockHash =
::Hash; + +/// Session Count +pub type SessionCount = u32; + +/// Version +pub type Version = u32;\ + /// Opaque, encoded, unchecked extrinsic. pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic; diff --git a/blockchain/runtime/src/constants.rs b/blockchain/runtime/src/constants.rs index 959889e2..865210ff 100644 --- a/blockchain/runtime/src/constants.rs +++ b/blockchain/runtime/src/constants.rs @@ -1,105 +1,84 @@ -// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم - -// This file is part of Setheum. - -// Copyright (C) 2019-Present Setheum Labs. -// 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 . - -//! A set of constant values used in dev runtime. - -/// Time and blocks. -pub mod time { - use primitives::{Balance, BlockNumber, Moment}; - // use runtime_common::{dollar, millicent, SEE}; - - // 3 seconds blocktime - pub const SECS_PER_BLOCK: Moment = 3; - pub const MILLISECS_PER_BLOCK: Moment = SECS_PER_BLOCK * 1000; - - // These time units are defined in number of blocks. - pub const MINUTES: BlockNumber = 60 / (SECS_PER_BLOCK as BlockNumber); - pub const HOURS: BlockNumber = MINUTES * 60; - pub const DAYS: BlockNumber = HOURS * 24; - - pub const SLOT_DURATION: Moment = MILLISECS_PER_BLOCK; - - // 1 in 4 blocks (on average, not counting collisions) will be primary BABE blocks. - pub const PRIMARY_PROBABILITY: (u64, u64) = (1, 4); - - // Use different settings in the test - #[cfg(feature = "test")] - pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = 10 * MINUTES; - #[cfg(not(feature = "test"))] - pub const EPOCH_DURATION_IN_BLOCKS: BlockNumber = HOURS; - - pub const EPOCH_DURATION_IN_SLOTS: u64 = { - const SLOT_FILL_RATE: f64 = MILLISECS_PER_BLOCK as f64 / SLOT_DURATION as f64; - - (EPOCH_DURATION_IN_BLOCKS as f64 * SLOT_FILL_RATE) as u64 - }; - - pub fn deposit(items: u32, bytes: u32) -> Balance { - // 2_000_000_000_000_000_000 = 2 dollars; 100_000_000_000_000 = 10 millicents; - items as Balance * 2_000_000_000_000_000_000 + (bytes as Balance) * 100_000_000_000_000 - } -} - -/// Fee-related -pub mod fee { - use frame_support::weights::{ - constants::ExtrinsicBaseWeight, - WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, - }; - use primitives::Balance; - use runtime_common::{cent, SEE}; - use smallvec::smallvec; - use sp_runtime::Perbill; - - /// The block saturation level. Fees will be updates based on this value. - pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); - - fn base_tx_in_setm() -> Balance { - cent(SEE) / 10 - } - - /// Handles converting a weight scalar to a fee value, based on the scale - /// and granularity of the node's balance type. - /// - /// This should typically create a mapping between the following ranges: - /// - [0, system::MaximumBlockWeight] - /// - [Balance::min, Balance::max] - /// - /// Yet, it can be used for any other sort of change to weight-fee. Some - /// examples being: - /// - Setting it to `0` will essentially disable the weight fee. - /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. - pub struct WeightToFee; - impl WeightToFeePolynomial for WeightToFee { - type Balance = Balance; - fn polynomial() -> WeightToFeeCoefficients { - // in Setheum, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 - // CENT: - let p = base_tx_in_setm(); // 10_000_000_000_000_000; - let q = Balance::from(ExtrinsicBaseWeight::get()); // 125_000_000 - smallvec![WeightToFeeCoefficient { - degree: 1, - negative: false, - coeff_frac: Perbill::from_rational(p % q, q), // zero - coeff_integer: p / q, // 80 - }] - } - } -} +// بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم + +// This file is part of Setheum. + +// Copyright (C) 2019-Present Setheum Labs. +// 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 . + +//! A set of constant values used in dev runtime. + +/// Time and blocks. +pub mod time { + use primitives::{MILLISECS_PER_BLOCK, Balance, BlockNumber, Moment}; + // use runtime_common::{dollar, millicent, SEE}; + + // These time units are defined in number of blocks. + pub const MINUTES: BlockNumber = 60 / (MILLISECS_PER_BLOCK as BlockNumber); + pub const HOURS: BlockNumber = MINUTES * 60; + pub const DAYS: BlockNumber = HOURS * 24; + + pub fn deposit(items: u32, bytes: u32) -> Balance { + // 2_000_000_000_000_000_000 = 2 dollars; 100_000_000_000_000 = 10 millicents; + items as Balance * 2_000_000_000_000_000_000 + (bytes as Balance) * 100_000_000_000_000 + } +} + +/// Fee-related +pub mod fee { + use frame_support::weights::{ + constants::ExtrinsicBaseWeight, + WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, + }; + use primitives::Balance; + use runtime_common::{cent, SEE}; + use smallvec::smallvec; + use sp_runtime::Perbill; + + /// The block saturation level. Fees will be updates based on this value. + pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); + + fn base_tx_in_setm() -> Balance { + cent(SEE) / 10 + } + + /// Handles converting a weight scalar to a fee value, based on the scale + /// and granularity of the node's balance type. + /// + /// This should typically create a mapping between the following ranges: + /// - [0, system::MaximumBlockWeight] + /// - [Balance::min, Balance::max] + /// + /// Yet, it can be used for any other sort of change to weight-fee. Some + /// examples being: + /// - Setting it to `0` will essentially disable the weight fee. + /// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. + pub struct WeightToFee; + impl WeightToFeePolynomial for WeightToFee { + type Balance = Balance; + fn polynomial() -> WeightToFeeCoefficients { + // in Setheum, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 + // CENT: + let p = base_tx_in_setm(); // 10_000_000_000_000_000; + let q = Balance::from(ExtrinsicBaseWeight::get()); // 125_000_000 + smallvec![WeightToFeeCoefficient { + degree: 1, + negative: false, + coeff_frac: Perbill::from_rational(p % q, q), // zero + coeff_integer: p / q, // 80 + }] + } + } +} From 9beafa9d99276af306b5f60bb92b406278742d14 Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Thu, 14 Mar 2024 01:44:38 +0800 Subject: [PATCH 8/9] Update Deps --- Cargo.toml | 612 ++++++++++++++++++++++++++++------------------------- 1 file changed, 323 insertions(+), 289 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b1993804..c6127694 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,289 +1,323 @@ -cargo-features = ["resolver"] - -[workspace] -members = [ - "blockchain/node", - "blockchain/node/cli", - "blockchain/node/service", - - "blockchain/modules/*", - "blockchain/modules/currencies/runtime-api", - "blockchain/modules/evm-utility/macro", - "blockchain/primitives", - "blockchain/rpc", - - "blockchainruntime/common", - "blockchainruntime/qingdao", - "blockchainruntime/setheum", - - "orml/asset-registry", - "orml/auction", - "orml/authority", - "orml/benchmarking", - "orml/currencies", - "orml/gradually-update", - "orml/nft", - "orml/oracle", - "orml/oracle/runtime-api", - "orml/parameters", - "orml/payments", - "orml/rewards", - "orml/tokens", - "orml/tokens/runtime-api", - "orml/traits", - "orml/unknown-tokens", - "orml/utilities", - "orml/vesting", - "orml/xcm-support", - "orml/xcm", - "orml/xtokens", -] - -resolver = "2" - -[profile.release] -# Substrate runtime requires unwinding. -panic = 'unwind' - -[profile.dev] -split-debuginfo = "unpacked" - -[profile.production] -inherits = "release" -lto = true -codegen-units = 1 - -# The list of dependencies below (which can be both direct and indirect dependencies) are crates -# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of -# their debug info might be missing) or to require to be frequently recompiled. We compile these -# dependencies with `opt-level=3` even in "dev" mode in order to make "dev" mode more usable. -# The majority of these crates are cryptographic libraries. -# -# Note that this does **not** affect crates that depend on Substrate. In other words, if you add -# a dependency on Substrate, you have to copy-paste this list in your own `Cargo.toml` (assuming -# that you want the same list). This list is only relevant when running `cargo build` from within -# the Substrate workspace. -# -# If you see an error mentioning "profile package spec ... did not match any packages", it -# probably concerns this list. -# -# This list is ordered alphabetically. -[profile.dev.package] -blake2 = { opt-level = 3 } -blake2b_simd = { opt-level = 3 } -chacha20poly1305 = { opt-level = 3 } -cranelift-codegen = { opt-level = 3 } -cranelift-wasm = { opt-level = 3 } -crc32fast = { opt-level = 3 } -crossbeam-deque = { opt-level = 3 } -crypto-mac = { opt-level = 3 } -curve25519-dalek = { opt-level = 3 } -ed25519-zebra = { opt-level = 3 } -flate2 = { opt-level = 3 } -futures-channel = { opt-level = 3 } -hashbrown = { opt-level = 3 } -hash-db = { opt-level = 3 } -hmac = { opt-level = 3 } -httparse = { opt-level = 3 } -integer-sqrt = { opt-level = 3 } -keccak = { opt-level = 3 } -librocksdb-sys = { opt-level = 3 } -libsecp256k1 = { opt-level = 3 } -libz-sys = { opt-level = 3 } -mio = { opt-level = 3 } -nalgebra = { opt-level = 3 } -num-bigint = { opt-level = 3 } -parking_lot = { opt-level = 3 } -parking_lot_core = { opt-level = 3 } -percent-encoding = { opt-level = 3 } -primitive-types = { opt-level = 3 } -ring = { opt-level = 3 } -rustls = { opt-level = 3 } -sha2 = { opt-level = 3 } -sha3 = { opt-level = 3 } -smallvec = { opt-level = 3 } -snow = { opt-level = 3 } -twox-hash = { opt-level = 3 } -uint = { opt-level = 3 } -x25519-dalek = { opt-level = 3 } -yamux = { opt-level = 3 } -zeroize = { opt-level = 3 } -insta.opt-level = 3 -similar.opt-level = 3 - -[workspace.dependencies] -log = { version = "0.4.20", default-features = false } -scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } -serde = { version = "1.0.145", default-features = false } -parity-scale-codec = { version = "3.6.5", default-features = false } -serde_json = { version = "1.0.81", default-features = false } -hex = { version = "0.4", default-features = false } -hex-literal = { version = "0.4.1" } -rand_chacha = { version = "0.2", default-features = false } -env_logger = { version = "0.10.0" } -smallvec = { version = "1.4.1" } -ripemd = { version = "0.1.3", default-features = false } -rlp = { version = "0.5.2", default-features = false } -sha3 = { version = "0.10.8", default-features = false } -tiny-keccak = { version = "2.0" } -num = { version = "0.4", default-features = false } -bn = { package = "substrate-bn", version = "0.6", default-features = false } -libsecp256k1 = { version = "0.7", default-features = false } -impl-trait-for-tuples = { version = "0.2.2" } -ethereum-types = { version = "0.14.0", default-features = false } -num_enum = { version = "0.5.1", default-features = false } -quote = { version = "1.0.20" } -syn = { version = "1.0.98" } -proc-macro2 = { version = "1.0.40" } -clap = { version = "4.0.9" } -derive_more = { version = "0.99" } -bstringify = { version = "0.1.2" } -enumflags2 = { version = "0.7.7" } -paste = { version = "1.0" } -futures = { version = "0.3.28" } -jsonrpsee = { version = "0.16.2" } -static_assertions = { version = "1.1.0" } -ethabi = { version = "18.0.0", default-features = false } -async-trait = { version = "0.1.71" } -coins-bip32 = { version = "0.7.0" } -coins-bip39 = { version = "0.7.0" } -k256 = { version = "0.11.5", default-features = false } - -# Dependencies are split into 2 groups: WASM and Client. -# - "WASM" dependencies requires to be no_std compatible, which often requires -# `default-features = false`. When used in a client-side crate the "std" feature should be enabled -# there if it exists. -# - "Client" dependencies are only used in the client, and thus don't need to be no_std compatible. - -# ORML (WASM) -wasm-bencher = { git = "https://github.com/open-web3-stack/wasm-bencher", branch = "polkadot-v1.3.0", default-features = false } -orml-auction = { path = "orml/auction", default-features = false } -orml-authority = { path = "orml/authority", default-features = false } -orml-benchmarking = { path = "orml/benchmarking", default-features = false } -orml-currencies = { path = "orml/currencies", default-features = false } -orml-nft = { path = "orml/nft", default-features = false } -orml-oracle = { path = "orml/oracle", default-features = false } -orml-oracle-runtime-api = { path = "orml/oracle/runtime-api", default-features = false } -orml-parameters = { path = "orml/parameters", default-features = false } -orml-payments = { path = "orml/payments", default-features = false } -orml-rewards = { path = "orml/rewards", default-features = false } -orml-tokens = { path = "orml/tokens", default-features = false } -orml-tokens-runtime-api = { path = "orml/tokens/runtime-api", default-features = false } -orml-traits = { path = "orml/traits", default-features = false } -orml-unknown-tokens = { path = "orml/unknown-tokens", default-features = false } -orml-utilities = { path = "orml/utilities", default-features = false } -orml-vesting = { path = "orml/vesting", default-features = false } -orml-xcm = { path = "orml/xcm", default-features = false } -orml-xcm-support = { path = "orml/xcm-support", default-features = false } -orml-xtokens = { path = "orml/xtokens", default-features = false } - -# Setheum (WASM) -primitives = { package = "setheum-primitives", path = "blockchain/primitives", default-features = false } -runtime-common = { path = "blockchain/runtime/common", default-features = false } -qingdao-runtime = { path = "blockchain/runtime/qingdao", default-features = false } -setheum-runtime = { path = "blockchain/runtime/setheum", default-features = false } - -# Setheum & ORML (client) -setheum-cli = { path = "blockchain/node/cli" } -setheum-rpc = { path = "blockchain/rpc" } -setheum-service = { path = "blockchain/node/service", default-features = false } -module-evm-utility-macro = { path = "blockchain/modules/evm-utility/macro" } -orml-build-script-utils = { path = "orml/build-script-utils" } - -# Substrate (WASM) -frame-benchmarking = { version = "25.0.0", default-features = false } -frame-executive = { version = "25.0.0", default-features = false } -frame-support = { version = "25.0.0", default-features = false } -frame-system = { version = "25.0.0", default-features = false } -frame-system-rpc-runtime-api = { version = "23.0.0", default-features = false } -frame-try-runtime = { version = "0.31.0", default-features = false } -pallet-aura = { version = "24.0.0", default-features = false } -pallet-authority-discovery = { version = "25.0.0", default-features = false } -pallet-authorship = { version = "25.0.0", default-features = false } -pallet-balances = { version = "25.0.0", default-features = false } -pallet-bounties = { version = "24.0.0", default-features = false } -pallet-collective = { version = "25.0.0", default-features = false } -pallet-democracy = { version = "25.0.0", default-features = false } -pallet-elections-phragmen = { version = "26.0.0", default-features = false } -pallet-indices = { version = "25.0.0", default-features = false } -pallet-membership = { version = "25.0.0", default-features = false } -pallet-message-queue = { version = "28.0.0", default-features = false } -pallet-multisig = { version = "25.0.0", default-features = false } -pallet-preimage = { version = "25.0.0", default-features = false } -pallet-proxy = { version = "25.0.0", default-features = false } -pallet-recovery = { version = "25.0.0", default-features = false } -pallet-root-testing = { version = "1.0.0", default-features = false } -pallet-scheduler = { version = "26.0.0", default-features = false } -pallet-session = { version = "25.0.0", default-features = false } -pallet-sudo = { version = "25.0.0", default-features = false } -pallet-timestamp = { version = "24.0.0", default-features = false } -pallet-tips = { version = "24.0.0", default-features = false } -pallet-transaction-payment = { version = "25.0.0", default-features = false } -pallet-transaction-payment-rpc-runtime-api = { version = "25.0.0", default-features = false } -pallet-treasury = { version = "24.0.0", default-features = false } -pallet-utility = { version = "25.0.0", default-features = false } -pallet-xcm = { version = "4.0.0", default-features = false } -sp-api = { version = "23.0.0", default-features = false } -sp-application-crypto = { version = "27.0.0", default-features = false } -sp-arithmetic = { version = "20.0.0", default-features = false } -sp-block-builder = { version = "23.0.0", default-features = false } -sp-blockchain = { version = "25.0.0", default-features = false } -sp-consensus = { version = "0.29.0", default-features = false } -sp-consensus-aura = { version = "0.29.0", default-features = false } -sp-consensus-slots = { version = "0.29.0", default-features = false } -sp-core = { version = "25.0.0", default-features = false } -sp-debug-derive = { version = "12.0.0", default-features = false } -sp-externalities = { version = "0.23.0", default-features = false } -sp-inherents = { version = "23.0.0", default-features = false } -sp-io = { version = "27.0.0", default-features = false } -sp-keyring = { version = "28.0.0", default-features = false } -sp-keystore = { version = "0.31.0", default-features = false } -sp-offchain = { version = "23.0.0", default-features = false } -sp-runtime = { version = "28.0.0", default-features = false } -sp-runtime-interface = { version = "21.0.0", default-features = false } -sp-session = { version = "24.0.0", default-features = false } -sp-staking = { version = "23.0.0", default-features = false } -sp-state-machine = { version = "0.32.0", default-features = false } -sp-std = { version = "12.0.0", default-features = false } -sp-storage = { version = "17.0.0", default-features = false } -sp-timestamp = { version = "23.0.0", default-features = false } -sp-tracing = { version = "14.0.0", default-features = false } -sp-transaction-pool = { version = "23.0.0", default-features = false } -sp-trie = { version = "26.0.0", default-features = false } -sp-version = { version = "26.0.0", default-features = false } -sp-wasm-interface = { version = "18.0.0", default-features = false } -sp-weights = { version = "24.0.0", default-features = false } -xcm = { package = "staging-xcm", version = "4.0.0", default-features = false } -xcm-builder = { package = "staging-xcm-builder", version = "4.0.0", default-features = false } -xcm-executor = { package = "staging-xcm-executor", version = "4.0.0", default-features = false } -# Substrate (WASM) -frame-benchmarking-cli = { version = "29.0.0" } -pallet-transaction-payment-rpc = { version = "27.0.0" } -sc-basic-authorship = { version = "0.31.0" } -sc-chain-spec = { version = "24.0.0" } -sc-cli = { version = "0.33.0" } -sc-client-api = { version = "25.0.0" } -sc-consensus = { version = "0.30.0" } -sc-consensus-aura = { version = "0.31.0" } -sc-consensus-grandpa = { version = "0.16.0" } -sc-consensus-manual-seal = { version = "0.32.0" } -sc-consensus-slots = { version = "0.30.0" } -sc-executor = { version = "0.29.0" } -sc-network = { version = "0.31.0" } -sc-network-common = { version = "0.30.0" } -sc-network-sync = { version = "0.30.0" } -sc-offchain = { version = "26.0.0" } -sc-rpc = { version = "26.0.0" } -sc-rpc-api = { version = "0.30.0" } -sc-rpc-server = { version = "10.0.0" } -sc-service = { version = "0.32.0" } -sc-telemetry = { version = "12.0.0" } -sc-tracing = { version = "25.0.0" } -sc-transaction-pool = { version = "25.0.0" } -sc-transaction-pool-api = { version = "25.0.0" } -substrate-build-script-utils = { version = "9.0.0" } -substrate-frame-rpc-system = { version = "25.0.0" } -substrate-prometheus-endpoint = { version = "0.16.0" } -substrate-wasm-builder = { version = "14.0.0" } -try-runtime-cli = { version = "0.35.0" } -xcm-simulator = { version = "4.0.0" } +cargo-features = ["resolver"] + +[workspace] +members = [ + "blockchain/node", + "blockchain/node/cli", + "blockchain/node/service", + + "blockchain/modules/*", + "blockchain/modules/currencies/runtime-api", + "blockchain/modules/evm-utility/macro", + "blockchain/primitives", + "blockchain/rpc", + + "blockchainruntime/common", + "blockchainruntime/qingdao", + "blockchainruntime/setheum", + + "orml/asset-registry", + "orml/auction", + "orml/authority", + "orml/benchmarking", + "orml/currencies", + "orml/gradually-update", + "orml/nft", + "orml/oracle", + "orml/oracle/runtime-api", + "orml/parameters", + "orml/payments", + "orml/rewards", + "orml/tokens", + "orml/tokens/runtime-api", + "orml/traits", + "orml/unknown-tokens", + "orml/utilities", + "orml/vesting", + "orml/xcm-support", + "orml/xcm", + "orml/xtokens", +] + +resolver = "2" + +[profile.release] +# Substrate runtime requires unwinding. +panic = 'unwind' + +[profile.dev] +split-debuginfo = "unpacked" + +[profile.production] +inherits = "release" +lto = true +codegen-units = 1 + +[workspace.package] +authors = ["Setheum Labs", "Open Web3 Foundation"] +edition = "2021" +homepage = "https://setheum.xyz" +repository = "https://github.com/Setheum-Labs/Setheum" + +# The list of dependencies below (which can be both direct and indirect dependencies) are crates +# that are suspected to be CPU-intensive, and that are unlikely to require debugging (as some of +# their debug info might be missing) or to require to be frequently recompiled. We compile these +# dependencies with `opt-level=3` even in "dev" mode in order to make "dev" mode more usable. +# The majority of these crates are cryptographic libraries. +# +# Note that this does **not** affect crates that depend on Substrate. In other words, if you add +# a dependency on Substrate, you have to copy-paste this list in your own `Cargo.toml` (assuming +# that you want the same list). This list is only relevant when running `cargo build` from within +# the Substrate workspace. +# +# If you see an error mentioning "profile package spec ... did not match any packages", it +# probably concerns this list. +# +# This list is ordered alphabetically. +[profile.dev.package] +blake2 = { opt-level = 3 } +blake2b_simd = { opt-level = 3 } +chacha20poly1305 = { opt-level = 3 } +cranelift-codegen = { opt-level = 3 } +cranelift-wasm = { opt-level = 3 } +crc32fast = { opt-level = 3 } +crossbeam-deque = { opt-level = 3 } +crypto-mac = { opt-level = 3 } +curve25519-dalek = { opt-level = 3 } +ed25519-zebra = { opt-level = 3 } +flate2 = { opt-level = 3 } +futures-channel = { opt-level = 3 } +hashbrown = { opt-level = 3 } +hash-db = { opt-level = 3 } +hmac = { opt-level = 3 } +httparse = { opt-level = 3 } +integer-sqrt = { opt-level = 3 } +keccak = { opt-level = 3 } +librocksdb-sys = { opt-level = 3 } +libsecp256k1 = { opt-level = 3 } +libz-sys = { opt-level = 3 } +mio = { opt-level = 3 } +nalgebra = { opt-level = 3 } +num-bigint = { opt-level = 3 } +parking_lot = { opt-level = 3 } +parking_lot_core = { opt-level = 3 } +percent-encoding = { opt-level = 3 } +primitive-types = { opt-level = 3 } +ring = { opt-level = 3 } +rustls = { opt-level = 3 } +sha2 = { opt-level = 3 } +sha3 = { opt-level = 3 } +smallvec = { opt-level = 3 } +snow = { opt-level = 3 } +twox-hash = { opt-level = 3 } +uint = { opt-level = 3 } +x25519-dalek = { opt-level = 3 } +yamux = { opt-level = 3 } +zeroize = { opt-level = 3 } +insta.opt-level = 3 +similar.opt-level = 3 + +[workspace.dependencies] +aleph-bft-crypto = { version = "0.8" } +aleph-bft-mock = { version = "0.11.1" } +aleph-bft-rmc = { version = "0.11" } +aleph-bft-types = { version = "0.11" } +async-trait = { version = "0.1.71" } +bn = { package = "substrate-bn", version = "0.6", default-features = false } +bytes = { version = "1.5" } +bstringify = { version = "0.1.2" } +clap = { version = "4.0.9" } +coins-bip32 = { version = "0.7.0" } +coins-bip39 = { version = "0.7.0" } +derive_more = { version = "0.99" } +enumflags2 = { version = "0.7.7" } +env_logger = { version = "0.10.0" } +ethabi = { version = "18.0.0", default-features = false } +ethereum-types = { version = "0.14.0", default-features = false } +futures = { version = "0.3.28" } +futures-timer = { version = "3.0" } +hash-db = { version = "0.16", default-features = false } +hex = { version = "0.4", default-features = false } +hex-literal = { version = "0.4.1" } +impl-trait-for-tuples = { version = "0.2.2" } +ink = { version = "5.0.0-rc" } +ip_network = { version = "0.4" } +jsonrpsee = { version = "0.16.3" } +k256 = { version = "0.11.5", default-features = false } +libp2p = { version = "0.51" } +libsecp256k1 = { version = "0.7", default-features = false } +log = { version = "0.4.20", default-features = false } +lru = { version = "0.10" } +num = { version = "0.4", default-features = false } +num_enum = { version = "0.5.1", default-features = false } +parity-scale-codec = { version = "3.6.5", default-features = false } +parking_lot = { version = "0.12" } +paste = { version = "1.0" } +proc-macro2 = { version = "1.0.40" } +quote = { version = "1.0.20" } +rand = { version = "0.8.5", default-features = false } +rand_chacha = { version = "0.2", default-features = false } +rand_pcg = { version = "0.3.1", default-features = false } +rlp = { version = "0.5.2", default-features = false } +ripemd = { version = "0.1.3", default-features = false } +scale-info = { version = "2.10.0", default-features = false, features = ["derive"] } +serde = { version = "1.0.145", default-features = false } +serde_json = { version = "1.0.81", default-features = false } +sha3 = { version = "0.10.8", default-features = false } +smallvec = { version = "1.4.1" } +static_assertions = { version = "1.1.0" } +thiserror = { version = "1.0" } +tiny-bip39 = { version = "1.0" }syn = { version = "1.0.98" } +tiny-keccak = { version = "2.0" } +tokio = { version = "1.36" } + +# Dependencies are split into 2 groups: WASM and Client. +# - "WASM" dependencies requires to be no_std compatible, which often requires +# `default-features = false`. When used in a client-side crate the "std" feature should be enabled +# there if it exists. +# - "Client" dependencies are only used in the client, and thus don't need to be no_std compatible. + +# ORML (WASM) +orml-auction = { path = "orml/auction", default-features = false } +orml-authority = { path = "orml/authority", default-features = false } +orml-benchmarking = { path = "orml/benchmarking", default-features = false } +orml-build-script-utils = { path = "orml/build-script-utils" } +orml-currencies = { path = "orml/currencies", default-features = false } +orml-nft = { path = "orml/nft", default-features = false } +orml-oracle = { path = "orml/oracle", default-features = false } +orml-oracle-runtime-api = { path = "orml/oracle/runtime-api", default-features = false } +orml-parameters = { path = "orml/parameters", default-features = false } +orml-payments = { path = "orml/payments", default-features = false } +orml-rewards = { path = "orml/rewards", default-features = false } +orml-tokens = { path = "orml/tokens", default-features = false } +orml-tokens-runtime-api = { path = "orml/tokens/runtime-api", default-features = false } +orml-traits = { path = "orml/traits", default-features = false } +orml-unknown-tokens = { path = "orml/unknown-tokens", default-features = false } +orml-utilities = { path = "orml/utilities", default-features = false } +orml-vesting = { path = "orml/vesting", default-features = false } +orml-xcm = { path = "orml/xcm", default-features = false } +orml-xcm-support = { path = "orml/xcm-support", default-features = false } +orml-xtokens = { path = "orml/xtokens", default-features = false } + +wasm-bencher = { git = "https://github.com/open-web3-stack/wasm-bencher", branch = "polkadot-v1.3.0", default-features = false } + +# Setheum (WASM) +primitives = { package = "setheum-primitives", path = "blockchain/primitives", default-features = false } +runtime-common = { path = "blockchain/runtime/common", default-features = false } +qingdao-runtime = { path = "blockchain/runtime/qingdao", default-features = false } +setheum-runtime = { path = "blockchain/runtime/setheum", default-features = false } + +# Setheum & ORML (client) +setheum-cli = { path = "blockchain/node/cli" } +setheum-rpc = { path = "blockchain/rpc" } +setheum-service = { path = "blockchain/node/service", default-features = false } +module-evm-utility-macro = { path = "blockchain/modules/evm-utility/macro" } + +# Substrate Pallets (WASM) +frame-benchmarking = { version = "25.0.0", default-features = false } +frame-executive = { version = "25.0.0", default-features = false } +frame-support = { version = "25.0.0", default-features = false } +frame-system = { version = "25.0.0", default-features = false } +frame-system-rpc-runtime-api = { version = "23.0.0", default-features = false } +frame-try-runtime = { version = "0.31.0", default-features = false } +pallet-aura = { version = "24.0.0", default-features = false } +pallet-authority-discovery = { version = "25.0.0", default-features = false } +pallet-authorship = { version = "25.0.0", default-features = false } +pallet-balances = { version = "25.0.0", default-features = false } +pallet-bounties = { version = "24.0.0", default-features = false } +pallet-contracts = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-contracts-primitives = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-collective = { version = "25.0.0", default-features = false } +pallet-democracy = { version = "25.0.0", default-features = false } +pallet-identity = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-indices = { version = "25.0.0", default-features = false } +pallet-insecure-randomness-collective-flip = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-nomination-pools = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-nomination-pools-runtime-api = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-membership = { version = "25.0.0", default-features = false } +pallet-multisig = { version = "25.0.0", default-features = false } +pallet-preimage = { version = "25.0.0", default-features = false } +pallet-proxy = { version = "25.0.0", default-features = false } +pallet-recovery = { version = "25.0.0", default-features = false } +pallet-root-testing = { version = "1.0.0", default-features = false } +pallet-scheduler = { version = "26.0.0", default-features = false } +pallet-session = { version = "25.0.0", default-features = false } +pallet-staking = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-staking-runtime-api = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0", default-features = false } +pallet-sudo = { version = "25.0.0", default-features = false } +pallet-timestamp = { version = "24.0.0", default-features = false } +pallet-transaction-payment = { version = "25.0.0", default-features = false } +pallet-transaction-payment-rpc = { version = "27.0.0" } +pallet-transaction-payment-rpc-runtime-api = { version = "25.0.0", default-features = false } +pallet-treasury = { version = "24.0.0", default-features = false } +pallet-utility = { version = "25.0.0", default-features = false } +pallet-xcm = { version = "4.0.0", default-features = false } + +sp-api = { version = "23.0.0", default-features = false } +sp-application-crypto = { version = "27.0.0", default-features = false } +sp-arithmetic = { version = "20.0.0", default-features = false } +sp-block-builder = { version = "23.0.0", default-features = false } +sp-blockchain = { version = "25.0.0", default-features = false } +sp-consensus = { version = "0.29.0", default-features = false } +sp-consensus-aura = { version = "0.29.0", default-features = false } +sp-consensus-slots = { version = "0.29.0", default-features = false } +sp-core = { version = "25.0.0", default-features = false } +sp-debug-derive = { version = "12.0.0", default-features = false } +sp-externalities = { version = "0.23.0", default-features = false } +sp-inherents = { version = "23.0.0", default-features = false } +sp-io = { version = "27.0.0", default-features = false } +sp-keyring = { version = "28.0.0", default-features = false } +sp-keystore = { version = "0.31.0", default-features = false } +sp-offchain = { version = "23.0.0", default-features = false } +sp-runtime = { version = "28.0.0", default-features = false } +sp-runtime-interface = { version = "21.0.0", default-features = false } +sp-session = { version = "24.0.0", default-features = false } +sp-staking = { version = "23.0.0", default-features = false } +sp-state-machine = { version = "0.32.0", default-features = false } +sp-std = { version = "12.0.0", default-features = false } +sp-storage = { version = "17.0.0", default-features = false } +sp-timestamp = { version = "23.0.0", default-features = false } +sp-tracing = { version = "14.0.0", default-features = false } +sp-transaction-pool = { version = "23.0.0", default-features = false } +sp-trie = { version = "26.0.0", default-features = false } +sp-version = { version = "26.0.0", default-features = false } +sp-wasm-interface = { version = "18.0.0", default-features = false } +sp-weights = { version = "24.0.0", default-features = false } +xcm = { package = "staging-xcm", version = "4.0.0", default-features = false } +xcm-builder = { package = "staging-xcm-builder", version = "4.0.0", default-features = false } +xcm-executor = { package = "staging-xcm-executor", version = "4.0.0", default-features = false } + +frame-benchmarking-cli = { version = "29.0.0" } +sc-basic-authorship = { version = "0.31.0" } +sc-chain-spec = { version = "24.0.0" } +sc-cli = { version = "0.33.0" } +sc-client-api = { version = "25.0.0" } +sc-consensus = { version = "0.30.0" } +sc-consensus-aura = { version = "0.31.0" } +sc-consensus-slots = { version = "0.30.0" } +sc-executor = { version = "0.29.0" } +sc-keystore = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0" } +sc-network = { version = "0.31.0" } +sc-network-common = { version = "0.30.0" } +sc-network-sync = { version = "0.30.0" } +sc-offchain = { version = "26.0.0" } +sc-rpc = { version = "26.0.0" } +sc-rpc-api = { version = "0.30.0" } +sc-rpc-server = { version = "10.0.0" } +sc-service = { version = "0.32.0" } +sc-telemetry = { version = "12.0.0" } +sc-tracing = { version = "25.0.0" } +sc-transaction-pool = { version = "25.0.0" } +sc-transaction-pool-api = { version = "25.0.0" } +sc-utils = { git = "https://github.com/Cardinal-Cryptography/polkadot-sdk.git", branch = "aleph-v1.3.0" } + +substrate-build-script-utils = { version = "9.0.0" } +substrate-frame-rpc-system = { version = "25.0.0" } +substrate-prometheus-endpoint = { version = "0.16.0" } +substrate-wasm-builder = { version = "14.0.0" } + +try-runtime-cli = { version = "0.35.0" } + +xcm-simulator = { version = "4.0.0" } + +halo2_proofs = { git = "https://github.com/Cardinal-Cryptography/pse-halo2", branch = "aleph", default-features = false } From 60924214e3f2f32c233ae453a795628331323c66 Mon Sep 17 00:00:00 2001 From: "Muhammad-Jibril B.A. (Khalifa MBA)" Date: Thu, 14 Mar 2024 01:53:03 +0800 Subject: [PATCH 9/9] Update package details --- blockchain/modules/airdrop/Cargo.toml | 6 +- blockchain/modules/asset-registry/Cargo.toml | 6 +- blockchain/modules/currencies/Cargo.toml | 6 +- .../modules/currencies/runtime-api/Cargo.toml | 6 +- blockchain/modules/ecdp-auctions/Cargo.toml | 6 +- .../ecdp-emergency-shutdown/Cargo.toml | 102 +++++++++--------- .../modules/ecdp-setr-engine/Cargo.toml | 6 +- blockchain/modules/ecdp-setr-loans/Cargo.toml | 6 +- .../modules/ecdp-setr-treasury/Cargo.toml | 6 +- .../modules/ecdp-ussd-engine/Cargo.toml | 6 +- blockchain/modules/ecdp-ussd-loans/Cargo.toml | 6 +- .../modules/ecdp-ussd-treasury/Cargo.toml | 6 +- blockchain/modules/ecdp/Cargo.toml | 6 +- blockchain/modules/edfis-launchpad/Cargo.toml | 6 +- .../modules/edfis-launchpool/Cargo.toml | 6 +- blockchain/modules/edfis-oracle/Cargo.toml | 6 +- .../modules/edfis-swap-legacy/Cargo.toml | 6 +- blockchain/modules/edfis-swap/Cargo.toml | 6 +- blockchain/modules/edfis-x/Cargo.toml | 6 +- blockchain/modules/evm-bridge/Cargo.toml | 6 +- blockchain/modules/evm-utility/Cargo.toml | 6 +- .../modules/evm-utility/macro/Cargo.toml | 6 +- blockchain/modules/evm/Cargo.toml | 6 +- .../modules/evm/rpc/runtime_api/Cargo.toml | 6 +- blockchain/modules/incentives/Cargo.toml | 6 +- blockchain/modules/lockdrop/Cargo.toml | 6 +- .../modules/moya-liquid-edf-earn/Cargo.toml | 6 +- .../moya-liquid-edf-validators/Cargo.toml | 6 +- blockchain/modules/moya-liquid-edf/Cargo.toml | 6 +- .../modules/moya-liquid-see-earn/Cargo.toml | 6 +- .../moya-liquid-see-validators/Cargo.toml | 6 +- blockchain/modules/moya-liquid-see/Cargo.toml | 6 +- blockchain/modules/nft/Cargo.toml | 6 +- blockchain/modules/prices/Cargo.toml | 6 +- blockchain/modules/setheum-bridge/Cargo.toml | 6 +- blockchain/modules/support/Cargo.toml | 6 +- .../modules/transaction-pause/Cargo.toml | 6 +- .../modules/transaction-payment/Cargo.toml | 6 +- .../modules/unified-accounts/Cargo.toml | 6 +- blockchain/modules/vesting/Cargo.toml | 6 +- blockchain/modules/x-nft/Cargo.toml | 6 +- blockchain/modules/x-wallet/Cargo.toml | 6 +- blockchain/primitives/Cargo.toml | 6 +- 43 files changed, 220 insertions(+), 134 deletions(-) diff --git a/blockchain/modules/airdrop/Cargo.toml b/blockchain/modules/airdrop/Cargo.toml index 916ad5d5..d50e9571 100644 --- a/blockchain/modules/airdrop/Cargo.toml +++ b/blockchain/modules/airdrop/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-airdrop" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } diff --git a/blockchain/modules/asset-registry/Cargo.toml b/blockchain/modules/asset-registry/Cargo.toml index a1925990..e55259db 100644 --- a/blockchain/modules/asset-registry/Cargo.toml +++ b/blockchain/modules/asset-registry/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-asset-registry" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/currencies/Cargo.toml b/blockchain/modules/currencies/Cargo.toml index 0c87e384..13adec20 100644 --- a/blockchain/modules/currencies/Cargo.toml +++ b/blockchain/modules/currencies/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-currencies" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true } diff --git a/blockchain/modules/currencies/runtime-api/Cargo.toml b/blockchain/modules/currencies/runtime-api/Cargo.toml index 8896618d..d977d21d 100644 --- a/blockchain/modules/currencies/runtime-api/Cargo.toml +++ b/blockchain/modules/currencies/runtime-api/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-currencies-runtime-api" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] sp-runtime = { workspace = true } diff --git a/blockchain/modules/ecdp-auctions/Cargo.toml b/blockchain/modules/ecdp-auctions/Cargo.toml index 51435c50..6122aaa2 100644 --- a/blockchain/modules/ecdp-auctions/Cargo.toml +++ b/blockchain/modules/ecdp-auctions/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-auctions" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/ecdp-emergency-shutdown/Cargo.toml b/blockchain/modules/ecdp-emergency-shutdown/Cargo.toml index 5482f4cc..65d343f8 100644 --- a/blockchain/modules/ecdp-emergency-shutdown/Cargo.toml +++ b/blockchain/modules/ecdp-emergency-shutdown/Cargo.toml @@ -1,50 +1,52 @@ -[package] -name = "module-ecdp-emergency-shutdown" -version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" - -[dependencies] -scale-info = { workspace = true } -serde = { workspace = true, optional = true } -parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } -sp-runtime = { workspace = true } -sp-io = { workspace = true } -sp-std = { workspace = true } -frame-support = { workspace = true } -frame-system = { workspace = true } - -primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } -support = { package = "module-support", path = "../support", default-features = false } -orml-traits = { path = "../submodules/orml/traits", default-features = false } - -[dev-dependencies] -sp-core = { workspace = true, features = ["std"] } -pallet-balances = { workspace = true } -orml-tokens = { workspace = true } - -[features] -default = ["std"] -std = [ - "scale-info/std", - "serde", - "parity-scale-codec/std", - "sp-runtime/std", - "sp-std/std", - "sp-io/std", - "frame-support/std", - "frame-system/std", - "primitives/std", - "support/std", - "orml-traits/std", -] -runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", -] -try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "sp-runtime/try-runtime", -] +[package] +name = "module-ecdp-emergency-shutdown" +version = "0.9.81-dev" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true + +[dependencies] +scale-info = { workspace = true } +serde = { workspace = true, optional = true } +parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } +sp-runtime = { workspace = true } +sp-io = { workspace = true } +sp-std = { workspace = true } +frame-support = { workspace = true } +frame-system = { workspace = true } + +primitives = { package = "setheum-primitives", path = "../primitives", default-features = false } +support = { package = "module-support", path = "../support", default-features = false } +orml-traits = { path = "../submodules/orml/traits", default-features = false } + +[dev-dependencies] +sp-core = { workspace = true, features = ["std"] } +pallet-balances = { workspace = true } +orml-tokens = { workspace = true } + +[features] +default = ["std"] +std = [ + "scale-info/std", + "serde", + "parity-scale-codec/std", + "sp-runtime/std", + "sp-std/std", + "sp-io/std", + "frame-support/std", + "frame-system/std", + "primitives/std", + "support/std", + "orml-traits/std", +] +runtime-benchmarks = [ + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", +] +try-runtime = [ + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", +] diff --git a/blockchain/modules/ecdp-setr-engine/Cargo.toml b/blockchain/modules/ecdp-setr-engine/Cargo.toml index 2b200a9d..c538df44 100644 --- a/blockchain/modules/ecdp-setr-engine/Cargo.toml +++ b/blockchain/modules/ecdp-setr-engine/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-setr-engine" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/ecdp-setr-loans/Cargo.toml b/blockchain/modules/ecdp-setr-loans/Cargo.toml index 60c4db9a..595081c2 100644 --- a/blockchain/modules/ecdp-setr-loans/Cargo.toml +++ b/blockchain/modules/ecdp-setr-loans/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-setr-loans" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/ecdp-setr-treasury/Cargo.toml b/blockchain/modules/ecdp-setr-treasury/Cargo.toml index ec3046da..c76ecaf3 100644 --- a/blockchain/modules/ecdp-setr-treasury/Cargo.toml +++ b/blockchain/modules/ecdp-setr-treasury/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-setr-treasury" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/ecdp-ussd-engine/Cargo.toml b/blockchain/modules/ecdp-ussd-engine/Cargo.toml index d3a6438e..758763b1 100644 --- a/blockchain/modules/ecdp-ussd-engine/Cargo.toml +++ b/blockchain/modules/ecdp-ussd-engine/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-ussd-engine" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/ecdp-ussd-loans/Cargo.toml b/blockchain/modules/ecdp-ussd-loans/Cargo.toml index ea8cb6a2..82097992 100644 --- a/blockchain/modules/ecdp-ussd-loans/Cargo.toml +++ b/blockchain/modules/ecdp-ussd-loans/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-ussd-loans" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/ecdp-ussd-treasury/Cargo.toml b/blockchain/modules/ecdp-ussd-treasury/Cargo.toml index 329ef32b..bbb471a7 100644 --- a/blockchain/modules/ecdp-ussd-treasury/Cargo.toml +++ b/blockchain/modules/ecdp-ussd-treasury/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-ussd-treasury" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/ecdp/Cargo.toml b/blockchain/modules/ecdp/Cargo.toml index 2d4916b4..cd55ec4b 100644 --- a/blockchain/modules/ecdp/Cargo.toml +++ b/blockchain/modules/ecdp/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-ecdp-core" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true } diff --git a/blockchain/modules/edfis-launchpad/Cargo.toml b/blockchain/modules/edfis-launchpad/Cargo.toml index 001b4d09..74a159f1 100644 --- a/blockchain/modules/edfis-launchpad/Cargo.toml +++ b/blockchain/modules/edfis-launchpad/Cargo.toml @@ -2,8 +2,10 @@ name = "module-edfis-launchpad" description = "Provides a launchpad crowdsales platform on Edfis." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/modules/edfis-launchpool/Cargo.toml b/blockchain/modules/edfis-launchpool/Cargo.toml index 237946d1..1d154c15 100644 --- a/blockchain/modules/edfis-launchpool/Cargo.toml +++ b/blockchain/modules/edfis-launchpool/Cargo.toml @@ -2,8 +2,10 @@ name = "module-edfis-launchpool" description = "Provides a launchpool platform on Edfis." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/modules/edfis-oracle/Cargo.toml b/blockchain/modules/edfis-oracle/Cargo.toml index 221a8440..c65b9366 100644 --- a/blockchain/modules/edfis-oracle/Cargo.toml +++ b/blockchain/modules/edfis-oracle/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-edfis-oracle" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } diff --git a/blockchain/modules/edfis-swap-legacy/Cargo.toml b/blockchain/modules/edfis-swap-legacy/Cargo.toml index 13f8a2ea..46a1a862 100644 --- a/blockchain/modules/edfis-swap-legacy/Cargo.toml +++ b/blockchain/modules/edfis-swap-legacy/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-edfis-swap-legacy" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/edfis-swap/Cargo.toml b/blockchain/modules/edfis-swap/Cargo.toml index c0c34bcf..a34db62a 100644 --- a/blockchain/modules/edfis-swap/Cargo.toml +++ b/blockchain/modules/edfis-swap/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-edfis-swap" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/edfis-x/Cargo.toml b/blockchain/modules/edfis-x/Cargo.toml index c58a4b51..7faac12e 100644 --- a/blockchain/modules/edfis-x/Cargo.toml +++ b/blockchain/modules/edfis-x/Cargo.toml @@ -2,8 +2,10 @@ name = "module-edfis-x" description = "Provides cross-chain multichain Swaps on Edfis Exchange." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/modules/evm-bridge/Cargo.toml b/blockchain/modules/evm-bridge/Cargo.toml index 6c91db32..65f5f4c9 100644 --- a/blockchain/modules/evm-bridge/Cargo.toml +++ b/blockchain/modules/evm-bridge/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-evm-bridge" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [package.metadata.docs.rs] targets = ["x86_64-unknown-linux-gnu"] diff --git a/blockchain/modules/evm-utility/Cargo.toml b/blockchain/modules/evm-utility/Cargo.toml index 8aa7bc7b..bca62886 100644 --- a/blockchain/modules/evm-utility/Cargo.toml +++ b/blockchain/modules/evm-utility/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-evm-utility" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] sha3 = { workspace = true } diff --git a/blockchain/modules/evm-utility/macro/Cargo.toml b/blockchain/modules/evm-utility/macro/Cargo.toml index 21ceb6c0..bf9e3b93 100644 --- a/blockchain/modules/evm-utility/macro/Cargo.toml +++ b/blockchain/modules/evm-utility/macro/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-evm-utility-macro" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [lib] proc-macro = true diff --git a/blockchain/modules/evm/Cargo.toml b/blockchain/modules/evm/Cargo.toml index bf862b74..93dae63c 100644 --- a/blockchain/modules/evm/Cargo.toml +++ b/blockchain/modules/evm/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-evm" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [[bench]] name = "orml_benches" diff --git a/blockchain/modules/evm/rpc/runtime_api/Cargo.toml b/blockchain/modules/evm/rpc/runtime_api/Cargo.toml index a83fef68..dcabd9c5 100644 --- a/blockchain/modules/evm/rpc/runtime_api/Cargo.toml +++ b/blockchain/modules/evm/rpc/runtime_api/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-evm-rpc-runtime-api" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] sp-runtime = { workspace = true } diff --git a/blockchain/modules/incentives/Cargo.toml b/blockchain/modules/incentives/Cargo.toml index f73b62ce..2cf1075f 100644 --- a/blockchain/modules/incentives/Cargo.toml +++ b/blockchain/modules/incentives/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-incentives" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/lockdrop/Cargo.toml b/blockchain/modules/lockdrop/Cargo.toml index 7aba9a4d..6d7e4cf3 100644 --- a/blockchain/modules/lockdrop/Cargo.toml +++ b/blockchain/modules/lockdrop/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-lockdrop" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true, features = ["max-encoded-len"] } diff --git a/blockchain/modules/moya-liquid-edf-earn/Cargo.toml b/blockchain/modules/moya-liquid-edf-earn/Cargo.toml index 25275881..df60e0b9 100644 --- a/blockchain/modules/moya-liquid-edf-earn/Cargo.toml +++ b/blockchain/modules/moya-liquid-edf-earn/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-edf-earn" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/moya-liquid-edf-validators/Cargo.toml b/blockchain/modules/moya-liquid-edf-validators/Cargo.toml index 97dcf189..250e0bdc 100644 --- a/blockchain/modules/moya-liquid-edf-validators/Cargo.toml +++ b/blockchain/modules/moya-liquid-edf-validators/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-edf-validators" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/moya-liquid-edf/Cargo.toml b/blockchain/modules/moya-liquid-edf/Cargo.toml index 88f3743a..30611b24 100644 --- a/blockchain/modules/moya-liquid-edf/Cargo.toml +++ b/blockchain/modules/moya-liquid-edf/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-edf" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/moya-liquid-see-earn/Cargo.toml b/blockchain/modules/moya-liquid-see-earn/Cargo.toml index 3e56c976..86b8ed93 100644 --- a/blockchain/modules/moya-liquid-see-earn/Cargo.toml +++ b/blockchain/modules/moya-liquid-see-earn/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-see-earn" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/moya-liquid-see-validators/Cargo.toml b/blockchain/modules/moya-liquid-see-validators/Cargo.toml index d89fb546..d84aef5b 100644 --- a/blockchain/modules/moya-liquid-see-validators/Cargo.toml +++ b/blockchain/modules/moya-liquid-see-validators/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-see-validators" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/moya-liquid-see/Cargo.toml b/blockchain/modules/moya-liquid-see/Cargo.toml index 1b4f3254..1f12a27d 100644 --- a/blockchain/modules/moya-liquid-see/Cargo.toml +++ b/blockchain/modules/moya-liquid-see/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-moya-liquid-see" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/nft/Cargo.toml b/blockchain/modules/nft/Cargo.toml index 40e230bc..6e9f6c3a 100644 --- a/blockchain/modules/nft/Cargo.toml +++ b/blockchain/modules/nft/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-nft" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] serde = { workspace = true, features = ["alloc", "derive"] } diff --git a/blockchain/modules/prices/Cargo.toml b/blockchain/modules/prices/Cargo.toml index 89d99949..b3b5273a 100644 --- a/blockchain/modules/prices/Cargo.toml +++ b/blockchain/modules/prices/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-prices" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true } diff --git a/blockchain/modules/setheum-bridge/Cargo.toml b/blockchain/modules/setheum-bridge/Cargo.toml index a2b1191b..321812b6 100644 --- a/blockchain/modules/setheum-bridge/Cargo.toml +++ b/blockchain/modules/setheum-bridge/Cargo.toml @@ -2,8 +2,10 @@ name = "module-setheum-bridge" description = "Provides a cross-chain bridge network on the Setheum Network." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/modules/support/Cargo.toml b/blockchain/modules/support/Cargo.toml index 6fea841c..ec05c86a 100644 --- a/blockchain/modules/support/Cargo.toml +++ b/blockchain/modules/support/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-support" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] impl-trait-for-tuples = { workspace = true } diff --git a/blockchain/modules/transaction-pause/Cargo.toml b/blockchain/modules/transaction-pause/Cargo.toml index ad22f476..ba6f97b5 100644 --- a/blockchain/modules/transaction-pause/Cargo.toml +++ b/blockchain/modules/transaction-pause/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-transaction-pause" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/transaction-payment/Cargo.toml b/blockchain/modules/transaction-payment/Cargo.toml index f3a10fe6..001368cb 100644 --- a/blockchain/modules/transaction-payment/Cargo.toml +++ b/blockchain/modules/transaction-payment/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-transaction-payment" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] log = { workspace = true } diff --git a/blockchain/modules/unified-accounts/Cargo.toml b/blockchain/modules/unified-accounts/Cargo.toml index 5ccf513c..b484d41d 100644 --- a/blockchain/modules/unified-accounts/Cargo.toml +++ b/blockchain/modules/unified-accounts/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "module-unified-accounts" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { workspace = true } diff --git a/blockchain/modules/vesting/Cargo.toml b/blockchain/modules/vesting/Cargo.toml index 1272266c..a2d042b8 100644 --- a/blockchain/modules/vesting/Cargo.toml +++ b/blockchain/modules/vesting/Cargo.toml @@ -2,8 +2,10 @@ name = "module-vesting" description = "Provides scheduled balance locking mechanism, in a *graded vesting* way." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] scale-info = { workspace = true } diff --git a/blockchain/modules/x-nft/Cargo.toml b/blockchain/modules/x-nft/Cargo.toml index 0b07feac..f40b1bc6 100644 --- a/blockchain/modules/x-nft/Cargo.toml +++ b/blockchain/modules/x-nft/Cargo.toml @@ -2,8 +2,10 @@ name = "module-x-nft" description = "Provides Cross-chain Multichain NFTs on the Setheum Network." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/modules/x-wallet/Cargo.toml b/blockchain/modules/x-wallet/Cargo.toml index 8ec567dc..1f12f423 100644 --- a/blockchain/modules/x-wallet/Cargo.toml +++ b/blockchain/modules/x-wallet/Cargo.toml @@ -2,8 +2,10 @@ name = "module-x-wallet" description = "Provides a Cross-chain Multichain Wallet on the Setheum Network." version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] parity-scale-codec = { version = "3.0.0", default-features = false, features = ["max-encoded-len"] } diff --git a/blockchain/primitives/Cargo.toml b/blockchain/primitives/Cargo.toml index 5f1755f4..60c25f33 100644 --- a/blockchain/primitives/Cargo.toml +++ b/blockchain/primitives/Cargo.toml @@ -1,8 +1,10 @@ [package] name = "setheum-primitives" version = "0.9.81-dev" -authors = ["Setheum Labs"] -edition = "2021" +authors.workspace = true +edition.workspace = true +homepage.workspace = true +repository.workspace = true [dependencies] bstringify = { workspace = true }