difftreelog
Merge pull request #230 from UniqueNetwork/feature/core-202
in: master
orml-vesting pallet
3 files changed
runtime/Cargo.tomldiffbeforeafterboth--- a/runtime/Cargo.toml
+++ b/runtime/Cargo.toml
@@ -60,7 +60,7 @@
'pallet-transaction-payment/std',
'pallet-transaction-payment-rpc-runtime-api/std',
'pallet-treasury/std',
- 'pallet-vesting/std',
+ # 'pallet-vesting/std',
'pallet-evm/std',
'pallet-evm-migration/std',
'pallet-evm-contract-helpers/std',
@@ -97,6 +97,8 @@
'xcm/std',
'xcm-builder/std',
'xcm-executor/std',
+
+ "orml-vesting/std",
]
limit-testing = ['pallet-nft/limit-testing', 'nft-data-structs/limit-testing']
@@ -210,10 +212,10 @@
git = 'https://github.com/paritytech/substrate.git'
branch = 'polkadot-v0.9.12'
-[dependencies.pallet-vesting]
-default-features = false
-git = 'https://github.com/paritytech/substrate.git'
-branch = 'polkadot-v0.9.12'
+# [dependencies.pallet-vesting]
+# default-features = false
+# git = 'https://github.com/paritytech/substrate.git'
+# branch = 'polkadot-v0.9.12'
[dependencies.sp-arithmetic]
default-features = false
@@ -359,6 +361,10 @@
branch = 'release-v0.9.12'
default-features = false
+[dependencies.orml-vesting]
+git = "https://github.com/open-web3-stack/open-runtime-module-library"
+version = "0.4.1-dev"
+default-features = false
################################################################################
# local dependencies
runtime/src/lib.rsdiffbeforeafterboth--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -22,8 +22,7 @@
use sp_runtime::{
Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,
traits::{
- AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,
- AccountIdConversion,
+ AccountIdLookup, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify, AccountIdConversion,
},
transaction_validity::{TransactionSource, TransactionValidity},
ApplyExtrinsicResult, MultiSignature,
@@ -70,7 +69,7 @@
use fp_rpc::TransactionStatus;
use sp_core::crypto::Public;
use sp_runtime::{
- traits::{Dispatchable, PostDispatchInfoOf},
+ traits::{BlockNumberProvider, Dispatchable, PostDispatchInfoOf},
transaction_validity::TransactionValidityError,
};
@@ -515,17 +514,33 @@
type Call = Call;
}
+pub struct RelayChainBlockNumberProvider<T>(sp_std::marker::PhantomData<T>);
+
+impl<T: cumulus_pallet_parachain_system::Config> BlockNumberProvider
+ for RelayChainBlockNumberProvider<T>
+{
+ type BlockNumber = BlockNumber;
+
+ fn current_block_number() -> Self::BlockNumber {
+ cumulus_pallet_parachain_system::Pallet::<T>::validation_data()
+ .map(|d| d.relay_parent_number)
+ .unwrap_or_default()
+ }
+}
+
parameter_types! {
pub const MinVestedTransfer: Balance = 10 * UNIQUE;
+ pub const MaxVestingSchedules: u32 = 28;
}
-impl pallet_vesting::Config for Runtime {
+impl orml_vesting::Config for Runtime {
type Event = Event;
- type Currency = Balances;
- type BlockNumberToBalance = ConvertInto;
+ type Currency = pallet_balances::Pallet<Runtime>;
type MinVestedTransfer = MinVestedTransfer;
+ type VestedTransferOrigin = EnsureSigned<AccountId>;
type WeightInfo = ();
- const MAX_VESTING_SCHEDULES: u32 = 28;
+ type MaxVestingSchedules = MaxVestingSchedules;
+ type BlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;
}
parameter_types! {
@@ -841,7 +856,8 @@
Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,
Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,
System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,
- Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
+ Vesting: orml_vesting::{Pallet, Storage, Call, Event<T>, Config<T>} = 37,
+ // Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,
// Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,
// XCM helpers.
tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth1import {readFile} from 'fs/promises';1import {readFile} from 'fs/promises';2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';2import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';3import privateKey from '../../substrate/privateKey';3import privateKey from '../../substrate/privateKey';4import {addToWhiteListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';4import {addToAllowListExpectSuccess, confirmSponsorshipExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, setCollectionSponsorExpectSuccess, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase} from '../util/helpers';5import {collectionIdToAddress, contractHelpers, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase} from '../util/helpers';6import {evmToAddress} from '@polkadot/util-crypto';6import {evmToAddress} from '@polkadot/util-crypto';7import nonFungibleAbi from '../nonFungibleAbi.json';7import nonFungibleAbi from '../nonFungibleAbi.json';101011const PRICE = 2000n;11const PRICE = 2000n;121213describe.only('Matcher contract usage', () => {13describe('Matcher contract usage', () => {14 itWeb3('With UNQ', async ({api, web3}) => {14 itWeb3('With UNQ', async ({api, web3}) => {15 const matcherOwner = await createEthAccountWithBalance(api, web3);15 const matcherOwner = await createEthAccountWithBalance(api, web3);16 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {16 const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlace.abi`)).toString()), undefined, {29 await confirmSponsorshipExpectSuccess(collectionId);29 await confirmSponsorshipExpectSuccess(collectionId);303031 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});31 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});32 await addToWhiteListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));32 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));333334 const seller = privateKey('//Bob');34 const seller = privateKey('//Bob');35 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});35 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});36 await addToWhiteListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));36 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));373738 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);38 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);3939156 await confirmSponsorshipExpectSuccess(collectionId);156 await confirmSponsorshipExpectSuccess(collectionId);157157158 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});158 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(alice.address), true).send({from: matcherOwner});159 await addToWhiteListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));159 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(alice.address)));160160161 const seller = privateKey('//Bob');161 const seller = privateKey('//Bob');162 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});162 await helpers.methods.toggleAllowed(matcher.options.address, subToEth(seller.address), true).send({from: matcherOwner});163 await addToWhiteListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));163 await addToAllowListExpectSuccess(alice, collectionId, evmToAddress(subToEth(seller.address)));164164165 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);165 const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);166166