difftreelog
Merge branch 'develop' into feature/core-203
in: master
130 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -18,7 +18,16 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3e61f2b7f93d2c7d2b08263acaa4a363b3e276806c68af6134c44f523bf1aacd"
dependencies = [
- "gimli",
+ "gimli 0.25.0",
+]
+
+[[package]]
+name = "addr2line"
+version = "0.17.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b"
+dependencies = [
+ "gimli 0.26.1",
]
[[package]]
@@ -385,11 +394,11 @@
[[package]]
name = "backtrace"
-version = "0.3.62"
+version = "0.3.63"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "091bcdf2da9950f96aa522681ce805e6857f6ca8df73833d35736ab2dc78e152"
+checksum = "321629d8ba6513061f26707241fa9bc89524ff1cd7a915a97ef0c62c666ce1b6"
dependencies = [
- "addr2line",
+ "addr2line 0.17.0",
"cc",
"cfg-if 1.0.0",
"libc",
@@ -1065,9 +1074,9 @@
[[package]]
name = "clang-sys"
-version = "1.2.2"
+version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10612c0ec0e0a1ff0e97980647cb058a6e7aedb913d01d009c406b8b7d0b26ee"
+checksum = "fa66045b9cb23c2e9c1520732030608b02ee07e5cfaa5a521ec15ded7fa24c90"
dependencies = [
"glob",
"libc",
@@ -1181,7 +1190,7 @@
"cranelift-codegen-meta",
"cranelift-codegen-shared",
"cranelift-entity",
- "gimli",
+ "gimli 0.25.0",
"log",
"regalloc",
"smallvec",
@@ -2998,6 +3007,12 @@
]
[[package]]
+name = "gimli"
+version = "0.26.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4"
+
+[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -5055,6 +5070,8 @@
"sp-transaction-pool",
"substrate-frame-rpc-system",
"tokio 0.2.25",
+ "uc-rpc",
+ "up-rpc",
]
[[package]]
@@ -5082,16 +5099,20 @@
"nft-data-structs",
"pallet-aura",
"pallet-balances",
+ "pallet-common",
"pallet-ethereum",
"pallet-evm",
"pallet-evm-coder-substrate",
"pallet-evm-contract-helpers",
"pallet-evm-migration",
"pallet-evm-transaction-payment",
+ "pallet-fungible",
"pallet-inflation",
"pallet-nft",
"pallet-nft-transaction-payment",
+ "pallet-nonfungible",
"pallet-randomness-collective-flip",
+ "pallet-refungible",
"pallet-sudo",
"pallet-template-charge-transaction",
"pallet-timestamp",
@@ -5121,6 +5142,7 @@
"sp-transaction-pool",
"sp-version",
"substrate-wasm-builder",
+ "up-rpc",
"xcm",
"xcm-builder",
"xcm-executor",
@@ -5538,6 +5560,24 @@
]
[[package]]
+name = "pallet-common"
+version = "0.1.0"
+dependencies = [
+ "evm-coder",
+ "frame-support",
+ "frame-system",
+ "nft-data-structs",
+ "pallet-evm",
+ "pallet-evm-coder-substrate",
+ "parity-scale-codec",
+ "scale-info",
+ "serde",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "pallet-contract-helpers"
version = "0.1.0"
dependencies = [
@@ -5788,6 +5828,25 @@
]
[[package]]
+name = "pallet-fungible"
+version = "0.1.0"
+dependencies = [
+ "ethereum 0.9.0 (git+https://github.com/purestake/ethereum?branch=joshy-scale-info)",
+ "evm-coder",
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "nft-data-structs",
+ "pallet-common",
+ "pallet-evm-coder-substrate",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "pallet-gilt"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.12#d76f39995315ec36980908e4b99709bd14927044"
@@ -5993,10 +6052,14 @@
"hex-literal",
"nft-data-structs",
"pallet-balances",
+ "pallet-common",
"pallet-ethereum",
"pallet-evm",
"pallet-evm-coder-substrate",
+ "pallet-fungible",
+ "pallet-nonfungible",
"pallet-randomness-collective-flip",
+ "pallet-refungible",
"pallet-timestamp",
"pallet-transaction-payment",
"parity-scale-codec",
@@ -6045,6 +6108,25 @@
]
[[package]]
+name = "pallet-nonfungible"
+version = "0.1.0"
+dependencies = [
+ "ethereum 0.9.0 (git+https://github.com/purestake/ethereum?branch=joshy-scale-info)",
+ "evm-coder",
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "nft-data-structs",
+ "pallet-common",
+ "pallet-evm-coder-substrate",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "pallet-offences"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.12#d76f39995315ec36980908e4b99709bd14927044"
@@ -6128,6 +6210,22 @@
]
[[package]]
+name = "pallet-refungible"
+version = "0.1.0"
+dependencies = [
+ "frame-benchmarking",
+ "frame-support",
+ "frame-system",
+ "nft-data-structs",
+ "pallet-common",
+ "parity-scale-codec",
+ "scale-info",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "pallet-scheduler"
version = "4.0.0-dev"
source = "git+https://github.com/paritytech/substrate.git?branch=polkadot-v0.9.12#d76f39995315ec36980908e4b99709bd14927044"
@@ -6470,9 +6568,9 @@
[[package]]
name = "parity-db"
-version = "0.3.2"
+version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "91b679c6acc14fac74382942e2b73bea441686a33430b951ea03b5aeb6a7f254"
+checksum = "e7ccc4a8687027deb53d45c5434a1f1b330c9d1069a59cfe80a62aa9a1da25ae"
dependencies = [
"blake2-rfc",
"crc32fast",
@@ -11610,6 +11708,24 @@
checksum = "b63708a265f51345575b27fe43f9500ad611579e764c79edbc2037b1121959ec"
[[package]]
+name = "uc-rpc"
+version = "0.1.0"
+dependencies = [
+ "jsonrpc-core",
+ "jsonrpc-core-client",
+ "jsonrpc-derive",
+ "nft-data-structs",
+ "pallet-common",
+ "parity-scale-codec",
+ "sp-api",
+ "sp-blockchain",
+ "sp-core",
+ "sp-rpc",
+ "sp-runtime",
+ "up-rpc",
+]
+
+[[package]]
name = "ucd-trie"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -11716,6 +11832,19 @@
checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a"
[[package]]
+name = "up-rpc"
+version = "0.1.0"
+dependencies = [
+ "nft-data-structs",
+ "pallet-common",
+ "parity-scale-codec",
+ "sp-api",
+ "sp-core",
+ "sp-runtime",
+ "sp-std",
+]
+
+[[package]]
name = "up-sponsorship"
version = "0.1.0"
source = "git+https://github.com/UniqueNetwork/pallet-sponsoring#e5d3354ab68face1b2ef709dc7f629803f56598d"
@@ -12007,7 +12136,7 @@
"cranelift-frontend",
"cranelift-native",
"cranelift-wasm",
- "gimli",
+ "gimli 0.25.0",
"more-asserts",
"object 0.26.2",
"target-lexicon",
@@ -12025,7 +12154,7 @@
"anyhow",
"cfg-if 1.0.0",
"cranelift-entity",
- "gimli",
+ "gimli 0.25.0",
"indexmap",
"log",
"more-asserts",
@@ -12043,11 +12172,11 @@
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24f46dd757225f29a419be415ea6fb8558df9b0194f07e3a6a9c99d0e14dd534"
dependencies = [
- "addr2line",
+ "addr2line 0.16.0",
"anyhow",
"bincode",
"cfg-if 1.0.0",
- "gimli",
+ "gimli 0.25.0",
"libc",
"log",
"more-asserts",
client/rpc/src/lib.rsdiffbeforeafterboth--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -75,9 +75,17 @@
) -> Result<String>;
#[rpc(name = "nft_adminlist")]
- fn adminlist(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<Vec<AccountId>>;
+ fn adminlist(
+ &self,
+ collection: CollectionId,
+ at: Option<BlockHash>,
+ ) -> Result<Vec<CrossAccountId>>;
#[rpc(name = "nft_allowlist")]
- fn allowlist(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<Vec<AccountId>>;
+ fn allowlist(
+ &self,
+ collection: CollectionId,
+ at: Option<BlockHash>,
+ ) -> Result<Vec<CrossAccountId>>;
#[rpc(name = "nft_lastTokenId")]
fn last_token_id(&self, collection: CollectionId, at: Option<BlockHash>) -> Result<TokenId>;
}
@@ -150,7 +158,7 @@
pass_method!(balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
pass_method!(allowance(collection: CollectionId, sender: CrossAccountId, spender: CrossAccountId, token: TokenId) -> String => |v| v.to_string());
- pass_method!(adminlist(collection: CollectionId) -> Vec<AccountId>);
- pass_method!(allowlist(collection: CollectionId) -> Vec<AccountId>);
+ pass_method!(adminlist(collection: CollectionId) -> Vec<CrossAccountId>);
+ pass_method!(allowlist(collection: CollectionId) -> Vec<CrossAccountId>);
pass_method!(last_token_id(collection: CollectionId) -> TokenId);
}
launch-config.jsondiffbeforeafterboth--- a/launch-config.json
+++ b/launch-config.json
@@ -9,7 +9,8 @@
"rpcPort": 9843,
"port": 30444,
"flags": [
- "--rpc-port=9843"
+ "--rpc-port=9843",
+ "-lparachain::candidate_validation=debug"
]
},
{
@@ -18,7 +19,8 @@
"rpcPort": 9854,
"port": 30555,
"flags": [
- "--rpc-port=9854"
+ "--rpc-port=9854",
+ "-lparachain::candidate_validation=debug"
]
},
{
@@ -27,7 +29,8 @@
"rpcPort": 9865,
"port": 30666,
"flags": [
- "--rpc-port=9865"
+ "--rpc-port=9865",
+ "-lparachain::candidate_validation=debug"
]
},
{
@@ -36,7 +39,8 @@
"rpcPort": 9876,
"port": 30777,
"flags": [
- "--rpc-port=9876"
+ "--rpc-port=9876",
+ "-lparachain::candidate_validation=debug"
]
}
],
pallets/common/src/account.rsdiffbeforeafterboth--- a/pallets/common/src/account.rs
+++ b/pallets/common/src/account.rs
@@ -19,6 +19,8 @@
fn from_sub(account: AccountId) -> Self;
fn from_eth(account: H160) -> Self;
+
+ fn conv_eq(&self, other: &Self) -> bool;
}
#[derive(Encode, Decode, Serialize, Deserialize, TypeInfo)]
@@ -28,7 +30,7 @@
Ethereum(H160),
}
-#[derive(Eq)]
+#[derive(PartialEq, Eq)]
pub struct BasicCrossAccountId<T: Config> {
/// If true - then ethereum is canonical encoding
from_ethereum: bool,
@@ -77,18 +79,6 @@
}
}
-impl<T: Config> PartialEq for BasicCrossAccountId<T> {
- fn eq(&self, other: &Self) -> bool {
- if self.from_ethereum == other.from_ethereum {
- self.substrate == other.substrate && self.ethereum == other.ethereum
- } else if self.from_ethereum {
- // ethereum is canonical encoding, but we need to compare derived address
- self.substrate == other.substrate
- } else {
- self.ethereum == other.ethereum
- }
- }
-}
impl<T: Config> Clone for BasicCrossAccountId<T> {
fn clone(&self) -> Self {
Self {
@@ -158,6 +148,16 @@
from_ethereum: true,
}
}
+ fn conv_eq(&self, other: &Self) -> bool {
+ if self.from_ethereum == other.from_ethereum {
+ self.substrate == other.substrate && self.ethereum == other.ethereum
+ } else if self.from_ethereum {
+ // ethereum is canonical encoding, but we need to compare derived address
+ self.substrate == other.substrate
+ } else {
+ self.ethereum == other.ethereum
+ }
+ }
}
impl<T: Config> From<BasicCrossAccountIdRepr<T::AccountId>> for BasicCrossAccountId<T> {
fn from(repr: BasicCrossAccountIdRepr<T::AccountId>) -> Self {
pallets/common/src/lib.rsdiffbeforeafterboth--- a/pallets/common/src/lib.rs
+++ b/pallets/common/src/lib.rs
@@ -11,7 +11,8 @@
use nft_data_structs::{
COLLECTION_NUMBER_LIMIT, Collection, CollectionId, CreateItemData, ExistenceRequirement,
MAX_COLLECTION_DESCRIPTION_LENGTH, MAX_COLLECTION_NAME_LENGTH, MAX_TOKEN_PREFIX_LENGTH,
- MetaUpdatePermission, Pays, PostDispatchInfo, TokenId, Weight, WithdrawReasons,
+ COLLECTION_ADMINS_LIMIT, MetaUpdatePermission, Pays, PostDispatchInfo, TokenId, Weight,
+ WithdrawReasons,
};
pub use pallet::*;
use sp_core::H160;
@@ -98,23 +99,23 @@
pub fn is_owner_or_admin(&self, subject: &T::CrossAccountId) -> Result<bool, DispatchError> {
self.consume_sload()?;
- Ok(*subject.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, subject.as_sub())))
+ Ok(*subject.as_sub() == self.owner || <IsAdmin<T>>::get((self.id, subject)))
}
pub fn check_is_owner_or_admin(&self, subject: &T::CrossAccountId) -> DispatchResult {
ensure!(self.is_owner_or_admin(subject)?, <Error<T>>::NoPermission);
Ok(())
}
pub fn ignores_allowance(&self, user: &T::CrossAccountId) -> Result<bool, DispatchError> {
- Ok(self.limits.owner_can_transfer && self.is_owner_or_admin(user)?)
+ Ok(self.limits.owner_can_transfer() && self.is_owner_or_admin(user)?)
}
pub fn ignores_owned_amount(&self, user: &T::CrossAccountId) -> Result<bool, DispatchError> {
- Ok(self.limits.owner_can_transfer && self.is_owner_or_admin(user)?)
+ Ok(self.limits.owner_can_transfer() && self.is_owner_or_admin(user)?)
}
pub fn check_allowlist(&self, user: &T::CrossAccountId) -> DispatchResult {
self.consume_sload()?;
ensure!(
- <Allowlist<T>>::get((self.id, user.as_sub())),
+ <Allowlist<T>>::get((self.id, user)),
<Error<T>>::AddressNotInAllowlist
);
Ok(())
@@ -139,8 +140,7 @@
#[frame_support::pallet]
pub mod pallet {
use super::*;
- use frame_support::{pallet_prelude::*};
- use frame_support::{Blake2_128Concat, storage::Key};
+ use frame_support::{Blake2_128Concat, pallet_prelude::*, storage::Key};
use account::{EvmBackwardsAddressMapping, CrossAccountId};
use frame_support::traits::Currency;
use nft_data_structs::TokenId;
@@ -166,6 +166,13 @@
#[pallet::generate_store(pub(super) trait Store)]
pub struct Pallet<T>(_);
+ #[pallet::extra_constants]
+ impl<T: Config> Pallet<T> {
+ pub fn collection_admins_limit() -> u32 {
+ COLLECTION_ADMINS_LIMIT
+ }
+ }
+
#[pallet::event]
#[pallet::generate_deposit(pub fn deposit_event)]
pub enum Event<T: Config> {
@@ -266,6 +273,8 @@
TotalCollectionsLimitExceeded,
/// variable_data exceeded data limit.
TokenVariableDataLimitExceeded,
+ /// Exceeded max admin amount
+ CollectionAdminAmountExceeded,
/// Collection settings not allowing items transferring
TransferNotAllowed,
@@ -306,12 +315,20 @@
QueryKind = OptionQuery,
>;
+ #[pallet::storage]
+ pub type AdminAmount<T> = StorageMap<
+ Hasher = Blake2_128Concat,
+ Key = CollectionId,
+ Value = u32,
+ QueryKind = ValueQuery,
+ >;
+
/// List of collection admins
#[pallet::storage]
pub type IsAdmin<T: Config> = StorageNMap<
Key = (
Key<Blake2_128Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = bool,
QueryKind = ValueQuery,
@@ -322,7 +339,7 @@
pub type Allowlist<T: Config> = StorageNMap<
Key = (
Key<Blake2_128Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = bool,
QueryKind = ValueQuery,
@@ -405,9 +422,10 @@
collection: CollectionHandle<T>,
sender: &T::CrossAccountId,
) -> DispatchResult {
- if !collection.limits.owner_can_destroy {
- fail!(Error::<T>::NoPermission);
- }
+ ensure!(
+ collection.limits.owner_can_destroy(),
+ <Error<T>>::NoPermission,
+ );
collection.check_is_owner(&sender)?;
let destroyed_collections = <DestroyedCollectionCount<T>>::get()
@@ -419,6 +437,7 @@
<DestroyedCollectionCount<T>>::put(destroyed_collections);
<CollectionById<T>>::remove(collection.id);
+ <AdminAmount<T>>::remove(collection.id);
<IsAdmin<T>>::remove_prefix((collection.id,), None);
<Allowlist<T>>::remove_prefix((collection.id,), None);
Ok(())
@@ -435,9 +454,44 @@
// =========
if allowed {
- <Allowlist<T>>::insert((collection.id, user.as_sub()), true);
+ <Allowlist<T>>::insert((collection.id, user), true);
} else {
- <Allowlist<T>>::remove((collection.id, user.as_sub()));
+ <Allowlist<T>>::remove((collection.id, user));
+ }
+
+ Ok(())
+ }
+
+ pub fn toggle_admin(
+ collection: &CollectionHandle<T>,
+ sender: &T::CrossAccountId,
+ user: &T::CrossAccountId,
+ admin: bool,
+ ) -> DispatchResult {
+ collection.check_is_owner_or_admin(&sender)?;
+
+ let was_admin = <IsAdmin<T>>::get((collection.id, user));
+ if was_admin == admin {
+ return Ok(());
+ }
+ let amount = <AdminAmount<T>>::get(collection.id);
+
+ if admin {
+ let amount = amount
+ .checked_add(1)
+ .ok_or(<Error<T>>::CollectionAdminAmountExceeded)?;
+ ensure!(
+ amount <= Self::collection_admins_limit(),
+ <Error<T>>::CollectionAdminAmountExceeded,
+ );
+
+ // =========
+
+ <AdminAmount<T>>::insert(collection.id, amount);
+ <IsAdmin<T>>::insert((collection.id, user), true);
+ } else {
+ <AdminAmount<T>>::insert(collection.id, amount.saturating_sub(1));
+ <IsAdmin<T>>::remove((collection.id, user));
}
Ok(())
pallets/fungible/src/common.rsdiffbeforeafterboth--- a/pallets/fungible/src/common.rs
+++ b/pallets/fungible/src/common.rs
@@ -2,9 +2,7 @@
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use nft_data_structs::TokenId;
-use pallet_common::{
- CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::ArithmeticError;
use sp_std::{vec::Vec, vec};
@@ -188,7 +186,7 @@
}
fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
- if <Balance<T>>::get((self.id, account.as_sub())) != 0 {
+ if <Balance<T>>::get((self.id, account)) != 0 {
vec![TokenId::default()]
} else {
vec![]
@@ -218,7 +216,7 @@
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
- if <Balance<T>>::get((self.id, account.as_sub())) != 0 {
+ if <Balance<T>>::get((self.id, account)) != 0 {
1
} else {
0
@@ -229,7 +227,7 @@
if token != TokenId::default() {
return 0;
}
- <Balance<T>>::get((self.id, account.as_sub()))
+ <Balance<T>>::get((self.id, account))
}
fn allowance(
@@ -241,6 +239,6 @@
if token != TokenId::default() {
return 0;
}
- <Allowance<T>>::get((self.id, sender.as_sub(), spender.as_sub()))
+ <Allowance<T>>::get((self.id, sender, spender))
}
}
pallets/fungible/src/erc.rsdiffbeforeafterboth--- a/pallets/fungible/src/erc.rs
+++ b/pallets/fungible/src/erc.rs
@@ -52,7 +52,7 @@
}
fn balance_of(&self, owner: address) -> Result<uint256> {
let owner = T::CrossAccountId::from_eth(owner);
- let balance = <Balance<T>>::get((self.id, owner.as_sub()));
+ let balance = <Balance<T>>::get((self.id, owner));
Ok(balance.into())
}
fn transfer(&mut self, caller: caller, to: address, amount: uint256) -> Result<bool> {
@@ -92,7 +92,7 @@
let owner = T::CrossAccountId::from_eth(owner);
let spender = T::CrossAccountId::from_eth(spender);
- Ok(<Allowance<T>>::get((self.id, owner.as_sub(), spender.as_sub())).into())
+ Ok(<Allowance<T>>::get((self.id, owner, spender)).into())
}
}
pallets/fungible/src/lib.rsdiffbeforeafterboth--- a/pallets/fungible/src/lib.rs
+++ b/pallets/fungible/src/lib.rs
@@ -55,7 +55,7 @@
pub(super) type Balance<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = u128,
QueryKind = ValueQuery,
@@ -65,8 +65,8 @@
pub(super) type Allowance<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
- Key<Blake2_128, T::AccountId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128, T::CrossAccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = u128,
QueryKind = ValueQuery,
@@ -119,7 +119,7 @@
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
- let balance = <Balance<T>>::get((collection.id, owner.as_sub()))
+ let balance = <Balance<T>>::get((collection.id, owner))
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
@@ -130,9 +130,9 @@
// =========
if balance == 0 {
- <Balance<T>>::remove((collection.id, owner.as_sub()));
+ <Balance<T>>::remove((collection.id, owner));
} else {
- <Balance<T>>::insert((collection.id, owner.as_sub()), balance);
+ <Balance<T>>::insert((collection.id, owner), balance);
}
<TotalSupply<T>>::insert(collection.id, total_supply);
@@ -157,8 +157,8 @@
amount: u128,
) -> DispatchResult {
ensure!(
- collection.transfers_enabled,
- <CommonError<T>>::TransferNotAllowed
+ collection.limits.transfers_enabled(),
+ <CommonError<T>>::TransferNotAllowed,
);
if collection.access == AccessMode::AllowList {
@@ -167,12 +167,12 @@
}
<PalletCommon<T>>::ensure_correct_receiver(to)?;
- let balance_from = <Balance<T>>::get((collection.id, from.as_sub()))
+ let balance_from = <Balance<T>>::get((collection.id, from))
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
let balance_to = if from != to {
Some(
- <Balance<T>>::get((collection.id, to.as_sub()))
+ <Balance<T>>::get((collection.id, to))
.checked_add(amount)
.ok_or(ArithmeticError::Overflow)?,
)
@@ -190,11 +190,11 @@
if let Some(balance_to) = balance_to {
// from != to
if balance_from == 0 {
- <Balance<T>>::remove((collection.id, from.as_sub()));
+ <Balance<T>>::remove((collection.id, from));
} else {
- <Balance<T>>::insert((collection.id, from.as_sub()), balance_from);
+ <Balance<T>>::insert((collection.id, from), balance_from);
}
- <Balance<T>>::insert((collection.id, to.as_sub()), balance_to);
+ <Balance<T>>::insert((collection.id, to), balance_to);
}
collection.log_infallible(ERC20Events::Transfer {
@@ -235,14 +235,16 @@
let total_supply = data
.iter()
.map(|u| u.1)
- .try_fold(0u128, |acc, v| acc.checked_add(v))
+ .try_fold(<TotalSupply<T>>::get(collection.id), |acc, v| {
+ acc.checked_add(v)
+ })
.ok_or(ArithmeticError::Overflow)?;
for (user, amount) in data.into_iter() {
collection.consume_sload()?;
let balance = balances
.entry(user.clone())
- .or_insert_with(|| <Balance<T>>::get((collection.id, user.as_sub())));
+ .or_insert_with(|| <Balance<T>>::get((collection.id, user)));
*balance = (*balance)
.checked_add(amount)
.ok_or(ArithmeticError::Overflow)?;
@@ -259,7 +261,7 @@
<TotalSupply<T>>::insert(collection.id, total_supply);
for (user, amount) in balances {
- <Balance<T>>::insert((collection.id, user.as_sub()), amount);
+ <Balance<T>>::insert((collection.id, &user), amount);
collection.log_infallible(ERC20Events::Transfer {
from: H160::default(),
@@ -283,7 +285,7 @@
spender: &T::CrossAccountId,
amount: u128,
) {
- <Allowance<T>>::insert((collection.id, owner.as_sub(), spender.as_sub()), amount);
+ <Allowance<T>>::insert((collection.id, owner, spender), amount);
collection.log_infallible(ERC20Events::Approval {
owner: *owner.as_eth(),
@@ -310,7 +312,7 @@
collection.check_allowlist(&spender)?;
}
- if <Balance<T>>::get((collection.id, owner.as_sub())) < amount {
+ if <Balance<T>>::get((collection.id, owner)) < amount {
ensure!(
collection.ignores_owned_amount(owner)?,
<CommonError<T>>::CantApproveMoreThanOwned
@@ -330,7 +332,7 @@
to: &T::CrossAccountId,
amount: u128,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::transfer(collection, from, to, amount);
}
if collection.access == AccessMode::AllowList {
@@ -338,8 +340,7 @@
collection.check_allowlist(spender)?;
}
- let allowance = <Allowance<T>>::get((collection.id, from.as_sub(), spender.as_sub()))
- .checked_sub(amount);
+ let allowance = <Allowance<T>>::get((collection.id, from, spender)).checked_sub(amount);
if allowance.is_none() {
ensure!(
collection.ignores_allowance(spender)?,
@@ -362,7 +363,7 @@
from: &T::CrossAccountId,
amount: u128,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::burn(collection, from, amount);
}
if collection.access == AccessMode::AllowList {
@@ -370,8 +371,7 @@
collection.check_allowlist(spender)?;
}
- let allowance = <Allowance<T>>::get((collection.id, from.as_sub(), spender.as_sub()))
- .checked_sub(amount);
+ let allowance = <Allowance<T>>::get((collection.id, from, spender)).checked_sub(amount);
if allowance.is_none() {
ensure!(
collection.ignores_allowance(spender)?,
pallets/nft/src/eth/sponsoring.rsdiffbeforeafterboth--- a/pallets/nft/src/eth/sponsoring.rs
+++ b/pallets/nft/src/eth/sponsoring.rs
@@ -43,11 +43,8 @@
let token_id: u32 = token_id.try_into().map_err(|_| AnyError)?;
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let collection_limits = &collection.limits;
- let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
- collection_limits.sponsor_transfer_timeout
- } else {
- NFT_SPONSOR_TRANSFER_TIMEOUT
- };
+ let limit =
+ collection_limits.sponsor_transfer_timeout(NFT_SPONSOR_TRANSFER_TIMEOUT);
let mut sponsor = true;
if <NftTransferBasket<T>>::contains_key(collection_id, token_id) {
@@ -74,11 +71,8 @@
UniqueFungibleCall::ERC20(ERC20Call::Transfer { .. }) => {
let who = T::CrossAccountId::from_eth(*caller);
let collection_limits = &collection.limits;
- let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
- collection_limits.sponsor_transfer_timeout
- } else {
- FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
- };
+ let limit = collection_limits
+ .sponsor_transfer_timeout(FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT);
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let mut sponsored = true;
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -36,9 +36,10 @@
use sp_runtime::{sp_std::prelude::Vec};
use nft_data_structs::{
MAX_DECIMAL_POINTS, MAX_SPONSOR_TIMEOUT, MAX_TOKEN_OWNERSHIP, CUSTOM_DATA_LIMIT,
- VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, COLLECTION_ADMINS_LIMIT,
- OFFCHAIN_SCHEMA_LIMIT, AccessMode, Collection, CreateItemData, CollectionLimits, CollectionId,
- CollectionMode, TokenId, SchemaVersion, SponsorshipState, MetaUpdatePermission,
+ VARIABLE_ON_CHAIN_SCHEMA_LIMIT, CONST_ON_CHAIN_SCHEMA_LIMIT, OFFCHAIN_SCHEMA_LIMIT,
+ FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT, REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ NFT_SPONSOR_TRANSFER_TIMEOUT, AccessMode, Collection, CreateItemData, CollectionLimits,
+ CollectionId, CollectionMode, TokenId, SchemaVersion, SponsorshipState, MetaUpdatePermission,
};
use pallet_common::{
account::CrossAccountId, CollectionHandle, IsAdmin, Pallet as PalletCommon,
@@ -155,7 +156,6 @@
where
origin: T::Origin
{
- const CollectionAdminsLimit: u64 = COLLECTION_ADMINS_LIMIT;
type Error = Error<T>;
fn on_initialize(_now: T::BlockNumber) -> Weight {
@@ -188,11 +188,6 @@
// Anyone can create a collection
let who = ensure_signed(origin)?;
-
- let limits = CollectionLimits::<T::BlockNumber> {
- sponsored_data_size: CUSTOM_DATA_LIMIT,
- ..Default::default()
- };
// Create new collection
let new_collection = Collection::<T> {
@@ -208,8 +203,7 @@
sponsorship: SponsorshipState::Disabled,
variable_on_chain_schema: Vec::new(),
const_on_chain_schema: Vec::new(),
- limits,
- transfers_enabled: true,
+ limits: Default::default(),
meta_update_permission: Default::default(),
};
@@ -411,12 +405,9 @@
#[transactional]
pub fn add_collection_admin(origin, collection_id: CollectionId, new_admin_id: T::CrossAccountId) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
- collection.check_is_owner_or_admin(&sender)?;
- <IsAdmin<T>>::insert((collection_id, new_admin_id.as_sub()), true);
- Ok(())
+ <PalletCommon<T>>::toggle_admin(&collection, &sender, &new_admin_id, true)
}
/// Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.
@@ -435,12 +426,9 @@
#[transactional]
pub fn remove_collection_admin(origin, collection_id: CollectionId, account_id: T::CrossAccountId) -> DispatchResult {
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
-
let collection = <CollectionHandle<T>>::try_get(collection_id)?;
- collection.check_is_owner_or_admin(&sender)?;
- <IsAdmin<T>>::remove((collection_id, account_id.as_sub()));
- Ok(())
+ <PalletCommon<T>>::toggle_admin(&collection, &sender, &account_id, false)
}
/// # Permissions
@@ -458,7 +446,7 @@
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
- target_collection.check_is_owner_or_admin(&sender)?;
+ target_collection.check_is_owner(&sender)?;
target_collection.sponsorship = SponsorshipState::Unconfirmed(new_sponsor);
target_collection.save()
@@ -582,7 +570,7 @@
// =========
- target_collection.transfers_enabled = value;
+ target_collection.limits.transfers_enabled = Some(value);
target_collection.save()
}
@@ -888,30 +876,63 @@
pub fn set_collection_limits(
origin,
collection_id: CollectionId,
- new_limits: CollectionLimits<T::BlockNumber>,
+ new_limit: CollectionLimits,
) -> DispatchResult {
+ let mut new_limit = new_limit;
let sender = T::CrossAccountId::from_sub(ensure_signed(origin)?);
let mut target_collection = <CollectionHandle<T>>::try_get(collection_id)?;
target_collection.check_is_owner(&sender)?;
- let old_limits = &target_collection.limits;
-
- // collection bounds
- ensure!(new_limits.sponsor_transfer_timeout <= MAX_SPONSOR_TIMEOUT &&
- new_limits.account_token_ownership_limit.unwrap_or(0) <= MAX_TOKEN_OWNERSHIP &&
- new_limits.sponsored_data_size <= CUSTOM_DATA_LIMIT,
- Error::<T>::CollectionLimitBoundsExceeded);
+ let old_limit = &target_collection.limits;
- // token_limit check prev
- ensure!(old_limits.token_limit >= new_limits.token_limit, <CommonError<T>>::CollectionTokenLimitExceeded);
- ensure!(new_limits.token_limit > 0, <CommonError<T>>::CollectionTokenLimitExceeded);
+ macro_rules! limit_default {
+ ($old:ident, $new:ident, $($field:ident $(($arg:expr))? => $check:expr),* $(,)?) => {{
+ $(
+ if let Some($new) = $new.$field {
+ let $old = $old.$field($($arg)?);
+ let _ = $new;
+ let _ = $old;
+ $check
+ } else {
+ $new.$field = $old.$field
+ }
+ )*
+ }};
+ }
- ensure!(
- (old_limits.owner_can_transfer || !new_limits.owner_can_transfer) &&
- (old_limits.owner_can_destroy || !new_limits.owner_can_destroy),
- Error::<T>::OwnerPermissionsCantBeReverted,
+ limit_default!(old_limit, new_limit,
+ account_token_ownership_limit => ensure!(
+ new_limit <= MAX_TOKEN_OWNERSHIP,
+ <Error<T>>::CollectionLimitBoundsExceeded,
+ ),
+ sponsor_transfer_timeout(match target_collection.mode {
+ CollectionMode::NFT => NFT_SPONSOR_TRANSFER_TIMEOUT,
+ CollectionMode::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ CollectionMode::ReFungible => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ }) => ensure!(
+ new_limit <= MAX_SPONSOR_TIMEOUT,
+ <Error<T>>::CollectionLimitBoundsExceeded,
+ ),
+ sponsored_data_size => ensure!(
+ new_limit <= CUSTOM_DATA_LIMIT,
+ <Error<T>>::CollectionLimitBoundsExceeded,
+ ),
+ token_limit => ensure!(
+ old_limit >= new_limit && new_limit > 0,
+ <CommonError<T>>::CollectionTokenLimitExceeded
+ ),
+ owner_can_transfer => ensure!(
+ old_limit || !new_limit,
+ <Error<T>>::OwnerPermissionsCantBeReverted,
+ ),
+ owner_can_destroy => ensure!(
+ old_limit || !new_limit,
+ <Error<T>>::OwnerPermissionsCantBeReverted,
+ ),
+ sponsored_data_rate_limit => {},
+ transfers_enabled => {},
);
- target_collection.limits = new_limits;
+ target_collection.limits = new_limit;
target_collection.save()
}
@@ -920,12 +941,12 @@
// TODO: limit returned entries?
impl<T: Config> Pallet<T> {
- pub fn adminlist(collection: CollectionId) -> Vec<T::AccountId> {
+ pub fn adminlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
<IsAdmin<T>>::iter_prefix((collection,))
.map(|(a, _)| a)
.collect()
}
- pub fn allowlist(collection: CollectionId) -> Vec<T::AccountId> {
+ pub fn allowlist(collection: CollectionId) -> Vec<T::CrossAccountId> {
<Allowlist<T>>::iter_prefix((collection,))
.map(|(a, _)| a)
.collect()
pallets/nft/src/sponsorship.rsdiffbeforeafterboth--- a/pallets/nft/src/sponsorship.rs
+++ b/pallets/nft/src/sponsorship.rs
@@ -26,7 +26,13 @@
// sponsor timeout
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
- let limit = collection.limits.sponsor_transfer_timeout;
+ let limit = collection
+ .limits
+ .sponsor_transfer_timeout(match _properties {
+ CreateItemData::NFT(_) => NFT_SPONSOR_TRANSFER_TIMEOUT,
+ CreateItemData::Fungible(_) => FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ CreateItemData::ReFungible(_) => REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT,
+ });
if CreateItemBasket::<T>::contains_key((collection_id, &who)) {
let last_tx_block = CreateItemBasket::<T>::get((collection_id, &who));
let limit_time = last_tx_block + limit.into();
@@ -37,7 +43,7 @@
CreateItemBasket::<T>::insert((collection_id, who.clone()), block_number);
// check free create limit
- if collection.limits.sponsored_data_size >= (_properties.data_size() as u32) {
+ if collection.limits.sponsored_data_size() >= (_properties.data_size() as u32) {
collection.sponsorship.sponsor().cloned()
} else {
None
@@ -61,11 +67,8 @@
sponsor_transfer = match collection_mode {
CollectionMode::NFT => {
// get correct limit
- let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
- collection_limits.sponsor_transfer_timeout
- } else {
- NFT_SPONSOR_TRANSFER_TIMEOUT
- };
+ let limit =
+ collection_limits.sponsor_transfer_timeout(NFT_SPONSOR_TRANSFER_TIMEOUT);
let mut sponsored = true;
if NftTransferBasket::<T>::contains_key(collection_id, item_id) {
@@ -83,11 +86,8 @@
}
CollectionMode::Fungible(_) => {
// get correct limit
- let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
- collection_limits.sponsor_transfer_timeout
- } else {
- FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
- };
+ let limit = collection_limits
+ .sponsor_transfer_timeout(FUNGIBLE_SPONSOR_TRANSFER_TIMEOUT);
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
let mut sponsored = true;
@@ -106,11 +106,8 @@
}
CollectionMode::ReFungible => {
// get correct limit
- let limit: u32 = if collection_limits.sponsor_transfer_timeout > 0 {
- collection_limits.sponsor_transfer_timeout
- } else {
- REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT
- };
+ let limit = collection_limits
+ .sponsor_transfer_timeout(REFUNGIBLE_SPONSOR_TRANSFER_TIMEOUT);
let mut sponsored = true;
if ReFungibleTransferBasket::<T>::contains_key(collection_id, item_id) {
@@ -150,13 +147,13 @@
// Can't sponsor fungible collection, this tx will be rejected
// as invalid
!matches!(collection.mode, CollectionMode::Fungible(_)) &&
- data.len() <= collection.limits.sponsored_data_size as usize
+ data.len() <= collection.limits.sponsored_data_size() as usize
{
- if let Some(rate_limit) = collection.limits.sponsored_data_rate_limit {
+ if let Some(rate_limit) = collection.limits.sponsored_data_rate_limit() {
let block_number = <frame_system::Pallet<T>>::block_number() as T::BlockNumber;
if VariableMetaDataBasket::<T>::get(collection_id, item_id)
- .map(|last_block| block_number - last_block > rate_limit)
+ .map(|last_block| block_number - last_block > rate_limit.into())
.unwrap_or(true)
{
sponsor_metadata_changes = true;
pallets/nonfungible/src/common.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/common.rs
+++ b/pallets/nonfungible/src/common.rs
@@ -2,9 +2,7 @@
use frame_support::{dispatch::DispatchResultWithPostInfo, ensure, fail, weights::Weight};
use nft_data_structs::TokenId;
-use pallet_common::{
- CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
@@ -200,7 +198,7 @@
}
fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
- <Owned<T>>::iter_prefix((self.id, account.as_sub()))
+ <Owned<T>>::iter_prefix((self.id, account))
.map(|(id, _)| id)
.collect()
}
@@ -234,7 +232,7 @@
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
- <AccountBalance<T>>::get((self.id, account.as_sub()))
+ <AccountBalance<T>>::get((self.id, account))
}
fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {
@@ -255,8 +253,8 @@
token: TokenId,
) -> u128 {
if <TokenData<T>>::get((self.id, token))
- .map(|a| a.owner == sender)
- .unwrap_or(false)
+ .map(|a| a.owner != sender)
+ .unwrap_or(true)
{
0
} else if <Allowance<T>>::get((self.id, token)) == Some(spender) {
pallets/nonfungible/src/erc.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/erc.rs
+++ b/pallets/nonfungible/src/erc.rs
@@ -93,7 +93,7 @@
impl<T: Config> NonfungibleHandle<T> {
fn balance_of(&self, owner: address) -> Result<uint256> {
let owner = T::CrossAccountId::from_eth(owner);
- let balance = <AccountBalance<T>>::get((self.id, owner.as_sub()));
+ let balance = <AccountBalance<T>>::get((self.id, owner));
Ok(balance.into())
}
fn owner_of(&self, token_id: uint256) -> Result<address> {
pallets/nonfungible/src/lib.rsdiffbeforeafterboth--- a/pallets/nonfungible/src/lib.rs
+++ b/pallets/nonfungible/src/lib.rs
@@ -80,7 +80,7 @@
pub(super) type Owned<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
Key<Twox64Concat, TokenId>,
),
Value = bool,
@@ -91,7 +91,7 @@
pub(super) type AccountBalance<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = u32,
QueryKind = ValueQuery,
@@ -164,7 +164,7 @@
.ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
ensure!(
&token_data.owner == sender
- || (collection.limits.owner_can_transfer
+ || (collection.limits.owner_can_transfer()
&& collection.is_owner_or_admin(sender)?),
<CommonError<T>>::NoPermission
);
@@ -179,7 +179,7 @@
// =========
- <Owned<T>>::remove((collection.id, token_data.owner.as_sub(), token));
+ <Owned<T>>::remove((collection.id, &token_data.owner, token));
<TokensBurnt<T>>::insert(collection.id, burnt);
<TokenData<T>>::remove((collection.id, token));
let old_spender = <Allowance<T>>::take((collection.id, token));
@@ -215,7 +215,7 @@
token: TokenId,
) -> DispatchResult {
ensure!(
- collection.transfers_enabled,
+ collection.limits.transfers_enabled(),
<CommonError<T>>::TransferNotAllowed
);
@@ -223,7 +223,8 @@
.ok_or_else(|| <CommonError<T>>::TokenNotFound)?;
ensure!(
&token_data.owner == from
- || (collection.limits.owner_can_transfer && collection.is_owner_or_admin(from)?),
+ || (collection.limits.owner_can_transfer()
+ && collection.is_owner_or_admin(from)?),
<CommonError<T>>::NoPermission
);
@@ -233,11 +234,11 @@
}
<PalletCommon<T>>::ensure_correct_receiver(to)?;
- let balance_from = <AccountBalance<T>>::get((collection.id, from.as_sub()))
+ let balance_from = <AccountBalance<T>>::get((collection.id, from))
.checked_sub(1)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
let balance_to = if from != to {
- let balance_to = <AccountBalance<T>>::get((collection.id, to.as_sub()))
+ let balance_to = <AccountBalance<T>>::get((collection.id, to))
.checked_add(1)
.ok_or(ArithmeticError::Overflow)?;
@@ -267,15 +268,15 @@
if let Some(balance_to) = balance_to {
// from != to
if balance_from == 0 {
- <AccountBalance<T>>::remove((collection.id, from.as_sub()));
+ <AccountBalance<T>>::remove((collection.id, from));
} else {
- <AccountBalance<T>>::insert((collection.id, from.as_sub()), balance_from);
+ <AccountBalance<T>>::insert((collection.id, from), balance_from);
}
- <AccountBalance<T>>::insert((collection.id, to.as_sub()), balance_to);
- <Owned<T>>::remove((collection.id, from.as_sub(), token));
- <Owned<T>>::insert((collection.id, to.as_sub(), token), true);
+ <AccountBalance<T>>::insert((collection.id, to), balance_to);
+ <Owned<T>>::remove((collection.id, from, token));
+ <Owned<T>>::insert((collection.id, to, token), true);
}
- Self::set_allowance_unchecked(collection, from, token, None);
+ Self::set_allowance_unchecked(collection, from, token, None, true);
collection.log_infallible(ERC721Events::Transfer {
from: *from.as_eth(),
@@ -327,7 +328,7 @@
.checked_add(data.len() as u32)
.ok_or(ArithmeticError::Overflow)?;
ensure!(
- tokens_minted < collection.limits.token_limit,
+ tokens_minted < collection.limits.token_limit(),
<CommonError<T>>::CollectionTokenLimitExceeded
);
collection.consume_sstore()?;
@@ -335,8 +336,8 @@
let mut balances = BTreeMap::new();
for data in &data {
let balance = balances
- .entry(data.owner.as_sub())
- .or_insert_with(|| <AccountBalance<T>>::get((collection.id, data.owner.as_sub())));
+ .entry(&data.owner)
+ .or_insert_with(|| <AccountBalance<T>>::get((collection.id, &data.owner)));
*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;
ensure!(
@@ -363,7 +364,7 @@
owner: data.owner.clone(),
},
);
- <Owned<T>>::insert((collection.id, data.owner.as_sub(), token), true);
+ <Owned<T>>::insert((collection.id, &data.owner, token), true);
collection.log_infallible(ERC721Events::Transfer {
from: H160::default(),
@@ -385,6 +386,7 @@
sender: &T::CrossAccountId,
token: TokenId,
spender: Option<&T::CrossAccountId>,
+ assume_implicit_eth: bool,
) {
if let Some(spender) = spender {
let old_spender = <Allowance<T>>::get((collection.id, token));
@@ -418,13 +420,15 @@
}
} else {
let old_spender = <Allowance<T>>::take((collection.id, token));
- // In ERC721 there is only one possible approved user of token, so we set
- // approved user to zero address
- collection.log_infallible(ERC721Events::Approval {
- owner: *sender.as_eth(),
- approved: H160::default(),
- token_id: token.into(),
- });
+ if !assume_implicit_eth {
+ // In ERC721 there is only one possible approved user of token, so we set
+ // approved user to zero address
+ collection.log_infallible(ERC721Events::Approval {
+ owner: *sender.as_eth(),
+ approved: H160::default(),
+ token_id: token.into(),
+ });
+ }
// In Unique chain, any token can have any amount of approved users, so we need to
// set allowance of old owner to 0
if let Some(old_spender) = old_spender {
@@ -466,7 +470,7 @@
// =========
- Self::set_allowance_unchecked(collection, sender, token, spender);
+ Self::set_allowance_unchecked(collection, sender, token, spender, false);
Ok(())
}
@@ -477,7 +481,7 @@
to: &T::CrossAccountId,
token: TokenId,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::transfer(collection, from, to, token);
}
if collection.access == AccessMode::AllowList {
@@ -505,7 +509,7 @@
from: &T::CrossAccountId,
token: TokenId,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::burn(collection, from, token);
}
if collection.access == AccessMode::AllowList {
pallets/refungible/src/common.rsdiffbeforeafterboth--- a/pallets/refungible/src/common.rs
+++ b/pallets/refungible/src/common.rs
@@ -3,9 +3,7 @@
use sp_std::collections::btree_map::BTreeMap;
use frame_support::{dispatch::DispatchResultWithPostInfo, fail, weights::Weight};
use nft_data_structs::TokenId;
-use pallet_common::{
- CommonCollectionOperations, CommonWeightInfo, account::CrossAccountId, with_weight,
-};
+use pallet_common::{CommonCollectionOperations, CommonWeightInfo, with_weight};
use sp_runtime::DispatchError;
use sp_std::vec::Vec;
@@ -196,7 +194,7 @@
}
fn account_tokens(&self, account: T::CrossAccountId) -> Vec<TokenId> {
- <Owned<T>>::iter_prefix((self.id, account.as_sub()))
+ <Owned<T>>::iter_prefix((self.id, account))
.map(|(id, _)| id)
.collect()
}
@@ -224,11 +222,11 @@
}
fn account_balance(&self, account: T::CrossAccountId) -> u32 {
- <AccountBalance<T>>::get((self.id, account.as_sub()))
+ <AccountBalance<T>>::get((self.id, account))
}
fn balance(&self, account: T::CrossAccountId, token: TokenId) -> u128 {
- <Balance<T>>::get((self.id, token, account.as_sub()))
+ <Balance<T>>::get((self.id, token, account))
}
fn allowance(
@@ -237,6 +235,6 @@
spender: T::CrossAccountId,
token: TokenId,
) -> u128 {
- <Allowance<T>>::get((self.id, token, sender.as_sub(), spender))
+ <Allowance<T>>::get((self.id, token, sender, spender))
}
}
pallets/refungible/src/lib.rsdiffbeforeafterboth--- a/pallets/refungible/src/lib.rs
+++ b/pallets/refungible/src/lib.rs
@@ -83,7 +83,7 @@
pub(super) type Owned<T: Config> = StorageNMap<
Key = (
Key<Twox64Concat, CollectionId>,
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
Key<Twox64Concat, TokenId>,
),
Value = bool,
@@ -95,7 +95,7 @@
Key = (
Key<Twox64Concat, CollectionId>,
// Owner
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = u32,
QueryKind = ValueQuery,
@@ -107,7 +107,7 @@
Key<Twox64Concat, CollectionId>,
Key<Twox64Concat, TokenId>,
// Owner
- Key<Blake2_128Concat, T::AccountId>,
+ Key<Blake2_128Concat, T::CrossAccountId>,
),
Value = u128,
QueryKind = ValueQuery,
@@ -119,7 +119,7 @@
Key<Twox64Concat, CollectionId>,
Key<Twox64Concat, TokenId>,
// Owner
- Key<Blake2_128, T::AccountId>,
+ Key<Blake2_128, T::CrossAccountId>,
// Spender
Key<Blake2_128Concat, T::CrossAccountId>,
),
@@ -206,18 +206,18 @@
if total_supply == 0 {
// Ensure user actually owns this amount
ensure!(
- <Balance<T>>::get((collection.id, token, owner.as_sub())) == amount,
+ <Balance<T>>::get((collection.id, token, owner)) == amount,
<CommonError<T>>::TokenValueTooLow
);
- let account_balance = <AccountBalance<T>>::get((collection.id, owner.as_sub()))
+ let account_balance = <AccountBalance<T>>::get((collection.id, owner))
.checked_sub(1)
// Should not occur
.ok_or(ArithmeticError::Underflow)?;
// =========
- <Owned<T>>::remove((collection.id, owner.as_sub(), token));
- <AccountBalance<T>>::insert((collection.id, owner.as_sub()), account_balance);
+ <Owned<T>>::remove((collection.id, owner, token));
+ <AccountBalance<T>>::insert((collection.id, owner), account_balance);
Self::burn_token(collection, token)?;
<PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
collection.id,
@@ -228,11 +228,11 @@
return Ok(());
}
- let balance = <Balance<T>>::get((collection.id, token, owner.as_sub()))
+ let balance = <Balance<T>>::get((collection.id, token, owner))
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
let account_balance = if balance == 0 {
- <AccountBalance<T>>::get((collection.id, owner.as_sub()))
+ <AccountBalance<T>>::get((collection.id, owner))
.checked_sub(1)
// Should not occur
.ok_or(ArithmeticError::Underflow)?
@@ -243,11 +243,11 @@
// =========
if balance == 0 {
- <Owned<T>>::remove((collection.id, owner.as_sub(), token));
- <Balance<T>>::remove((collection.id, token, owner.as_sub()));
- <AccountBalance<T>>::insert((collection.id, owner.as_sub()), account_balance);
+ <Owned<T>>::remove((collection.id, owner, token));
+ <Balance<T>>::remove((collection.id, token, owner));
+ <AccountBalance<T>>::insert((collection.id, owner), account_balance);
} else {
- <Balance<T>>::insert((collection.id, token, owner.as_sub()), balance);
+ <Balance<T>>::insert((collection.id, token, owner), balance);
}
<TotalSupply<T>>::insert((collection.id, token), total_supply);
// TODO: ERC20 transfer event
@@ -268,7 +268,7 @@
amount: u128,
) -> DispatchResult {
ensure!(
- collection.transfers_enabled,
+ collection.limits.transfers_enabled(),
<CommonError<T>>::TransferNotAllowed
);
@@ -278,13 +278,13 @@
}
<PalletCommon<T>>::ensure_correct_receiver(to)?;
- let balance_from = <Balance<T>>::get((collection.id, token, from.as_sub()))
+ let balance_from = <Balance<T>>::get((collection.id, token, from))
.checked_sub(amount)
.ok_or(<CommonError<T>>::TokenValueTooLow)?;
let mut create_target = false;
let from_to_differ = from != to;
let balance_to = if from != to {
- let old_balance = <Balance<T>>::get((collection.id, token, to.as_sub()));
+ let old_balance = <Balance<T>>::get((collection.id, token, to));
if old_balance == 0 {
create_target = true;
}
@@ -299,7 +299,7 @@
let account_balance_from = if balance_from == 0 {
Some(
- <AccountBalance<T>>::get((collection.id, from.as_sub()))
+ <AccountBalance<T>>::get((collection.id, from))
.checked_sub(1)
// Should not occur
.ok_or(ArithmeticError::Underflow)?,
@@ -310,7 +310,7 @@
// Account data is created in token, AccountBalance should be increased
// But only if from != to as we shouldn't check overflow in this case
let account_balance_to = if create_target && from_to_differ {
- let account_balance_to = <AccountBalance<T>>::get((collection.id, to.as_sub()))
+ let account_balance_to = <AccountBalance<T>>::get((collection.id, to))
.checked_add(1)
.ok_or(ArithmeticError::Overflow)?;
ensure!(
@@ -328,18 +328,18 @@
if let Some(balance_to) = balance_to {
// from != to
if balance_from == 0 {
- <Balance<T>>::remove((collection.id, token, from.as_sub()));
+ <Balance<T>>::remove((collection.id, token, from));
} else {
- <Balance<T>>::insert((collection.id, token, from.as_sub()), balance_from);
+ <Balance<T>>::insert((collection.id, token, from), balance_from);
}
- <Balance<T>>::insert((collection.id, token, to.as_sub()), balance_to);
+ <Balance<T>>::insert((collection.id, token, to), balance_to);
if let Some(account_balance_from) = account_balance_from {
- <AccountBalance<T>>::insert((collection.id, from.as_sub()), account_balance_from);
- <Owned<T>>::remove((collection.id, from.as_sub(), token));
+ <AccountBalance<T>>::insert((collection.id, from), account_balance_from);
+ <Owned<T>>::remove((collection.id, from, token));
}
if let Some(account_balance_to) = account_balance_to {
- <AccountBalance<T>>::insert((collection.id, to.as_sub()), account_balance_to);
- <Owned<T>>::insert((collection.id, to.as_sub(), token), true);
+ <AccountBalance<T>>::insert((collection.id, to), account_balance_to);
+ <Owned<T>>::insert((collection.id, to, token), true);
}
}
@@ -404,7 +404,7 @@
.checked_add(data.len() as u32)
.ok_or(ArithmeticError::Overflow)?;
ensure!(
- tokens_minted < collection.limits.token_limit,
+ tokens_minted < collection.limits.token_limit(),
<CommonError<T>>::CollectionTokenLimitExceeded
);
@@ -412,8 +412,8 @@
for data in &data {
for (owner, _) in &data.users {
let balance = balances
- .entry(owner.as_sub())
- .or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner.as_sub())));
+ .entry(owner)
+ .or_insert_with(|| <AccountBalance<T>>::get((collection.id, owner)));
*balance = balance.checked_add(1).ok_or(ArithmeticError::Overflow)?;
ensure!(
@@ -444,8 +444,8 @@
if amount == 0 {
continue;
}
- <Balance<T>>::insert((collection.id, token_id, user.as_sub()), amount);
- <Owned<T>>::insert((collection.id, user.as_sub(), TokenId(token_id)), true);
+ <Balance<T>>::insert((collection.id, token_id, &user), amount);
+ <Owned<T>>::insert((collection.id, &user, TokenId(token_id)), true);
// TODO: ERC20 transfer event
<PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
collection.id,
@@ -465,7 +465,7 @@
token: TokenId,
amount: u128,
) {
- <Allowance<T>>::insert((collection.id, token, sender.as_sub(), spender), amount);
+ <Allowance<T>>::insert((collection.id, token, sender, spender), amount);
// TODO: ERC20 approval event
<PalletCommon<T>>::deposit_event(CommonEvent::Approved(
collection.id,
@@ -490,9 +490,9 @@
<PalletCommon<T>>::ensure_correct_receiver(spender)?;
- if <Balance<T>>::get((collection.id, token, sender.as_sub())) < amount {
+ if <Balance<T>>::get((collection.id, token, sender)) < amount {
ensure!(
- collection.ignores_owned_amount(sender)?,
+ collection.ignores_owned_amount(sender)? && Self::token_exists(collection, token),
<CommonError<T>>::CantApproveMoreThanOwned
);
}
@@ -511,7 +511,7 @@
token: TokenId,
amount: u128,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::transfer(collection, from, to, token, amount);
}
if collection.access == AccessMode::AllowList {
@@ -519,8 +519,8 @@
collection.check_allowlist(spender)?;
}
- let allowance = <Allowance<T>>::get((collection.id, token, from.as_sub(), &spender))
- .checked_sub(amount);
+ let allowance =
+ <Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);
if allowance.is_none() {
ensure!(
collection.ignores_allowance(spender)?,
@@ -544,7 +544,7 @@
token: TokenId,
amount: u128,
) -> DispatchResult {
- if spender == from {
+ if spender.conv_eq(from) {
return Self::burn(collection, from, token, amount);
}
if collection.access == AccessMode::AllowList {
@@ -552,8 +552,8 @@
collection.check_allowlist(spender)?;
}
- let allowance = <Allowance<T>>::get((collection.id, token, from.as_sub(), &spender))
- .checked_sub(amount);
+ let allowance =
+ <Allowance<T>>::get((collection.id, token, from, &spender)).checked_sub(amount);
if allowance.is_none() {
ensure!(
collection.ignores_allowance(spender)?,
primitives/nft/src/lib.rsdiffbeforeafterboth--- a/primitives/nft/src/lib.rs
+++ b/primitives/nft/src/lib.rs
@@ -41,7 +41,8 @@
} else {
10
};
-pub const COLLECTION_ADMINS_LIMIT: u64 = 5;
+pub const COLLECTION_ADMINS_LIMIT: u32 = 5;
+pub const COLLECTION_TOKEN_LIMIT: u32 = u32::MAX;
pub const ACCOUNT_TOKEN_OWNERSHIP_LIMIT: u32 = if cfg!(not(feature = "limit-testing")) {
1000000
} else {
@@ -217,11 +218,10 @@
pub offchain_schema: Vec<u8>,
pub schema_version: SchemaVersion,
pub sponsorship: SponsorshipState<T::AccountId>,
- pub limits: CollectionLimits<T::BlockNumber>, // Collection private restrictions
- pub variable_on_chain_schema: Vec<u8>, //
- pub const_on_chain_schema: Vec<u8>, //
+ pub limits: CollectionLimits, // Collection private restrictions
+ pub variable_on_chain_schema: Vec<u8>, //
+ pub const_on_chain_schema: Vec<u8>, //
pub meta_update_permission: MetaUpdatePermission,
- pub transfers_enabled: bool,
}
#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo)]
@@ -246,42 +246,57 @@
pub variable_data: Vec<u8>,
}
-#[derive(Encode, Decode, Debug, Clone, PartialEq, TypeInfo)]
+#[derive(Encode, Decode, Debug, Default, Clone, PartialEq, TypeInfo)]
#[cfg_attr(feature = "serde1", derive(Serialize, Deserialize))]
-pub struct CollectionLimits<BlockNumber: Encode + Decode> {
+pub struct CollectionLimits {
pub account_token_ownership_limit: Option<u32>,
- pub sponsored_data_size: u32,
+ pub sponsored_data_size: Option<u32>,
/// None - setVariableMetadata is not sponsored
/// Some(v) - setVariableMetadata is sponsored
/// if there is v block between txs
- pub sponsored_data_rate_limit: Option<BlockNumber>,
- pub token_limit: u32,
+ pub sponsored_data_rate_limit: Option<u32>,
+ pub token_limit: Option<u32>,
// Timeouts for item types in passed blocks
- pub sponsor_transfer_timeout: u32,
- pub owner_can_transfer: bool,
- pub owner_can_destroy: bool,
+ pub sponsor_transfer_timeout: Option<u32>,
+ pub owner_can_transfer: Option<bool>,
+ pub owner_can_destroy: Option<bool>,
+ pub transfers_enabled: Option<bool>,
}
-impl<BlockNumber: Encode + Decode> CollectionLimits<BlockNumber> {
+impl CollectionLimits {
pub fn account_token_ownership_limit(&self) -> u32 {
self.account_token_ownership_limit
.unwrap_or(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)
- .min(ACCOUNT_TOKEN_OWNERSHIP_LIMIT)
+ .min(MAX_TOKEN_OWNERSHIP)
}
-}
-
-impl<BlockNumber: Encode + Decode> Default for CollectionLimits<BlockNumber> {
- fn default() -> Self {
- Self {
- account_token_ownership_limit: Some(10_000_000),
- token_limit: u32::max_value(),
- sponsored_data_size: u32::MAX,
- sponsored_data_rate_limit: None,
- sponsor_transfer_timeout: 14400,
- owner_can_transfer: true,
- owner_can_destroy: true,
- }
+ pub fn sponsored_data_size(&self) -> u32 {
+ self.sponsored_data_size
+ .unwrap_or(CUSTOM_DATA_LIMIT)
+ .min(CUSTOM_DATA_LIMIT)
+ }
+ pub fn token_limit(&self) -> u32 {
+ self.token_limit
+ .unwrap_or(COLLECTION_TOKEN_LIMIT)
+ .min(COLLECTION_TOKEN_LIMIT)
+ }
+ pub fn sponsor_transfer_timeout(&self, default: u32) -> u32 {
+ self.sponsor_transfer_timeout
+ .unwrap_or(default)
+ .min(MAX_SPONSOR_TIMEOUT)
+ }
+ pub fn owner_can_transfer(&self) -> bool {
+ self.owner_can_transfer.unwrap_or(true)
+ }
+ pub fn owner_can_destroy(&self) -> bool {
+ self.owner_can_destroy.unwrap_or(true)
+ }
+ pub fn transfers_enabled(&self) -> bool {
+ self.transfers_enabled.unwrap_or(true)
+ }
+ pub fn sponsored_data_rate_limit(&self) -> Option<u32> {
+ self.sponsored_data_rate_limit
+ .map(|v| v.min(MAX_SPONSOR_TIMEOUT))
}
}
primitives/rpc/src/lib.rsdiffbeforeafterboth--- a/primitives/rpc/src/lib.rs
+++ b/primitives/rpc/src/lib.rs
@@ -30,8 +30,8 @@
/// Used for ethereum integration
fn eth_contract_code(account: H160) -> Option<Vec<u8>>;
- fn adminlist(collection: CollectionId) -> Vec<AccountId>;
- fn allowlist(collection: CollectionId) -> Vec<AccountId>;
+ fn adminlist(collection: CollectionId) -> Vec<CrossAccountId>;
+ fn allowlist(collection: CollectionId) -> Vec<CrossAccountId>;
fn last_token_id(collection: CollectionId) -> TokenId;
}
}
runtime/src/lib.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.78#![cfg_attr(not(feature = "std"), no_std)]9// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.10#![recursion_limit = "1024"]11#![allow(clippy::from_over_into, clippy::identity_op)]12#![allow(clippy::fn_to_numeric_cast_with_truncation)]13// Make the WASM binary available.14#[cfg(feature = "std")]15include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1617use sp_api::impl_runtime_apis;18use sp_core::{crypto::KeyTypeId, OpaqueMetadata, H256, U256, H160};19// #[cfg(any(feature = "std", test))]20// pub use sp_runtime::BuildStorage;2122use sp_runtime::{23 Permill, Perbill, Percent, create_runtime_str, generic, impl_opaque_keys,24 traits::{25 AccountIdLookup, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, Verify,26 AccountIdConversion,27 },28 transaction_validity::{TransactionSource, TransactionValidity},29 ApplyExtrinsicResult, MultiSignature,30};3132use sp_std::prelude::*;3334#[cfg(feature = "std")]35use sp_version::NativeVersion;36use sp_version::RuntimeVersion;37pub use pallet_transaction_payment::{38 Multiplier, TargetedFeeAdjustment, FeeDetails, RuntimeDispatchInfo,39};40// A few exports that help ease life for downstream crates.41pub use pallet_balances::Call as BalancesCall;42pub use pallet_evm::{EnsureAddressTruncated, HashedAddressMapping, Runner};43pub use frame_support::{44 construct_runtime, match_type,45 dispatch::DispatchResult,46 PalletId, parameter_types, StorageValue, ConsensusEngineId,47 traits::{48 Everything, Currency, ExistenceRequirement, Get, IsInVec, KeyOwnerProofSystem,49 LockIdentifier, OnUnbalanced, Randomness, FindAuthor,50 },51 weights::{52 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},53 DispatchClass, DispatchInfo, GetDispatchInfo, IdentityFee, Pays, PostDispatchInfo, Weight,54 WeightToFeePolynomial, WeightToFeeCoefficient, WeightToFeeCoefficients,55 },56};57use nft_data_structs::*;58// use pallet_contracts::weights::WeightInfo;59// #[cfg(any(feature = "std", test))]60use frame_system::{61 self as system, EnsureRoot, EnsureSigned,62 limits::{BlockWeights, BlockLength},63};64use sp_arithmetic::{65 traits::{BaseArithmetic, Unsigned},66};67use smallvec::smallvec;68use codec::{Encode, Decode};69use pallet_evm::{Account as EVMAccount, FeeCalculator, OnMethodCall};70use fp_rpc::TransactionStatus;71use sp_core::crypto::Public;72use sp_runtime::{73 traits::{Dispatchable, PostDispatchInfoOf},74 transaction_validity::TransactionValidityError,75};7677// pub use pallet_timestamp::Call as TimestampCall;78pub use sp_consensus_aura::sr25519::AuthorityId as AuraId;7980// Polkadot imports81use pallet_xcm::XcmPassthrough;82use polkadot_parachain::primitives::Sibling;83use xcm::v1::{BodyId, Junction::*, MultiLocation, NetworkId, Junctions::*};84use xcm_builder::{85 AccountId32Aliases, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter,86 EnsureXcmOrigin, FixedWeightBounds, IsConcrete, LocationInverter, NativeAsset,87 ParentAsSuperuser, ParentIsDefault, RelayChainAsNative, SiblingParachainAsNative,88 SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,89 SovereignSignedViaLocation, TakeWeightCredit, UsingComponents,90};91use xcm_executor::{Config, XcmExecutor};9293// mod chain_extension;94// use crate::chain_extension::{NFTExtension, Imbalance};9596/// An index to a block.97pub type BlockNumber = u32;9899/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.100pub type Signature = MultiSignature;101102/// Some way of identifying an account on the chain. We intentionally make it equivalent103/// to the public key of our transaction signing scheme.104pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;105106pub type CrossAccountId = pallet_common::account::BasicCrossAccountId<Runtime>;107108/// The type for looking up accounts. We don't expect more than 4 billion of them, but you109/// never know...110pub type AccountIndex = u32;111112/// Balance of an account.113pub type Balance = u128;114115/// Index of a transaction in the chain.116pub type Index = u32;117118/// A hash of some data used by the chain.119pub type Hash = sp_core::H256;120121/// Digest item type.122pub type DigestItem = generic::DigestItem<Hash>;123124/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know125/// the specifics of the runtime. They can then be made to be agnostic over specific formats126/// of data like extrinsics, allowing for them to continue syncing the network through upgrades127/// to even the core data structures.128pub mod opaque {129 use super::*;130131 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;132133 /// Opaque block type.134 pub type Block = generic::Block<Header, UncheckedExtrinsic>;135136 pub type SessionHandlers = ();137138 impl_opaque_keys! {139 pub struct SessionKeys {140 pub aura: Aura,141 }142 }143}144145/// This runtime version.146pub const VERSION: RuntimeVersion = RuntimeVersion {147 spec_name: create_runtime_str!("opal"),148 impl_name: create_runtime_str!("opal"),149 authoring_version: 1,150 spec_version: 912202,151 impl_version: 1,152 apis: RUNTIME_API_VERSIONS,153 transaction_version: 1,154};155156pub const MILLISECS_PER_BLOCK: u64 = 12000;157158pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;159160// These time units are defined in number of blocks.161pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);162pub const HOURS: BlockNumber = MINUTES * 60;163pub const DAYS: BlockNumber = HOURS * 24;164165parameter_types! {166 pub const DefaultSponsoringRateLimit: BlockNumber = 1 * DAYS;167}168169#[derive(codec::Encode, codec::Decode)]170pub enum XCMPMessage<XAccountId, XBalance> {171 /// Transfer tokens to the given account from the Parachain account.172 TransferToken(XAccountId, XBalance),173}174175/// The version information used to identify this runtime when compiled natively.176#[cfg(feature = "std")]177pub fn native_version() -> NativeVersion {178 NativeVersion {179 runtime_version: VERSION,180 can_author_with: Default::default(),181 }182}183184type NegativeImbalance = <Balances as Currency<AccountId>>::NegativeImbalance;185186pub struct DealWithFees;187impl OnUnbalanced<NegativeImbalance> for DealWithFees {188 fn on_unbalanceds<B>(mut fees_then_tips: impl Iterator<Item = NegativeImbalance>) {189 if let Some(fees) = fees_then_tips.next() {190 // for fees, 100% to treasury191 let mut split = fees.ration(100, 0);192 if let Some(tips) = fees_then_tips.next() {193 // for tips, if any, 100% to treasury194 tips.ration_merge_into(100, 0, &mut split);195 }196 Treasury::on_unbalanced(split.0);197 // Author::on_unbalanced(split.1);198 }199 }200}201202/// We assume that ~10% of the block weight is consumed by `on_initalize` handlers.203/// This is used to limit the maximal weight of a single extrinsic.204const AVERAGE_ON_INITIALIZE_RATIO: Perbill = Perbill::from_percent(10);205/// We allow `Normal` extrinsics to fill up the block up to 75%, the rest can be used206/// by Operational extrinsics.207const NORMAL_DISPATCH_RATIO: Perbill = Perbill::from_percent(75);208/// We allow for 2 seconds of compute with a 6 second average block time.209const MAXIMUM_BLOCK_WEIGHT: Weight = WEIGHT_PER_SECOND / 2;210211parameter_types! {212 pub const BlockHashCount: BlockNumber = 2400;213 pub RuntimeBlockLength: BlockLength =214 BlockLength::max_with_normal_ratio(5 * 1024 * 1024, NORMAL_DISPATCH_RATIO);215 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);216 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;217 pub RuntimeBlockWeights: BlockWeights = BlockWeights::builder()218 .base_block(BlockExecutionWeight::get())219 .for_class(DispatchClass::all(), |weights| {220 weights.base_extrinsic = ExtrinsicBaseWeight::get();221 })222 .for_class(DispatchClass::Normal, |weights| {223 weights.max_total = Some(NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT);224 })225 .for_class(DispatchClass::Operational, |weights| {226 weights.max_total = Some(MAXIMUM_BLOCK_WEIGHT);227 // Operational transactions have some extra reserved space, so that they228 // are included even if block reached `MAXIMUM_BLOCK_WEIGHT`.229 weights.reserved = Some(230 MAXIMUM_BLOCK_WEIGHT - NORMAL_DISPATCH_RATIO * MAXIMUM_BLOCK_WEIGHT231 );232 })233 .avg_block_initialization(AVERAGE_ON_INITIALIZE_RATIO)234 .build_or_panic();235 pub const Version: RuntimeVersion = VERSION;236 pub const SS58Prefix: u8 = 42;237}238239parameter_types! {240 pub const ChainId: u64 = 8888;241}242243pub struct FixedFee;244impl FeeCalculator for FixedFee {245 fn min_gas_price() -> U256 {246 1.into()247 }248}249250impl pallet_evm::Config for Runtime {251 type BlockGasLimit = BlockGasLimit;252 type FeeCalculator = FixedFee;253 type GasWeightMapping = ();254 type BlockHashMapping = pallet_ethereum::EthereumBlockHashMapping<Self>;255 type CallOrigin = EnsureAddressTruncated;256 type WithdrawOrigin = EnsureAddressTruncated;257 type AddressMapping = HashedAddressMapping<Self::Hashing>;258 type Precompiles = ();259 type Currency = Balances;260 type Event = Event;261 type OnMethodCall = (262 pallet_evm_migration::OnMethodCall<Self>,263 pallet_nft::NftErcSupport<Self>,264 pallet_evm_contract_helpers::HelpersOnMethodCall<Self>,265 );266 type OnCreate = pallet_evm_contract_helpers::HelpersOnCreate<Self>;267 type ChainId = ChainId;268 type Runner = pallet_evm::runner::stack::Runner<Self>;269 type OnChargeTransaction = pallet_evm_transaction_payment::OnChargeTransaction<Self>;270 type TransactionValidityHack = pallet_evm_transaction_payment::TransactionValidityHack<Self>;271 type FindAuthor = EthereumFindAuthor<Aura>;272}273274impl pallet_evm_migration::Config for Runtime {275 type WeightInfo = pallet_evm_migration::weights::SubstrateWeight<Self>;276}277278pub struct EthereumFindAuthor<F>(core::marker::PhantomData<F>);279impl<F: FindAuthor<u32>> FindAuthor<H160> for EthereumFindAuthor<F> {280 fn find_author<'a, I>(digests: I) -> Option<H160>281 where282 I: 'a + IntoIterator<Item = (ConsensusEngineId, &'a [u8])>,283 {284 if let Some(author_index) = F::find_author(digests) {285 let authority_id = Aura::authorities()[author_index as usize].clone();286 return Some(H160::from_slice(&authority_id.to_raw_vec()[4..24]));287 }288 None289 }290}291292parameter_types! {293 pub BlockGasLimit: U256 = U256::from(u32::max_value());294}295296impl pallet_ethereum::Config for Runtime {297 type Event = Event;298 type StateRoot = pallet_ethereum::IntermediateStateRoot;299 type EvmSubmitLog = pallet_evm::Pallet<Self>;300}301302impl pallet_randomness_collective_flip::Config for Runtime {}303304impl system::Config for Runtime {305 /// The data to be stored in an account.306 type AccountData = pallet_balances::AccountData<Balance>;307 /// The identifier used to distinguish between accounts.308 type AccountId = AccountId;309 /// The basic call filter to use in dispatchable.310 type BaseCallFilter = Everything;311 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).312 type BlockHashCount = BlockHashCount;313 /// The maximum length of a block (in bytes).314 type BlockLength = RuntimeBlockLength;315 /// The index type for blocks.316 type BlockNumber = BlockNumber;317 /// The weight of the overhead invoked on the block import process, independent of the extrinsics included in that block.318 type BlockWeights = RuntimeBlockWeights;319 /// The aggregated dispatch type that is available for extrinsics.320 type Call = Call;321 /// The weight of database operations that the runtime can invoke.322 type DbWeight = RocksDbWeight;323 /// The ubiquitous event type.324 type Event = Event;325 /// The type for hashing blocks and tries.326 type Hash = Hash;327 /// The hashing algorithm used.328 type Hashing = BlakeTwo256;329 /// The header type.330 type Header = generic::Header<BlockNumber, BlakeTwo256>;331 /// The index type for storing how many extrinsics an account has signed.332 type Index = Index;333 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.334 type Lookup = AccountIdLookup<AccountId, ()>;335 /// What to do if an account is fully reaped from the system.336 type OnKilledAccount = ();337 /// What to do if a new account is created.338 type OnNewAccount = ();339 type OnSetCode = cumulus_pallet_parachain_system::ParachainSetCode<Self>;340 /// The ubiquitous origin type.341 type Origin = Origin;342 /// This type is being generated by `construct_runtime!`.343 type PalletInfo = PalletInfo;344 /// This is used as an identifier of the chain. 42 is the generic substrate prefix.345 type SS58Prefix = SS58Prefix;346 /// Weight information for the extrinsics of this pallet.347 type SystemWeightInfo = system::weights::SubstrateWeight<Self>;348 /// Version of the runtime.349 type Version = Version;350}351352parameter_types! {353 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;354}355356impl pallet_timestamp::Config for Runtime {357 /// A timestamp: milliseconds since the unix epoch.358 type Moment = u64;359 type OnTimestampSet = ();360 type MinimumPeriod = MinimumPeriod;361 type WeightInfo = ();362}363364parameter_types! {365 // pub const ExistentialDeposit: u128 = 500;366 pub const ExistentialDeposit: u128 = 0;367 pub const MaxLocks: u32 = 50;368}369370impl pallet_balances::Config for Runtime {371 type MaxLocks = MaxLocks;372 type MaxReserves = ();373 type ReserveIdentifier = [u8; 8];374 /// The type for recording an account's balance.375 type Balance = Balance;376 /// The ubiquitous event type.377 type Event = Event;378 type DustRemoval = Treasury;379 type ExistentialDeposit = ExistentialDeposit;380 type AccountStore = System;381 type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;382}383384pub const MICROUNIQUE: Balance = 1_000_000_000;385pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;386pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;387pub const UNIQUE: Balance = 100 * CENTIUNIQUE;388389pub const fn deposit(items: u32, bytes: u32) -> Balance {390 items as Balance * 15 * CENTIUNIQUE + (bytes as Balance) * 6 * CENTIUNIQUE391}392393/*394parameter_types! {395 pub TombstoneDeposit: Balance = deposit(396 1,397 sp_std::mem::size_of::<pallet_contracts::Pallet<Runtime>> as u32,398 );399 pub DepositPerContract: Balance = TombstoneDeposit::get();400 pub const DepositPerStorageByte: Balance = deposit(0, 1);401 pub const DepositPerStorageItem: Balance = deposit(1, 0);402 pub RentFraction: Perbill = Perbill::from_rational(1u32, 30 * DAYS);403 pub const SurchargeReward: Balance = 150 * MILLIUNIQUE;404 pub const SignedClaimHandicap: u32 = 2;405 pub const MaxDepth: u32 = 32;406 pub const MaxValueSize: u32 = 16 * 1024;407 pub const MaxCodeSize: u32 = 1024 * 1024 * 25; // 25 Mb408 // The lazy deletion runs inside on_initialize.409 pub DeletionWeightLimit: Weight = AVERAGE_ON_INITIALIZE_RATIO *410 RuntimeBlockWeights::get().max_block;411 // The weight needed for decoding the queue should be less or equal than a fifth412 // of the overall weight dedicated to the lazy deletion.413 pub DeletionQueueDepth: u32 = ((DeletionWeightLimit::get() / (414 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(1) -415 <Runtime as pallet_contracts::Config>::WeightInfo::on_initialize_per_queue_item(0)416 )) / 5) as u32;417 pub Schedule: pallet_contracts::Schedule<Runtime> = Default::default();418}419420impl pallet_contracts::Config for Runtime {421 type Time = Timestamp;422 type Randomness = RandomnessCollectiveFlip;423 type Currency = Balances;424 type Event = Event;425 type RentPayment = ();426 type SignedClaimHandicap = SignedClaimHandicap;427 type TombstoneDeposit = TombstoneDeposit;428 type DepositPerContract = DepositPerContract;429 type DepositPerStorageByte = DepositPerStorageByte;430 type DepositPerStorageItem = DepositPerStorageItem;431 type RentFraction = RentFraction;432 type SurchargeReward = SurchargeReward;433 type WeightPrice = pallet_transaction_payment::Pallet<Self>;434 type WeightInfo = pallet_contracts::weights::SubstrateWeight<Self>;435 type ChainExtension = NFTExtension;436 type DeletionQueueDepth = DeletionQueueDepth;437 type DeletionWeightLimit = DeletionWeightLimit;438 type Schedule = Schedule;439 type CallStack = [pallet_contracts::Frame<Self>; 31];440}441*/442443parameter_types! {444 pub const TransactionByteFee: Balance = 501 * MICROUNIQUE; // Targeting 0.1 Unique per NFT transfer445 /// This value increases the priority of `Operational` transactions by adding446 /// a "virtual tip" that's equal to the `OperationalFeeMultiplier * final_fee`.447 pub const OperationalFeeMultiplier: u8 = 5;448}449450/// Linear implementor of `WeightToFeePolynomial`451pub struct LinearFee<T>(sp_std::marker::PhantomData<T>);452453impl<T> WeightToFeePolynomial for LinearFee<T>454where455 T: BaseArithmetic + From<u32> + Copy + Unsigned,456{457 type Balance = T;458459 fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {460 smallvec!(WeightToFeeCoefficient {461 coeff_integer: 146_700u32.into(), // Targeting 0.1 Unique per NFT transfer462 coeff_frac: Perbill::zero(),463 negative: false,464 degree: 1,465 })466 }467}468469impl pallet_transaction_payment::Config for Runtime {470 type OnChargeTransaction = pallet_transaction_payment::CurrencyAdapter<Balances, DealWithFees>;471 type TransactionByteFee = TransactionByteFee;472 type OperationalFeeMultiplier = OperationalFeeMultiplier;473 type WeightToFee = LinearFee<Balance>;474 type FeeMultiplierUpdate = ();475}476477parameter_types! {478 pub const ProposalBond: Permill = Permill::from_percent(5);479 pub const ProposalBondMinimum: Balance = 1 * UNIQUE;480 pub const SpendPeriod: BlockNumber = 5 * MINUTES;481 pub const Burn: Permill = Permill::from_percent(0);482 pub const TipCountdown: BlockNumber = 1 * DAYS;483 pub const TipFindersFee: Percent = Percent::from_percent(20);484 pub const TipReportDepositBase: Balance = 1 * UNIQUE;485 pub const DataDepositPerByte: Balance = 1 * CENTIUNIQUE;486 pub const BountyDepositBase: Balance = 1 * UNIQUE;487 pub const BountyDepositPayoutDelay: BlockNumber = 1 * DAYS;488 pub const TreasuryModuleId: PalletId = PalletId(*b"py/trsry");489 pub const BountyUpdatePeriod: BlockNumber = 14 * DAYS;490 pub const MaximumReasonLength: u32 = 16384;491 pub const BountyCuratorDeposit: Permill = Permill::from_percent(50);492 pub const BountyValueMinimum: Balance = 5 * UNIQUE;493 pub const MaxApprovals: u32 = 100;494}495496impl pallet_treasury::Config for Runtime {497 type PalletId = TreasuryModuleId;498 type Currency = Balances;499 type ApproveOrigin = EnsureRoot<AccountId>;500 type RejectOrigin = EnsureRoot<AccountId>;501 type Event = Event;502 type OnSlash = ();503 type ProposalBond = ProposalBond;504 type ProposalBondMinimum = ProposalBondMinimum;505 type SpendPeriod = SpendPeriod;506 type Burn = Burn;507 type BurnDestination = ();508 type SpendFunds = ();509 type WeightInfo = pallet_treasury::weights::SubstrateWeight<Self>;510 type MaxApprovals = MaxApprovals;511}512513impl pallet_sudo::Config for Runtime {514 type Event = Event;515 type Call = Call;516}517518parameter_types! {519 pub const MinVestedTransfer: Balance = 10 * UNIQUE;520}521522impl pallet_vesting::Config for Runtime {523 type Event = Event;524 type Currency = Balances;525 type BlockNumberToBalance = ConvertInto;526 type MinVestedTransfer = MinVestedTransfer;527 type WeightInfo = ();528 const MAX_VESTING_SCHEDULES: u32 = 28;529}530531parameter_types! {532 pub const ReservedDmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;533 pub const ReservedXcmpWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 4;534}535536impl cumulus_pallet_parachain_system::Config for Runtime {537 type Event = Event;538 type OnValidationData = ();539 type SelfParaId = parachain_info::Pallet<Self>;540 // type DownwardMessageHandlers = cumulus_primitives_utility::UnqueuedDmpAsParent<541 // MaxDownwardMessageWeight,542 // XcmExecutor<XcmConfig>,543 // Call,544 // >;545 type OutboundXcmpMessageSource = XcmpQueue;546 type DmpMessageHandler = DmpQueue;547 type ReservedDmpWeight = ReservedDmpWeight;548 type ReservedXcmpWeight = ReservedXcmpWeight;549 type XcmpMessageHandler = XcmpQueue;550}551552impl parachain_info::Config for Runtime {}553554impl cumulus_pallet_aura_ext::Config for Runtime {}555556parameter_types! {557 pub const RelayLocation: MultiLocation = MultiLocation::parent();558 pub const RelayNetwork: NetworkId = NetworkId::Polkadot;559 pub RelayOrigin: Origin = cumulus_pallet_xcm::Origin::Relay.into();560 pub Ancestry: MultiLocation = Parachain(ParachainInfo::parachain_id().into()).into();561}562563/// Type for specifying how a `MultiLocation` can be converted into an `AccountId`. This is used564/// when determining ownership of accounts for asset transacting and when attempting to use XCM565/// `Transact` in order to determine the dispatch Origin.566pub type LocationToAccountId = (567 // The parent (Relay-chain) origin converts to the default `AccountId`.568 ParentIsDefault<AccountId>,569 // Sibling parachain origins convert to AccountId via the `ParaId::into`.570 SiblingParachainConvertsVia<Sibling, AccountId>,571 // Straight up local `AccountId32` origins just alias directly to `AccountId`.572 AccountId32Aliases<RelayNetwork, AccountId>,573);574575/// Means for transacting assets on this chain.576pub type LocalAssetTransactor = CurrencyAdapter<577 // Use this currency:578 Balances,579 // Use this currency when it is a fungible asset matching the given location or name:580 IsConcrete<RelayLocation>,581 // Do a simple punn to convert an AccountId32 MultiLocation into a native chain account ID:582 LocationToAccountId,583 // Our chain's account ID type (we can't get away without mentioning it explicitly):584 AccountId,585 // We don't track any teleports.586 (),587>;588589/// This is the type we use to convert an (incoming) XCM origin into a local `Origin` instance,590/// ready for dispatching a transaction with Xcm's `Transact`. There is an `OriginKind` which can591/// biases the kind of local `Origin` it will become.592pub type XcmOriginToTransactDispatchOrigin = (593 // Sovereign account converter; this attempts to derive an `AccountId` from the origin location594 // using `LocationToAccountId` and then turn that into the usual `Signed` origin. Useful for595 // foreign chains who want to have a local sovereign account on this chain which they control.596 SovereignSignedViaLocation<LocationToAccountId, Origin>,597 // Native converter for Relay-chain (Parent) location; will converts to a `Relay` origin when598 // recognised.599 RelayChainAsNative<RelayOrigin, Origin>,600 // Native converter for sibling Parachains; will convert to a `SiblingPara` origin when601 // recognised.602 SiblingParachainAsNative<cumulus_pallet_xcm::Origin, Origin>,603 // Superuser converter for the Relay-chain (Parent) location. This will allow it to issue a604 // transaction from the Root origin.605 ParentAsSuperuser<Origin>,606 // Native signed account converter; this just converts an `AccountId32` origin into a normal607 // `Origin::Signed` origin of the same 32-byte value.608 SignedAccountId32AsNative<RelayNetwork, Origin>,609 // Xcm origins can be represented natively under the Xcm pallet's Xcm origin.610 XcmPassthrough<Origin>,611);612613parameter_types! {614 // One XCM operation is 1_000_000 weight - almost certainly a conservative estimate.615 pub UnitWeightCost: Weight = 1_000_000;616 // 1200 UNIQUEs buy 1 second of weight.617 pub const WeightPrice: (MultiLocation, u128) = (MultiLocation::parent(), 1_200 * UNIQUE);618 pub const MaxInstructions: u32 = 100;619 pub const MaxAuthorities: u32 = 100_000;620}621622match_type! {623 pub type ParentOrParentsUnitPlurality: impl Contains<MultiLocation> = {624 MultiLocation { parents: 1, interior: Here } |625 MultiLocation { parents: 1, interior: X1(Plurality { id: BodyId::Unit, .. }) }626 };627}628629pub type Barrier = (630 TakeWeightCredit,631 AllowTopLevelPaidExecutionFrom<Everything>,632 AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,633 // ^^^ Parent & its unit plurality gets free execution634);635636pub struct XcmConfig;637impl Config for XcmConfig {638 type Call = Call;639 type XcmSender = XcmRouter;640 // How to withdraw and deposit an asset.641 type AssetTransactor = LocalAssetTransactor;642 type OriginConverter = XcmOriginToTransactDispatchOrigin;643 type IsReserve = NativeAsset;644 type IsTeleporter = (); // Teleportation is disabled645 type LocationInverter = LocationInverter<Ancestry>;646 type Barrier = Barrier;647 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;648 type Trader = UsingComponents<IdentityFee<Balance>, RelayLocation, AccountId, Balances, ()>;649 type ResponseHandler = (); // Don't handle responses for now.650 type SubscriptionService = PolkadotXcm;651652 type AssetTrap = PolkadotXcm;653 type AssetClaims = PolkadotXcm;654}655656// parameter_types! {657// pub const MaxDownwardMessageWeight: Weight = MAXIMUM_BLOCK_WEIGHT / 10;658// }659660/// No local origins on this chain are allowed to dispatch XCM sends/executions.661pub type LocalOriginToLocation = (SignedToAccountId32<Origin, AccountId, RelayNetwork>,);662663/// The means for routing XCM messages which are not for local execution into the right message664/// queues.665pub type XcmRouter = (666 // Two routers - use UMP to communicate with the relay chain:667 cumulus_primitives_utility::ParentAsUmp<ParachainSystem, ()>,668 // ..and XCMP to communicate with the sibling chains.669 XcmpQueue,670);671672impl pallet_evm_coder_substrate::Config for Runtime {673 type EthereumTransactionSender = pallet_ethereum::Pallet<Self>;674}675676impl pallet_xcm::Config for Runtime {677 type Event = Event;678 type SendXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;679 type XcmRouter = XcmRouter;680 type ExecuteXcmOrigin = EnsureXcmOrigin<Origin, LocalOriginToLocation>;681 type XcmExecuteFilter = Everything;682 type XcmExecutor = XcmExecutor<XcmConfig>;683 type XcmTeleportFilter = Everything;684 type XcmReserveTransferFilter = Everything;685 type Weigher = FixedWeightBounds<UnitWeightCost, Call, MaxInstructions>;686 type LocationInverter = LocationInverter<Ancestry>;687 type Origin = Origin;688 type Call = Call;689 const VERSION_DISCOVERY_QUEUE_SIZE: u32 = 100;690 type AdvertisedXcmVersion = pallet_xcm::CurrentXcmVersion;691}692693impl cumulus_pallet_xcm::Config for Runtime {694 type Event = Event;695 type XcmExecutor = XcmExecutor<XcmConfig>;696}697698impl cumulus_pallet_xcmp_queue::Config for Runtime {699 type Event = Event;700 type XcmExecutor = XcmExecutor<XcmConfig>;701 type ChannelInfo = ParachainSystem;702 type VersionWrapper = ();703}704705impl cumulus_pallet_dmp_queue::Config for Runtime {706 type Event = Event;707 type XcmExecutor = XcmExecutor<XcmConfig>;708 type ExecuteOverweightOrigin = frame_system::EnsureRoot<AccountId>;709}710711impl pallet_aura::Config for Runtime {712 type AuthorityId = AuraId;713 type DisabledValidators = ();714 type MaxAuthorities = MaxAuthorities;715}716717parameter_types! {718 pub TreasuryAccountId: AccountId = TreasuryModuleId::get().into_account();719 pub const CollectionCreationPrice: Balance = 100 * UNIQUE;720}721722impl pallet_common::Config for Runtime {723 type Event = Event;724 type EvmBackwardsAddressMapping = pallet_common::account::MapBackwardsAddressTruncated;725 type EvmAddressMapping = HashedAddressMapping<Self::Hashing>;726 type CrossAccountId = pallet_common::account::BasicCrossAccountId<Self>;727728 type Currency = Balances;729 type CollectionCreationPrice = CollectionCreationPrice;730 type TreasuryAccountId = TreasuryAccountId;731}732733impl pallet_fungible::Config for Runtime {734 type WeightInfo = pallet_fungible::weights::SubstrateWeight<Self>;735}736impl pallet_refungible::Config for Runtime {737 type WeightInfo = pallet_refungible::weights::SubstrateWeight<Self>;738}739impl pallet_nonfungible::Config for Runtime {740 type WeightInfo = pallet_nonfungible::weights::SubstrateWeight<Self>;741}742743/// Used for the pallet nft in `./nft.rs`744impl pallet_nft::Config for Runtime {745 type WeightInfo = pallet_nft::weights::SubstrateWeight<Self>;746}747748parameter_types! {749 pub const InflationBlockInterval: BlockNumber = 100; // every time per how many blocks inflation is applied750}751752/// Used for the pallet inflation753impl pallet_inflation::Config for Runtime {754 type Currency = Balances;755 type TreasuryAccountId = TreasuryAccountId;756 type InflationBlockInterval = InflationBlockInterval;757}758759parameter_types! {760 pub MaximumSchedulerWeight: Weight = Perbill::from_percent(50) *761 RuntimeBlockWeights::get().max_block;762 pub const MaxScheduledPerBlock: u32 = 50;763}764765pub struct Sponsoring;766impl SponsoringResolve<AccountId, Call> for Sponsoring {767 fn resolve(who: &AccountId, call: &Call) -> Option<AccountId>768 where769 Call: Dispatchable<Info = DispatchInfo>,770 AccountId: AsRef<[u8]>,771 {772 pallet_nft_transaction_payment::Module::<Runtime>::withdraw_type(who, call)773 }774}775776type SponsorshipHandler = (777 pallet_nft::NftSponsorshipHandler<Runtime>,778 //pallet_contract_helpers::ContractSponsorshipHandler<Runtime>,779);780781impl pallet_unq_scheduler::Config for Runtime {782 type Event = Event;783 type Origin = Origin;784 type PalletsOrigin = OriginCaller;785 type Call = Call;786 type MaximumWeight = MaximumSchedulerWeight;787 type ScheduleOrigin = EnsureSigned<AccountId>;788 type MaxScheduledPerBlock = MaxScheduledPerBlock;789 type SponsorshipHandler = SponsorshipHandler;790 type WeightInfo = ();791}792793impl pallet_nft_transaction_payment::Config for Runtime {794 type SponsorshipHandler = SponsorshipHandler;795}796797impl pallet_evm_transaction_payment::Config for Runtime {798 type SponsorshipHandler = (799 pallet_nft::NftEthSponsorshipHandler<Self>,800 pallet_evm_contract_helpers::HelpersContractSponsoring<Self>,801 );802 type Currency = Balances;803}804805impl pallet_nft_charge_transaction::Config for Runtime {806 type SponsorshipHandler = pallet_nft::NftSponsorshipHandler<Runtime>;807}808809// impl pallet_contract_helpers::Config for Runtime {810// type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;811// }812813parameter_types! {814 // 0x842899ECF380553E8a4de75bF534cdf6fBF64049815 pub const HelpersContractAddress: H160 = H160([816 0x84, 0x28, 0x99, 0xec, 0xf3, 0x80, 0x55, 0x3e, 0x8a, 0x4d, 0xe7, 0x5b, 0xf5, 0x34, 0xcd, 0xf6, 0xfb, 0xf6, 0x40, 0x49,817 ]);818}819820impl pallet_evm_contract_helpers::Config for Runtime {821 type ContractAddress = HelpersContractAddress;822 type DefaultSponsoringRateLimit = DefaultSponsoringRateLimit;823}824825construct_runtime!(826 pub enum Runtime where827 Block = Block,828 NodeBlock = opaque::Block,829 UncheckedExtrinsic = UncheckedExtrinsic830 {831 ParachainSystem: cumulus_pallet_parachain_system::{Pallet, Call, Storage, Inherent, Event<T>, ValidateUnsigned} = 20,832 ParachainInfo: parachain_info::{Pallet, Storage, Config} = 21,833834 Aura: pallet_aura::{Pallet, Config<T>} = 22,835 AuraExt: cumulus_pallet_aura_ext::{Pallet, Config} = 23,836837 Balances: pallet_balances::{Pallet, Call, Storage, Config<T>, Event<T>} = 30,838 RandomnessCollectiveFlip: pallet_randomness_collective_flip::{Pallet, Storage} = 31,839 Timestamp: pallet_timestamp::{Pallet, Call, Storage, Inherent} = 32,840 TransactionPayment: pallet_transaction_payment::{Pallet, Storage} = 33,841 Treasury: pallet_treasury::{Pallet, Call, Storage, Config, Event<T>} = 34,842 Sudo: pallet_sudo::{Pallet, Call, Storage, Config<T>, Event<T>} = 35,843 System: system::{Pallet, Call, Storage, Config, Event<T>} = 36,844 Vesting: pallet_vesting::{Pallet, Call, Config<T>, Storage, Event<T>} = 37,845 // Contracts: pallet_contracts::{Pallet, Call, Storage, Event<T>} = 38,846847 // XCM helpers.848 XcmpQueue: cumulus_pallet_xcmp_queue::{Pallet, Call, Storage, Event<T>} = 50,849 PolkadotXcm: pallet_xcm::{Pallet, Call, Event<T>, Origin} = 51,850 CumulusXcm: cumulus_pallet_xcm::{Pallet, Call, Event<T>, Origin} = 52,851 DmpQueue: cumulus_pallet_dmp_queue::{Pallet, Call, Storage, Event<T>} = 53,852853 // Unique Pallets854 Inflation: pallet_inflation::{Pallet, Call, Storage} = 60,855 Nft: pallet_nft::{Pallet, Call, Storage} = 61,856 Scheduler: pallet_unq_scheduler::{Pallet, Call, Storage, Event<T>} = 62,857 NftPayment: pallet_nft_transaction_payment::{Pallet, Call, Storage} = 63,858 Charging: pallet_nft_charge_transaction::{Pallet, Call, Storage } = 64,859 // ContractHelpers: pallet_contract_helpers::{Pallet, Call, Storage} = 65,860 Common: pallet_common::{Pallet, Storage, Event<T>} = 66,861 Fungible: pallet_fungible::{Pallet, Storage} = 67,862 Refungible: pallet_refungible::{Pallet, Storage} = 68,863 Nonfungible: pallet_nonfungible::{Pallet, Storage} = 69,864865 // Frontier866 EVM: pallet_evm::{Pallet, Config, Call, Storage, Event<T>} = 100,867 Ethereum: pallet_ethereum::{Pallet, Config, Call, Storage, Event, Origin} = 101,868869 EvmCoderSubstrate: pallet_evm_coder_substrate::{Pallet, Storage} = 150,870 EvmContractHelpers: pallet_evm_contract_helpers::{Pallet, Storage} = 151,871 EvmTransactionPayment: pallet_evm_transaction_payment::{Pallet} = 152,872 EvmMigration: pallet_evm_migration::{Pallet, Call, Storage} = 153,873 }874);875876pub struct TransactionConverter;877878impl fp_rpc::ConvertTransaction<UncheckedExtrinsic> for TransactionConverter {879 fn convert_transaction(&self, transaction: pallet_ethereum::Transaction) -> UncheckedExtrinsic {880 UncheckedExtrinsic::new_unsigned(881 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),882 )883 }884}885886impl fp_rpc::ConvertTransaction<opaque::UncheckedExtrinsic> for TransactionConverter {887 fn convert_transaction(888 &self,889 transaction: pallet_ethereum::Transaction,890 ) -> opaque::UncheckedExtrinsic {891 let extrinsic = UncheckedExtrinsic::new_unsigned(892 pallet_ethereum::Call::<Runtime>::transact { transaction }.into(),893 );894 let encoded = extrinsic.encode();895 opaque::UncheckedExtrinsic::decode(&mut &encoded[..])896 .expect("Encoded extrinsic is always valid")897 }898}899900/// The address format for describing accounts.901pub type Address = sp_runtime::MultiAddress<AccountId, ()>;902/// Block header type as expected by this runtime.903pub type Header = generic::Header<BlockNumber, BlakeTwo256>;904/// Block type as expected by this runtime.905pub type Block = generic::Block<Header, UncheckedExtrinsic>;906/// A Block signed with a Justification907pub type SignedBlock = generic::SignedBlock<Block>;908/// BlockId type as expected by this runtime.909pub type BlockId = generic::BlockId<Block>;910/// The SignedExtension to the basic transaction logic.911pub type SignedExtra = (912 system::CheckSpecVersion<Runtime>,913 // system::CheckTxVersion<Runtime>,914 system::CheckGenesis<Runtime>,915 system::CheckEra<Runtime>,916 system::CheckNonce<Runtime>,917 system::CheckWeight<Runtime>,918 pallet_nft_charge_transaction::ChargeTransactionPayment<Runtime>,919 //pallet_contract_helpers::ContractHelpersExtension<Runtime>,920);921/// Unchecked extrinsic type as expected by this runtime.922pub type UncheckedExtrinsic =923 fp_self_contained::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;924/// Extrinsic type that has already been checked.925pub type CheckedExtrinsic = fp_self_contained::CheckedExtrinsic<AccountId, Call, SignedExtra, H160>;926/// Executive: handles dispatch to the various modules.927pub type Executive = frame_executive::Executive<928 Runtime,929 Block,930 frame_system::ChainContext<Runtime>,931 Runtime,932 AllPallets,933>;934935impl_opaque_keys! {936 pub struct SessionKeys {937 pub aura: Aura,938 }939}940941impl fp_self_contained::SelfContainedCall for Call {942 type SignedInfo = H160;943944 fn is_self_contained(&self) -> bool {945 match self {946 Call::Ethereum(call) => call.is_self_contained(),947 _ => false,948 }949 }950951 fn check_self_contained(&self) -> Option<Result<Self::SignedInfo, TransactionValidityError>> {952 match self {953 Call::Ethereum(call) => call.check_self_contained(),954 _ => None,955 }956 }957958 fn validate_self_contained(&self, info: &Self::SignedInfo) -> Option<TransactionValidity> {959 match self {960 Call::Ethereum(call) => call.validate_self_contained(info),961 _ => None,962 }963 }964965 fn pre_dispatch_self_contained(966 &self,967 info: &Self::SignedInfo,968 ) -> Option<Result<(), TransactionValidityError>> {969 match self {970 Call::Ethereum(call) => call.pre_dispatch_self_contained(info),971 _ => None,972 }973 }974975 fn apply_self_contained(976 self,977 info: Self::SignedInfo,978 ) -> Option<sp_runtime::DispatchResultWithInfo<PostDispatchInfoOf<Self>>> {979 match self {980 call @ Call::Ethereum(pallet_ethereum::Call::transact { .. }) => Some(call.dispatch(981 Origin::from(pallet_ethereum::RawOrigin::EthereumTransaction(info)),982 )),983 _ => None,984 }985 }986}987988macro_rules! dispatch_nft_runtime {989 ($collection:ident.$method:ident($($name:ident),*)) => {{990 use pallet_nft::dispatch::Dispatched;991992 let collection = Dispatched::dispatch(<pallet_common::CollectionHandle<Runtime>>::new($collection).unwrap());993 let dispatch = collection.as_dyn();994995 dispatch.$method($($name),*)996 }};997}998impl_runtime_apis! {999 impl up_rpc::NftApi<Block, CrossAccountId, AccountId>1000 for Runtime1001 {1002 fn account_tokens(collection: CollectionId, account: CrossAccountId) -> Vec<TokenId> {1003 dispatch_nft_runtime!(collection.account_tokens(account))1004 }1005 fn token_exists(collection: CollectionId, token: TokenId) -> bool {1006 dispatch_nft_runtime!(collection.token_exists(token))1007 }10081009 fn token_owner(collection: CollectionId, token: TokenId) -> CrossAccountId {1010 dispatch_nft_runtime!(collection.token_owner(token))1011 }1012 fn const_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1013 dispatch_nft_runtime!(collection.const_metadata(token))1014 }1015 fn variable_metadata(collection: CollectionId, token: TokenId) -> Vec<u8> {1016 dispatch_nft_runtime!(collection.variable_metadata(token))1017 }10181019 fn collection_tokens(collection: CollectionId) -> u32 {1020 dispatch_nft_runtime!(collection.collection_tokens())1021 }1022 fn account_balance(collection: CollectionId, account: CrossAccountId) -> u32 {1023 dispatch_nft_runtime!(collection.account_balance(account))1024 }1025 fn balance(collection: CollectionId, account: CrossAccountId, token: TokenId) -> u128 {1026 dispatch_nft_runtime!(collection.balance(account, token))1027 }1028 fn allowance(1029 collection: CollectionId,1030 sender: CrossAccountId,1031 spender: CrossAccountId,1032 token: TokenId,1033 ) -> u128 {1034 dispatch_nft_runtime!(collection.allowance(sender, spender, token))1035 }10361037 fn eth_contract_code(account: H160) -> Option<Vec<u8>> {1038 <pallet_nft::NftErcSupport<Runtime>>::get_code(&account).or_else(|| <pallet_evm_migration::OnMethodCall<Runtime>>::get_code(&account)).or_else(|| <pallet_evm_contract_helpers::HelpersOnMethodCall<Self>>::get_code(&account))1039 }1040 fn adminlist(collection: CollectionId) -> Vec<AccountId> {1041 <pallet_nft::Pallet<Runtime>>::adminlist(collection)1042 }1043 fn allowlist(collection: CollectionId) -> Vec<AccountId> {1044 <pallet_nft::Pallet<Runtime>>::allowlist(collection)1045 }1046 fn last_token_id(collection: CollectionId) -> TokenId {1047 dispatch_nft_runtime!(collection.last_token_id())1048 }1049 }10501051 impl sp_api::Core<Block> for Runtime {1052 fn version() -> RuntimeVersion {1053 VERSION1054 }10551056 fn execute_block(block: Block) {1057 Executive::execute_block(block)1058 }10591060 fn initialize_block(header: &<Block as BlockT>::Header) {1061 Executive::initialize_block(header)1062 }1063 }10641065 impl sp_api::Metadata<Block> for Runtime {1066 fn metadata() -> OpaqueMetadata {1067 OpaqueMetadata::new(Runtime::metadata().into())1068 }1069 }10701071 impl sp_block_builder::BlockBuilder<Block> for Runtime {1072 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {1073 Executive::apply_extrinsic(extrinsic)1074 }10751076 fn finalize_block() -> <Block as BlockT>::Header {1077 Executive::finalize_block()1078 }10791080 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {1081 data.create_extrinsics()1082 }10831084 fn check_inherents(1085 block: Block,1086 data: sp_inherents::InherentData,1087 ) -> sp_inherents::CheckInherentsResult {1088 data.check_extrinsics(&block)1089 }10901091 // fn random_seed() -> <Block as BlockT>::Hash {1092 // RandomnessCollectiveFlip::random_seed().01093 // }1094 }10951096 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {1097 fn validate_transaction(1098 source: TransactionSource,1099 tx: <Block as BlockT>::Extrinsic,1100 hash: <Block as BlockT>::Hash,1101 ) -> TransactionValidity {1102 Executive::validate_transaction(source, tx, hash)1103 }1104 }11051106 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {1107 fn offchain_worker(header: &<Block as BlockT>::Header) {1108 Executive::offchain_worker(header)1109 }1110 }11111112 impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {1113 fn chain_id() -> u64 {1114 <Runtime as pallet_evm::Config>::ChainId::get()1115 }11161117 fn account_basic(address: H160) -> EVMAccount {1118 EVM::account_basic(&address)1119 }11201121 fn gas_price() -> U256 {1122 <Runtime as pallet_evm::Config>::FeeCalculator::min_gas_price()1123 }11241125 fn account_code_at(address: H160) -> Vec<u8> {1126 EVM::account_codes(address)1127 }11281129 fn author() -> H160 {1130 <pallet_evm::Pallet<Runtime>>::find_author()1131 }11321133 fn storage_at(address: H160, index: U256) -> H256 {1134 let mut tmp = [0u8; 32];1135 index.to_big_endian(&mut tmp);1136 EVM::account_storages(address, H256::from_slice(&tmp[..]))1137 }11381139 fn call(1140 from: H160,1141 to: H160,1142 data: Vec<u8>,1143 value: U256,1144 gas_limit: U256,1145 gas_price: Option<U256>,1146 nonce: Option<U256>,1147 estimate: bool,1148 ) -> Result<pallet_evm::CallInfo, sp_runtime::DispatchError> {1149 let config = if estimate {1150 let mut config = <Runtime as pallet_evm::Config>::config().clone();1151 config.estimate = true;1152 Some(config)1153 } else {1154 None1155 };11561157 <Runtime as pallet_evm::Config>::Runner::call(1158 from,1159 to,1160 data,1161 value,1162 gas_limit.low_u64(),1163 gas_price,1164 nonce,1165 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1166 ).map_err(|err| err.into())1167 }11681169 fn create(1170 from: H160,1171 data: Vec<u8>,1172 value: U256,1173 gas_limit: U256,1174 gas_price: Option<U256>,1175 nonce: Option<U256>,1176 estimate: bool,1177 ) -> Result<pallet_evm::CreateInfo, sp_runtime::DispatchError> {1178 let config = if estimate {1179 let mut config = <Runtime as pallet_evm::Config>::config().clone();1180 config.estimate = true;1181 Some(config)1182 } else {1183 None1184 };11851186 <Runtime as pallet_evm::Config>::Runner::create(1187 from,1188 data,1189 value,1190 gas_limit.low_u64(),1191 gas_price,1192 nonce,1193 config.as_ref().unwrap_or_else(|| <Runtime as pallet_evm::Config>::config()),1194 ).map_err(|err| err.into())1195 }11961197 fn current_transaction_statuses() -> Option<Vec<TransactionStatus>> {1198 Ethereum::current_transaction_statuses()1199 }12001201 fn current_block() -> Option<pallet_ethereum::Block> {1202 Ethereum::current_block()1203 }12041205 fn current_receipts() -> Option<Vec<pallet_ethereum::Receipt>> {1206 Ethereum::current_receipts()1207 }12081209 fn current_all() -> (1210 Option<pallet_ethereum::Block>,1211 Option<Vec<pallet_ethereum::Receipt>>,1212 Option<Vec<TransactionStatus>>1213 ) {1214 (1215 Ethereum::current_block(),1216 Ethereum::current_receipts(),1217 Ethereum::current_transaction_statuses()1218 )1219 }12201221 fn extrinsic_filter(xts: Vec<<Block as sp_api::BlockT>::Extrinsic>) -> Vec<pallet_ethereum::Transaction> {1222 xts.into_iter().filter_map(|xt| match xt.0.function {1223 Call::Ethereum(pallet_ethereum::Call::transact { transaction }) => Some(transaction),1224 _ => None1225 }).collect()1226 }1227 }12281229 impl sp_session::SessionKeys<Block> for Runtime {1230 fn decode_session_keys(1231 encoded: Vec<u8>,1232 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {1233 SessionKeys::decode_into_raw_public_keys(&encoded)1234 }12351236 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {1237 SessionKeys::generate(seed)1238 }1239 }12401241 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {1242 fn slot_duration() -> sp_consensus_aura::SlotDuration {1243 sp_consensus_aura::SlotDuration::from_millis(Aura::slot_duration())1244 }12451246 fn authorities() -> Vec<AuraId> {1247 Aura::authorities().to_vec()1248 }1249 }12501251 impl cumulus_primitives_core::CollectCollationInfo<Block> for Runtime {1252 fn collect_collation_info() -> cumulus_primitives_core::CollationInfo {1253 ParachainSystem::collect_collation_info()1254 }1255 }12561257 impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Index> for Runtime {1258 fn account_nonce(account: AccountId) -> Index {1259 System::account_nonce(account)1260 }1261 }12621263 impl pallet_transaction_payment_rpc_runtime_api::TransactionPaymentApi<Block, Balance> for Runtime {1264 fn query_info(uxt: <Block as BlockT>::Extrinsic, len: u32) -> RuntimeDispatchInfo<Balance> {1265 TransactionPayment::query_info(uxt, len)1266 }1267 fn query_fee_details(uxt: <Block as BlockT>::Extrinsic, len: u32) -> FeeDetails<Balance> {1268 TransactionPayment::query_fee_details(uxt, len)1269 }1270 }12711272 /*1273 impl pallet_contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber, Hash>1274 for Runtime1275 {1276 fn call(1277 origin: AccountId,1278 dest: AccountId,1279 value: Balance,1280 gas_limit: u64,1281 input_data: Vec<u8>,1282 ) -> pallet_contracts_primitives::ContractExecResult {1283 Contracts::bare_call(origin, dest, value, gas_limit, input_data, false)1284 }12851286 fn instantiate(1287 origin: AccountId,1288 endowment: Balance,1289 gas_limit: u64,1290 code: pallet_contracts_primitives::Code<Hash>,1291 data: Vec<u8>,1292 salt: Vec<u8>,1293 ) -> pallet_contracts_primitives::ContractInstantiateResult<AccountId, BlockNumber>1294 {1295 Contracts::bare_instantiate(origin, endowment, gas_limit, code, data, salt, true, false)1296 }12971298 fn get_storage(1299 address: AccountId,1300 key: [u8; 32],1301 ) -> pallet_contracts_primitives::GetStorageResult {1302 Contracts::get_storage(address, key)1303 }13041305 fn rent_projection(1306 address: AccountId,1307 ) -> pallet_contracts_primitives::RentProjectionResult<BlockNumber> {1308 Contracts::rent_projection(address)1309 }1310 }1311 */13121313 #[cfg(feature = "runtime-benchmarks")]1314 impl frame_benchmarking::Benchmark<Block> for Runtime {1315 fn benchmark_metadata(extra: bool) -> (1316 Vec<frame_benchmarking::BenchmarkList>,1317 Vec<frame_support::traits::StorageInfo>,1318 ) {1319 use frame_benchmarking::{list_benchmark, Benchmarking, BenchmarkList};1320 use frame_support::traits::StorageInfoTrait;13211322 let mut list = Vec::<BenchmarkList>::new();13231324 list_benchmark!(list, extra, pallet_evm_migration, EvmMigration);1325 list_benchmark!(list, extra, pallet_nft, Nft);1326 list_benchmark!(list, extra, pallet_inflation, Inflation);1327 list_benchmark!(list, extra, pallet_fungible, Fungible);1328 list_benchmark!(list, extra, pallet_refungible, Refungible);1329 list_benchmark!(list, extra, pallet_nonfungible, Nonfungible);13301331 let storage_info = AllPalletsWithSystem::storage_info();13321333 return (list, storage_info)1334 }13351336 fn dispatch_benchmark(1337 config: frame_benchmarking::BenchmarkConfig1338 ) -> Result<Vec<frame_benchmarking::BenchmarkBatch>, sp_runtime::RuntimeString> {1339 use frame_benchmarking::{Benchmarking, BenchmarkBatch, add_benchmark, TrackedStorageKey};13401341 let whitelist: Vec<TrackedStorageKey> = vec![1342 // Block Number1343 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac").to_vec().into(),1344 // Total Issuance1345 hex_literal::hex!("c2261276cc9d1f8598ea4b6a74b15c2f57c875e4cff74148e4628f264b974c80").to_vec().into(),1346 // Execution Phase1347 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef7ff553b5a9862a516939d82b3d3d8661a").to_vec().into(),1348 // Event Count1349 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef70a98fdbe9ce6c55837576c60c7af3850").to_vec().into(),1350 // System Events1351 hex_literal::hex!("26aa394eea5630e07c48ae0c9558cef780d41e5e16056765bc8461851072c9d7").to_vec().into(),1352 ];13531354 let mut batches = Vec::<BenchmarkBatch>::new();1355 let params = (&config, &whitelist);13561357 add_benchmark!(params, batches, pallet_evm_migration, EvmMigration);1358 add_benchmark!(params, batches, pallet_nft, Nft);1359 add_benchmark!(params, batches, pallet_inflation, Inflation);1360 add_benchmark!(params, batches, pallet_fungible, Fungible);1361 add_benchmark!(params, batches, pallet_refungible, Refungible);1362 add_benchmark!(params, batches, pallet_nonfungible, Nonfungible);13631364 if batches.is_empty() { return Err("Benchmark not found for this pallet.".into()) }1365 Ok(batches)1366 }1367 }1368}13691370struct CheckInherents;13711372impl cumulus_pallet_parachain_system::CheckInherents<Block> for CheckInherents {1373 fn check_inherents(1374 block: &Block,1375 relay_state_proof: &cumulus_pallet_parachain_system::RelayChainStateProof,1376 ) -> sp_inherents::CheckInherentsResult {1377 let relay_chain_slot = relay_state_proof1378 .read_slot()1379 .expect("Could not read the relay chain slot from the proof");13801381 let inherent_data =1382 cumulus_primitives_timestamp::InherentDataProvider::from_relay_chain_slot_and_duration(1383 relay_chain_slot,1384 sp_std::time::Duration::from_secs(6),1385 )1386 .create_inherent_data()1387 .expect("Could not create the timestamp inherent data");13881389 inherent_data.check_extrinsics(block)1390 }1391}13921393cumulus_pallet_parachain_system::register_validate_block!(1394 Runtime = Runtime,1395 BlockExecutor = cumulus_pallet_aura_ext::BlockExecutor::<Runtime, Executive>,1396 CheckInherents = CheckInherents,1397);tests/.eslintrc.jsondiffbeforeafterboth--- a/tests/.eslintrc.json
+++ b/tests/.eslintrc.json
@@ -63,6 +63,41 @@
{
"destructuring": "all"
}
+ ],
+ "object-curly-spacing": "warn",
+ "arrow-spacing": "warn",
+ "array-bracket-spacing": "warn",
+ "template-curly-spacing": "warn",
+ "space-in-parens": "warn",
+ "@typescript-eslint/naming-convention": [
+ "warn",
+ {
+ "selector": "default",
+ "format": [
+ "camelCase"
+ ],
+ "leadingUnderscore": "allow",
+ "trailingUnderscore": "allow"
+ },
+ {
+ "selector": "variable",
+ "format": [
+ "camelCase",
+ "UPPER_CASE"
+ ],
+ "leadingUnderscore": "allow",
+ "trailingUnderscore": "allow"
+ },
+ {
+ "selector": "typeLike",
+ "format": [
+ "PascalCase"
+ ]
+ },
+ {
+ "selector": "memberLike",
+ "format": null
+ }
]
}
-}
\ No newline at end of file
+}
tests/package.jsondiffbeforeafterboth--- a/tests/package.json
+++ b/tests/package.json
@@ -4,15 +4,15 @@
"description": "Substrate Nft tests",
"main": "",
"devDependencies": {
- "@polkadot/dev": "0.63.9",
+ "@polkadot/dev": "0.63.18",
"@polkadot/ts": "0.4.12",
- "@polkadot/typegen": "6.5.2-3",
+ "@polkadot/typegen": "6.6.2-5",
"@types/chai": "^4.2.22",
"@types/chai-as-promised": "^7.1.4",
"@types/mocha": "^9.0.0",
- "@types/node": "^16.11.4",
- "@typescript-eslint/eslint-plugin": "^5.1.0",
- "@typescript-eslint/parser": "^5.1.0",
+ "@types/node": "^16.11.6",
+ "@typescript-eslint/eslint-plugin": "^5.3.0",
+ "@typescript-eslint/parser": "^5.3.0",
"chai": "^4.3.4",
"eslint": "^8.1.0",
"mocha": "^9.1.3",
@@ -29,6 +29,7 @@
"fix": "eslint --ext .ts,.js src/ --fix",
"test": "mocha --timeout 9999999 -r ts-node/register './**/*.test.ts'",
"testEth": "mocha --timeout 9999999 -r ts-node/register './**/eth/**/*.test.ts'",
+ "testEthMarketplace": "mocha --timeout 9999999 -r ts-node/register './**/eth/marketplace/**/*.test.ts'",
"load": "mocha --timeout 9999999 -r ts-node/register './**/*.load.ts'",
"loadTransfer": "ts-node src/transfer.nload.ts",
"testCollision": "mocha --timeout 9999999 -r ts-node/register ./src/collision-tests/*.test.ts",
@@ -65,15 +66,18 @@
"testInflation": "mocha --timeout 9999999 -r ts-node/register ./**/inflation.test.ts",
"testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",
"testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",
- "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts"
+ "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",
+ "polkadot-types-from-defs": "ts-node ./node_modules/.bin/polkadot-types-from-defs --input src/interfaces/ --package .",
+ "polkadot-types-from-chain": "ts-node ./node_modules/.bin/polkadot-types-from-chain --endpoint ws://localhost:9944 --output src/interfaces/ --package .",
+ "polkadot-types": "yarn polkadot-types-from-defs && yarn polkadot-types-from-chain"
},
"author": "",
"license": "SEE LICENSE IN ../LICENSE",
"homepage": "",
"dependencies": {
- "@polkadot/api": "6.5.1",
- "@polkadot/api-contract": "6.5.1",
- "@polkadot/util-crypto": "^7.6.1",
+ "@polkadot/api": "6.6.2-5",
+ "@polkadot/api-contract": "6.6.2-5",
+ "@polkadot/util-crypto": "^7.7.1",
"bignumber.js": "^9.0.1",
"chai-as-promised": "^7.1.1",
"solc": "^0.8.9",
tests/src/addCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/addCollectionAdmin.test.ts
+++ b/tests/src/addCollectionAdmin.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
+import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, normalizeAccountId} from './util/helpers';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {addCollectionAdminExpectSuccess, createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId} from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -20,38 +20,38 @@
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.equal(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.equal(alice.address);
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
await submitTransactionAsync(alice, changeAdminTx);
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
- expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(bob.address));
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));
});
});
it('Add admin using added collection admin.', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
- const Charlie = privateKey('//CHARLIE');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+ const charlie = privateKey('//CHARLIE');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.equal(Alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.equal(alice.address);
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Alice, changeAdminTx);
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(alice, changeAdminTx);
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
- expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(Bob.address));
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));
- const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));
- await submitTransactionAsync(Bob, changeAdminTxCharlie);
- const adminListAfterAddNewAdmin: any = (await api.query.nft.adminList(collectionId));
- expect(adminListAfterAddNewAdmin).to.be.contains(normalizeAccountId(Bob.address));
- expect(adminListAfterAddNewAdmin).to.be.contains(normalizeAccountId(Charlie.address));
+ const changeAdminTxCharlie = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));
+ await submitTransactionAsync(bob, changeAdminTxCharlie);
+ const adminListAfterAddNewAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddNewAdmin).to.be.deep.contains(normalizeAccountId(bob.address));
+ expect(adminListAfterAddNewAdmin).to.be.deep.contains(normalizeAccountId(charlie.address));
});
});
});
@@ -66,8 +66,8 @@
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(alice.address));
await expect(submitTransactionExpectFailAsync(nonOwner, changeAdminTx)).to.be.rejected;
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
- expect(adminListAfterAddAdmin).not.to.be.contains(normalizeAccountId(alice.address));
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).not.to.be.deep.contains(normalizeAccountId(alice.address));
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
@@ -91,11 +91,11 @@
it("Can't add an admin to a destroyed collection.", async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
await destroyCollectionExpectSuccess(collectionId);
- const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
+ const changeOwnerTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
@@ -104,30 +104,29 @@
it('Add an admin to a collection that has reached the maximum number of admins limit', async () => {
await usingApi(async (api: ApiPromise) => {
- const Alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
const accounts = [
- 'GsvVmjr1CBHwQHw84pPHMDxgNY3iBLz6Qn7qS3CH8qPhrHz',
- 'FoQJpPyadYccjavVdTWxpxU7rUEaYhfLCPwXgkfD6Zat9QP',
- 'JKspFU6ohf1Grg3Phdzj2pSgWvsYWzSfKghhfzMbdhNBWs5',
- 'Fr4NzY1udSFFLzb2R3qxVQkwz9cZraWkyfH4h3mVVk7BK7P',
- 'DfnTB4z7eUvYRqcGtTpFsLC69o6tvBSC1pEv8vWPZFtCkaK',
- 'HnMAUz7r2G8G3hB27SYNyit5aJmh2a5P4eMdDtACtMFDbam',
- 'DE14BzQ1bDXWPKeLoAqdLAm1GpyAWaWF1knF74cEZeomTBM',
+ privateKey('//AdminTest/1').address,
+ privateKey('//AdminTest/2').address,
+ privateKey('//AdminTest/3').address,
+ privateKey('//AdminTest/4').address,
+ privateKey('//AdminTest/5').address,
+ privateKey('//AdminTest/6').address,
+ privateKey('//AdminTest/7').address,
];
const collectionId = await createCollectionExpectSuccess();
- const chainAdminLimit = (api.consts.nft.collectionAdminsLimit as any).toNumber();
+ const chainAdminLimit = api.consts.common.collectionAdminsLimit.toNumber();
expect(chainAdminLimit).to.be.equal(5);
for (let i = 0; i < chainAdminLimit; i++) {
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(accounts[i]));
- await submitTransactionAsync(Alice, changeAdminTx);
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId));
- expect(adminListAfterAddAdmin).to.be.contains(normalizeAccountId(accounts[i]));
+ await addCollectionAdminExpectSuccess(alice, collectionId, accounts[i]);
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(accounts[i]));
}
const tx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(accounts[chainAdminLimit]));
- await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
});
tests/src/addToContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToContractWhiteList.test.ts
+++ b/tests/src/addToContractWhiteList.test.ts
@@ -5,7 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import privateKey from './substrate/privateKey';
import {
deployFlipper,
tests/src/addToWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/addToWhiteList.test.ts
+++ b/tests/src/addToWhiteList.test.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import usingApi, { submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
addToWhiteListExpectSuccess,
createCollectionExpectSuccess,
@@ -23,30 +23,30 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Charlie: IKeyringPair;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let charlie: IKeyringPair;
describe('Integration Test ext. addToWhiteList()', () => {
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
});
it('Whitelisted minting: list restrictions', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enablePublicMintingExpectSuccess(Alice, collectionId);
- await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enablePublicMintingExpectSuccess(alice, collectionId);
+ await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);
});
});
@@ -55,35 +55,35 @@
it('White list an address in the collection that does not exist', async () => {
await usingApi(async (api) => {
// tslint:disable-next-line: no-bitwise
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
- const Bob = privateKey('//Bob');
+ const collectionId = ((await api.query.common.createdCollectionCount()).toNumber()) + 1;
+ const bob = privateKey('//Bob');
- const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Bob.address));
- await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(bob.address));
+ await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
it('White list an address in the collection that was destroyed', async () => {
await usingApi(async (api) => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
- const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(Bob.address));
- await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(bob.address));
+ await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
it('White list an address in the collection that does not have white list access enabled', async () => {
await usingApi(async (api) => {
- const Alice = privateKey('//Alice');
- const Ferdie = privateKey('//Ferdie');
+ const alice = privateKey('//Alice');
+ const ferdie = privateKey('//Ferdie');
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enablePublicMintingExpectSuccess(Alice, collectionId);
- const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(Ferdie.address), 'NFT');
- await expect(submitTransactionExpectFailAsync(Ferdie, tx)).to.be.rejected;
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enablePublicMintingExpectSuccess(alice, collectionId);
+ const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(ferdie.address), 'NFT');
+ await expect(submitTransactionExpectFailAsync(ferdie, tx)).to.be.rejected;
});
});
@@ -93,32 +93,32 @@
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Negative. Add to the white list by regular user', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectFail(Bob, collectionId, Charlie.address);
+ await addToWhiteListExpectFail(bob, collectionId, charlie.address);
});
it('Execute the extrinsic with parameters: Collection ID and address to add to the white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await addToWhiteListExpectSuccess(Bob, collectionId, Charlie.address);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await addToWhiteListExpectSuccess(bob, collectionId, charlie.address);
});
it('Whitelisted minting: list restrictions', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await addToWhiteListExpectSuccess(Bob, collectionId, Charlie.address);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await addToWhiteListExpectSuccess(bob, collectionId, charlie.address);
// allowed only for collection owner
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enablePublicMintingExpectSuccess(Alice, collectionId);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enablePublicMintingExpectSuccess(alice, collectionId);
- await createItemExpectSuccess(Charlie, collectionId, 'NFT', Charlie.address);
+ await createItemExpectSuccess(charlie, collectionId, 'NFT', charlie.address);
});
-});
\ No newline at end of file
+});
tests/src/approve.test.tsdiffbeforeafterboth--- a/tests/src/approve.test.ts
+++ b/tests/src/approve.test.ts
@@ -2,12 +2,12 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
-import { ApiPromise } from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi } from './substrate/substrate-api';
+import {default as usingApi} from './substrate/substrate-api';
import {
approveExpectFail,
approveExpectSuccess,
@@ -17,90 +17,91 @@
setCollectionLimitsExpectSuccess,
transferExpectSuccess,
addCollectionAdminExpectSuccess,
+ adminApproveFromExpectSuccess,
} from './util/helpers';
chai.use(chaiAsPromised);
describe('Integration Test approve(spender, collection_id, item_id, amount):', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Execute the extrinsic and check approvedList', async () => {
const nftCollectionId = await createCollectionExpectSuccess();
// nft
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
// reFungible
const reFungibleCollectionId =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
});
it('Remove approval by using 0 amount', async () => {
const nftCollectionId = await createCollectionExpectSuccess();
// nft
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 0);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 1);
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address, 0);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 0);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 1);
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 0);
// reFungible
const reFungibleCollectionId =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 1);
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 0);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 1);
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 0);
});
it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
- await approveExpectSuccess(collectionId, itemId, Alice, Charlie);
+ await adminApproveFromExpectSuccess(collectionId, itemId, alice, bob.address, charlie.address);
});
});
describe('Negative Integration Test approve(spender, collection_id, item_id, amount):', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Approve for a collection that does not exist', async () => {
await usingApi(async (api: ApiPromise) => {
// nft
- const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
+ const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
// fungible
- const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);
+ const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
// reFungible
- const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);
+ const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
});
});
@@ -108,95 +109,87 @@
// nft
const nftCollectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(nftCollectionId);
- await approveExpectFail(nftCollectionId, 1, Alice, Bob);
+ await approveExpectFail(nftCollectionId, 1, alice, bob);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
await destroyCollectionExpectSuccess(fungibleCollectionId);
- await approveExpectFail(fungibleCollectionId, 1, Alice, Bob);
+ await approveExpectFail(fungibleCollectionId, 0, alice, bob);
// reFungible
const reFungibleCollectionId =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await destroyCollectionExpectSuccess(reFungibleCollectionId);
- await approveExpectFail(reFungibleCollectionId, 1, Alice, Bob);
+ await approveExpectFail(reFungibleCollectionId, 1, alice, bob);
});
it('Approve transfer of a token that does not exist', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await approveExpectFail(nftCollectionId, 2, Alice, Bob);
+ await approveExpectFail(nftCollectionId, 2, alice, bob);
// reFungible
const reFungibleCollectionId =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- await approveExpectFail(reFungibleCollectionId, 2, Alice, Bob);
+ await approveExpectFail(reFungibleCollectionId, 2, alice, bob);
});
it('Approve using the address that does not own the approved token', async () => {
const nftCollectionId = await createCollectionExpectSuccess();
// nft
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectFail(nftCollectionId, newNftTokenId, bob, alice);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice);
// reFungible
const reFungibleCollectionId =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice);
- });
-
- it('should fail if approved more NFTs than owned', async () => {
- const nftCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice);
- await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, alice);
});
it('should fail if approved more ReFungibles than owned', async () => {
- const nftCollectionId = await createCollectionExpectSuccess({ mode: { type: 'ReFungible' } });
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'ReFungible');
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 100, 'ReFungible');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, 100);
- await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, 1);
+ const nftCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'ReFungible');
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 100, 'ReFungible');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, bob, alice.address, 100);
+ await approveExpectFail(nftCollectionId, newNftTokenId, bob, alice, 101);
});
it('should fail if approved more Fungibles than owned', async () => {
- const nftCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'Fungible');
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 10, 'Fungible');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, 10);
- await approveExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, 1);
+ const nftCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'Fungible');
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 10, 'Fungible');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, bob, alice.address, 10);
+ await approveExpectFail(nftCollectionId, newNftTokenId, bob, alice, 11);
});
it('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { ownerCanTransfer: false });
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: false});
- await approveExpectFail(collectionId, itemId, Alice, Charlie);
+ await approveExpectFail(collectionId, itemId, alice, charlie);
});
});
describe('Integration Test approve(spender, collection_id, item_id, amount) with collection admin permissions:', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('can be called by collection admin on non-owned item', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await approveExpectSuccess(collectionId, itemId, Bob, Charlie);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await adminApproveFromExpectSuccess(collectionId, itemId, bob, alice.address, charlie.address);
});
});
tests/src/block-production.test.tsdiffbeforeafterboth--- a/tests/src/block-production.test.ts
+++ b/tests/src/block-production.test.ts
@@ -4,17 +4,17 @@
//
import usingApi from './substrate/substrate-api';
-import { expect } from 'chai';
-import { ApiPromise } from '@polkadot/api';
+import {expect} from 'chai';
+import {ApiPromise} from '@polkadot/api';
-const BlockTimeMs = 12000;
-const ToleranceMs = 1000;
+const BLOCK_TIME_MS = 12000;
+const TOLERANCE_MS = 3000;
/* eslint no-async-promise-executor: "off" */
function getBlocks(api: ApiPromise): Promise<number[]> {
return new Promise<number[]>(async (resolve, reject) => {
const blockNumbers: number[] = [];
- setTimeout(() => reject('Block production test failed due to timeout.'), BlockTimeMs + ToleranceMs);
+ setTimeout(() => reject('Block production test failed due to timeout.'), BLOCK_TIME_MS + TOLERANCE_MS);
const unsubscribe = await api.rpc.chain.subscribeNewHeads((head: any) => {
blockNumbers.push(head.number.toNumber());
if(blockNumbers.length >= 2) {
tests/src/burnItem.test.tsdiffbeforeafterboth--- a/tests/src/burnItem.test.ts
+++ b/tests/src/burnItem.test.ts
@@ -3,9 +3,9 @@
// file 'LICENSE', which is part of this source code package.
//
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import {
createCollectionExpectSuccess,
createItemExpectSuccess,
@@ -13,6 +13,8 @@
destroyCollectionExpectSuccess,
normalizeAccountId,
addCollectionAdminExpectSuccess,
+ getBalance,
+ isTokenExists,
} from './util/helpers';
import chai from 'chai';
@@ -26,7 +28,7 @@
describe('integration test: ext. burnItem():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -41,19 +43,16 @@
const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(alice, tx);
const result = getGenericResult(events);
- // Get the item
- const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();
- // What to expect
- // tslint:disable-next-line:no-unused-expression
+
expect(result.success).to.be.true;
- // tslint:disable-next-line:no-unused-expression
- expect(item).to.be.null;
+ // Get the item
+ expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;
});
});
it('Burn item in Fungible collection', async () => {
const createMode = 'Fungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
const tokenId = 0; // ignored
@@ -64,18 +63,17 @@
const result = getGenericResult(events);
// Get alice balance
- const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
+ const balance = await getBalance(api, collectionId, alice.address, 0);
// What to expect
expect(result.success).to.be.true;
- expect(balance).to.be.not.null;
- expect(balance.value).to.be.equal(9);
+ expect(balance).to.be.equal(9n);
});
});
it('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -84,11 +82,11 @@
const result = getGenericResult(events);
// Get alice balance
- const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+ const balance = await getBalance(api, collectionId, alice.address, tokenId);
// What to expect
expect(result.success).to.be.true;
- expect(balance).to.be.null;
+ expect(balance).to.be.equal(0n);
});
});
@@ -104,7 +102,8 @@
const result1 = getGenericResult(events1);
// Get balances
- const balanceBefore: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+ const bobBalanceBefore = await getBalance(api, collectionId, bob.address, tokenId);
+ const aliceBalanceBefore = await getBalance(api, collectionId, alice.address, tokenId);
// Bob burns his portion
const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
@@ -112,24 +111,19 @@
const result2 = getGenericResult(events2);
// Get balances
- const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
+ const bobBalanceAfter = await getBalance(api, collectionId, bob.address, tokenId);
+ const aliceBalanceAfter = await getBalance(api, collectionId, alice.address, tokenId);
// console.log(balance);
// What to expect before burning
expect(result1.success).to.be.true;
- expect(balanceBefore).to.be.not.null;
- expect(balanceBefore.owner.length).to.be.equal(2);
- expect(balanceBefore.owner[0].owner).to.be.deep.equal(normalizeAccountId(alice.address));
- expect(balanceBefore.owner[0].fraction).to.be.equal(99);
- expect(balanceBefore.owner[1].owner).to.be.deep.equal(normalizeAccountId(bob.address));
- expect(balanceBefore.owner[1].fraction).to.be.equal(1);
+ expect(aliceBalanceBefore).to.be.equal(99n);
+ expect(bobBalanceBefore).to.be.equal(1n);
// What to expect after burning
expect(result2.success).to.be.true;
- expect(balance).to.be.not.null;
- expect(balance.owner.length).to.be.equal(1);
- expect(balance.owner[0].fraction).to.be.equal(99);
- expect(balance.owner[0].owner).to.be.deep.equal(normalizeAccountId(alice.address));
+ expect(aliceBalanceAfter).to.be.equal(99n);
+ expect(bobBalanceAfter).to.be.equal(0n);
});
});
@@ -139,7 +133,7 @@
describe('integration test: ext. burnItem() with admin permissions:', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -149,28 +143,25 @@
const createMode = 'NFT';
const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await usingApi(async (api) => {
const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const events = await submitTransactionAsync(bob, tx);
const result = getGenericResult(events);
+
+ expect(result.success).to.be.true;
// Get the item
- const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();
- // What to expect
- // tslint:disable-next-line:no-unused-expression
- expect(result.success).to.be.true;
- // tslint:disable-next-line:no-unused-expression
- expect(item).to.be.null;
+ expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;
});
});
-
+ // TODO: burnFrom
it('Burn item in Fungible collection', async () => {
const createMode = 'Fungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode); // Helper creates 10 fungible tokens
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await usingApi(async (api) => {
// Destroy 1 of 10
@@ -179,31 +170,29 @@
const result = getGenericResult(events);
// Get alice balance
- const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
+ const balance = await getBalance(api, collectionId, alice.address, 0);
// What to expect
expect(result.success).to.be.true;
- expect(balance).to.be.not.null;
- expect(balance.value).to.be.equal(9);
+ expect(balance).to.be.equal(9n);
});
});
+ // TODO: burnFrom
it('Burn item in ReFungible collection', async () => {
const createMode = 'ReFungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await usingApi(async (api) => {
const tx = api.tx.nft.burnFrom(collectionId, normalizeAccountId(alice.address), tokenId, 100);
const events = await submitTransactionAsync(bob, tx);
const result = getGenericResult(events);
// Get alice balance
- const balance: any = (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON();
-
- // What to expect
expect(result.success).to.be.true;
- expect(balance).to.be.null;
+ // Get the item
+ expect(await isTokenExists(api, collectionId, tokenId)).to.be.false;
});
});
});
@@ -211,7 +200,7 @@
describe('Negative integration test: ext. burnItem():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -219,7 +208,7 @@
it('Burn a token in a destroyed collection', async () => {
const createMode = 'NFT';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await destroyCollectionExpectSuccess(collectionId);
@@ -235,7 +224,7 @@
it('Burn a token that was never created', async () => {
const createMode = 'NFT';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = 10;
await usingApi(async (api) => {
@@ -250,11 +239,11 @@
it('Burn a token using the address that does not own it', async () => {
const createMode = 'NFT';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
- const tx = api.tx.nft.burnItem(collectionId, tokenId, 0);
+ const tx = api.tx.nft.burnItem(collectionId, tokenId, 1);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(bob, tx);
};
@@ -265,7 +254,7 @@
it('Transfer a burned a token', async () => {
const createMode = 'NFT';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode}});
const tokenId = await createItemExpectSuccess(alice, collectionId, createMode);
await usingApi(async (api) => {
@@ -275,7 +264,7 @@
const result1 = getGenericResult(events1);
expect(result1.success).to.be.true;
- const tx = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 0);
+ const tx = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionId, tokenId, 1);
const badTransaction = async function () {
await submitTransactionExpectFailAsync(alice, tx);
};
@@ -286,7 +275,7 @@
it('Burn more than owned in Fungible collection', async () => {
const createMode = 'Fungible';
- const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
// Helper creates 10 fungible tokens
await createItemExpectSuccess(alice, collectionId, createMode);
const tokenId = 0; // ignored
@@ -300,11 +289,10 @@
await expect(badTransaction()).to.be.rejected;
// Get alice balance
- const balance: any = (await api.query.nft.fungibleItemList(collectionId, alice.address)).toJSON();
+ const balance = await getBalance(api, collectionId, alice.address, 0);
// What to expect
- expect(balance).to.be.not.null;
- expect(balance.value).to.be.equal(10);
+ expect(balance).to.be.equal(10n);
});
});
tests/src/change-collection-owner.test.tsdiffbeforeafterboth--- a/tests/src/change-collection-owner.test.ts
+++ b/tests/src/change-collection-owner.test.ts
@@ -6,8 +6,8 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import { createCollectionExpectSuccess,
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {createCollectionExpectSuccess,
addCollectionAdminExpectSuccess,
setCollectionSponsorExpectSuccess,
confirmSponsorshipExpectSuccess,
@@ -34,14 +34,14 @@
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await submitTransactionAsync(alice, changeOwnerTx);
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(bob.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
});
});
});
@@ -53,8 +53,8 @@
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await submitTransactionAsync(alice, changeOwnerTx);
@@ -62,8 +62,8 @@
const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(bob.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
});
});
@@ -74,14 +74,14 @@
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await submitTransactionAsync(alice, changeOwnerTx);
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(bob.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
// After changing the owner of the collection, all privileged methods are available to the new owner
// The new owner of the collection has access to sponsorship management operations in the collection
@@ -94,7 +94,7 @@
accountTokenOwnershipLimit: 1,
sponsoredMintSize: 1,
tokenLimit: 1,
- sponsorTimeout: 1,
+ sponsorTransferTimeout: 1,
ownerCanTransfer: true,
ownerCanDestroy: true,
};
@@ -118,21 +118,21 @@
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await submitTransactionAsync(alice, changeOwnerTx);
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(bob.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
const changeOwnerTx2 = api.tx.nft.changeCollectionOwner(collectionId, charlie.address);
await submitTransactionAsync(bob, changeOwnerTx2);
// ownership lost
- const collectionAfterOwnerChange2: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange2.owner).to.be.deep.eq(charlie.address);
+ const collectionAfterOwnerChange2 = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange2.owner.toString()).to.be.deep.eq(charlie.address);
});
});
});
@@ -147,8 +147,8 @@
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(alice.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
@@ -161,13 +161,13 @@
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await expect(submitTransactionExpectFailAsync(bob, changeOwnerTx)).to.be.rejected;
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(alice.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(alice.address);
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
@@ -195,8 +195,8 @@
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(alice.address);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
const changeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, bob.address);
await submitTransactionAsync(alice, changeOwnerTx);
@@ -204,8 +204,8 @@
const badChangeOwnerTx = api.tx.nft.changeCollectionOwner(collectionId, alice.address);
await expect(submitTransactionExpectFailAsync(alice, badChangeOwnerTx)).to.be.rejected;
- const collectionAfterOwnerChange: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collectionAfterOwnerChange.owner).to.be.deep.eq(bob.address);
+ const collectionAfterOwnerChange = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collectionAfterOwnerChange.owner.toString()).to.be.deep.eq(bob.address);
await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Alice');
await confirmSponsorshipExpectFailure(collectionId, '//Alice');
@@ -215,7 +215,7 @@
accountTokenOwnershipLimit: 1,
sponsoredMintSize: 1,
tokenLimit: 1,
- sponsorTimeout: 1,
+ sponsorTransferTimeout: 1,
ownerCanTransfer: true,
ownerCanDestroy: true,
};
tests/src/check-event/burnItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/burnItemEvent.test.ts
+++ b/tests/src/check-event/burnItemEvent.test.ts
@@ -4,33 +4,33 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage } from '../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Burn Item event ', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
const checkSection = 'ItemDestroyed';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it('Check event from burnItem(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');
+ const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');
const burnItem = api.tx.nft.burnItem(collectionID, itemID, 1);
- const events = await submitTransactionAsync(Alice, burnItem);
+ const events = await submitTransactionAsync(alice, burnItem);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -38,4 +38,3 @@
});
});
});
-
tests/src/check-event/createCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createCollectionEvent.test.ts
+++ b/tests/src/check-event/createCollectionEvent.test.ts
@@ -4,31 +4,31 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { nftEventMessage } from '../util/helpers';
+import {nftEventMessage} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Create collection event ', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
const checkSection = 'CollectionCreated';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it('Check event from createCollection(): ', async () => {
await usingApi(async (api: ApiPromise) => {
- const tx = api.tx.nft.createCollection('0x31', '0x32', '0x33', 'NFT');
- const events = await submitTransactionAsync(Alice, tx);
+ const tx = api.tx.nft.createCollection([0x31], [0x32], '0x33', 'NFT');
+ const events = await submitTransactionAsync(alice, tx);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -36,4 +36,3 @@
});
});
});
-
\ No newline at end of file
tests/src/check-event/createItemEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createItemEvent.test.ts
+++ b/tests/src/check-event/createItemEvent.test.ts
@@ -4,32 +4,32 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, nftEventMessage, normalizeAccountId } from '../util/helpers';
+import {createCollectionExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Create Item event ', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
const checkSection = 'ItemCreated';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it('Check event from createItem(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const createItem = api.tx.nft.createItem(collectionID, normalizeAccountId(Alice.address), 'NFT');
- const events = await submitTransactionAsync(Alice, createItem);
+ const createItem = api.tx.nft.createItem(collectionID, normalizeAccountId(alice.address), 'NFT');
+ const events = await submitTransactionAsync(alice, createItem);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -37,4 +37,3 @@
});
});
});
-
tests/src/check-event/createMultipleItemsEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/createMultipleItemsEvent.test.ts
+++ b/tests/src/check-event/createMultipleItemsEvent.test.ts
@@ -4,33 +4,33 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, nftEventMessage, normalizeAccountId } from '../util/helpers';
+import {createCollectionExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Create Multiple Items Event event ', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
const checkSection = 'ItemCreated';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it('Check event from createMultipleItems(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
- const createMultipleItems = api.tx.nft.createMultipleItems(collectionID, normalizeAccountId(Alice.address), args);
- const events = await submitTransactionAsync(Alice, createMultipleItems);
+ const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
+ const createMultipleItems = api.tx.nft.createMultipleItems(collectionID, normalizeAccountId(alice.address), args);
+ const events = await submitTransactionAsync(alice, createMultipleItems);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -38,4 +38,3 @@
});
});
});
-
tests/src/check-event/destroyCollectionEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/destroyCollectionEvent.test.ts
+++ b/tests/src/check-event/destroyCollectionEvent.test.ts
@@ -4,35 +4,34 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, nftEventMessage } from '../util/helpers';
+import {createCollectionExpectSuccess, nftEventMessage} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Destroy collection event ', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it('Check event from destroyCollection(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
const destroyCollection = api.tx.nft.destroyCollection(collectionID);
- const events = await submitTransactionAsync(Alice, destroyCollection);
+ const events = await submitTransactionAsync(alice, destroyCollection);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkTreasury);
expect(msg).to.be.contain(checkSystem);
});
});
});
-
tests/src/check-event/transferEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferEvent.test.ts
+++ b/tests/src/check-event/transferEvent.test.ts
@@ -4,35 +4,35 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId } from '../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Transfer event ', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
const checkSection = 'Transfer';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Check event from transfer(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');
- const transfer = api.tx.nft.transfer(normalizeAccountId(Bob.address), collectionID, itemID, 1);
- const events = await submitTransactionAsync(Alice, transfer);
+ const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');
+ const transfer = api.tx.nft.transfer(normalizeAccountId(bob.address), collectionID, itemID, 1);
+ const events = await submitTransactionAsync(alice, transfer);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -40,5 +40,3 @@
});
});
});
-
-
tests/src/check-event/transferFromEvent.test.tsdiffbeforeafterboth--- a/tests/src/check-event/transferFromEvent.test.ts
+++ b/tests/src/check-event/transferFromEvent.test.ts
@@ -4,35 +4,35 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from '../substrate/privateKey';
import usingApi, {submitTransactionAsync} from '../substrate/substrate-api';
-import { createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId } from '../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, nftEventMessage, normalizeAccountId} from '../util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
describe('Transfer from event ', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
const checkSection = 'Transfer';
const checkTreasury = 'Deposit';
const checkSystem = 'ExtrinsicSuccess';
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Check event from transferFrom(): ', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionID = await createCollectionExpectSuccess();
- const itemID = await createItemExpectSuccess(Alice, collectionID, 'NFT');
- const transferFrom = api.tx.nft.transferFrom(normalizeAccountId(Alice.address), normalizeAccountId(Bob.address), collectionID, itemID, 1);
- const events = await submitTransactionAsync(Alice, transferFrom);
+ const itemID = await createItemExpectSuccess(alice, collectionID, 'NFT');
+ const transferFrom = api.tx.nft.transferFrom(normalizeAccountId(alice.address), normalizeAccountId(bob.address), collectionID, itemID, 1);
+ const events = await submitTransactionAsync(alice, transferFrom);
const msg = JSON.stringify(nftEventMessage(events));
expect(msg).to.be.contain(checkSection);
expect(msg).to.be.contain(checkTreasury);
@@ -40,4 +40,3 @@
});
});
});
-
tests/src/collision-tests/admVsOwnerChanges.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerChanges.test.ts
+++ b/tests/src/collision-tests/admVsOwnerChanges.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -50,3 +54,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/admVsOwnerData.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerData.test.ts
+++ b/tests/src/collision-tests/admVsOwnerData.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -46,3 +50,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/admVsOwnerTake.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/admVsOwnerTake.test.ts
+++ b/tests/src/collision-tests/admVsOwnerTake.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -48,3 +52,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/adminDestroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/adminDestroyCollection.test.ts
+++ b/tests/src/collision-tests/adminDestroyCollection.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -47,3 +51,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/adminLimitsOff.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/adminLimitsOff.test.ts
+++ b/tests/src/collision-tests/adminLimitsOff.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -63,3 +67,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/adminRightsOff.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/adminRightsOff.test.ts
+++ b/tests/src/collision-tests/adminRightsOff.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import BN from 'bn.js';
import chai from 'chai';
@@ -46,3 +50,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/setSponsorNewOwner.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/setSponsorNewOwner.test.ts
+++ b/tests/src/collision-tests/setSponsorNewOwner.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -44,3 +48,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/sponsorPayments.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/sponsorPayments.test.ts
+++ b/tests/src/collision-tests/sponsorPayments.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -53,3 +57,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/collision-tests/tokenLimitsOff.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/tokenLimitsOff.test.ts
+++ b/tests/src/collision-tests/tokenLimitsOff.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import BN from 'bn.js';
import chai from 'chai';
@@ -77,3 +81,4 @@
});
});
});
+*/
tests/src/collision-tests/turnsOffMinting.test.tsdiffbeforeafterboth--- a/tests/src/collision-tests/turnsOffMinting.test.ts
+++ b/tests/src/collision-tests/turnsOffMinting.test.ts
@@ -1,3 +1,7 @@
+/* broken by design
+// substrate transactions are sequential, not parallel
+// the order of execution is indeterminate
+
import { IKeyringPair } from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -45,3 +49,4 @@
});
});
});
+*/
\ No newline at end of file
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -5,11 +5,11 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import {
- createCollectionExpectSuccess,
- setCollectionSponsorExpectSuccess,
- destroyCollectionExpectSuccess,
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {
+ createCollectionExpectSuccess,
+ setCollectionSponsorExpectSuccess,
+ destroyCollectionExpectSuccess,
confirmSponsorshipExpectSuccess,
confirmSponsorshipExpectFailure,
createItemExpectSuccess,
@@ -21,9 +21,8 @@
normalizeAccountId,
addCollectionAdminExpectSuccess,
} from './util/helpers';
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import { BigNumber } from 'bignumber.js';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -36,7 +35,7 @@
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
charlie = keyring.addFromUri('//Charlie');
@@ -67,7 +66,7 @@
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
await usingApi(async (api) => {
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Find unused address
const zeroBalance = await findUnusedAddress(api);
@@ -79,22 +78,22 @@
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);
const events = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result = getGenericResult(events);
+ expect(result.success).to.be.true;
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
- expect(result.success).to.be.true;
- expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
});
});
it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
await usingApi(async (api) => {
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Find unused address
const zeroBalance = await findUnusedAddress(api);
@@ -106,11 +105,11 @@
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);
const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result1 = getGenericResult(events1);
+ expect(result1.success).to.be.true;
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
- expect(result1.success).to.be.true;
- expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
});
});
@@ -120,7 +119,7 @@
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
await usingApi(async (api) => {
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Find unused address
const zeroBalance = await findUnusedAddress(api);
@@ -133,10 +132,10 @@
const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result1 = getGenericResult(events1);
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
expect(result1.success).to.be.true;
- expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
});
});
@@ -145,15 +144,15 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
- // Enable collection white list
+ // Enable collection white list
await enableWhiteListExpectSuccess(alice, collectionId);
// Enable public minting
await enablePublicMintingExpectSuccess(alice, collectionId);
- // Create Item
+ // Create Item
await usingApi(async (api) => {
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Find unused address
const zeroBalance = await findUnusedAddress(api);
@@ -164,9 +163,9 @@
// Mint token using unused address as signer
await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
- expect(BsponsorBalance.lt(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;
});
});
@@ -189,13 +188,13 @@
const result1 = getGenericResult(events1);
// Second transfer should fail
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);
- const badTransaction = async function () {
+ const badTransaction = async function () {
await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
};
await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
@@ -205,12 +204,12 @@
expect(result1.success).to.be.true;
expect(result2.success).to.be.true;
- expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
});
});
it('Fungible: Sponsoring is rate limited', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0 }});
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
@@ -225,20 +224,20 @@
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);
const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result1 = getGenericResult(events1);
+ expect(result1.success).to.be.true;
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejected;
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
await submitTransactionAsync(alice, balancetx);
const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result2 = getGenericResult(events2);
-
- expect(result1.success).to.be.true;
expect(result2.success).to.be.true;
- expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+
+ expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
});
});
@@ -259,25 +258,25 @@
const aliceToZero = api.tx.nft.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);
const events1 = await submitTransactionAsync(alice, aliceToZero);
const result1 = getGenericResult(events1);
+ expect(result1.success).to.be.true;
// Second transfer should fail
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);
- const badTransaction = async function () {
+ const badTransaction = async function () {
await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
};
await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
await submitTransactionAsync(alice, balancetx);
const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result2 = getGenericResult(events2);
+ expect(result2.success).to.be.true;
- expect(result1.success).to.be.true;
- expect(result2.success).to.be.true;
- expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
});
});
@@ -286,7 +285,7 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Bob');
- // Enable collection white list
+ // Enable collection white list
await enableWhiteListExpectSuccess(alice, collectionId);
// Enable public minting
@@ -303,26 +302,20 @@
await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);
// Second mint should fail
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
-
- const consoleError = console.error;
- const consoleLog = console.log;
- console.error = () => {};
- console.log = () => {};
- const badTransaction = async function () {
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
+
+ const badTransaction = async function () {
await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);
};
await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');
- console.error = consoleError;
- console.log = consoleLog;
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
await submitTransactionAsync(alice, balancetx);
await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);
- expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
});
});
@@ -331,7 +324,7 @@
describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
charlie = keyring.addFromUri('//Charlie');
@@ -342,7 +335,7 @@
// Find the collection that never existed
let collectionId = 0;
await usingApi(async (api) => {
- collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
});
await confirmSponsorshipExpectFailure(collectionId, '//Bob');
@@ -369,7 +362,7 @@
it('(!negative test!) Confirm sponsorship by collection admin', async () => {
const collectionId = await createCollectionExpectSuccess();
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
- await addCollectionAdminExpectSuccess(alice, collectionId, charlie);
+ await addCollectionAdminExpectSuccess(alice, collectionId, charlie.address);
await confirmSponsorshipExpectFailure(collectionId, '//Charlie');
});
@@ -377,7 +370,7 @@
const collectionId = await createCollectionExpectSuccess();
await confirmSponsorshipExpectFailure(collectionId, '//Bob');
});
-
+
it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
tests/src/connection.test.tsdiffbeforeafterboth--- a/tests/src/connection.test.ts
+++ b/tests/src/connection.test.ts
@@ -4,7 +4,7 @@
//
import usingApi from './substrate/substrate-api';
-import { WsProvider } from '@polkadot/api';
+import {WsProvider} from '@polkadot/api';
import * as chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
@@ -21,19 +21,11 @@
});
it('Cannot connect to 255.255.255.255', async () => {
- const log = console.log;
- const error = console.error;
- console.log = function () {};
- console.error = function () {};
-
const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');
await expect((async () => {
await usingApi(async api => {
await api.rpc.system.health();
- }, { provider: neverConnectProvider });
+ }, {provider: neverConnectProvider});
})()).to.be.eventually.rejected;
-
- console.log = log;
- console.error = error;
});
-});
\ No newline at end of file
+});
tests/src/contracts.test.tsdiffbeforeafterboth--- a/tests/src/contracts.test.ts
+++ b/tests/src/contracts.test.ts
@@ -5,9 +5,9 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import usingApi, { submitTransactionAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
import fs from 'fs';
-import { Abi, ContractPromise as Contract } from '@polkadot/api-contract';
+import {Abi, ContractPromise as Contract} from '@polkadot/api-contract';
import privateKey from './substrate/privateKey';
import {
deployFlipper,
@@ -26,6 +26,7 @@
normalizeAccountId,
isWhitelisted,
transferFromExpectSuccess,
+ getTokenOwner,
} from './util/helpers';
@@ -75,18 +76,15 @@
const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, contract.address);
await submitTransactionAsync(alice, changeAdminTx);
- const tokenBefore: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(alice.address));
// Transfer
const transferTx = contract.tx.transfer(value, gasLimit, bob.address, collectionId, tokenId, 1);
const events = await submitTransactionAsync(alice, transferTx);
const result = getGenericResult(events);
- const tokenAfter: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON();
-
- // tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- expect(tokenBefore.owner).to.be.deep.equal(normalizeAccountId(alice.address));
- expect(tokenAfter.owner).to.be.deep.equal(normalizeAccountId(bob.address));
+
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(bob.address));
});
});
@@ -102,17 +100,17 @@
await addToWhiteListExpectSuccess(alice, collectionId, contract.address);
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
- const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, { Nft: {const_data: '0x010203', variable_data: '0x020304' }});
+ const transferTx = contract.tx.createItem(value, gasLimit, bob.address, collectionId, {Nft: {const_data: '0x010203', variable_data: '0x020304'}});
const events = await submitTransactionAsync(alice, transferTx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
- const tokensAfter: any = (await api.query.nft.nftItemList.entries(collectionId) as any).map((kv: any) => kv[1].toJSON());
+ const tokensAfter = (await api.query.nft.nftItemList.entries(collectionId)).map((kv: any) => kv[1].toJSON());
expect(tokensAfter).to.be.deep.equal([
{
- Owner: bob.address,
- ConstData: '0x010203',
- VariableData: '0x020304',
+ owner: bob.address,
+ constData: '0x010203',
+ variableData: '0x020304',
},
]);
});
@@ -131,9 +129,9 @@
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
const transferTx = contract.tx.createMultipleItems(value, gasLimit, bob.address, collectionId, [
- { Nft: { const_data: '0x010203', variable_data: '0x020304' } },
- { Nft: { const_data: '0x010204', variable_data: '0x020305' } },
- { Nft: { const_data: '0x010205', variable_data: '0x020306' } },
+ {Nft: {const_data: '0x010203', variable_data: '0x020304'}},
+ {Nft: {const_data: '0x010204', variable_data: '0x020305'}},
+ {Nft: {const_data: '0x010205', variable_data: '0x020306'}},
]);
const events = await submitTransactionAsync(alice, transferTx);
const result = getGenericResult(events);
tests/src/createCollection.test.tsdiffbeforeafterboth--- a/tests/src/createCollection.test.ts
+++ b/tests/src/createCollection.test.ts
@@ -5,11 +5,9 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi } from './substrate/substrate-api';
-import { createCollectionExpectFailure, createCollectionExpectSuccess } from './util/helpers';
+import {createCollectionExpectFailure, createCollectionExpectSuccess} from './util/helpers';
chai.use(chaiAsPromised);
-const expect = chai.expect;
describe('integration test: ext. createCollection():', () => {
it('Create new NFT collection', async () => {
@@ -34,10 +32,10 @@
describe('(!negative test!) integration test: ext. createCollection():', () => {
it('(!negative test!) create new NFT collection whith incorrect data (collection_name)', async () => {
- await createCollectionExpectFailure({ name: 'A'.repeat(65), mode: {type: 'NFT'}});
+ await createCollectionExpectFailure({name: 'A'.repeat(65), mode: {type: 'NFT'}});
});
it('(!negative test!) create new NFT collection whith incorrect data (collection_description)', async () => {
- await createCollectionExpectFailure({ description: 'A'.repeat(257), mode: { type: 'NFT' }});
+ await createCollectionExpectFailure({description: 'A'.repeat(257), mode: {type: 'NFT'}});
});
it('(!negative test!) create new NFT collection whith incorrect data (token_prefix)', async () => {
await createCollectionExpectFailure({tokenPrefix: 'A'.repeat(17), mode: {type: 'NFT'}});
tests/src/createItem.test.tsdiffbeforeafterboth--- a/tests/src/createItem.test.ts
+++ b/tests/src/createItem.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { default as usingApi } from './substrate/substrate-api';
+import {default as usingApi} from './substrate/substrate-api';
import chai from 'chai';
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import {
- createCollectionExpectSuccess,
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
+import {
+ createCollectionExpectSuccess,
createItemExpectSuccess,
addCollectionAdminExpectSuccess,
} from './util/helpers';
@@ -20,7 +20,7 @@
describe('integration test: ext. createItem():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -44,19 +44,19 @@
it('Create new item in NFT collection with collection admin permissions', async () => {
const createMode = 'NFT';
const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
- await addCollectionAdminExpectSuccess(alice, newCollectionID, bob);
+ await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
await createItemExpectSuccess(bob, newCollectionID, createMode);
});
it('Create new item in Fungible collection with collection admin permissions', async () => {
const createMode = 'Fungible';
const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode, decimalPoints: 0}});
- await addCollectionAdminExpectSuccess(alice, newCollectionID, bob);
+ await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
await createItemExpectSuccess(bob, newCollectionID, createMode);
});
it('Create new item in ReFungible collection with collection admin permissions', async () => {
const createMode = 'ReFungible';
const newCollectionID = await createCollectionExpectSuccess({mode: {type: createMode}});
- await addCollectionAdminExpectSuccess(alice, newCollectionID, bob);
+ await addCollectionAdminExpectSuccess(alice, newCollectionID, bob.address);
await createItemExpectSuccess(bob, newCollectionID, createMode);
});
});
@@ -64,7 +64,7 @@
describe('Negative integration test: ext. createItem():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
tests/src/createMultipleItems.test.tsdiffbeforeafterboth--- a/tests/src/createMultipleItems.test.ts
+++ b/tests/src/createMultipleItems.test.ts
@@ -2,120 +2,105 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import BN from 'bn.js';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
getGenericResult,
- IFungibleTokenDataType,
- IReFungibleTokenDataType,
normalizeAccountId,
setCollectionLimitsExpectSuccess,
addCollectionAdminExpectSuccess,
+ getBalance,
+ getTokenOwner,
+ getLastTokenId,
+ getVariableMetadata,
+ getConstMetadata,
} from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
-interface ITokenDataType {
- owner: number[];
- constData: number[];
- variableData: number[];
-}
-
describe('Integration Test createMultipleItems(collection_id, owner, items_data):', () => {
it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- const Alice = privateKey('//Alice');
- const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ const alice = privateKey('//Alice');
+ const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await submitTransactionAsync(Alice, createMultipleItemsTx);
- const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
- const token1Data = (await api.query.nft.nftItemList(collectionId, 1)).toJSON() as unknown as ITokenDataType;
- const token2Data = (await api.query.nft.nftItemList(collectionId, 2)).toJSON() as unknown as ITokenDataType;
- const token3Data = (await api.query.nft.nftItemList(collectionId, 3)).toJSON() as unknown as ITokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await submitTransactionAsync(alice, createMultipleItemsTx);
+ const itemsListIndexAfter = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexAfter).to.be.equal(3);
- expect(token1Data.owner).to.be.deep.equal(normalizeAccountId(Alice.address));
- expect(token2Data.owner).to.be.deep.equal(normalizeAccountId(Alice.address));
- expect(token3Data.owner).to.be.deep.equal(normalizeAccountId(Alice.address));
+ expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(alice.address));
+ expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(alice.address));
+ expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(alice.address));
- expect(token1Data.constData.toString()).to.be.equal('0x31');
- expect(token2Data.constData.toString()).to.be.equal('0x32');
- expect(token3Data.constData.toString()).to.be.equal('0x33');
+ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
- expect(token1Data.variableData.toString()).to.be.equal('0x31');
- expect(token2Data.variableData.toString()).to.be.equal('0x32');
- expect(token3Data.variableData.toString()).to.be.equal('0x33');
+ expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
});
});
it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- const Alice = privateKey('//Alice');
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ const alice = privateKey('//Alice');
const args = [
- {fungible: { value: 1 }},
- {fungible: { value: 2 }},
- {fungible: { value: 3 }},
+ {Fungible: {value: 1}},
+ {Fungible: {value: 2}},
+ {Fungible: {value: 3}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await submitTransactionAsync(Alice, createMultipleItemsTx);
- const token1Data = (await api.query.nft.fungibleItemList(collectionId, Alice.address) as any).toJSON() as unknown as IFungibleTokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await submitTransactionAsync(alice, createMultipleItemsTx);
+ const token1Data = await getBalance(api, collectionId, alice.address, 0);
- expect(token1Data.value).to.be.equal(6); // 1 + 2 + 3
+ expect(token1Data).to.be.equal(6n); // 1 + 2 + 3
});
});
it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- const Alice = privateKey('//Alice');
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ const alice = privateKey('//Alice');
const args = [
- {refungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
- {refungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
- {refungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
+ {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
+ {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
+ {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await submitTransactionAsync(Alice, createMultipleItemsTx);
- const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
- const token1Data = (await api.query.nft.reFungibleItemList(collectionId, 1) as any).toJSON() as unknown as IReFungibleTokenDataType;
- const token2Data = (await api.query.nft.reFungibleItemList(collectionId, 2) as any).toJSON() as unknown as IReFungibleTokenDataType;
- const token3Data = (await api.query.nft.reFungibleItemList(collectionId, 3) as any).toJSON() as unknown as IReFungibleTokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await submitTransactionAsync(alice, createMultipleItemsTx);
+ const itemsListIndexAfter = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexAfter).to.be.equal(3);
- expect(token1Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Alice.address));
- expect(token1Data.owner[0].fraction).to.be.equal(1);
+ expect(await getBalance(api, collectionId, alice.address, 1)).to.be.equal(1n);
+ expect(await getBalance(api, collectionId, alice.address, 2)).to.be.equal(1n);
+ expect(await getBalance(api, collectionId, alice.address, 3)).to.be.equal(1n);
- expect(token2Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Alice.address));
- expect(token2Data.owner[0].fraction).to.be.equal(1);
+ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
- expect(token3Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Alice.address));
- expect(token3Data.owner[0].fraction).to.be.equal(1);
-
- expect(token1Data.constData.toString()).to.be.equal('0x31');
- expect(token2Data.constData.toString()).to.be.equal('0x32');
- expect(token3Data.constData.toString()).to.be.equal('0x33');
-
- expect(token1Data.variableData.toString()).to.be.equal('0x31');
- expect(token2Data.variableData.toString()).to.be.equal('0x32');
- expect(token3Data.variableData.toString()).to.be.equal('0x33');
+ expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
});
});
@@ -128,8 +113,8 @@
tokenLimit: 2,
});
const args = [
- { nft: ['A', 'A'] },
- { nft: ['B', 'B'] },
+ {NFT: ['A', 'A']},
+ {NFT: ['B', 'B']},
];
const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
const events = await submitTransactionAsync(alice, createMultipleItemsTx);
@@ -141,183 +126,157 @@
describe('Integration Test createMultipleItems(collection_id, owner, items_data) with collection admin permissions:', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Create 0x31, 0x32, 0x33 items in active NFT collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);
- await submitTransactionAsync(Bob, createMultipleItemsTx);
- const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
- const token1Data = (await api.query.nft.nftItemList(collectionId, 1)).toJSON() as unknown as ITokenDataType;
- const token2Data = (await api.query.nft.nftItemList(collectionId, 2)).toJSON() as unknown as ITokenDataType;
- const token3Data = (await api.query.nft.nftItemList(collectionId, 3)).toJSON() as unknown as ITokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
+ await submitTransactionAsync(bob, createMultipleItemsTx);
+ const itemsListIndexAfter = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexAfter).to.be.equal(3);
- expect(token1Data.owner).to.be.deep.equal(normalizeAccountId(Bob.address));
- expect(token2Data.owner).to.be.deep.equal(normalizeAccountId(Bob.address));
- expect(token3Data.owner).to.be.deep.equal(normalizeAccountId(Bob.address));
+ expect(await getTokenOwner(api, collectionId, 1)).to.be.deep.equal(normalizeAccountId(bob.address));
+ expect(await getTokenOwner(api, collectionId, 2)).to.be.deep.equal(normalizeAccountId(bob.address));
+ expect(await getTokenOwner(api, collectionId, 3)).to.be.deep.equal(normalizeAccountId(bob.address));
- expect(token1Data.constData.toString()).to.be.equal('0x31');
- expect(token2Data.constData.toString()).to.be.equal('0x32');
- expect(token3Data.constData.toString()).to.be.equal('0x33');
+ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
- expect(token1Data.variableData.toString()).to.be.equal('0x31');
- expect(token2Data.variableData.toString()).to.be.equal('0x32');
- expect(token3Data.variableData.toString()).to.be.equal('0x33');
+ expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
});
});
it('Create 0x01, 0x02, 0x03 items in active Fungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const args = [
- {fungible: { value: 1 }},
- {fungible: { value: 2 }},
- {fungible: { value: 3 }},
+ {Fungible: {value: 1}},
+ {Fungible: {value: 2}},
+ {Fungible: {value: 3}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);
- await submitTransactionAsync(Bob, createMultipleItemsTx);
- const token1Data = (await api.query.nft.fungibleItemList(collectionId, Bob.address) as any).toJSON() as unknown as IFungibleTokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
+ await submitTransactionAsync(bob, createMultipleItemsTx);
+ const token1Data = await getBalance(api, collectionId, bob.address, 0);
- expect(token1Data.value).to.be.equal(6); // 1 + 2 + 3
+ expect(token1Data).to.be.equal(6n); // 1 + 2 + 3
});
});
it('Create 0x31, 0x32, 0x33 items in active ReFungible collection and verify tokens data in chain', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const args = [
- {refungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
- {refungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
- {refungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
+ {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
+ {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
+ {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Bob.address), args);
- await submitTransactionAsync(Bob, createMultipleItemsTx);
- const itemsListIndexAfter = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexAfter.toNumber()).to.be.equal(3);
- const token1Data = (await api.query.nft.reFungibleItemList(collectionId, 1) as any).toJSON() as unknown as IReFungibleTokenDataType;
- const token2Data = (await api.query.nft.reFungibleItemList(collectionId, 2) as any).toJSON() as unknown as IReFungibleTokenDataType;
- const token3Data = (await api.query.nft.reFungibleItemList(collectionId, 3) as any).toJSON() as unknown as IReFungibleTokenDataType;
+ .createMultipleItems(collectionId, normalizeAccountId(bob.address), args);
+ await submitTransactionAsync(bob, createMultipleItemsTx);
+ const itemsListIndexAfter = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexAfter).to.be.equal(3);
- expect(token1Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Bob.address));
- expect(token1Data.owner[0].fraction).to.be.equal(1);
+ expect(await getBalance(api, collectionId, bob.address, 1)).to.be.equal(1n);
+ expect(await getBalance(api, collectionId, bob.address, 2)).to.be.equal(1n);
+ expect(await getBalance(api, collectionId, bob.address, 3)).to.be.equal(1n);
- expect(token2Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Bob.address));
- expect(token2Data.owner[0].fraction).to.be.equal(1);
-
- expect(token3Data.owner[0].owner).to.be.deep.equal(normalizeAccountId(Bob.address));
- expect(token3Data.owner[0].fraction).to.be.equal(1);
+ expect(await getConstMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getConstMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getConstMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
- expect(token1Data.constData.toString()).to.be.equal('0x31');
- expect(token2Data.constData.toString()).to.be.equal('0x32');
- expect(token3Data.constData.toString()).to.be.equal('0x33');
-
- expect(token1Data.variableData.toString()).to.be.equal('0x31');
- expect(token2Data.variableData.toString()).to.be.equal('0x32');
- expect(token3Data.variableData.toString()).to.be.equal('0x33');
+ expect(await getVariableMetadata(api, collectionId, 1)).to.be.deep.equal([0x31]);
+ expect(await getVariableMetadata(api, collectionId, 2)).to.be.deep.equal([0x32]);
+ expect(await getVariableMetadata(api, collectionId, 3)).to.be.deep.equal([0x33]);
});
});
});
describe('Negative Integration Test createMultipleItems(collection_id, owner, items_data):', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Regular user cannot create items in active NFT collection', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
- const args = [{ nft: ['0x31', '0x31'] }, { nft: ['0x32', '0x32'] }, { nft: ['0x33', '0x33'] }];
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
+ const args = [{NFT: ['0x31', '0x31']}, {NFT: ['0x32', '0x32']}, {NFT: ['0x33', '0x33']}];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionAsync(Bob, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
});
});
it('Regular user cannot create items in active Fungible collection', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
const args = [
- {fungible: { value: 1 }},
- {fungible: { value: 2 }},
- {fungible: { value: 3 }},
+ {Fungible: {value: 1}},
+ {Fungible: {value: 2}},
+ {Fungible: {value: 3}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionAsync(Bob, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
});
});
it('Regular user cannot create items in active ReFungible collection', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const itemsListIndexBefore = await api.query.nft.itemListIndex(collectionId) as unknown as BN;
- expect(itemsListIndexBefore.toNumber()).to.be.equal(0);
+ const itemsListIndexBefore = await getLastTokenId(api, collectionId);
+ expect(itemsListIndexBefore).to.be.equal(0);
const args = [
- {refungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
- {refungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
- {refungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
+ {ReFungible: {const_data: [0x31], variable_data: [0x31], pieces: 1}},
+ {ReFungible: {const_data: [0x32], variable_data: [0x32], pieces: 1}},
+ {ReFungible: {const_data: [0x33], variable_data: [0x33], pieces: 1}},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionAsync(Bob, createMultipleItemsTx)).to.be.rejected;
- });
- });
-
- it('Create token with not existing type', async () => {
- await usingApi(async (api: ApiPromise) => {
- const collectionId = await createCollectionExpectSuccess();
- try {
- const args = [{ invalid: null }, { invalid: null }, { invalid: null }];
- const createMultipleItemsTx = await api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
- } catch (e) {
- // tslint:disable-next-line:no-unused-expression
- expect(e).to.be.exist;
- }
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionAsync(bob, createMultipleItemsTx)).to.be.rejected;
});
});
it('Create token in not existing collection', async () => {
await usingApi(async (api: ApiPromise) => {
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), ['NFT', 'NFT', 'NFT']);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'NFT', 'NFT']);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
});
});
@@ -325,27 +284,27 @@
await usingApi(async (api: ApiPromise) => {
// NFT
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
const args = [
- { nft: ['A'.repeat(2049), 'A'.repeat(2049)] },
- { nft: ['B'.repeat(2049), 'B'.repeat(2049)] },
- { nft: ['C'.repeat(2049), 'C'.repeat(2049)] },
+ {NFT: ['A'.repeat(2049), 'A'.repeat(2049)]},
+ {NFT: ['B'.repeat(2049), 'B'.repeat(2049)]},
+ {NFT: ['C'.repeat(2049), 'C'.repeat(2049)]},
];
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
// ReFungible
const collectionIdReFungible =
await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
const argsReFungible = [
- { ReFungible: ['1'.repeat(2049), '1'.repeat(2049), 10] },
- { ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10] },
- { ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10] },
+ {ReFungible: ['1'.repeat(2049), '1'.repeat(2049), 10]},
+ {ReFungible: ['2'.repeat(2049), '2'.repeat(2049), 10]},
+ {ReFungible: ['3'.repeat(2049), '3'.repeat(2049), 10]},
];
const createMultipleItemsTxFungible = api.tx.nft
- .createMultipleItems(collectionIdReFungible, normalizeAccountId(Alice.address), argsReFungible);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTxFungible)).to.be.rejected;
+ .createMultipleItems(collectionIdReFungible, normalizeAccountId(alice.address), argsReFungible);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTxFungible)).to.be.rejected;
});
});
@@ -353,8 +312,8 @@
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
const createMultipleItemsTx = api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), ['NFT', 'Fungible', 'ReFungible']);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), ['NFT', 'Fungible', 'ReFungible']);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
// garbage collection :-D
await destroyCollectionExpectSuccess(collectionId);
});
@@ -364,13 +323,13 @@
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
const args = [
- { nft: ['A', 'A'] },
- { nft: ['B', 'B'.repeat(2049)] },
- { nft: ['C'.repeat(2049), 'C'] },
+ {NFT: ['A', 'A']},
+ {NFT: ['B', 'B'.repeat(2049)]},
+ {NFT: ['C'.repeat(2049), 'C']},
];
const createMultipleItemsTx = await api.tx.nft
- .createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
+ .createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
});
});
@@ -378,15 +337,15 @@
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- await setCollectionLimitsExpectSuccess(Alice, collectionId, {
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {
tokenLimit: 1,
});
const args = [
- { nft: ['A', 'A'] },
- { nft: ['B', 'B'] },
+ {NFT: ['A', 'A']},
+ {NFT: ['B', 'B']},
];
- const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(Alice.address), args);
- await expect(submitTransactionExpectFailAsync(Alice, createMultipleItemsTx)).to.be.rejected;
+ const createMultipleItemsTx = api.tx.nft.createMultipleItems(collectionId, normalizeAccountId(alice.address), args);
+ await expect(submitTransactionExpectFailAsync(alice, createMultipleItemsTx)).to.be.rejected;
});
});
});
tests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -5,25 +5,24 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import { alicesPublicKey, bobsPublicKey } from './accounts';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {alicesPublicKey, bobsPublicKey} from './accounts';
import privateKey from './substrate/privateKey';
-import { BigNumber } from 'bignumber.js';
-import { IKeyringPair } from '@polkadot/types/types';
-import {
- createCollectionExpectSuccess,
+import {IKeyringPair} from '@polkadot/types/types';
+import {
+ createCollectionExpectSuccess,
createItemExpectSuccess,
getGenericResult,
transferExpectSuccess,
} from './util/helpers';
-import { default as waitNewBlocks } from './substrate/wait-new-blocks';
-import { ApiPromise } from '@polkadot/api';
+import {default as waitNewBlocks} from './substrate/wait-new-blocks';
+import {ApiPromise} from '@polkadot/api';
chai.use(chaiAsPromised);
const expect = chai.expect;
-const Treasury = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z';
+const TREASURY = '5EYCAe5ijiYfyeZ2JJCGq56LmPyNRAKzpG4QkoQkkQNB5e6Z';
const saneMinimumFee = 0.05;
const saneMaximumFee = 0.5;
const createCollectionDeposit = 100;
@@ -31,14 +30,14 @@
let alice: IKeyringPair;
let bob: IKeyringPair;
-// Skip the inflation block pauses if the block is close to inflation block
+// Skip the inflation block pauses if the block is close to inflation block
// until the inflation happens
/*eslint no-async-promise-executor: "off"*/
function skipInflationBlock(api: ApiPromise): Promise<void> {
const promise = new Promise<void>(async (resolve) => {
- const blockInterval = parseInt((await api.consts.inflation.inflationBlockInterval).toString());
+ const blockInterval = (await api.consts.inflation.inflationBlockInterval).toNumber();
const unsubscribe = await api.rpc.chain.subscribeNewHeads(head => {
- const currentBlock = parseInt(head.number.toString());
+ const currentBlock = head.number.toNumber();
if (currentBlock % blockInterval < blockInterval - 10) {
unsubscribe();
resolve();
@@ -64,18 +63,18 @@
await skipInflationBlock(api);
await waitNewBlocks(api, 1);
- const totalBefore = new BigNumber((await api.query.balances.totalIssuance()).toString());
+ const totalBefore = (await api.query.balances.totalIssuance()).toBigInt();
const alicePrivateKey = privateKey('//Alice');
- const amount = new BigNumber(1);
- const transfer = api.tx.balances.transfer(bobsPublicKey, amount.toFixed());
+ const amount = 1n;
+ const transfer = api.tx.balances.transfer(bobsPublicKey, amount);
const result = getGenericResult(await submitTransactionAsync(alicePrivateKey, transfer));
- const totalAfter = new BigNumber((await api.query.balances.totalIssuance()).toString());
+ const totalAfter = (await api.query.balances.totalIssuance()).toBigInt();
expect(result.success).to.be.true;
- expect(totalAfter.toFixed()).to.be.equal(totalBefore.toFixed());
+ expect(totalAfter).to.be.equal(totalBefore);
});
});
@@ -85,20 +84,20 @@
await waitNewBlocks(api, 1);
const alicePrivateKey = privateKey('//Alice');
- const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
+ const treasuryBalanceBefore: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
- const amount = new BigNumber(1);
- const transfer = api.tx.balances.transfer(bobsPublicKey, amount.toFixed());
+ const amount = 1n;
+ const transfer = api.tx.balances.transfer(bobsPublicKey, amount);
const result = getGenericResult(await submitTransactionAsync(alicePrivateKey, transfer));
- const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const aliceBalanceAfter = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
- const fee = aliceBalanceBefore.minus(aliceBalanceAfter).minus(amount);
- const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);
+ const treasuryBalanceAfter: bigint = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
+ const fee = aliceBalanceBefore - aliceBalanceAfter - amount;
+ const treasuryIncrease = treasuryBalanceAfter - treasuryBalanceBefore;
expect(result.success).to.be.true;
- expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());
+ expect(treasuryIncrease).to.be.equal(fee);
});
});
@@ -108,18 +107,18 @@
await waitNewBlocks(api, 1);
const bobPrivateKey = privateKey('//Bob');
- const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const bobBalanceBefore = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());
+ const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const bobBalanceBefore = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();
const badTx = api.tx.balances.setBalance(alicesPublicKey, 0, 0);
await expect(submitTransactionExpectFailAsync(bobPrivateKey, badTx)).to.be.rejected;
- const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const bobBalanceAfter = new BigNumber((await api.query.system.account(bobsPublicKey)).data.free.toString());
- const fee = bobBalanceBefore.minus(bobBalanceAfter);
- const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);
+ const treasuryBalanceAfter = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const bobBalanceAfter = (await api.query.system.account(bobsPublicKey)).data.free.toBigInt();
+ const fee = bobBalanceBefore - bobBalanceAfter;
+ const treasuryIncrease = treasuryBalanceAfter - treasuryBalanceBefore;
- expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());
+ expect(treasuryIncrease).to.be.equal(fee);
});
});
@@ -128,17 +127,17 @@
await skipInflationBlock(api);
await waitNewBlocks(api, 1);
- const treasuryBalanceBefore = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
+ const treasuryBalanceBefore = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const aliceBalanceBefore = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
await createCollectionExpectSuccess();
- const treasuryBalanceAfter = new BigNumber((await api.query.system.account(Treasury)).data.free.toString());
- const aliceBalanceAfter = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
- const fee = aliceBalanceBefore.minus(aliceBalanceAfter);
- const treasuryIncrease = treasuryBalanceAfter.minus(treasuryBalanceBefore);
+ const treasuryBalanceAfter = (await api.query.system.account(TREASURY)).data.free.toBigInt();
+ const aliceBalanceAfter = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
+ const fee = aliceBalanceBefore - aliceBalanceAfter;
+ const treasuryIncrease = treasuryBalanceAfter - treasuryBalanceBefore;
- expect(treasuryIncrease.toFixed()).to.be.equal(fee.toFixed());
+ expect(treasuryIncrease).to.be.equal(fee);
});
});
@@ -147,15 +146,15 @@
await skipInflationBlock(api);
await waitNewBlocks(api, 1);
- const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
+ const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
await createCollectionExpectSuccess();
- const aliceBalanceAfter = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
- const fee = aliceBalanceBefore.minus(aliceBalanceAfter);
+ const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
+ const fee = aliceBalanceBefore - aliceBalanceAfter;
- expect(fee.dividedBy(1e15).toNumber()).to.be.lessThan(saneMaximumFee + createCollectionDeposit);
- expect(fee.dividedBy(1e15).toNumber()).to.be.greaterThan(saneMinimumFee + createCollectionDeposit);
+ expect(fee / 10n ** 15n < BigInt(Math.ceil(saneMaximumFee + createCollectionDeposit))).to.be.true;
+ expect(fee / 10n ** 15n < BigInt(Math.ceil(saneMinimumFee + createCollectionDeposit))).to.be.true;
});
});
@@ -167,17 +166,16 @@
const collectionId = await createCollectionExpectSuccess();
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
- const aliceBalanceBefore = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
+ const aliceBalanceBefore: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
await transferExpectSuccess(collectionId, tokenId, alice, bob, 1, 'NFT');
- const aliceBalanceAfter = new BigNumber((await api.query.system.account(alicesPublicKey)).data.free.toString());
- const fee = aliceBalanceBefore.minus(aliceBalanceAfter);
+ const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
+ const fee = aliceBalanceBefore - aliceBalanceAfter;
// console.log(fee.toString());
const expectedTransferFee = 0.1;
const tolerance = 0.001;
- expect(fee.dividedBy(1e15).minus(expectedTransferFee).abs().toNumber()).to.be.lessThan(tolerance);
+ expect(Number(fee) / 1e15 - expectedTransferFee).to.be.lessThan(tolerance);
});
});
});
-
tests/src/destroyCollection.test.tsdiffbeforeafterboth--- a/tests/src/destroyCollection.test.ts
+++ b/tests/src/destroyCollection.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi } from './substrate/substrate-api';
-import { createCollectionExpectSuccess,
+import {default as usingApi} from './substrate/substrate-api';
+import {createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
destroyCollectionExpectFailure,
setCollectionLimitsExpectSuccess,
@@ -46,7 +46,7 @@
it('(!negative test!) Destroy a collection that never existed', async () => {
await usingApi(async (api) => {
// Find the collection that never existed
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
await destroyCollectionExpectFailure(collectionId);
});
});
@@ -62,12 +62,12 @@
});
it('(!negative test!) Destroy a collection using collection admin account', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await destroyCollectionExpectFailure(collectionId, '//Bob');
});
it('fails when OwnerCanDestroy == false', async () => {
const collectionId = await createCollectionExpectSuccess();
- await setCollectionLimitsExpectSuccess(alice, collectionId, { ownerCanDestroy: false });
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanDestroy: false});
await destroyCollectionExpectFailure(collectionId, '//Alice');
});
tests/src/enableContractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/enableContractSponsoring.test.ts
+++ b/tests/src/enableContractSponsoring.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
-import { deployFlipper, getFlipValue, toggleFlipValueExpectSuccess } from './util/contracthelpers';
+import {deployFlipper, getFlipValue, toggleFlipValueExpectSuccess} from './util/contracthelpers';
import {
enableContractSponsoringExpectFailure,
enableContractSponsoringExpectSuccess,
tests/src/enableDisableTransfer.test.tsdiffbeforeafterboth--- a/tests/src/enableDisableTransfer.test.ts
+++ b/tests/src/enableDisableTransfer.test.ts
@@ -21,31 +21,31 @@
describe('Enable/Disable Transfers', () => {
it('User can transfer token with enabled transfer flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
// explicitely set transfer flag
- await setTransferFlagExpectSuccess(Alice, nftCollectionId, true);
+ await setTransferFlagExpectSuccess(alice, nftCollectionId, true);
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 1);
});
});
it('User can\'n transfer token with disabled transfer flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
// explicitely set transfer flag
- await setTransferFlagExpectSuccess(Alice, nftCollectionId, false);
+ await setTransferFlagExpectSuccess(alice, nftCollectionId, false);
- await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
});
});
});
@@ -53,12 +53,12 @@
describe('Negative Enable/Disable Transfers', () => {
it('Non-owner cannot change transfer flag', async () => {
await usingApi(async () => {
- const Bob = privateKey('//Bob');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
// Change transfer flag
- await setTransferFlagExpectFailure(Bob, nftCollectionId, false);
+ await setTransferFlagExpectFailure(bob, nftCollectionId, false);
});
});
});
tests/src/eth/allowlist.test.tsdiffbeforeafterboth--- a/tests/src/eth/allowlist.test.ts
+++ b/tests/src/eth/allowlist.test.ts
@@ -1,61 +1,48 @@
-import { expect } from 'chai';
-import waitNewBlocks from '../substrate/wait-new-blocks';
-import { contractHelpers, createEthAccount, createEthAccountWithBalance, deployFlipper, itWeb3, usingWeb3Http } from './util/helpers';
+import {expect} from 'chai';
+import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployFlipper, itWeb3} from './util/helpers';
describe('EVM allowlist', () => {
- itWeb3('Contract allowlist can be toggled', async ({ api }) => {
- await usingWeb3Http(async web3Http => {
- const owner = await createEthAccountWithBalance(api, web3Http);
- const flipper = await deployFlipper(web3Http, owner);
- await waitNewBlocks(api, 1);
- const randomUser = createEthAccount(web3Http);
+ itWeb3('Contract allowlist can be toggled', async ({api, web3}) => {
+ const owner = await createEthAccountWithBalance(api, web3);
+ const flipper = await deployFlipper(web3, owner);
+ const randomUser = createEthAccount(web3);
- const helpers = contractHelpers(web3Http, owner);
+ const helpers = contractHelpers(web3, owner);
- // Any user is allowed by default
- expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
- await waitNewBlocks(api, 1);
+ // Any user is allowed by default
+ expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
+ expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
- // Enable
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.false;
+ // Enable
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.true;
+ expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.false;
- // Disable
- await helpers.methods.toggleAllowlist(flipper.options.address, false).send({ from: owner });
- await waitNewBlocks(api, 1);
- expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
- expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
- });
+ // Disable
+ await helpers.methods.toggleAllowlist(flipper.options.address, false).send({from: owner});
+ expect(await helpers.methods.allowlistEnabled(flipper.options.address).call()).to.be.false;
+ expect(await helpers.methods.allowed(flipper.options.address, randomUser).call()).to.be.true;
});
- itWeb3('Non-whitelisted user can\'t call contract with allowlist enabled', async ({ api }) => {
- await usingWeb3Http(async web3Http => {
- const owner = await createEthAccountWithBalance(api, web3Http);
- const flipper = await deployFlipper(web3Http, owner);
- await waitNewBlocks(api, 1);
- const caller = await createEthAccountWithBalance(api, web3Http);
+ itWeb3('Non-whitelisted user can\'t call contract with allowlist enabled', async ({api, web3}) => {
+ const owner = await createEthAccountWithBalance(api, web3);
+ const flipper = await deployFlipper(web3, owner);
+ const caller = await createEthAccountWithBalance(api, web3);
- const helpers = contractHelpers(web3Http, owner);
+ const helpers = contractHelpers(web3, owner);
- // User can flip with allowlist disabled
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
- expect(await flipper.methods.getValue().call()).to.be.true;
+ // User can flip with allowlist disabled
+ await flipper.methods.flip().send({from: caller});
+ expect(await flipper.methods.getValue().call()).to.be.true;
- // Tx will be reverted if user is not in whitelist
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await expect(flipper.methods.flip().send({ from: caller })).to.rejected;
- await waitNewBlocks(api, 1);
- expect(await flipper.methods.getValue().call()).to.be.true;
+ // Tx will be reverted if user is not in whitelist
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ await expect(flipper.methods.flip().send({from: caller})).to.rejected;
+ expect(await flipper.methods.getValue().call()).to.be.true;
- // Adding caller to allowlist will make contract callable again
- await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
- expect(await flipper.methods.getValue().call()).to.be.false;
- });
+ // Adding caller to allowlist will make contract callable again
+ await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
+ await flipper.methods.flip().send({from: caller});
+ expect(await flipper.methods.getValue().call()).to.be.false;
});
-});
\ No newline at end of file
+});
tests/src/eth/base.test.tsdiffbeforeafterboth--- a/tests/src/eth/base.test.ts
+++ b/tests/src/eth/base.test.ts
@@ -1,22 +1,22 @@
-import { createEthAccount, createEthAccountWithBalance, deployFlipper, ethBalanceViaSub, GAS_ARGS, itWeb3, recordEthFee } from './util/helpers';
-import { expect } from 'chai';
-import { UNIQUE } from '../util/helpers';
+import {createEthAccount, createEthAccountWithBalance, deployFlipper, ethBalanceViaSub, GAS_ARGS, itWeb3, recordEthFee} from './util/helpers';
+import {expect} from 'chai';
+import {UNIQUE} from '../util/helpers';
describe('Contract calls', () => {
- itWeb3('Call of simple contract fee is less than 0.2 UNQ', async ({ web3, api }) => {
+ itWeb3('Call of simple contract fee is less than 0.2 UNQ', async ({web3, api}) => {
const deployer = await createEthAccountWithBalance(api, web3);
- const flipper = await deployFlipper(web3 as any, deployer);
+ const flipper = await deployFlipper(web3, deployer);
const cost = await recordEthFee(api, deployer, () => flipper.methods.flip().send({from: deployer}));
expect(cost < BigInt(0.2 * Number(UNIQUE))).to.be.true;
});
- itWeb3('Balance transfer fee is less than 0.2 UNQ', async ({ web3, api }) => {
+ itWeb3('Balance transfer fee is less than 0.2 UNQ', async ({web3, api}) => {
const userA = await createEthAccountWithBalance(api, web3);
const userB = createEthAccount(web3);
- const cost = await recordEthFee(api, userA, () => web3.eth.sendTransaction({ from: userA, to: userB, value: '1000000', ...GAS_ARGS }));
+ const cost = await recordEthFee(api, userA, () => web3.eth.sendTransaction({from: userA, to: userB, value: '1000000', ...GAS_ARGS}));
expect(cost - await ethBalanceViaSub(api, userB) < BigInt(0.2 * Number(UNIQUE))).to.be.true;
});
-});
\ No newline at end of file
+});
tests/src/eth/contractSponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/contractSponsoring.test.ts
+++ b/tests/src/eth/contractSponsoring.test.ts
@@ -4,26 +4,21 @@
//
import privateKey from '../substrate/privateKey';
-import { expect } from 'chai';
-import {
+import {expect} from 'chai';
+import {
contractHelpers,
createEthAccountWithBalance,
transferBalanceToEth,
deployFlipper,
- itWeb3 } from './util/helpers';
-import waitNewBlocks from '../substrate/wait-new-blocks';
+ itWeb3} from './util/helpers';
describe('Sponsoring EVM contracts', () => {
itWeb3('Sponsoring can be set by the address that has deployed the contract', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
const helpers = contractHelpers(web3, owner);
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
- await waitNewBlocks(api, 1);
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
});
@@ -31,13 +26,9 @@
const owner = await createEthAccountWithBalance(api, web3);
const notOwner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
const helpers = contractHelpers(web3, owner);
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
- await waitNewBlocks(api, 1);
await expect(helpers.methods.toggleSponsoring(notOwner, true).send({from: notOwner})).to.rejected;
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
});
@@ -48,29 +39,22 @@
const caller = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
-
+
const helpers = contractHelpers(web3, owner);
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({ from: owner });
- await waitNewBlocks(api, 1);
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await flipper.methods.getValue().call()).to.be.true;
// Balance should be taken from flipper instead of caller
@@ -85,25 +69,20 @@
const caller = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
-
+
const helpers = contractHelpers(web3, owner);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await flipper.methods.getValue().call()).to.be.true;
// Balance should be taken from flipper instead of caller
@@ -119,29 +98,22 @@
const originalCallerBalance = await web3.eth.getBalance(caller);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
-
+
const helpers = contractHelpers(web3, owner);
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({ from: owner });
- await waitNewBlocks(api, 1);
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await flipper.methods.getValue().call()).to.be.true;
expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
@@ -155,44 +127,34 @@
const originalCallerBalance = await web3.eth.getBalance(caller);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
-
+
const helpers = contractHelpers(web3, owner);
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({ from: owner });
- await waitNewBlocks(api, 1);
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
await helpers.methods.setSponsoringRateLimit(flipper.options.address, 10).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await flipper.methods.getValue().call()).to.be.true;
expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await web3.eth.getBalance(caller)).to.be.not.equals(originalCallerBalance);
});
- // TODO: Find a way to calculate default rate limit
+ // TODO: Find a way to calculate default rate limit
itWeb3('Default rate limit equals 7200', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
const helpers = contractHelpers(web3, owner);
- await waitNewBlocks(api, 1);
expect(await helpers.methods.getSponsoringRateLimit(flipper.options.address).call()).to.be.equals('7200');
});
@@ -203,25 +165,20 @@
const caller = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
-
+
const helpers = contractHelpers(web3, owner);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
- await waitNewBlocks(api, 1);
expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: caller});
expect(await flipper.methods.getValue().call()).to.be.true;
// Balance should be taken from flipper instead of caller
tests/src/eth/crossTransfer.test.tsdiffbeforeafterboth--- a/tests/src/eth/crossTransfer.test.ts
+++ b/tests/src/eth/crossTransfer.test.ts
@@ -4,15 +4,15 @@
//
import privateKey from '../substrate/privateKey';
-import { createCollectionExpectSuccess,
- createFungibleItemExpectSuccess,
- transferExpectSuccess,
- transferFromExpectSuccess,
- createItemExpectSuccess } from '../util/helpers';
-import { collectionIdToAddress,
- createEthAccountWithBalance,
+import {createCollectionExpectSuccess,
+ createFungibleItemExpectSuccess,
+ transferExpectSuccess,
+ transferFromExpectSuccess,
+ createItemExpectSuccess} from '../util/helpers';
+import {collectionIdToAddress,
+ createEthAccountWithBalance,
subToEth,
- GAS_ARGS, itWeb3 } from './util/helpers';
+ GAS_ARGS, itWeb3} from './util/helpers';
import fungibleAbi from './fungibleAbi.json';
import nonFungibleAbi from './nonFungibleAbi.json';
@@ -20,34 +20,34 @@
itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async () => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { substrate: alice.address });
- await transferExpectSuccess(collection, 0, alice, {ethereum: subToEth(charlie.address)} , 200, 'Fungible');
- await transferFromExpectSuccess(collection, 0, alice, {ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
+ await transferExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)} , 200, 'Fungible');
+ await transferFromExpectSuccess(collection, 0, alice, {Ethereum: subToEth(charlie.address)}, charlie, 50, 'Fungible');
await transferExpectSuccess(collection, 0, charlie, bob, 50, 'Fungible');
});
- itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({ api, web3 }) => {
+ itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const bobProxy = await createEthAccountWithBalance(api, web3);
const aliceProxy = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, alice.address);
- await transferExpectSuccess(collection, 0, alice, { ethereum: aliceProxy } , 200, 'Fungible');
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, alice.address);
+ await transferExpectSuccess(collection, 0, alice, {Ethereum: aliceProxy} , 200, 'Fungible');
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: aliceProxy, ...GAS_ARGS});
- await contract.methods.transfer(bobProxy, 50).send({ from: aliceProxy });
- await transferFromExpectSuccess(collection, 0, alice, {ethereum: bobProxy}, bob, 50, 'Fungible');
+ await contract.methods.transfer(bobProxy, 50).send({from: aliceProxy});
+ await transferFromExpectSuccess(collection, 0, alice, {Ethereum: bobProxy}, bob, 50, 'Fungible');
await transferExpectSuccess(collection, 0, bob, alice, 50, 'Fungible');
});
});
@@ -56,33 +56,33 @@
itWeb3('The private key X create a substrate address. Alice sends a token to the corresponding EVM address, and X can send it to Bob in the substrate', async () => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { substrate: alice.address });
- await transferExpectSuccess(collection, tokenId, alice, { ethereum: subToEth(charlie.address) }, 1, 'NFT');
- await transferFromExpectSuccess(collection, tokenId, alice, {ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
+ await transferExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, 1, 'NFT');
+ await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: subToEth(charlie.address)}, charlie, 1, 'NFT');
await transferExpectSuccess(collection, tokenId, charlie, bob, 1, 'NFT');
});
- itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({ api, web3 }) => {
+ itWeb3('The private key X create a EVM address. Alice sends a token to the substrate address corresponding to this EVM address, and X can send it to Bob in the EVM', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
const bobProxy = await createEthAccountWithBalance(api, web3);
const aliceProxy = await createEthAccountWithBalance(api, web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { substrate: alice.address });
- await transferExpectSuccess(collection, tokenId, alice, { ethereum: aliceProxy } , 1, 'NFT');
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
+ await transferExpectSuccess(collection, tokenId, alice, {Ethereum: aliceProxy} , 1, 'NFT');
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: aliceProxy, ...GAS_ARGS});
- await contract.methods.transfer(bobProxy, 1).send({ from: aliceProxy });
- await transferFromExpectSuccess(collection, tokenId, alice, {ethereum: bobProxy}, bob, 1, 'NFT');
+ await contract.methods.transfer(bobProxy, 1).send({from: aliceProxy});
+ await transferFromExpectSuccess(collection, tokenId, alice, {Ethereum: bobProxy}, bob, 1, 'NFT');
await transferExpectSuccess(collection, tokenId, bob, charlie, 1, 'NFT');
});
-});
\ No newline at end of file
+});
tests/src/eth/fungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/fungible.test.ts
+++ b/tests/src/eth/fungible.test.ts
@@ -4,41 +4,40 @@
//
import privateKey from '../substrate/privateKey';
-import { approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE } from '../util/helpers';
-import { collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth } from './util/helpers';
+import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE} from '../util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
import fungibleAbi from './fungibleAbi.json';
-import { expect } from 'chai';
+import {expect} from 'chai';
describe('Fungible: Information getting', () => {
- itWeb3('totalSupply', async ({ api, web3 }) => {
+ itWeb3('totalSupply', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
-
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { substrate: alice.address });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
+
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS});
const totalSupply = await contract.methods.totalSupply().call();
- // FIXME: always equals to 0, because this method is not implemented
- expect(totalSupply).to.equal('0');
+ expect(totalSupply).to.equal('200');
});
- itWeb3('balanceOf', async ({ api, web3 }) => {
+ itWeb3('balanceOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: caller });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS});
@@ -49,16 +48,16 @@
});
describe('Fungible: Plain calls', () => {
- itWeb3('Can perform approve()', async ({ web3, api }) => {
+ itWeb3('Can perform approve()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const spender = createEthAccount(web3);
@@ -88,17 +87,17 @@
}
});
- itWeb3('Can perform transferFrom()', async ({ web3, api }) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner, 999999999999999);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const spender = createEthAccount(web3);
await transferBalanceToEth(api, alice, spender, 999999999999999);
@@ -146,17 +145,17 @@
}
});
- itWeb3('Can perform transfer()', async ({ web3, api }) => {
+ itWeb3('Can perform transfer()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner, 999999999999999);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const receiver = createEthAccount(web3);
await transferBalanceToEth(api, alice, receiver, 999999999999999);
@@ -165,7 +164,7 @@
const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: owner, ...GAS_ARGS});
{
- const result = await contract.methods.transfer(receiver, 50).send({ from: owner});
+ const result = await contract.methods.transfer(receiver, 50).send({from: owner});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -193,79 +192,79 @@
});
describe('Fungible: Fees', () => {
- itWeb3('approve() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, 100).send({ from: owner }));
+ const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, 100).send({from: owner}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
-
+
const owner = await createEthAccountWithBalance(api, web3);
const spender = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- await contract.methods.approve(spender, 100).send({ from: owner });
+ await contract.methods.approve(spender, 100).send({from: owner});
- const cost = await recordEthFee(api, spender, () => contract.methods.transferFrom(owner, spender, 100).send({ from: spender }));
+ const cost = await recordEthFee(api, spender, () => contract.methods.transferFrom(owner, spender, 100).send({from: spender}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transfer() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, 100).send({ from: owner }));
+ const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, 100).send({from: owner}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
});
describe('Fungible: Substrate calls', () => {
- itWeb3('Events emitted for approve()', async ({ web3 }) => {
+ itWeb3('Events emitted for approve()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const receiver = createEthAccount(web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await approveExpectSuccess(collection, 1, alice, { ethereum: receiver }, 100);
+ await approveExpectSuccess(collection, 0, alice, {Ethereum: receiver}, 100);
});
expect(events).to.be.deep.equal([
@@ -281,23 +280,23 @@
]);
});
- itWeb3('Events emitted for transferFrom()', async ({ web3 }) => {
+ itWeb3('Events emitted for transferFrom()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const receiver = createEthAccount(web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n });
- await approveExpectSuccess(collection, 1, alice, bob, 100);
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n});
+ await approveExpectSuccess(collection, 0, alice, bob.address, 100);
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await transferFromExpectSuccess(collection, 1, bob, alice, { ethereum: receiver }, 51, 'Fungible');
+ await transferFromExpectSuccess(collection, 0, bob, alice, {Ethereum: receiver}, 51, 'Fungible');
});
expect(events).to.be.deep.equal([
@@ -322,21 +321,21 @@
]);
});
- itWeb3('Events emitted for transfer()', async ({ web3 }) => {
+ itWeb3('Events emitted for transfer()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const receiver = createEthAccount(web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(fungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await transferExpectSuccess(collection, 1, alice, { ethereum: receiver }, 51, 'Fungible');
+ await transferExpectSuccess(collection, 0, alice, {Ethereum:receiver}, 51, 'Fungible');
});
expect(events).to.be.deep.equal([
@@ -351,4 +350,4 @@
},
]);
});
-});
\ No newline at end of file
+});
tests/src/eth/helpersSmoke.test.tsdiffbeforeafterboth--- a/tests/src/eth/helpersSmoke.test.ts
+++ b/tests/src/eth/helpersSmoke.test.ts
@@ -1,25 +1,21 @@
-import { expect } from 'chai';
-import waitNewBlocks from '../substrate/wait-new-blocks';
-import { createEthAccountWithBalance, deployFlipper, itWeb3, contractHelpers } from './util/helpers';
+import {expect} from 'chai';
+import {createEthAccountWithBalance, deployFlipper, itWeb3, contractHelpers} from './util/helpers';
describe('Helpers sanity check', () => {
- itWeb3('Contract owner is recorded', async ({ api, web3 }) => {
+ itWeb3('Contract owner is recorded', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
expect(await contractHelpers(web3, owner).methods.contractOwner(flipper.options.address).call()).to.be.equal(owner);
});
- itWeb3('Flipper is working', async ({ api, web3 }) => {
+ itWeb3('Flipper is working', async ({api, web3}) => {
const owner = await createEthAccountWithBalance(api, web3);
const flipper = await deployFlipper(web3, owner);
- await waitNewBlocks(api, 1);
expect(await flipper.methods.getValue().call()).to.be.false;
- await flipper.methods.flip().send({ from: owner });
- await waitNewBlocks(api, 1);
+ await flipper.methods.flip().send({from: owner});
expect(await flipper.methods.getValue().call()).to.be.true;
});
-});
\ No newline at end of file
+});
tests/src/eth/marketplace/marketplace.test.tsdiffbeforeafterboth--- a/tests/src/eth/marketplace/marketplace.test.ts
+++ b/tests/src/eth/marketplace/marketplace.test.ts
@@ -1,109 +1,106 @@
-import { readFile } from 'fs/promises';
-import { getBalanceSingle, transferBalanceExpectSuccess } from '../../substrate/get-balance';
+import {readFile} from 'fs/promises';
+import {getBalanceSingle, transferBalanceExpectSuccess} from '../../substrate/get-balance';
import privateKey from '../../substrate/privateKey';
-import { createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, queryNftOwner, transferExpectSuccess, transferFromExpectSuccess } from '../../util/helpers';
-import { collectionIdToAddress, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase } from '../util/helpers';
-import { evmToAddress } from '@polkadot/util-crypto';
+import {createCollectionExpectSuccess, createFungibleItemExpectSuccess, createItemExpectSuccess, getTokenOwner, transferExpectSuccess, transferFromExpectSuccess} from '../../util/helpers';
+import {collectionIdToAddress, createEthAccountWithBalance, executeEthTxOnSub, GAS_ARGS, itWeb3, subToEth, subToEthLowercase} from '../util/helpers';
+import {evmToAddress} from '@polkadot/util-crypto';
import nonFungibleAbi from '../nonFungibleAbi.json';
import fungibleAbi from '../fungibleAbi.json';
-import waitNewBlocks from '../../substrate/wait-new-blocks';
-import { expect } from 'chai';
+import {expect} from 'chai';
const PRICE = 2000n;
describe('Matcher contract usage', () => {
itWeb3('With UNQ', async ({api, web3}) => {
const matcherOwner = await createEthAccountWithBalance(api, web3);
- const Matcher = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceUNQ.abi`)).toString()), undefined, {
+ const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceUNQ.abi`)).toString()), undefined, {
from: matcherOwner,
...GAS_ARGS,
});
- const matcher = await Matcher.deploy({ data: (await readFile(`${__dirname}/MarketPlaceUNQ.bin`)).toString() }).send({ from: matcherOwner });
+ const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlaceUNQ.bin`)).toString()}).send({from: matcherOwner});
const alice = privateKey('//Alice');
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), { from: matcherOwner });
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
const seller = privateKey('//Bob');
-
+
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
// To transfer item to matcher it first needs to be transfered to EVM account of bob
- await transferExpectSuccess(collectionId, tokenId, seller, {ethereum: subToEth(seller.address)});
+ await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
// Fees will be paid from EVM account, so we should have some balance here
await transferBalanceExpectSuccess(api, seller, evmToAddress(subToEth(seller.address)), 10n ** 18n);
await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), 10n ** 18n);
- await waitNewBlocks(api, 1);
// Token is owned by seller initially
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(seller.address) });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
// Ask
{
await executeEthTxOnSub(api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
await executeEthTxOnSub(api, seller, matcher, m => m.setAsk(PRICE, '0x0000000000000000000000000000000000000000', evmCollection.options.address, tokenId, 1));
}
-
+
// Token is transferred to matcher
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: matcher.options.address.toLowerCase() });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});
// Buy
{
const sellerBalanceBeforePurchase = await getBalanceSingle(api, seller.address);
// There is two functions named 'buy', so we should provide full signature
- await executeEthTxOnSub(api, alice, matcher, m => m['buy(address,uint256)'](evmCollection.options.address, tokenId), { value: PRICE });
+ await executeEthTxOnSub(api, alice, matcher, m => m['buy(address,uint256)'](evmCollection.options.address, tokenId), {value: PRICE});
expect(await getBalanceSingle(api, seller.address) - sellerBalanceBeforePurchase === PRICE);
}
// Token is transferred to evm account of alice
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(alice.address) });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});
+
-
// Transfer token to substrate side of alice
- await transferFromExpectSuccess(collectionId, tokenId, alice, { ethereum: subToEth(alice.address) }, { substrate: alice.address });
-
+ await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});
+
// Token is transferred to substrate account of alice, seller received funds
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ substrate: alice.address });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});
});
itWeb3('With custom ERC20', async ({api, web3}) => {
const matcherOwner = await createEthAccountWithBalance(api, web3);
- const Matcher = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceUNQ.abi`)).toString()), undefined, {
+ const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceUNQ.abi`)).toString()), undefined, {
from: matcherOwner,
...GAS_ARGS,
});
- const matcher = await Matcher.deploy({ data: (await readFile(`${__dirname}/MarketPlaceUNQ.bin`)).toString() }).send({ from: matcherOwner });
+ const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlaceUNQ.bin`)).toString()}).send({from: matcherOwner});
const alice = privateKey('//Alice');
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), { from: matcherOwner });
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
- const fungibleId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
- const evmFungible = new web3.eth.Contract(fungibleAbi as any, collectionIdToAddress(fungibleId), { from: matcherOwner, ...GAS_ARGS });
- await createFungibleItemExpectSuccess(alice, fungibleId, { Value: PRICE }, { ethereum: subToEth(alice.address) });
+ const fungibleId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ const evmFungible = new web3.eth.Contract(fungibleAbi as any, collectionIdToAddress(fungibleId), {from: matcherOwner, ...GAS_ARGS});
+ await createFungibleItemExpectSuccess(alice, fungibleId, {Value: PRICE}, {Ethereum: subToEth(alice.address)});
const seller = privateKey('//Bob');
-
+
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
// To transfer item to matcher it first needs to be transfered to EVM account of bob
- await transferExpectSuccess(collectionId, tokenId, seller, {ethereum: subToEth(seller.address)});
+ await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
// Fees will be paid from EVM account, so we should have some balance here
await transferBalanceExpectSuccess(api, seller, evmToAddress(subToEth(seller.address)), 10n ** 18n);
await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), 10n ** 18n);
- await waitNewBlocks(api, 1);
// Token is owned by seller initially
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(seller.address) });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
// Ask
{
await executeEthTxOnSub(api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
await executeEthTxOnSub(api, seller, matcher, m => m.setAsk(PRICE, evmFungible.options.address, evmCollection.options.address, tokenId, 1));
}
-
+
// Token is transferred to matcher
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: matcher.options.address.toLowerCase() });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});
// Buy
{
@@ -121,65 +118,62 @@
}
// Token is transferred to evm account of alice
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(alice.address) });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});
+
-
// Transfer token to substrate side of alice
- await transferFromExpectSuccess(collectionId, tokenId, alice, { ethereum: subToEth(alice.address) }, { substrate: alice.address });
-
+ await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});
+
// Token is transferred to substrate account of alice
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ substrate: alice.address });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});
});
- itWeb3('With escrow', async ({ api, web3 }) => {
+ itWeb3('With escrow', async ({api, web3}) => {
const matcherOwner = await createEthAccountWithBalance(api, web3);
const escrow = await createEthAccountWithBalance(api, web3);
- const Matcher = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceKSM.abi`)).toString()), undefined, {
+ const matcherContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/MarketPlaceKSM.abi`)).toString()), undefined, {
from: matcherOwner,
...GAS_ARGS,
});
- const matcher = await Matcher.deploy({ data: (await readFile(`${__dirname}/MarketPlaceKSM.bin`)).toString(), arguments: [escrow] }).send({ from: matcherOwner });
-
+ const matcher = await matcherContract.deploy({data: (await readFile(`${__dirname}/MarketPlaceKSM.bin`)).toString(), arguments: [escrow]}).send({from: matcherOwner});
+
const ksmToken = 11;
const alice = privateKey('//Alice');
const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), { from: matcherOwner });
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, collectionIdToAddress(collectionId), {from: matcherOwner});
const seller = privateKey('//Bob');
-
+
const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT', seller.address);
// To transfer item to matcher it first needs to be transfered to EVM account of bob
- await transferExpectSuccess(collectionId, tokenId, seller, {ethereum: subToEth(seller.address)});
+ await transferExpectSuccess(collectionId, tokenId, seller, {Ethereum: subToEth(seller.address)});
// Fees will be paid from EVM account, so we should have some balance here
await transferBalanceExpectSuccess(api, seller, evmToAddress(subToEth(seller.address)), 10n ** 18n);
await transferBalanceExpectSuccess(api, alice, evmToAddress(subToEth(alice.address)), 10n ** 18n);
- await waitNewBlocks(api, 1);
// Token is owned by seller initially
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(seller.address) });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(seller.address)});
// Ask
{
await executeEthTxOnSub(api, seller, evmCollection, m => m.approve(matcher.options.address, tokenId));
await executeEthTxOnSub(api, seller, matcher, m => m.setAsk(PRICE, ksmToken, evmCollection.options.address, tokenId, 1));
}
-
+
// Token is transferred to matcher
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: matcher.options.address.toLowerCase() });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: matcher.options.address.toLowerCase()});
// Give buyer KSM
- await matcher.methods.deposit(PRICE, ksmToken, subToEth(alice.address)).send({ from: escrow });
- await waitNewBlocks(api, 1);
-
+ await matcher.methods.deposit(PRICE, ksmToken, subToEth(alice.address)).send({from: escrow});
+
// Buy
{
expect(await matcher.methods.escrowBalance(ksmToken, subToEth(seller.address)).call()).to.be.equal('0');
expect(await matcher.methods.escrowBalance(ksmToken, subToEth(alice.address)).call()).to.be.equal(PRICE.toString());
await executeEthTxOnSub(api, alice, matcher, m => m.buy(evmCollection.options.address, tokenId));
- await waitNewBlocks(api, 1);
// Price is removed from buyer balance, and added to seller
expect(await matcher.methods.escrowBalance(ksmToken, subToEth(alice.address)).call()).to.be.equal('0');
@@ -187,12 +181,12 @@
}
// Token is transferred to evm account of alice
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ ethereum: subToEthLowercase(alice.address) });
-
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Ethereum: subToEthLowercase(alice.address)});
+
// Transfer token to substrate side of alice
- await transferFromExpectSuccess(collectionId, tokenId, alice, { ethereum: subToEth(alice.address) }, { substrate: alice.address });
-
+ await transferFromExpectSuccess(collectionId, tokenId, alice, {Ethereum: subToEth(alice.address)}, {Substrate: alice.address});
+
// Token is transferred to substrate account of alice, seller received funds
- expect(await queryNftOwner(api, collectionId, tokenId)).to.be.deep.equal({ substrate: alice.address });
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal({Substrate: alice.address});
});
});
tests/src/eth/metadata.test.tsdiffbeforeafterboth--- a/tests/src/eth/metadata.test.ts
+++ b/tests/src/eth/metadata.test.ts
@@ -3,35 +3,35 @@
// file 'LICENSE', which is part of this source code package.
//
-import { expect } from 'chai';
-import { createCollectionExpectSuccess } from '../util/helpers';
-import { collectionIdToAddress, createEthAccountWithBalance, GAS_ARGS, itWeb3 } from './util/helpers';
+import {expect} from 'chai';
+import {createCollectionExpectSuccess} from '../util/helpers';
+import {collectionIdToAddress, createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';
import fungibleMetadataAbi from './fungibleMetadataAbi.json';
describe('Common metadata', () => {
- itWeb3('Returns collection name', async ({ api, web3 }) => {
+ itWeb3('Returns collection name', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});
const name = await contract.methods.name().call();
expect(name).to.equal('token name');
});
- itWeb3('Returns symbol name', async ({ api, web3 }) => {
+ itWeb3('Returns symbol name', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
tokenPrefix: 'TOK',
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});
const symbol = await contract.methods.symbol().call();
expect(symbol).to.equal('TOK');
@@ -39,14 +39,14 @@
});
describe('Fungible metadata', () => {
- itWeb3('Returns fungible decimals', async ({ api, web3 }) => {
+ itWeb3('Returns fungible decimals', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'Fungible', decimalPoints: 6 },
+ mode: {type: 'Fungible', decimalPoints: 6},
});
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, { from: caller, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(fungibleMetadataAbi as any, address, {from: caller, ...GAS_ARGS});
const decimals = await contract.methods.decimals().call();
expect(+decimals).to.equal(6);
tests/src/eth/migration.test.tsdiffbeforeafterboth--- a/tests/src/eth/migration.test.ts
+++ b/tests/src/eth/migration.test.ts
@@ -1,10 +1,10 @@
-import { expect } from 'chai';
+import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
-import { submitTransactionAsync } from '../substrate/substrate-api';
-import { createEthAccountWithBalance, GAS_ARGS, itWeb3 } from './util/helpers';
+import {submitTransactionAsync} from '../substrate/substrate-api';
+import {createEthAccountWithBalance, GAS_ARGS, itWeb3} from './util/helpers';
describe('EVM Migrations', () => {
- itWeb3('Deploy contract saved state', async ({ web3, api }) => {
+ itWeb3('Deploy contract saved state', async ({web3, api}) => {
/*
contract StatefulContract {
uint counter;
@@ -41,9 +41,9 @@
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS)));
- await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.setData(ADDRESS, DATA)));
- await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.finish(ADDRESS, CODE)));
+ await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.begin(ADDRESS) as any));
+ await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.setData(ADDRESS, DATA as any) as any));
+ await submitTransactionAsync(alice, api.tx.sudo.sudo(api.tx.evmMigration.finish(ADDRESS, CODE) as any));
const contract = new web3.eth.Contract([
{
@@ -72,11 +72,11 @@
stateMutability: 'view',
type: 'function',
},
- ], ADDRESS, { from: caller, ...GAS_ARGS });
-
+ ], ADDRESS, {from: caller, ...GAS_ARGS});
+
expect(await contract.methods.counterValue().call()).to.be.equal('10');
for (let i = 1; i <= 4; i++) {
expect(await contract.methods.get(i).call()).to.be.equal(i.toString());
}
});
-});
\ No newline at end of file
+});
tests/src/eth/nonFungible.test.tsdiffbeforeafterboth--- a/tests/src/eth/nonFungible.test.ts
+++ b/tests/src/eth/nonFungible.test.ts
@@ -4,41 +4,39 @@
//
import privateKey from '../substrate/privateKey';
-import { approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE, setMetadataUpdatePermissionFlagExpectSuccess } from '../util/helpers';
-import { collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth } from './util/helpers';
+import {approveExpectSuccess, burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, transferExpectSuccess, transferFromExpectSuccess, UNIQUE, setMetadataUpdatePermissionFlagExpectSuccess} from '../util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents, recordEthFee, recordEvents, subToEth, transferBalanceToEth} from './util/helpers';
import nonFungibleAbi from './nonFungibleAbi.json';
-import { expect } from 'chai';
-import waitNewBlocks from '../substrate/wait-new-blocks';
-import { submitTransactionAsync } from '../substrate/substrate-api';
+import {expect} from 'chai';
+import {submitTransactionAsync} from '../substrate/substrate-api';
describe('NFT: Information getting', () => {
- itWeb3('totalSupply', async ({ api, web3 }) => {
+ itWeb3('totalSupply', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createItemExpectSuccess(alice, collection, 'NFT', { substrate: alice.address });
+ await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
const totalSupply = await contract.methods.totalSupply().call();
- // FIXME: always equals to 0, because this method is not implemented
- expect(totalSupply).to.equal('0');
+ expect(totalSupply).to.equal('1');
});
- itWeb3('balanceOf', async ({ api, web3 }) => {
+ itWeb3('balanceOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum:caller});
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
@@ -47,14 +45,14 @@
expect(balance).to.equal('3');
});
- itWeb3('ownerOf', async ({ api, web3 }) => {
+ itWeb3('ownerOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
@@ -65,14 +63,14 @@
});
describe('NFT: Plain calls', () => {
- itWeb3('Can perform mint()', async ({ web3, api }) => {
+ itWeb3('Can perform mint()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, { ethereum: caller });
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: caller});
await submitTransactionAsync(alice, changeAdminTx);
const receiver = createEthAccount(web3);
@@ -101,18 +99,17 @@
},
]);
- await waitNewBlocks(api, 1);
expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
}
});
- itWeb3('Can perform mintBulk()', async ({ web3, api }) => {
+ itWeb3('Can perform mintBulk()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, { ethereum: caller });
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: caller});
await submitTransactionAsync(alice, changeAdminTx);
const receiver = createEthAccount(web3);
@@ -129,7 +126,7 @@
[+nextTokenId + 1, 'Test URI 1'],
[+nextTokenId + 2, 'Test URI 2'],
],
- ).send({ from: caller });
+ ).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
@@ -162,14 +159,13 @@
},
]);
- await waitNewBlocks(api, 1);
expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');
expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
}
});
- itWeb3('Can perform burn()', async ({ web3, api }) => {
+ itWeb3('Can perform burn()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
@@ -177,15 +173,15 @@
const owner = await createEthAccountWithBalance(api, web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
-
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
+
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
{
- const result = await contract.methods.burn(tokenId).send({ from: owner });
+ const result = await contract.methods.burn(tokenId).send({from: owner});
const events = normalizeEvents(result.events);
-
+
expect(events).to.be.deep.equal([
{
address,
@@ -200,16 +196,16 @@
}
});
- itWeb3('Can perform approve()', async ({ web3, api }) => {
+ itWeb3('Can perform approve()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner, 999999999999999);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const spender = createEthAccount(web3);
@@ -217,7 +213,7 @@
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
{
- const result = await contract.methods.approve(spender, tokenId).send({ from: owner, gas: '0x1000000', gasPrice: '0x01' });
+ const result = await contract.methods.approve(spender, tokenId).send({from: owner, gas: '0x1000000', gasPrice: '0x01'});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
@@ -234,16 +230,16 @@
}
});
- itWeb3('Can perform transferFrom()', async ({ web3, api }) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner, 999999999999999);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const spender = createEthAccount(web3);
await transferBalanceToEth(api, alice, spender, 999999999999999);
@@ -253,10 +249,10 @@
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- await contract.methods.approve(spender, tokenId).send({ from: owner });
+ await contract.methods.approve(spender, tokenId).send({from: owner});
{
- const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({ from: spender });
+ const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: spender});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -282,16 +278,16 @@
}
});
- itWeb3('Can perform transfer()', async ({ web3, api }) => {
+ itWeb3('Can perform transfer()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = createEthAccount(web3);
await transferBalanceToEth(api, alice, owner, 999999999999999);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const receiver = createEthAccount(web3);
await transferBalanceToEth(api, alice, receiver, 999999999999999);
@@ -300,8 +296,7 @@
const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
{
- const result = await contract.methods.transfer(receiver, tokenId).send({ from: owner });
- await waitNewBlocks(api, 1);
+ const result = await contract.methods.transfer(receiver, tokenId).send({from: owner});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -327,105 +322,104 @@
}
});
- itWeb3('Can perform getVariableMetadata', async ({ web3, api }) => {
+ itWeb3('Can perform getVariableMetadata', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
- const item = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
await setMetadataUpdatePermissionFlagExpectSuccess(alice, collection, 'Admin');
await setVariableMetaDataExpectSuccess(alice, collection, item, [1, 2, 3]);
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(nonFungibleAbi as any, address, { from: owner, ...GAS_ARGS });
-
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
+
expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203');
});
- itWeb3('Can perform setVariableMetadata', async ({ web3, api }) => {
+ itWeb3('Can perform setVariableMetadata', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
- const item = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(nonFungibleAbi as any, address, { from: owner, ...GAS_ARGS });
-
- expect(await contract.methods.setVariableMetadata(item, '0x010203').send({ from: owner }));
- await waitNewBlocks(api, 1);
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
+
+ expect(await contract.methods.setVariableMetadata(item, '0x010203').send({from: owner}));
expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203');
});
});
describe('NFT: Fees', () => {
- itWeb3('approve() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('approve() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const spender = createEthAccount(web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(nonFungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, tokenId).send({ from: owner }));
+ const cost = await recordEthFee(api, owner, () => contract.methods.approve(spender, tokenId).send({from: owner}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('transferFrom() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
-
+
const owner = await createEthAccountWithBalance(api, web3);
const spender = await createEthAccountWithBalance(api, web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(nonFungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- await contract.methods.approve(spender, tokenId).send({ from: owner });
+ await contract.methods.approve(spender, tokenId).send({from: owner});
- const cost = await recordEthFee(api, spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({ from: spender }));
+ const cost = await recordEthFee(api, spender, () => contract.methods.transferFrom(owner, spender, tokenId).send({from: spender}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
- itWeb3('transfer() call fee is less than 0.2UNQ', async ({ web3, api }) => {
+ itWeb3('transfer() call fee is less than 0.2UNQ', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const owner = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
const address = collectionIdToAddress(collection);
- const contract = new web3.eth.Contract(nonFungibleAbi as any, address, { from: owner, ...GAS_ARGS });
+ const contract = new web3.eth.Contract(nonFungibleAbi as any, address, {from: owner, ...GAS_ARGS});
- const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, tokenId).send({ from: owner }));
+ const cost = await recordEthFee(api, owner, () => contract.methods.transfer(receiver, tokenId).send({from: owner}));
expect(cost < BigInt(0.2 * Number(UNIQUE)));
});
});
describe('NFT: Substrate calls', () => {
- itWeb3('Events emitted for mint()', async ({ web3 }) => {
+ itWeb3('Events emitted for mint()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
@@ -450,9 +444,9 @@
]);
});
- itWeb3('Events emitted for burn()', async ({ web3 }) => {
+ itWeb3('Events emitted for burn()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
@@ -477,9 +471,9 @@
]);
});
- itWeb3('Events emitted for approve()', async ({ web3 }) => {
+ itWeb3('Events emitted for approve()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
@@ -491,7 +485,7 @@
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await approveExpectSuccess(collection, tokenId, alice, { ethereum: receiver }, 1);
+ await approveExpectSuccess(collection, tokenId, alice, {Ethereum: receiver}, 1);
});
expect(events).to.be.deep.equal([
@@ -507,9 +501,9 @@
]);
});
- itWeb3('Events emitted for transferFrom()', async ({ web3 }) => {
+ itWeb3('Events emitted for transferFrom()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
@@ -517,13 +511,13 @@
const receiver = createEthAccount(web3);
const tokenId = await createItemExpectSuccess(alice, collection, 'NFT');
- await approveExpectSuccess(collection, tokenId, alice, bob, 1);
+ await approveExpectSuccess(collection, tokenId, alice, bob.address, 1);
const address = collectionIdToAddress(collection);
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await transferFromExpectSuccess(collection, tokenId, bob, alice, { ethereum: receiver }, 1, 'NFT');
+ await transferFromExpectSuccess(collection, tokenId, bob, alice, {Ethereum: receiver}, 1, 'NFT');
});
expect(events).to.be.deep.equal([
@@ -539,9 +533,9 @@
]);
});
- itWeb3('Events emitted for transfer()', async ({ web3 }) => {
+ itWeb3('Events emitted for transfer()', async ({web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
@@ -553,7 +547,7 @@
const contract = new web3.eth.Contract(nonFungibleAbi as any, address);
const events = await recordEvents(contract, async () => {
- await transferExpectSuccess(collection, tokenId, alice, { ethereum: receiver }, 1, 'NFT');
+ await transferExpectSuccess(collection, tokenId, alice, {Ethereum: receiver}, 1, 'NFT');
});
expect(events).to.be.deep.equal([
tests/src/eth/payable.test.tsdiffbeforeafterboth--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -1,19 +1,17 @@
-import { expect } from 'chai';
+import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
-import { submitTransactionAsync } from '../substrate/substrate-api';
-import waitNewBlocks from '../substrate/wait-new-blocks';
-import { createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth } from './util/helpers';
+import {submitTransactionAsync} from '../substrate/substrate-api';
+import {createEthAccountWithBalance, deployCollector, GAS_ARGS, itWeb3, subToEth} from './util/helpers';
import {evmToAddress} from '@polkadot/util-crypto';
-import { getGenericResult } from '../util/helpers';
-import { getBalanceSingle, transferBalanceExpectSuccess } from '../substrate/get-balance';
+import {getGenericResult} from '../util/helpers';
+import {getBalanceSingle, transferBalanceExpectSuccess} from '../substrate/get-balance';
-describe('EVM payable contracts', ()=>{
+describe('EVM payable contracts', () => {
itWeb3('Evm contract can receive wei from eth account', async ({api, web3}) => {
const deployer = await createEthAccountWithBalance(api, web3);
const contract = await deployCollector(web3, deployer);
await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: '10000', ...GAS_ARGS});
- await waitNewBlocks(api, 1);
expect(await contract.methods.getCollected().call()).to.be.equal('10000');
});
@@ -52,7 +50,7 @@
const alice = privateKey('//Alice');
await transferBalanceExpectSuccess(api, alice, evmToAddress(contract.options.address), '10000');
-
+
expect(await contract.methods.getUnaccounted().call()).to.be.equal('10000');
});
@@ -65,7 +63,6 @@
const alice = privateKey('//Alice');
await web3.eth.sendTransaction({from: deployer, to: contract.options.address, value: CONTRACT_BALANCE.toString(), ...GAS_ARGS});
- await waitNewBlocks(api, 1);
const receiver = privateKey(`//Receiver${Date.now()}`);
@@ -95,4 +92,4 @@
expect(finalReceiverBalance > initialReceiverBalance).to.be.true;
}
});
-});
\ No newline at end of file
+});
tests/src/eth/proxy/fungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/fungibleProxy.test.ts
+++ b/tests/src/eth/proxy/fungibleProxy.test.ts
@@ -4,53 +4,52 @@
//
import privateKey from '../../substrate/privateKey';
-import { createCollectionExpectSuccess, createFungibleItemExpectSuccess } from '../../util/helpers';
-import { collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents } from '../util/helpers';
+import {createCollectionExpectSuccess, createFungibleItemExpectSuccess} from '../../util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';
import fungibleAbi from '../fungibleAbi.json';
-import { expect } from 'chai';
-import { ApiPromise } from '@polkadot/api';
+import {expect} from 'chai';
+import {ApiPromise} from '@polkadot/api';
import Web3 from 'web3';
-import { readFile } from 'fs/promises';
+import {readFile} from 'fs/promises';
async function proxyWrap(api: ApiPromise, web3: Web3, wrapped: any) {
// Proxy owner has no special privilegies, we don't need to reuse them
const owner = await createEthAccountWithBalance(api, web3);
- const Proxy = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueFungibleProxy.abi`)).toString()), undefined, {
+ const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueFungibleProxy.abi`)).toString()), undefined, {
from: owner,
...GAS_ARGS,
});
- const proxy = await Proxy.deploy({ data: (await readFile(`${__dirname}/UniqueFungibleProxy.bin`)).toString(), arguments: [wrapped.options.address] }).send({ from: owner });
+ const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueFungibleProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});
return proxy;
}
describe('Fungible (Via EVM proxy): Information getting', () => {
- itWeb3('totalSupply', async ({ api, web3 }) => {
+ itWeb3('totalSupply', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
-
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { substrate: alice.address });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Substrate: alice.address});
+
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
const totalSupply = await contract.methods.totalSupply().call();
- // FIXME: always equals to 0, because this method is not implemented
- expect(totalSupply).to.equal('0');
+ expect(totalSupply).to.equal('200');
});
- itWeb3('balanceOf', async ({ api, web3 }) => {
+ itWeb3('balanceOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: caller });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
@@ -61,10 +60,10 @@
});
describe('Fungible (Via EVM proxy): Plain calls', () => {
- itWeb3('Can perform approve()', async ({ web3, api }) => {
+ itWeb3('Can perform approve()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -72,7 +71,7 @@
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: contract.options.address });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: contract.options.address});
{
const result = await contract.methods.approve(spender, 100).send({from: caller});
@@ -97,21 +96,21 @@
}
});
- itWeb3('Can perform transferFrom()', async ({ web3, api }) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const owner = await createEthAccountWithBalance(api, web3);
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: owner });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: owner});
const receiver = createEthAccount(web3);
const address = collectionIdToAddress(collection);
- const evmCollection = new web3.eth.Contract(fungibleAbi as any, address, { from: caller, ...GAS_ARGS });
+ const evmCollection = new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS});
const contract = await proxyWrap(api, web3, evmCollection);
await evmCollection.methods.approve(contract.options.address, 100).send({from: owner});
@@ -152,10 +151,10 @@
}
});
- itWeb3('Can perform transfer()', async ({ web3, api }) => {
+ itWeb3('Can perform transfer()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
name: 'token name',
- mode: { type: 'Fungible', decimalPoints: 0 },
+ mode: {type: 'Fungible', decimalPoints: 0},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -163,10 +162,10 @@
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(fungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
- await createFungibleItemExpectSuccess(alice, collection, { Value: 200n }, { ethereum: contract.options.address });
+ await createFungibleItemExpectSuccess(alice, collection, {Value: 200n}, {Ethereum: contract.options.address});
{
- const result = await contract.methods.transfer(receiver, 50).send({ from: caller});
+ const result = await contract.methods.transfer(receiver, 50).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
tests/src/eth/proxy/nonFungibleProxy.test.tsdiffbeforeafterboth--- a/tests/src/eth/proxy/nonFungibleProxy.test.ts
+++ b/tests/src/eth/proxy/nonFungibleProxy.test.ts
@@ -4,55 +4,53 @@
//
import privateKey from '../../substrate/privateKey';
-import { createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, setMetadataUpdatePermissionFlagExpectSuccess } from '../../util/helpers';
-import { collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents } from '../util/helpers';
+import {createCollectionExpectSuccess, createItemExpectSuccess, setVariableMetaDataExpectSuccess, setMetadataUpdatePermissionFlagExpectSuccess} from '../../util/helpers';
+import {collectionIdToAddress, createEthAccount, createEthAccountWithBalance, GAS_ARGS, itWeb3, normalizeEvents} from '../util/helpers';
import nonFungibleAbi from '../nonFungibleAbi.json';
-import { expect } from 'chai';
-import waitNewBlocks from '../../substrate/wait-new-blocks';
-import { submitTransactionAsync } from '../../substrate/substrate-api';
+import {expect} from 'chai';
+import {submitTransactionAsync} from '../../substrate/substrate-api';
import Web3 from 'web3';
-import { readFile } from 'fs/promises';
-import { ApiPromise } from '@polkadot/api';
+import {readFile} from 'fs/promises';
+import {ApiPromise} from '@polkadot/api';
async function proxyWrap(api: ApiPromise, web3: Web3, wrapped: any) {
// Proxy owner has no special privilegies, we don't need to reuse them
const owner = await createEthAccountWithBalance(api, web3);
- const Proxy = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {
+ const proxyContract = new web3.eth.Contract(JSON.parse((await readFile(`${__dirname}/UniqueNFTProxy.abi`)).toString()), undefined, {
from: owner,
...GAS_ARGS,
});
- const proxy = await Proxy.deploy({ data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address] }).send({ from: owner });
+ const proxy = await proxyContract.deploy({data: (await readFile(`${__dirname}/UniqueNFTProxy.bin`)).toString(), arguments: [wrapped.options.address]}).send({from: owner});
return proxy;
}
describe('NFT (Via EVM proxy): Information getting', () => {
- itWeb3('totalSupply', async ({ api, web3 }) => {
+ itWeb3('totalSupply', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createItemExpectSuccess(alice, collection, 'NFT', { substrate: alice.address });
+ await createItemExpectSuccess(alice, collection, 'NFT', {Substrate: alice.address});
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
const totalSupply = await contract.methods.totalSupply().call();
- // FIXME: always equals to 0, because this method is not implemented
- expect(totalSupply).to.equal('0');
+ expect(totalSupply).to.equal('1');
});
- itWeb3('balanceOf', async ({ api, web3 }) => {
+ itWeb3('balanceOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
- await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
+ await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
@@ -61,14 +59,14 @@
expect(balance).to.equal('3');
});
- itWeb3('ownerOf', async ({ api, web3 }) => {
+ itWeb3('ownerOf', async ({api, web3}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: caller });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: caller});
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
@@ -79,18 +77,18 @@
});
describe('NFT (Via EVM proxy): Plain calls', () => {
- itWeb3('Can perform mint()', async ({ web3, api }) => {
+ itWeb3('Can perform mint()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const receiver = createEthAccount(web3);
const address = collectionIdToAddress(collection);
- const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, { from: caller, ...GAS_ARGS }));
+ const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, { ethereum: contract.options.address });
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});
await submitTransactionAsync(alice, changeAdminTx);
{
@@ -100,7 +98,7 @@
receiver,
nextTokenId,
'Test URI',
- ).send({ from: caller });
+ ).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
@@ -115,13 +113,12 @@
},
]);
- await waitNewBlocks(api, 1);
expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI');
}
});
- itWeb3('Can perform mintBulk()', async ({ web3, api }) => {
+ itWeb3('Can perform mintBulk()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
@@ -129,8 +126,8 @@
const receiver = createEthAccount(web3);
const address = collectionIdToAddress(collection);
- const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, { from: caller, ...GAS_ARGS }));
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, { ethereum: contract.options.address });
+ const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});
await submitTransactionAsync(alice, changeAdminTx);
{
@@ -143,7 +140,7 @@
[+nextTokenId + 1, 'Test URI 1'],
[+nextTokenId + 2, 'Test URI 2'],
],
- ).send({ from: caller });
+ ).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
@@ -176,31 +173,30 @@
},
]);
- await waitNewBlocks(api, 1);
expect(await contract.methods.tokenURI(nextTokenId).call()).to.be.equal('Test URI 0');
expect(await contract.methods.tokenURI(+nextTokenId + 1).call()).to.be.equal('Test URI 1');
expect(await contract.methods.tokenURI(+nextTokenId + 2).call()).to.be.equal('Test URI 2');
}
});
- itWeb3('Can perform burn()', async ({ web3, api }) => {
+ itWeb3('Can perform burn()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
-
+
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: contract.options.address });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, { ethereum: contract.options.address });
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collection, {Ethereum: contract.options.address});
await submitTransactionAsync(alice, changeAdminTx);
{
- const result = await contract.methods.burn(tokenId).send({ from: caller });
+ const result = await contract.methods.burn(tokenId).send({from: caller});
const events = normalizeEvents(result.events);
-
+
expect(events).to.be.deep.equal([
{
address,
@@ -215,9 +211,9 @@
}
});
- itWeb3('Can perform approve()', async ({ web3, api }) => {
+ itWeb3('Can perform approve()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -225,10 +221,10 @@
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address));
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: contract.options.address });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});
{
- const result = await contract.methods.approve(spender, tokenId).send({ from: caller, gas: '0x1000000', gasPrice: '0x01' });
+ const result = await contract.methods.approve(spender, tokenId).send({from: caller, gas: '0x1000000', gasPrice: '0x01'});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
@@ -245,9 +241,9 @@
}
});
- itWeb3('Can perform transferFrom()', async ({ web3, api }) => {
+ itWeb3('Can perform transferFrom()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -256,14 +252,14 @@
const receiver = createEthAccount(web3);
const address = collectionIdToAddress(collection);
- const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, address, { from: caller, ...GAS_ARGS });
+ const evmCollection = new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS});
const contract = await proxyWrap(api, web3, evmCollection);
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: owner });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: owner});
- await evmCollection.methods.approve(contract.options.address, tokenId).send({ from: owner });
+ await evmCollection.methods.approve(contract.options.address, tokenId).send({from: owner});
{
- const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({ from: caller });
+ const result = await contract.methods.transferFrom(owner, receiver, tokenId).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -289,9 +285,9 @@
}
});
- itWeb3('Can perform transfer()', async ({ web3, api }) => {
+ itWeb3('Can perform transfer()', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
@@ -299,11 +295,10 @@
const address = collectionIdToAddress(collection);
const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
- const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: contract.options.address });
+ const tokenId = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});
{
- const result = await contract.methods.transfer(receiver, tokenId).send({ from: caller });
- await waitNewBlocks(api, 1);
+ const result = await contract.methods.transfer(receiver, tokenId).send({from: caller});
const events = normalizeEvents(result.events);
expect(events).to.be.deep.equal([
{
@@ -329,35 +324,34 @@
}
});
- itWeb3('Can perform getVariableMetadata', async ({ web3, api }) => {
+ itWeb3('Can perform getVariableMetadata', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
- const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, { from: caller, ...GAS_ARGS }));
- const item = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: contract.options.address });
+ const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
+ const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});
await setMetadataUpdatePermissionFlagExpectSuccess(alice, collection, 'Admin');
await setVariableMetaDataExpectSuccess(alice, collection, item, [1, 2, 3]);
-
+
expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203');
});
- itWeb3('Can perform setVariableMetadata', async ({ web3, api }) => {
+ itWeb3('Can perform setVariableMetadata', async ({web3, api}) => {
const collection = await createCollectionExpectSuccess({
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
});
const alice = privateKey('//Alice');
const caller = await createEthAccountWithBalance(api, web3);
const address = collectionIdToAddress(collection);
- const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, { from: caller, ...GAS_ARGS }));
- const item = await createItemExpectSuccess(alice, collection, 'NFT', { ethereum: contract.options.address });
-
- expect(await contract.methods.setVariableMetadata(item, '0x010203').send({ from: caller }));
- await waitNewBlocks(api, 1);
+ const contract = await proxyWrap(api, web3, new web3.eth.Contract(nonFungibleAbi as any, address, {from: caller, ...GAS_ARGS}));
+ const item = await createItemExpectSuccess(alice, collection, 'NFT', {Ethereum: contract.options.address});
+
+ expect(await contract.methods.setVariableMetadata(item, '0x010203').send({from: caller}));
expect(await contract.methods.getVariableMetadata(item).call()).to.be.equal('0x010203');
});
});
tests/src/eth/sponsoring.test.tsdiffbeforeafterboth--- a/tests/src/eth/sponsoring.test.ts
+++ b/tests/src/eth/sponsoring.test.ts
@@ -1,88 +1,68 @@
-import { expect } from 'chai';
+import {expect} from 'chai';
import privateKey from '../substrate/privateKey';
-import waitNewBlocks from '../substrate/wait-new-blocks';
-import { contractHelpers, createEthAccount, createEthAccountWithBalance, deployCollector, deployFlipper, itWeb3, transferBalanceToEth, usingWeb3Http } from './util/helpers';
+import {contractHelpers, createEthAccount, createEthAccountWithBalance, deployCollector, deployFlipper, itWeb3, transferBalanceToEth} from './util/helpers';
describe('EVM sponsoring', () => {
itWeb3('Fee is deducted from contract if sponsoring is enabled', async ({api, web3}) => {
- await usingWeb3Http(async web3Http => {
- const alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
- const owner = await createEthAccountWithBalance(api, web3Http);
- const caller = createEthAccount(web3Http);
- const originalCallerBalance = await web3.eth.getBalance(caller);
- expect(originalCallerBalance).to.be.equal('0');
+ const owner = await createEthAccountWithBalance(api, web3);
+ const caller = createEthAccount(web3);
+ const originalCallerBalance = await web3.eth.getBalance(caller);
+ expect(originalCallerBalance).to.be.equal('0');
- const flipper = await deployFlipper(web3Http, owner);
- await waitNewBlocks(api, 1);
-
- const helpers = contractHelpers(web3Http, owner);
- await helpers.methods.toggleAllowlist(flipper.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({ from: owner });
- await waitNewBlocks(api, 1);
+ const flipper = await deployFlipper(web3, owner);
- expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
- await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
- await waitNewBlocks(api, 1);
- await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
- await waitNewBlocks(api, 1);
- expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
+ const helpers = contractHelpers(web3, owner);
+ await helpers.methods.toggleAllowlist(flipper.options.address, true).send({from: owner});
+ await helpers.methods.toggleAllowed(flipper.options.address, caller, true).send({from: owner});
+
+ expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.false;
+ await helpers.methods.toggleSponsoring(flipper.options.address, true).send({from: owner});
+ await helpers.methods.setSponsoringRateLimit(flipper.options.address, 0).send({from: owner});
+ expect(await helpers.methods.sponsoringEnabled(flipper.options.address).call()).to.be.true;
- await transferBalanceToEth(api, alice, flipper.options.address);
- await waitNewBlocks(api, 2);
+ await transferBalanceToEth(api, alice, flipper.options.address);
- const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
- expect(originalFlipperBalance).to.be.not.equal('0');
+ const originalFlipperBalance = await web3.eth.getBalance(flipper.options.address);
+ expect(originalFlipperBalance).to.be.not.equal('0');
- await flipper.methods.flip().send({ from: caller });
- await waitNewBlocks(api, 1);
- expect(await flipper.methods.getValue().call()).to.be.true;
+ await flipper.methods.flip().send({from: caller});
+ expect(await flipper.methods.getValue().call()).to.be.true;
- // Balance should be taken from flipper instead of caller
- expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
- expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);
- });
+ // Balance should be taken from flipper instead of caller
+ expect(await web3.eth.getBalance(caller)).to.be.equals(originalCallerBalance);
+ expect(await web3.eth.getBalance(flipper.options.address)).to.be.not.equals(originalFlipperBalance);
});
itWeb3('...but this doesn\'t applies to payable value', async ({api, web3}) => {
- await usingWeb3Http(async web3Http => {
- const alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
- const owner = await createEthAccountWithBalance(api, web3Http);
- const caller = await createEthAccountWithBalance(api, web3Http);
- await waitNewBlocks(api, 1);
- const originalCallerBalance = await web3.eth.getBalance(caller);
- expect(originalCallerBalance).to.be.not.equal('0');
+ const owner = await createEthAccountWithBalance(api, web3);
+ const caller = await createEthAccountWithBalance(api, web3);
+ const originalCallerBalance = await web3.eth.getBalance(caller);
+ expect(originalCallerBalance).to.be.not.equal('0');
- const collector = await deployCollector(web3Http, owner);
- await waitNewBlocks(api, 1);
-
- const helpers = contractHelpers(web3Http, owner);
- await helpers.methods.toggleAllowlist(collector.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.toggleAllowed(collector.options.address, caller, true).send({ from: owner });
- await waitNewBlocks(api, 1);
+ const collector = await deployCollector(web3, owner);
- expect(await helpers.methods.sponsoringEnabled(collector.options.address).call()).to.be.false;
- await helpers.methods.toggleSponsoring(collector.options.address, true).send({ from: owner });
- await waitNewBlocks(api, 1);
- await helpers.methods.setSponsoringRateLimit(collector.options.address, 0).send({ from: owner });
- await waitNewBlocks(api, 1);
- expect(await helpers.methods.sponsoringEnabled(collector.options.address).call()).to.be.true;
+ const helpers = contractHelpers(web3, owner);
+ await helpers.methods.toggleAllowlist(collector.options.address, true).send({from: owner});
+ await helpers.methods.toggleAllowed(collector.options.address, caller, true).send({from: owner});
+
+ expect(await helpers.methods.sponsoringEnabled(collector.options.address).call()).to.be.false;
+ await helpers.methods.toggleSponsoring(collector.options.address, true).send({from: owner});
+ await helpers.methods.setSponsoringRateLimit(collector.options.address, 0).send({from: owner});
+ expect(await helpers.methods.sponsoringEnabled(collector.options.address).call()).to.be.true;
- await transferBalanceToEth(api, alice, collector.options.address);
- await waitNewBlocks(api, 2);
+ await transferBalanceToEth(api, alice, collector.options.address);
- const originalCollectorBalance = await web3.eth.getBalance(collector.options.address);
- expect(originalCollectorBalance).to.be.not.equal('0');
+ const originalCollectorBalance = await web3.eth.getBalance(collector.options.address);
+ expect(originalCollectorBalance).to.be.not.equal('0');
- await collector.methods.giveMoney().send({ from: caller, value: '10000' });
- await waitNewBlocks(api, 1);
+ await collector.methods.giveMoney().send({from: caller, value: '10000'});
- // Balance will be taken from both caller (value) and from collector (fee)
- expect(await web3.eth.getBalance(caller)).to.be.equals((BigInt(originalCallerBalance) - 10000n).toString());
- expect(await web3.eth.getBalance(collector.options.address)).to.be.not.equals(originalCollectorBalance);
- expect(await collector.methods.getCollected().call()).to.be.equal('10000');
- });
+ // Balance will be taken from both caller (value) and from collector (fee)
+ expect(await web3.eth.getBalance(caller)).to.be.equals((BigInt(originalCallerBalance) - 10000n).toString());
+ expect(await web3.eth.getBalance(collector.options.address)).to.be.not.equals(originalCollectorBalance);
+ expect(await collector.methods.getCollected().call()).to.be.equal('10000');
});
-});
\ No newline at end of file
+});
tests/src/eth/util/helpers.tsdiffbeforeafterboth--- a/tests/src/eth/util/helpers.ts
+++ b/tests/src/eth/util/helpers.ts
@@ -6,21 +6,20 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="helpers.d.ts" />
-import { ApiPromise } from '@polkadot/api';
-import { addressToEvm, evmToAddress } from '@polkadot/util-crypto';
+import {ApiPromise} from '@polkadot/api';
+import {addressToEvm, evmToAddress} from '@polkadot/util-crypto';
import Web3 from 'web3';
-import usingApi, { submitTransactionAsync } from '../../substrate/substrate-api';
-import { IKeyringPair } from '@polkadot/types/types';
-import { expect } from 'chai';
-import { getGenericResult } from '../../util/helpers';
+import usingApi, {submitTransactionAsync} from '../../substrate/substrate-api';
+import {IKeyringPair} from '@polkadot/types/types';
+import {expect} from 'chai';
+import {getGenericResult} from '../../util/helpers';
import * as solc from 'solc';
import config from '../../config';
import privateKey from '../../substrate/privateKey';
import contractHelpersAbi from './contractHelpersAbi.json';
import getBalance from '../../substrate/get-balance';
-import waitNewBlocks from '../../substrate/wait-new-blocks';
-export const GAS_ARGS = { gas: 0x1000000, gasPrice: '0x01' };
+export const GAS_ARGS = {gas: 0x1000000, gasPrice: '0x01'};
let web3Connected = false;
export async function usingWeb3<T>(cb: (web3: Web3) => Promise<T> | T): Promise<T> {
@@ -37,16 +36,6 @@
provider.connection.close();
web3Connected = false;
}
-}
-
-/**
- * @deprecated Web3 update solved issue with deployment over ws provider
- */
-export async function usingWeb3Http<T>(cb: (web3: Web3) => Promise<T> | T): Promise<T> {
- const provider = new Web3.providers.HttpProvider(config.frontierUrl);
- const web3: Web3 = new Web3(provider);
-
- return await cb(web3);
}
export function collectionIdToAddress(address: number): string {
@@ -88,13 +77,13 @@
i(name, async () => {
await usingApi(async api => {
await usingWeb3(async web3 => {
- await cb({ api, web3 });
+ await cb({api, web3});
});
});
});
}
-itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, { only: true });
-itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, { skip: true });
+itWeb3.only = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {only: true});
+itWeb3.skip = (name: string, cb: (apis: { web3: Web3, api: ApiPromise }) => any) => itWeb3(name, cb, {skip: true});
export async function generateSubstrateEthPair(web3: Web3) {
const account = web3.eth.accounts.create();
@@ -119,7 +108,7 @@
}
}
output.sort((a, b) => a.logIndex - b.logIndex);
- return output.map(({ address, event, returnValues }) => {
+ return output.map(({address, event, returnValues}) => {
const args: { [key: string]: string } = {};
for (const key of Object.keys(returnValues)) {
if (!key.match(/^[0-9]+$/)) {
@@ -192,12 +181,12 @@
}
}
`);
- const Flipper = new web3.eth.Contract(compiled.abi, undefined, {
+ const flipperContract = new web3.eth.Contract(compiled.abi, undefined, {
data: compiled.object,
from: deployer,
...GAS_ARGS,
});
- const flipper = await Flipper.deploy({ data: compiled.object }).send({from: deployer});
+ const flipper = await flipperContract.deploy({data: compiled.object}).send({from: deployer});
return flipper;
}
@@ -225,12 +214,12 @@
}
}
`);
- const Collector = new web3.eth.Contract(compiled.abi, undefined, {
+ const collectorContract = new web3.eth.Contract(compiled.abi, undefined, {
data: compiled.object,
from: deployer,
...GAS_ARGS,
});
- const collector = await Collector.deploy({ data: compiled.object }).send({ from: deployer });
+ const collector = await collectorContract.deploy({data: compiled.object}).send({from: deployer});
return collector;
}
@@ -239,7 +228,7 @@
return new web3.eth.Contract(contractHelpersAbi as any, '0x842899ECF380553E8a4de75bF534cdf6fBF64049', {from: caller, ...GAS_ARGS});
}
-export async function executeEthTxOnSub(api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, { value = 0 }: {value?: bigint | number} = { }) {
+export async function executeEthTxOnSub(api: ApiPromise, from: IKeyringPair, to: any, mkTx: (methods: any) => any, {value = 0}: {value?: bigint | number} = { }) {
const tx = api.tx.evm.call(
subToEth(from.address),
to.options.address,
@@ -250,7 +239,7 @@
null,
);
const events = await submitTransactionAsync(from, tx);
- expect(events.find(({ event: {section, method}})=>section === 'evm' && method === 'Executed')).to.be.not.undefined;
+ expect(events.some(({event: {section, method}}) => section == 'evm' && method == 'Executed')).to.be.true;
}
export async function ethBalanceViaSub(api: ApiPromise, address: string): Promise<bigint> {
@@ -261,7 +250,6 @@
const before = await ethBalanceViaSub(api, user);
await call();
- await waitNewBlocks(api, 1);
const after = await ethBalanceViaSub(api, user);
tests/src/inflation.test.tsdiffbeforeafterboth--- a/tests/src/inflation.test.ts
+++ b/tests/src/inflation.test.ts
@@ -5,8 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi } from './substrate/substrate-api';
-import { BigNumber } from 'bignumber.js';
+import {default as usingApi} from './substrate/substrate-api';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -15,16 +14,20 @@
it('First year inflation is 10%', async () => {
await usingApi(async (api) => {
- const blockInterval = parseInt((await api.consts.inflation.inflationBlockInterval).toString());
- const totalIssuanceStart = new BigNumber((await api.query.inflation.startingYearTotalIssuance()).toString());
- const blockInflation = new BigNumber((await api.query.inflation.blockInflation()).toString());
+ const blockInterval = (api.consts.inflation.inflationBlockInterval).toBigInt();
+ const totalIssuanceStart = (await api.query.inflation.startingYearTotalIssuance()).toBigInt();
+ const blockInflation = (await api.query.inflation.blockInflation()).toBigInt();
- const YEAR = 5259600; // Blocks in one year
- const totalExpectedInflation = totalIssuanceStart.multipliedBy(0.1);
- const totalActualInflation = blockInflation.multipliedBy(YEAR / blockInterval);
+ const YEAR = 5259600n; // Blocks in one year
+ const totalExpectedInflation = totalIssuanceStart / 10n;
+ const totalActualInflation = blockInflation * YEAR / blockInterval;
const tolerance = 0.00001; // Relative difference per year between theoretical and actual inflation
- expect(totalExpectedInflation.dividedBy(totalActualInflation).minus(1).abs().toNumber()).to.be.lessThan(tolerance);
+ let abs = totalExpectedInflation / totalActualInflation - 1n;
+ if (abs < 0n) {
+ abs = -abs;
+ }
+ expect(abs <= tolerance).to.be.true;
});
});
tests/src/interfaces/augment-api-consts.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-consts.ts
@@ -0,0 +1,177 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { ApiTypes } from '@polkadot/api/types';
+import type { Vec, u128, u16, u32, u64, u8 } from '@polkadot/types';
+import type { Permill } from '@polkadot/types/interfaces/runtime';
+import type { FrameSupportPalletId, FrameSupportWeightsRuntimeDbWeight, FrameSupportWeightsWeightToFeeCoefficient, FrameSystemLimitsBlockLength, FrameSystemLimitsBlockWeights, SpVersionRuntimeVersion } from '@polkadot/types/lookup';
+import type { Codec } from '@polkadot/types/types';
+
+declare module '@polkadot/api/types/consts' {
+ export interface AugmentedConsts<ApiType> {
+ balances: {
+ /**
+ * The minimum amount required to keep an account open.
+ **/
+ existentialDeposit: u128 & AugmentedConst<ApiType>;
+ /**
+ * The maximum number of locks that should exist on an account.
+ * Not strictly enforced, but used for weight estimation.
+ **/
+ maxLocks: u32 & AugmentedConst<ApiType>;
+ /**
+ * The maximum number of named reserves that can exist on an account.
+ **/
+ maxReserves: u32 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ common: {
+ collectionAdminsLimit: u32 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ inflation: {
+ inflationBlockInterval: u32 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ system: {
+ /**
+ * Maximum number of block number to block hash mappings to keep (oldest pruned first).
+ **/
+ blockHashCount: u32 & AugmentedConst<ApiType>;
+ /**
+ * The maximum length of a block (in bytes).
+ **/
+ blockLength: FrameSystemLimitsBlockLength & AugmentedConst<ApiType>;
+ /**
+ * Block & extrinsics weights: base values and limits.
+ **/
+ blockWeights: FrameSystemLimitsBlockWeights & AugmentedConst<ApiType>;
+ /**
+ * The weight of runtime database operations the runtime can invoke.
+ **/
+ dbWeight: FrameSupportWeightsRuntimeDbWeight & AugmentedConst<ApiType>;
+ /**
+ * The designated SS85 prefix of this chain.
+ *
+ * This replaces the "ss58Format" property declared in the chain spec. Reason is
+ * that the runtime should know about the prefix in order to make use of it as
+ * an identifier of the chain.
+ **/
+ ss58Prefix: u16 & AugmentedConst<ApiType>;
+ /**
+ * Get the chain's current version.
+ **/
+ version: SpVersionRuntimeVersion & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ timestamp: {
+ /**
+ * The minimum period between blocks. Beware that this is different to the *expected*
+ * period that the block production apparatus provides. Your chosen consensus system will
+ * generally work with this to determine a sensible block time. e.g. For Aura, it will be
+ * double this period on default settings.
+ **/
+ minimumPeriod: u64 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ transactionPayment: {
+ /**
+ * A fee mulitplier for `Operational` extrinsics to compute "virtual tip" to boost their
+ * `priority`
+ *
+ * This value is multipled by the `final_fee` to obtain a "virtual tip" that is later
+ * added to a tip component in regular `priority` calculations.
+ * It means that a `Normal` transaction can front-run a similarly-sized `Operational`
+ * extrinsic (with no tip), by including a tip value greater than the virtual tip.
+ *
+ * ```rust,ignore
+ * // For `Normal`
+ * let priority = priority_calc(tip);
+ *
+ * // For `Operational`
+ * let virtual_tip = (inclusion_fee + tip) * OperationalFeeMultiplier;
+ * let priority = priority_calc(tip + virtual_tip);
+ * ```
+ *
+ * Note that since we use `final_fee` the multiplier applies also to the regular `tip`
+ * sent with the transaction. So, not only does the transaction get a priority bump based
+ * on the `inclusion_fee`, but we also amplify the impact of tips applied to `Operational`
+ * transactions.
+ **/
+ operationalFeeMultiplier: u8 & AugmentedConst<ApiType>;
+ /**
+ * The fee to be paid for making a transaction; the per-byte portion.
+ **/
+ transactionByteFee: u128 & AugmentedConst<ApiType>;
+ /**
+ * The polynomial that is applied in order to derive fee from weight.
+ **/
+ weightToFee: Vec<FrameSupportWeightsWeightToFeeCoefficient> & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ treasury: {
+ /**
+ * Percentage of spare funds (if any) that are burnt per spend period.
+ **/
+ burn: Permill & AugmentedConst<ApiType>;
+ /**
+ * The maximum number of approvals that can wait in the spending queue.
+ **/
+ maxApprovals: u32 & AugmentedConst<ApiType>;
+ /**
+ * The treasury's pallet id, used for deriving its sovereign account ID.
+ **/
+ palletId: FrameSupportPalletId & AugmentedConst<ApiType>;
+ /**
+ * Fraction of a proposal's value that should be bonded in order to place the proposal.
+ * An accepted proposal gets these back. A rejected proposal does not.
+ **/
+ proposalBond: Permill & AugmentedConst<ApiType>;
+ /**
+ * Minimum amount of funds that should be placed in a deposit for making a proposal.
+ **/
+ proposalBondMinimum: u128 & AugmentedConst<ApiType>;
+ /**
+ * Period between successive spends.
+ **/
+ spendPeriod: u32 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ vesting: {
+ maxVestingSchedules: u32 & AugmentedConst<ApiType>;
+ /**
+ * The minimum amount transferred to call `vested_transfer`.
+ **/
+ minVestedTransfer: u128 & AugmentedConst<ApiType>;
+ /**
+ * Generic const
+ **/
+ [key: string]: Codec;
+ };
+ }
+
+ export interface QueryableConsts<ApiType extends ApiTypes> extends AugmentedConsts<ApiType> {
+ [key: string]: QueryableModuleConsts;
+ }
+}
tests/src/interfaces/augment-api-errors.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-errors.ts
@@ -0,0 +1,528 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { ApiTypes } from '@polkadot/api/types';
+
+declare module '@polkadot/api/types/errors' {
+ export interface AugmentedErrors<ApiType> {
+ balances: {
+ /**
+ * Beneficiary account must pre-exist
+ **/
+ DeadAccount: AugmentedError<ApiType>;
+ /**
+ * Value too low to create account due to existential deposit
+ **/
+ ExistentialDeposit: AugmentedError<ApiType>;
+ /**
+ * A vesting schedule already exists for this account
+ **/
+ ExistingVestingSchedule: AugmentedError<ApiType>;
+ /**
+ * Balance too low to send value
+ **/
+ InsufficientBalance: AugmentedError<ApiType>;
+ /**
+ * Transfer/payment would kill account
+ **/
+ KeepAlive: AugmentedError<ApiType>;
+ /**
+ * Account liquidity restrictions prevent withdrawal
+ **/
+ LiquidityRestrictions: AugmentedError<ApiType>;
+ /**
+ * Number of named reserves exceed MaxReserves
+ **/
+ TooManyReserves: AugmentedError<ApiType>;
+ /**
+ * Vesting balance too high to send value
+ **/
+ VestingBalance: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ common: {
+ /**
+ * Account token limit exceeded per collection
+ **/
+ AccountTokenLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Can't transfer tokens to ethereum zero address
+ **/
+ AddressIsZero: AugmentedError<ApiType>;
+ /**
+ * Address is not in white list.
+ **/
+ AddressNotInAllowlist: AugmentedError<ApiType>;
+ /**
+ * Tried to approve more than owned
+ **/
+ CantApproveMoreThanOwned: AugmentedError<ApiType>;
+ /**
+ * Exceeded max admin amount
+ **/
+ CollectionAdminAmountExceeded: AugmentedError<ApiType>;
+ /**
+ * Collection description can not be longer than 255 char.
+ **/
+ CollectionDescriptionLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Collection name can not be longer than 63 char.
+ **/
+ CollectionNameLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * This collection does not exist.
+ **/
+ CollectionNotFound: AugmentedError<ApiType>;
+ /**
+ * Collection token limit exceeded
+ **/
+ CollectionTokenLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Token prefix can not be longer than 15 char.
+ **/
+ CollectionTokenPrefixLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Metadata flag frozen
+ **/
+ MetadataFlagFrozen: AugmentedError<ApiType>;
+ /**
+ * Sender parameter and item owner must be equal.
+ **/
+ MustBeTokenOwner: AugmentedError<ApiType>;
+ /**
+ * No permission to perform action
+ **/
+ NoPermission: AugmentedError<ApiType>;
+ /**
+ * Collection is not in mint mode.
+ **/
+ PublicMintingNotAllowed: AugmentedError<ApiType>;
+ /**
+ * Item not exists.
+ **/
+ TokenNotFound: AugmentedError<ApiType>;
+ /**
+ * Requested value more than approved.
+ **/
+ TokenValueNotEnough: AugmentedError<ApiType>;
+ /**
+ * Item balance not enough.
+ **/
+ TokenValueTooLow: AugmentedError<ApiType>;
+ /**
+ * variable_data exceeded data limit.
+ **/
+ TokenVariableDataLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Total collections bound exceeded.
+ **/
+ TotalCollectionsLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Collection settings not allowing items transferring
+ **/
+ TransferNotAllowed: AugmentedError<ApiType>;
+ /**
+ * Target collection doesn't supports this operation
+ **/
+ UnsupportedOperation: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ cumulusXcm: {
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ dmpQueue: {
+ /**
+ * The amount of weight given is possibly not enough for executing the message.
+ **/
+ OverLimit: AugmentedError<ApiType>;
+ /**
+ * The message index given is unknown.
+ **/
+ Unknown: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ ethereum: {
+ /**
+ * Signature is invalid.
+ **/
+ InvalidSignature: AugmentedError<ApiType>;
+ /**
+ * Pre-log is present, therefore transact is not allowed.
+ **/
+ PreLogExists: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ evm: {
+ /**
+ * Not enough balance to perform action
+ **/
+ BalanceLow: AugmentedError<ApiType>;
+ /**
+ * Calculating total fee overflowed
+ **/
+ FeeOverflow: AugmentedError<ApiType>;
+ /**
+ * Gas price is too low.
+ **/
+ GasPriceTooLow: AugmentedError<ApiType>;
+ /**
+ * Nonce is invalid
+ **/
+ InvalidNonce: AugmentedError<ApiType>;
+ /**
+ * Calculating total payment overflowed
+ **/
+ PaymentOverflow: AugmentedError<ApiType>;
+ /**
+ * Withdraw fee failed
+ **/
+ WithdrawFailed: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ evmCoderSubstrate: {
+ OutOfFund: AugmentedError<ApiType>;
+ OutOfGas: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ evmContractHelpers: {
+ /**
+ * This method is only executable by owner
+ **/
+ NoPermission: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ evmMigration: {
+ AccountIsNotMigrating: AugmentedError<ApiType>;
+ AccountNotEmpty: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ fungible: {
+ /**
+ * Tried to set data for fungible item
+ **/
+ FungibleItemsHaveData: AugmentedError<ApiType>;
+ /**
+ * Not default id passed as TokenId argument
+ **/
+ FungibleItemsHaveNoId: AugmentedError<ApiType>;
+ /**
+ * Not Fungible item data used to mint in Fungible collection.
+ **/
+ NotFungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ nft: {
+ /**
+ * Decimal_points parameter must be lower than MAX_DECIMAL_POINTS constant, currently it is 30.
+ **/
+ CollectionDecimalPointLimitExceeded: AugmentedError<ApiType>;
+ /**
+ * Collection limit bounds per collection exceeded
+ **/
+ CollectionLimitBoundsExceeded: AugmentedError<ApiType>;
+ /**
+ * This address is not set as sponsor, use setCollectionSponsor first.
+ **/
+ ConfirmUnsetSponsorFail: AugmentedError<ApiType>;
+ /**
+ * Length of items properties must be greater than 0.
+ **/
+ EmptyArgument: AugmentedError<ApiType>;
+ /**
+ * Tried to enable permissions which are only permitted to be disabled
+ **/
+ OwnerPermissionsCantBeReverted: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ nonfungible: {
+ /**
+ * Used amount > 1 with NFT
+ **/
+ NonfungibleItemsHaveNoAmount: AugmentedError<ApiType>;
+ /**
+ * Not Nonfungible item data used to mint in Nonfungible collection.
+ **/
+ NotNonfungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ parachainSystem: {
+ /**
+ * The inherent which supplies the host configuration did not run this block
+ **/
+ HostConfigurationNotAvailable: AugmentedError<ApiType>;
+ /**
+ * No code upgrade has been authorized.
+ **/
+ NothingAuthorized: AugmentedError<ApiType>;
+ /**
+ * No validation function upgrade is currently scheduled.
+ **/
+ NotScheduled: AugmentedError<ApiType>;
+ /**
+ * Attempt to upgrade validation function while existing upgrade pending
+ **/
+ OverlappingUpgrades: AugmentedError<ApiType>;
+ /**
+ * Polkadot currently prohibits this parachain from upgrading its validation function
+ **/
+ ProhibitedByPolkadot: AugmentedError<ApiType>;
+ /**
+ * The supplied validation function has compiled into a blob larger than Polkadot is
+ * willing to run
+ **/
+ TooBig: AugmentedError<ApiType>;
+ /**
+ * The given code upgrade has not been authorized.
+ **/
+ Unauthorized: AugmentedError<ApiType>;
+ /**
+ * The inherent which supplies the validation data did not run this block
+ **/
+ ValidationDataNotAvailable: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ polkadotXcm: {
+ /**
+ * The location is invalid since it already has a subscription from us.
+ **/
+ AlreadySubscribed: AugmentedError<ApiType>;
+ /**
+ * The given location could not be used (e.g. because it cannot be expressed in the
+ * desired version of XCM).
+ **/
+ BadLocation: AugmentedError<ApiType>;
+ /**
+ * The version of the `Versioned` value used is not able to be interpreted.
+ **/
+ BadVersion: AugmentedError<ApiType>;
+ /**
+ * Could not re-anchor the assets to declare the fees for the destination chain.
+ **/
+ CannotReanchor: AugmentedError<ApiType>;
+ /**
+ * The destination `MultiLocation` provided cannot be inverted.
+ **/
+ DestinationNotInvertible: AugmentedError<ApiType>;
+ /**
+ * The assets to be sent are empty.
+ **/
+ Empty: AugmentedError<ApiType>;
+ /**
+ * The message execution fails the filter.
+ **/
+ Filtered: AugmentedError<ApiType>;
+ /**
+ * Origin is invalid for sending.
+ **/
+ InvalidOrigin: AugmentedError<ApiType>;
+ /**
+ * The referenced subscription could not be found.
+ **/
+ NoSubscription: AugmentedError<ApiType>;
+ /**
+ * There was some other issue (i.e. not to do with routing) in sending the message. Perhaps
+ * a lack of space for buffering the message.
+ **/
+ SendFailure: AugmentedError<ApiType>;
+ /**
+ * Too many assets have been attempted for transfer.
+ **/
+ TooManyAssets: AugmentedError<ApiType>;
+ /**
+ * The desired destination was unreachable, generally because there is a no way of routing
+ * to it.
+ **/
+ Unreachable: AugmentedError<ApiType>;
+ /**
+ * The message's weight could not be determined.
+ **/
+ UnweighableMessage: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ refungible: {
+ /**
+ * Not Refungible item data used to mint in Refungible collection.
+ **/
+ NotRefungibleDataUsedToMintFungibleCollectionToken: AugmentedError<ApiType>;
+ /**
+ * Maximum refungibility exceeded
+ **/
+ WrongRefungiblePieces: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ scheduler: {
+ /**
+ * Failed to schedule a call
+ **/
+ FailedToSchedule: AugmentedError<ApiType>;
+ /**
+ * Cannot find the scheduled call.
+ **/
+ NotFound: AugmentedError<ApiType>;
+ /**
+ * Reschedule failed because it does not change scheduled time.
+ **/
+ RescheduleNoChange: AugmentedError<ApiType>;
+ /**
+ * Given target block number is in the past.
+ **/
+ TargetBlockNumberInPast: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ sudo: {
+ /**
+ * Sender must be the Sudo account
+ **/
+ RequireSudo: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ system: {
+ /**
+ * Failed to extract the runtime version from the new runtime.
+ *
+ * Either calling `Core_version` or decoding `RuntimeVersion` failed.
+ **/
+ FailedToExtractRuntimeVersion: AugmentedError<ApiType>;
+ /**
+ * The name of specification does not match between the current runtime
+ * and the new runtime.
+ **/
+ InvalidSpecName: AugmentedError<ApiType>;
+ /**
+ * Suicide called when the account has non-default composite data.
+ **/
+ NonDefaultComposite: AugmentedError<ApiType>;
+ /**
+ * There is a non-zero reference count preventing the account from being purged.
+ **/
+ NonZeroRefCount: AugmentedError<ApiType>;
+ /**
+ * The specification version is not allowed to decrease between the current runtime
+ * and the new runtime.
+ **/
+ SpecVersionNeedsToIncrease: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ treasury: {
+ /**
+ * Proposer's balance is too low.
+ **/
+ InsufficientProposersBalance: AugmentedError<ApiType>;
+ /**
+ * No proposal or bounty at that index.
+ **/
+ InvalidIndex: AugmentedError<ApiType>;
+ /**
+ * Too many approvals in the queue.
+ **/
+ TooManyApprovals: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ vesting: {
+ /**
+ * Amount being transferred is too low to create a vesting schedule.
+ **/
+ AmountLow: AugmentedError<ApiType>;
+ /**
+ * The account already has `MaxVestingSchedules` count of schedules and thus
+ * cannot add another one. Consider merging existing schedules in order to add another.
+ **/
+ AtMaxVestingSchedules: AugmentedError<ApiType>;
+ /**
+ * Failed to create a new schedule because some parameter was invalid.
+ **/
+ InvalidScheduleParams: AugmentedError<ApiType>;
+ /**
+ * The account given is not vesting.
+ **/
+ NotVesting: AugmentedError<ApiType>;
+ /**
+ * An index was out of bounds of the vesting schedules.
+ **/
+ ScheduleIndexOutOfBounds: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ xcmpQueue: {
+ /**
+ * Bad XCM data.
+ **/
+ BadXcm: AugmentedError<ApiType>;
+ /**
+ * Bad XCM origin.
+ **/
+ BadXcmOrigin: AugmentedError<ApiType>;
+ /**
+ * Failed to send XCM message.
+ **/
+ FailedToSend: AugmentedError<ApiType>;
+ /**
+ * Generic error
+ **/
+ [key: string]: AugmentedError<ApiType>;
+ };
+ }
+
+ export interface DecoratedErrors<ApiType extends ApiTypes> extends AugmentedErrors<ApiType> {
+ [key: string]: ModuleErrors<ApiType>;
+ }
+}
tests/src/interfaces/augment-api-events.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-events.ts
@@ -0,0 +1,544 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { EthereumLog, EvmCoreErrorExitReason } from './ethereum';
+import type { PalletCommonAccountBasicCrossAccountIdRepr } from './nft';
+import type { ApiTypes } from '@polkadot/api/types';
+import type { Bytes, Null, Option, Result, U256, U8aFixed, u128, u32, u64, u8 } from '@polkadot/types';
+import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
+import type { FrameSupportTokensMiscBalanceStatus, FrameSupportWeightsDispatchInfo, SpRuntimeDispatchError, XcmV1MultiLocation, XcmV2Response, XcmV2TraitsError, XcmV2TraitsOutcome, XcmV2Xcm, XcmVersionedMultiAssets, XcmVersionedMultiLocation } from '@polkadot/types/lookup';
+import type { ITuple } from '@polkadot/types/types';
+
+declare module '@polkadot/api/types/events' {
+ export interface AugmentedEvents<ApiType> {
+ balances: {
+ /**
+ * A balance was set by root. \[who, free, reserved\]
+ **/
+ BalanceSet: AugmentedEvent<ApiType, [AccountId32, u128, u128]>;
+ /**
+ * Some amount was deposited into the account (e.g. for transaction fees). \[who,
+ * deposit\]
+ **/
+ Deposit: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * An account was removed whose balance was non-zero but below ExistentialDeposit,
+ * resulting in an outright loss. \[account, balance\]
+ **/
+ DustLost: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * An account was created with some free balance. \[account, free_balance\]
+ **/
+ Endowed: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Some balance was reserved (moved from free to reserved). \[who, value\]
+ **/
+ Reserved: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Some balance was moved from the reserve of the first account to the second account.
+ * Final argument indicates the destination balance type.
+ * \[from, to, balance, destination_status\]
+ **/
+ ReserveRepatriated: AugmentedEvent<ApiType, [AccountId32, AccountId32, u128, FrameSupportTokensMiscBalanceStatus]>;
+ /**
+ * Some amount was removed from the account (e.g. for misbehavior). \[who,
+ * amount_slashed\]
+ **/
+ Slashed: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Transfer succeeded. \[from, to, value\]
+ **/
+ Transfer: AugmentedEvent<ApiType, [AccountId32, AccountId32, u128]>;
+ /**
+ * Some balance was unreserved (moved from reserved to free). \[who, value\]
+ **/
+ Unreserved: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Some amount was withdrawn from the account (e.g. for transaction fees). \[who, value\]
+ **/
+ Withdraw: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ common: {
+ /**
+ * * collection_id
+ *
+ * * item_id
+ *
+ * * sender
+ *
+ * * spender
+ *
+ * * amount
+ **/
+ Approved: AugmentedEvent<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr, u128]>;
+ /**
+ * New collection was created
+ *
+ * # Arguments
+ *
+ * * collection_id: Globally unique identifier of newly created collection.
+ *
+ * * mode: [CollectionMode] converted into u8.
+ *
+ * * account_id: Collection owner.
+ **/
+ CollectionCreated: AugmentedEvent<ApiType, [u32, u8, AccountId32]>;
+ /**
+ * New item was created.
+ *
+ * # Arguments
+ *
+ * * collection_id: Id of the collection where item was created.
+ *
+ * * item_id: Id of an item. Unique within the collection.
+ *
+ * * recipient: Owner of newly created item
+ *
+ * * amount: Always 1 for NFT
+ **/
+ ItemCreated: AugmentedEvent<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, u128]>;
+ /**
+ * Collection item was burned.
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * item_id: Identifier of burned NFT.
+ *
+ * * owner: which user has destroyed its tokens
+ *
+ * * amount: Always 1 for NFT
+ **/
+ ItemDestroyed: AugmentedEvent<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, u128]>;
+ /**
+ * Item was transferred
+ *
+ * * collection_id: Id of collection to which item is belong
+ *
+ * * item_id: Id of an item
+ *
+ * * sender: Original owner of item
+ *
+ * * recipient: New owner of item
+ *
+ * * amount: Always 1 for NFT
+ **/
+ Transfer: AugmentedEvent<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr, u128]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ cumulusXcm: {
+ /**
+ * Downward message executed with the given outcome.
+ * \[ id, outcome \]
+ **/
+ ExecutedDownward: AugmentedEvent<ApiType, [U8aFixed, XcmV2TraitsOutcome]>;
+ /**
+ * Downward message is invalid XCM.
+ * \[ id \]
+ **/
+ InvalidFormat: AugmentedEvent<ApiType, [U8aFixed]>;
+ /**
+ * Downward message is unsupported version of XCM.
+ * \[ id \]
+ **/
+ UnsupportedVersion: AugmentedEvent<ApiType, [U8aFixed]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ dmpQueue: {
+ /**
+ * Downward message executed with the given outcome.
+ * \[ id, outcome \]
+ **/
+ ExecutedDownward: AugmentedEvent<ApiType, [U8aFixed, XcmV2TraitsOutcome]>;
+ /**
+ * Downward message is invalid XCM.
+ * \[ id \]
+ **/
+ InvalidFormat: AugmentedEvent<ApiType, [U8aFixed]>;
+ /**
+ * Downward message is overweight and was placed in the overweight queue.
+ * \[ id, index, required \]
+ **/
+ OverweightEnqueued: AugmentedEvent<ApiType, [U8aFixed, u64, u64]>;
+ /**
+ * Downward message from the overweight queue was executed.
+ * \[ index, used \]
+ **/
+ OverweightServiced: AugmentedEvent<ApiType, [u64, u64]>;
+ /**
+ * Downward message is unsupported version of XCM.
+ * \[ id \]
+ **/
+ UnsupportedVersion: AugmentedEvent<ApiType, [U8aFixed]>;
+ /**
+ * The weight limit for handling downward messages was reached.
+ * \[ id, remaining, required \]
+ **/
+ WeightExhausted: AugmentedEvent<ApiType, [U8aFixed, u64, u64]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ ethereum: {
+ /**
+ * An ethereum transaction was successfully executed. [from, to/contract_address, transaction_hash, exit_reason]
+ **/
+ Executed: AugmentedEvent<ApiType, [H160, H160, H256, EvmCoreErrorExitReason]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ evm: {
+ /**
+ * A deposit has been made at a given address. \[sender, address, value\]
+ **/
+ BalanceDeposit: AugmentedEvent<ApiType, [AccountId32, H160, U256]>;
+ /**
+ * A withdrawal has been made from a given address. \[sender, address, value\]
+ **/
+ BalanceWithdraw: AugmentedEvent<ApiType, [AccountId32, H160, U256]>;
+ /**
+ * A contract has been created at given \[address\].
+ **/
+ Created: AugmentedEvent<ApiType, [H160]>;
+ /**
+ * A \[contract\] was attempted to be created, but the execution failed.
+ **/
+ CreatedFailed: AugmentedEvent<ApiType, [H160]>;
+ /**
+ * A \[contract\] has been executed successfully with states applied.
+ **/
+ Executed: AugmentedEvent<ApiType, [H160]>;
+ /**
+ * A \[contract\] has been executed with errors. States are reverted with only gas fees applied.
+ **/
+ ExecutedFailed: AugmentedEvent<ApiType, [H160]>;
+ /**
+ * Ethereum events from contracts.
+ **/
+ Log: AugmentedEvent<ApiType, [EthereumLog]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ parachainSystem: {
+ /**
+ * Downward messages were processed using the given weight.
+ * \[ weight_used, result_mqc_head \]
+ **/
+ DownwardMessagesProcessed: AugmentedEvent<ApiType, [u64, H256]>;
+ /**
+ * Some downward messages have been received and will be processed.
+ * \[ count \]
+ **/
+ DownwardMessagesReceived: AugmentedEvent<ApiType, [u32]>;
+ /**
+ * An upgrade has been authorized.
+ **/
+ UpgradeAuthorized: AugmentedEvent<ApiType, [H256]>;
+ /**
+ * The validation function was applied as of the contained relay chain block number.
+ **/
+ ValidationFunctionApplied: AugmentedEvent<ApiType, [u32]>;
+ /**
+ * The relay-chain aborted the upgrade process.
+ **/
+ ValidationFunctionDiscarded: AugmentedEvent<ApiType, []>;
+ /**
+ * The validation function has been scheduled to apply.
+ **/
+ ValidationFunctionStored: AugmentedEvent<ApiType, []>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ polkadotXcm: {
+ /**
+ * Some assets have been placed in an asset trap.
+ *
+ * \[ hash, origin, assets \]
+ **/
+ AssetsTrapped: AugmentedEvent<ApiType, [H256, XcmV1MultiLocation, XcmVersionedMultiAssets]>;
+ /**
+ * Execution of an XCM message was attempted.
+ *
+ * \[ outcome \]
+ **/
+ Attempted: AugmentedEvent<ApiType, [XcmV2TraitsOutcome]>;
+ /**
+ * Expected query response has been received but the origin location of the response does
+ * not match that expected. The query remains registered for a later, valid, response to
+ * be received and acted upon.
+ *
+ * \[ origin location, id, expected location \]
+ **/
+ InvalidResponder: AugmentedEvent<ApiType, [XcmV1MultiLocation, u64, Option<XcmV1MultiLocation>]>;
+ /**
+ * Expected query response has been received but the expected origin location placed in
+ * storate by this runtime previously cannot be decoded. The query remains registered.
+ *
+ * This is unexpected (since a location placed in storage in a previously executing
+ * runtime should be readable prior to query timeout) and dangerous since the possibly
+ * valid response will be dropped. Manual governance intervention is probably going to be
+ * needed.
+ *
+ * \[ origin location, id \]
+ **/
+ InvalidResponderVersion: AugmentedEvent<ApiType, [XcmV1MultiLocation, u64]>;
+ /**
+ * Query response has been received and query is removed. The registered notification has
+ * been dispatched and executed successfully.
+ *
+ * \[ id, pallet index, call index \]
+ **/
+ Notified: AugmentedEvent<ApiType, [u64, u8, u8]>;
+ /**
+ * Query response has been received and query is removed. The dispatch was unable to be
+ * decoded into a `Call`; this might be due to dispatch function having a signature which
+ * is not `(origin, QueryId, Response)`.
+ *
+ * \[ id, pallet index, call index \]
+ **/
+ NotifyDecodeFailed: AugmentedEvent<ApiType, [u64, u8, u8]>;
+ /**
+ * Query response has been received and query is removed. There was a general error with
+ * dispatching the notification call.
+ *
+ * \[ id, pallet index, call index \]
+ **/
+ NotifyDispatchError: AugmentedEvent<ApiType, [u64, u8, u8]>;
+ /**
+ * Query response has been received and query is removed. The registered notification could
+ * not be dispatched because the dispatch weight is greater than the maximum weight
+ * originally budgeted by this runtime for the query result.
+ *
+ * \[ id, pallet index, call index, actual weight, max budgeted weight \]
+ **/
+ NotifyOverweight: AugmentedEvent<ApiType, [u64, u8, u8, u64, u64]>;
+ /**
+ * A given location which had a version change subscription was dropped owing to an error
+ * migrating the location to our new XCM format.
+ *
+ * \[ location, query ID \]
+ **/
+ NotifyTargetMigrationFail: AugmentedEvent<ApiType, [XcmVersionedMultiLocation, u64]>;
+ /**
+ * A given location which had a version change subscription was dropped owing to an error
+ * sending the notification to it.
+ *
+ * \[ location, query ID, error \]
+ **/
+ NotifyTargetSendFail: AugmentedEvent<ApiType, [XcmV1MultiLocation, u64, XcmV2TraitsError]>;
+ /**
+ * Query response has been received and is ready for taking with `take_response`. There is
+ * no registered notification call.
+ *
+ * \[ id, response \]
+ **/
+ ResponseReady: AugmentedEvent<ApiType, [u64, XcmV2Response]>;
+ /**
+ * Received query response has been read and removed.
+ *
+ * \[ id \]
+ **/
+ ResponseTaken: AugmentedEvent<ApiType, [u64]>;
+ /**
+ * A XCM message was sent.
+ *
+ * \[ origin, destination, message \]
+ **/
+ Sent: AugmentedEvent<ApiType, [XcmV1MultiLocation, XcmV1MultiLocation, XcmV2Xcm]>;
+ /**
+ * The supported version of a location has been changed. This might be through an
+ * automatic notification or a manual intervention.
+ *
+ * \[ location, XCM version \]
+ **/
+ SupportedVersionChanged: AugmentedEvent<ApiType, [XcmV1MultiLocation, u32]>;
+ /**
+ * Query response received which does not match a registered query. This may be because a
+ * matching query was never registered, it may be because it is a duplicate response, or
+ * because the query timed out.
+ *
+ * \[ origin location, id \]
+ **/
+ UnexpectedResponse: AugmentedEvent<ApiType, [XcmV1MultiLocation, u64]>;
+ /**
+ * An XCM version change notification message has been attempted to be sent.
+ *
+ * \[ destination, result \]
+ **/
+ VersionChangeNotified: AugmentedEvent<ApiType, [XcmV1MultiLocation, u32]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ scheduler: {
+ /**
+ * Canceled some task. \[when, index\]
+ **/
+ Canceled: AugmentedEvent<ApiType, [u32, u32]>;
+ /**
+ * Dispatched some task. \[task, id, result\]
+ **/
+ Dispatched: AugmentedEvent<ApiType, [ITuple<[u32, u32]>, Option<Bytes>, Result<Null, SpRuntimeDispatchError>]>;
+ /**
+ * Scheduled some task. \[when, index\]
+ **/
+ Scheduled: AugmentedEvent<ApiType, [u32, u32]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ sudo: {
+ /**
+ * The \[sudoer\] just switched identity; the old key is supplied.
+ **/
+ KeyChanged: AugmentedEvent<ApiType, [AccountId32]>;
+ /**
+ * A sudo just took place. \[result\]
+ **/
+ Sudid: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
+ /**
+ * A sudo just took place. \[result\]
+ **/
+ SudoAsDone: AugmentedEvent<ApiType, [Result<Null, SpRuntimeDispatchError>]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ system: {
+ /**
+ * `:code` was updated.
+ **/
+ CodeUpdated: AugmentedEvent<ApiType, []>;
+ /**
+ * An extrinsic failed. \[error, info\]
+ **/
+ ExtrinsicFailed: AugmentedEvent<ApiType, [SpRuntimeDispatchError, FrameSupportWeightsDispatchInfo]>;
+ /**
+ * An extrinsic completed successfully. \[info\]
+ **/
+ ExtrinsicSuccess: AugmentedEvent<ApiType, [FrameSupportWeightsDispatchInfo]>;
+ /**
+ * An \[account\] was reaped.
+ **/
+ KilledAccount: AugmentedEvent<ApiType, [AccountId32]>;
+ /**
+ * A new \[account\] was created.
+ **/
+ NewAccount: AugmentedEvent<ApiType, [AccountId32]>;
+ /**
+ * On on-chain remark happened. \[origin, remark_hash\]
+ **/
+ Remarked: AugmentedEvent<ApiType, [AccountId32, H256]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ treasury: {
+ /**
+ * Some funds have been allocated. \[proposal_index, award, beneficiary\]
+ **/
+ Awarded: AugmentedEvent<ApiType, [u32, u128, AccountId32]>;
+ /**
+ * Some of our funds have been burnt. \[burn\]
+ **/
+ Burnt: AugmentedEvent<ApiType, [u128]>;
+ /**
+ * Some funds have been deposited. \[deposit\]
+ **/
+ Deposit: AugmentedEvent<ApiType, [u128]>;
+ /**
+ * New proposal. \[proposal_index\]
+ **/
+ Proposed: AugmentedEvent<ApiType, [u32]>;
+ /**
+ * A proposal was rejected; funds were slashed. \[proposal_index, slashed\]
+ **/
+ Rejected: AugmentedEvent<ApiType, [u32, u128]>;
+ /**
+ * Spending has finished; this is the amount that rolls over until next spend.
+ * \[budget_remaining\]
+ **/
+ Rollover: AugmentedEvent<ApiType, [u128]>;
+ /**
+ * We have ended a spend period and will now allocate funds. \[budget_remaining\]
+ **/
+ Spending: AugmentedEvent<ApiType, [u128]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ vesting: {
+ /**
+ * An \[account\] has become fully vested.
+ **/
+ VestingCompleted: AugmentedEvent<ApiType, [AccountId32]>;
+ /**
+ * The amount vested has been updated. This could indicate a change in funds available.
+ * The balance given is the amount which is left unvested (and thus locked).
+ * \[account, unvested\]
+ **/
+ VestingUpdated: AugmentedEvent<ApiType, [AccountId32, u128]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ xcmpQueue: {
+ /**
+ * Bad XCM format used.
+ **/
+ BadFormat: AugmentedEvent<ApiType, [Option<H256>]>;
+ /**
+ * Bad XCM version used.
+ **/
+ BadVersion: AugmentedEvent<ApiType, [Option<H256>]>;
+ /**
+ * Some XCM failed.
+ **/
+ Fail: AugmentedEvent<ApiType, [Option<H256>, XcmV2TraitsError]>;
+ /**
+ * Some XCM was executed ok.
+ **/
+ Success: AugmentedEvent<ApiType, [Option<H256>]>;
+ /**
+ * An upward message was sent to the relay chain.
+ **/
+ UpwardMessageSent: AugmentedEvent<ApiType, [Option<H256>]>;
+ /**
+ * An HRMP message was sent to a sibling parachain.
+ **/
+ XcmpMessageSent: AugmentedEvent<ApiType, [Option<H256>]>;
+ /**
+ * Generic event
+ **/
+ [key: string]: AugmentedEvent<ApiType>;
+ };
+ }
+
+ export interface DecoratedEvents<ApiType extends ApiTypes> extends AugmentedEvents<ApiType> {
+ [key: string]: ModuleEvents<ApiType>;
+ }
+}
tests/src/interfaces/augment-api-query.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-query.ts
@@ -0,0 +1,596 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { EthereumBlock, EthereumReceipt, EthereumTransactionLegacyTransaction, FpRpcTransactionStatus } from './ethereum';
+import type { NftDataStructsCollection, PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, PalletUnqSchedulerCallSpec, PalletUnqSchedulerReleases, PalletUnqSchedulerScheduledV2 } from './nft';
+import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';
+import type { ApiTypes } from '@polkadot/api/types';
+import type { BTreeMap, Bytes, Option, U256, Vec, bool, u128, u16, u32, u64 } from '@polkadot/types';
+import type { AccountId32, H160, H256 } from '@polkadot/types/interfaces/runtime';
+import type { FrameSupportWeightsPerDispatchClassU64, FrameSystemAccountInfo, FrameSystemEventRecord, FrameSystemLastRuntimeUpgradeInfo, FrameSystemPhase, PalletBalancesAccountData, PalletBalancesBalanceLock, PalletBalancesReleases, PalletBalancesReserveData, PalletTransactionPaymentReleases, PalletTreasuryProposal, PalletVestingReleases, PalletVestingVestingInfo, PolkadotCorePrimitivesOutboundHrmpMessage, PolkadotPrimitivesV1UpgradeRestriction, SpRuntimeGenericDigest } from '@polkadot/types/lookup';
+import type { AnyNumber, ITuple, Observable } from '@polkadot/types/types';
+
+declare module '@polkadot/api/types/storage' {
+ export interface AugmentedQueries<ApiType> {
+ balances: {
+ /**
+ * The balance of an account.
+ *
+ * NOTE: This is only used in the case that this pallet is used to store balances.
+ **/
+ account: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<PalletBalancesAccountData>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
+ /**
+ * Any liquidity locks on some account balances.
+ * NOTE: Should only be accessed when setting, changing and freeing a lock.
+ **/
+ locks: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<PalletBalancesBalanceLock>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
+ /**
+ * Named reserves on some account balances.
+ **/
+ reserves: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Vec<PalletBalancesReserveData>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
+ /**
+ * Storage version of the pallet.
+ *
+ * This is set to v2.0.0 for new networks.
+ **/
+ storageVersion: AugmentedQuery<ApiType, () => Observable<PalletBalancesReleases>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The total units issued in the system.
+ **/
+ totalIssuance: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ charging: {
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ common: {
+ adminAmount: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Allowlisted collection users
+ **/
+ allowlist: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Collection info
+ **/
+ collectionById: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<NftDataStructsCollection>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ createdCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ destroyedCollectionCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * List of collection admins
+ **/
+ isAdmin: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<bool>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ dmpQueue: {
+ /**
+ * The configuration.
+ **/
+ configuration: AugmentedQuery<ApiType, () => Observable<CumulusPalletDmpQueueConfigData>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The overweight messages.
+ **/
+ overweight: AugmentedQuery<ApiType, (arg: u64 | AnyNumber | Uint8Array) => Observable<Option<ITuple<[u32, Bytes]>>>, [u64]> & QueryableStorageEntry<ApiType, [u64]>;
+ /**
+ * The page index.
+ **/
+ pageIndex: AugmentedQuery<ApiType, () => Observable<CumulusPalletDmpQueuePageIndexData>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The queue pages.
+ **/
+ pages: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<ITuple<[u32, Bytes]>>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ ethereum: {
+ blockHash: AugmentedQuery<ApiType, (arg: U256 | AnyNumber | Uint8Array) => Observable<H256>, [U256]> & QueryableStorageEntry<ApiType, [U256]>;
+ /**
+ * The current Ethereum block.
+ **/
+ currentBlock: AugmentedQuery<ApiType, () => Observable<Option<EthereumBlock>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The current Ethereum receipts.
+ **/
+ currentReceipts: AugmentedQuery<ApiType, () => Observable<Option<Vec<EthereumReceipt>>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The current transaction statuses.
+ **/
+ currentTransactionStatuses: AugmentedQuery<ApiType, () => Observable<Option<Vec<FpRpcTransactionStatus>>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Current building block's transactions and receipts.
+ **/
+ pending: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[EthereumTransactionLegacyTransaction, FpRpcTransactionStatus, EthereumReceipt]>>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ evm: {
+ accountCodes: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<Bytes>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ accountStorages: AugmentedQuery<ApiType, (arg1: H160 | string | Uint8Array, arg2: H256 | string | Uint8Array) => Observable<H256>, [H160, H256]> & QueryableStorageEntry<ApiType, [H160, H256]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ evmCoderSubstrate: {
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ evmContractHelpers: {
+ allowlist: AugmentedQuery<ApiType, (arg1: H160 | string | Uint8Array, arg2: H160 | string | Uint8Array) => Observable<bool>, [H160, H160]> & QueryableStorageEntry<ApiType, [H160, H160]>;
+ allowlistEnabled: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<bool>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ owner: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<H160>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ selfSponsoring: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<bool>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ sponsorBasket: AugmentedQuery<ApiType, (arg1: H160 | string | Uint8Array, arg2: H160 | string | Uint8Array) => Observable<Option<u32>>, [H160, H160]> & QueryableStorageEntry<ApiType, [H160, H160]>;
+ sponsoringRateLimit: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<u32>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ evmMigration: {
+ migrationPending: AugmentedQuery<ApiType, (arg: H160 | string | Uint8Array) => Observable<bool>, [H160]> & QueryableStorageEntry<ApiType, [H160]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ fungible: {
+ allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ totalSupply: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ inflation: {
+ /**
+ * Current block inflation
+ **/
+ blockInflation: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * starting year total issuance
+ **/
+ startingYearTotalIssuance: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ nft: {
+ /**
+ * Used for migrations
+ **/
+ chainVersion: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * (Collection id (controlled?2), who created (real))
+ * TODO: Off chain worker should remove from this map when collection gets removed
+ **/
+ createItemBasket: AugmentedQuery<ApiType, (arg: ITuple<[u32, AccountId32]> | [u32 | AnyNumber | Uint8Array, AccountId32 | string | Uint8Array]) => Observable<u32>, [ITuple<[u32, AccountId32]>]> & QueryableStorageEntry<ApiType, [ITuple<[u32, AccountId32]>]>;
+ /**
+ * Collection id (controlled?2), owning user (real)
+ **/
+ fungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: AccountId32 | string | Uint8Array) => Observable<u32>, [u32, AccountId32]> & QueryableStorageEntry<ApiType, [u32, AccountId32]>;
+ /**
+ * Collection id (controlled?2), token id (controlled?2)
+ **/
+ nftTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Collection id (controlled?2), token id (controlled?2)
+ **/
+ reFungibleTransferBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Variable metadata sponsoring
+ * Collection id (controlled?2), token id (controlled?2)
+ **/
+ variableMetaDataBasket: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<u32>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ nftPayment: {
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ nonfungible: {
+ accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletCommonAccountBasicCrossAccountIdRepr>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Used to enumerate tokens owned by account
+ **/
+ owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32]>;
+ tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletNonfungibleItemData>>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ parachainInfo: {
+ parachainId: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ parachainSystem: {
+ /**
+ * The number of HRMP messages we observed in `on_initialize` and thus used that number for
+ * announcing the weight of `on_initialize` and `on_finalize`.
+ **/
+ announcedHrmpMessagesPerCandidate: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The next authorized upgrade, if there is one.
+ **/
+ authorizedUpgrade: AugmentedQuery<ApiType, () => Observable<Option<H256>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Were the validation data set to notify the relay chain?
+ **/
+ didSetValidationCode: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The parachain host configuration that was obtained from the relay parent.
+ *
+ * This field is meant to be updated each block with the validation data inherent. Therefore,
+ * before processing of the inherent, e.g. in `on_initialize` this data may be stale.
+ *
+ * This data is also absent from the genesis.
+ **/
+ hostConfiguration: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV1AbridgedHostConfiguration>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * HRMP messages that were sent in a block.
+ *
+ * This will be cleared in `on_initialize` of each new block.
+ **/
+ hrmpOutboundMessages: AugmentedQuery<ApiType, () => Observable<Vec<PolkadotCorePrimitivesOutboundHrmpMessage>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * HRMP watermark that was set in a block.
+ *
+ * This will be cleared in `on_initialize` of each new block.
+ **/
+ hrmpWatermark: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The last downward message queue chain head we have observed.
+ *
+ * This value is loaded before and saved after processing inbound downward messages carried
+ * by the system inherent.
+ **/
+ lastDmqMqcHead: AugmentedQuery<ApiType, () => Observable<H256>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The message queue chain heads we have observed per each channel incoming channel.
+ *
+ * This value is loaded before and saved after processing inbound downward messages carried
+ * by the system inherent.
+ **/
+ lastHrmpMqcHeads: AugmentedQuery<ApiType, () => Observable<BTreeMap<u32, H256>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Validation code that is set by the parachain and is to be communicated to collator and
+ * consequently the relay-chain.
+ *
+ * This will be cleared in `on_initialize` of each new block if no other pallet already set
+ * the value.
+ **/
+ newValidationCode: AugmentedQuery<ApiType, () => Observable<Option<Bytes>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Upward messages that are still pending and not yet send to the relay chain.
+ **/
+ pendingUpwardMessages: AugmentedQuery<ApiType, () => Observable<Vec<Bytes>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * In case of a scheduled upgrade, this storage field contains the validation code to be applied.
+ *
+ * As soon as the relay chain gives us the go-ahead signal, we will overwrite the [`:code`][well_known_keys::CODE]
+ * which will result the next block process with the new validation code. This concludes the upgrade process.
+ *
+ * [well_known_keys::CODE]: sp_core::storage::well_known_keys::CODE
+ **/
+ pendingValidationCode: AugmentedQuery<ApiType, () => Observable<Bytes>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Number of downward messages processed in a block.
+ *
+ * This will be cleared in `on_initialize` of each new block.
+ **/
+ processedDownwardMessages: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The snapshot of some state related to messaging relevant to the current parachain as per
+ * the relay parent.
+ *
+ * This field is meant to be updated each block with the validation data inherent. Therefore,
+ * before processing of the inherent, e.g. in `on_initialize` this data may be stale.
+ *
+ * This data is also absent from the genesis.
+ **/
+ relevantMessagingState: AugmentedQuery<ApiType, () => Observable<Option<CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The weight we reserve at the beginning of the block for processing DMP messages. This
+ * overrides the amount set in the Config trait.
+ **/
+ reservedDmpWeightOverride: AugmentedQuery<ApiType, () => Observable<Option<u64>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The weight we reserve at the beginning of the block for processing XCMP messages. This
+ * overrides the amount set in the Config trait.
+ **/
+ reservedXcmpWeightOverride: AugmentedQuery<ApiType, () => Observable<Option<u64>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * An option which indicates if the relay-chain restricts signalling a validation code upgrade.
+ * In other words, if this is `Some` and [`NewValidationCode`] is `Some` then the produced
+ * candidate will be invalid.
+ *
+ * This storage item is a mirror of the corresponding value for the current parachain from the
+ * relay-chain. This value is ephemeral which means it doesn't hit the storage. This value is
+ * set after the inherent.
+ **/
+ upgradeRestrictionSignal: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV1UpgradeRestriction>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Upward messages that were sent in a block.
+ *
+ * This will be cleared in `on_initialize` of each new block.
+ **/
+ upwardMessages: AugmentedQuery<ApiType, () => Observable<Vec<Bytes>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The [`PersistedValidationData`] set for this block.
+ * This value is expected to be set only once per block and it's never stored
+ * in the trie.
+ **/
+ validationData: AugmentedQuery<ApiType, () => Observable<Option<PolkadotPrimitivesV1PersistedValidationData>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ randomnessCollectiveFlip: {
+ /**
+ * Series of block headers from the last 81 blocks that acts as random seed material. This
+ * is arranged as a ring buffer with `block_number % 81` being the index into the `Vec` of
+ * the oldest hash.
+ **/
+ randomMaterial: AugmentedQuery<ApiType, () => Observable<Vec<H256>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ refungible: {
+ accountBalance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u32>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ allowance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg4: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ balance: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array, arg3: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => Observable<u128>, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr]> & QueryableStorageEntry<ApiType, [u32, u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Used to enumerate tokens owned by account
+ **/
+ owned: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, arg3: u32 | AnyNumber | Uint8Array) => Observable<bool>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32]> & QueryableStorageEntry<ApiType, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32]>;
+ tokenData: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<PalletRefungibleItemData>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ tokensBurnt: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ tokensMinted: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<u32>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ totalSupply: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<u128>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ scheduler: {
+ /**
+ * Items to be executed, indexed by the block number that they should be executed on.
+ **/
+ agenda: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Option<PalletUnqSchedulerScheduledV2>>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Lookup from identity to the block number and index of the task.
+ **/
+ lookup: AugmentedQuery<ApiType, (arg: Bytes | string | Uint8Array) => Observable<Option<ITuple<[u32, u32]>>>, [Bytes]> & QueryableStorageEntry<ApiType, [Bytes]>;
+ specAgenda: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Vec<Option<PalletUnqSchedulerCallSpec>>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Storage version of the pallet.
+ *
+ * New networks start with last version.
+ **/
+ storageVersion: AugmentedQuery<ApiType, () => Observable<PalletUnqSchedulerReleases>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ sudo: {
+ /**
+ * The `AccountId` of the sudo key.
+ **/
+ key: AugmentedQuery<ApiType, () => Observable<AccountId32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ system: {
+ /**
+ * The full account information for a particular account ID.
+ **/
+ account: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<FrameSystemAccountInfo>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
+ /**
+ * Total length (in bytes) for all extrinsics put together, for the current block.
+ **/
+ allExtrinsicsLen: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Map of block numbers to block hashes.
+ **/
+ blockHash: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<H256>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * The current weight for the block.
+ **/
+ blockWeight: AugmentedQuery<ApiType, () => Observable<FrameSupportWeightsPerDispatchClassU64>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Digest of the current block, also part of the block header.
+ **/
+ digest: AugmentedQuery<ApiType, () => Observable<SpRuntimeGenericDigest>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The number of events in the `Events<T>` list.
+ **/
+ eventCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Events deposited for the current block.
+ *
+ * NOTE: This storage item is explicitly unbounded since it is never intended to be read
+ * from within the runtime.
+ **/
+ events: AugmentedQuery<ApiType, () => Observable<Vec<FrameSystemEventRecord>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Mapping between a topic (represented by T::Hash) and a vector of indexes
+ * of events in the `<Events<T>>` list.
+ *
+ * All topic vectors have deterministic storage locations depending on the topic. This
+ * allows light-clients to leverage the changes trie storage tracking mechanism and
+ * in case of changes fetch the list of events of interest.
+ *
+ * The value has the type `(T::BlockNumber, EventIndex)` because if we used only just
+ * the `EventIndex` then in case if the topic has the same contents on the next block
+ * no notification will be triggered thus the event might be lost.
+ **/
+ eventTopics: AugmentedQuery<ApiType, (arg: H256 | string | Uint8Array) => Observable<Vec<ITuple<[u32, u32]>>>, [H256]> & QueryableStorageEntry<ApiType, [H256]>;
+ /**
+ * The execution phase of the block.
+ **/
+ executionPhase: AugmentedQuery<ApiType, () => Observable<Option<FrameSystemPhase>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Total extrinsics count for the current block.
+ **/
+ extrinsicCount: AugmentedQuery<ApiType, () => Observable<Option<u32>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Extrinsics data for the current block (maps an extrinsic's index to its data).
+ **/
+ extrinsicData: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Bytes>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Stores the `spec_version` and `spec_name` of when the last runtime upgrade happened.
+ **/
+ lastRuntimeUpgrade: AugmentedQuery<ApiType, () => Observable<Option<FrameSystemLastRuntimeUpgradeInfo>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The current block number being processed. Set by `execute_block`.
+ **/
+ number: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Hash of the previous block.
+ **/
+ parentHash: AugmentedQuery<ApiType, () => Observable<H256>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * True if we have upgraded so that AccountInfo contains three types of `RefCount`. False
+ * (default) if not.
+ **/
+ upgradedToTripleRefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * True if we have upgraded so that `type RefCount` is `u32`. False (default) if not.
+ **/
+ upgradedToU32RefCount: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ timestamp: {
+ /**
+ * Did the timestamp get updated in this block?
+ **/
+ didUpdate: AugmentedQuery<ApiType, () => Observable<bool>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Current time for the current block.
+ **/
+ now: AugmentedQuery<ApiType, () => Observable<u64>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ transactionPayment: {
+ nextFeeMultiplier: AugmentedQuery<ApiType, () => Observable<u128>, []> & QueryableStorageEntry<ApiType, []>;
+ storageVersion: AugmentedQuery<ApiType, () => Observable<PalletTransactionPaymentReleases>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ treasury: {
+ /**
+ * Proposal indices that have been approved but not yet awarded.
+ **/
+ approvals: AugmentedQuery<ApiType, () => Observable<Vec<u32>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Number of proposals that have been made.
+ **/
+ proposalCount: AugmentedQuery<ApiType, () => Observable<u32>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Proposals that have been made.
+ **/
+ proposals: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Option<PalletTreasuryProposal>>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ vesting: {
+ /**
+ * Storage version of the pallet.
+ *
+ * New networks start with latest version, as determined by the genesis build.
+ **/
+ storageVersion: AugmentedQuery<ApiType, () => Observable<PalletVestingReleases>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Information regarding the vesting of a given account.
+ **/
+ vesting: AugmentedQuery<ApiType, (arg: AccountId32 | string | Uint8Array) => Observable<Option<Vec<PalletVestingVestingInfo>>>, [AccountId32]> & QueryableStorageEntry<ApiType, [AccountId32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ xcmpQueue: {
+ /**
+ * Inbound aggregate XCMP messages. It can only be one per ParaId/block.
+ **/
+ inboundXcmpMessages: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u32 | AnyNumber | Uint8Array) => Observable<Bytes>, [u32, u32]> & QueryableStorageEntry<ApiType, [u32, u32]>;
+ /**
+ * Status of the inbound XCMP channels.
+ **/
+ inboundXcmpStatus: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[u32, CumulusPalletXcmpQueueInboundStatus, Vec<ITuple<[u32, PolkadotParachainPrimitivesXcmpMessageFormat]>>]>>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The messages outbound in a given XCMP channel.
+ **/
+ outboundXcmpMessages: AugmentedQuery<ApiType, (arg1: u32 | AnyNumber | Uint8Array, arg2: u16 | AnyNumber | Uint8Array) => Observable<Bytes>, [u32, u16]> & QueryableStorageEntry<ApiType, [u32, u16]>;
+ /**
+ * The non-empty XCMP channels in order of becoming non-empty, and the index of the first
+ * and last outbound message. If the two indices are equal, then it indicates an empty
+ * queue and there must be a non-`Ok` `OutboundStatus`. We assume queues grow no greater
+ * than 65535 items. Queue indices for normal messages begin at one; zero is reserved in
+ * case of the need to send a high-priority signal message this block.
+ * The bool is true if there is a signal message waiting to be sent.
+ **/
+ outboundXcmpStatus: AugmentedQuery<ApiType, () => Observable<Vec<ITuple<[u32, CumulusPalletXcmpQueueOutboundStatus, bool, u16, u16]>>>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * The configuration which controls the dynamics of the outbound queue.
+ **/
+ queueConfig: AugmentedQuery<ApiType, () => Observable<CumulusPalletXcmpQueueQueueConfigData>, []> & QueryableStorageEntry<ApiType, []>;
+ /**
+ * Any signal messages waiting to be sent.
+ **/
+ signalMessages: AugmentedQuery<ApiType, (arg: u32 | AnyNumber | Uint8Array) => Observable<Bytes>, [u32]> & QueryableStorageEntry<ApiType, [u32]>;
+ /**
+ * Generic query
+ **/
+ [key: string]: QueryableStorageEntry<ApiType>;
+ };
+ }
+
+ export interface QueryableStorage<ApiType extends ApiTypes> extends AugmentedQueries<ApiType> {
+ [key: string]: QueryableModuleStorage<ApiType>;
+ }
+}
tests/src/interfaces/augment-api-rpc.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-rpc.ts
@@ -0,0 +1,611 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { NftDataStructsCollectionId, NftDataStructsTokenId, PalletCommonAccountBasicCrossAccountIdRepr } from './nft';
+import type { Bytes, HashMap, Json, Metadata, Null, Option, StorageKey, Text, U256, U64, Vec, bool, u128, u32, u64 } from '@polkadot/types';
+import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
+import type { EpochAuthorship } from '@polkadot/types/interfaces/babe';
+import type { BeefySignedCommitment } from '@polkadot/types/interfaces/beefy';
+import type { BlockHash } from '@polkadot/types/interfaces/chain';
+import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
+import type { AuthorityId } from '@polkadot/types/interfaces/consensus';
+import type { ContractCallRequest, ContractExecResult, ContractInstantiateResult, InstantiateRequest } from '@polkadot/types/interfaces/contracts';
+import type { CreatedBlock } from '@polkadot/types/interfaces/engine';
+import type { EthAccount, EthCallRequest, EthFilter, EthFilterChanges, EthLog, EthReceipt, EthRichBlock, EthSubKind, EthSubParams, EthSyncStatus, EthTransaction, EthTransactionRequest, EthWork } from '@polkadot/types/interfaces/eth';
+import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
+import type { EncodedFinalityProofs, JustificationNotification, ReportedRoundStates } from '@polkadot/types/interfaces/grandpa';
+import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
+import type { StorageKind } from '@polkadot/types/interfaces/offchain';
+import type { FeeDetails, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
+import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
+import type { AccountId, BlockNumber, H160, H256, H64, Hash, Header, Index, Justification, KeyValue, SignedBlock, StorageData } from '@polkadot/types/interfaces/runtime';
+import type { ReadProof, RuntimeVersion, TraceBlockResponse } from '@polkadot/types/interfaces/state';
+import type { ApplyExtrinsicResult, ChainProperties, ChainType, Health, NetworkState, NodeRole, PeerInfo, SyncState } from '@polkadot/types/interfaces/system';
+import type { AnyNumber, Codec, IExtrinsic, Observable } from '@polkadot/types/types';
+
+declare module '@polkadot/rpc-core/types.jsonrpc' {
+ export interface RpcInterface {
+ author: {
+ /**
+ * Returns true if the keystore has private keys for the given public key and key type.
+ **/
+ hasKey: AugmentedRpc<(publicKey: Bytes | string | Uint8Array, keyType: Text | string) => Observable<bool>>;
+ /**
+ * Returns true if the keystore has private keys for the given session public keys.
+ **/
+ hasSessionKeys: AugmentedRpc<(sessionKeys: Bytes | string | Uint8Array) => Observable<bool>>;
+ /**
+ * Insert a key into the keystore.
+ **/
+ insertKey: AugmentedRpc<(keyType: Text | string, suri: Text | string, publicKey: Bytes | string | Uint8Array) => Observable<Bytes>>;
+ /**
+ * Returns all pending extrinsics, potentially grouped by sender
+ **/
+ pendingExtrinsics: AugmentedRpc<() => Observable<Vec<Extrinsic>>>;
+ /**
+ * Remove given extrinsic from the pool and temporarily ban it to prevent reimporting
+ **/
+ removeExtrinsic: AugmentedRpc<(bytesOrHash: Vec<ExtrinsicOrHash> | (ExtrinsicOrHash | { Hash: any } | { Extrinsic: any } | string | Uint8Array)[]) => Observable<Vec<Hash>>>;
+ /**
+ * Generate new session keys and returns the corresponding public keys
+ **/
+ rotateKeys: AugmentedRpc<() => Observable<Bytes>>;
+ /**
+ * Submit and subscribe to watch an extrinsic until unsubscribed
+ **/
+ submitAndWatchExtrinsic: AugmentedRpc<(extrinsic: IExtrinsic) => Observable<ExtrinsicStatus>>;
+ /**
+ * Submit a fully formatted extrinsic for block inclusion
+ **/
+ submitExtrinsic: AugmentedRpc<(extrinsic: IExtrinsic) => Observable<Hash>>;
+ };
+ babe: {
+ /**
+ * Returns data about which slots (primary or secondary) can be claimed in the current epoch with the keys in the keystore
+ **/
+ epochAuthorship: AugmentedRpc<() => Observable<HashMap<AuthorityId, EpochAuthorship>>>;
+ };
+ beefy: {
+ /**
+ * Returns the block most recently finalized by BEEFY, alongside side its justification.
+ **/
+ subscribeJustifications: AugmentedRpc<() => Observable<BeefySignedCommitment>>;
+ };
+ chain: {
+ /**
+ * Get header and body of a relay chain block
+ **/
+ getBlock: AugmentedRpc<(hash?: BlockHash | string | Uint8Array) => Observable<SignedBlock>>;
+ /**
+ * Get the block hash for a specific block
+ **/
+ getBlockHash: AugmentedRpc<(blockNumber?: BlockNumber | AnyNumber | Uint8Array) => Observable<BlockHash>>;
+ /**
+ * Get hash of the last finalized block in the canon chain
+ **/
+ getFinalizedHead: AugmentedRpc<() => Observable<BlockHash>>;
+ /**
+ * Retrieves the header for a specific block
+ **/
+ getHeader: AugmentedRpc<(hash?: BlockHash | string | Uint8Array) => Observable<Header>>;
+ /**
+ * Retrieves the newest header via subscription
+ **/
+ subscribeAllHeads: AugmentedRpc<() => Observable<Header>>;
+ /**
+ * Retrieves the best finalized header via subscription
+ **/
+ subscribeFinalizedHeads: AugmentedRpc<() => Observable<Header>>;
+ /**
+ * Retrieves the best header via subscription
+ **/
+ subscribeNewHeads: AugmentedRpc<() => Observable<Header>>;
+ };
+ childstate: {
+ /**
+ * Returns the keys with prefix from a child storage, leave empty to get all the keys
+ **/
+ getKeys: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
+ /**
+ * Returns the keys with prefix from a child storage with pagination support
+ **/
+ getKeysPaged: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, prefix: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
+ /**
+ * Returns a child storage entry at a specific block state
+ **/
+ getStorage: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<StorageData>>>;
+ /**
+ * Returns child storage entries for multiple keys at a specific block state
+ **/
+ getStorageEntries: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: Hash | string | Uint8Array) => Observable<Vec<Option<StorageData>>>>;
+ /**
+ * Returns the hash of a child storage entry at a block state
+ **/
+ getStorageHash: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<Hash>>>;
+ /**
+ * Returns the size of a child storage entry at a block state
+ **/
+ getStorageSize: AugmentedRpc<(childKey: PrefixedStorageKey | string | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: Hash | string | Uint8Array) => Observable<Option<u64>>>;
+ };
+ contracts: {
+ /**
+ * Executes a call to a contract
+ **/
+ call: AugmentedRpc<(callRequest: ContractCallRequest | { origin?: any; dest?: any; value?: any; gasLimit?: any; inputData?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractExecResult>>;
+ /**
+ * Returns the value under a specified storage key in a contract
+ **/
+ getStorage: AugmentedRpc<(address: AccountId | string | Uint8Array, key: H256 | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<Bytes>>>;
+ /**
+ * Instantiate a new contract
+ **/
+ instantiate: AugmentedRpc<(request: InstantiateRequest | { origin?: any; endowment?: any; gasLimit?: any; code?: any; data?: any; salt?: any } | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ContractInstantiateResult>>;
+ /**
+ * Returns the projected time a given contract will be able to sustain paying its rent
+ **/
+ rentProjection: AugmentedRpc<(address: AccountId | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Option<BlockNumber>>>;
+ };
+ engine: {
+ /**
+ * Instructs the manual-seal authorship task to create a new block
+ **/
+ createBlock: AugmentedRpc<(createEmpty: bool | boolean | Uint8Array, finalize: bool | boolean | Uint8Array, parentHash?: BlockHash | string | Uint8Array) => Observable<CreatedBlock>>;
+ /**
+ * Instructs the manual-seal authorship task to finalize a block
+ **/
+ finalizeBlock: AugmentedRpc<(hash: BlockHash | string | Uint8Array, justification?: Justification) => Observable<bool>>;
+ };
+ eth: {
+ /**
+ * Returns accounts list.
+ **/
+ accounts: AugmentedRpc<() => Observable<Vec<H160>>>;
+ /**
+ * Returns the blockNumber
+ **/
+ blockNumber: AugmentedRpc<() => Observable<U256>>;
+ /**
+ * Call contract, returning the output data.
+ **/
+ call: AugmentedRpc<(request: EthCallRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
+ /**
+ * Returns the chain ID used for transaction signing at the current best block. None is returned if not available.
+ **/
+ chainId: AugmentedRpc<() => Observable<U64>>;
+ /**
+ * Returns block author.
+ **/
+ coinbase: AugmentedRpc<() => Observable<H160>>;
+ /**
+ * Estimate gas needed for execution of given contract.
+ **/
+ estimateGas: AugmentedRpc<(request: EthCallRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns current gas price.
+ **/
+ gasPrice: AugmentedRpc<() => Observable<U256>>;
+ /**
+ * Returns balance of the given account.
+ **/
+ getBalance: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns block with given hash.
+ **/
+ getBlockByHash: AugmentedRpc<(hash: H256 | string | Uint8Array, full: bool | boolean | Uint8Array) => Observable<Option<EthRichBlock>>>;
+ /**
+ * Returns block with given number.
+ **/
+ getBlockByNumber: AugmentedRpc<(block: BlockNumber | AnyNumber | Uint8Array, full: bool | boolean | Uint8Array) => Observable<Option<EthRichBlock>>>;
+ /**
+ * Returns the number of transactions in a block with given hash.
+ **/
+ getBlockTransactionCountByHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns the number of transactions in a block with given block number.
+ **/
+ getBlockTransactionCountByNumber: AugmentedRpc<(block: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns the code at given address at given time (block number).
+ **/
+ getCode: AugmentedRpc<(address: H160 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<Bytes>>;
+ /**
+ * Returns filter changes since last poll.
+ **/
+ getFilterChanges: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<EthFilterChanges>>;
+ /**
+ * Returns all logs matching given filter (in a range 'from' - 'to').
+ **/
+ getFilterLogs: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<Vec<EthLog>>>;
+ /**
+ * Returns logs matching given filter object.
+ **/
+ getLogs: AugmentedRpc<(filter: EthFilter | { fromBlock?: any; toBlock?: any; blockHash?: any; address?: any; topics?: any } | string | Uint8Array) => Observable<Vec<EthLog>>>;
+ /**
+ * Returns proof for account and storage.
+ **/
+ getProof: AugmentedRpc<(address: H160 | string | Uint8Array, storageKeys: Vec<H256> | (H256 | string | Uint8Array)[], number: BlockNumber | AnyNumber | Uint8Array) => Observable<EthAccount>>;
+ /**
+ * Returns content of the storage at given address.
+ **/
+ getStorageAt: AugmentedRpc<(address: H160 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<H256>>;
+ /**
+ * Returns transaction at given block hash and index.
+ **/
+ getTransactionByBlockHashAndIndex: AugmentedRpc<(hash: H256 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthTransaction>>;
+ /**
+ * Returns transaction by given block number and index.
+ **/
+ getTransactionByBlockNumberAndIndex: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthTransaction>>;
+ /**
+ * Get transaction by its hash.
+ **/
+ getTransactionByHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<EthTransaction>>;
+ /**
+ * Returns the number of transactions sent from given address at given time (block number).
+ **/
+ getTransactionCount: AugmentedRpc<(hash: H256 | string | Uint8Array, number?: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns transaction receipt by transaction hash.
+ **/
+ getTransactionReceipt: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<EthReceipt>>;
+ /**
+ * Returns an uncles at given block and index.
+ **/
+ getUncleByBlockHashAndIndex: AugmentedRpc<(hash: H256 | string | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthRichBlock>>;
+ /**
+ * Returns an uncles at given block and index.
+ **/
+ getUncleByBlockNumberAndIndex: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array, index: U256 | AnyNumber | Uint8Array) => Observable<EthRichBlock>>;
+ /**
+ * Returns the number of uncles in a block with given hash.
+ **/
+ getUncleCountByBlockHash: AugmentedRpc<(hash: H256 | string | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns the number of uncles in a block with given block number.
+ **/
+ getUncleCountByBlockNumber: AugmentedRpc<(number: BlockNumber | AnyNumber | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns the hash of the current block, the seedHash, and the boundary condition to be met.
+ **/
+ getWork: AugmentedRpc<() => Observable<EthWork>>;
+ /**
+ * Returns the number of hashes per second that the node is mining with.
+ **/
+ hashrate: AugmentedRpc<() => Observable<U256>>;
+ /**
+ * Returns true if client is actively mining new blocks.
+ **/
+ mining: AugmentedRpc<() => Observable<bool>>;
+ /**
+ * Returns id of new block filter.
+ **/
+ newBlockFilter: AugmentedRpc<() => Observable<U256>>;
+ /**
+ * Returns id of new filter.
+ **/
+ newFilter: AugmentedRpc<(filter: EthFilter | { fromBlock?: any; toBlock?: any; blockHash?: any; address?: any; topics?: any } | string | Uint8Array) => Observable<U256>>;
+ /**
+ * Returns id of new block filter.
+ **/
+ newPendingTransactionFilter: AugmentedRpc<() => Observable<U256>>;
+ /**
+ * Returns protocol version encoded as a string (quotes are necessary).
+ **/
+ protocolVersion: AugmentedRpc<() => Observable<u64>>;
+ /**
+ * Sends signed transaction, returning its hash.
+ **/
+ sendRawTransaction: AugmentedRpc<(bytes: Bytes | string | Uint8Array) => Observable<H256>>;
+ /**
+ * Sends transaction; will block waiting for signer to return the transaction hash
+ **/
+ sendTransaction: AugmentedRpc<(tx: EthTransactionRequest | { from?: any; to?: any; gasPrice?: any; gas?: any; value?: any; data?: any; nonce?: any } | string | Uint8Array) => Observable<H256>>;
+ /**
+ * Used for submitting mining hashrate.
+ **/
+ submitHashrate: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array, hash: H256 | string | Uint8Array) => Observable<bool>>;
+ /**
+ * Used for submitting a proof-of-work solution.
+ **/
+ submitWork: AugmentedRpc<(nonce: H64 | string | Uint8Array, headerHash: H256 | string | Uint8Array, mixDigest: H256 | string | Uint8Array) => Observable<bool>>;
+ /**
+ * Subscribe to Eth subscription.
+ **/
+ subscribe: AugmentedRpc<(kind: EthSubKind | 'newHeads' | 'logs' | 'newPendingTransactions' | 'syncing' | number | Uint8Array, params?: EthSubParams | { None: any } | { Logs: any } | string | Uint8Array) => Observable<Null>>;
+ /**
+ * Returns an object with data about the sync status or false.
+ **/
+ syncing: AugmentedRpc<() => Observable<EthSyncStatus>>;
+ /**
+ * Uninstalls filter.
+ **/
+ uninstallFilter: AugmentedRpc<(index: U256 | AnyNumber | Uint8Array) => Observable<bool>>;
+ };
+ grandpa: {
+ /**
+ * Prove finality for the range (begin; end] hash.
+ **/
+ proveFinality: AugmentedRpc<(begin: BlockHash | string | Uint8Array, end: BlockHash | string | Uint8Array, authoritiesSetId?: u64 | AnyNumber | Uint8Array) => Observable<Option<EncodedFinalityProofs>>>;
+ /**
+ * Returns the state of the current best round state as well as the ongoing background rounds
+ **/
+ roundState: AugmentedRpc<() => Observable<ReportedRoundStates>>;
+ /**
+ * Subscribes to grandpa justifications
+ **/
+ subscribeJustifications: AugmentedRpc<() => Observable<JustificationNotification>>;
+ };
+ mmr: {
+ /**
+ * Generate MMR proof for given leaf index.
+ **/
+ generateProof: AugmentedRpc<(leafIndex: u64 | AnyNumber | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<MmrLeafProof>>;
+ };
+ net: {
+ /**
+ * Returns true if client is actively listening for network connections. Otherwise false.
+ **/
+ listening: AugmentedRpc<() => Observable<bool>>;
+ /**
+ * Returns number of peers connected to node.
+ **/
+ peerCount: AugmentedRpc<() => Observable<Text>>;
+ /**
+ * Returns protocol version.
+ **/
+ version: AugmentedRpc<() => Observable<Text>>;
+ };
+ nft: {
+ /**
+ * Get amount of different user tokens
+ **/
+ accountBalance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u32>>;
+ /**
+ * Get tokens owned by account
+ **/
+ accountTokens: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<NftDataStructsTokenId>>>;
+ /**
+ * Get admin list
+ **/
+ adminlist: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
+ /**
+ * Get allowed amount
+ **/
+ allowance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, sender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+ /**
+ * Get allowlist
+ **/
+ allowlist: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<PalletCommonAccountBasicCrossAccountIdRepr>>>;
+ /**
+ * Get amount of specific account token
+ **/
+ balance: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, account: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<u128>>;
+ /**
+ * Get tokens contained in collection
+ **/
+ collectionTokens: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Vec<NftDataStructsTokenId>>>;
+ /**
+ * Get token constant metadata
+ **/
+ constMetadata: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
+ /**
+ * Get last token id
+ **/
+ lastTokenId: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<NftDataStructsTokenId>>;
+ /**
+ * Check if token exists
+ **/
+ tokenExists: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<bool>>;
+ /**
+ * Get token owner
+ **/
+ tokenOwner: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<PalletCommonAccountBasicCrossAccountIdRepr>>;
+ /**
+ * Get token variable metadata
+ **/
+ variableMetadata: AugmentedRpc<(collection: NftDataStructsCollectionId | AnyNumber | Uint8Array, tokenId: NftDataStructsTokenId | AnyNumber | Uint8Array, at?: Hash | string | Uint8Array) => Observable<Bytes>>;
+ };
+ offchain: {
+ /**
+ * Get offchain local storage under given key and prefix
+ **/
+ localStorageGet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array) => Observable<Option<Bytes>>>;
+ /**
+ * Set offchain local storage under given key and prefix
+ **/
+ localStorageSet: AugmentedRpc<(kind: StorageKind | 'PERSISTENT' | 'LOCAL' | number | Uint8Array, key: Bytes | string | Uint8Array, value: Bytes | string | Uint8Array) => Observable<Null>>;
+ };
+ payment: {
+ /**
+ * Query the detailed fee of a given encoded extrinsic
+ **/
+ queryFeeDetails: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<FeeDetails>>;
+ /**
+ * Retrieves the fee information for an encoded extrinsic
+ **/
+ queryInfo: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<RuntimeDispatchInfo>>;
+ };
+ rpc: {
+ /**
+ * Retrieves the list of RPC methods that are exposed by the node
+ **/
+ methods: AugmentedRpc<() => Observable<RpcMethods>>;
+ };
+ state: {
+ /**
+ * Perform a call to a builtin on the chain
+ **/
+ call: AugmentedRpc<(method: Text | string, data: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<Bytes>>;
+ /**
+ * Retrieves the keys with prefix of a specific child storage
+ **/
+ getChildKeys: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
+ /**
+ * Returns proof of storage for child key entries at a specific block state.
+ **/
+ getChildReadProof: AugmentedRpc<(childStorageKey: PrefixedStorageKey | string | Uint8Array, keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: BlockHash | string | Uint8Array) => Observable<ReadProof>>;
+ /**
+ * Retrieves the child storage for a key
+ **/
+ getChildStorage: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<StorageData>>;
+ /**
+ * Retrieves the child storage hash
+ **/
+ getChildStorageHash: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Hash>>;
+ /**
+ * Retrieves the child storage size
+ **/
+ getChildStorageSize: AugmentedRpc<(childStorageKey: StorageKey | string | Uint8Array | any, childDefinition: StorageKey | string | Uint8Array | any, childType: u32 | AnyNumber | Uint8Array, key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<u64>>;
+ /**
+ * Retrieves the keys with a certain prefix
+ **/
+ getKeys: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
+ /**
+ * Returns the keys with prefix with pagination support.
+ **/
+ getKeysPaged: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, count: u32 | AnyNumber | Uint8Array, startKey?: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<StorageKey>>>;
+ /**
+ * Returns the runtime metadata
+ **/
+ getMetadata: AugmentedRpc<(at?: BlockHash | string | Uint8Array) => Observable<Metadata>>;
+ /**
+ * Returns the keys with prefix, leave empty to get all the keys (deprecated: Use getKeysPaged)
+ **/
+ getPairs: AugmentedRpc<(prefix: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Vec<KeyValue>>>;
+ /**
+ * Returns proof of storage entries at a specific block state
+ **/
+ getReadProof: AugmentedRpc<(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: BlockHash | string | Uint8Array) => Observable<ReadProof>>;
+ /**
+ * Get the runtime version
+ **/
+ getRuntimeVersion: AugmentedRpc<(at?: BlockHash | string | Uint8Array) => Observable<RuntimeVersion>>;
+ /**
+ * Retrieves the storage for a key
+ **/
+ getStorage: AugmentedRpc<<T = Codec>(key: StorageKey | string | Uint8Array | any, block?: Hash | Uint8Array | string) => Observable<T>>;
+ /**
+ * Retrieves the storage hash
+ **/
+ getStorageHash: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<Hash>>;
+ /**
+ * Retrieves the storage size
+ **/
+ getStorageSize: AugmentedRpc<(key: StorageKey | string | Uint8Array | any, at?: BlockHash | string | Uint8Array) => Observable<u64>>;
+ /**
+ * Query historical storage entries (by key) starting from a start block
+ **/
+ queryStorage: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], fromBlock?: Hash | Uint8Array | string, toBlock?: Hash | Uint8Array | string) => Observable<[Hash, T][]>>;
+ /**
+ * Query storage entries (by key) starting at block hash given as the second parameter
+ **/
+ queryStorageAt: AugmentedRpc<<T = Codec[]>(keys: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[], at?: Hash | Uint8Array | string) => Observable<T>>;
+ /**
+ * Retrieves the runtime version via subscription
+ **/
+ subscribeRuntimeVersion: AugmentedRpc<() => Observable<RuntimeVersion>>;
+ /**
+ * Subscribes to storage changes for the provided keys
+ **/
+ subscribeStorage: AugmentedRpc<<T = Codec[]>(keys?: Vec<StorageKey> | (StorageKey | string | Uint8Array | any)[]) => Observable<T>>;
+ /**
+ * Provides a way to trace the re-execution of a single block
+ **/
+ traceBlock: AugmentedRpc<(block: Hash | string | Uint8Array, targets: Option<Text> | null | object | string | Uint8Array, storageKeys: Option<Text> | null | object | string | Uint8Array) => Observable<TraceBlockResponse>>;
+ };
+ syncstate: {
+ /**
+ * Returns the json-serialized chainspec running the node, with a sync state.
+ **/
+ genSyncSpec: AugmentedRpc<(raw: bool | boolean | Uint8Array) => Observable<Json>>;
+ };
+ system: {
+ /**
+ * Retrieves the next accountIndex as available on the node
+ **/
+ accountNextIndex: AugmentedRpc<(accountId: AccountId | string | Uint8Array) => Observable<Index>>;
+ /**
+ * Adds the supplied directives to the current log filter
+ **/
+ addLogFilter: AugmentedRpc<(directives: Text | string) => Observable<Null>>;
+ /**
+ * Adds a reserved peer
+ **/
+ addReservedPeer: AugmentedRpc<(peer: Text | string) => Observable<Text>>;
+ /**
+ * Retrieves the chain
+ **/
+ chain: AugmentedRpc<() => Observable<Text>>;
+ /**
+ * Retrieves the chain type
+ **/
+ chainType: AugmentedRpc<() => Observable<ChainType>>;
+ /**
+ * Dry run an extrinsic at a given block
+ **/
+ dryRun: AugmentedRpc<(extrinsic: Bytes | string | Uint8Array, at?: BlockHash | string | Uint8Array) => Observable<ApplyExtrinsicResult>>;
+ /**
+ * Return health status of the node
+ **/
+ health: AugmentedRpc<() => Observable<Health>>;
+ /**
+ * The addresses include a trailing /p2p/ with the local PeerId, and are thus suitable to be passed to addReservedPeer or as a bootnode address for example
+ **/
+ localListenAddresses: AugmentedRpc<() => Observable<Vec<Text>>>;
+ /**
+ * Returns the base58-encoded PeerId of the node
+ **/
+ localPeerId: AugmentedRpc<() => Observable<Text>>;
+ /**
+ * Retrieves the node name
+ **/
+ name: AugmentedRpc<() => Observable<Text>>;
+ /**
+ * Returns current state of the network
+ **/
+ networkState: AugmentedRpc<() => Observable<NetworkState>>;
+ /**
+ * Returns the roles the node is running as
+ **/
+ nodeRoles: AugmentedRpc<() => Observable<Vec<NodeRole>>>;
+ /**
+ * Returns the currently connected peers
+ **/
+ peers: AugmentedRpc<() => Observable<Vec<PeerInfo>>>;
+ /**
+ * Get a custom set of properties as a JSON object, defined in the chain spec
+ **/
+ properties: AugmentedRpc<() => Observable<ChainProperties>>;
+ /**
+ * Remove a reserved peer
+ **/
+ removeReservedPeer: AugmentedRpc<(peerId: Text | string) => Observable<Text>>;
+ /**
+ * Returns the list of reserved peers
+ **/
+ reservedPeers: AugmentedRpc<() => Observable<Vec<Text>>>;
+ /**
+ * Resets the log filter to Substrate defaults
+ **/
+ resetLogFilter: AugmentedRpc<() => Observable<Null>>;
+ /**
+ * Returns the state of the syncing of the node
+ **/
+ syncState: AugmentedRpc<() => Observable<SyncState>>;
+ /**
+ * Retrieves the version of the node
+ **/
+ version: AugmentedRpc<() => Observable<Text>>;
+ };
+ web3: {
+ /**
+ * Returns current client version.
+ **/
+ clientVersion: AugmentedRpc<() => Observable<Text>>;
+ /**
+ * Returns sha3 of the given data
+ **/
+ sha3: AugmentedRpc<(data: Bytes | string | Uint8Array) => Observable<H256>>;
+ };
+ }
+}
tests/src/interfaces/augment-api-tx.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api-tx.ts
@@ -0,0 +1,1214 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import type { EthereumTransactionLegacyTransaction } from './ethereum';
+import type { NftDataStructsAccessMode, NftDataStructsCollectionLimits, NftDataStructsCollectionMode, NftDataStructsCreateItemData, NftDataStructsMetaUpdatePermission, NftDataStructsSchemaVersion, PalletCommonAccountBasicCrossAccountIdRepr } from './nft';
+import type { CumulusPrimitivesParachainInherentParachainInherentData } from './polkadot';
+import type { ApiTypes, SubmittableExtrinsic } from '@polkadot/api/types';
+import type { Bytes, Compact, Option, U256, Vec, bool, u128, u16, u32, u64, u8 } from '@polkadot/types';
+import type { Extrinsic } from '@polkadot/types/interfaces/extrinsics';
+import type { AccountId32, Call, H160, H256, MultiAddress, Perbill } from '@polkadot/types/interfaces/runtime';
+import type { PalletVestingVestingInfo, SpCoreChangesTrieChangesTrieConfiguration, XcmV1MultiLocation, XcmV2WeightLimit, XcmVersionedMultiAssets, XcmVersionedMultiLocation, XcmVersionedXcm } from '@polkadot/types/lookup';
+import type { AnyNumber, ITuple } from '@polkadot/types/types';
+
+declare module '@polkadot/api/types/submittable' {
+ export interface AugmentedSubmittables<ApiType> {
+ balances: {
+ /**
+ * Exactly as `transfer`, except the origin must be root and the source account may be
+ * specified.
+ * # <weight>
+ * - Same as transfer, but additional read and write because the source account is not
+ * assumed to be in the overlay.
+ * # </weight>
+ **/
+ forceTransfer: AugmentedSubmittable<(source: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<u128> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, MultiAddress, Compact<u128>]>;
+ /**
+ * Unreserve some balance from a user by force.
+ *
+ * Can only be called by ROOT.
+ **/
+ forceUnreserve: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, u128]>;
+ /**
+ * Set the balances of a given account.
+ *
+ * This will alter `FreeBalance` and `ReservedBalance` in storage. it will
+ * also decrease the total issuance of the system (`TotalIssuance`).
+ * If the new free or reserved balance is below the existential deposit,
+ * it will reset the account nonce (`frame_system::AccountNonce`).
+ *
+ * The dispatch origin for this call is `root`.
+ *
+ * # <weight>
+ * - Independent of the arguments.
+ * - Contains a limited number of reads and writes.
+ * ---------------------
+ * - Base Weight:
+ * - Creating: 27.56 µs
+ * - Killing: 35.11 µs
+ * - DB Weight: 1 Read, 1 Write to `who`
+ * # </weight>
+ **/
+ setBalance: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, newFree: Compact<u128> | AnyNumber | Uint8Array, newReserved: Compact<u128> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, Compact<u128>, Compact<u128>]>;
+ /**
+ * Transfer some liquid free balance to another account.
+ *
+ * `transfer` will set the `FreeBalance` of the sender and receiver.
+ * It will decrease the total issuance of the system by the `TransferFee`.
+ * If the sender's account is below the existential deposit as a result
+ * of the transfer, the account will be reaped.
+ *
+ * The dispatch origin for this call must be `Signed` by the transactor.
+ *
+ * # <weight>
+ * - Dependent on arguments but not critical, given proper implementations for input config
+ * types. See related functions below.
+ * - It contains a limited number of reads and writes internally and no complex
+ * computation.
+ *
+ * Related functions:
+ *
+ * - `ensure_can_withdraw` is always called internally but has a bounded complexity.
+ * - Transferring balances to accounts that did not exist before will cause
+ * `T::OnNewAccount::on_new_account` to be called.
+ * - Removing enough funds from an account will trigger `T::DustRemoval::on_unbalanced`.
+ * - `transfer_keep_alive` works the same way as `transfer`, but has an additional check
+ * that the transfer will not kill the origin account.
+ * ---------------------------------
+ * - Base Weight: 73.64 µs, worst case scenario (account created, account removed)
+ * - DB Weight: 1 Read and 1 Write to destination account
+ * - Origin account is already in memory, so no DB operations for them.
+ * # </weight>
+ **/
+ transfer: AugmentedSubmittable<(dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<u128> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, Compact<u128>]>;
+ /**
+ * Transfer the entire transferable balance from the caller account.
+ *
+ * NOTE: This function only attempts to transfer _transferable_ balances. This means that
+ * any locked, reserved, or existential deposits (when `keep_alive` is `true`), will not be
+ * transferred by this function. To ensure that this function results in a killed account,
+ * you might need to prepare the account by removing any reference counters, storage
+ * deposits, etc...
+ *
+ * The dispatch origin of this call must be Signed.
+ *
+ * - `dest`: The recipient of the transfer.
+ * - `keep_alive`: A boolean to determine if the `transfer_all` operation should send all
+ * of the funds the account has, causing the sender account to be killed (false), or
+ * transfer everything except at least the existential deposit, which will guarantee to
+ * keep the sender account alive (true). # <weight>
+ * - O(1). Just like transfer, but reading the user's transferable balance first.
+ * #</weight>
+ **/
+ transferAll: AugmentedSubmittable<(dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, keepAlive: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, bool]>;
+ /**
+ * Same as the [`transfer`] call, but with a check that the transfer will not kill the
+ * origin account.
+ *
+ * 99% of the time you want [`transfer`] instead.
+ *
+ * [`transfer`]: struct.Pallet.html#method.transfer
+ * # <weight>
+ * - Cheaper than transfer because account cannot be killed.
+ * - Base Weight: 51.4 µs
+ * - DB Weight: 1 Read and 1 Write to dest (sender is in overlay already)
+ * #</weight>
+ **/
+ transferKeepAlive: AugmentedSubmittable<(dest: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, value: Compact<u128> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, Compact<u128>]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ charging: {
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ cumulusXcm: {
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ dmpQueue: {
+ /**
+ * Service a single overweight message.
+ *
+ * - `origin`: Must pass `ExecuteOverweightOrigin`.
+ * - `index`: The index of the overweight message to service.
+ * - `weight_limit`: The amount of weight that message execution may take.
+ *
+ * Errors:
+ * - `Unknown`: Message of `index` is unknown.
+ * - `OverLimit`: Message execution may use greater than `weight_limit`.
+ *
+ * Events:
+ * - `OverweightServiced`: On success.
+ **/
+ serviceOverweight: AugmentedSubmittable<(index: u64 | AnyNumber | Uint8Array, weightLimit: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u64, u64]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ ethereum: {
+ /**
+ * Transact an Ethereum transaction.
+ **/
+ transact: AugmentedSubmittable<(transaction: EthereumTransactionLegacyTransaction | { nonce?: any; gasPrice?: any; gasLimit?: any; action?: any; value?: any; input?: any; signature?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [EthereumTransactionLegacyTransaction]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ evm: {
+ /**
+ * Issue an EVM call operation. This is similar to a message call transaction in Ethereum.
+ **/
+ call: AugmentedSubmittable<(source: H160 | string | Uint8Array, target: H160 | string | Uint8Array, input: Bytes | string | Uint8Array, value: U256 | AnyNumber | Uint8Array, gasLimit: u64 | AnyNumber | Uint8Array, gasPrice: U256 | AnyNumber | Uint8Array, nonce: Option<U256> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, H160, Bytes, U256, u64, U256, Option<U256>]>;
+ /**
+ * Issue an EVM create operation. This is similar to a contract creation transaction in
+ * Ethereum.
+ **/
+ create: AugmentedSubmittable<(source: H160 | string | Uint8Array, init: Bytes | string | Uint8Array, value: U256 | AnyNumber | Uint8Array, gasLimit: u64 | AnyNumber | Uint8Array, gasPrice: U256 | AnyNumber | Uint8Array, nonce: Option<U256> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, Bytes, U256, u64, U256, Option<U256>]>;
+ /**
+ * Issue an EVM create2 operation.
+ **/
+ create2: AugmentedSubmittable<(source: H160 | string | Uint8Array, init: Bytes | string | Uint8Array, salt: H256 | string | Uint8Array, value: U256 | AnyNumber | Uint8Array, gasLimit: u64 | AnyNumber | Uint8Array, gasPrice: U256 | AnyNumber | Uint8Array, nonce: Option<U256> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, Bytes, H256, U256, u64, U256, Option<U256>]>;
+ /**
+ * Withdraw balance from EVM into currency/balances pallet.
+ **/
+ withdraw: AugmentedSubmittable<(address: H160 | string | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, u128]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ evmMigration: {
+ begin: AugmentedSubmittable<(address: H160 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160]>;
+ finish: AugmentedSubmittable<(address: H160 | string | Uint8Array, code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H160, Bytes]>;
+ setData: AugmentedSubmittable<(address: H160 | string | Uint8Array, data: Vec<ITuple<[H256, H256]>> | ([H256 | string | Uint8Array, H256 | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>, [H160, Vec<ITuple<[H256, H256]>>]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ inflation: {
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ nft: {
+ /**
+ * Adds an admin of the Collection.
+ * NFT Collection can be controlled by multiple admin addresses (some which can also be servers, for example). Admins can issue and burn NFTs, as well as add and remove other admins, but cannot change NFT or Collection ownership.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the Collection to add admin for.
+ *
+ * * new_admin_id: Address of new admin to add.
+ **/
+ addCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newAdminId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Add an address to white list.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * address.
+ **/
+ addToWhiteList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Set, change, or remove approved address to transfer the ownership of the NFT.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ * * Current NFT owner
+ *
+ * # Arguments
+ *
+ * * approved: Address that is approved to transfer this NFT or zero (if needed to remove approval).
+ *
+ * * collection_id.
+ *
+ * * item_id: ID of the item.
+ **/
+ approve: AugmentedSubmittable<(spender: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, amount: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
+ /**
+ * Destroys a concrete instance of NFT on behalf of the owner
+ * See also: [`approve`]
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ * * Current NFT Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * item_id: ID of NFT to burn.
+ *
+ * * from: owner of item
+ **/
+ burnFrom: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, u32, u128]>;
+ /**
+ * Destroys a concrete instance of NFT.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ * * Current NFT Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * item_id: ID of NFT to burn.
+ **/
+ burnItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, u128]>;
+ /**
+ * Change the owner of the collection.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * new_owner.
+ **/
+ changeCollectionOwner: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newOwner: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
+ /**
+ * # Permissions
+ *
+ * * Sponsor.
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ **/
+ confirmSponsorship: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
+ /**
+ * This method creates a Collection of NFTs. Each Token may have multiple properties encoded as an array of bytes of certain length. The initial owner and admin of the collection are set to the address that signed the transaction. Both addresses can be changed later.
+ *
+ * # Permissions
+ *
+ * * Anyone.
+ *
+ * # Arguments
+ *
+ * * collection_name: UTF-16 string with collection name (limit 64 characters), will be stored as zero-terminated.
+ *
+ * * collection_description: UTF-16 string with collection description (limit 256 characters), will be stored as zero-terminated.
+ *
+ * * token_prefix: UTF-8 string with token prefix.
+ *
+ * * mode: [CollectionMode] collection type and type dependent data.
+ **/
+ createCollection: AugmentedSubmittable<(collectionName: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], collectionDescription: Vec<u16> | (u16 | AnyNumber | Uint8Array)[], tokenPrefix: Bytes | string | Uint8Array, mode: NftDataStructsCollectionMode | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Vec<u16>, Vec<u16>, Bytes, NftDataStructsCollectionMode]>;
+ /**
+ * This method creates a concrete instance of NFT Collection created with CreateCollection method.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ * * Anyone if
+ * * White List is enabled, and
+ * * Address is added to white list, and
+ * * MintPermission is enabled (see SetMintPermission method)
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * owner: Address, initial owner of the NFT.
+ *
+ * * data: Token data to store on chain.
+ **/
+ createItem: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, data: NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, NftDataStructsCreateItemData]>;
+ /**
+ * This method creates multiple items in a collection created with CreateCollection method.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ * * Anyone if
+ * * White List is enabled, and
+ * * Address is added to white list, and
+ * * MintPermission is enabled (see SetMintPermission method)
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * itemsData: Array items properties. Each property is an array of bytes itself, see [create_item].
+ *
+ * * owner: Address, initial owner of the NFT.
+ **/
+ createMultipleItems: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, owner: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, itemsData: Vec<NftDataStructsCreateItemData> | (NftDataStructsCreateItemData | { NFT: any } | { Fungible: any } | { ReFungible: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr, Vec<NftDataStructsCreateItemData>]>;
+ /**
+ * **DANGEROUS**: Destroys collection and all NFTs within this collection. Users irrecoverably lose their assets and may lose real money.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id: collection to destroy.
+ **/
+ destroyCollection: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
+ /**
+ * Remove admin address of the Collection. An admin address can remove itself. List of admins may become empty, in which case only Collection Owner will be able to add an Admin.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ * * Collection Admin.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the Collection to remove admin for.
+ *
+ * * account_id: Address of admin to remove.
+ **/
+ removeCollectionAdmin: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, accountId: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ /**
+ * Switch back to pay-per-own-transaction model.
+ *
+ * # Permissions
+ *
+ * * Collection owner.
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ **/
+ removeCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32]>;
+ /**
+ * Remove an address from white list.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * address.
+ **/
+ removeFromWhiteList: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, address: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, PalletCommonAccountBasicCrossAccountIdRepr]>;
+ setCollectionLimits: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newLimit: NftDataStructsCollectionLimits | { accountTokenOwnershipLimit?: any; sponsoredDataSize?: any; sponsoredDataRateLimit?: any; tokenLimit?: any; sponsorTransferTimeout?: any; ownerCanTransfer?: any; ownerCanDestroy?: any; transfersEnabled?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsCollectionLimits]>;
+ /**
+ * # Permissions
+ *
+ * * Collection Owner
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * new_sponsor.
+ **/
+ setCollectionSponsor: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, newSponsor: AccountId32 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, AccountId32]>;
+ /**
+ * Set const on-chain data schema.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * schema: String representing the const on-chain data schema.
+ **/
+ setConstOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
+ /**
+ * Set meta_update_permission value for particular collection
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * value: New flag value.
+ **/
+ setMetaUpdatePermissionFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: NftDataStructsMetaUpdatePermission | 'ItemOwner' | 'Admin' | 'None' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsMetaUpdatePermission]>;
+ /**
+ * Allows Anyone to create tokens if:
+ * * White List is enabled, and
+ * * Address is added to white list, and
+ * * This method was called with True parameter
+ *
+ * # Permissions
+ * * Collection Owner
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * mint_permission: Boolean parameter. If True, allows minting to Anyone with conditions above.
+ **/
+ setMintPermission: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mintPermission: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
+ /**
+ * Set off-chain data schema.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * schema: String representing the offchain data schema.
+ **/
+ setOffchainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
+ /**
+ * Toggle between normal and white list access for the methods with access for `Anyone`.
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * mode: [AccessMode]
+ **/
+ setPublicAccessMode: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, mode: NftDataStructsAccessMode | 'Normal' | 'WhiteList' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsAccessMode]>;
+ /**
+ * Set schema standard
+ * ImageURL
+ * Unique
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * schema: SchemaVersion: enum
+ **/
+ setSchemaVersion: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, version: NftDataStructsSchemaVersion | 'ImageURL' | 'Unique' | number | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, NftDataStructsSchemaVersion]>;
+ /**
+ * Set transfers_enabled value for particular collection
+ *
+ * # Permissions
+ *
+ * * Collection Owner.
+ *
+ * # Arguments
+ *
+ * * collection_id: ID of the collection.
+ *
+ * * value: New flag value.
+ **/
+ setTransfersEnabledFlag: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, value: bool | boolean | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, bool]>;
+ /**
+ * Set off-chain data schema.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * schema: String representing the offchain data schema.
+ **/
+ setVariableMetaData: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, data: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32, Bytes]>;
+ /**
+ * Set variable on-chain data schema.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ *
+ * # Arguments
+ *
+ * * collection_id.
+ *
+ * * schema: String representing the variable on-chain data schema.
+ **/
+ setVariableOnChainSchema: AugmentedSubmittable<(collectionId: u32 | AnyNumber | Uint8Array, schema: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, Bytes]>;
+ /**
+ * Change ownership of the token.
+ *
+ * # Permissions
+ *
+ * * Collection Owner
+ * * Collection Admin
+ * * Current NFT owner
+ *
+ * # Arguments
+ *
+ * * recipient: Address of token recipient.
+ *
+ * * collection_id.
+ *
+ * * item_id: ID of the item
+ * * Non-Fungible Mode: Required.
+ * * Fungible Mode: Ignored.
+ * * Re-Fungible Mode: Required.
+ *
+ * * value: Amount to transfer.
+ * * Non-Fungible Mode: Ignored
+ * * Fungible Mode: Must specify transferred amount
+ * * Re-Fungible Mode: Must specify transferred portion (between 0 and 1)
+ **/
+ transfer: AugmentedSubmittable<(recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
+ /**
+ * Change ownership of a NFT on behalf of the owner. See Approve method for additional information. After this method executes, the approval is removed so that the approved address will not be able to transfer this NFT again from this owner.
+ *
+ * # Permissions
+ * * Collection Owner
+ * * Collection Admin
+ * * Current NFT owner
+ * * Address approved by current NFT owner
+ *
+ * # Arguments
+ *
+ * * from: Address that owns token.
+ *
+ * * recipient: Address of token recipient.
+ *
+ * * collection_id.
+ *
+ * * item_id: ID of the item.
+ *
+ * * value: Amount to transfer.
+ **/
+ transferFrom: AugmentedSubmittable<(from: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, recipient: PalletCommonAccountBasicCrossAccountIdRepr | { Substrate: any } | { Ethereum: any } | string | Uint8Array, collectionId: u32 | AnyNumber | Uint8Array, itemId: u32 | AnyNumber | Uint8Array, value: u128 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [PalletCommonAccountBasicCrossAccountIdRepr, PalletCommonAccountBasicCrossAccountIdRepr, u32, u32, u128]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ nftPayment: {
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ parachainSystem: {
+ authorizeUpgrade: AugmentedSubmittable<(codeHash: H256 | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [H256]>;
+ enactAuthorizedUpgrade: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Set the current validation data.
+ *
+ * This should be invoked exactly once per block. It will panic at the finalization
+ * phase if the call was not invoked.
+ *
+ * The dispatch origin for this call must be `Inherent`
+ *
+ * As a side effect, this function upgrades the current validation function
+ * if the appropriate time has come.
+ **/
+ setValidationData: AugmentedSubmittable<(data: CumulusPrimitivesParachainInherentParachainInherentData | { validationData?: any; relayChainState?: any; downwardMessages?: any; horizontalMessages?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [CumulusPrimitivesParachainInherentParachainInherentData]>;
+ sudoSendUpwardMessage: AugmentedSubmittable<(message: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ polkadotXcm: {
+ /**
+ * Execute an XCM message from a local, signed, origin.
+ *
+ * An event is deposited indicating whether `msg` could be executed completely or only
+ * partially.
+ *
+ * No more than `max_weight` will be used in its attempted execution. If this is less than the
+ * maximum amount of weight that the message could take to be executed, then no execution
+ * attempt will be made.
+ *
+ * NOTE: A successful return to this does *not* imply that the `msg` was executed successfully
+ * to completion; only that *some* of it was executed.
+ **/
+ execute: AugmentedSubmittable<(message: XcmVersionedXcm | { V0: any } | { V1: any } | { V2: any } | string | Uint8Array, maxWeight: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedXcm, u64]>;
+ /**
+ * Set a safe XCM version (the version that XCM should be encoded with if the most recent
+ * version a destination can accept is unknown).
+ *
+ * - `origin`: Must be Root.
+ * - `maybe_xcm_version`: The default XCM encoding version, or `None` to disable.
+ **/
+ forceDefaultXcmVersion: AugmentedSubmittable<(maybeXcmVersion: Option<u32> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<u32>]>;
+ /**
+ * Ask a location to notify us regarding their XCM version and any changes to it.
+ *
+ * - `origin`: Must be Root.
+ * - `location`: The location to which we should subscribe for XCM version notifications.
+ **/
+ forceSubscribeVersionNotify: AugmentedSubmittable<(location: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation]>;
+ /**
+ * Require that a particular destination should no longer notify us regarding any XCM
+ * version changes.
+ *
+ * - `origin`: Must be Root.
+ * - `location`: The location to which we are currently subscribed for XCM version
+ * notifications which we no longer desire.
+ **/
+ forceUnsubscribeVersionNotify: AugmentedSubmittable<(location: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation]>;
+ /**
+ * Extoll that a particular destination can be communicated with through a particular
+ * version of XCM.
+ *
+ * - `origin`: Must be Root.
+ * - `location`: The destination that is being described.
+ * - `xcm_version`: The latest version of XCM that `location` supports.
+ **/
+ forceXcmVersion: AugmentedSubmittable<(location: XcmV1MultiLocation | { parents?: any; interior?: any } | string | Uint8Array, xcmVersion: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmV1MultiLocation, u32]>;
+ /**
+ * Transfer some assets from the local chain to the sovereign account of a destination chain and forward
+ * a notification XCM.
+ *
+ * Fee payment on the destination side is made from the first asset listed in the `assets` vector.
+ *
+ * - `origin`: Must be capable of withdrawing the `assets` and executing XCM.
+ * - `dest`: Destination context for the assets. Will typically be `X2(Parent, Parachain(..))` to send
+ * from parachain to parachain, or `X1(Parachain(..))` to send from relay to parachain.
+ * - `beneficiary`: A beneficiary location for the assets in the context of `dest`. Will generally be
+ * an `AccountId32` value.
+ * - `assets`: The assets to be withdrawn. This should include the assets used to pay the fee on the
+ * `dest` side.
+ * - `fee_asset_item`: The index into `assets` of the item which should be used to pay
+ * fees.
+ * - `weight_limit`: The remote-side weight limit, if any, for the XCM fee purchase.
+ **/
+ limitedReserveTransferAssets: AugmentedSubmittable<(dest: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, beneficiary: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, assets: XcmVersionedMultiAssets | { V0: any } | { V1: any } | string | Uint8Array, feeAssetItem: u32 | AnyNumber | Uint8Array, weightLimit: XcmV2WeightLimit | { Unlimited: any } | { Limited: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation, XcmVersionedMultiLocation, XcmVersionedMultiAssets, u32, XcmV2WeightLimit]>;
+ /**
+ * Teleport some assets from the local chain to some destination chain.
+ *
+ * Fee payment on the destination side is made from the first asset listed in the `assets` vector.
+ *
+ * - `origin`: Must be capable of withdrawing the `assets` and executing XCM.
+ * - `dest`: Destination context for the assets. Will typically be `X2(Parent, Parachain(..))` to send
+ * from parachain to parachain, or `X1(Parachain(..))` to send from relay to parachain.
+ * - `beneficiary`: A beneficiary location for the assets in the context of `dest`. Will generally be
+ * an `AccountId32` value.
+ * - `assets`: The assets to be withdrawn. The first item should be the currency used to to pay the fee on the
+ * `dest` side. May not be empty.
+ * - `dest_weight`: Equal to the total weight on `dest` of the XCM message
+ * `Teleport { assets, effects: [ BuyExecution{..}, DepositAsset{..} ] }`.
+ * - `weight_limit`: The remote-side weight limit, if any, for the XCM fee purchase.
+ **/
+ limitedTeleportAssets: AugmentedSubmittable<(dest: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, beneficiary: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, assets: XcmVersionedMultiAssets | { V0: any } | { V1: any } | string | Uint8Array, feeAssetItem: u32 | AnyNumber | Uint8Array, weightLimit: XcmV2WeightLimit | { Unlimited: any } | { Limited: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation, XcmVersionedMultiLocation, XcmVersionedMultiAssets, u32, XcmV2WeightLimit]>;
+ /**
+ * Transfer some assets from the local chain to the sovereign account of a destination chain and forward
+ * a notification XCM.
+ *
+ * Fee payment on the destination side is made from the first asset listed in the `assets` vector and
+ * fee-weight is calculated locally and thus remote weights are assumed to be equal to
+ * local weights.
+ *
+ * - `origin`: Must be capable of withdrawing the `assets` and executing XCM.
+ * - `dest`: Destination context for the assets. Will typically be `X2(Parent, Parachain(..))` to send
+ * from parachain to parachain, or `X1(Parachain(..))` to send from relay to parachain.
+ * - `beneficiary`: A beneficiary location for the assets in the context of `dest`. Will generally be
+ * an `AccountId32` value.
+ * - `assets`: The assets to be withdrawn. This should include the assets used to pay the fee on the
+ * `dest` side.
+ * - `fee_asset_item`: The index into `assets` of the item which should be used to pay
+ * fees.
+ **/
+ reserveTransferAssets: AugmentedSubmittable<(dest: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, beneficiary: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, assets: XcmVersionedMultiAssets | { V0: any } | { V1: any } | string | Uint8Array, feeAssetItem: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation, XcmVersionedMultiLocation, XcmVersionedMultiAssets, u32]>;
+ send: AugmentedSubmittable<(dest: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, message: XcmVersionedXcm | { V0: any } | { V1: any } | { V2: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation, XcmVersionedXcm]>;
+ /**
+ * Teleport some assets from the local chain to some destination chain.
+ *
+ * Fee payment on the destination side is made from the first asset listed in the `assets` vector and
+ * fee-weight is calculated locally and thus remote weights are assumed to be equal to
+ * local weights.
+ *
+ * - `origin`: Must be capable of withdrawing the `assets` and executing XCM.
+ * - `dest`: Destination context for the assets. Will typically be `X2(Parent, Parachain(..))` to send
+ * from parachain to parachain, or `X1(Parachain(..))` to send from relay to parachain.
+ * - `beneficiary`: A beneficiary location for the assets in the context of `dest`. Will generally be
+ * an `AccountId32` value.
+ * - `assets`: The assets to be withdrawn. The first item should be the currency used to to pay the fee on the
+ * `dest` side. May not be empty.
+ * - `dest_weight`: Equal to the total weight on `dest` of the XCM message
+ * `Teleport { assets, effects: [ BuyExecution{..}, DepositAsset{..} ] }`.
+ **/
+ teleportAssets: AugmentedSubmittable<(dest: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, beneficiary: XcmVersionedMultiLocation | { V0: any } | { V1: any } | string | Uint8Array, assets: XcmVersionedMultiAssets | { V0: any } | { V1: any } | string | Uint8Array, feeAssetItem: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [XcmVersionedMultiLocation, XcmVersionedMultiLocation, XcmVersionedMultiAssets, u32]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ scheduler: {
+ /**
+ * Cancel an anonymously scheduled task.
+ *
+ * # <weight>
+ * - S = Number of already scheduled calls
+ * - Base Weight: 22.15 + 2.869 * S µs
+ * - DB Weight:
+ * - Read: Agenda
+ * - Write: Agenda, Lookup
+ * - Will use base weight of 100 which should be good for up to 30 scheduled calls
+ * # </weight>
+ **/
+ cancel: AugmentedSubmittable<(when: u32 | AnyNumber | Uint8Array, index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
+ /**
+ * Cancel a named scheduled task.
+ *
+ * # <weight>
+ * - S = Number of already scheduled calls
+ * - Base Weight: 24.91 + 2.907 * S µs
+ * - DB Weight:
+ * - Read: Agenda, Lookup
+ * - Write: Agenda, Lookup
+ * - Will use base weight of 100 which should be good for up to 30 scheduled calls
+ * # </weight>
+ **/
+ cancelNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Anonymously schedule a task.
+ *
+ * # <weight>
+ * - S = Number of already scheduled calls
+ * - Base Weight: 22.29 + .126 * S µs
+ * - DB Weight:
+ * - Read: Agenda
+ * - Write: Agenda
+ * - Will use base weight of 25 which should be good for up to 30 scheduled calls
+ * # </weight>
+ **/
+ schedule: AugmentedSubmittable<(when: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
+ /**
+ * Anonymously schedule a task after a delay.
+ *
+ * # <weight>
+ * Same as [`schedule`].
+ * # </weight>
+ **/
+ scheduleAfter: AugmentedSubmittable<(after: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
+ /**
+ * Schedule a named task.
+ *
+ * # <weight>
+ * - S = Number of already scheduled calls
+ * - Base Weight: 29.6 + .159 * S µs
+ * - DB Weight:
+ * - Read: Agenda, Lookup
+ * - Write: Agenda, Lookup
+ * - Will use base weight of 35 which should be good for more than 30 scheduled calls
+ * # </weight>
+ **/
+ scheduleNamed: AugmentedSubmittable<(id: Bytes | string | Uint8Array, when: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [Bytes, u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
+ /**
+ * Schedule a named task after a delay.
+ *
+ * # <weight>
+ * Same as [`schedule_named`].
+ * # </weight>
+ **/
+ scheduleNamedAfter: AugmentedSubmittable<(id: Bytes | string | Uint8Array, after: u32 | AnyNumber | Uint8Array, maybePeriodic: Option<ITuple<[u32, u32]>> | null | object | string | Uint8Array, priority: u8 | AnyNumber | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [Bytes, u32, Option<ITuple<[u32, u32]>>, u8, Call]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ sudo: {
+ /**
+ * Authenticates the current sudo key and sets the given AccountId (`new`) as the new sudo
+ * key.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * # <weight>
+ * - O(1).
+ * - Limited storage reads.
+ * - One DB change.
+ * # </weight>
+ **/
+ setKey: AugmentedSubmittable<(updated: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
+ /**
+ * Authenticates the sudo key and dispatches a function call with `Root` origin.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * # <weight>
+ * - O(1).
+ * - Limited storage reads.
+ * - One DB write (event).
+ * - Weight of derivative `call` execution + 10,000.
+ * # </weight>
+ **/
+ sudo: AugmentedSubmittable<(call: Call) => SubmittableExtrinsic<ApiType>, [Call]>;
+ /**
+ * Authenticates the sudo key and dispatches a function call with `Signed` origin from
+ * a given account.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * # <weight>
+ * - O(1).
+ * - Limited storage reads.
+ * - One DB write (event).
+ * - Weight of derivative `call` execution + 10,000.
+ * # </weight>
+ **/
+ sudoAs: AugmentedSubmittable<(who: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, call: Call) => SubmittableExtrinsic<ApiType>, [MultiAddress, Call]>;
+ /**
+ * Authenticates the sudo key and dispatches a function call with `Root` origin.
+ * This function does not check the weight of the call, and instead allows the
+ * Sudo user to specify the weight of the call.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * # <weight>
+ * - O(1).
+ * - The weight of this call is defined by the caller.
+ * # </weight>
+ **/
+ sudoUncheckedWeight: AugmentedSubmittable<(call: Call, weight: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Call, u64]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ system: {
+ /**
+ * A dispatch that will fill the block weight up to the given ratio.
+ **/
+ fillBlock: AugmentedSubmittable<(ratio: Perbill | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Perbill]>;
+ /**
+ * Kill all storage items with a key that starts with the given prefix.
+ *
+ * **NOTE:** We rely on the Root origin to provide us the number of subkeys under
+ * the prefix we are removing to accurately calculate the weight of this function.
+ *
+ * # <weight>
+ * - `O(P)` where `P` amount of keys with prefix `prefix`
+ * - `P` storage deletions.
+ * - Base Weight: 0.834 * P µs
+ * - Writes: Number of subkeys + 1
+ * # </weight>
+ **/
+ killPrefix: AugmentedSubmittable<(prefix: Bytes | string | Uint8Array, subkeys: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes, u32]>;
+ /**
+ * Kill some items from storage.
+ *
+ * # <weight>
+ * - `O(IK)` where `I` length of `keys` and `K` length of one key
+ * - `I` storage deletions.
+ * - Base Weight: .378 * i µs
+ * - Writes: Number of items
+ * # </weight>
+ **/
+ killStorage: AugmentedSubmittable<(keys: Vec<Bytes> | (Bytes | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Vec<Bytes>]>;
+ /**
+ * Make some on-chain remark.
+ *
+ * # <weight>
+ * - `O(1)`
+ * # </weight>
+ **/
+ remark: AugmentedSubmittable<(remark: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Make some on-chain remark and emit event.
+ *
+ * # <weight>
+ * - `O(b)` where b is the length of the remark.
+ * - 1 event.
+ * # </weight>
+ **/
+ remarkWithEvent: AugmentedSubmittable<(remark: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Set the new changes trie configuration.
+ *
+ * # <weight>
+ * - `O(1)`
+ * - 1 storage write or delete (codec `O(1)`).
+ * - 1 call to `deposit_log`: Uses `append` API, so O(1)
+ * - Base Weight: 7.218 µs
+ * - DB Weight:
+ * - Writes: Changes Trie, System Digest
+ * # </weight>
+ **/
+ setChangesTrieConfig: AugmentedSubmittable<(changesTrieConfig: Option<SpCoreChangesTrieChangesTrieConfiguration> | null | object | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Option<SpCoreChangesTrieChangesTrieConfiguration>]>;
+ /**
+ * Set the new runtime code.
+ *
+ * # <weight>
+ * - `O(C + S)` where `C` length of `code` and `S` complexity of `can_set_code`
+ * - 1 call to `can_set_code`: `O(S)` (calls `sp_io::misc::runtime_version` which is
+ * expensive).
+ * - 1 storage write (codec `O(C)`).
+ * - 1 digest item.
+ * - 1 event.
+ * The weight of this function is dependent on the runtime, but generally this is very
+ * expensive. We will treat this as a full block.
+ * # </weight>
+ **/
+ setCode: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Set the new runtime code without doing any checks of the given `code`.
+ *
+ * # <weight>
+ * - `O(C)` where `C` length of `code`
+ * - 1 storage write (codec `O(C)`).
+ * - 1 digest item.
+ * - 1 event.
+ * The weight of this function is dependent on the runtime. We will treat this as a full
+ * block. # </weight>
+ **/
+ setCodeWithoutChecks: AugmentedSubmittable<(code: Bytes | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Bytes]>;
+ /**
+ * Set the number of pages in the WebAssembly environment's heap.
+ *
+ * # <weight>
+ * - `O(1)`
+ * - 1 storage write.
+ * - Base Weight: 1.405 µs
+ * - 1 write to HEAP_PAGES
+ * - 1 digest item
+ * # </weight>
+ **/
+ setHeapPages: AugmentedSubmittable<(pages: u64 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u64]>;
+ /**
+ * Set some items of storage.
+ *
+ * # <weight>
+ * - `O(I)` where `I` length of `items`
+ * - `I` storage writes (`O(1)`).
+ * - Base Weight: 0.568 * i µs
+ * - Writes: Number of items
+ * # </weight>
+ **/
+ setStorage: AugmentedSubmittable<(items: Vec<ITuple<[Bytes, Bytes]>> | ([Bytes | string | Uint8Array, Bytes | string | Uint8Array])[]) => SubmittableExtrinsic<ApiType>, [Vec<ITuple<[Bytes, Bytes]>>]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ timestamp: {
+ /**
+ * Set the current time.
+ *
+ * This call should be invoked exactly once per block. It will panic at the finalization
+ * phase, if this call hasn't been invoked by that time.
+ *
+ * The timestamp should be greater than the previous one by the amount specified by
+ * `MinimumPeriod`.
+ *
+ * The dispatch origin for this call must be `Inherent`.
+ *
+ * # <weight>
+ * - `O(1)` (Note that implementations of `OnTimestampSet` must also be `O(1)`)
+ * - 1 storage read and 1 storage mutation (codec `O(1)`). (because of `DidUpdate::take` in
+ * `on_finalize`)
+ * - 1 event handler `on_timestamp_set`. Must be `O(1)`.
+ * # </weight>
+ **/
+ set: AugmentedSubmittable<(now: Compact<u64> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u64>]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ treasury: {
+ /**
+ * Approve a proposal. At a later time, the proposal will be allocated to the beneficiary
+ * and the original deposit will be returned.
+ *
+ * May only be called from `T::ApproveOrigin`.
+ *
+ * # <weight>
+ * - Complexity: O(1).
+ * - DbReads: `Proposals`, `Approvals`
+ * - DbWrite: `Approvals`
+ * # </weight>
+ **/
+ approveProposal: AugmentedSubmittable<(proposalId: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
+ /**
+ * Put forward a suggestion for spending. A deposit proportional to the value
+ * is reserved and slashed if the proposal is rejected. It is returned once the
+ * proposal is awarded.
+ *
+ * # <weight>
+ * - Complexity: O(1)
+ * - DbReads: `ProposalCount`, `origin account`
+ * - DbWrites: `ProposalCount`, `Proposals`, `origin account`
+ * # </weight>
+ **/
+ proposeSpend: AugmentedSubmittable<(value: Compact<u128> | AnyNumber | Uint8Array, beneficiary: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u128>, MultiAddress]>;
+ /**
+ * Reject a proposed spend. The original deposit will be slashed.
+ *
+ * May only be called from `T::RejectOrigin`.
+ *
+ * # <weight>
+ * - Complexity: O(1)
+ * - DbReads: `Proposals`, `rejected proposer account`
+ * - DbWrites: `Proposals`, `rejected proposer account`
+ * # </weight>
+ **/
+ rejectProposal: AugmentedSubmittable<(proposalId: Compact<u32> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u32>]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ vesting: {
+ /**
+ * Force a vested transfer.
+ *
+ * The dispatch origin for this call must be _Root_.
+ *
+ * - `source`: The account whose funds should be transferred.
+ * - `target`: The account that should be transferred the vested funds.
+ * - `schedule`: The vesting schedule attached to the transfer.
+ *
+ * Emits `VestingCreated`.
+ *
+ * NOTE: This will unlock all schedules through the current block.
+ *
+ * # <weight>
+ * - `O(1)`.
+ * - DbWeight: 4 Reads, 4 Writes
+ * - Reads: Vesting Storage, Balances Locks, Target Account, Source Account
+ * - Writes: Vesting Storage, Balances Locks, Target Account, Source Account
+ * # </weight>
+ **/
+ forceVestedTransfer: AugmentedSubmittable<(source: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: PalletVestingVestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, MultiAddress, PalletVestingVestingInfo]>;
+ /**
+ * Merge two vesting schedules together, creating a new vesting schedule that unlocks over
+ * the highest possible start and end blocks. If both schedules have already started the
+ * current block will be used as the schedule start; with the caveat that if one schedule
+ * is finished by the current block, the other will be treated as the new merged schedule,
+ * unmodified.
+ *
+ * NOTE: If `schedule1_index == schedule2_index` this is a no-op.
+ * NOTE: This will unlock all schedules through the current block prior to merging.
+ * NOTE: If both schedules have ended by the current block, no new schedule will be created
+ * and both will be removed.
+ *
+ * Merged schedule attributes:
+ * - `starting_block`: `MAX(schedule1.starting_block, scheduled2.starting_block,
+ * current_block)`.
+ * - `ending_block`: `MAX(schedule1.ending_block, schedule2.ending_block)`.
+ * - `locked`: `schedule1.locked_at(current_block) + schedule2.locked_at(current_block)`.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * - `schedule1_index`: index of the first schedule to merge.
+ * - `schedule2_index`: index of the second schedule to merge.
+ **/
+ mergeSchedules: AugmentedSubmittable<(schedule1Index: u32 | AnyNumber | Uint8Array, schedule2Index: u32 | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [u32, u32]>;
+ /**
+ * Unlock any vested funds of the sender account.
+ *
+ * The dispatch origin for this call must be _Signed_ and the sender must have funds still
+ * locked under this pallet.
+ *
+ * Emits either `VestingCompleted` or `VestingUpdated`.
+ *
+ * # <weight>
+ * - `O(1)`.
+ * - DbWeight: 2 Reads, 2 Writes
+ * - Reads: Vesting Storage, Balances Locks, [Sender Account]
+ * - Writes: Vesting Storage, Balances Locks, [Sender Account]
+ * # </weight>
+ **/
+ vest: AugmentedSubmittable<() => SubmittableExtrinsic<ApiType>, []>;
+ /**
+ * Create a vested transfer.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * - `target`: The account receiving the vested funds.
+ * - `schedule`: The vesting schedule attached to the transfer.
+ *
+ * Emits `VestingCreated`.
+ *
+ * NOTE: This will unlock all schedules through the current block.
+ *
+ * # <weight>
+ * - `O(1)`.
+ * - DbWeight: 3 Reads, 3 Writes
+ * - Reads: Vesting Storage, Balances Locks, Target Account, [Sender Account]
+ * - Writes: Vesting Storage, Balances Locks, Target Account, [Sender Account]
+ * # </weight>
+ **/
+ vestedTransfer: AugmentedSubmittable<(target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array, schedule: PalletVestingVestingInfo | { locked?: any; perBlock?: any; startingBlock?: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress, PalletVestingVestingInfo]>;
+ /**
+ * Unlock any vested funds of a `target` account.
+ *
+ * The dispatch origin for this call must be _Signed_.
+ *
+ * - `target`: The account whose vested funds should be unlocked. Must have funds still
+ * locked under this pallet.
+ *
+ * Emits either `VestingCompleted` or `VestingUpdated`.
+ *
+ * # <weight>
+ * - `O(1)`.
+ * - DbWeight: 3 Reads, 3 Writes
+ * - Reads: Vesting Storage, Balances Locks, Target Account
+ * - Writes: Vesting Storage, Balances Locks, Target Account
+ * # </weight>
+ **/
+ vestOther: AugmentedSubmittable<(target: MultiAddress | { Id: any } | { Index: any } | { Raw: any } | { Address32: any } | { Address20: any } | string | Uint8Array) => SubmittableExtrinsic<ApiType>, [MultiAddress]>;
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ xcmpQueue: {
+ /**
+ * Generic tx
+ **/
+ [key: string]: SubmittableExtrinsicFunction<ApiType>;
+ };
+ }
+
+ export interface SubmittableExtrinsics<ApiType extends ApiTypes> extends AugmentedSubmittables<ApiType> {
+ (extrinsic: Call | Extrinsic | Uint8Array | string): SubmittableExtrinsic<ApiType>;
+ [key: string]: SubmittableModuleExtrinsics<ApiType>;
+ }
+}
tests/src/interfaces/augment-api.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-api.ts
@@ -0,0 +1,10 @@
+// Auto-generated via `yarn polkadot-types-from-chain`, do not edit
+/* eslint-disable */
+
+import '@polkadot/api/augment/rpc';
+import './augment-api-consts';
+import './augment-api-errors';
+import './augment-api-events';
+import './augment-api-query';
+import './augment-api-tx';
+import './augment-api-rpc';
tests/src/interfaces/augment-types.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/augment-types.ts
@@ -0,0 +1,1112 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+import type { EthereumBlock, EthereumLog, EthereumReceipt, EthereumTransactionLegacyTransaction, EvmCoreErrorExitReason, FpRpcTransactionStatus } from './ethereum';
+import type { NftDataStructsAccessMode, NftDataStructsCollection, NftDataStructsCollectionId, NftDataStructsCollectionLimits, NftDataStructsCollectionMode, NftDataStructsCreateItemData, NftDataStructsMetaUpdatePermission, NftDataStructsSchemaVersion, NftDataStructsSponsorshipState, NftDataStructsTokenId, PalletCommonAccountBasicCrossAccountIdRepr, PalletNonfungibleItemData, PalletRefungibleItemData, PalletUnqSchedulerCallSpec, PalletUnqSchedulerReleases, PalletUnqSchedulerScheduledV2 } from './nft';
+import type { CumulusPalletDmpQueueConfigData, CumulusPalletDmpQueuePageIndexData, CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot, CumulusPalletXcmpQueueInboundStatus, CumulusPalletXcmpQueueOutboundStatus, CumulusPalletXcmpQueueQueueConfigData, CumulusPrimitivesParachainInherentParachainInherentData, PolkadotParachainPrimitivesXcmpMessageFormat, PolkadotPrimitivesV1AbridgedHostConfiguration, PolkadotPrimitivesV1PersistedValidationData } from './polkadot';
+import type { BitVec, Bool, Bytes, Data, I128, I16, I256, I32, I64, I8, Json, Null, Raw, StorageKey, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, i128, i16, i256, i32, i64, i8, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types';
+import type { AssetApproval, AssetApprovalKey, AssetBalance, AssetDestroyWitness, AssetDetails, AssetMetadata, TAssetBalance, TAssetDepositBalance } from '@polkadot/types/interfaces/assets';
+import type { BlockAttestations, IncludedBlocks, MoreAttestations } from '@polkadot/types/interfaces/attestations';
+import type { RawAuraPreDigest } from '@polkadot/types/interfaces/aura';
+import type { ExtrinsicOrHash, ExtrinsicStatus } from '@polkadot/types/interfaces/author';
+import type { UncleEntryItem } from '@polkadot/types/interfaces/authorship';
+import type { AllowedSlots, BabeAuthorityWeight, BabeBlockWeight, BabeEpochConfiguration, BabeEquivocationProof, BabeWeight, EpochAuthorship, MaybeRandomness, MaybeVrf, NextConfigDescriptor, NextConfigDescriptorV1, Randomness, RawBabePreDigest, RawBabePreDigestCompat, RawBabePreDigestPrimary, RawBabePreDigestPrimaryTo159, RawBabePreDigestSecondaryPlain, RawBabePreDigestSecondaryTo159, RawBabePreDigestSecondaryVRF, RawBabePreDigestTo159, SlotNumber, VrfData, VrfOutput, VrfProof } from '@polkadot/types/interfaces/babe';
+import type { AccountData, BalanceLock, BalanceLockTo212, BalanceStatus, Reasons, ReserveData, ReserveIdentifier, VestingSchedule, WithdrawReasons } from '@polkadot/types/interfaces/balances';
+import type { BeefyCommitment, BeefyId, BeefyNextAuthoritySet, BeefyPayload, BeefySignedCommitment, MmrRootHash, ValidatorSetId } from '@polkadot/types/interfaces/beefy';
+import type { BridgeMessageId, BridgedBlockHash, BridgedBlockNumber, BridgedHeader, CallOrigin, ChainId, DeliveredMessages, DispatchFeePayment, InboundLaneData, InboundRelayer, InitializationData, LaneId, MessageData, MessageKey, MessageNonce, MessagesDeliveryProofOf, MessagesProofOf, OperatingMode, OutboundLaneData, OutboundMessageFee, OutboundPayload, Parameter, RelayerId, UnrewardedRelayer, UnrewardedRelayersState } from '@polkadot/types/interfaces/bridges';
+import type { BlockHash } from '@polkadot/types/interfaces/chain';
+import type { PrefixedStorageKey } from '@polkadot/types/interfaces/childstate';
+import type { StatementKind } from '@polkadot/types/interfaces/claims';
+import type { CollectiveOrigin, MemberCount, ProposalIndex, Votes, VotesTo230 } from '@polkadot/types/interfaces/collective';
+import type { AuthorityId, RawVRFOutput } from '@polkadot/types/interfaces/consensus';
+import type { AliveContractInfo, CodeHash, ContractCallRequest, ContractExecResult, ContractExecResultErr, ContractExecResultErrModule, ContractExecResultOk, ContractExecResultResult, ContractExecResultSuccessTo255, ContractExecResultSuccessTo260, ContractExecResultTo255, ContractExecResultTo260, ContractExecResultTo267, ContractInfo, ContractInstantiateResult, ContractInstantiateResultTo267, ContractStorageKey, DeletedContract, ExecReturnValue, Gas, HostFnWeights, HostFnWeightsTo264, InstantiateRequest, InstantiateReturnValue, InstantiateReturnValueTo267, InstructionWeights, Limits, LimitsTo264, PrefabWasmModule, RentProjection, Schedule, ScheduleTo212, ScheduleTo258, ScheduleTo264, SeedOf, TombstoneContractInfo, TrieId } from '@polkadot/types/interfaces/contracts';
+import type { ContractConstructorSpec, ContractContractSpec, ContractCryptoHasher, ContractDiscriminant, ContractDisplayName, ContractEventParamSpec, ContractEventSpec, ContractLayoutArray, ContractLayoutCell, ContractLayoutEnum, ContractLayoutHash, ContractLayoutHashingStrategy, ContractLayoutKey, ContractLayoutStruct, ContractLayoutStructField, ContractMessageParamSpec, ContractMessageSpec, ContractMetadata, ContractMetadataLatest, ContractMetadataV0, ContractMetadataV1, ContractProject, ContractProjectContract, ContractProjectInfo, ContractProjectSource, ContractProjectV0, ContractSelector, ContractStorageLayout, ContractTypeSpec } from '@polkadot/types/interfaces/contractsAbi';
+import type { FundIndex, FundInfo, LastContribution, TrieIndex } from '@polkadot/types/interfaces/crowdloan';
+import type { ConfigData, MessageId, OverweightIndex, PageCounter, PageIndexData } from '@polkadot/types/interfaces/cumulus';
+import type { AccountVote, AccountVoteSplit, AccountVoteStandard, Conviction, Delegations, PreimageStatus, PreimageStatusAvailable, PriorLock, PropIndex, Proposal, ProxyState, ReferendumIndex, ReferendumInfo, ReferendumInfoFinished, ReferendumInfoTo239, ReferendumStatus, Tally, Voting, VotingDelegating, VotingDirect, VotingDirectVote } from '@polkadot/types/interfaces/democracy';
+import type { ApprovalFlag, DefunctVoter, Renouncing, SetIndex, Vote, VoteIndex, VoteThreshold, VoterInfo } from '@polkadot/types/interfaces/elections';
+import type { CreatedBlock, ImportedAux } from '@polkadot/types/interfaces/engine';
+import type { BlockV0, BlockV1, BlockV2, EIP1559Transaction, EIP2930Transaction, EthAccessList, EthAccessListItem, EthAccount, EthAddress, EthBlock, EthBloom, EthCallRequest, EthFilter, EthFilterAddress, EthFilterChanges, EthFilterTopic, EthFilterTopicEntry, EthFilterTopicInner, EthHeader, EthLog, EthReceipt, EthRichBlock, EthRichHeader, EthStorageProof, EthSubKind, EthSubParams, EthSubResult, EthSyncInfo, EthSyncStatus, EthTransaction, EthTransactionAction, EthTransactionCondition, EthTransactionRequest, EthTransactionSignature, EthTransactionStatus, EthWork, EthereumAccountId, EthereumAddress, EthereumLookupSource, EthereumSignature, LegacyTransaction, TransactionV0, TransactionV1, TransactionV2 } from '@polkadot/types/interfaces/eth';
+import type { EvmAccount, EvmLog, EvmVicinity, ExitError, ExitFatal, ExitReason, ExitRevert, ExitSucceed } from '@polkadot/types/interfaces/evm';
+import type { AnySignature, EcdsaSignature, Ed25519Signature, Era, Extrinsic, ExtrinsicEra, ExtrinsicPayload, ExtrinsicPayloadUnknown, ExtrinsicPayloadV4, ExtrinsicSignature, ExtrinsicSignatureV4, ExtrinsicUnknown, ExtrinsicV4, ImmortalEra, MortalEra, MultiSignature, Signature, SignerPayload, Sr25519Signature } from '@polkadot/types/interfaces/extrinsics';
+import type { AssetOptions, Owner, PermissionLatest, PermissionVersions, PermissionsV1 } from '@polkadot/types/interfaces/genericAsset';
+import type { ActiveGilt, ActiveGiltsTotal, ActiveIndex, GiltBid } from '@polkadot/types/interfaces/gilt';
+import type { AuthorityIndex, AuthorityList, AuthoritySet, AuthoritySetChange, AuthoritySetChanges, AuthorityWeight, DelayKind, DelayKindBest, EncodedFinalityProofs, ForkTreePendingChange, ForkTreePendingChangeNode, GrandpaCommit, GrandpaEquivocation, GrandpaEquivocationProof, GrandpaEquivocationValue, GrandpaJustification, GrandpaPrecommit, GrandpaPrevote, GrandpaSignedPrecommit, JustificationNotification, KeyOwnerProof, NextAuthority, PendingChange, PendingPause, PendingResume, Precommits, Prevotes, ReportedRoundStates, RoundState, SetId, StoredPendingChange, StoredState } from '@polkadot/types/interfaces/grandpa';
+import type { IdentityFields, IdentityInfo, IdentityInfoAdditional, IdentityInfoTo198, IdentityJudgement, RegistrarIndex, RegistrarInfo, Registration, RegistrationJudgement, RegistrationTo198 } from '@polkadot/types/interfaces/identity';
+import type { AuthIndex, AuthoritySignature, Heartbeat, HeartbeatTo244, OpaqueMultiaddr, OpaqueNetworkState, OpaquePeerId } from '@polkadot/types/interfaces/imOnline';
+import type { CallIndex, LotteryConfig } from '@polkadot/types/interfaces/lottery';
+import type { ErrorMetadataLatest, ErrorMetadataV10, ErrorMetadataV11, ErrorMetadataV12, ErrorMetadataV13, ErrorMetadataV14, ErrorMetadataV9, EventMetadataLatest, EventMetadataV10, EventMetadataV11, EventMetadataV12, EventMetadataV13, EventMetadataV14, EventMetadataV9, ExtrinsicMetadataLatest, ExtrinsicMetadataV11, ExtrinsicMetadataV12, ExtrinsicMetadataV13, ExtrinsicMetadataV14, FunctionArgumentMetadataLatest, FunctionArgumentMetadataV10, FunctionArgumentMetadataV11, FunctionArgumentMetadataV12, FunctionArgumentMetadataV13, FunctionArgumentMetadataV14, FunctionArgumentMetadataV9, FunctionMetadataLatest, FunctionMetadataV10, FunctionMetadataV11, FunctionMetadataV12, FunctionMetadataV13, FunctionMetadataV14, FunctionMetadataV9, MetadataAll, MetadataLatest, MetadataV10, MetadataV11, MetadataV12, MetadataV13, MetadataV14, MetadataV9, ModuleConstantMetadataV10, ModuleConstantMetadataV11, ModuleConstantMetadataV12, ModuleConstantMetadataV13, ModuleConstantMetadataV9, ModuleMetadataV10, ModuleMetadataV11, ModuleMetadataV12, ModuleMetadataV13, ModuleMetadataV9, PalletCallMetadataLatest, PalletCallMetadataV14, PalletConstantMetadataLatest, PalletConstantMetadataV14, PalletErrorMetadataLatest, PalletErrorMetadataV14, PalletEventMetadataLatest, PalletEventMetadataV14, PalletMetadataLatest, PalletMetadataV14, PalletStorageMetadataLatest, PalletStorageMetadataV14, PortableRegistry, PortableRegistryV14, PortableType, PortableTypeV14, SignedExtensionMetadataLatest, SignedExtensionMetadataV14, StorageEntryMetadataLatest, StorageEntryMetadataV10, StorageEntryMetadataV11, StorageEntryMetadataV12, StorageEntryMetadataV13, StorageEntryMetadataV14, StorageEntryMetadataV9, StorageEntryModifierLatest, StorageEntryModifierV10, StorageEntryModifierV11, StorageEntryModifierV12, StorageEntryModifierV13, StorageEntryModifierV14, StorageEntryModifierV9, StorageEntryTypeLatest, StorageEntryTypeV10, StorageEntryTypeV11, StorageEntryTypeV12, StorageEntryTypeV13, StorageEntryTypeV14, StorageEntryTypeV9, StorageHasher, StorageHasherV10, StorageHasherV11, StorageHasherV12, StorageHasherV13, StorageHasherV14, StorageHasherV9, StorageMetadataV10, StorageMetadataV11, StorageMetadataV12, StorageMetadataV13, StorageMetadataV9 } from '@polkadot/types/interfaces/metadata';
+import type { MmrLeafProof } from '@polkadot/types/interfaces/mmr';
+import type { StorageKind } from '@polkadot/types/interfaces/offchain';
+import type { DeferredOffenceOf, Kind, OffenceDetails, Offender, OpaqueTimeSlot, ReportIdOf, Reporter } from '@polkadot/types/interfaces/offences';
+import type { AbridgedCandidateReceipt, AbridgedHostConfiguration, AbridgedHrmpChannel, AssignmentId, AssignmentKind, AttestedCandidate, AuctionIndex, AuthorityDiscoveryId, AvailabilityBitfield, AvailabilityBitfieldRecord, BackedCandidate, Bidder, BufferedSessionChange, CandidateCommitments, CandidateDescriptor, CandidateHash, CandidateInfo, CandidatePendingAvailability, CandidateReceipt, CollatorId, CollatorSignature, CommittedCandidateReceipt, CoreAssignment, CoreIndex, CoreOccupied, DisputeLocation, DisputeResult, DisputeState, DisputeStatement, DisputeStatementSet, DoubleVoteReport, DownwardMessage, ExplicitDisputeStatement, GlobalValidationData, GlobalValidationSchedule, GroupIndex, HeadData, HostConfiguration, HrmpChannel, HrmpChannelId, HrmpOpenChannelRequest, InboundDownwardMessage, InboundHrmpMessage, InboundHrmpMessages, IncomingParachain, IncomingParachainDeploy, IncomingParachainFixed, InvalidDisputeStatementKind, LeasePeriod, LeasePeriodOf, LocalValidationData, MessageIngestionType, MessageQueueChain, MessagingStateSnapshot, MessagingStateSnapshotEgressEntry, MultiDisputeStatementSet, NewBidder, OutboundHrmpMessage, ParaGenesisArgs, ParaId, ParaInfo, ParaLifecycle, ParaPastCodeMeta, ParaScheduling, ParaValidatorIndex, ParachainDispatchOrigin, ParachainInherentData, ParachainProposal, ParachainsInherentData, ParathreadClaim, ParathreadClaimQueue, ParathreadEntry, PersistedValidationData, QueuedParathread, RegisteredParachainInfo, RelayBlockNumber, RelayChainBlockNumber, RelayChainHash, RelayHash, Remark, ReplacementTimes, Retriable, Scheduling, ServiceQuality, SessionInfo, SessionInfoValidatorGroup, SignedAvailabilityBitfield, SignedAvailabilityBitfields, SigningContext, SlotRange, Statement, SubId, SystemInherentData, TransientValidationData, UpgradeGoAhead, UpgradeRestriction, UpwardMessage, ValidDisputeStatementKind, ValidationCode, ValidationCodeHash, ValidationData, ValidationDataType, ValidationFunctionParams, ValidatorSignature, ValidityAttestation, VecInboundHrmpMessage, WinnersData, WinnersDataTuple, WinningData, WinningDataEntry } from '@polkadot/types/interfaces/parachains';
+import type { FeeDetails, InclusionFee, RuntimeDispatchInfo } from '@polkadot/types/interfaces/payment';
+import type { Approvals } from '@polkadot/types/interfaces/poll';
+import type { ProxyAnnouncement, ProxyDefinition, ProxyType } from '@polkadot/types/interfaces/proxy';
+import type { AccountStatus, AccountValidity } from '@polkadot/types/interfaces/purchase';
+import type { ActiveRecovery, RecoveryConfig } from '@polkadot/types/interfaces/recovery';
+import type { RpcMethods } from '@polkadot/types/interfaces/rpc';
+import type { AccountId, AccountId20, AccountId32, AccountIdOf, AccountIndex, Address, AssetId, Balance, BalanceOf, Block, BlockNumber, BlockNumberFor, BlockNumberOf, Call, CallHash, CallHashOf, ChangesTrieConfiguration, ChangesTrieSignal, CodecHash, Consensus, ConsensusEngineId, CrateVersion, Digest, DigestItem, EncodedJustification, ExtrinsicsWeight, Fixed128, Fixed64, FixedI128, FixedI64, FixedU128, FixedU64, H1024, H128, H160, H2048, H256, H32, H512, H64, Hash, Header, HeaderPartial, I32F32, Index, IndicesLookupSource, Justification, Justifications, KeyTypeId, KeyValue, LockIdentifier, LookupSource, LookupTarget, ModuleId, Moment, MultiAddress, MultiSigner, OpaqueCall, Origin, OriginCaller, PalletId, PalletVersion, PalletsOrigin, Pays, PerU16, Perbill, Percent, Permill, Perquintill, Phantom, PhantomData, PreRuntime, Releases, RuntimeDbWeight, Seal, SealV0, SignedBlock, SignedBlockWithJustification, SignedBlockWithJustifications, Slot, StorageData, StorageProof, TransactionInfo, TransactionPriority, TransactionStorageProof, U32F32, ValidatorId, ValidatorIdOf, Weight, WeightMultiplier } from '@polkadot/types/interfaces/runtime';
+import type { Si0Field, Si0LookupTypeId, Si0Path, Si0Type, Si0TypeDef, Si0TypeDefArray, Si0TypeDefBitSequence, Si0TypeDefCompact, Si0TypeDefComposite, Si0TypeDefPhantom, Si0TypeDefPrimitive, Si0TypeDefSequence, Si0TypeDefTuple, Si0TypeDefVariant, Si0TypeParameter, Si0Variant, Si1Field, Si1LookupTypeId, Si1Path, Si1Type, Si1TypeDef, Si1TypeDefArray, Si1TypeDefBitSequence, Si1TypeDefCompact, Si1TypeDefComposite, Si1TypeDefPrimitive, Si1TypeDefSequence, Si1TypeDefTuple, Si1TypeDefVariant, Si1TypeParameter, Si1Variant, SiField, SiLookupTypeId, SiPath, SiType, SiTypeDef, SiTypeDefArray, SiTypeDefBitSequence, SiTypeDefCompact, SiTypeDefComposite, SiTypeDefPrimitive, SiTypeDefSequence, SiTypeDefTuple, SiTypeDefVariant, SiTypeParameter, SiVariant } from '@polkadot/types/interfaces/scaleInfo';
+import type { Period, Priority, SchedulePeriod, SchedulePriority, Scheduled, ScheduledTo254, TaskAddress } from '@polkadot/types/interfaces/scheduler';
+import type { BeefyKey, FullIdentification, IdentificationTuple, Keys, MembershipProof, SessionIndex, SessionKeys1, SessionKeys10, SessionKeys10B, SessionKeys2, SessionKeys3, SessionKeys4, SessionKeys5, SessionKeys6, SessionKeys6B, SessionKeys7, SessionKeys7B, SessionKeys8, SessionKeys8B, SessionKeys9, SessionKeys9B, ValidatorCount } from '@polkadot/types/interfaces/session';
+import type { Bid, BidKind, SocietyJudgement, SocietyVote, StrikeCount, VouchingStatus } from '@polkadot/types/interfaces/society';
+import type { ActiveEraInfo, CompactAssignments, CompactAssignmentsTo257, CompactAssignmentsTo265, CompactAssignmentsWith16, CompactAssignmentsWith24, CompactScore, CompactScoreCompact, ElectionCompute, ElectionPhase, ElectionResult, ElectionScore, ElectionSize, ElectionStatus, EraIndex, EraPoints, EraRewardPoints, EraRewards, Exposure, ExtendedBalance, Forcing, IndividualExposure, KeyType, MomentOf, Nominations, NominatorIndex, NominatorIndexCompact, OffchainAccuracy, OffchainAccuracyCompact, PhragmenScore, Points, RawSolution, RawSolutionTo265, RawSolutionWith16, RawSolutionWith24, ReadySolution, RewardDestination, RewardPoint, RoundSnapshot, SeatHolder, SignedSubmission, SignedSubmissionOf, SignedSubmissionTo276, SlashJournalEntry, SlashingSpans, SlashingSpansTo204, SolutionOrSnapshotSize, SolutionSupport, SolutionSupports, SpanIndex, SpanRecord, StakingLedger, StakingLedgerTo223, StakingLedgerTo240, SubmissionIndicesOf, Supports, UnappliedSlash, UnappliedSlashOther, UnlockChunk, ValidatorIndex, ValidatorIndexCompact, ValidatorPrefs, ValidatorPrefsTo145, ValidatorPrefsTo196, ValidatorPrefsWithBlocked, ValidatorPrefsWithCommission, VoteWeight, Voter } from '@polkadot/types/interfaces/staking';
+import type { ApiId, BlockTrace, BlockTraceEvent, BlockTraceEventData, BlockTraceSpan, KeyValueOption, ReadProof, RuntimeVersion, RuntimeVersionApi, RuntimeVersionPartial, SpecVersion, StorageChangeSet, TraceBlockResponse, TraceError } from '@polkadot/types/interfaces/state';
+import type { WeightToFeeCoefficient } from '@polkadot/types/interfaces/support';
+import type { AccountInfo, AccountInfoWithDualRefCount, AccountInfoWithProviders, AccountInfoWithRefCount, AccountInfoWithRefCountU8, AccountInfoWithTripleRefCount, ApplyExtrinsicResult, ArithmeticError, BlockLength, BlockWeights, ChainProperties, ChainType, ConsumedWeight, DigestOf, DispatchClass, DispatchError, DispatchErrorModule, DispatchErrorTo198, DispatchInfo, DispatchInfoTo190, DispatchInfoTo244, DispatchOutcome, DispatchResult, DispatchResultOf, DispatchResultTo198, Event, EventId, EventIndex, EventRecord, Health, InvalidTransaction, Key, LastRuntimeUpgradeInfo, NetworkState, NetworkStatePeerset, NetworkStatePeersetInfo, NodeRole, NotConnectedPeer, Peer, PeerEndpoint, PeerEndpointAddr, PeerInfo, PeerPing, PerDispatchClassU32, PerDispatchClassWeight, PerDispatchClassWeightsPerClass, Phase, RawOrigin, RefCount, RefCountTo259, SyncState, SystemOrigin, TokenError, TransactionValidityError, UnknownTransaction, WeightPerClass } from '@polkadot/types/interfaces/system';
+import type { Bounty, BountyIndex, BountyStatus, BountyStatusActive, BountyStatusCuratorProposed, BountyStatusPendingPayout, OpenTip, OpenTipFinderTo225, OpenTipTip, OpenTipTo225, TreasuryProposal } from '@polkadot/types/interfaces/treasury';
+import type { Multiplier } from '@polkadot/types/interfaces/txpayment';
+import type { ClassDetails, ClassId, ClassMetadata, DepositBalance, DepositBalanceOf, DestroyWitness, InstanceDetails, InstanceId, InstanceMetadata } from '@polkadot/types/interfaces/uniques';
+import type { Multisig, Timepoint } from '@polkadot/types/interfaces/utility';
+import type { VestingInfo } from '@polkadot/types/interfaces/vesting';
+import type { AssetInstance, AssetInstanceV0, AssetInstanceV1, AssetInstanceV2, BodyId, BodyPart, DoubleEncodedCall, Fungibility, FungibilityV0, FungibilityV1, FungibilityV2, InboundStatus, InstructionV2, InteriorMultiLocation, Junction, JunctionV0, JunctionV1, JunctionV2, Junctions, JunctionsV1, JunctionsV2, MultiAsset, MultiAssetFilter, MultiAssetFilterV1, MultiAssetFilterV2, MultiAssetV0, MultiAssetV1, MultiAssetV2, MultiAssets, MultiAssetsV1, MultiAssetsV2, MultiLocation, MultiLocationV0, MultiLocationV1, MultiLocationV2, NetworkId, OriginKindV0, OriginKindV1, OriginKindV2, OutboundStatus, Outcome, QueryId, QueryStatus, QueueConfigData, Response, ResponseV0, ResponseV1, ResponseV2, ResponseV2Error, ResponseV2Result, VersionMigrationStage, VersionedMultiAsset, VersionedMultiAssets, VersionedMultiLocation, VersionedResponse, VersionedXcm, WeightLimitV2, WildFungibility, WildFungibilityV0, WildFungibilityV1, WildFungibilityV2, WildMultiAsset, WildMultiAssetV1, WildMultiAssetV2, Xcm, XcmAssetId, XcmError, XcmErrorV0, XcmErrorV1, XcmErrorV2, XcmOrder, XcmOrderV0, XcmOrderV1, XcmOrderV2, XcmOrigin, XcmOriginKind, XcmV0, XcmV1, XcmV2, XcmVersion, XcmpMessageFormat } from '@polkadot/types/interfaces/xcm';
+
+declare module '@polkadot/types/types/registry' {
+ export interface InterfaceTypes {
+ AbridgedCandidateReceipt: AbridgedCandidateReceipt;
+ AbridgedHostConfiguration: AbridgedHostConfiguration;
+ AbridgedHrmpChannel: AbridgedHrmpChannel;
+ AccountData: AccountData;
+ AccountId: AccountId;
+ AccountId20: AccountId20;
+ AccountId32: AccountId32;
+ AccountIdOf: AccountIdOf;
+ AccountIndex: AccountIndex;
+ AccountInfo: AccountInfo;
+ AccountInfoWithDualRefCount: AccountInfoWithDualRefCount;
+ AccountInfoWithProviders: AccountInfoWithProviders;
+ AccountInfoWithRefCount: AccountInfoWithRefCount;
+ AccountInfoWithRefCountU8: AccountInfoWithRefCountU8;
+ AccountInfoWithTripleRefCount: AccountInfoWithTripleRefCount;
+ AccountStatus: AccountStatus;
+ AccountValidity: AccountValidity;
+ AccountVote: AccountVote;
+ AccountVoteSplit: AccountVoteSplit;
+ AccountVoteStandard: AccountVoteStandard;
+ ActiveEraInfo: ActiveEraInfo;
+ ActiveGilt: ActiveGilt;
+ ActiveGiltsTotal: ActiveGiltsTotal;
+ ActiveIndex: ActiveIndex;
+ ActiveRecovery: ActiveRecovery;
+ Address: Address;
+ AliveContractInfo: AliveContractInfo;
+ AllowedSlots: AllowedSlots;
+ AnySignature: AnySignature;
+ ApiId: ApiId;
+ ApplyExtrinsicResult: ApplyExtrinsicResult;
+ ApprovalFlag: ApprovalFlag;
+ Approvals: Approvals;
+ ArithmeticError: ArithmeticError;
+ AssetApproval: AssetApproval;
+ AssetApprovalKey: AssetApprovalKey;
+ AssetBalance: AssetBalance;
+ AssetDestroyWitness: AssetDestroyWitness;
+ AssetDetails: AssetDetails;
+ AssetId: AssetId;
+ AssetInstance: AssetInstance;
+ AssetInstanceV0: AssetInstanceV0;
+ AssetInstanceV1: AssetInstanceV1;
+ AssetInstanceV2: AssetInstanceV2;
+ AssetMetadata: AssetMetadata;
+ AssetOptions: AssetOptions;
+ AssignmentId: AssignmentId;
+ AssignmentKind: AssignmentKind;
+ AttestedCandidate: AttestedCandidate;
+ AuctionIndex: AuctionIndex;
+ AuthIndex: AuthIndex;
+ AuthorityDiscoveryId: AuthorityDiscoveryId;
+ AuthorityId: AuthorityId;
+ AuthorityIndex: AuthorityIndex;
+ AuthorityList: AuthorityList;
+ AuthoritySet: AuthoritySet;
+ AuthoritySetChange: AuthoritySetChange;
+ AuthoritySetChanges: AuthoritySetChanges;
+ AuthoritySignature: AuthoritySignature;
+ AuthorityWeight: AuthorityWeight;
+ AvailabilityBitfield: AvailabilityBitfield;
+ AvailabilityBitfieldRecord: AvailabilityBitfieldRecord;
+ BabeAuthorityWeight: BabeAuthorityWeight;
+ BabeBlockWeight: BabeBlockWeight;
+ BabeEpochConfiguration: BabeEpochConfiguration;
+ BabeEquivocationProof: BabeEquivocationProof;
+ BabeWeight: BabeWeight;
+ BackedCandidate: BackedCandidate;
+ Balance: Balance;
+ BalanceLock: BalanceLock;
+ BalanceLockTo212: BalanceLockTo212;
+ BalanceOf: BalanceOf;
+ BalanceStatus: BalanceStatus;
+ BeefyCommitment: BeefyCommitment;
+ BeefyId: BeefyId;
+ BeefyKey: BeefyKey;
+ BeefyNextAuthoritySet: BeefyNextAuthoritySet;
+ BeefyPayload: BeefyPayload;
+ BeefySignedCommitment: BeefySignedCommitment;
+ Bid: Bid;
+ Bidder: Bidder;
+ BidKind: BidKind;
+ BitVec: BitVec;
+ Block: Block;
+ BlockAttestations: BlockAttestations;
+ BlockHash: BlockHash;
+ BlockLength: BlockLength;
+ BlockNumber: BlockNumber;
+ BlockNumberFor: BlockNumberFor;
+ BlockNumberOf: BlockNumberOf;
+ BlockTrace: BlockTrace;
+ BlockTraceEvent: BlockTraceEvent;
+ BlockTraceEventData: BlockTraceEventData;
+ BlockTraceSpan: BlockTraceSpan;
+ BlockV0: BlockV0;
+ BlockV1: BlockV1;
+ BlockV2: BlockV2;
+ BlockWeights: BlockWeights;
+ BodyId: BodyId;
+ BodyPart: BodyPart;
+ bool: bool;
+ Bool: Bool;
+ Bounty: Bounty;
+ BountyIndex: BountyIndex;
+ BountyStatus: BountyStatus;
+ BountyStatusActive: BountyStatusActive;
+ BountyStatusCuratorProposed: BountyStatusCuratorProposed;
+ BountyStatusPendingPayout: BountyStatusPendingPayout;
+ BridgedBlockHash: BridgedBlockHash;
+ BridgedBlockNumber: BridgedBlockNumber;
+ BridgedHeader: BridgedHeader;
+ BridgeMessageId: BridgeMessageId;
+ BufferedSessionChange: BufferedSessionChange;
+ Bytes: Bytes;
+ Call: Call;
+ CallHash: CallHash;
+ CallHashOf: CallHashOf;
+ CallIndex: CallIndex;
+ CallOrigin: CallOrigin;
+ CandidateCommitments: CandidateCommitments;
+ CandidateDescriptor: CandidateDescriptor;
+ CandidateHash: CandidateHash;
+ CandidateInfo: CandidateInfo;
+ CandidatePendingAvailability: CandidatePendingAvailability;
+ CandidateReceipt: CandidateReceipt;
+ ChainId: ChainId;
+ ChainProperties: ChainProperties;
+ ChainType: ChainType;
+ ChangesTrieConfiguration: ChangesTrieConfiguration;
+ ChangesTrieSignal: ChangesTrieSignal;
+ ClassDetails: ClassDetails;
+ ClassId: ClassId;
+ ClassMetadata: ClassMetadata;
+ CodecHash: CodecHash;
+ CodeHash: CodeHash;
+ CollatorId: CollatorId;
+ CollatorSignature: CollatorSignature;
+ CollectiveOrigin: CollectiveOrigin;
+ CommittedCandidateReceipt: CommittedCandidateReceipt;
+ CompactAssignments: CompactAssignments;
+ CompactAssignmentsTo257: CompactAssignmentsTo257;
+ CompactAssignmentsTo265: CompactAssignmentsTo265;
+ CompactAssignmentsWith16: CompactAssignmentsWith16;
+ CompactAssignmentsWith24: CompactAssignmentsWith24;
+ CompactScore: CompactScore;
+ CompactScoreCompact: CompactScoreCompact;
+ ConfigData: ConfigData;
+ Consensus: Consensus;
+ ConsensusEngineId: ConsensusEngineId;
+ ConsumedWeight: ConsumedWeight;
+ ContractCallRequest: ContractCallRequest;
+ ContractConstructorSpec: ContractConstructorSpec;
+ ContractContractSpec: ContractContractSpec;
+ ContractCryptoHasher: ContractCryptoHasher;
+ ContractDiscriminant: ContractDiscriminant;
+ ContractDisplayName: ContractDisplayName;
+ ContractEventParamSpec: ContractEventParamSpec;
+ ContractEventSpec: ContractEventSpec;
+ ContractExecResult: ContractExecResult;
+ ContractExecResultErr: ContractExecResultErr;
+ ContractExecResultErrModule: ContractExecResultErrModule;
+ ContractExecResultOk: ContractExecResultOk;
+ ContractExecResultResult: ContractExecResultResult;
+ ContractExecResultSuccessTo255: ContractExecResultSuccessTo255;
+ ContractExecResultSuccessTo260: ContractExecResultSuccessTo260;
+ ContractExecResultTo255: ContractExecResultTo255;
+ ContractExecResultTo260: ContractExecResultTo260;
+ ContractExecResultTo267: ContractExecResultTo267;
+ ContractInfo: ContractInfo;
+ ContractInstantiateResult: ContractInstantiateResult;
+ ContractInstantiateResultTo267: ContractInstantiateResultTo267;
+ ContractLayoutArray: ContractLayoutArray;
+ ContractLayoutCell: ContractLayoutCell;
+ ContractLayoutEnum: ContractLayoutEnum;
+ ContractLayoutHash: ContractLayoutHash;
+ ContractLayoutHashingStrategy: ContractLayoutHashingStrategy;
+ ContractLayoutKey: ContractLayoutKey;
+ ContractLayoutStruct: ContractLayoutStruct;
+ ContractLayoutStructField: ContractLayoutStructField;
+ ContractMessageParamSpec: ContractMessageParamSpec;
+ ContractMessageSpec: ContractMessageSpec;
+ ContractMetadata: ContractMetadata;
+ ContractMetadataLatest: ContractMetadataLatest;
+ ContractMetadataV0: ContractMetadataV0;
+ ContractMetadataV1: ContractMetadataV1;
+ ContractProject: ContractProject;
+ ContractProjectContract: ContractProjectContract;
+ ContractProjectInfo: ContractProjectInfo;
+ ContractProjectSource: ContractProjectSource;
+ ContractProjectV0: ContractProjectV0;
+ ContractSelector: ContractSelector;
+ ContractStorageKey: ContractStorageKey;
+ ContractStorageLayout: ContractStorageLayout;
+ ContractTypeSpec: ContractTypeSpec;
+ Conviction: Conviction;
+ CoreAssignment: CoreAssignment;
+ CoreIndex: CoreIndex;
+ CoreOccupied: CoreOccupied;
+ CrateVersion: CrateVersion;
+ CreatedBlock: CreatedBlock;
+ CumulusPalletDmpQueueConfigData: CumulusPalletDmpQueueConfigData;
+ CumulusPalletDmpQueuePageIndexData: CumulusPalletDmpQueuePageIndexData;
+ CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot: CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot;
+ CumulusPalletXcmpQueueInboundStatus: CumulusPalletXcmpQueueInboundStatus;
+ CumulusPalletXcmpQueueOutboundStatus: CumulusPalletXcmpQueueOutboundStatus;
+ CumulusPalletXcmpQueueQueueConfigData: CumulusPalletXcmpQueueQueueConfigData;
+ CumulusPrimitivesParachainInherentParachainInherentData: CumulusPrimitivesParachainInherentParachainInherentData;
+ Data: Data;
+ DeferredOffenceOf: DeferredOffenceOf;
+ DefunctVoter: DefunctVoter;
+ DelayKind: DelayKind;
+ DelayKindBest: DelayKindBest;
+ Delegations: Delegations;
+ DeletedContract: DeletedContract;
+ DeliveredMessages: DeliveredMessages;
+ DepositBalance: DepositBalance;
+ DepositBalanceOf: DepositBalanceOf;
+ DestroyWitness: DestroyWitness;
+ Digest: Digest;
+ DigestItem: DigestItem;
+ DigestOf: DigestOf;
+ DispatchClass: DispatchClass;
+ DispatchError: DispatchError;
+ DispatchErrorModule: DispatchErrorModule;
+ DispatchErrorTo198: DispatchErrorTo198;
+ DispatchFeePayment: DispatchFeePayment;
+ DispatchInfo: DispatchInfo;
+ DispatchInfoTo190: DispatchInfoTo190;
+ DispatchInfoTo244: DispatchInfoTo244;
+ DispatchOutcome: DispatchOutcome;
+ DispatchResult: DispatchResult;
+ DispatchResultOf: DispatchResultOf;
+ DispatchResultTo198: DispatchResultTo198;
+ DisputeLocation: DisputeLocation;
+ DisputeResult: DisputeResult;
+ DisputeState: DisputeState;
+ DisputeStatement: DisputeStatement;
+ DisputeStatementSet: DisputeStatementSet;
+ DoubleEncodedCall: DoubleEncodedCall;
+ DoubleVoteReport: DoubleVoteReport;
+ DownwardMessage: DownwardMessage;
+ EcdsaSignature: EcdsaSignature;
+ Ed25519Signature: Ed25519Signature;
+ EIP1559Transaction: EIP1559Transaction;
+ EIP2930Transaction: EIP2930Transaction;
+ ElectionCompute: ElectionCompute;
+ ElectionPhase: ElectionPhase;
+ ElectionResult: ElectionResult;
+ ElectionScore: ElectionScore;
+ ElectionSize: ElectionSize;
+ ElectionStatus: ElectionStatus;
+ EncodedFinalityProofs: EncodedFinalityProofs;
+ EncodedJustification: EncodedJustification;
+ EpochAuthorship: EpochAuthorship;
+ Era: Era;
+ EraIndex: EraIndex;
+ EraPoints: EraPoints;
+ EraRewardPoints: EraRewardPoints;
+ EraRewards: EraRewards;
+ ErrorMetadataLatest: ErrorMetadataLatest;
+ ErrorMetadataV10: ErrorMetadataV10;
+ ErrorMetadataV11: ErrorMetadataV11;
+ ErrorMetadataV12: ErrorMetadataV12;
+ ErrorMetadataV13: ErrorMetadataV13;
+ ErrorMetadataV14: ErrorMetadataV14;
+ ErrorMetadataV9: ErrorMetadataV9;
+ EthAccessList: EthAccessList;
+ EthAccessListItem: EthAccessListItem;
+ EthAccount: EthAccount;
+ EthAddress: EthAddress;
+ EthBlock: EthBlock;
+ EthBloom: EthBloom;
+ EthCallRequest: EthCallRequest;
+ EthereumAccountId: EthereumAccountId;
+ EthereumAddress: EthereumAddress;
+ EthereumBlock: EthereumBlock;
+ EthereumLog: EthereumLog;
+ EthereumLookupSource: EthereumLookupSource;
+ EthereumReceipt: EthereumReceipt;
+ EthereumSignature: EthereumSignature;
+ EthereumTransactionLegacyTransaction: EthereumTransactionLegacyTransaction;
+ EthFilter: EthFilter;
+ EthFilterAddress: EthFilterAddress;
+ EthFilterChanges: EthFilterChanges;
+ EthFilterTopic: EthFilterTopic;
+ EthFilterTopicEntry: EthFilterTopicEntry;
+ EthFilterTopicInner: EthFilterTopicInner;
+ EthHeader: EthHeader;
+ EthLog: EthLog;
+ EthReceipt: EthReceipt;
+ EthRichBlock: EthRichBlock;
+ EthRichHeader: EthRichHeader;
+ EthStorageProof: EthStorageProof;
+ EthSubKind: EthSubKind;
+ EthSubParams: EthSubParams;
+ EthSubResult: EthSubResult;
+ EthSyncInfo: EthSyncInfo;
+ EthSyncStatus: EthSyncStatus;
+ EthTransaction: EthTransaction;
+ EthTransactionAction: EthTransactionAction;
+ EthTransactionCondition: EthTransactionCondition;
+ EthTransactionRequest: EthTransactionRequest;
+ EthTransactionSignature: EthTransactionSignature;
+ EthTransactionStatus: EthTransactionStatus;
+ EthWork: EthWork;
+ Event: Event;
+ EventId: EventId;
+ EventIndex: EventIndex;
+ EventMetadataLatest: EventMetadataLatest;
+ EventMetadataV10: EventMetadataV10;
+ EventMetadataV11: EventMetadataV11;
+ EventMetadataV12: EventMetadataV12;
+ EventMetadataV13: EventMetadataV13;
+ EventMetadataV14: EventMetadataV14;
+ EventMetadataV9: EventMetadataV9;
+ EventRecord: EventRecord;
+ EvmAccount: EvmAccount;
+ EvmCoreErrorExitReason: EvmCoreErrorExitReason;
+ EvmLog: EvmLog;
+ EvmVicinity: EvmVicinity;
+ ExecReturnValue: ExecReturnValue;
+ ExitError: ExitError;
+ ExitFatal: ExitFatal;
+ ExitReason: ExitReason;
+ ExitRevert: ExitRevert;
+ ExitSucceed: ExitSucceed;
+ ExplicitDisputeStatement: ExplicitDisputeStatement;
+ Exposure: Exposure;
+ ExtendedBalance: ExtendedBalance;
+ Extrinsic: Extrinsic;
+ ExtrinsicEra: ExtrinsicEra;
+ ExtrinsicMetadataLatest: ExtrinsicMetadataLatest;
+ ExtrinsicMetadataV11: ExtrinsicMetadataV11;
+ ExtrinsicMetadataV12: ExtrinsicMetadataV12;
+ ExtrinsicMetadataV13: ExtrinsicMetadataV13;
+ ExtrinsicMetadataV14: ExtrinsicMetadataV14;
+ ExtrinsicOrHash: ExtrinsicOrHash;
+ ExtrinsicPayload: ExtrinsicPayload;
+ ExtrinsicPayloadUnknown: ExtrinsicPayloadUnknown;
+ ExtrinsicPayloadV4: ExtrinsicPayloadV4;
+ ExtrinsicSignature: ExtrinsicSignature;
+ ExtrinsicSignatureV4: ExtrinsicSignatureV4;
+ ExtrinsicStatus: ExtrinsicStatus;
+ ExtrinsicsWeight: ExtrinsicsWeight;
+ ExtrinsicUnknown: ExtrinsicUnknown;
+ ExtrinsicV4: ExtrinsicV4;
+ FeeDetails: FeeDetails;
+ Fixed128: Fixed128;
+ Fixed64: Fixed64;
+ FixedI128: FixedI128;
+ FixedI64: FixedI64;
+ FixedU128: FixedU128;
+ FixedU64: FixedU64;
+ Forcing: Forcing;
+ ForkTreePendingChange: ForkTreePendingChange;
+ ForkTreePendingChangeNode: ForkTreePendingChangeNode;
+ FpRpcTransactionStatus: FpRpcTransactionStatus;
+ FullIdentification: FullIdentification;
+ FunctionArgumentMetadataLatest: FunctionArgumentMetadataLatest;
+ FunctionArgumentMetadataV10: FunctionArgumentMetadataV10;
+ FunctionArgumentMetadataV11: FunctionArgumentMetadataV11;
+ FunctionArgumentMetadataV12: FunctionArgumentMetadataV12;
+ FunctionArgumentMetadataV13: FunctionArgumentMetadataV13;
+ FunctionArgumentMetadataV14: FunctionArgumentMetadataV14;
+ FunctionArgumentMetadataV9: FunctionArgumentMetadataV9;
+ FunctionMetadataLatest: FunctionMetadataLatest;
+ FunctionMetadataV10: FunctionMetadataV10;
+ FunctionMetadataV11: FunctionMetadataV11;
+ FunctionMetadataV12: FunctionMetadataV12;
+ FunctionMetadataV13: FunctionMetadataV13;
+ FunctionMetadataV14: FunctionMetadataV14;
+ FunctionMetadataV9: FunctionMetadataV9;
+ FundIndex: FundIndex;
+ FundInfo: FundInfo;
+ Fungibility: Fungibility;
+ FungibilityV0: FungibilityV0;
+ FungibilityV1: FungibilityV1;
+ FungibilityV2: FungibilityV2;
+ Gas: Gas;
+ GiltBid: GiltBid;
+ GlobalValidationData: GlobalValidationData;
+ GlobalValidationSchedule: GlobalValidationSchedule;
+ GrandpaCommit: GrandpaCommit;
+ GrandpaEquivocation: GrandpaEquivocation;
+ GrandpaEquivocationProof: GrandpaEquivocationProof;
+ GrandpaEquivocationValue: GrandpaEquivocationValue;
+ GrandpaJustification: GrandpaJustification;
+ GrandpaPrecommit: GrandpaPrecommit;
+ GrandpaPrevote: GrandpaPrevote;
+ GrandpaSignedPrecommit: GrandpaSignedPrecommit;
+ GroupIndex: GroupIndex;
+ H1024: H1024;
+ H128: H128;
+ H160: H160;
+ H2048: H2048;
+ H256: H256;
+ H32: H32;
+ H512: H512;
+ H64: H64;
+ Hash: Hash;
+ HeadData: HeadData;
+ Header: Header;
+ HeaderPartial: HeaderPartial;
+ Health: Health;
+ Heartbeat: Heartbeat;
+ HeartbeatTo244: HeartbeatTo244;
+ HostConfiguration: HostConfiguration;
+ HostFnWeights: HostFnWeights;
+ HostFnWeightsTo264: HostFnWeightsTo264;
+ HrmpChannel: HrmpChannel;
+ HrmpChannelId: HrmpChannelId;
+ HrmpOpenChannelRequest: HrmpOpenChannelRequest;
+ i128: i128;
+ I128: I128;
+ i16: i16;
+ I16: I16;
+ i256: i256;
+ I256: I256;
+ i32: i32;
+ I32: I32;
+ I32F32: I32F32;
+ i64: i64;
+ I64: I64;
+ i8: i8;
+ I8: I8;
+ IdentificationTuple: IdentificationTuple;
+ IdentityFields: IdentityFields;
+ IdentityInfo: IdentityInfo;
+ IdentityInfoAdditional: IdentityInfoAdditional;
+ IdentityInfoTo198: IdentityInfoTo198;
+ IdentityJudgement: IdentityJudgement;
+ ImmortalEra: ImmortalEra;
+ ImportedAux: ImportedAux;
+ InboundDownwardMessage: InboundDownwardMessage;
+ InboundHrmpMessage: InboundHrmpMessage;
+ InboundHrmpMessages: InboundHrmpMessages;
+ InboundLaneData: InboundLaneData;
+ InboundRelayer: InboundRelayer;
+ InboundStatus: InboundStatus;
+ IncludedBlocks: IncludedBlocks;
+ InclusionFee: InclusionFee;
+ IncomingParachain: IncomingParachain;
+ IncomingParachainDeploy: IncomingParachainDeploy;
+ IncomingParachainFixed: IncomingParachainFixed;
+ Index: Index;
+ IndicesLookupSource: IndicesLookupSource;
+ IndividualExposure: IndividualExposure;
+ InitializationData: InitializationData;
+ InstanceDetails: InstanceDetails;
+ InstanceId: InstanceId;
+ InstanceMetadata: InstanceMetadata;
+ InstantiateRequest: InstantiateRequest;
+ InstantiateReturnValue: InstantiateReturnValue;
+ InstantiateReturnValueTo267: InstantiateReturnValueTo267;
+ InstructionV2: InstructionV2;
+ InstructionWeights: InstructionWeights;
+ InteriorMultiLocation: InteriorMultiLocation;
+ InvalidDisputeStatementKind: InvalidDisputeStatementKind;
+ InvalidTransaction: InvalidTransaction;
+ Json: Json;
+ Junction: Junction;
+ Junctions: Junctions;
+ JunctionsV1: JunctionsV1;
+ JunctionsV2: JunctionsV2;
+ JunctionV0: JunctionV0;
+ JunctionV1: JunctionV1;
+ JunctionV2: JunctionV2;
+ Justification: Justification;
+ JustificationNotification: JustificationNotification;
+ Justifications: Justifications;
+ Key: Key;
+ KeyOwnerProof: KeyOwnerProof;
+ Keys: Keys;
+ KeyType: KeyType;
+ KeyTypeId: KeyTypeId;
+ KeyValue: KeyValue;
+ KeyValueOption: KeyValueOption;
+ Kind: Kind;
+ LaneId: LaneId;
+ LastContribution: LastContribution;
+ LastRuntimeUpgradeInfo: LastRuntimeUpgradeInfo;
+ LeasePeriod: LeasePeriod;
+ LeasePeriodOf: LeasePeriodOf;
+ LegacyTransaction: LegacyTransaction;
+ Limits: Limits;
+ LimitsTo264: LimitsTo264;
+ LocalValidationData: LocalValidationData;
+ LockIdentifier: LockIdentifier;
+ LookupSource: LookupSource;
+ LookupTarget: LookupTarget;
+ LotteryConfig: LotteryConfig;
+ MaybeRandomness: MaybeRandomness;
+ MaybeVrf: MaybeVrf;
+ MemberCount: MemberCount;
+ MembershipProof: MembershipProof;
+ MessageData: MessageData;
+ MessageId: MessageId;
+ MessageIngestionType: MessageIngestionType;
+ MessageKey: MessageKey;
+ MessageNonce: MessageNonce;
+ MessageQueueChain: MessageQueueChain;
+ MessagesDeliveryProofOf: MessagesDeliveryProofOf;
+ MessagesProofOf: MessagesProofOf;
+ MessagingStateSnapshot: MessagingStateSnapshot;
+ MessagingStateSnapshotEgressEntry: MessagingStateSnapshotEgressEntry;
+ MetadataAll: MetadataAll;
+ MetadataLatest: MetadataLatest;
+ MetadataV10: MetadataV10;
+ MetadataV11: MetadataV11;
+ MetadataV12: MetadataV12;
+ MetadataV13: MetadataV13;
+ MetadataV14: MetadataV14;
+ MetadataV9: MetadataV9;
+ MmrLeafProof: MmrLeafProof;
+ MmrRootHash: MmrRootHash;
+ ModuleConstantMetadataV10: ModuleConstantMetadataV10;
+ ModuleConstantMetadataV11: ModuleConstantMetadataV11;
+ ModuleConstantMetadataV12: ModuleConstantMetadataV12;
+ ModuleConstantMetadataV13: ModuleConstantMetadataV13;
+ ModuleConstantMetadataV9: ModuleConstantMetadataV9;
+ ModuleId: ModuleId;
+ ModuleMetadataV10: ModuleMetadataV10;
+ ModuleMetadataV11: ModuleMetadataV11;
+ ModuleMetadataV12: ModuleMetadataV12;
+ ModuleMetadataV13: ModuleMetadataV13;
+ ModuleMetadataV9: ModuleMetadataV9;
+ Moment: Moment;
+ MomentOf: MomentOf;
+ MoreAttestations: MoreAttestations;
+ MortalEra: MortalEra;
+ MultiAddress: MultiAddress;
+ MultiAsset: MultiAsset;
+ MultiAssetFilter: MultiAssetFilter;
+ MultiAssetFilterV1: MultiAssetFilterV1;
+ MultiAssetFilterV2: MultiAssetFilterV2;
+ MultiAssets: MultiAssets;
+ MultiAssetsV1: MultiAssetsV1;
+ MultiAssetsV2: MultiAssetsV2;
+ MultiAssetV0: MultiAssetV0;
+ MultiAssetV1: MultiAssetV1;
+ MultiAssetV2: MultiAssetV2;
+ MultiDisputeStatementSet: MultiDisputeStatementSet;
+ MultiLocation: MultiLocation;
+ MultiLocationV0: MultiLocationV0;
+ MultiLocationV1: MultiLocationV1;
+ MultiLocationV2: MultiLocationV2;
+ Multiplier: Multiplier;
+ Multisig: Multisig;
+ MultiSignature: MultiSignature;
+ MultiSigner: MultiSigner;
+ NetworkId: NetworkId;
+ NetworkState: NetworkState;
+ NetworkStatePeerset: NetworkStatePeerset;
+ NetworkStatePeersetInfo: NetworkStatePeersetInfo;
+ NewBidder: NewBidder;
+ NextAuthority: NextAuthority;
+ NextConfigDescriptor: NextConfigDescriptor;
+ NextConfigDescriptorV1: NextConfigDescriptorV1;
+ NftDataStructsAccessMode: NftDataStructsAccessMode;
+ NftDataStructsCollection: NftDataStructsCollection;
+ NftDataStructsCollectionId: NftDataStructsCollectionId;
+ NftDataStructsCollectionLimits: NftDataStructsCollectionLimits;
+ NftDataStructsCollectionMode: NftDataStructsCollectionMode;
+ NftDataStructsCreateItemData: NftDataStructsCreateItemData;
+ NftDataStructsMetaUpdatePermission: NftDataStructsMetaUpdatePermission;
+ NftDataStructsSchemaVersion: NftDataStructsSchemaVersion;
+ NftDataStructsSponsorshipState: NftDataStructsSponsorshipState;
+ NftDataStructsTokenId: NftDataStructsTokenId;
+ NodeRole: NodeRole;
+ Nominations: Nominations;
+ NominatorIndex: NominatorIndex;
+ NominatorIndexCompact: NominatorIndexCompact;
+ NotConnectedPeer: NotConnectedPeer;
+ Null: Null;
+ OffchainAccuracy: OffchainAccuracy;
+ OffchainAccuracyCompact: OffchainAccuracyCompact;
+ OffenceDetails: OffenceDetails;
+ Offender: Offender;
+ OpaqueCall: OpaqueCall;
+ OpaqueMultiaddr: OpaqueMultiaddr;
+ OpaqueNetworkState: OpaqueNetworkState;
+ OpaquePeerId: OpaquePeerId;
+ OpaqueTimeSlot: OpaqueTimeSlot;
+ OpenTip: OpenTip;
+ OpenTipFinderTo225: OpenTipFinderTo225;
+ OpenTipTip: OpenTipTip;
+ OpenTipTo225: OpenTipTo225;
+ OperatingMode: OperatingMode;
+ Origin: Origin;
+ OriginCaller: OriginCaller;
+ OriginKindV0: OriginKindV0;
+ OriginKindV1: OriginKindV1;
+ OriginKindV2: OriginKindV2;
+ OutboundHrmpMessage: OutboundHrmpMessage;
+ OutboundLaneData: OutboundLaneData;
+ OutboundMessageFee: OutboundMessageFee;
+ OutboundPayload: OutboundPayload;
+ OutboundStatus: OutboundStatus;
+ Outcome: Outcome;
+ OverweightIndex: OverweightIndex;
+ Owner: Owner;
+ PageCounter: PageCounter;
+ PageIndexData: PageIndexData;
+ PalletCallMetadataLatest: PalletCallMetadataLatest;
+ PalletCallMetadataV14: PalletCallMetadataV14;
+ PalletCommonAccountBasicCrossAccountIdRepr: PalletCommonAccountBasicCrossAccountIdRepr;
+ PalletConstantMetadataLatest: PalletConstantMetadataLatest;
+ PalletConstantMetadataV14: PalletConstantMetadataV14;
+ PalletErrorMetadataLatest: PalletErrorMetadataLatest;
+ PalletErrorMetadataV14: PalletErrorMetadataV14;
+ PalletEventMetadataLatest: PalletEventMetadataLatest;
+ PalletEventMetadataV14: PalletEventMetadataV14;
+ PalletId: PalletId;
+ PalletMetadataLatest: PalletMetadataLatest;
+ PalletMetadataV14: PalletMetadataV14;
+ PalletNonfungibleItemData: PalletNonfungibleItemData;
+ PalletRefungibleItemData: PalletRefungibleItemData;
+ PalletsOrigin: PalletsOrigin;
+ PalletStorageMetadataLatest: PalletStorageMetadataLatest;
+ PalletStorageMetadataV14: PalletStorageMetadataV14;
+ PalletUnqSchedulerCallSpec: PalletUnqSchedulerCallSpec;
+ PalletUnqSchedulerReleases: PalletUnqSchedulerReleases;
+ PalletUnqSchedulerScheduledV2: PalletUnqSchedulerScheduledV2;
+ PalletVersion: PalletVersion;
+ ParachainDispatchOrigin: ParachainDispatchOrigin;
+ ParachainInherentData: ParachainInherentData;
+ ParachainProposal: ParachainProposal;
+ ParachainsInherentData: ParachainsInherentData;
+ ParaGenesisArgs: ParaGenesisArgs;
+ ParaId: ParaId;
+ ParaInfo: ParaInfo;
+ ParaLifecycle: ParaLifecycle;
+ Parameter: Parameter;
+ ParaPastCodeMeta: ParaPastCodeMeta;
+ ParaScheduling: ParaScheduling;
+ ParathreadClaim: ParathreadClaim;
+ ParathreadClaimQueue: ParathreadClaimQueue;
+ ParathreadEntry: ParathreadEntry;
+ ParaValidatorIndex: ParaValidatorIndex;
+ Pays: Pays;
+ Peer: Peer;
+ PeerEndpoint: PeerEndpoint;
+ PeerEndpointAddr: PeerEndpointAddr;
+ PeerInfo: PeerInfo;
+ PeerPing: PeerPing;
+ PendingChange: PendingChange;
+ PendingPause: PendingPause;
+ PendingResume: PendingResume;
+ Perbill: Perbill;
+ Percent: Percent;
+ PerDispatchClassU32: PerDispatchClassU32;
+ PerDispatchClassWeight: PerDispatchClassWeight;
+ PerDispatchClassWeightsPerClass: PerDispatchClassWeightsPerClass;
+ Period: Period;
+ Permill: Permill;
+ PermissionLatest: PermissionLatest;
+ PermissionsV1: PermissionsV1;
+ PermissionVersions: PermissionVersions;
+ Perquintill: Perquintill;
+ PersistedValidationData: PersistedValidationData;
+ PerU16: PerU16;
+ Phantom: Phantom;
+ PhantomData: PhantomData;
+ Phase: Phase;
+ PhragmenScore: PhragmenScore;
+ Points: Points;
+ PolkadotParachainPrimitivesXcmpMessageFormat: PolkadotParachainPrimitivesXcmpMessageFormat;
+ PolkadotPrimitivesV1AbridgedHostConfiguration: PolkadotPrimitivesV1AbridgedHostConfiguration;
+ PolkadotPrimitivesV1PersistedValidationData: PolkadotPrimitivesV1PersistedValidationData;
+ PortableRegistry: PortableRegistry;
+ PortableRegistryV14: PortableRegistryV14;
+ PortableType: PortableType;
+ PortableTypeV14: PortableTypeV14;
+ Precommits: Precommits;
+ PrefabWasmModule: PrefabWasmModule;
+ PrefixedStorageKey: PrefixedStorageKey;
+ PreimageStatus: PreimageStatus;
+ PreimageStatusAvailable: PreimageStatusAvailable;
+ PreRuntime: PreRuntime;
+ Prevotes: Prevotes;
+ Priority: Priority;
+ PriorLock: PriorLock;
+ PropIndex: PropIndex;
+ Proposal: Proposal;
+ ProposalIndex: ProposalIndex;
+ ProxyAnnouncement: ProxyAnnouncement;
+ ProxyDefinition: ProxyDefinition;
+ ProxyState: ProxyState;
+ ProxyType: ProxyType;
+ QueryId: QueryId;
+ QueryStatus: QueryStatus;
+ QueueConfigData: QueueConfigData;
+ QueuedParathread: QueuedParathread;
+ Randomness: Randomness;
+ Raw: Raw;
+ RawAuraPreDigest: RawAuraPreDigest;
+ RawBabePreDigest: RawBabePreDigest;
+ RawBabePreDigestCompat: RawBabePreDigestCompat;
+ RawBabePreDigestPrimary: RawBabePreDigestPrimary;
+ RawBabePreDigestPrimaryTo159: RawBabePreDigestPrimaryTo159;
+ RawBabePreDigestSecondaryPlain: RawBabePreDigestSecondaryPlain;
+ RawBabePreDigestSecondaryTo159: RawBabePreDigestSecondaryTo159;
+ RawBabePreDigestSecondaryVRF: RawBabePreDigestSecondaryVRF;
+ RawBabePreDigestTo159: RawBabePreDigestTo159;
+ RawOrigin: RawOrigin;
+ RawSolution: RawSolution;
+ RawSolutionTo265: RawSolutionTo265;
+ RawSolutionWith16: RawSolutionWith16;
+ RawSolutionWith24: RawSolutionWith24;
+ RawVRFOutput: RawVRFOutput;
+ ReadProof: ReadProof;
+ ReadySolution: ReadySolution;
+ Reasons: Reasons;
+ RecoveryConfig: RecoveryConfig;
+ RefCount: RefCount;
+ RefCountTo259: RefCountTo259;
+ ReferendumIndex: ReferendumIndex;
+ ReferendumInfo: ReferendumInfo;
+ ReferendumInfoFinished: ReferendumInfoFinished;
+ ReferendumInfoTo239: ReferendumInfoTo239;
+ ReferendumStatus: ReferendumStatus;
+ RegisteredParachainInfo: RegisteredParachainInfo;
+ RegistrarIndex: RegistrarIndex;
+ RegistrarInfo: RegistrarInfo;
+ Registration: Registration;
+ RegistrationJudgement: RegistrationJudgement;
+ RegistrationTo198: RegistrationTo198;
+ RelayBlockNumber: RelayBlockNumber;
+ RelayChainBlockNumber: RelayChainBlockNumber;
+ RelayChainHash: RelayChainHash;
+ RelayerId: RelayerId;
+ RelayHash: RelayHash;
+ Releases: Releases;
+ Remark: Remark;
+ Renouncing: Renouncing;
+ RentProjection: RentProjection;
+ ReplacementTimes: ReplacementTimes;
+ ReportedRoundStates: ReportedRoundStates;
+ Reporter: Reporter;
+ ReportIdOf: ReportIdOf;
+ ReserveData: ReserveData;
+ ReserveIdentifier: ReserveIdentifier;
+ Response: Response;
+ ResponseV0: ResponseV0;
+ ResponseV1: ResponseV1;
+ ResponseV2: ResponseV2;
+ ResponseV2Error: ResponseV2Error;
+ ResponseV2Result: ResponseV2Result;
+ Retriable: Retriable;
+ RewardDestination: RewardDestination;
+ RewardPoint: RewardPoint;
+ RoundSnapshot: RoundSnapshot;
+ RoundState: RoundState;
+ RpcMethods: RpcMethods;
+ RuntimeDbWeight: RuntimeDbWeight;
+ RuntimeDispatchInfo: RuntimeDispatchInfo;
+ RuntimeVersion: RuntimeVersion;
+ RuntimeVersionApi: RuntimeVersionApi;
+ RuntimeVersionPartial: RuntimeVersionPartial;
+ Schedule: Schedule;
+ Scheduled: Scheduled;
+ ScheduledTo254: ScheduledTo254;
+ SchedulePeriod: SchedulePeriod;
+ SchedulePriority: SchedulePriority;
+ ScheduleTo212: ScheduleTo212;
+ ScheduleTo258: ScheduleTo258;
+ ScheduleTo264: ScheduleTo264;
+ Scheduling: Scheduling;
+ Seal: Seal;
+ SealV0: SealV0;
+ SeatHolder: SeatHolder;
+ SeedOf: SeedOf;
+ ServiceQuality: ServiceQuality;
+ SessionIndex: SessionIndex;
+ SessionInfo: SessionInfo;
+ SessionInfoValidatorGroup: SessionInfoValidatorGroup;
+ SessionKeys1: SessionKeys1;
+ SessionKeys10: SessionKeys10;
+ SessionKeys10B: SessionKeys10B;
+ SessionKeys2: SessionKeys2;
+ SessionKeys3: SessionKeys3;
+ SessionKeys4: SessionKeys4;
+ SessionKeys5: SessionKeys5;
+ SessionKeys6: SessionKeys6;
+ SessionKeys6B: SessionKeys6B;
+ SessionKeys7: SessionKeys7;
+ SessionKeys7B: SessionKeys7B;
+ SessionKeys8: SessionKeys8;
+ SessionKeys8B: SessionKeys8B;
+ SessionKeys9: SessionKeys9;
+ SessionKeys9B: SessionKeys9B;
+ SetId: SetId;
+ SetIndex: SetIndex;
+ Si0Field: Si0Field;
+ Si0LookupTypeId: Si0LookupTypeId;
+ Si0Path: Si0Path;
+ Si0Type: Si0Type;
+ Si0TypeDef: Si0TypeDef;
+ Si0TypeDefArray: Si0TypeDefArray;
+ Si0TypeDefBitSequence: Si0TypeDefBitSequence;
+ Si0TypeDefCompact: Si0TypeDefCompact;
+ Si0TypeDefComposite: Si0TypeDefComposite;
+ Si0TypeDefPhantom: Si0TypeDefPhantom;
+ Si0TypeDefPrimitive: Si0TypeDefPrimitive;
+ Si0TypeDefSequence: Si0TypeDefSequence;
+ Si0TypeDefTuple: Si0TypeDefTuple;
+ Si0TypeDefVariant: Si0TypeDefVariant;
+ Si0TypeParameter: Si0TypeParameter;
+ Si0Variant: Si0Variant;
+ Si1Field: Si1Field;
+ Si1LookupTypeId: Si1LookupTypeId;
+ Si1Path: Si1Path;
+ Si1Type: Si1Type;
+ Si1TypeDef: Si1TypeDef;
+ Si1TypeDefArray: Si1TypeDefArray;
+ Si1TypeDefBitSequence: Si1TypeDefBitSequence;
+ Si1TypeDefCompact: Si1TypeDefCompact;
+ Si1TypeDefComposite: Si1TypeDefComposite;
+ Si1TypeDefPrimitive: Si1TypeDefPrimitive;
+ Si1TypeDefSequence: Si1TypeDefSequence;
+ Si1TypeDefTuple: Si1TypeDefTuple;
+ Si1TypeDefVariant: Si1TypeDefVariant;
+ Si1TypeParameter: Si1TypeParameter;
+ Si1Variant: Si1Variant;
+ SiField: SiField;
+ Signature: Signature;
+ SignedAvailabilityBitfield: SignedAvailabilityBitfield;
+ SignedAvailabilityBitfields: SignedAvailabilityBitfields;
+ SignedBlock: SignedBlock;
+ SignedBlockWithJustification: SignedBlockWithJustification;
+ SignedBlockWithJustifications: SignedBlockWithJustifications;
+ SignedExtensionMetadataLatest: SignedExtensionMetadataLatest;
+ SignedExtensionMetadataV14: SignedExtensionMetadataV14;
+ SignedSubmission: SignedSubmission;
+ SignedSubmissionOf: SignedSubmissionOf;
+ SignedSubmissionTo276: SignedSubmissionTo276;
+ SignerPayload: SignerPayload;
+ SigningContext: SigningContext;
+ SiLookupTypeId: SiLookupTypeId;
+ SiPath: SiPath;
+ SiType: SiType;
+ SiTypeDef: SiTypeDef;
+ SiTypeDefArray: SiTypeDefArray;
+ SiTypeDefBitSequence: SiTypeDefBitSequence;
+ SiTypeDefCompact: SiTypeDefCompact;
+ SiTypeDefComposite: SiTypeDefComposite;
+ SiTypeDefPrimitive: SiTypeDefPrimitive;
+ SiTypeDefSequence: SiTypeDefSequence;
+ SiTypeDefTuple: SiTypeDefTuple;
+ SiTypeDefVariant: SiTypeDefVariant;
+ SiTypeParameter: SiTypeParameter;
+ SiVariant: SiVariant;
+ SlashingSpans: SlashingSpans;
+ SlashingSpansTo204: SlashingSpansTo204;
+ SlashJournalEntry: SlashJournalEntry;
+ Slot: Slot;
+ SlotNumber: SlotNumber;
+ SlotRange: SlotRange;
+ SocietyJudgement: SocietyJudgement;
+ SocietyVote: SocietyVote;
+ SolutionOrSnapshotSize: SolutionOrSnapshotSize;
+ SolutionSupport: SolutionSupport;
+ SolutionSupports: SolutionSupports;
+ SpanIndex: SpanIndex;
+ SpanRecord: SpanRecord;
+ SpecVersion: SpecVersion;
+ Sr25519Signature: Sr25519Signature;
+ StakingLedger: StakingLedger;
+ StakingLedgerTo223: StakingLedgerTo223;
+ StakingLedgerTo240: StakingLedgerTo240;
+ Statement: Statement;
+ StatementKind: StatementKind;
+ StorageChangeSet: StorageChangeSet;
+ StorageData: StorageData;
+ StorageEntryMetadataLatest: StorageEntryMetadataLatest;
+ StorageEntryMetadataV10: StorageEntryMetadataV10;
+ StorageEntryMetadataV11: StorageEntryMetadataV11;
+ StorageEntryMetadataV12: StorageEntryMetadataV12;
+ StorageEntryMetadataV13: StorageEntryMetadataV13;
+ StorageEntryMetadataV14: StorageEntryMetadataV14;
+ StorageEntryMetadataV9: StorageEntryMetadataV9;
+ StorageEntryModifierLatest: StorageEntryModifierLatest;
+ StorageEntryModifierV10: StorageEntryModifierV10;
+ StorageEntryModifierV11: StorageEntryModifierV11;
+ StorageEntryModifierV12: StorageEntryModifierV12;
+ StorageEntryModifierV13: StorageEntryModifierV13;
+ StorageEntryModifierV14: StorageEntryModifierV14;
+ StorageEntryModifierV9: StorageEntryModifierV9;
+ StorageEntryTypeLatest: StorageEntryTypeLatest;
+ StorageEntryTypeV10: StorageEntryTypeV10;
+ StorageEntryTypeV11: StorageEntryTypeV11;
+ StorageEntryTypeV12: StorageEntryTypeV12;
+ StorageEntryTypeV13: StorageEntryTypeV13;
+ StorageEntryTypeV14: StorageEntryTypeV14;
+ StorageEntryTypeV9: StorageEntryTypeV9;
+ StorageHasher: StorageHasher;
+ StorageHasherV10: StorageHasherV10;
+ StorageHasherV11: StorageHasherV11;
+ StorageHasherV12: StorageHasherV12;
+ StorageHasherV13: StorageHasherV13;
+ StorageHasherV14: StorageHasherV14;
+ StorageHasherV9: StorageHasherV9;
+ StorageKey: StorageKey;
+ StorageKind: StorageKind;
+ StorageMetadataV10: StorageMetadataV10;
+ StorageMetadataV11: StorageMetadataV11;
+ StorageMetadataV12: StorageMetadataV12;
+ StorageMetadataV13: StorageMetadataV13;
+ StorageMetadataV9: StorageMetadataV9;
+ StorageProof: StorageProof;
+ StoredPendingChange: StoredPendingChange;
+ StoredState: StoredState;
+ StrikeCount: StrikeCount;
+ SubId: SubId;
+ SubmissionIndicesOf: SubmissionIndicesOf;
+ Supports: Supports;
+ SyncState: SyncState;
+ SystemInherentData: SystemInherentData;
+ SystemOrigin: SystemOrigin;
+ Tally: Tally;
+ TaskAddress: TaskAddress;
+ TAssetBalance: TAssetBalance;
+ TAssetDepositBalance: TAssetDepositBalance;
+ Text: Text;
+ Timepoint: Timepoint;
+ TokenError: TokenError;
+ TombstoneContractInfo: TombstoneContractInfo;
+ TraceBlockResponse: TraceBlockResponse;
+ TraceError: TraceError;
+ TransactionInfo: TransactionInfo;
+ TransactionPriority: TransactionPriority;
+ TransactionStorageProof: TransactionStorageProof;
+ TransactionV0: TransactionV0;
+ TransactionV1: TransactionV1;
+ TransactionV2: TransactionV2;
+ TransactionValidityError: TransactionValidityError;
+ TransientValidationData: TransientValidationData;
+ TreasuryProposal: TreasuryProposal;
+ TrieId: TrieId;
+ TrieIndex: TrieIndex;
+ Type: Type;
+ u128: u128;
+ U128: U128;
+ u16: u16;
+ U16: U16;
+ u256: u256;
+ U256: U256;
+ u32: u32;
+ U32: U32;
+ U32F32: U32F32;
+ u64: u64;
+ U64: U64;
+ u8: u8;
+ U8: U8;
+ UnappliedSlash: UnappliedSlash;
+ UnappliedSlashOther: UnappliedSlashOther;
+ UncleEntryItem: UncleEntryItem;
+ UnknownTransaction: UnknownTransaction;
+ UnlockChunk: UnlockChunk;
+ UnrewardedRelayer: UnrewardedRelayer;
+ UnrewardedRelayersState: UnrewardedRelayersState;
+ UpgradeGoAhead: UpgradeGoAhead;
+ UpgradeRestriction: UpgradeRestriction;
+ UpwardMessage: UpwardMessage;
+ usize: usize;
+ USize: USize;
+ ValidationCode: ValidationCode;
+ ValidationCodeHash: ValidationCodeHash;
+ ValidationData: ValidationData;
+ ValidationDataType: ValidationDataType;
+ ValidationFunctionParams: ValidationFunctionParams;
+ ValidatorCount: ValidatorCount;
+ ValidatorId: ValidatorId;
+ ValidatorIdOf: ValidatorIdOf;
+ ValidatorIndex: ValidatorIndex;
+ ValidatorIndexCompact: ValidatorIndexCompact;
+ ValidatorPrefs: ValidatorPrefs;
+ ValidatorPrefsTo145: ValidatorPrefsTo145;
+ ValidatorPrefsTo196: ValidatorPrefsTo196;
+ ValidatorPrefsWithBlocked: ValidatorPrefsWithBlocked;
+ ValidatorPrefsWithCommission: ValidatorPrefsWithCommission;
+ ValidatorSetId: ValidatorSetId;
+ ValidatorSignature: ValidatorSignature;
+ ValidDisputeStatementKind: ValidDisputeStatementKind;
+ ValidityAttestation: ValidityAttestation;
+ VecInboundHrmpMessage: VecInboundHrmpMessage;
+ VersionedMultiAsset: VersionedMultiAsset;
+ VersionedMultiAssets: VersionedMultiAssets;
+ VersionedMultiLocation: VersionedMultiLocation;
+ VersionedResponse: VersionedResponse;
+ VersionedXcm: VersionedXcm;
+ VersionMigrationStage: VersionMigrationStage;
+ VestingInfo: VestingInfo;
+ VestingSchedule: VestingSchedule;
+ Vote: Vote;
+ VoteIndex: VoteIndex;
+ Voter: Voter;
+ VoterInfo: VoterInfo;
+ Votes: Votes;
+ VotesTo230: VotesTo230;
+ VoteThreshold: VoteThreshold;
+ VoteWeight: VoteWeight;
+ Voting: Voting;
+ VotingDelegating: VotingDelegating;
+ VotingDirect: VotingDirect;
+ VotingDirectVote: VotingDirectVote;
+ VouchingStatus: VouchingStatus;
+ VrfData: VrfData;
+ VrfOutput: VrfOutput;
+ VrfProof: VrfProof;
+ Weight: Weight;
+ WeightLimitV2: WeightLimitV2;
+ WeightMultiplier: WeightMultiplier;
+ WeightPerClass: WeightPerClass;
+ WeightToFeeCoefficient: WeightToFeeCoefficient;
+ WildFungibility: WildFungibility;
+ WildFungibilityV0: WildFungibilityV0;
+ WildFungibilityV1: WildFungibilityV1;
+ WildFungibilityV2: WildFungibilityV2;
+ WildMultiAsset: WildMultiAsset;
+ WildMultiAssetV1: WildMultiAssetV1;
+ WildMultiAssetV2: WildMultiAssetV2;
+ WinnersData: WinnersData;
+ WinnersDataTuple: WinnersDataTuple;
+ WinningData: WinningData;
+ WinningDataEntry: WinningDataEntry;
+ WithdrawReasons: WithdrawReasons;
+ Xcm: Xcm;
+ XcmAssetId: XcmAssetId;
+ XcmError: XcmError;
+ XcmErrorV0: XcmErrorV0;
+ XcmErrorV1: XcmErrorV1;
+ XcmErrorV2: XcmErrorV2;
+ XcmOrder: XcmOrder;
+ XcmOrderV0: XcmOrderV0;
+ XcmOrderV1: XcmOrderV1;
+ XcmOrderV2: XcmOrderV2;
+ XcmOrigin: XcmOrigin;
+ XcmOriginKind: XcmOriginKind;
+ XcmpMessageFormat: XcmpMessageFormat;
+ XcmV0: XcmV0;
+ XcmV1: XcmV1;
+ XcmV2: XcmV2;
+ XcmVersion: XcmVersion;
+ }
+}
tests/src/interfaces/definitions.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/definitions.ts
@@ -0,0 +1,3 @@
+export {default as nft} from './nft/definitions';
+export {default as ethereum} from './ethereum/definitions';
+export {default as polkadot} from './polkadot/definitions';
tests/src/interfaces/ethereum/definitions.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/ethereum/definitions.ts
@@ -0,0 +1,16 @@
+function mkDummy(name: string) {
+ return {
+ ['dummy' + name]: 'u32',
+ };
+}
+
+export default {
+ types: {
+ EvmCoreErrorExitReason: mkDummy('ExitReason'),
+ EthereumLog: mkDummy('Log'),
+ EthereumTransactionLegacyTransaction: mkDummy('LegacyTx'),
+ EthereumBlock: mkDummy('EthBlock'),
+ EthereumReceipt: mkDummy('EthReceipt'),
+ FpRpcTransactionStatus: mkDummy('EthTxStatus'),
+ },
+};
tests/src/interfaces/ethereum/index.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/ethereum/index.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './types';
tests/src/interfaces/ethereum/types.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/ethereum/types.ts
@@ -0,0 +1,36 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+import type { Struct, u32 } from '@polkadot/types';
+
+/** @name EthereumBlock */
+export interface EthereumBlock extends Struct {
+ readonly dummyEthBlock: u32;
+}
+
+/** @name EthereumLog */
+export interface EthereumLog extends Struct {
+ readonly dummyLog: u32;
+}
+
+/** @name EthereumReceipt */
+export interface EthereumReceipt extends Struct {
+ readonly dummyEthReceipt: u32;
+}
+
+/** @name EthereumTransactionLegacyTransaction */
+export interface EthereumTransactionLegacyTransaction extends Struct {
+ readonly dummyLegacyTx: u32;
+}
+
+/** @name EvmCoreErrorExitReason */
+export interface EvmCoreErrorExitReason extends Struct {
+ readonly dummyExitReason: u32;
+}
+
+/** @name FpRpcTransactionStatus */
+export interface FpRpcTransactionStatus extends Struct {
+ readonly dummyEthTxStatus: u32;
+}
+
+export type PHANTOM_ETHEREUM = 'ethereum';
tests/src/interfaces/index.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/index.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './types';
tests/src/interfaces/nft/definitions.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/nft/definitions.ts
@@ -0,0 +1,102 @@
+function mkDummy(name: string) {
+ return {
+ ['dummy' + name]: 'u32',
+ };
+}
+
+type RpcParam = {
+ name: string;
+ type: string;
+ isOptional?: true;
+};
+
+const CROSS_ACCOUNT_ID_TYPE = 'PalletCommonAccountBasicCrossAccountIdRepr';
+const TOKEN_ID_TYPE = 'NftDataStructsTokenId';
+
+const collectionParam = {name: 'collection', type: 'NftDataStructsCollectionId'};
+const tokenParam = {name: 'tokenId', type: TOKEN_ID_TYPE};
+const crossAccountParam = (name = 'account') => ({name, type: CROSS_ACCOUNT_ID_TYPE});
+const atParam = {name: 'at', type: 'Hash', isOptional: true};
+
+const fun = (description: string, params: RpcParam[], type: string) => ({
+ description,
+ params: [...params, atParam],
+ type,
+});
+
+export default {
+ rpc: {
+ adminlist: fun('Get admin list', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),
+ allowlist: fun('Get allowlist', [collectionParam], 'Vec<PalletCommonAccountBasicCrossAccountIdRepr>'),
+
+ accountTokens: fun('Get tokens owned by account', [collectionParam, crossAccountParam()], 'Vec<NftDataStructsTokenId>'),
+ collectionTokens: fun('Get tokens contained in collection', [collectionParam], 'Vec<NftDataStructsTokenId>'),
+
+ lastTokenId: fun('Get last token id', [collectionParam], TOKEN_ID_TYPE),
+ accountBalance: fun('Get amount of different user tokens', [collectionParam, crossAccountParam()], 'u32'),
+ balance: fun('Get amount of specific account token', [collectionParam, crossAccountParam(), tokenParam], 'u128'),
+ allowance: fun('Get allowed amount', [collectionParam, crossAccountParam('sender'), crossAccountParam('spender'), tokenParam], 'u128'),
+ tokenOwner: fun('Get token owner', [collectionParam, tokenParam], CROSS_ACCOUNT_ID_TYPE),
+ constMetadata: fun('Get token constant metadata', [collectionParam, tokenParam], 'Vec<u8>'),
+ variableMetadata: fun('Get token variable metadata', [collectionParam, tokenParam], 'Vec<u8>'),
+ tokenExists: fun('Check if token exists', [collectionParam, tokenParam], 'bool'),
+ },
+ types: {
+ PalletCommonAccountBasicCrossAccountIdRepr: {
+ _enum: {
+ Substrate: 'AccountId',
+ Ethereum: 'H160',
+ },
+ },
+ NftDataStructsCollection: {
+ owner: 'AccountId',
+ mode: 'NftDataStructsCollectionMode',
+ access: 'NftDataStructsAccessMode',
+ name: 'Vec<u16>',
+ description: 'Vec<u16>',
+ tokenPrefix: 'Vec<u8>',
+ mintMode: 'bool',
+ offchainSchema: 'Vec<u8>',
+ schemaVersion: 'NftDataStructsSchemaVersion',
+ sponsorship: 'NftDataStructsSponsorshipState',
+ limits: 'NftDataStructsCollectionLimits',
+ variableOnChainSchema: 'Vec<u8>',
+ constOnChainSchema: 'Vec<u8>',
+ metaUpdatePermission: 'NftDataStructsMetaUpdatePermission',
+ },
+ NftDataStructsCollectionId: 'u32',
+ NftDataStructsTokenId: 'u32',
+ PalletNonfungibleItemData: mkDummy('NftItemData'),
+ PalletRefungibleItemData: mkDummy('RftItemData'),
+ NftDataStructsCollectionMode: mkDummy('CollectionMode'),
+ NftDataStructsCreateItemData: mkDummy('CreateItemData'),
+ NftDataStructsCollectionLimits: {
+ accountTokenOwnershipLimit: 'Option<u32>',
+ sponsoredDataSize: 'Option<u32>',
+ sponsoredDataRateLimit: 'Option<u32>',
+ tokenLimit: 'Option<u32>',
+ sponsorTransferTimeout: 'Option<u32>',
+ ownerCanTransfer: 'Option<bool>',
+ ownerCanDestroy: 'Option<bool>',
+ transfersEnabled: 'Option<bool>',
+ },
+ NftDataStructsMetaUpdatePermission: {
+ _enum: ['ItemOwner', 'Admin', 'None'],
+ },
+ NftDataStructsSponsorshipState: {
+ _enum: {
+ Disabled: null,
+ Unconfirmed: 'AccountId',
+ Confirmed: 'AccountId',
+ },
+ },
+ NftDataStructsAccessMode: {
+ _enum: ['Normal', 'WhiteList'],
+ },
+ NftDataStructsSchemaVersion: mkDummy('SchemaVersion'),
+
+ PalletUnqSchedulerScheduledV2: mkDummy('ScheduledV2'),
+ PalletUnqSchedulerCallSpec: mkDummy('CallSpec'),
+ PalletUnqSchedulerReleases: mkDummy('Releases'),
+ },
+};
tests/src/interfaces/nft/index.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/nft/index.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './types';
tests/src/interfaces/nft/types.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/nft/types.ts
@@ -0,0 +1,113 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+import type { Bytes, Enum, Option, Struct, Vec, bool, u16, u32 } from '@polkadot/types';
+import type { AccountId, H160 } from '@polkadot/types/interfaces/runtime';
+
+/** @name NftDataStructsAccessMode */
+export interface NftDataStructsAccessMode extends Enum {
+ readonly isNormal: boolean;
+ readonly isWhiteList: boolean;
+}
+
+/** @name NftDataStructsCollection */
+export interface NftDataStructsCollection extends Struct {
+ readonly owner: AccountId;
+ readonly mode: NftDataStructsCollectionMode;
+ readonly access: NftDataStructsAccessMode;
+ readonly name: Vec<u16>;
+ readonly description: Vec<u16>;
+ readonly tokenPrefix: Bytes;
+ readonly mintMode: bool;
+ readonly offchainSchema: Bytes;
+ readonly schemaVersion: NftDataStructsSchemaVersion;
+ readonly sponsorship: NftDataStructsSponsorshipState;
+ readonly limits: NftDataStructsCollectionLimits;
+ readonly variableOnChainSchema: Bytes;
+ readonly constOnChainSchema: Bytes;
+ readonly metaUpdatePermission: NftDataStructsMetaUpdatePermission;
+}
+
+/** @name NftDataStructsCollectionId */
+export interface NftDataStructsCollectionId extends u32 {}
+
+/** @name NftDataStructsCollectionLimits */
+export interface NftDataStructsCollectionLimits extends Struct {
+ readonly accountTokenOwnershipLimit: Option<u32>;
+ readonly sponsoredDataSize: Option<u32>;
+ readonly sponsoredDataRateLimit: Option<u32>;
+ readonly tokenLimit: Option<u32>;
+ readonly sponsorTransferTimeout: Option<u32>;
+ readonly ownerCanTransfer: Option<bool>;
+ readonly ownerCanDestroy: Option<bool>;
+ readonly transfersEnabled: Option<bool>;
+}
+
+/** @name NftDataStructsCollectionMode */
+export interface NftDataStructsCollectionMode extends Struct {
+ readonly dummyCollectionMode: u32;
+}
+
+/** @name NftDataStructsCreateItemData */
+export interface NftDataStructsCreateItemData extends Struct {
+ readonly dummyCreateItemData: u32;
+}
+
+/** @name NftDataStructsMetaUpdatePermission */
+export interface NftDataStructsMetaUpdatePermission extends Enum {
+ readonly isItemOwner: boolean;
+ readonly isAdmin: boolean;
+ readonly isNone: boolean;
+}
+
+/** @name NftDataStructsSchemaVersion */
+export interface NftDataStructsSchemaVersion extends Struct {
+ readonly dummySchemaVersion: u32;
+}
+
+/** @name NftDataStructsSponsorshipState */
+export interface NftDataStructsSponsorshipState extends Enum {
+ readonly isDisabled: boolean;
+ readonly isUnconfirmed: boolean;
+ readonly asUnconfirmed: AccountId;
+ readonly isConfirmed: boolean;
+ readonly asConfirmed: AccountId;
+}
+
+/** @name NftDataStructsTokenId */
+export interface NftDataStructsTokenId extends u32 {}
+
+/** @name PalletCommonAccountBasicCrossAccountIdRepr */
+export interface PalletCommonAccountBasicCrossAccountIdRepr extends Enum {
+ readonly isSubstrate: boolean;
+ readonly asSubstrate: AccountId;
+ readonly isEthereum: boolean;
+ readonly asEthereum: H160;
+}
+
+/** @name PalletNonfungibleItemData */
+export interface PalletNonfungibleItemData extends Struct {
+ readonly dummyNftItemData: u32;
+}
+
+/** @name PalletRefungibleItemData */
+export interface PalletRefungibleItemData extends Struct {
+ readonly dummyRftItemData: u32;
+}
+
+/** @name PalletUnqSchedulerCallSpec */
+export interface PalletUnqSchedulerCallSpec extends Struct {
+ readonly dummyCallSpec: u32;
+}
+
+/** @name PalletUnqSchedulerReleases */
+export interface PalletUnqSchedulerReleases extends Struct {
+ readonly dummyReleases: u32;
+}
+
+/** @name PalletUnqSchedulerScheduledV2 */
+export interface PalletUnqSchedulerScheduledV2 extends Struct {
+ readonly dummyScheduledV2: u32;
+}
+
+export type PHANTOM_NFT = 'nft';
tests/src/interfaces/polkadot/definitions.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/polkadot/definitions.ts
@@ -0,0 +1,20 @@
+function mkDummy(name: string) {
+ return {
+ ['dummy' + name]: 'u32',
+ };
+}
+
+export default {
+ types: {
+ CumulusPrimitivesParachainInherentParachainInherentData: mkDummy('ParachainInherentData'),
+ CumulusPalletDmpQueueConfigData: mkDummy('DmpQueueConfigData'),
+ CumulusPalletDmpQueuePageIndexData: mkDummy('DmpQueryPageIndexData'),
+ PolkadotPrimitivesV1AbridgedHostConfiguration: mkDummy('AbridgedHostConfiguration'),
+ CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot: mkDummy('CumulusStateSnapshot'),
+ PolkadotPrimitivesV1PersistedValidationData: mkDummy('PersistedValidationData'),
+ CumulusPalletXcmpQueueInboundStatus: mkDummy('CumulusInboundStatus'),
+ CumulusPalletXcmpQueueOutboundStatus: mkDummy('CumulusOutboundStatus'),
+ PolkadotParachainPrimitivesXcmpMessageFormat: mkDummy('XcmpMessageFormat'),
+ CumulusPalletXcmpQueueQueueConfigData: mkDummy('QueueConfigData'),
+ },
+};
tests/src/interfaces/polkadot/index.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/polkadot/index.ts
@@ -0,0 +1,4 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './types';
tests/src/interfaces/polkadot/types.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/polkadot/types.ts
@@ -0,0 +1,56 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+import type { Struct, u32 } from '@polkadot/types';
+
+/** @name CumulusPalletDmpQueueConfigData */
+export interface CumulusPalletDmpQueueConfigData extends Struct {
+ readonly dummyDmpQueueConfigData: u32;
+}
+
+/** @name CumulusPalletDmpQueuePageIndexData */
+export interface CumulusPalletDmpQueuePageIndexData extends Struct {
+ readonly dummyDmpQueryPageIndexData: u32;
+}
+
+/** @name CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot */
+export interface CumulusPalletParachainSystemRelayStateSnapshotMessagingStateSnapshot extends Struct {
+ readonly dummyCumulusStateSnapshot: u32;
+}
+
+/** @name CumulusPalletXcmpQueueInboundStatus */
+export interface CumulusPalletXcmpQueueInboundStatus extends Struct {
+ readonly dummyCumulusInboundStatus: u32;
+}
+
+/** @name CumulusPalletXcmpQueueOutboundStatus */
+export interface CumulusPalletXcmpQueueOutboundStatus extends Struct {
+ readonly dummyCumulusOutboundStatus: u32;
+}
+
+/** @name CumulusPalletXcmpQueueQueueConfigData */
+export interface CumulusPalletXcmpQueueQueueConfigData extends Struct {
+ readonly dummyQueueConfigData: u32;
+}
+
+/** @name CumulusPrimitivesParachainInherentParachainInherentData */
+export interface CumulusPrimitivesParachainInherentParachainInherentData extends Struct {
+ readonly dummyParachainInherentData: u32;
+}
+
+/** @name PolkadotParachainPrimitivesXcmpMessageFormat */
+export interface PolkadotParachainPrimitivesXcmpMessageFormat extends Struct {
+ readonly dummyXcmpMessageFormat: u32;
+}
+
+/** @name PolkadotPrimitivesV1AbridgedHostConfiguration */
+export interface PolkadotPrimitivesV1AbridgedHostConfiguration extends Struct {
+ readonly dummyAbridgedHostConfiguration: u32;
+}
+
+/** @name PolkadotPrimitivesV1PersistedValidationData */
+export interface PolkadotPrimitivesV1PersistedValidationData extends Struct {
+ readonly dummyPersistedValidationData: u32;
+}
+
+export type PHANTOM_POLKADOT = 'polkadot';
tests/src/interfaces/types.tsdiffbeforeafterboth--- /dev/null
+++ b/tests/src/interfaces/types.ts
@@ -0,0 +1,6 @@
+// Auto-generated via `yarn polkadot-types-from-defs`, do not edit
+/* eslint-disable */
+
+export * from './nft/types';
+export * from './ethereum/types';
+export * from './polkadot/types';
tests/src/limits.test.tsdiffbeforeafterboth--- a/tests/src/limits.test.ts
+++ b/tests/src/limits.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
@@ -18,98 +18,98 @@
getFreeBalance,
waitNewBlocks,
} from './util/helpers';
-import { expect } from 'chai';
+import {expect} from 'chai';
describe('Number of tokens per address (NFT)', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 20 });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 20});
for(let i = 0; i < 10; i++){
- await createItemExpectSuccess(Alice, collectionId, 'NFT');
+ await createItemExpectSuccess(alice, collectionId, 'NFT');
}
- await createItemExpectFailure(Alice, collectionId, 'NFT');
+ await createItemExpectFailure(alice, collectionId, 'NFT');
await destroyCollectionExpectSuccess(collectionId);
});
it('Collection limits allow lower number than chain limits, collection limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 1 });
- await createItemExpectSuccess(Alice, collectionId, 'NFT');
- await createItemExpectFailure(Alice, collectionId, 'NFT');
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
+ await createItemExpectSuccess(alice, collectionId, 'NFT');
+ await createItemExpectFailure(alice, collectionId, 'NFT');
await destroyCollectionExpectSuccess(collectionId);
});
});
describe('Number of tokens per address (ReFungible)', () => {
- let Alice: IKeyringPair;
+ let alice: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
+ alice = privateKey('//Alice');
});
});
it.skip('Collection limits allow greater number than chain limits, chain limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible' }});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 20 });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 20});
for(let i = 0; i < 10; i++){
- await createItemExpectSuccess(Alice, collectionId, 'ReFungible');
+ await createItemExpectSuccess(alice, collectionId, 'ReFungible');
}
- await createItemExpectFailure(Alice, collectionId, 'ReFungible');
+ await createItemExpectFailure(alice, collectionId, 'ReFungible');
await destroyCollectionExpectSuccess(collectionId);
});
it('Collection limits allow lower number than chain limits, collection limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible' }});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 1 });
- await createItemExpectSuccess(Alice, collectionId, 'ReFungible');
- await createItemExpectFailure(Alice, collectionId, 'ReFungible');
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 1});
+ await createItemExpectSuccess(alice, collectionId, 'ReFungible');
+ await createItemExpectFailure(alice, collectionId, 'ReFungible');
await destroyCollectionExpectSuccess(collectionId);
});
});
describe('Sponsor timeout (NFT)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Collection limits have greater timeout value than chain limits, collection limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 7 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'NFT');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob);
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob);
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 5, fail
await waitNewBlocks(5);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie);
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie);
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 7, success
await waitNewBlocks(2); // 5 + 2
- await transferExpectSuccess(collectionId, tokenId, Charlie, Bob);
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, charlie, bob);
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
await destroyCollectionExpectSuccess(collectionId);
@@ -117,24 +117,24 @@
it('Collection limits have lower timeout value than chain limits, chain limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 1 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'NFT');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob);
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob);
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 1, fail
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie);
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie);
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 5, success
await waitNewBlocks(4);
- await transferExpectSuccess(collectionId, tokenId, Charlie, Bob);
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, charlie, bob);
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
await destroyCollectionExpectSuccess(collectionId);
@@ -142,38 +142,38 @@
});
describe('Sponsor timeout (Fungible)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Collection limits have greater timeout value than chain limits, collection limits are enforced', async () => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 7 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'Fungible');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob, 10, 'Fungible');
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 5, fail
await waitNewBlocks(5);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 7, success
await waitNewBlocks(2); // 5 + 2
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
@@ -183,24 +183,24 @@
it('Collection limits have lower timeout value than chain limits, chain limits are enforced', async () => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 1 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'Fungible');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob, 10, 'Fungible');
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 1, fail
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 5, success
await waitNewBlocks(4);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
@@ -209,37 +209,37 @@
});
describe('Sponsor timeout (ReFungible)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Collection limits have greater timeout value than chain limits, collection limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible' }});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 7 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'ReFungible');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 7});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'ReFungible');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob, 100, 'ReFungible');
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob, 100, 'ReFungible');
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 5, fail
await waitNewBlocks(5);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 20, 'ReFungible');
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 7, success
await waitNewBlocks(2); // 5 + 2
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 20, 'ReFungible');
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
await destroyCollectionExpectSuccess(collectionId);
@@ -247,24 +247,24 @@
it('Collection limits have lower timeout value than chain limits, chain limits are enforced', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 1 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'NFT');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 1});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob);
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob);
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 1, fail
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie);
- const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie);
+ const aliceBalanceAfterUnsponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterUnsponsoredTransaction).to.be.equals(aliceBalanceBefore);
// check setting SponsorTimeout = 5, success
await waitNewBlocks(4);
- await transferExpectSuccess(collectionId, tokenId, Charlie, Bob);
- const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, charlie, bob);
+ const aliceBalanceAfterSponsoredTransaction = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction).to.be.lessThan(aliceBalanceBefore);
await destroyCollectionExpectSuccess(collectionId);
@@ -272,115 +272,115 @@
});
describe('Collection zero limits (NFT)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it.skip('Limits have 0 in tokens per address field, the chain limits are applied', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 0 });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 0});
for(let i = 0; i < 10; i++){
- await createItemExpectSuccess(Alice, collectionId, 'NFT');
+ await createItemExpectSuccess(alice, collectionId, 'NFT');
}
- await createItemExpectFailure(Alice, collectionId, 'NFT');
+ await createItemExpectFailure(alice, collectionId, 'NFT');
});
it('Limits have 0 in sponsor timeout, no limits are applied', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 0 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'NFT');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 0});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob);
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob);
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 0, success with next block
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie);
- const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie);
+ const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction1).to.be.lessThan(aliceBalanceBefore);
});
});
describe('Collection zero limits (Fungible)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Limits have 0 in sponsor timeout, no limits are applied', async () => {
const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 0 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'Fungible');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 0});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'Fungible');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob, 10, 'Fungible');
- const aliceBalanceBefore = await getFreeBalance(Alice);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
+ await transferExpectSuccess(collectionId, tokenId, alice, bob, 10, 'Fungible');
+ const aliceBalanceBefore = await getFreeBalance(alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
// check setting SponsorTimeout = 0, success with next block
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 2, 'Fungible');
- const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 2, 'Fungible');
+ const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction1).to.be.lessThan(aliceBalanceBefore);
});
});
describe('Collection zero limits (ReFungible)', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it.skip('Limits have 0 in tokens per address field, the chain limits are applied', async () => {
- const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible' }});
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { accountTokenOwnershipLimit: 0 });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {accountTokenOwnershipLimit: 0});
for(let i = 0; i < 10; i++){
- await createItemExpectSuccess(Alice, collectionId, 'ReFungible');
+ await createItemExpectSuccess(alice, collectionId, 'ReFungible');
}
- await createItemExpectFailure(Alice, collectionId, 'ReFungible');
+ await createItemExpectFailure(alice, collectionId, 'ReFungible');
});
it('Limits have 0 in sponsor timeout, no limits are applied', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'ReFungible' } });
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { sponsorTimeout: 0 });
- const tokenId = await createItemExpectSuccess(Alice, collectionId, 'ReFungible');
- await setCollectionSponsorExpectSuccess(collectionId, Alice.address);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {sponsorTransferTimeout: 0});
+ const tokenId = await createItemExpectSuccess(alice, collectionId, 'ReFungible');
+ await setCollectionSponsorExpectSuccess(collectionId, alice.address);
await confirmSponsorshipExpectSuccess(collectionId, '//Alice');
- await transferExpectSuccess(collectionId, tokenId, Alice, Bob, 100, 'ReFungible');
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 20, 'ReFungible');
- const aliceBalanceBefore = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, alice, bob, 100, 'ReFungible');
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');
+ const aliceBalanceBefore = await getFreeBalance(alice);
// check setting SponsorTimeout = 0, success with next block
await waitNewBlocks(1);
- await transferExpectSuccess(collectionId, tokenId, Bob, Charlie, 20, 'ReFungible');
- const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(Alice);
+ await transferExpectSuccess(collectionId, tokenId, bob, charlie, 20, 'ReFungible');
+ const aliceBalanceAfterSponsoredTransaction1 = await getFreeBalance(alice);
expect(aliceBalanceAfterSponsoredTransaction1 < aliceBalanceBefore).to.be.true;
//expect(aliceBalanceAfterSponsoredTransaction1).to.be.lessThan(aliceBalanceBefore);
});
tests/src/metadataUpdate.test.tsdiffbeforeafterboth--- a/tests/src/metadataUpdate.test.ts
+++ b/tests/src/metadataUpdate.test.ts
@@ -27,53 +27,53 @@
describe('Metadata update permissions with ItemOwner flag', () => {
it('ItemOwner can set variable metadata with ItemOwner permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
const data = [1, 2, 254, 255];
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'ItemOwner');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner');
- await setVariableMetaDataExpectSuccess(Alice, nftCollectionId, newNftTokenId, data);
+ await setVariableMetaDataExpectSuccess(alice, nftCollectionId, newNftTokenId, data);
});
});
it('Admin can\'n set variable metadata with ItemOwner permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'ItemOwner');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner');
+
+ await setMintPermissionExpectSuccess(alice, nftCollectionId, true);
+ await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);
+ await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
- await setMintPermissionExpectSuccess(Alice, nftCollectionId, true);
- await addToWhiteListExpectSuccess(Alice, nftCollectionId, Bob.address);
- await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);
-
- await setVariableMetaDataExpectFailure(Bob, nftCollectionId, newNftTokenId, data);
+ await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);
});
});
it('User can\'n set variable metadata with ItemOwner permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'ItemOwner');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'ItemOwner');
- await setMintPermissionExpectSuccess(Alice, nftCollectionId, true);
- await setVariableMetaDataExpectFailure(Bob, nftCollectionId, newNftTokenId, data);
+ await setMintPermissionExpectSuccess(alice, nftCollectionId, true);
+ await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);
});
});
});
@@ -81,60 +81,60 @@
describe('Metadata update permissions with Admin flag', () => {
it('Admin can set variable metadata with Admin permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'Admin');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');
- await setMintPermissionExpectSuccess(Alice, nftCollectionId, true);
- await addToWhiteListExpectSuccess(Alice, nftCollectionId, Bob.address);
- await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);
-
- await setVariableMetaDataExpectSuccess(Bob, nftCollectionId, newNftTokenId, data);
+ await setMintPermissionExpectSuccess(alice, nftCollectionId, true);
+ await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);
+ await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
+
+ await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);
});
});
it('User can\'n can set variable metadata with Admin permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'Admin');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');
+
+ await setMintPermissionExpectSuccess(alice, nftCollectionId, true);
+ await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);
+ await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
- await setMintPermissionExpectSuccess(Alice, nftCollectionId, true);
- await addToWhiteListExpectSuccess(Alice, nftCollectionId, Bob.address);
- await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);
-
- await setVariableMetaDataExpectSuccess(Bob, nftCollectionId, newNftTokenId, data);
+ await setVariableMetaDataExpectSuccess(bob, nftCollectionId, newNftTokenId, data);
});
});
it('ItemOwner can\'n can set variable metadata with Admin permission flag', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await enablePublicMintingExpectSuccess(Alice, nftCollectionId);
- await addToWhiteListExpectSuccess(Alice, nftCollectionId, Bob.address);
- await enableWhiteListExpectSuccess(Alice, nftCollectionId);
- const newNftTokenId = await createItemExpectSuccess(Bob, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'Admin');
-
- await setVariableMetaDataExpectFailure(Bob, nftCollectionId, newNftTokenId, data);
+ await enablePublicMintingExpectSuccess(alice, nftCollectionId);
+ await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);
+ await enableWhiteListExpectSuccess(alice, nftCollectionId);
+ const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'Admin');
+
+ await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);
});
});
});
@@ -142,63 +142,63 @@
describe('Metadata update permissions with None flag', () => {
it('Nobody can set variable metadata with None flag (Regular)', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'None');
-
- await setVariableMetaDataExpectFailure(Bob, nftCollectionId, newNftTokenId, data);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');
+
+ await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);
});
});
it('Nobody can set variable metadata with None flag (Admin)', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
-
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'None');
-
- await setMintPermissionExpectSuccess(Alice, nftCollectionId, true);
- await addToWhiteListExpectSuccess(Alice, nftCollectionId, Bob.address);
- await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);
-
- await setVariableMetaDataExpectFailure(Bob, nftCollectionId, newNftTokenId, data);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');
+
+ await setMintPermissionExpectSuccess(alice, nftCollectionId, true);
+ await addToWhiteListExpectSuccess(alice, nftCollectionId, bob.address);
+ await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
+
+ await setVariableMetaDataExpectFailure(bob, nftCollectionId, newNftTokenId, data);
});
});
it('Nobody can set variable metadata with None flag (ItemOwner)', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
-
+ const alice = privateKey('//Alice');
+
const data = [1, 2, 254, 255];
-
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'None');
-
- await setVariableMetaDataExpectFailure(Alice, nftCollectionId, newNftTokenId, data);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');
+
+ await setVariableMetaDataExpectFailure(alice, nftCollectionId, newNftTokenId, data);
});
});
it('Nobody can set variable metadata flag after freeze', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
-
+ const alice = privateKey('//Alice');
+
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await setMetadataUpdatePermissionFlagExpectSuccess(Alice, nftCollectionId, 'None');
- await setMetadataUpdatePermissionFlagExpectFailure(Alice, nftCollectionId, 'Admin');
+ await setMetadataUpdatePermissionFlagExpectSuccess(alice, nftCollectionId, 'None');
+ await setMetadataUpdatePermissionFlagExpectFailure(alice, nftCollectionId, 'Admin');
});
});
});
tests/src/mintModes.test.tsdiffbeforeafterboth--- a/tests/src/mintModes.test.ts
+++ b/tests/src/mintModes.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
@@ -30,7 +30,7 @@
it('If the AllowList mode is enabled, then the address added to the whitelist and not the owner or administrator can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
@@ -41,7 +41,7 @@
it('If the AllowList mode is enabled, address not included in whitelist that is regular user cannot create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await createItemExpectFailure(bob, collectionId, 'NFT');
@@ -50,17 +50,17 @@
it('If the AllowList mode is enabled, address not included in whitelist that is admin can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await createItemExpectSuccess(bob, collectionId, 'NFT');
});
});
it('If the AllowList mode is enabled, address not included in whitelist that is owner can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await createItemExpectSuccess(alice, collectionId, 'NFT');
@@ -69,7 +69,7 @@
it('If the AllowList mode is disabled, owner can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await disableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await createItemExpectSuccess(alice, collectionId, 'NFT');
@@ -78,17 +78,17 @@
it('If the AllowList mode is disabled, collection admin can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await disableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await createItemExpectSuccess(bob, collectionId, 'NFT');
});
});
it('If the AllowList mode is disabled, regular user can`t create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await disableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await createItemExpectFailure(bob, collectionId, 'NFT');
@@ -109,7 +109,7 @@
it('Address that is the not owner or not admin cannot create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, false);
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
@@ -119,7 +119,7 @@
it('Address that is collection owner can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await disableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, false);
await createItemExpectSuccess(alice, collectionId, 'NFT');
@@ -128,10 +128,10 @@
it('Address that is admin can create tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await disableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, false);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await createItemExpectSuccess(bob, collectionId, 'NFT');
});
});
tests/src/overflow.test.tsdiffbeforeafterboth--- a/tests/src/overflow.test.ts
+++ b/tests/src/overflow.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
-import { approveExpectFail, approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getFungibleBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX } from './util/helpers';
+import {approveExpectSuccess, createCollectionExpectSuccess, createFungibleItemExpectSuccess, getAllowance, getBalance, transferExpectFailure, transferExpectSuccess, transferFromExpectFail, transferFromExpectSuccess, U128_MAX} from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -27,41 +27,36 @@
});
it('fails when overflows on transfer', async () => {
- const fungibleCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
+ await usingApi(async api => {
+ const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: U128_MAX });
- await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');
-
- await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: 1n });
- await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);
-
- expect(await getFungibleBalance(fungibleCollectionId, alice.address)).to.equal(1n);
- expect(await getFungibleBalance(fungibleCollectionId, bob.address)).to.equal(U128_MAX);
- });
+ await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});
+ await transferExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX, 'Fungible');
- it('fails on allowance overflow', async () => {
- const fungibleCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
+ await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: 1n});
+ await transferExpectFailure(fungibleCollectionId, 0, alice, bob, 1);
- await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: U128_MAX });
- await approveExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX);
- await approveExpectFail(fungibleCollectionId, 0, alice, bob, U128_MAX);
+ expect(await getBalance(api, fungibleCollectionId, alice.address, 0)).to.equal(1n);
+ expect(await getBalance(api, fungibleCollectionId, bob.address, 0)).to.equal(U128_MAX);
+ });
});
it('fails when overflows on transferFrom', async () => {
- const fungibleCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
+ await usingApi(async api => {
+ const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
+ await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});
+ await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, U128_MAX);
+ await transferFromExpectSuccess(fungibleCollectionId, 0, bob, alice, charlie, U128_MAX, 'Fungible');
- await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: U128_MAX });
- await approveExpectSuccess(fungibleCollectionId, 0, alice, bob, U128_MAX);
- await transferFromExpectSuccess(fungibleCollectionId, 0, bob, alice, charlie, U128_MAX, 'Fungible');
+ expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);
+ expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(0n);
- expect(await getFungibleBalance(fungibleCollectionId, charlie.address)).to.equal(U128_MAX);
- expect((await getAllowance(fungibleCollectionId, 0, alice.address, bob.address)).toString()).to.equal('0');
-
- await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: U128_MAX });
- await approveExpectSuccess(fungibleCollectionId, 0, alice, bob, 1n);
- await transferFromExpectFail(fungibleCollectionId, 0, bob, alice, charlie, 1);
+ await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: U128_MAX});
+ await approveExpectSuccess(fungibleCollectionId, 0, alice, bob.address, 1n);
+ await transferFromExpectFail(fungibleCollectionId, 0, bob, alice, charlie, 1);
- expect(await getFungibleBalance(fungibleCollectionId, charlie.address)).to.equal(U128_MAX);
- expect((await getAllowance(fungibleCollectionId, 0, alice.address, bob.address)).toString()).to.equal('1');
+ expect(await getBalance(api, fungibleCollectionId, charlie.address, 0)).to.equal(U128_MAX);
+ expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, 0)).to.equal(1n);
+ });
});
});
tests/src/pallet-presence.test.tsdiffbeforeafterboth--- a/tests/src/pallet-presence.test.ts
+++ b/tests/src/pallet-presence.test.ts
@@ -3,8 +3,8 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
-import { expect } from 'chai';
+import {ApiPromise} from '@polkadot/api';
+import {expect} from 'chai';
import usingApi from './substrate/substrate-api';
function getModuleNames(api: ApiPromise): string[] {
@@ -14,6 +14,7 @@
// Pallets that must always be present
const requiredPallets = [
'balances',
+ 'common',
'randomnesscollectiveflip',
'timestamp',
'transactionpayment',
@@ -28,12 +29,15 @@
'evmmigration',
'evmtransactionpayment',
'ethereum',
+ 'fungible',
'xcmpqueue',
'polkadotxcm',
'cumulusxcm',
'dmpqueue',
'inflation',
'nft',
+ 'nonfungible',
+ 'refungible',
'scheduler',
'nftpayment',
'charging',
tests/src/removeCollectionAdmin.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionAdmin.test.ts
+++ b/tests/src/removeCollectionAdmin.test.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
+import {ApiPromise} from '@polkadot/api';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, normalizeAccountId} from './util/helpers';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {createCollectionExpectSuccess, destroyCollectionExpectSuccess, getAdminList, normalizeAccountId} from './util/helpers';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -17,63 +17,63 @@
it('Remove collection admin.', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(Alice.address);
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.deep.eq(alice.address);
// first - add collection admin Bob
- const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Alice, addAdminTx);
+ const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(alice, addAdminTx);
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON();
- expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(Bob.address));
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));
// then remove bob from admins of collection
- const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Alice, removeAdminTx);
+ const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(alice, removeAdminTx);
- const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON;
- expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(Bob.address));
+ const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));
});
});
it('Remove collection admin by admin.', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
- const Charlie = privateKey('//Charlie');
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.deep.eq(Alice.address);
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+ const charlie = privateKey('//Charlie');
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
// first - add collection admin Bob
- const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Alice, addAdminTx);
+ const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(alice, addAdminTx);
- const addAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Charlie.address));
- await submitTransactionAsync(Alice, addAdminTx2);
+ const addAdminTx2 = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(charlie.address));
+ await submitTransactionAsync(alice, addAdminTx2);
- const adminListAfterAddAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON();
- expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(Bob.address));
+ const adminListAfterAddAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterAddAdmin).to.be.deep.contains(normalizeAccountId(bob.address));
// then remove bob from admins of collection
- const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Charlie, removeAdminTx);
+ const removeAdminTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(charlie, removeAdminTx);
- const adminListAfterRemoveAdmin: any = (await api.query.nft.adminList(collectionId)).toJSON;
- expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(Bob.address));
+ const adminListAfterRemoveAdmin = await getAdminList(api, collectionId);
+ expect(adminListAfterRemoveAdmin).not.to.be.deep.contains(normalizeAccountId(bob.address));
});
});
it('Remove admin from collection that has no admins', async () => {
await usingApi(async (api: ApiPromise) => {
- const Alice = privateKey('//Alice');
+ const alice = privateKey('//Alice');
const collectionId = await createCollectionExpectSuccess();
- const adminListBeforeAddAdmin: any = (await api.query.nft.adminList(collectionId));
+ const adminListBeforeAddAdmin = await getAdminList(api, collectionId);
expect(adminListBeforeAddAdmin).to.have.lengthOf(0);
- const tx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Alice.address));
- await submitTransactionAsync(Alice, tx);
+ const tx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(alice.address));
+ await submitTransactionAsync(alice, tx);
});
});
});
@@ -98,13 +98,13 @@
await usingApi(async (api: ApiPromise) => {
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
await destroyCollectionExpectSuccess(collectionId);
- const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await expect(submitTransactionExpectFailAsync(Alice, changeOwnerTx)).to.be.rejected;
+ const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await expect(submitTransactionExpectFailAsync(alice, changeOwnerTx)).to.be.rejected;
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
@@ -114,15 +114,15 @@
it('Regular user Can\'t remove collection admin', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
- const Charlie = privateKey('//Charlie');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
+ const charlie = privateKey('//Charlie');
- const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await submitTransactionAsync(Alice, addAdminTx);
+ const addAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await submitTransactionAsync(alice, addAdminTx);
- const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(Bob.address));
- await expect(submitTransactionExpectFailAsync(Charlie, changeOwnerTx)).to.be.rejected;
+ const changeOwnerTx = api.tx.nft.removeCollectionAdmin(collectionId, normalizeAccountId(bob.address));
+ await expect(submitTransactionExpectFailAsync(charlie, changeOwnerTx)).to.be.rejected;
// Verifying that nothing bad happened (network is live, new collections can be created, etc.)
await createCollectionExpectSuccess();
tests/src/removeCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/removeCollectionSponsor.test.ts
+++ b/tests/src/removeCollectionSponsor.test.ts
@@ -5,11 +5,11 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionExpectFailAsync } from './substrate/substrate-api';
-import {
- createCollectionExpectSuccess,
- setCollectionSponsorExpectSuccess,
- destroyCollectionExpectSuccess,
+import {default as usingApi, submitTransactionExpectFailAsync} from './substrate/substrate-api';
+import {
+ createCollectionExpectSuccess,
+ setCollectionSponsorExpectSuccess,
+ destroyCollectionExpectSuccess,
confirmSponsorshipExpectSuccess,
confirmSponsorshipExpectFailure,
createItemExpectSuccess,
@@ -19,9 +19,8 @@
normalizeAccountId,
addCollectionAdminExpectSuccess,
} from './util/helpers';
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import { BigNumber } from 'bignumber.js';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
chai.use(chaiAsPromised);
const expect = chai.expect;
@@ -33,7 +32,7 @@
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -53,15 +52,15 @@
const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);
// Transfer this tokens from unused address to Alice - should fail
- const AsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();
const zeroToAlice = api.tx.nft.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);
- const badTransaction = async function () {
+ const badTransaction = async function () {
await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);
};
await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');
- const BsponsorBalance = new BigNumber((await api.query.system.account(bob.address)).data.free.toString());
+ const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
- expect(BsponsorBalance.isEqualTo(AsponsorBalance)).to.be.true;
+ expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
});
});
@@ -89,7 +88,7 @@
describe('(!negative test!) integration test: ext. removeCollectionSponsor():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -99,7 +98,7 @@
// Find the collection that never existed
let collectionId = 0;
await usingApi(async (api) => {
- collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
});
await removeCollectionSponsorExpectFailure(collectionId);
@@ -108,7 +107,7 @@
it('(!negative test!) Remove sponsor for a collection with collection admin permissions', async () => {
const collectionId = await createCollectionExpectSuccess();
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await removeCollectionSponsorExpectFailure(collectionId, '//Bob');
});
tests/src/removeFromContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromContractWhiteList.test.ts
+++ b/tests/src/removeFromContractWhiteList.test.ts
@@ -5,10 +5,10 @@
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
-import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from './util/contracthelpers';
-import { addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess } from './util/helpers';
-import { IKeyringPair } from '@polkadot/types/types';
-import { expect } from 'chai';
+import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';
+import {addToContractWhiteListExpectSuccess, isWhitelistedInContract, removeFromContractWhiteListExpectFailure, removeFromContractWhiteListExpectSuccess, toggleContractWhitelistExpectSuccess} from './util/helpers';
+import {IKeyringPair} from '@polkadot/types/types';
+import {expect} from 'chai';
describe.skip('Integration Test removeFromContractWhiteList', () => {
let bob: IKeyringPair;
tests/src/removeFromWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/removeFromWhiteList.test.ts
+++ b/tests/src/removeFromWhiteList.test.ts
@@ -5,7 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi } from './substrate/substrate-api';
+import {default as usingApi} from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
@@ -19,7 +19,7 @@
normalizeAccountId,
addCollectionAdminExpectSuccess,
} from './util/helpers';
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
chai.use(chaiAsPromised);
@@ -38,7 +38,7 @@
it('ensure bob is not in whitelist after removal', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
@@ -105,9 +105,9 @@
it('ensure address is not in whitelist after removal', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
await removeFromWhiteListExpectSuccess(bob, collectionId, normalizeAccountId(charlie.address));
expect(await isWhitelisted(collectionId, charlie.address)).to.be.false;
@@ -118,7 +118,7 @@
await usingApi(async () => {
const collectionWithoutWhitelistId = await createCollectionExpectSuccess();
await enableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);
- await addCollectionAdminExpectSuccess(alice, collectionWithoutWhitelistId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionWithoutWhitelistId, bob.address);
await addToWhiteListExpectSuccess(alice, collectionWithoutWhitelistId, charlie.address);
await disableWhiteListExpectSuccess(alice, collectionWithoutWhitelistId);
await removeFromWhiteListExpectSuccess(bob, collectionWithoutWhitelistId, normalizeAccountId(charlie.address));
@@ -133,4 +133,4 @@
await removeFromWhiteListExpectFailure(bob, collectionWithoutWhitelistId, normalizeAccountId(charlie.address));
});
});
-});
\ No newline at end of file
+});
tests/src/rpc.load.tsdiffbeforeafterboth--- a/tests/src/rpc.load.ts
+++ b/tests/src/rpc.load.ts
@@ -3,12 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import usingApi, { submitTransactionAsync } from './substrate/substrate-api';
-import { IKeyringPair } from '@polkadot/types/types';
-import { Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract } from '@polkadot/api-contract';
-import { ApiPromise, Keyring } from '@polkadot/api';
-import { BigNumber } from 'bignumber.js';
-import { findUnusedAddress } from './util/helpers';
+import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
+import {IKeyringPair} from '@polkadot/types/types';
+import {Abi, BlueprintPromise as Blueprint, CodePromise, ContractPromise as Contract} from '@polkadot/api-contract';
+import {ApiPromise, Keyring} from '@polkadot/api';
+import {findUnusedAddress} from './util/helpers';
import fs from 'fs';
import privateKey from './substrate/privateKey';
@@ -41,7 +40,7 @@
unsub();
resolve(result);
}
- });
+ });
});
}
@@ -50,11 +49,10 @@
const deployer = await findUnusedAddress(api);
// Transfer balance to it
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
const alice = keyring.addFromUri('//Alice');
- let amount = new BigNumber(endowment);
- amount = amount.plus(1e15);
- const tx = api.tx.balances.transfer(deployer.address, amount.toFixed());
+ const amount = BigInt(endowment) + 10n**15n;
+ const tx = api.tx.balances.transfer(deployer.address, amount);
await submitTransactionAsync(alice, tx);
return deployer;
@@ -100,7 +98,7 @@
await api.rpc.system.chain();
count++;
process.stdout.write(`RPC reads: ${count} times at rate ${rate} r/s \r`);
-
+
if (count % checkPoint == 0) {
hrTime = process.hrtime();
const microsec2 = hrTime[0] * 1000000 + hrTime[1] / 1000;
@@ -134,7 +132,7 @@
await getScData(contract, deployer);
count++;
process.stdout.write(`SC reads: ${count} times at rate ${rate} r/s \r`);
-
+
if (count % checkPoint == 0) {
hrTime = process.hrtime();
const microsec2 = hrTime[0] * 1000000 + hrTime[1] / 1000;
tests/src/scheduler.test.tsdiffbeforeafterboth--- a/tests/src/scheduler.test.ts
+++ b/tests/src/scheduler.test.ts
@@ -20,15 +20,15 @@
describe('Integration Test scheduler base transaction', () => {
it('User can transfer owned token with delay (scheduler)', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await setCollectionSponsorExpectSuccess(nftCollectionId, Alice.address);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await setCollectionSponsorExpectSuccess(nftCollectionId, alice.address);
await confirmSponsorshipExpectSuccess(nftCollectionId);
- await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 12000, 4);
+ await scheduleTransferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 1, 4);
});
});
});
tests/src/setChainLimits.test.tsdiffbeforeafterboth--- a/tests/src/setChainLimits.test.ts
+++ b/tests/src/setChainLimits.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
@@ -40,16 +40,16 @@
});
it('Collection owner cannot set chain limits', async () => {
- await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await setChainLimitsExpectFailure(alice, limits);
});
it('Collection admin cannot set chain limits', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await setChainLimitsExpectFailure(bob, limits);
});
-
+
it('Regular user cannot set chain limits', async () => {
await setChainLimitsExpectFailure(dave, limits);
});
tests/src/setCollectionLimits.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionLimits.test.ts
+++ b/tests/src/setCollectionLimits.test.ts
@@ -4,19 +4,18 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setchainlimits
-import { ApiPromise, Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise, Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import { ICollectionInterface } from './types';
import {
createCollectionExpectSuccess, getCreatedCollectionCount,
getCreateItemResult,
- getDetailedCollectionInfo,
setCollectionLimitsExpectFailure,
setCollectionLimitsExpectSuccess,
addCollectionAdminExpectSuccess,
+ queryCollectionExpectSuccess,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -28,15 +27,14 @@
const accountTokenOwnershipLimit = 0;
const sponsoredDataSize = 0;
-const sponsoredMintSize = 0;
-const sponsorTimeout = 1;
+const sponsorTransferTimeout = 1;
const tokenLimit = 10;
describe('setCollectionLimits positive', () => {
let tx;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
});
@@ -47,9 +45,9 @@
collectionIdForTesting,
{
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
- sponsoredMintSize: sponsoredDataSize,
+ sponsoredDataSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: true,
},
@@ -58,16 +56,16 @@
const result = getCreateItemResult(events);
// get collection limits defined previously
- const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+ const collectionInfo = await queryCollectionExpectSuccess(api, collectionIdForTesting);
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- expect(collectionInfo.limits.accountTokenOwnershipLimit).to.be.equal(accountTokenOwnershipLimit);
- expect(collectionInfo.limits.sponsoredDataSize).to.be.equal(sponsoredDataSize);
- expect(collectionInfo.limits.tokenLimit).to.be.equal(tokenLimit);
- expect(collectionInfo.limits.sponsorTimeout).to.be.equal(sponsorTimeout);
- expect(collectionInfo.limits.ownerCanTransfer).to.be.true;
- expect(collectionInfo.limits.ownerCanDestroy).to.be.true;
+ expect(collectionInfo.limits.accountTokenOwnershipLimit.unwrap().toNumber()).to.be.equal(accountTokenOwnershipLimit);
+ expect(collectionInfo.limits.sponsoredDataSize.unwrap().toNumber()).to.be.equal(sponsoredDataSize);
+ expect(collectionInfo.limits.tokenLimit.unwrap().toNumber()).to.be.equal(tokenLimit);
+ expect(collectionInfo.limits.sponsorTransferTimeout.unwrap().toNumber()).to.be.equal(sponsorTransferTimeout);
+ expect(collectionInfo.limits.ownerCanTransfer.unwrap().toJSON()).to.be.true;
+ expect(collectionInfo.limits.ownerCanDestroy.unwrap().toJSON()).to.be.true;
});
});
@@ -78,7 +76,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: true,
};
@@ -90,7 +88,9 @@
);
const events1 = await submitTransactionAsync(alice, tx1);
const result1 = getCreateItemResult(events1);
- const collectionInfo1 = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+ expect(result1.success).to.be.true;
+ const collectionInfo1 = await queryCollectionExpectSuccess(api, collectionIdForTesting);
+ expect(collectionInfo1.limits.tokenLimit.unwrap().toNumber()).to.be.equal(tokenLimit);
// The second time
const tx2 = api.tx.nft.setCollectionLimits(
@@ -99,13 +99,9 @@
);
const events2 = await submitTransactionAsync(alice, tx2);
const result2 = getCreateItemResult(events2);
- const collectionInfo2 = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
-
- // tslint:disable-next-line:no-unused-expression
- expect(result1.success).to.be.true;
- expect(collectionInfo1.limits.tokenLimit).to.be.equal(tokenLimit);
expect(result2.success).to.be.true;
- expect(collectionInfo2.limits.tokenLimit).to.be.equal(tokenLimit);
+ const collectionInfo2 = await queryCollectionExpectSuccess(api, collectionIdForTesting);
+ expect(collectionInfo2.limits.tokenLimit.unwrap().toNumber()).to.be.equal(tokenLimit);
});
});
@@ -115,7 +111,7 @@
let tx;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
@@ -130,7 +126,7 @@
{
accountTokenOwnershipLimit,
sponsoredDataSize,
- sponsoredMintSize,
+ // sponsoredMintSize,
tokenLimit,
},
);
@@ -144,7 +140,7 @@
{
accountTokenOwnershipLimit,
sponsoredDataSize,
- sponsoredMintSize,
+ // sponsoredMintSize,
tokenLimit,
},
);
@@ -152,14 +148,14 @@
});
});
it('execute setCollectionLimits from admin collection', async () => {
- await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);
await usingApi(async (api: ApiPromise) => {
tx = api.tx.nft.setCollectionLimits(
collectionIdForTesting,
{
accountTokenOwnershipLimit,
sponsoredDataSize,
- sponsoredMintSize,
+ // sponsoredMintSize,
tokenLimit,
},
);
@@ -173,7 +169,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: false,
ownerCanDestroy: true,
});
@@ -181,7 +177,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: true,
});
@@ -193,7 +189,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: false,
});
@@ -201,7 +197,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: true,
});
@@ -215,7 +211,7 @@
accountTokenOwnershipLimit: accountTokenOwnershipLimit,
sponsoredMintSize: sponsoredDataSize,
tokenLimit: tokenLimit,
- sponsorTimeout: sponsorTimeout,
+ sponsorTransferTimeout,
ownerCanTransfer: true,
ownerCanDestroy: true,
};
tests/src/setCollectionSponsor.test.tsdiffbeforeafterboth--- a/tests/src/setCollectionSponsor.test.ts
+++ b/tests/src/setCollectionSponsor.test.ts
@@ -5,15 +5,15 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi } from './substrate/substrate-api';
-import { createCollectionExpectSuccess,
- setCollectionSponsorExpectSuccess,
- destroyCollectionExpectSuccess,
+import {default as usingApi} from './substrate/substrate-api';
+import {createCollectionExpectSuccess,
+ setCollectionSponsorExpectSuccess,
+ destroyCollectionExpectSuccess,
setCollectionSponsorExpectFailure,
addCollectionAdminExpectSuccess,
} from './util/helpers';
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
chai.use(chaiAsPromised);
@@ -25,7 +25,7 @@
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
});
@@ -36,11 +36,11 @@
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
it('Set Fungible collection sponsor', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: {type: 'Fungible', decimalPoints: 0} });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
it('Set ReFungible collection sponsor', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: {type: 'ReFungible'} });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
});
@@ -52,7 +52,7 @@
it('Replace collection sponsor', async () => {
const collectionId = await createCollectionExpectSuccess();
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
const charlie = keyring.addFromUri('//Charlie');
await setCollectionSponsorExpectSuccess(collectionId, bob.address);
await setCollectionSponsorExpectSuccess(collectionId, charlie.address);
@@ -62,7 +62,7 @@
describe('(!negative test!) integration test: ext. setCollectionSponsor():', () => {
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
charlie = keyring.addFromUri('//Charlie');
@@ -77,7 +77,7 @@
// Find the collection that never existed
let collectionId = 0;
await usingApi(async (api) => {
- collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
});
await setCollectionSponsorExpectFailure(collectionId, bob.address);
@@ -89,7 +89,7 @@
});
it('(!negative test!) Collection admin add sponsor', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await setCollectionSponsorExpectFailure(collectionId, charlie.address, '//Bob');
});
});
tests/src/setConstOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setConstOnChainSchema.test.ts
+++ b/tests/src/setConstOnChainSchema.test.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
@@ -17,17 +17,17 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Shema: any;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let shema: any;
let largeShema: any;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
- Alice = keyring.addFromUri('//Alice');
- Bob = keyring.addFromUri('//Bob');
- Shema = '0x31';
+ const keyring = new Keyring({type: 'sr25519'});
+ alice = keyring.addFromUri('//Alice');
+ bob = keyring.addFromUri('//Bob');
+ shema = '0x31';
largeShema = new Array(4097).fill(0xff);
});
@@ -37,32 +37,31 @@
it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await submitTransactionAsync(Alice, setShema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await submitTransactionAsync(alice, setShema);
});
});
it('Collection admin can set the scheme', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await submitTransactionAsync(Bob, setShema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await submitTransactionAsync(bob, setShema);
});
});
it('Checking collection data using the ConstOnChainSchema parameter', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await submitTransactionAsync(Alice, setShema);
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.constOnChainSchema.toString()).to.be.eq(Shema);
-
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await submitTransactionAsync(alice, setShema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.constOnChainSchema.toString()).to.be.eq(shema);
});
});
});
@@ -72,9 +71,9 @@
it('Set a non-existent collection', async () => {
await usingApi(async (api) => {
// tslint:disable-next-line: radix
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;
+ const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
});
});
@@ -82,8 +81,8 @@
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
});
});
@@ -91,17 +90,17 @@
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
const setShema = api.tx.nft.setConstOnChainSchema(collectionId, largeShema);
- await expect(submitTransactionExpectFailAsync(Alice, setShema)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, setShema)).to.be.rejected;
});
});
it('Execute method not on behalf of the collection owner', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- const setShema = api.tx.nft.setConstOnChainSchema(collectionId, Shema);
- await expect(submitTransactionExpectFailAsync(Bob, setShema)).to.be.rejected;
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ const setShema = api.tx.nft.setConstOnChainSchema(collectionId, shema);
+ await expect(submitTransactionExpectFailAsync(bob, setShema)).to.be.rejected;
});
});
tests/src/setContractSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setContractSponsoringRateLimit.test.ts
+++ b/tests/src/setContractSponsoringRateLimit.test.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import waitNewBlocks from './substrate/wait-new-blocks';
-import { deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess } from './util/contracthelpers';
+import {deployFlipper, toggleFlipValueExpectFailure, toggleFlipValueExpectSuccess} from './util/contracthelpers';
import {
enableContractSponsoringExpectSuccess,
findUnusedAddress,
tests/src/setMintPermission.test.tsdiffbeforeafterboth--- a/tests/src/setMintPermission.test.ts
+++ b/tests/src/setMintPermission.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
@@ -32,7 +32,7 @@
it('ensure white-listed non-privileged address can mint tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
@@ -43,7 +43,7 @@
it('can be enabled twice', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await setMintPermissionExpectSuccess(alice, collectionId, true);
await setMintPermissionExpectSuccess(alice, collectionId, true);
});
@@ -51,7 +51,7 @@
it('can be disabled twice', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await setMintPermissionExpectSuccess(alice, collectionId, true);
await setMintPermissionExpectSuccess(alice, collectionId, false);
await setMintPermissionExpectSuccess(alice, collectionId, false);
@@ -79,7 +79,7 @@
it('fails on removed collection', async () => {
await usingApi(async () => {
- const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const removedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await destroyCollectionExpectSuccess(removedCollectionId);
await setMintPermissionExpectFailure(alice, removedCollectionId, true);
@@ -87,22 +87,22 @@
});
it('fails when not collection owner tries to set mint status', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectFailure(bob, collectionId, true);
});
it('Collection admin fails on set', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
await setMintPermissionExpectFailure(bob, collectionId, true);
});
});
it('ensure non-white-listed non-privileged address can\'t mint tokens', async () => {
await usingApi(async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await enableWhiteListExpectSuccess(alice, collectionId);
await setMintPermissionExpectSuccess(alice, collectionId, true);
tests/src/setOffchainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setOffchainSchema.test.ts
+++ b/tests/src/setOffchainSchema.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
@@ -35,20 +35,24 @@
});
it('execute setOffchainSchema, verify data was set', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await setOffchainSchemaExpectSuccess(alice, collectionId, DATA);
- const collection = await queryCollectionExpectSuccess(collectionId);
+ await usingApi(async api => {
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await setOffchainSchemaExpectSuccess(alice, collectionId, DATA);
+ const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ });
});
it('execute setOffchainSchema (collection admin), verify data was set', async () => {
- const collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
- await setOffchainSchemaExpectSuccess(bob, collectionId, DATA);
- const collection = await queryCollectionExpectSuccess(collectionId);
+ await usingApi(async api => {
+ const collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await setOffchainSchemaExpectSuccess(bob, collectionId, DATA);
+ const collection = await queryCollectionExpectSuccess(api, collectionId);
- expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ expect(collection.offchainSchema).to.be.equal('0x' + Buffer.from(DATA).toString('hex'));
+ });
});
});
@@ -63,7 +67,7 @@
alice = privateKey('//Alice');
bob = privateKey('//Bob');
- validCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ validCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
});
});
@@ -74,7 +78,7 @@
});
it('fails on destroyed collection id', async () => {
- const destroyedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const destroyedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
await destroyCollectionExpectSuccess(destroyedCollectionId);
await setOffchainSchemaExpectFailure(alice, destroyedCollectionId, DATA);
tests/src/setPublicAccessMode.test.tsdiffbeforeafterboth--- a/tests/src/setPublicAccessMode.test.ts
+++ b/tests/src/setPublicAccessMode.test.ts
@@ -4,8 +4,8 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
@@ -24,34 +24,34 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
describe('Integration Test setPublicAccessMode(): ', () => {
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('Run extrinsic with collection id parameters, set the whitelist mode for the collection', async () => {
await usingApi(async () => {
const collectionId: number = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enablePublicMintingExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enablePublicMintingExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);
});
});
it('Whitelisted collection limits', async () => {
await usingApi(async (api: ApiPromise) => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enablePublicMintingExpectSuccess(Alice, collectionId);
- const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(Bob.address), 'NFT');
- await expect(submitTransactionExpectFailAsync(Bob, tx)).to.be.rejected;
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enablePublicMintingExpectSuccess(alice, collectionId);
+ const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(bob.address), 'NFT');
+ await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
});
});
});
@@ -60,9 +60,9 @@
it('Set a non-existent collection', async () => {
await usingApi(async (api: ApiPromise) => {
// tslint:disable-next-line: radix
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
+ const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');
- await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
@@ -72,15 +72,15 @@
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');
- await expect(submitTransactionExpectFailAsync(Alice, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
});
});
it('Re-set the list mode already set in quantity', async () => {
await usingApi(async () => {
const collectionId: number = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await enableWhiteListExpectSuccess(Alice, collectionId);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await enableWhiteListExpectSuccess(alice, collectionId);
});
});
@@ -89,7 +89,7 @@
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');
- await expect(submitTransactionExpectFailAsync(Bob, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
});
});
});
@@ -97,17 +97,17 @@
describe('Negative Integration Test ext. collection admin setPublicAccessMode(): ', () => {
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
});
});
it('setPublicAccessMode by collection admin', async () => {
await usingApi(async (api: ApiPromise) => {
// tslint:disable-next-line: no-bitwise
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
const tx = api.tx.nft.setPublicAccessMode(collectionId, 'WhiteList');
- await expect(submitTransactionExpectFailAsync(Bob, tx)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(bob, tx)).to.be.rejected;
});
});
});
tests/src/setSchemaVersion.test.tsdiffbeforeafterboth--- a/tests/src/setSchemaVersion.test.ts
+++ b/tests/src/setSchemaVersion.test.ts
@@ -4,12 +4,11 @@
//
// https://unique-network.readthedocs.io/en/latest/jsapi.html#setschemaversion
-import { ApiPromise, Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise, Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
-import { ICollectionInterface } from './types';
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
@@ -25,42 +24,27 @@
let alice: IKeyringPair;
let bob: IKeyringPair;
let charlie: IKeyringPair;
-let collectionIdForTesting: number;
/*
1. We create collection.
2. Save just created collection id.
3. Use this id for setSchemaVersion.
*/
-
-describe('hooks', () => {
- before(async () => {
- await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
- alice = keyring.addFromUri('//Alice');
- });
- });
- it('choose or create collection for testing', async () => {
- await usingApi(async () => {
- collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
- });
- });
-});
-
describe('setSchemaVersion positive', () => {
let tx;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
});
});
it('execute setSchemaVersion with image url and unique ', async () => {
await usingApi(async (api: ApiPromise) => {
+ const collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');
const events = await submitTransactionAsync(alice, tx);
const result = getCreateItemResult(events);
- const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+ const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
// tslint:disable-next-line:no-unused-expression
@@ -73,12 +57,15 @@
describe('Collection admin setSchemaVersion positive', () => {
let tx;
+ let collectionIdForTesting: any;
+
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
bob = keyring.addFromUri('//Bob');
- await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob);
+ collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
+ await addCollectionAdminExpectSuccess(alice, collectionIdForTesting, bob.address);
});
});
it('execute setSchemaVersion with image url and unique ', async () => {
@@ -86,7 +73,7 @@
tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Unique');
const events = await submitTransactionAsync(bob, tx);
const result = getCreateItemResult(events);
- const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+ const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
// tslint:disable-next-line:no-unused-expression
@@ -101,7 +88,7 @@
tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'ImageURL');
const events = await submitTransactionAsync(bob, tx);
const result = getCreateItemResult(events);
- const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting) as ICollectionInterface;
+ const collectionInfo = await getDetailedCollectionInfo(api, collectionIdForTesting);
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
// tslint:disable-next-line:no-unused-expression
@@ -114,11 +101,13 @@
describe('setSchemaVersion negative', () => {
let tx;
+ let collectionIdForTesting: any;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
alice = keyring.addFromUri('//Alice');
charlie = keyring.addFromUri('//Charlie');
+ collectionIdForTesting = await createCollectionExpectSuccess({name: 'A', description: 'B', tokenPrefix: 'C', mode: {type: 'NFT'}});
});
});
it('execute setSchemaVersion for not exists collection', async () => {
@@ -127,21 +116,6 @@
const nonExistedCollectionId = collectionCount + 1;
tx = api.tx.nft.setSchemaVersion(nonExistedCollectionId, 'ImageURL');
await expect(submitTransactionExpectFailAsync(alice, tx)).to.be.rejected;
- });
- });
- it('execute setSchemaVersion with not correct schema version', async () => {
- await usingApi(async (api: ApiPromise) => {
- const consoleError = console.error;
- console.error = () => {};
- try {
- tx = api.tx.nft.setSchemaVersion(collectionIdForTesting, 'Test');
- await submitTransactionAsync(alice, tx);
- } catch (e) {
- // tslint:disable-next-line:no-unused-expression
- expect(e).to.be.exist;
- } finally {
- console.error = consoleError;
- }
});
});
it('execute setSchemaVersion for deleted collection', async () => {
tests/src/setVariableMetaData.test.tsdiffbeforeafterboth--- a/tests/src/setVariableMetaData.test.ts
+++ b/tests/src/setVariableMetaData.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
@@ -18,6 +18,7 @@
setVariableMetaDataExpectSuccess,
addCollectionAdminExpectSuccess,
setMetadataUpdatePermissionFlagExpectSuccess,
+ getVariableMetadata,
} from './util/helpers';
chai.use(chaiAsPromised);
@@ -32,7 +33,7 @@
before(async () => {
await usingApi(async () => {
alice = privateKey('//Alice');
- collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
});
});
@@ -43,9 +44,7 @@
it('verify data was set', async () => {
await usingApi(async api => {
- const item: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();
-
- expect(Array.from(item.variableData)).to.deep.equal(Array.from(data));
+ expect(await getVariableMetadata(api, collectionId, tokenId)).to.deep.equal(data);
});
});
});
@@ -61,10 +60,10 @@
await usingApi(async () => {
alice = privateKey('//Alice');
bob = privateKey('//Bob');
- collectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ collectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
tokenId = await createItemExpectSuccess(alice, collectionId, 'NFT');
await setMetadataUpdatePermissionFlagExpectSuccess(alice, collectionId, 'Admin');
- await addCollectionAdminExpectSuccess(alice, collectionId, bob);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
});
});
@@ -74,9 +73,7 @@
it('verify data was set', async () => {
await usingApi(async api => {
- const item: any = (await api.query.nft.nftItemList(collectionId, tokenId) as any).unwrap();
-
- expect(Array.from(item.variableData)).to.deep.equal(Array.from(data));
+ expect(await getVariableMetadata(api, collectionId, tokenId)).to.deep.equal(data);
});
});
});
@@ -95,7 +92,7 @@
alice = privateKey('//Alice');
bob = privateKey('//Bob');
- validCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ validCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
validTokenId = await createItemExpectSuccess(alice, validCollectionId, 'NFT');
});
});
@@ -107,14 +104,14 @@
});
});
it('fails on removed collection id', async () => {
- const removedCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const removedCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const removedCollectionTokenId = await createItemExpectSuccess(alice, removedCollectionId, 'NFT');
await destroyCollectionExpectSuccess(removedCollectionId);
await setVariableMetaDataExpectFailure(alice, removedCollectionId, removedCollectionTokenId, data);
});
it('fails on removed token', async () => {
- const removedTokenCollectionId = await createCollectionExpectSuccess({ mode: { type: 'NFT' } });
+ const removedTokenCollectionId = await createCollectionExpectSuccess({mode: {type: 'NFT'}});
const removedTokenId = await createItemExpectSuccess(alice, removedTokenCollectionId, 'NFT');
await burnItemExpectSuccess(alice, removedTokenCollectionId, removedTokenId);
@@ -131,7 +128,7 @@
await setVariableMetaDataExpectFailure(alice, validCollectionId, validTokenId, tooLongData);
});
it('fails on fungible token', async () => {
- const fungibleCollectionId = await createCollectionExpectSuccess({ mode: { type: 'Fungible', decimalPoints: 0 } });
+ const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
const fungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
await setVariableMetaDataExpectFailure(alice, fungibleCollectionId, fungibleTokenId, data);
tests/src/setVariableMetadataSponsoringRateLimit.test.tsdiffbeforeafterboth--- a/tests/src/setVariableMetadataSponsoringRateLimit.test.ts
+++ b/tests/src/setVariableMetadataSponsoringRateLimit.test.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
import usingApi from './substrate/substrate-api';
import {
tests/src/setVariableOnChainSchema.test.tsdiffbeforeafterboth--- a/tests/src/setVariableOnChainSchema.test.ts
+++ b/tests/src/setVariableOnChainSchema.test.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
createCollectionExpectSuccess,
destroyCollectionExpectSuccess,
@@ -17,17 +17,17 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Schema: any;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let schema: any;
let largeSchema: any;
before(async () => {
await usingApi(async () => {
- const keyring = new Keyring({ type: 'sr25519' });
- Alice = keyring.addFromUri('//Alice');
- Bob = keyring.addFromUri('//Bob');
- Schema = '0x31';
+ const keyring = new Keyring({type: 'sr25519'});
+ alice = keyring.addFromUri('//Alice');
+ bob = keyring.addFromUri('//Bob');
+ schema = '0x31';
largeSchema = new Array(4097).fill(0xff);
});
@@ -37,20 +37,20 @@
it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await submitTransactionAsync(Alice, setSchema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await submitTransactionAsync(alice, setSchema);
});
});
it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await submitTransactionAsync(Alice, setSchema);
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.variableOnChainSchema.toString()).to.be.eq(Schema);
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await submitTransactionAsync(alice, setSchema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
});
});
@@ -61,22 +61,22 @@
it('Run extrinsic with parameters of the collection id, set the scheme', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await submitTransactionAsync(Bob, setSchema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await submitTransactionAsync(bob, setSchema);
});
});
it('Checking collection data using the setVariableOnChainSchema parameter', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await submitTransactionAsync(Bob, setSchema);
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.variableOnChainSchema.toString()).to.be.eq(Schema);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await submitTransactionAsync(bob, setSchema);
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.variableOnChainSchema.toString()).to.be.eq(schema);
});
});
@@ -87,9 +87,9 @@
it('Set a non-existent collection', async () => {
await usingApi(async (api) => {
// tslint:disable-next-line: radix
- const collectionId = parseInt((await api.query.nft.createdCollectionCount()).toString()) + 1;
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+ const collectionId = (await api.query.common.createdCollectionCount()).toNumber() + 1;
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
});
});
@@ -97,8 +97,8 @@
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId);
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
});
});
@@ -106,17 +106,17 @@
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, largeSchema);
- await expect(submitTransactionExpectFailAsync(Alice, setSchema)).to.be.rejected;
+ await expect(submitTransactionExpectFailAsync(alice, setSchema)).to.be.rejected;
});
});
it('Execute method not on behalf of the collection owner', async () => {
await usingApi(async (api) => {
const collectionId = await createCollectionExpectSuccess();
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
- expect(collection.owner).to.be.eq(Alice.address);
- const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, Schema);
- await expect(submitTransactionExpectFailAsync(Bob, setSchema)).to.be.rejected;
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
+ expect(collection.owner.toString()).to.be.eq(alice.address);
+ const setSchema = api.tx.nft.setVariableOnChainSchema(collectionId, schema);
+ await expect(submitTransactionExpectFailAsync(bob, setSchema)).to.be.rejected;
});
});
tests/src/substrate/get-balance.tsdiffbeforeafterboth--- a/tests/src/substrate/get-balance.ts
+++ b/tests/src/substrate/get-balance.ts
@@ -3,13 +3,13 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
+import {ApiPromise} from '@polkadot/api';
import {AccountInfo} from '@polkadot/types/interfaces/system';
import promisifySubstrate from './promisify-substrate';
-import { IKeyringPair } from '@polkadot/types/types';
-import { submitTransactionAsync } from './substrate-api';
-import { getGenericResult } from '../util/helpers';
-import { expect } from 'chai';
+import {IKeyringPair} from '@polkadot/types/types';
+import {submitTransactionAsync} from './substrate-api';
+import {getGenericResult} from '../util/helpers';
+import {expect} from 'chai';
export default async function getBalance(api: ApiPromise, accounts: string[]): Promise<Array<bigint>> {
const balance = promisifySubstrate(api, (acc: string[]) => api.query.system.account.multi(acc));
@@ -26,4 +26,4 @@
const events = await submitTransactionAsync(from, tx);
const result = getGenericResult(events);
expect(result.success).to.be.true;
-}
\ No newline at end of file
+}
tests/src/substrate/privateKey.tsdiffbeforeafterboth--- a/tests/src/substrate/privateKey.ts
+++ b/tests/src/substrate/privateKey.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { Keyring } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {Keyring} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
export default function privateKey(account: string): IKeyringPair {
- const keyring = new Keyring({ type: 'sr25519' });
-
+ const keyring = new Keyring({type: 'sr25519'});
+
return keyring.addFromUri(account);
-}
\ No newline at end of file
+}
tests/src/substrate/promisify-substrate.tsdiffbeforeafterboth--- a/tests/src/substrate/promisify-substrate.ts
+++ b/tests/src/substrate/promisify-substrate.ts
@@ -3,7 +3,7 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
+import {ApiPromise} from '@polkadot/api';
type PromiseType<T> = T extends PromiseLike<infer TInner> ? TInner : T;
@@ -25,7 +25,7 @@
reject && reject(error);
cleanup();
};
-
+
api.on('disconnected', fail);
api.on('error', fail);
tests/src/substrate/rpc_defs.jsondiffbeforeafterboth--- a/tests/src/substrate/rpc_defs.json
+++ /dev/null
@@ -1,76 +0,0 @@
-{
- "nft": {
- "accountBalance": {
- "description": "Get amount of different user tokens",
- "params": [
- {
- "name": "collectionId",
- "type": "CollectionId"
- },
- {
- "name": "account",
- "type": "CrossAccountId"
- },
- {
- "isOptional": true,
- "name": "at",
- "type": "Hash"
- }
- ],
- "type": "u32"
- },
- "adminlist": {
- "description": "Get admin list",
- "params": [
- {
- "name": "collectionId",
- "type": "CollectionId"
- },
- {
- "isOptional": true,
- "name": "at",
- "type": "Hash"
- }
- ],
- "type": "Vec<AccountId>"
- },
- "balance": {
- "description": "Get amount of specific account token",
- "params": [
- {
- "name": "collectionId",
- "type": "CollectionId"
- },
- {
- "name": "account",
- "type": "CrossAccountId"
- },
- {
- "name": "tokenId",
- "type": "TokenId"
- },
- {
- "isOptional": true,
- "name": "at",
- "type": "Hash"
- }
- ],
- "type": "u128"
- },
- "lastTokenId": {
- "description": "Get last token id",
- "params": [
- {
- "name": "collectionId",
- "type": "CollectionId"
- },
- {
- "isOptional": true,
- "name": "at",
- "type": "Hash"
- }
- ],
- "type": "TokenId"
- }
- }
-}
tests/src/substrate/substrate-api.tsdiffbeforeafterboth--- a/tests/src/substrate/substrate-api.ts
+++ b/tests/src/substrate/substrate-api.ts
@@ -3,14 +3,16 @@
// file 'LICENSE', which is part of this source code package.
//
-import { WsProvider, ApiPromise } from '@polkadot/api';
-import { EventRecord } from '@polkadot/types/interfaces/system/types';
-import { ExtrinsicStatus } from '@polkadot/types/interfaces/author/types';
-import { IKeyringPair } from '@polkadot/types/types';
+import {WsProvider, ApiPromise} from '@polkadot/api';
+import {EventRecord} from '@polkadot/types/interfaces/system/types';
+import {ExtrinsicStatus} from '@polkadot/types/interfaces/author/types';
+import {IKeyringPair} from '@polkadot/types/types';
import config from '../config';
import promisifySubstrate from './promisify-substrate';
-import { ApiOptions, SubmittableExtrinsic, ApiTypes } from '@polkadot/api/types';
+import {ApiOptions, SubmittableExtrinsic, ApiTypes} from '@polkadot/api/types';
+import * as defs from '../interfaces/definitions';
+
function defaultApiOptions(): ApiOptions {
const wsProvider = new WsProvider(config.substrateUrl);
@@ -21,6 +23,9 @@
payload: {},
},
},
+ rpc: {
+ nft: defs.nft.rpc,
+ },
};
}
@@ -35,20 +40,19 @@
const consoleLog = console.log;
const consoleWarn = console.warn;
- const outFn = (message: string) => {
- if (typeof message !== 'string') {
- consoleErr(message);
- return;
+ const outFn = (printer: any) => (...args: any[]) => {
+ for (const arg of args) {
+ if (typeof arg !== 'string')
+ continue;
+ if (arg.includes('1000:: Normal connection closure' || arg === 'Normal connection closure'))
+ return;
}
- if (!message.includes('StorageChangeSet:: WebSocket is not connected') &&
- !message.includes('2021-') &&
- !message.includes('StorageChangeSet:: Normal connection closure'))
- consoleErr(message);
+ printer(...args);
};
- console.error = outFn;
- console.log = outFn;
- console.warn = outFn;
+ console.error = outFn(consoleErr.bind(console));
+ console.log = outFn(consoleLog.bind(console));
+ console.warn = outFn(consoleWarn.bind(console));
try {
await promisifySubstrate(api, async () => {
@@ -96,7 +100,7 @@
/* eslint no-async-promise-executor: "off" */
return new Promise(async (resolve, reject) => {
try {
- await transaction.signAndSend(sender, ({ events = [], status }) => {
+ await transaction.signAndSend(sender, ({events = [], status}) => {
const transactionStatus = getTransactionStatus(events, status);
if (transactionStatus === TransactionStatus.Success) {
@@ -114,8 +118,6 @@
}
export function submitTransactionExpectFailAsync(sender: IKeyringPair, transaction: SubmittableExtrinsic<ApiTypes>): Promise<EventRecord[]> {
- const consoleError = console.error;
- const consoleLog = console.log;
console.error = () => {};
console.log = () => {};
@@ -124,19 +126,15 @@
const resolve = (rec: EventRecord[]) => {
setTimeout(() => {
res(rec);
- console.error = consoleError;
- console.log = consoleLog;
});
};
const reject = (errror: any) => {
setTimeout(() => {
rej(errror);
- console.error = consoleError;
- console.log = consoleLog;
});
};
try {
- await transaction.signAndSend(sender, ({ events = [], status }) => {
+ await transaction.signAndSend(sender, ({events = [], status}) => {
const transactionStatus = getTransactionStatus(events, status);
// console.log('transactionStatus', transactionStatus, 'events', events);
tests/src/substrate/wait-new-blocks.tsdiffbeforeafterboth--- a/tests/src/substrate/wait-new-blocks.ts
+++ b/tests/src/substrate/wait-new-blocks.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
+import {ApiPromise} from '@polkadot/api';
/* eslint no-async-promise-executor: "off" */
export default function waitNewBlocks(api: ApiPromise, blocksCount = 1): Promise<void> {
const promise = new Promise<void>(async (resolve) => {
-
+
const unsubscribe = await api.rpc.chain.subscribeNewHeads(() => {
if (blocksCount > 0) {
blocksCount--;
@@ -20,4 +20,4 @@
});
return promise;
-}
\ No newline at end of file
+}
tests/src/toggleContractWhiteList.test.tsdiffbeforeafterboth--- a/tests/src/toggleContractWhiteList.test.ts
+++ b/tests/src/toggleContractWhiteList.test.ts
@@ -5,7 +5,7 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import usingApi, { submitTransactionAsync, submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';
import privateKey from './substrate/privateKey';
import {
deployFlipper,
tests/src/transfer.nload.tsdiffbeforeafterboth--- a/tests/src/transfer.nload.ts
+++ b/tests/src/transfer.nload.ts
@@ -3,12 +3,12 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import privateKey from './substrate/privateKey';
-import usingApi, { submitTransactionAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionAsync} from './substrate/substrate-api';
import waitNewBlocks from './substrate/wait-new-blocks';
-import { findUnusedAddresses } from './util/helpers';
+import {findUnusedAddresses} from './util/helpers';
import * as cluster from 'cluster';
import os from 'os';
@@ -115,4 +115,4 @@
flushCounterToMaster();
}, 100);
interval.unref();
-}
\ No newline at end of file
+}
tests/src/transfer.test.tsdiffbeforeafterboth--- a/tests/src/transfer.test.ts
+++ b/tests/src/transfer.test.ts
@@ -3,13 +3,13 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
-import { expect } from 'chai';
-import { alicesPublicKey, bobsPublicKey } from './accounts';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
+import {expect} from 'chai';
+import {alicesPublicKey, bobsPublicKey} from './accounts';
import getBalance from './substrate/get-balance';
import privateKey from './substrate/privateKey';
-import { default as usingApi, submitTransactionAsync } from './substrate/substrate-api';
+import {default as usingApi, submitTransactionAsync} from './substrate/substrate-api';
import {
burnItemExpectSuccess, createCollectionExpectSuccess, createItemExpectSuccess,
destroyCollectionExpectSuccess,
@@ -21,9 +21,9 @@
addCollectionAdminExpectSuccess,
} from './util/helpers';
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Charlie: IKeyringPair;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let charlie: IKeyringPair;
describe('Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
it('Balance transfers and check balance', async () => {
@@ -66,25 +66,25 @@
it('User can transfer owned token', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob, 1, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, alice, bob, 1, 'NFT');
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1, 'Fungible');
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
await transferExpectSuccess(
reFungibleCollectionId,
newReFungibleTokenId,
- Alice,
- Bob,
+ alice,
+ bob,
100,
'ReFungible',
);
@@ -93,27 +93,27 @@
it('Collection admin can transfer owned token', async () => {
await usingApi(async () => {
- const Alice = privateKey('//Alice');
- const Bob = privateKey('//Bob');
+ const alice = privateKey('//Alice');
+ const bob = privateKey('//Bob');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, nftCollectionId, Bob);
- const newNftTokenId = await createItemExpectSuccess(Bob, nftCollectionId, 'NFT', Bob.address);
- await transferExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, 1, 'NFT');
+ await addCollectionAdminExpectSuccess(alice, nftCollectionId, bob.address);
+ const newNftTokenId = await createItemExpectSuccess(bob, nftCollectionId, 'NFT', bob.address);
+ await transferExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, 1, 'NFT');
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await addCollectionAdminExpectSuccess(Alice, fungibleCollectionId, Bob);
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible', Bob.address);
- await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, 1, 'Fungible');
+ await addCollectionAdminExpectSuccess(alice, fungibleCollectionId, bob.address);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible', bob.address);
+ await transferExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- await addCollectionAdminExpectSuccess(Alice, reFungibleCollectionId, Bob);
- const newReFungibleTokenId = await createItemExpectSuccess(Bob, reFungibleCollectionId, 'ReFungible', Bob.address);
+ await addCollectionAdminExpectSuccess(alice, reFungibleCollectionId, bob.address);
+ const newReFungibleTokenId = await createItemExpectSuccess(bob, reFungibleCollectionId, 'ReFungible', bob.address);
await transferExpectSuccess(
reFungibleCollectionId,
newReFungibleTokenId,
- Bob,
- Alice,
+ bob,
+ alice,
100,
'ReFungible',
);
@@ -124,108 +124,108 @@
describe('Negative Integration Test Transfer(recipient, collection_id, item_id, value)', () => {
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Transfer with not existed collection_id', async () => {
await usingApi(async (api) => {
// nft
- const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFailure(nftCollectionCount + 1, 1, Alice, Bob, 1);
+ const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await transferExpectFailure(nftCollectionCount + 1, 1, alice, bob, 1);
// fungible
- const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFailure(fungibleCollectionCount + 1, 1, Alice, Bob, 1);
+ const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await transferExpectFailure(fungibleCollectionCount + 1, 0, alice, bob, 1);
// reFungible
- const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await transferExpectFailure(reFungibleCollectionCount + 1, 1, Alice, Bob, 1);
+ const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await transferExpectFailure(reFungibleCollectionCount + 1, 1, alice, bob, 1);
});
});
it('Transfer with deleted collection_id', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
await destroyCollectionExpectSuccess(nftCollectionId);
- await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
await destroyCollectionExpectSuccess(fungibleCollectionId);
- await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
await destroyCollectionExpectSuccess(reFungibleCollectionId);
await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
- Alice,
- Bob,
+ alice,
+ bob,
1,
);
});
it('Transfer with not existed item_id', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- await transferExpectFailure(nftCollectionId, 2, Alice, Bob, 1);
+ await transferExpectFailure(nftCollectionId, 2, alice, bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- await transferExpectFailure(fungibleCollectionId, 2, Alice, Bob, 1);
+ await transferExpectFailure(fungibleCollectionId, 2, alice, bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
await transferExpectFailure(
reFungibleCollectionId,
2,
- Alice,
- Bob,
+ alice,
+ bob,
1,
);
});
it('Transfer with deleted item_id', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
- await transferExpectFailure(nftCollectionId, newNftTokenId, Alice, Bob, 1);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
+ await transferExpectFailure(nftCollectionId, newNftTokenId, alice, bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await burnItemExpectSuccess(Alice, fungibleCollectionId, newFungibleTokenId, 10);
- await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Alice, Bob, 1);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, alice, bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 100);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
- Alice,
- Bob,
+ alice,
+ bob,
1,
);
});
it('Transfer with recipient that is not owner', async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await transferExpectFailure(nftCollectionId, newNftTokenId, Charlie, Bob, 1);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await transferExpectFailure(nftCollectionId, newNftTokenId, charlie, bob, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, Charlie, Bob, 1);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await transferExpectFailure(fungibleCollectionId, newFungibleTokenId, charlie, bob, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
await transferExpectFailure(
reFungibleCollectionId,
newReFungibleTokenId,
- Charlie,
- Bob,
+ charlie,
+ bob,
1,
);
});
tests/src/transferFrom.test.tsdiffbeforeafterboth--- a/tests/src/transferFrom.test.ts
+++ b/tests/src/transferFrom.test.ts
@@ -2,12 +2,12 @@
// This file is subject to the terms and conditions defined in
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise } from '@polkadot/api';
-import { IKeyringPair } from '@polkadot/types/types';
+import {ApiPromise} from '@polkadot/api';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import { default as usingApi } from './substrate/substrate-api';
+import {default as usingApi} from './substrate/substrate-api';
import {
approveExpectFail,
approveExpectSuccess,
@@ -25,15 +25,15 @@
const expect = chai.expect;
describe('Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
@@ -41,28 +41,28 @@
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
- await transferFromExpectSuccess(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1, 'NFT');
+ await transferFromExpectSuccess(nftCollectionId, newNftTokenId, bob, alice, charlie, 1, 'NFT');
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
- await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1, 'Fungible');
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
+ await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1, 'Fungible');
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob, 100);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address, 100);
await transferFromExpectSuccess(
reFungibleCollectionId,
newReFungibleTokenId,
- Bob,
- Alice,
- Charlie,
+ bob,
+ alice,
+ charlie,
100,
'ReFungible',
);
@@ -70,60 +70,60 @@
});
it('Should reduce allowance if value is big', async () => {
- await usingApi(async () => {
+ await usingApi(async (api) => {
const alice = privateKey('//Alice');
const bob = privateKey('//Bob');
const charlie = privateKey('//Charlie');
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createFungibleItemExpectSuccess(alice, fungibleCollectionId, { Value: 500000n });
+ const newFungibleTokenId = await createFungibleItemExpectSuccess(alice, fungibleCollectionId, {Value: 500000n});
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob, 500000n);
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address, 500000n);
await transferFromExpectSuccess(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 500000n, 'Fungible');
- expect((await getAllowance(fungibleCollectionId, newFungibleTokenId, alice.address, bob.address)).toString()).to.equal('0');
+ expect(await getAllowance(api, fungibleCollectionId, alice.address, bob.address, newFungibleTokenId)).to.equal(0n);
});
});
it('can be called by collection owner on non-owned item when OwnerCanTransfer == true', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
- await transferFromExpectSuccess(collectionId, itemId, Alice, Bob, Charlie);
+ await transferFromExpectSuccess(collectionId, itemId, alice, bob, charlie);
});
});
describe('Negative Integration Test transferFrom(from, recipient, collection_id, item_id, value):', () => {
- let Alice: IKeyringPair;
- let Bob: IKeyringPair;
- let Charlie: IKeyringPair;
+ let alice: IKeyringPair;
+ let bob: IKeyringPair;
+ let charlie: IKeyringPair;
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('transferFrom for a collection that does not exist', async () => {
await usingApi(async (api: ApiPromise) => {
// nft
- const nftCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(nftCollectionCount + 1, 1, Alice, Bob);
+ const nftCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(nftCollectionCount + 1, 1, alice, bob);
- await transferFromExpectFail(nftCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+ await transferFromExpectFail(nftCollectionCount + 1, 1, bob, alice, charlie, 1);
// fungible
- const fungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(fungibleCollectionCount + 1, 1, Alice, Bob);
+ const fungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(fungibleCollectionCount + 1, 0, alice, bob);
- await transferFromExpectFail(fungibleCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+ await transferFromExpectFail(fungibleCollectionCount + 1, 0, bob, alice, charlie, 1);
// reFungible
- const reFungibleCollectionCount = await api.query.nft.createdCollectionCount() as unknown as number;
- await approveExpectFail(reFungibleCollectionCount + 1, 1, Alice, Bob);
+ const reFungibleCollectionCount = (await api.query.common.createdCollectionCount()).toNumber();
+ await approveExpectFail(reFungibleCollectionCount + 1, 1, alice, bob);
- await transferFromExpectFail(reFungibleCollectionCount + 1, 1, Bob, Alice, Charlie, 1);
+ await transferFromExpectFail(reFungibleCollectionCount + 1, 1, bob, alice, charlie, 1);
});
});
@@ -149,24 +149,24 @@
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
- await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 1);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
await transferFromExpectFail(
reFungibleCollectionId,
newReFungibleTokenId,
- Bob,
- Alice,
- Charlie,
+ bob,
+ alice,
+ charlie,
1,
);
});
@@ -176,27 +176,27 @@
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
- await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 2);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 2);
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
- await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 2);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 2);
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
await transferFromExpectFail(
reFungibleCollectionId,
newReFungibleTokenId,
- Bob,
- Alice,
- Charlie,
+ bob,
+ alice,
+ charlie,
2,
);
});
@@ -204,13 +204,13 @@
it('execute transferFrom from account that is not owner of collection', async () => {
await usingApi(async () => {
- const Dave = privateKey('//Dave');
+ const dave = privateKey('//Dave');
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
try {
- await approveExpectFail(nftCollectionId, newNftTokenId, Dave, Bob);
- await transferFromExpectFail(nftCollectionId, newNftTokenId, Dave, Alice, Charlie, 1);
+ await approveExpectFail(nftCollectionId, newNftTokenId, dave, bob);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, dave, alice, charlie, 1);
} catch (e) {
// tslint:disable-next-line:no-unused-expression
expect(e).to.be.exist;
@@ -220,10 +220,10 @@
// fungible
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
try {
- await approveExpectFail(fungibleCollectionId, newFungibleTokenId, Dave, Bob);
- await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Dave, Alice, Charlie, 1);
+ await approveExpectFail(fungibleCollectionId, newFungibleTokenId, dave, bob);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, dave, alice, charlie, 1);
} catch (e) {
// tslint:disable-next-line:no-unused-expression
expect(e).to.be.exist;
@@ -231,83 +231,83 @@
// reFungible
const reFungibleCollectionId = await
createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
try {
- await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Bob);
- await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Dave, Alice, Charlie, 1);
+ await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, bob);
+ await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, dave, alice, charlie, 1);
} catch (e) {
// tslint:disable-next-line:no-unused-expression
expect(e).to.be.exist;
}
});
});
- it( 'transferFrom burnt token before approve NFT', async () => {
+ it('transferFrom burnt token before approve NFT', async () => {
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
- await approveExpectFail(nftCollectionId, newNftTokenId, Alice, Bob);
- await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
+ await approveExpectFail(nftCollectionId, newNftTokenId, alice, bob);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 1);
});
});
- it( 'transferFrom burnt token before approve Fungible', async () => {
+ it('transferFrom burnt token before approve Fungible', async () => {
await usingApi(async () => {
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
- await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1);
});
});
- it( 'transferFrom burnt token before approve ReFungible', async () => {
+ it('transferFrom burnt token before approve ReFungible', async () => {
await usingApi(async () => {
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 100);
- await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
- await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
+ await approveExpectFail(reFungibleCollectionId, newReFungibleTokenId, alice, bob);
+ await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, alice, charlie, 1);
});
});
- it( 'transferFrom burnt token after approve NFT', async () => {
+ it('transferFrom burnt token after approve NFT', async () => {
await usingApi(async () => {
// nft
const nftCollectionId = await createCollectionExpectSuccess();
- const newNftTokenId = await createItemExpectSuccess(Alice, nftCollectionId, 'NFT');
- await approveExpectSuccess(nftCollectionId, newNftTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, nftCollectionId, newNftTokenId, 1);
- await transferFromExpectFail(nftCollectionId, newNftTokenId, Bob, Alice, Charlie, 1);
+ const newNftTokenId = await createItemExpectSuccess(alice, nftCollectionId, 'NFT');
+ await approveExpectSuccess(nftCollectionId, newNftTokenId, alice, bob.address);
+ await burnItemExpectSuccess(alice, nftCollectionId, newNftTokenId, 1);
+ await transferFromExpectFail(nftCollectionId, newNftTokenId, bob, alice, charlie, 1);
});
});
- it( 'transferFrom burnt token after approve Fungible', async () => {
+ it('transferFrom burnt token after approve Fungible', async () => {
await usingApi(async () => {
const fungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});
- const newFungibleTokenId = await createItemExpectSuccess(Alice, fungibleCollectionId, 'Fungible');
- await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, fungibleCollectionId, 1, 10);
- await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, Bob, Alice, Charlie, 1);
+ const newFungibleTokenId = await createItemExpectSuccess(alice, fungibleCollectionId, 'Fungible');
+ await approveExpectSuccess(fungibleCollectionId, newFungibleTokenId, alice, bob.address);
+ await burnItemExpectSuccess(alice, fungibleCollectionId, newFungibleTokenId, 10);
+ await transferFromExpectFail(fungibleCollectionId, newFungibleTokenId, bob, alice, charlie, 1);
});
});
- it( 'transferFrom burnt token after approve ReFungible', async () => {
+ it('transferFrom burnt token after approve ReFungible', async () => {
await usingApi(async () => {
const reFungibleCollectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});
- const newReFungibleTokenId = await createItemExpectSuccess(Alice, reFungibleCollectionId, 'ReFungible');
- await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, Alice, Bob);
- await burnItemExpectSuccess(Alice, reFungibleCollectionId, newReFungibleTokenId, 100);
- await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, Bob, Alice, Charlie, 1);
+ const newReFungibleTokenId = await createItemExpectSuccess(alice, reFungibleCollectionId, 'ReFungible');
+ await approveExpectSuccess(reFungibleCollectionId, newReFungibleTokenId, alice, bob.address);
+ await burnItemExpectSuccess(alice, reFungibleCollectionId, newReFungibleTokenId, 100);
+ await transferFromExpectFail(reFungibleCollectionId, newReFungibleTokenId, bob, alice, charlie, 1);
});
});
it('fails when called by collection owner on non-owned item when OwnerCanTransfer == false', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Bob.address);
- await setCollectionLimitsExpectSuccess(Alice, collectionId, { ownerCanTransfer: false });
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', bob.address);
+ await setCollectionLimitsExpectSuccess(alice, collectionId, {ownerCanTransfer: false});
- await transferFromExpectFail(collectionId, itemId, Alice, Bob, Charlie);
+ await transferFromExpectFail(collectionId, itemId, alice, bob, charlie);
});
});
tests/src/types.tsdiffbeforeafterboth--- a/tests/src/types.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-//
-// This file is subject to the terms and conditions defined in
-// file 'LICENSE', which is part of this source code package.
-//
-
-import BN from 'bn.js';
-
-export interface ICollectionInterface {
- access: string;
- id: number;
- decimalPoints: BN;
- // constOnChainSchema
- description: [BN, BN]; // utf16
- isReFungible: boolean;
- limits: {
- accountTokenOwnershipLimit: number;
- sponsoredDataSize: number;
- sponsoredDataRateLimit?: number,
- tokenLimit: number;
- sponsorTimeout: number;
- ownerCanTransfer: boolean;
- ownerCanDestroy: boolean;
- };
- mintMode: boolean;
- mode: {
- nft: null;
- };
- name: [BN, BN]; // utf16
- offchainSchema: [Uint8Array];
- owner: [Uint8Array];
- schemaVersion: string;
- // prefix
- // sponsor
- // tokenPrefix
- // unconfirmedSponsor
- // variableOnChainSchema
-}
tests/src/util/contracthelpers.tsdiffbeforeafterboth--- a/tests/src/util/contracthelpers.ts
+++ b/tests/src/util/contracthelpers.ts
@@ -5,16 +5,15 @@
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
+import {submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
import fs from 'fs';
-import { Abi, CodePromise, ContractPromise as Contract } from '@polkadot/api-contract';
-import { IKeyringPair } from '@polkadot/types/types';
-import { ApiPromise, Keyring } from '@polkadot/api';
+import {Abi, CodePromise, ContractPromise as Contract} from '@polkadot/api-contract';
+import {IKeyringPair} from '@polkadot/types/types';
+import {ApiPromise, Keyring} from '@polkadot/api';
chai.use(chaiAsPromised);
const expect = chai.expect;
-import { BigNumber } from 'bignumber.js';
-import { findUnusedAddress, getGenericResult } from '../util/helpers';
+import {findUnusedAddress, getGenericResult} from '../util/helpers';
const value = 0;
const gasLimit = '200000000000';
@@ -40,11 +39,10 @@
const deployer = await findUnusedAddress(api);
// Transfer balance to it
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
const alice = keyring.addFromUri('//Alice');
- let amount = new BigNumber(endowment);
- amount = amount.plus(100e15);
- const tx = api.tx.balances.transfer(deployer.address, amount.toFixed());
+ const amount = BigInt(endowment) + 10n**15n;
+ const tx = api.tx.balances.transfer(deployer.address, amount);
await submitTransactionAsync(alice, tx);
return deployer;
tests/src/util/helpers.tsdiffbeforeafterboth--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -3,51 +3,67 @@
// file 'LICENSE', which is part of this source code package.
//
-import { ApiPromise, Keyring } from '@polkadot/api';
-import type { AccountId, EventRecord } from '@polkadot/types/interfaces';
-import { IKeyringPair } from '@polkadot/types/types';
-import { evmToAddress } from '@polkadot/util-crypto';
-import { BigNumber } from 'bignumber.js';
+import {ApiPromise, Keyring} from '@polkadot/api';
+import type {AccountId, EventRecord} from '@polkadot/types/interfaces';
+import {IKeyringPair} from '@polkadot/types/types';
+import {evmToAddress} from '@polkadot/util-crypto';
import BN from 'bn.js';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
-import { alicesPublicKey } from '../accounts';
+import {alicesPublicKey} from '../accounts';
+import {NftDataStructsCollection} from '../interfaces';
import privateKey from '../substrate/privateKey';
-import { default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync } from '../substrate/substrate-api';
-import { ICollectionInterface } from '../types';
-import { hexToStr, strToUTF16, utf16ToStr } from './util';
+import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from '../substrate/substrate-api';
+import {hexToStr, strToUTF16, utf16ToStr} from './util';
chai.use(chaiAsPromised);
const expect = chai.expect;
export type CrossAccountId = {
- substrate: string,
+ Substrate: string,
} | {
- ethereum: string,
+ Ethereum: string,
};
export function normalizeAccountId(input: string | AccountId | CrossAccountId | IKeyringPair): CrossAccountId {
- if (typeof input === 'string')
- return { substrate: input };
- if ('address' in input) {
- return { substrate: input.address };
+ if (typeof input === 'string') {
+ if (input.length === 48 || input.length === 47) {
+ return {Substrate: input};
+ } else if (input.length === 42 && input.startsWith('0x')) {
+ return {Ethereum: input.toLowerCase()};
+ } else if (input.length === 40 && !input.startsWith('0x')) {
+ return {Ethereum: '0x' + input.toLowerCase()};
+ } else {
+ throw new Error(`Unknown address format: "${input}"`);
+ }
}
- if ('ethereum' in input) {
- input.ethereum = input.ethereum.toLowerCase();
- return input;
+ if ('address' in input) {
+ return {Substrate: input.address};
}
- if ('substrate' in input) {
+ if ('Ethereum' in input) {
+ return {
+ Ethereum: input.Ethereum.toLowerCase(),
+ };
+ } else if ('ethereum' in input) {
+ return {
+ Ethereum: (input as any).ethereum.toLowerCase(),
+ };
+ } else if ('Substrate' in input) {
return input;
+ }else if ('substrate' in input) {
+ return {
+ Substrate: (input as any).substrate,
+ };
}
// AccountId
- return {substrate: input.toString()};
+ return {Substrate: input.toString()};
}
export function toSubstrateAddress(input: string | CrossAccountId | IKeyringPair): string {
input = normalizeAccountId(input);
- if ('substrate' in input) {
- return input.substrate;
+ if ('Substrate' in input) {
+ return input.Substrate;
} else {
- return evmToAddress(input.ethereum);
+ return evmToAddress(input.Ethereum);
}
}
@@ -86,12 +102,6 @@
interface IReFungibleOwner {
fraction: BN;
owner: number[];
-}
-
-interface ITokenDataType {
- owner: IKeyringPair;
- constData: number[];
- variableData: number[];
}
interface IGetMessage {
@@ -127,8 +137,8 @@
let checkMsgNftMethod = '';
let checkMsgTrsMethod = '';
let checkMsgSysMethod = '';
- events.forEach(({ event: { method, section } }) => {
- if (section === 'nft') {
+ events.forEach(({event: {method, section}}) => {
+ if (section === 'common') {
checkMsgNftMethod = method;
} else if (section === 'treasury') {
checkMsgTrsMethod = method;
@@ -148,7 +158,7 @@
const result: GenericResult = {
success: false,
};
- events.forEach(({ event: { method } }) => {
+ events.forEach(({event: {method}}) => {
// console.log(` ${phase}: ${section}.${method}:: ${data}`);
if (method === 'ExtrinsicSuccess') {
result.success = true;
@@ -162,12 +172,12 @@
export function getCreateCollectionResult(events: EventRecord[]): CreateCollectionResult {
let success = false;
let collectionId = 0;
- events.forEach(({ event: { data, method, section } }) => {
+ events.forEach(({event: {data, method, section}}) => {
// console.log(` ${phase}: ${section}.${method}:: ${data}`);
if (method == 'ExtrinsicSuccess') {
success = true;
- } else if ((section == 'nft') && (method == 'CollectionCreated')) {
- collectionId = parseInt(data[0].toString());
+ } else if ((section == 'common') && (method == 'CollectionCreated')) {
+ collectionId = parseInt(data[0].toString(), 10);
}
});
const result: CreateCollectionResult = {
@@ -182,14 +192,14 @@
let collectionId = 0;
let itemId = 0;
let recipient;
- events.forEach(({ event: { data, method, section } }) => {
+ events.forEach(({event: {data, method, section}}) => {
// console.log(` ${phase}: ${section}.${method}:: ${data}`);
if (method == 'ExtrinsicSuccess') {
success = true;
- } else if ((section == 'nft') && (method == 'ItemCreated')) {
- collectionId = parseInt(data[0].toString());
- itemId = parseInt(data[1].toString());
- recipient = data[2].toJSON();
+ } else if ((section == 'common') && (method == 'ItemCreated')) {
+ collectionId = parseInt(data[0].toString(), 10);
+ itemId = parseInt(data[1].toString(), 10);
+ recipient = normalizeAccountId(data[2].toJSON() as any);
}
});
const result: CreateItemResult = {
@@ -209,14 +219,14 @@
value: 0n,
};
- events.forEach(({ event: { data, method, section } }) => {
+ events.forEach(({event: {data, method, section}}) => {
if (method === 'ExtrinsicSuccess') {
result.success = true;
- } else if (section === 'nft' && method === 'Transfer') {
+ } else if (section === 'common' && method === 'Transfer') {
result.collectionId = +data[0].toString();
result.itemId = +data[1].toString();
- result.sender = data[2].toJSON() as CrossAccountId;
- result.recipient = data[3].toJSON() as CrossAccountId;
+ result.sender = normalizeAccountId(data[2].toJSON() as any);
+ result.recipient = normalizeAccountId(data[3].toJSON() as any);
result.value = BigInt(data[4].toString());
}
});
@@ -248,52 +258,52 @@
const defaultCreateCollectionParams: CreateCollectionParams = {
description: 'description',
- mode: { type: 'NFT' },
+ mode: {type: 'NFT'},
name: 'name',
tokenPrefix: 'prefix',
};
export async function createCollectionExpectSuccess(params: Partial<CreateCollectionParams> = {}): Promise<number> {
- const { name, description, mode, tokenPrefix } = { ...defaultCreateCollectionParams, ...params };
+ const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
let collectionId = 0;
await usingApi(async (api) => {
// Get number of collections before the transaction
- const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
+ const collectionCountBefore = (await api.query.common.createdCollectionCount()).toNumber();
// Run the CreateCollection transaction
const alicePrivateKey = privateKey('//Alice');
let modeprm = {};
if (mode.type === 'NFT') {
- modeprm = { nft: null };
+ modeprm = {nft: null};
} else if (mode.type === 'Fungible') {
- modeprm = { fungible: mode.decimalPoints };
+ modeprm = {fungible: mode.decimalPoints};
} else if (mode.type === 'ReFungible') {
- modeprm = { refungible: null };
+ modeprm = {refungible: null};
}
- const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);
+ const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getCreateCollectionResult(events);
// Get number of collections after the transaction
- const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10);
+ const collectionCountAfter = (await api.query.common.createdCollectionCount()).toNumber();
// Get the collection
- const collection: any = (await api.query.nft.collectionById(result.collectionId) as any).toJSON();
+ const collection = (await api.query.common.collectionById(result.collectionId)).unwrap();
// What to expect
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- expect(result.collectionId).to.be.equal(BcollectionCount);
+ expect(result.collectionId).to.be.equal(collectionCountAfter);
// tslint:disable-next-line:no-unused-expression
expect(collection).to.be.not.null;
- expect(BcollectionCount).to.be.equal(AcollectionCount + 1, 'Error: NFT collection NOT created.');
- expect(collection.owner).to.be.equal(toSubstrateAddress(alicesPublicKey));
- expect(utf16ToStr(collection.name)).to.be.equal(name);
- expect(utf16ToStr(collection.description)).to.be.equal(description);
- expect(hexToStr(collection.tokenPrefix)).to.be.equal(tokenPrefix);
+ expect(collectionCountAfter).to.be.equal(collectionCountBefore + 1, 'Error: NFT collection NOT created.');
+ expect(collection.owner.toString()).to.be.equal(toSubstrateAddress(alicesPublicKey));
+ expect(utf16ToStr(collection.name.toJSON() as any)).to.be.equal(name);
+ expect(utf16ToStr(collection.description.toJSON() as any)).to.be.equal(description);
+ expect(hexToStr(collection.tokenPrefix.toJSON())).to.be.equal(tokenPrefix);
collectionId = result.collectionId;
});
@@ -302,54 +312,51 @@
}
export async function createCollectionExpectFailure(params: Partial<CreateCollectionParams> = {}) {
- const { name, description, mode, tokenPrefix } = { ...defaultCreateCollectionParams, ...params };
+ const {name, description, mode, tokenPrefix} = {...defaultCreateCollectionParams, ...params};
let modeprm = {};
if (mode.type === 'NFT') {
- modeprm = { nft: null };
+ modeprm = {nft: null};
} else if (mode.type === 'Fungible') {
- modeprm = { fungible: mode.decimalPoints };
+ modeprm = {fungible: mode.decimalPoints};
} else if (mode.type === 'ReFungible') {
- modeprm = { refungible: null };
+ modeprm = {refungible: null};
}
await usingApi(async (api) => {
// Get number of collections before the transaction
- const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());
+ const collectionCountBefore = (await api.query.common.createdCollectionCount()).toNumber();
// Run the CreateCollection transaction
const alicePrivateKey = privateKey('//Alice');
- const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm);
+ const tx = api.tx.nft.createCollection(strToUTF16(name), strToUTF16(description), strToUTF16(tokenPrefix), modeprm as any);
const events = await expect(submitTransactionExpectFailAsync(alicePrivateKey, tx)).to.be.rejected;
const result = getCreateCollectionResult(events);
// Get number of collections after the transaction
- const BcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());
+ const collectionCountAfter = (await api.query.common.createdCollectionCount()).toNumber();
// What to expect
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.false;
- expect(BcollectionCount).to.be.equal(AcollectionCount, 'Error: Collection with incorrect data created.');
+ expect(collectionCountAfter).to.be.equal(collectionCountBefore, 'Error: Collection with incorrect data created.');
});
}
export async function findUnusedAddress(api: ApiPromise, seedAddition = ''): Promise<IKeyringPair> {
- let bal = new BigNumber(0);
+ let bal = 0n;
let unused;
do {
const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000)) + seedAddition;
- const keyring = new Keyring({ type: 'sr25519' });
+ const keyring = new Keyring({type: 'sr25519'});
unused = keyring.addFromUri(`//${randomSeed}`);
- bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());
- } while (bal.toFixed() != '0');
+ bal = (await api.query.system.account(unused.address)).data.free.toBigInt();
+ } while (bal !== 0n);
return unused;
}
-export async function getAllowance(collectionId: number, tokenId: number, owner: string, approved: string) {
- return await usingApi(async (api) => {
- const bn = await api.query.nft.allowances(collectionId, [tokenId, owner, approved]) as unknown as BN;
- return BigInt(bn.toString());
- });
+export async function getAllowance(api: ApiPromise, collectionId: number, owner: CrossAccountId | string, approved: CrossAccountId | string, tokenId: number) {
+ return (await api.rpc.nft.allowance(collectionId, normalizeAccountId(owner), normalizeAccountId(approved), tokenId)).toBigInt();
}
export function findUnusedAddresses(api: ApiPromise, amount: number): Promise<IKeyringPair[]> {
@@ -357,14 +364,14 @@
}
export async function findNotExistingCollection(api: ApiPromise): Promise<number> {
- const totalNumber = parseInt((await api.query.nft.createdCollectionCount()).toString(), 10) as unknown as number;
+ const totalNumber = (await api.query.common.createdCollectionCount()).toNumber();
const newCollection: number = totalNumber + 1;
return newCollection;
}
function getDestroyResult(events: EventRecord[]): boolean {
let success = false;
- events.forEach(({ event: { method } }) => {
+ events.forEach(({event: {method}}) => {
if (method == 'ExtrinsicSuccess') {
success = true;
}
@@ -388,27 +395,16 @@
const tx = api.tx.nft.destroyCollection(collectionId);
const events = await submitTransactionAsync(alicePrivateKey, tx);
const result = getDestroyResult(events);
-
- // Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ expect(result).to.be.true;
// What to expect
- expect(result).to.be.true;
- expect(collection).to.be.null;
- });
-}
-
-export async function queryCollectionLimits(collectionId: number) {
- return await usingApi(async (api) => {
- return ((await api.query.nft.collectionById(collectionId)).toJSON() as any).limits;
+ expect((await api.query.common.collectionById(collectionId)).isNone).to.be.true;
});
}
export async function setCollectionLimitsExpectSuccess(sender: IKeyringPair, collectionId: number, limits: any) {
await usingApi(async (api) => {
- const oldLimits = await queryCollectionLimits(collectionId);
- const newLimits = { ...oldLimits as any, ...limits };
- const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
+ const tx = api.tx.nft.setCollectionLimits(collectionId, limits);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
@@ -418,9 +414,7 @@
export async function setCollectionLimitsExpectFailure(sender: IKeyringPair, collectionId: number, limits: any) {
await usingApi(async (api) => {
- const oldLimits = await queryCollectionLimits(collectionId);
- const newLimits = { ...oldLimits as any, ...limits };
- const tx = api.tx.nft.setCollectionLimits(collectionId, newLimits);
+ const tx = api.tx.nft.setCollectionLimits(collectionId, limits);
const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
const result = getGenericResult(events);
@@ -438,11 +432,11 @@
const result = getGenericResult(events);
// Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
// What to expect
expect(result.success).to.be.true;
- expect(collection.sponsorship).to.deep.equal({
+ expect(collection.sponsorship.toJSON()).to.deep.equal({
unconfirmed: sponsor,
});
});
@@ -458,11 +452,11 @@
const result = getGenericResult(events);
// Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
// What to expect
expect(result.success).to.be.true;
- expect(collection.sponsorship).to.be.deep.equal({ disabled: null });
+ expect(collection.sponsorship.toJSON()).to.be.deep.equal({disabled: null});
});
}
@@ -496,11 +490,11 @@
const result = getGenericResult(events);
// Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
// What to expect
expect(result.success).to.be.true;
- expect(collection.sponsorship).to.be.deep.equal({
+ expect(collection.sponsorship.toJSON()).to.be.deep.equal({
confirmed: sender.address,
});
});
@@ -520,7 +514,7 @@
export async function setMetadataUpdatePermissionFlagExpectSuccess(sender: IKeyringPair, collectionId: number, flag: string) {
await usingApi(async (api) => {
- const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
+ const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag as any);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
@@ -531,7 +525,7 @@
export async function setMetadataUpdatePermissionFlagExpectFailure(sender: IKeyringPair, collectionId: number, flag: string) {
await usingApi(async (api) => {
- const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag);
+ const tx = api.tx.nft.setMetaUpdatePermissionFlag(collectionId, flag as any);
const events = await expect(submitTransactionExpectFailAsync(sender, tx)).to.be.rejected;
const result = getGenericResult(events);
@@ -702,36 +696,46 @@
export async function burnItemExpectSuccess(sender: IKeyringPair, collectionId: number, tokenId: number, value = 1) {
await usingApi(async (api) => {
+ const balanceBefore = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);
+ // if burning token by admin - use adminButnItemExpectSuccess
+ expect(balanceBefore >= BigInt(value)).to.be.true;
+
const tx = api.tx.nft.burnItem(collectionId, tokenId, value);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
- // Get the item
- const item: any = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON();
- // What to expect
- // tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- // tslint:disable-next-line:no-unused-expression
- expect(item).to.be.null;
+
+ const balanceAfter = await getBalance(api, collectionId, normalizeAccountId(sender), tokenId);
+ expect(balanceAfter + BigInt(value)).to.be.equal(balanceBefore);
});
}
export async function
approveExpectSuccess(
collectionId: number,
- tokenId: number, owner: IKeyringPair, approved: IKeyringPair | CrossAccountId | string, amount: number | bigint = 1,
+ tokenId: number, owner: IKeyringPair, approved: CrossAccountId | string, amount: number | bigint = 1,
) {
await usingApi(async (api: ApiPromise) => {
- approved = normalizeAccountId(approved);
- const allowanceBefore =
- await api.query.nft.allowances(collectionId, [tokenId, owner.address, toSubstrateAddress(approved)]) as unknown as BN;
- const approveNftTx = api.tx.nft.approve(approved, collectionId, tokenId, amount);
+ const approveNftTx = api.tx.nft.approve(normalizeAccountId(approved), collectionId, tokenId, amount);
const events = await submitTransactionAsync(owner, approveNftTx);
- const result = getCreateItemResult(events);
- // tslint:disable-next-line:no-unused-expression
+ const result = getGenericResult(events);
+ expect(result.success).to.be.true;
+
+ expect(await getAllowance(api, collectionId, owner.address, approved, tokenId)).to.be.equal(BigInt(amount));
+ });
+}
+
+export async function adminApproveFromExpectSuccess(
+ collectionId: number,
+ tokenId: number, admin: IKeyringPair, owner: CrossAccountId | string, approved: CrossAccountId | string, amount: number | bigint = 1,
+) {
+ await usingApi(async (api: ApiPromise) => {
+ const approveNftTx = api.tx.nft.approve(normalizeAccountId(approved), collectionId, tokenId, amount);
+ const events = await submitTransactionAsync(admin, approveNftTx);
+ const result = getGenericResult(events);
expect(result.success).to.be.true;
- const allowanceAfter =
- await api.query.nft.allowances(collectionId, [tokenId, owner.address, toSubstrateAddress(approved)]) as unknown as BN;
- expect(allowanceAfter.sub(allowanceBefore).toString()).to.be.equal(amount.toString());
+
+ expect(await getAllowance(api, collectionId, owner, approved, tokenId)).to.be.equal(BigInt(amount));
});
}
@@ -747,9 +751,9 @@
) {
await usingApi(async (api: ApiPromise) => {
const to = normalizeAccountId(accountTo);
- let balanceBefore = new BN(0);
+ let balanceBefore = 0n;
if (type === 'Fungible') {
- balanceBefore = await api.query.nft.balance(collectionId, toSubstrateAddress(to)) as unknown as BN;
+ balanceBefore = await getBalance(api, collectionId, to, tokenId);
}
const transferFromTx = api.tx.nft.transferFrom(normalizeAccountId(accountFrom), to, collectionId, tokenId, value);
const events = await submitTransactionAsync(accountApproved, transferFromTx);
@@ -757,18 +761,14 @@
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
if (type === 'NFT') {
- const nftItemData = (await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON() as ITokenDataType;
- expect(nftItemData.owner).to.be.deep.equal(to);
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);
}
if (type === 'Fungible') {
- const balanceAfter = (await api.query.nft.fungibleItemList(collectionId, toSubstrateAddress(to)) as any).value as unknown as BN;
- expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());
+ const balanceAfter = await getBalance(api, collectionId, to, tokenId);
+ expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));
}
if (type === 'ReFungible') {
- const nftItemData =
- (await api.query.nft.reFungibleItemList(collectionId, tokenId) as any).toJSON() as IReFungibleTokenDataType;
- expect(nftItemData.owner[0].owner).to.be.deep.equal(normalizeAccountId(to));
- expect(nftItemData.owner[0].fraction).to.be.equal(value);
+ expect(await getBalance(api, collectionId, to, tokenId)).to.be.equal(BigInt(value));
}
});
}
@@ -801,9 +801,9 @@
});
}
-export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: IKeyringPair) {
+export async function addCollectionAdminExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | CrossAccountId) {
await usingApi(async (api) => {
- const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(address.address));
+ const changeAdminTx = api.tx.nft.addCollectionAdmin(collectionId, normalizeAccountId(address));
const events = await submitTransactionAsync(sender, changeAdminTx);
const result = getCreateCollectionResult(events);
expect(result.success).to.be.true;
@@ -828,7 +828,6 @@
sender: IKeyringPair,
recipient: IKeyringPair,
value: number | bigint = 1,
- blockTimeMs: number,
blockSchedule: number,
) {
await usingApi(async (api: ApiPromise) => {
@@ -836,24 +835,22 @@
const expectedBlockNumber = blockNumber + blockSchedule;
expect(blockNumber).to.be.greaterThan(0);
- const transferTx = await api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
- const scheduleTx = await api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx);
+ const transferTx = api.tx.nft.transfer(normalizeAccountId(recipient.address), collectionId, tokenId, value);
+ const scheduleTx = api.tx.scheduler.schedule(expectedBlockNumber, null, 0, transferTx as any);
await submitTransactionAsync(sender, scheduleTx);
- const recipientBalanceBefore = new BigNumber((await api.query.system.account(recipient.address)).data.free.toString());
+ const recipientBalanceBefore = (await api.query.system.account(recipient.address)).data.free.toBigInt();
- const nftItemDataBefore = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON() as any as ITokenDataType;
- expect(toSubstrateAddress(nftItemDataBefore.owner)).to.be.equal(sender.address);
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(sender.address));
// sleep for 4 blocks
- await new Promise(resolve => setTimeout(resolve, blockTimeMs * (blockSchedule + 1)));
+ await waitNewBlocks(blockSchedule + 1);
- const recipientBalanceAfter = new BigNumber((await api.query.system.account(recipient.address)).data.free.toString());
+ const recipientBalanceAfter = (await api.query.system.account(recipient.address)).data.free.toBigInt();
- const nftItemData = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON() as unknown as ITokenDataType;
- expect(toSubstrateAddress(nftItemData.owner)).to.be.equal(recipient.address);
- expect(recipientBalanceAfter.toNumber()).to.be.equal(recipientBalanceBefore.toNumber());
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(normalizeAccountId(recipient.address));
+ expect(recipientBalanceAfter).to.be.equal(recipientBalanceBefore);
});
}
@@ -870,9 +867,9 @@
await usingApi(async (api: ApiPromise) => {
const to = normalizeAccountId(recipient);
- let balanceBefore = new BN(0);
+ let balanceBefore = 0n;
if (type === 'Fungible') {
- balanceBefore = await api.query.nft.balance(collectionId, toSubstrateAddress(to)) as unknown as BN;
+ balanceBefore = await getBalance(api, collectionId, to, tokenId);
}
const transferTx = api.tx.nft.transfer(to, collectionId, tokenId, value);
const events = await submitTransactionAsync(sender, transferTx);
@@ -883,23 +880,16 @@
expect(result.itemId).to.be.equal(tokenId);
expect(result.sender).to.be.deep.equal(normalizeAccountId(sender.address));
expect(result.recipient).to.be.deep.equal(to);
- expect(result.value.toString()).to.be.equal(value.toString());
+ expect(result.value).to.be.equal(BigInt(value));
if (type === 'NFT') {
- const nftItemData = (await api.query.nft.nftItemList(collectionId, tokenId)).toJSON() as unknown as ITokenDataType;
- expect(nftItemData.owner).to.be.deep.equal(to);
+ expect(await getTokenOwner(api, collectionId, tokenId)).to.be.deep.equal(to);
}
if (type === 'Fungible') {
- const balanceAfter = (await api.query.nft.fungibleItemList(collectionId, toSubstrateAddress(to)) as any).value as unknown as BN;
- expect(balanceAfter.sub(balanceBefore).toString()).to.be.equal(value.toString());
+ const balanceAfter = await getBalance(api, collectionId, to, tokenId);
+ expect(balanceAfter - balanceBefore).to.be.equal(BigInt(value));
}
if (type === 'ReFungible') {
- const nftItemData =
- (await api.query.nft.reFungibleItemList(collectionId, tokenId)).toJSON() as unknown as IReFungibleTokenDataType;
- const expectedOwner = toSubstrateAddress(to);
- const ownerIndex = nftItemData.owner.findIndex(v => toSubstrateAddress(v.owner as any as string) == expectedOwner);
- expect(ownerIndex).to.not.equal(-1);
- expect(nftItemData.owner[ownerIndex].owner).to.be.deep.equal(normalizeAccountId(to));
- expect(nftItemData.owner[ownerIndex].fraction).to.be.greaterThanOrEqual(value as number);
+ expect(await getBalance(api, collectionId, to, tokenId) >= value).to.be.true;
}
});
}
@@ -937,15 +927,54 @@
});
}
-export async function getFungibleBalance(
+export async function getBalance(
+ api: ApiPromise,
+ collectionId: number,
+ owner: string | CrossAccountId,
+ token: number,
+): Promise<bigint> {
+ return (await api.rpc.nft.balance(collectionId, normalizeAccountId(owner), token)).toBigInt();
+}
+export async function getTokenOwner(
+ api: ApiPromise,
+ collectionId: number,
+ token: number,
+): Promise<CrossAccountId> {
+ return normalizeAccountId((await api.rpc.nft.tokenOwner(collectionId, token)).toJSON() as any);
+}
+export async function isTokenExists(
+ api: ApiPromise,
+ collectionId: number,
+ token: number,
+): Promise<boolean> {
+ return (await api.rpc.nft.tokenExists(collectionId, token)).toJSON();
+}
+export async function getLastTokenId(
+ api: ApiPromise,
collectionId: number,
- owner: string,
-) {
- return await usingApi(async (api) => {
- const response = (await api.query.nft.fungibleItemList(collectionId, owner)).toJSON() as unknown as { value: string };
- return BigInt(response.value);
- });
+): Promise<number> {
+ return (await api.rpc.nft.lastTokenId(collectionId)).toJSON();
}
+export async function getAdminList(
+ api: ApiPromise,
+ collectionId: number,
+): Promise<string[]> {
+ return (await api.rpc.nft.adminlist(collectionId)).toHuman() as any;
+}
+export async function getVariableMetadata(
+ api: ApiPromise,
+ collectionId: number,
+ tokenId: number,
+): Promise<number[]> {
+ return [...(await api.rpc.nft.variableMetadata(collectionId, tokenId))];
+}
+export async function getConstMetadata(
+ api: ApiPromise,
+ collectionId: number,
+ tokenId: number,
+): Promise<number[]> {
+ return [...(await api.rpc.nft.constMetadata(collectionId, tokenId))];
+}
export async function createFungibleItemExpectSuccess(
sender: IKeyringPair,
@@ -954,7 +983,7 @@
owner: CrossAccountId | string = sender.address,
) {
return await usingApi(async (api) => {
- const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), { Fungible: data });
+ const tx = api.tx.nft.createItem(collectionId, normalizeAccountId(owner), {Fungible: data});
const events = await submitTransactionAsync(sender, tx);
const result = getCreateItemResult(events);
@@ -968,39 +997,37 @@
let newItemId = 0;
await usingApi(async (api) => {
const to = normalizeAccountId(owner);
- const AItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);
- const Aitem: any = (await api.query.nft.fungibleItemList(collectionId, toSubstrateAddress(to))).toJSON();
- const AItemBalance = new BigNumber(Aitem.value);
+ const itemCountBefore = await getLastTokenId(api, collectionId);
+ const itemBalanceBefore = await getBalance(api, collectionId, to, newItemId);
let tx;
if (createMode === 'Fungible') {
- const createData = { fungible: { value: 10 } };
- tx = api.tx.nft.createItem(collectionId, to, createData);
+ const createData = {fungible: {value: 10}};
+ tx = api.tx.nft.createItem(collectionId, to, createData as any);
} else if (createMode === 'ReFungible') {
- const createData = { refungible: { const_data: [], variable_data: [], pieces: 100 } };
- tx = api.tx.nft.createItem(collectionId, to, createData);
+ const createData = {refungible: {const_data: [], variable_data: [], pieces: 100}};
+ tx = api.tx.nft.createItem(collectionId, to, createData as any);
} else {
- const createData = { nft: { const_data: [], variable_data: [] } };
- tx = api.tx.nft.createItem(collectionId, to, createData);
+ const createData = {nft: {const_data: [], variable_data: []}};
+ tx = api.tx.nft.createItem(collectionId, to, createData as any);
}
const events = await submitTransactionAsync(sender, tx);
const result = getCreateItemResult(events);
- const BItemCount = parseInt((await api.query.nft.itemListIndex(collectionId)).toString(), 10);
- const Bitem: any = (await api.query.nft.fungibleItemList(collectionId, toSubstrateAddress(to))).toJSON();
- const BItemBalance = new BigNumber(Bitem.value);
+ const itemCountAfter = await getLastTokenId(api, collectionId);
+ const itemBalanceAfter = await getBalance(api, collectionId, to, newItemId);
// What to expect
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
if (createMode === 'Fungible') {
- expect(BItemBalance.minus(AItemBalance).toNumber()).to.be.equal(10);
+ expect(itemBalanceAfter - itemBalanceBefore).to.be.equal(10n);
} else {
- expect(BItemCount).to.be.equal(AItemCount + 1);
+ expect(itemCountAfter).to.be.equal(itemCountBefore + 1);
}
expect(collectionId).to.be.equal(result.collectionId);
- expect(BItemCount.toString()).to.be.equal(result.itemId.toString());
+ expect(itemCountAfter.toString()).to.be.equal(result.itemId.toString());
expect(to).to.be.deep.equal(result.recipient);
newItemId = result.itemId;
});
@@ -1030,12 +1057,12 @@
const result = getGenericResult(events);
// Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
// What to expect
// tslint:disable-next-line:no-unused-expression
expect(result.success).to.be.true;
- expect(collection.access).to.be.equal(accessMode);
+ expect(collection.access.toHuman()).to.be.equal(accessMode);
});
}
@@ -1075,14 +1102,12 @@
const tx = api.tx.nft.setMintPermission(collectionId, enabled);
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
+ expect(result.success).to.be.true;
// Get the collection
- const collection: any = (await api.query.nft.collectionById(collectionId)).toJSON();
+ const collection = (await api.query.common.collectionById(collectionId)).unwrap();
- // What to expect
- // tslint:disable-next-line:no-unused-expression
- expect(result.success).to.be.true;
- expect(collection.mintMode).to.be.equal(enabled);
+ expect(collection.mintMode.toHuman()).to.be.equal(enabled);
});
}
@@ -1112,55 +1137,38 @@
});
}
-export async function isWhitelisted(collectionId: number, address: string) {
- let whitelisted = false;
- await usingApi(async (api) => {
- whitelisted = (await api.query.nft.whiteList(collectionId, address)).toJSON() as unknown as boolean;
+export async function isWhitelisted(collectionId: number, address: string | CrossAccountId) {
+ return await usingApi(async (api) => {
+ return (await api.query.common.allowlist(collectionId, normalizeAccountId(address))).toJSON();
});
- return whitelisted;
}
-export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {
+export async function addToWhiteListExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId | CrossAccountId) {
await usingApi(async (api) => {
+ expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.false;
- const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();
-
// Run the transaction
const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
-
- const whiteListedAfter = (await api.query.nft.whiteList(collectionId, address)).toJSON();
+ expect(result.success).to.be.true;
- // What to expect
- // tslint:disable-next-line:no-unused-expression
- expect(result.success).to.be.true;
- // tslint:disable-next-line: no-unused-expression
- expect(whiteListedBefore).to.be.false;
- // tslint:disable-next-line: no-unused-expression
- expect(whiteListedAfter).to.be.true;
+ expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;
});
}
export async function addToWhiteListAgainExpectSuccess(sender: IKeyringPair, collectionId: number, address: string | AccountId) {
await usingApi(async (api) => {
- const whiteListedBefore = (await api.query.nft.whiteList(collectionId, address)).toJSON();
+ expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;
// Run the transaction
const tx = api.tx.nft.addToWhiteList(collectionId, normalizeAccountId(address));
const events = await submitTransactionAsync(sender, tx);
const result = getGenericResult(events);
-
- const whiteListedAfter = (await api.query.nft.whiteList(collectionId, address)).toJSON();
+ expect(result.success).to.be.true;
- // What to expect
- // tslint:disable-next-line:no-unused-expression
- expect(result.success).to.be.true;
- // tslint:disable-next-line: no-unused-expression
- expect(whiteListedBefore).to.be.true;
- // tslint:disable-next-line: no-unused-expression
- expect(whiteListedAfter).to.be.true;
+ expect(await isWhitelisted(collectionId, normalizeAccountId(address))).to.be.true;
});
}
@@ -1205,23 +1213,17 @@
}
export const getDetailedCollectionInfo = async (api: ApiPromise, collectionId: number)
- : Promise<ICollectionInterface | null> => {
- return (await api.query.nft.collectionById(collectionId)).toJSON() as unknown as ICollectionInterface;
+ : Promise<NftDataStructsCollection | null> => {
+ return (await api.query.common.collectionById(collectionId)).unwrapOr(null);
};
export const getCreatedCollectionCount = async (api: ApiPromise): Promise<number> => {
// set global object - collectionsCount
- return (await api.query.nft.createdCollectionCount() as unknown as BN).toNumber();
+ return (await api.query.common.createdCollectionCount()).toNumber();
};
-export async function queryCollectionExpectSuccess(collectionId: number): Promise<ICollectionInterface> {
- return await usingApi(async (api) => {
- return (await api.query.nft.collectionById(collectionId)).toJSON() as unknown as ICollectionInterface;
- });
-}
-
-export async function queryNftOwner(api: ApiPromise, collectionId: number, tokenId: number): Promise<CrossAccountId> {
- return normalizeAccountId((await api.query.nft.nftItemList(collectionId, tokenId) as any).toJSON().owner);
+export async function queryCollectionExpectSuccess(api: ApiPromise, collectionId: number): Promise<NftDataStructsCollection> {
+ return (await api.query.common.collectionById(collectionId)).unwrap();
}
export async function waitNewBlocks(blocksCount = 1): Promise<void> {
tests/src/whiteLists.test.tsdiffbeforeafterboth--- a/tests/src/whiteLists.test.ts
+++ b/tests/src/whiteLists.test.ts
@@ -3,11 +3,11 @@
// file 'LICENSE', which is part of this source code package.
//
-import { IKeyringPair } from '@polkadot/types/types';
+import {IKeyringPair} from '@polkadot/types/types';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import privateKey from './substrate/privateKey';
-import usingApi, { submitTransactionExpectFailAsync } from './substrate/substrate-api';
+import usingApi, {submitTransactionExpectFailAsync} from './substrate/substrate-api';
import {
addToWhiteListExpectSuccess,
createCollectionExpectSuccess,
@@ -32,276 +32,273 @@
chai.use(chaiAsPromised);
const expect = chai.expect;
-let Alice: IKeyringPair;
-let Bob: IKeyringPair;
-let Charlie: IKeyringPair;
+let alice: IKeyringPair;
+let bob: IKeyringPair;
+let charlie: IKeyringPair;
describe('Integration Test ext. White list tests', () => {
before(async () => {
await usingApi(async () => {
- Alice = privateKey('//Alice');
- Bob = privateKey('//Bob');
- Charlie = privateKey('//Charlie');
+ alice = privateKey('//Alice');
+ bob = privateKey('//Bob');
+ charlie = privateKey('//Charlie');
});
});
it('Owner can add address to white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
});
it('Admin can add address to white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await addToWhiteListExpectSuccess(Bob, collectionId, Charlie.address);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await addToWhiteListExpectSuccess(bob, collectionId, charlie.address);
});
it('Non-privileged user cannot add address to white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectFail(Bob, collectionId, Charlie.address);
+ await addToWhiteListExpectFail(bob, collectionId, charlie.address);
});
it('Nobody can add address to white list of non-existing collection', async () => {
const collectionId = (1<<32) - 1;
- await addToWhiteListExpectFail(Alice, collectionId, Bob.address);
+ await addToWhiteListExpectFail(alice, collectionId, bob.address);
});
it('Nobody can add address to white list of destroyed collection', async () => {
const collectionId = await createCollectionExpectSuccess();
await destroyCollectionExpectSuccess(collectionId, '//Alice');
- await addToWhiteListExpectFail(Alice, collectionId, Bob.address);
+ await addToWhiteListExpectFail(alice, collectionId, bob.address);
});
it('If address is already added to white list, nothing happens', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await addToWhiteListAgainExpectSuccess(Alice, collectionId, Bob.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await addToWhiteListAgainExpectSuccess(alice, collectionId, bob.address);
});
it('Owner can remove address from white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await removeFromWhiteListExpectSuccess(Alice, collectionId, normalizeAccountId(Bob));
- });
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(bob));
+ });
it('Admin can remove address from white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await removeFromWhiteListExpectSuccess(Bob, collectionId, normalizeAccountId(Charlie));
- });
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await removeFromWhiteListExpectSuccess(bob, collectionId, normalizeAccountId(charlie));
+ });
it('Non-privileged user cannot remove address from white list', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await removeFromWhiteListExpectFailure(Bob, collectionId, normalizeAccountId(Charlie));
- });
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await removeFromWhiteListExpectFailure(bob, collectionId, normalizeAccountId(charlie));
+ });
it('Nobody can remove address from white list of non-existing collection', async () => {
const collectionId = (1<<32) - 1;
- await removeFromWhiteListExpectFailure(Alice, collectionId, normalizeAccountId(Charlie));
- });
-
+ await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(charlie));
+ });
-
it('Nobody can remove address from white list of deleted collection', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
await destroyCollectionExpectSuccess(collectionId, '//Alice');
- await removeFromWhiteListExpectFailure(Alice, collectionId, normalizeAccountId(Charlie));
- });
+ await removeFromWhiteListExpectFailure(alice, collectionId, normalizeAccountId(charlie));
+ });
it('If address is already removed from white list, nothing happens', async () => {
const collectionId = await createCollectionExpectSuccess();
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await removeFromWhiteListExpectSuccess(Alice, collectionId, normalizeAccountId(Charlie));
- await removeFromWhiteListExpectSuccess(Alice, collectionId, normalizeAccountId(Charlie));
- });
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(charlie));
+ await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(charlie));
+ });
it('If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom. Test1', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
await transferExpectFailure(
collectionId,
itemId,
- Alice,
- Charlie,
+ alice,
+ charlie,
1,
);
- });
+ });
it('If Public Access mode is set to WhiteList, tokens can’t be transferred from a non-whitelisted address with transfer or transferFrom. Test2', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await approveExpectSuccess(collectionId, itemId, Alice, Charlie);
- await removeFromWhiteListExpectSuccess(Alice, collectionId, normalizeAccountId(Alice));
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await approveExpectSuccess(collectionId, itemId, alice, charlie.address);
+ await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(alice));
await transferExpectFailure(
collectionId,
itemId,
- Alice,
- Charlie,
+ alice,
+ charlie,
1,
);
- });
+ });
it('If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom. Test1', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
await transferExpectFailure(
collectionId,
itemId,
- Alice,
- Charlie,
+ alice,
+ charlie,
1,
);
- });
+ });
it('If Public Access mode is set to WhiteList, tokens can’t be transferred to a non-whitelisted address with transfer or transferFrom. Test2', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await approveExpectSuccess(collectionId, itemId, Alice, Charlie);
- await removeFromWhiteListExpectSuccess(Alice, collectionId, normalizeAccountId(Alice));
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await approveExpectSuccess(collectionId, itemId, alice, charlie.address);
+ await removeFromWhiteListExpectSuccess(alice, collectionId, normalizeAccountId(alice));
await transferExpectFailure(
collectionId,
itemId,
- Alice,
- Charlie,
+ alice,
+ charlie,
1,
);
- });
+ });
it('If Public Access mode is set to WhiteList, tokens can’t be destroyed by a non-whitelisted address (even if it owned them before enabling WhiteList mode)', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
await usingApi(async (api) => {
const tx = api.tx.nft.burnItem(collectionId, itemId, /*normalizeAccountId(Alice.address),*/ 11);
- const badTransaction = async function () {
- await submitTransactionExpectFailAsync(Alice, tx);
+ const badTransaction = async function () {
+ await submitTransactionExpectFailAsync(alice, tx);
};
await expect(badTransaction()).to.be.rejected;
});
- });
-
+ });
+
it('If Public Access mode is set to WhiteList, token transfers can’t be Approved by a non-whitelisted address (see Approve method)', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await approveExpectFail(collectionId, itemId, Alice, Bob);
- });
-
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await approveExpectFail(collectionId, itemId, alice, bob);
+ });
+
it('If Public Access mode is set to WhiteList, tokens can be transferred to a whitelisted address with transfer.', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await transferExpectSuccess(collectionId, itemId, Alice, Charlie, 1, 'NFT');
- });
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await transferExpectSuccess(collectionId, itemId, alice, charlie, 1, 'NFT');
+ });
it('If Public Access mode is set to WhiteList, tokens can be transferred to a whitelisted address with transferFrom.', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await approveExpectSuccess(collectionId, itemId, Alice, Charlie);
- await transferFromExpectSuccess(collectionId, itemId, Alice, Alice, Charlie, 1, 'NFT');
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await approveExpectSuccess(collectionId, itemId, alice, charlie.address);
+ await transferFromExpectSuccess(collectionId, itemId, alice, alice, charlie, 1, 'NFT');
});
it('If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transfer', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await transferExpectSuccess(collectionId, itemId, Alice, Charlie, 1, 'NFT');
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await transferExpectSuccess(collectionId, itemId, alice, charlie, 1, 'NFT');
});
it('If Public Access mode is set to WhiteList, tokens can be transferred from a whitelisted address with transferFrom', async () => {
const collectionId = await createCollectionExpectSuccess();
- const itemId = await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await addToWhiteListExpectSuccess(Alice, collectionId, Alice.address);
- await addToWhiteListExpectSuccess(Alice, collectionId, Charlie.address);
- await approveExpectSuccess(collectionId, itemId, Alice, Charlie);
- await transferFromExpectSuccess(collectionId, itemId, Alice, Alice, Charlie, 1, 'NFT');
+ const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await addToWhiteListExpectSuccess(alice, collectionId, alice.address);
+ await addToWhiteListExpectSuccess(alice, collectionId, charlie.address);
+ await approveExpectSuccess(collectionId, itemId, alice, charlie.address);
+ await transferFromExpectSuccess(collectionId, itemId, alice, alice, charlie, 1, 'NFT');
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by owner', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, false);
- await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, false);
+ await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens can be created by admin', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, false);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, false);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and white-listed address', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, false);
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await createItemExpectFailure(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, false);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await createItemExpectFailure(bob, collectionId, 'NFT', bob.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to false, tokens cannot be created by non-privileged and non-white listed address', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, false);
- await createItemExpectFailure(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, false);
+ await createItemExpectFailure(bob, collectionId, 'NFT', bob.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by owner', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, true);
- await createItemExpectSuccess(Alice, collectionId, 'NFT', Alice.address);
- });
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, true);
+ await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);
+ });
it('If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by admin', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, true);
- await addCollectionAdminExpectSuccess(Alice, collectionId, Bob);
- await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, true);
+ await addCollectionAdminExpectSuccess(alice, collectionId, bob.address);
+ await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens cannot be created by non-privileged and non-white listed address', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, true);
- await createItemExpectFailure(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, true);
+ await createItemExpectFailure(bob, collectionId, 'NFT', bob.address);
});
it('If Public Access mode is set to WhiteList, and Mint Permission is set to true, tokens can be created by non-privileged and white listed address', async () => {
const collectionId = await createCollectionExpectSuccess();
- await enableWhiteListExpectSuccess(Alice, collectionId);
- await setMintPermissionExpectSuccess(Alice, collectionId, true);
- await addToWhiteListExpectSuccess(Alice, collectionId, Bob.address);
- await createItemExpectSuccess(Bob, collectionId, 'NFT', Bob.address);
+ await enableWhiteListExpectSuccess(alice, collectionId);
+ await setMintPermissionExpectSuccess(alice, collectionId, true);
+ await addToWhiteListExpectSuccess(alice, collectionId, bob.address);
+ await createItemExpectSuccess(bob, collectionId, 'NFT', bob.address);
});
});
-
tests/tsconfig.jsondiffbeforeafterboth--- a/tests/tsconfig.json
+++ b/tests/tsconfig.json
@@ -13,10 +13,20 @@
"sourceMap": true,
"outDir": "dist",
"rootDir": "src",
- "strict": true
+ "strict": true,
+ "paths": {
+ "@polkadot/api/augment": [
+ "./src/interfaces/augment-api.ts"
+ ],
+ "@polkadot/types/augment": [
+ "./src/interfaces/augment-types.ts"
+ ]
+ }
},
"include": [
"src/**/*"
],
- "lib": ["es2017"]
+ "lib": [
+ "es2017"
+ ],
}
tests/yarn.lockdiffbeforeafterboth--- a/tests/yarn.lock
+++ b/tests/yarn.lock
@@ -1899,81 +1899,51 @@
dependencies:
"@octokit/openapi-types" "^7.3.2"
-"@polkadot/api-contract@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-6.5.1.tgz#bc61e0def693ab866550c304384d909fec6cf64d"
- integrity sha512-cV86H2oGKs9dbO3wf911ftRrGvbzq9tkJzTsocx12WhAKORVT11zIKPThaVmzzrdqSqN7q7tth8p4HBDXZp9qw==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/api" "6.5.1"
- "@polkadot/types" "6.5.1"
- "@polkadot/util" "^7.6.1"
- rxjs "^7.4.0"
-
-"@polkadot/api-derive@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-6.5.1.tgz#c2e7d632c3c156355218650e6414504d9a154b17"
- integrity sha512-OwiCYcak3fqiZtE28FbqEd+ZTck9LmsEk01VPQigwSgNu/qbiuKGZ+MurK6yWy8sHbFdcDLPR07/iD5/fhQZRw==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/api" "6.5.1"
- "@polkadot/rpc-core" "6.5.1"
- "@polkadot/types" "6.5.1"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
- rxjs "^7.4.0"
-
-"@polkadot/api-derive@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-6.5.2-3.tgz#c3c85a4326a105398083858d2eca44d14685d8b3"
- integrity sha512-VSBKcSrZU/nvl2yy3w1hWkTayoYGXGyySUkYrc6H/xA6NDeU9Pj3p3PMNnI1zeTL9SIuoQs1g2h8k8Ynaxq5fQ==
+"@polkadot/api-contract@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/api-contract/-/api-contract-6.6.2-5.tgz#b0e40242c320015f1c55999e86a08826e2d946c0"
+ integrity sha512-STchCvoGHq4BVnqYuYUDZnJ6NuHfuwDPH4oh2O8DSVRWSTLPWBcWLBFUzDPJe6wfWUf7ih0CW6p7msCq7zqltg==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/api" "6.5.2-3"
- "@polkadot/rpc-core" "6.5.2-3"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
+ "@polkadot/api" "6.6.2-5"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
rxjs "^7.4.0"
-"@polkadot/api@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-6.5.1.tgz#c6c46ed8274114d56652574bfc64a01610401490"
- integrity sha512-hxnXb4qFlRbqBKnWgvNtRAukDRthAcLjhh1IY9oQ6WRJipdb2wMtNz6MY06gLI0MVGv9u2fOC6Rhd2JGo4CKZg==
+"@polkadot/api-derive@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/api-derive/-/api-derive-6.6.2-5.tgz#52f8d7f071a0c8d8c81bf41e8e1666485af8cd56"
+ integrity sha512-TZmGJuSdfbvSaQ4bE4cCx+pjINnB8ZrSCpV4RZXfhUZmqQ1KQBXLDbXsSdRK+PldFnprged14T3yFD7pgptM6A==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/api-derive" "6.5.1"
- "@polkadot/keyring" "^7.6.1"
- "@polkadot/rpc-core" "6.5.1"
- "@polkadot/rpc-provider" "6.5.1"
- "@polkadot/types" "6.5.1"
- "@polkadot/types-known" "6.5.1"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
- eventemitter3 "^4.0.7"
+ "@polkadot/api" "6.6.2-5"
+ "@polkadot/rpc-core" "6.6.2-5"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
+ "@polkadot/util-crypto" "^7.7.1"
rxjs "^7.4.0"
-"@polkadot/api@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-6.5.2-3.tgz#715f2746faf5edb84ddebeeaf9b37c15226a50f4"
- integrity sha512-Ugrd3MK265cwE88cu6W9k/4bIutu5O5YFpw6t7Rf0OWOgibZsGnd1/CTi1e/F85Ro7FxyT7lBFQFM9XA1hUnDA==
+"@polkadot/api@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/api/-/api-6.6.2-5.tgz#d9c2ce51886407d1ee140ee4dbbc7da934ab0fc0"
+ integrity sha512-XS2Jetbo6zALL8pTgkRSAnpcOI83p92nGqCPf3gWHzL+MCuHT2kudLICbE1tKbJOHkiMyn87uH1v8OOV7mPPGw==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/api-derive" "6.5.2-3"
- "@polkadot/keyring" "^7.6.1"
- "@polkadot/rpc-core" "6.5.2-3"
- "@polkadot/rpc-provider" "6.5.2-3"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/types-known" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
+ "@polkadot/api-derive" "6.6.2-5"
+ "@polkadot/keyring" "^7.7.1"
+ "@polkadot/rpc-core" "6.6.2-5"
+ "@polkadot/rpc-provider" "6.6.2-5"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/types-known" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
+ "@polkadot/util-crypto" "^7.7.1"
eventemitter3 "^4.0.7"
rxjs "^7.4.0"
-"@polkadot/dev@0.63.9":
- version "0.63.9"
- resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.63.9.tgz#911e92d2b8c60d35dbb897fb917f065f1aa750ac"
- integrity sha512-lH9A7NTJNHJN+J4TBPcqhGkhEAsNAjqeVgUH980MwcovMo7mehFLadSt9Qi/+qFeZxEsp67+daeI4sqdo8csmg==
+"@polkadot/dev@0.63.18":
+ version "0.63.18"
+ resolved "https://registry.yarnpkg.com/@polkadot/dev/-/dev-0.63.18.tgz#2bd5f0a2019a67aa3acfd71bc4a9d81486887a7b"
+ integrity sha512-oaSySgI8eNctXzA2n3hEUgILw9sP4a9mAKdbtZAMDP2Jf6Dw92rsKwEfKiIXU6MRL0kukafMH3oQPd9nJIL+zg==
dependencies:
"@babel/cli" "^7.15.7"
"@babel/core" "^7.15.8"
@@ -1999,15 +1969,15 @@
"@rollup/plugin-inject" "^4.0.3"
"@rollup/plugin-json" "^4.1.0"
"@rollup/plugin-node-resolve" "^13.0.6"
- "@rushstack/eslint-patch" "^1.0.8"
- "@typescript-eslint/eslint-plugin" "5.1.0"
- "@typescript-eslint/parser" "5.1.0"
- "@vue/component-compiler-utils" "^3.2.2"
+ "@rushstack/eslint-patch" "^1.0.9"
+ "@typescript-eslint/eslint-plugin" "5.2.0"
+ "@typescript-eslint/parser" "5.2.0"
+ "@vue/component-compiler-utils" "^3.3.0"
babel-jest "^27.3.1"
babel-plugin-module-extension-resolver "^1.0.0-rc.2"
babel-plugin-module-resolver "^4.1.0"
babel-plugin-styled-components "^1.13.3"
- browserslist "^4.17.4"
+ browserslist "^4.17.5"
chalk "^4.1.2"
coveralls "^3.1.1"
eslint "^8.1.0"
@@ -2021,7 +1991,7 @@
eslint-plugin-react "^7.26.1"
eslint-plugin-react-hooks "^4.2.1-alpha-930c9e7ee-20211015"
eslint-plugin-simple-import-sort "^7.0.0"
- eslint-plugin-sort-destructure-keys "^1.3.5"
+ eslint-plugin-sort-destructure-keys "^1.4.0"
fs-extra "^10.0.0"
gh-pages "^3.2.3"
gh-release "^6.0.1"
@@ -2037,74 +2007,49 @@
mkdirp "^1.0.4"
prettier "^2.4.1"
rimraf "^3.0.2"
- rollup "^2.58.0"
+ rollup "^2.58.3"
typescript "^4.4.4"
yargs "^17.2.1"
-"@polkadot/keyring@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-7.6.1.tgz#a138e417cbbf85b3f0f66af66f5cd40735ba24a1"
- integrity sha512-lpbTHAQqae++cvaNfuCjdz2xbNrk0ZSGCM8w08Br6NIz8NyrwR/qm1PfV75leoLq/Qx58+aj8v2qANEBOVz4vQ==
+"@polkadot/keyring@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-7.7.1.tgz#0ab6a8d104669ead3e269cf2c185346b24dfbd36"
+ integrity sha512-MzdwUeR5BjqEqSnW1SVg1mMaUPkirGcLd60vsp187qf/y9IaI+ZinkeP50d/GxldRobNL/bOdiOuV3bSulUvSQ==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/util" "7.6.1"
- "@polkadot/util-crypto" "7.6.1"
+ "@polkadot/util" "7.7.1"
+ "@polkadot/util-crypto" "7.7.1"
-"@polkadot/networks@7.6.1", "@polkadot/networks@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-7.6.1.tgz#d7ca346a3c15b29c9286ccbc67b1438bf9c8130e"
- integrity sha512-76RdEVy+G14P13oxSe3+VDwFdVYRNVAy7xi9ESJBRZFnQC/TIL2rOeg7Gq5+HP/mkgzG4gL5X30VdE+aKzokpA==
+"@polkadot/networks@7.7.1", "@polkadot/networks@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/networks/-/networks-7.7.1.tgz#de9674a355bd4f68d650e3dd580d717d83ea4161"
+ integrity sha512-ghUA9jd+12lfbKclPIxRQBmvfd1+BoECr5C8t+2rfM5plE+1f1Ucdrpz9wQ362+WNlnP4q1u9yB1zQlFM+K6yQ==
dependencies:
"@babel/runtime" "^7.15.4"
-"@polkadot/rpc-core@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-6.5.1.tgz#0a2ecb78b38c63f0831c7fb5363d9cc1fb72ec0e"
- integrity sha512-teWI8iumsAMHF1vgMzbRVqpSTfVcNIG7bRwSlGoy4V4ZT8dS5LjOYCR7Eqr19wRuef1DjBY87oiN7e8M2x8jCA==
+"@polkadot/rpc-core@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-6.6.2-5.tgz#5b547406ba5b2ad117394cd624f18aab0f0d413a"
+ integrity sha512-8+Vw/oF2cal+G27g/T2aFgdt2GJFcpvQPH6fv/9WJc5gcTWciwb1mQsMDBaB/VA1DbjZXZlCdMZBigayg8/+jg==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/rpc-provider" "6.5.1"
- "@polkadot/types" "6.5.1"
- "@polkadot/util" "^7.6.1"
- rxjs "^7.4.0"
-
-"@polkadot/rpc-core@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/rpc-core/-/rpc-core-6.5.2-3.tgz#72a15dd6288ed9232b12be1e6f8b848268d8b3bd"
- integrity sha512-1Lkp4/k/MYbEqLj5adayw3jAMlrmwv0hGN5rfggyIQJVLXDpDf78frOIVLNGPsDQaB1Euizfxmm/IeShFAyvxg==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/rpc-provider" "6.5.2-3"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
+ "@polkadot/rpc-provider" "6.6.2-5"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
rxjs "^7.4.0"
-"@polkadot/rpc-provider@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-6.5.1.tgz#bde30ac49b62edb592b89e19aeea36d23e14b25c"
- integrity sha512-09GId3vknImuEaRH0WDlrP8rsTC/QSIFM7sV55QzjfnLKRct1Fulez0hfFP25orXpjraWqHNZvY1yxniUxK6nA==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/types" "6.5.1"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
- "@polkadot/x-fetch" "^7.6.1"
- "@polkadot/x-global" "^7.6.1"
- "@polkadot/x-ws" "^7.6.1"
- eventemitter3 "^4.0.7"
-
-"@polkadot/rpc-provider@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-6.5.2-3.tgz#3f9c87123adddf957c0789e23963a82817d96537"
- integrity sha512-Rw4oESRwJRIRlhjwhgrL8idbYelIFmSkdk3eV1QjLQZdkHUiZkujtltUnQgT5iRi1XvGN+0ybcgFDDaNz1Ncmg==
+"@polkadot/rpc-provider@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/rpc-provider/-/rpc-provider-6.6.2-5.tgz#46695eb11a0ce1ef8617ad354af22a027bae115a"
+ integrity sha512-HQ6zWqWtxMZ0k95ABGtrmFdV6LScQ3332Ic41qjOzYE8UMvKrK8vZy0/1wWx8h0tfIu6Evtw6zz/0q5KDJWjGw==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
- "@polkadot/x-fetch" "^7.6.1"
- "@polkadot/x-global" "^7.6.1"
- "@polkadot/x-ws" "^7.6.1"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
+ "@polkadot/util-crypto" "^7.7.1"
+ "@polkadot/x-fetch" "^7.7.1"
+ "@polkadot/x-global" "^7.7.1"
+ "@polkadot/x-ws" "^7.7.1"
eventemitter3 "^4.0.7"
"@polkadot/ts@0.4.12":
@@ -2114,81 +2059,61 @@
dependencies:
"@types/chrome" "^0.0.159"
-"@polkadot/typegen@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/typegen/-/typegen-6.5.2-3.tgz#f264ed18dbeb546be413aa905ac94e2043628159"
- integrity sha512-jB3yC7QX8wbABPwtrSIeCPcmFqE/pNlg6MBShrZou4OVCt9uuyE4ju2QGLxxBHbeaXriltV4jrPpZUklKvNS+w==
+"@polkadot/typegen@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/typegen/-/typegen-6.6.2-5.tgz#2f3df4f42a3acfc28a4e40e3af8e28c72d1fa5aa"
+ integrity sha512-1U29AIPNTjGgJkOn7aKn8/OmiOPcWOIQQn6+DqGxbDOjHclgQffSeE5og82b26j5hKqNE0ks6mVwmZLLoh5pAw==
dependencies:
"@babel/core" "^7.15.8"
"@babel/register" "^7.15.3"
"@babel/runtime" "^7.15.4"
- "@polkadot/api" "6.5.2-3"
- "@polkadot/rpc-provider" "6.5.2-3"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/types-support" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
+ "@polkadot/api" "6.6.2-5"
+ "@polkadot/rpc-provider" "6.6.2-5"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/types-support" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
handlebars "^4.7.7"
websocket "^1.0.34"
yargs "^17.2.1"
-"@polkadot/types-known@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-6.5.1.tgz#753af9a6c4188accb761639505e3e5cd7e5bc176"
- integrity sha512-eIgk836zlA5KnhK6UotXYr/I9O12xxhNcKXTcA+8NY6ek2xQWlT9VGuMk4wTF4qU1sV/fhOFIDeoNrT7AgSagg==
+"@polkadot/types-known@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-6.6.2-5.tgz#b0d479742b3887063efa82e77de8f13086782ef8"
+ integrity sha512-IsdWo3oR1l+DRXZoip5U/5VJfHJSVJoFMePKL+a51vTXM0Wcx7p8aYZtVlThenyItUUXiPvYY5NCPBnwX/ZsoQ==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/networks" "^7.6.1"
- "@polkadot/types" "6.5.1"
- "@polkadot/util" "^7.6.1"
+ "@polkadot/networks" "^7.7.1"
+ "@polkadot/types" "6.6.2-5"
+ "@polkadot/util" "^7.7.1"
-"@polkadot/types-known@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/types-known/-/types-known-6.5.2-3.tgz#ebfa59495f576c0895accda20ac9c019f2afa91d"
- integrity sha512-/ORaKrDnJdRgQy247G2Bst8WUWnKGf5snSZMFHAkVTfqQK4w017gsKR+NusgPiCqziHgRptdUsVgS4tFdh5lgQ==
+"@polkadot/types-support@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-6.6.2-5.tgz#13e414dee7e48e2bf5f1c837b2864a44b1c735c6"
+ integrity sha512-alq2VXVrLKogf3e1ebtxw37s9CwLkC3xdXJ0RUx0PbK4oFtVFM9U0s3Ogo2rXwVVXqRQnMIwbzEaFHI2LvLKLQ==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/networks" "^7.6.1"
- "@polkadot/types" "6.5.2-3"
- "@polkadot/util" "^7.6.1"
+ "@polkadot/util" "^7.7.1"
-"@polkadot/types-support@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/types-support/-/types-support-6.5.2-3.tgz#3d5d6fa864e825dd4bf3d00ca4de7af6e6167b09"
- integrity sha512-FL6n7xqts5f70gHSiYflszUY0wKJt0LGQ+BmkGJ9lxda2R5Ynx6hRP/jIse6XYhCe8xDZwz/wzf2f+k7m7ooTg==
+"@polkadot/types@6.6.2-5":
+ version "6.6.2-5"
+ resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-6.6.2-5.tgz#465a574c943484e87681c766f41698b5aed3b203"
+ integrity sha512-3Tv7RhKKtnqy77Quyt2JDdXbC7Hlt6GmBH9eQv47geR8CQMTwfAx7e4sVFocQQCANhhYn/VRl6aImkX+JYBcNA==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/util" "^7.6.1"
-
-"@polkadot/types@6.5.1":
- version "6.5.1"
- resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-6.5.1.tgz#6d348b7c37ec351506e952ee16f696ecf4a56725"
- integrity sha512-EiW/5vbR6sP20Yq7wto7Ozepie6YzGjPCH4IPLkGrPsDaMegbwNRvEV+5AbCYvEPKF6LJoaRPUcF/WQxncVonA==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
+ "@polkadot/util" "^7.7.1"
+ "@polkadot/util-crypto" "^7.7.1"
rxjs "^7.4.0"
-"@polkadot/types@6.5.2-3":
- version "6.5.2-3"
- resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-6.5.2-3.tgz#347e6044041d61cb411e03e2afefbbebd04d7115"
- integrity sha512-N+OsC8fAEY8YGWQxV0GHrHIlMncIHbumxJVbiB4QdW8fL0kUDlfl0414+6lVMCLlgu+XkoyJXkEc2u+KYKseOA==
+"@polkadot/util-crypto@7.7.1", "@polkadot/util-crypto@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-7.7.1.tgz#6c3b84558d4e971cc0a7190f99e34ce801eb498d"
+ integrity sha512-K269URC/ofbYM1vFSIVLbuRi4Z+9bMdyJQ1k+59+jx0VwYu50l9vzNhFO8WMGoBZ6eDzqQkeWj7usCTKlU9xUw==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/util" "^7.6.1"
- "@polkadot/util-crypto" "^7.6.1"
- rxjs "^7.4.0"
-
-"@polkadot/util-crypto@7.6.1", "@polkadot/util-crypto@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-7.6.1.tgz#3e40270e9dce7885d92d0992aef9761feb57f2e2"
- integrity sha512-5lLEfexkYOc73jitwC4K/Ll3JNA8Hdo2aU3GSOkDah8bBpm02djD7ypwfmuWRJw0UDyTgY67g0SXn4frPcQiag==
- dependencies:
- "@babel/runtime" "^7.15.4"
- "@polkadot/networks" "7.6.1"
- "@polkadot/util" "7.6.1"
+ "@polkadot/networks" "7.7.1"
+ "@polkadot/util" "7.7.1"
"@polkadot/wasm-crypto" "^4.2.1"
- "@polkadot/x-randomvalues" "7.6.1"
+ "@polkadot/x-randomvalues" "7.7.1"
base-x "^3.0.9"
base64-js "^1.5.1"
blakejs "^1.1.1"
@@ -2202,14 +2127,14 @@
tweetnacl "^1.0.3"
xxhashjs "^0.2.2"
-"@polkadot/util@7.6.1", "@polkadot/util@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-7.6.1.tgz#e6988124728fdf053929022827216241dd50a6fa"
- integrity sha512-96UgzMOxwwsndGHN4aoyPYVRXpHcVpYb4zngFH2O9ma0YxrG2HhhqqoJ5pS0OUlhvcQkVz6T6t+heGFnTkvQxw==
+"@polkadot/util@7.7.1", "@polkadot/util@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-7.7.1.tgz#b9c74f8c242669ff8ce26a3101630231914de7c7"
+ integrity sha512-REw11iHZKUm7GeC7Ktx1HguT9y76mbmiVtZJyNXpUTDKmfm6z+SMqs3pOCL/rvzqm+6M3ag6ffRrlzTTgh0HAg==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-textdecoder" "7.6.1"
- "@polkadot/x-textencoder" "7.6.1"
+ "@polkadot/x-textdecoder" "7.7.1"
+ "@polkadot/x-textencoder" "7.7.1"
"@types/bn.js" "^4.11.6"
bn.js "^4.12.0"
camelcase "^6.2.0"
@@ -2238,54 +2163,54 @@
"@polkadot/wasm-crypto-asmjs" "^4.2.1"
"@polkadot/wasm-crypto-wasm" "^4.2.1"
-"@polkadot/x-fetch@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-fetch/-/x-fetch-7.6.1.tgz#fda1a89bbb584217f96c2d3c3a3ce0f10a454436"
- integrity sha512-CdjCg7BGhKfKNntUiK9vFOoum44o86TInPpqNumLGWAZmqI+kU0DCUDtqcw7uFOdZL1j/3GHdXigJ6LL1TnNcg==
+"@polkadot/x-fetch@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-fetch/-/x-fetch-7.7.1.tgz#88b99936b89a44c3a3a980666b4ab4db6f90481b"
+ integrity sha512-0ocN1CSwDHXRzz2yUAaoDH0VrOg3Kmx0nAW05wZdoMfvU9vEiJHhTT/c27pss3dsbEs334PWL5QbcTzYiQvDVQ==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-global" "7.6.1"
+ "@polkadot/x-global" "7.7.1"
"@types/node-fetch" "^2.5.12"
node-fetch "^2.6.5"
-"@polkadot/x-global@7.6.1", "@polkadot/x-global@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-7.6.1.tgz#f43a61d40bfaf2f43f9a4ef39e01a24546768394"
- integrity sha512-jKPNFHiC0yIc6TfqZtopaqsW3pDun1uh9lp0kcDkfOYozwwN1NVXWLClDBa2C5UiKU/jxA3biYiNZUyZpbV13g==
+"@polkadot/x-global@7.7.1", "@polkadot/x-global@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-global/-/x-global-7.7.1.tgz#ab390aa07807d62a7ec0fa2fd6e7c4837524c227"
+ integrity sha512-S7MYqEtcfMgWA64qR09Z8O3zbaRyyW1y2qtvn04dexPesuEPOw2W5+WBHss8UAI/aVxjlG+d2D3OlYUr+IOO9Q==
dependencies:
"@babel/runtime" "^7.15.4"
-"@polkadot/x-randomvalues@7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-7.6.1.tgz#0cd143cf976e36f5c9fcf53ba41fd5fffca95c44"
- integrity sha512-hfSMBeMZTrnuejv/oXp3tMZARTOGyQZ3G0GW44dV2fR2L1+tlLj9VuXgVGgupNBq7AC6eSfE3XhJwCGyH5FhmQ==
+"@polkadot/x-randomvalues@7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-randomvalues/-/x-randomvalues-7.7.1.tgz#37edb6920bac4f6c6c7620f02ef9dd5b43405a5b"
+ integrity sha512-dFhxei2TP3cWepfITDSq6eaBbdsP8TPBQagincqJynt5EaU0pzQ5psMBMJ/rAYy194oEpg0ED16XK/iFdZ42rA==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-global" "7.6.1"
+ "@polkadot/x-global" "7.7.1"
-"@polkadot/x-textdecoder@7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-7.6.1.tgz#7e80b512f1ddfd01f243dbbe8afc9dab7d0c6c85"
- integrity sha512-sJtQMMw+jO3CwpOf0t1hrVl3xMw1BOLs/Xjd0v/yhiTAJ1rr6dqvhcnOHkU3a7udqo7G9dXDrnGi1q3efifXPw==
+"@polkadot/x-textdecoder@7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-textdecoder/-/x-textdecoder-7.7.1.tgz#bfcf8f8a7ce620ca72a649dd0a322a4476a51a28"
+ integrity sha512-2+kYLVxjdtbuxcIDMdEiBK+GvCs/M8QdKVmTGLTb47PphSeiMKLu8qjy1ygBJeaFeQOZxIj1f8IJ5ICI9TlVcA==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-global" "7.6.1"
+ "@polkadot/x-global" "7.7.1"
-"@polkadot/x-textencoder@7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-7.6.1.tgz#2a2fb4baa13889fbc53b86ce9003de748f0df2aa"
- integrity sha512-iqOGwXJIzc8rWYLPTYcO09LwA2q4fqwJhLsLCd+p13Z0yDSUvwgq785/2WEQfhSFbMd8HM6udedqrQTpnpIujg==
+"@polkadot/x-textencoder@7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-textencoder/-/x-textencoder-7.7.1.tgz#7dc5b0165e3b6ad6882904169ad3362487ada92b"
+ integrity sha512-pRTG7F6EYilkbkyxfWOV1LXCVohcVnFPVfPvGydHsDJ3kGZ4n+L9PuJ+t3WKwd6tirEDUIBGe2eNEl/arcWzTw==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-global" "7.6.1"
+ "@polkadot/x-global" "7.7.1"
-"@polkadot/x-ws@^7.6.1":
- version "7.6.1"
- resolved "https://registry.yarnpkg.com/@polkadot/x-ws/-/x-ws-7.6.1.tgz#60c86cfb43935b38a6512f3e7bab362ffe6bec1f"
- integrity sha512-nP8vHlL17SIuVinphuVbj2o3mfRWUTJqlhAYlA5RjO/sZ9TwYMvGTvL/1bOAfWdp/l451WLEWJtzSipzrVGBsg==
+"@polkadot/x-ws@^7.7.1":
+ version "7.7.1"
+ resolved "https://registry.yarnpkg.com/@polkadot/x-ws/-/x-ws-7.7.1.tgz#dc06d7a3cc6802de9c8449e437f5c10687cf8683"
+ integrity sha512-P1ZBuPvTX+H6pBiIkPjgygIw4GsekicoAE2ew5R1s/WE4uS0YjiO+QTwkaaB1fNqk2fBRSI+eDHOGiGmr5MM2Q==
dependencies:
"@babel/runtime" "^7.15.4"
- "@polkadot/x-global" "7.6.1"
+ "@polkadot/x-global" "7.7.1"
"@types/websocket" "^1.0.4"
websocket "^1.0.34"
@@ -2346,10 +2271,10 @@
estree-walker "^1.0.1"
picomatch "^2.2.2"
-"@rushstack/eslint-patch@^1.0.8":
- version "1.0.8"
- resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.0.8.tgz#be3e914e84eacf16dbebd311c0d0b44aa1174c64"
- integrity sha512-ZK5v4bJwgXldAUA8r3q9YKfCwOqoHTK/ZqRjSeRXQrBXWouoPnS4MQtgC4AXGiiBuUu5wxrRgTlv0ktmM4P1Aw==
+"@rushstack/eslint-patch@^1.0.9":
+ version "1.0.9"
+ resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.0.9.tgz#1168db664faab4c3bb82c76124b393970e80bf89"
+ integrity sha512-yk9Xj/3bUxyz3azMXW8qigLqXWEr2R0h9G7PVnnmjNQdlZLN+aESqCTnVN7ubtYUIQfW32/v8+AXsbpL1ryI1A==
"@sindresorhus/is@^0.14.0":
version "0.14.0"
@@ -2560,10 +2485,10 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.15.tgz#10ee6a6a3f971966fddfa3f6e89ef7a73ec622df"
integrity sha512-F6S4Chv4JicJmyrwlDkxUdGNSplsQdGwp1A0AJloEVDirWdZOAiRHhovDlsFkKUrquUXhz1imJhXHsf59auyAg==
-"@types/node@^16.11.4":
- version "16.11.4"
- resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.4.tgz#90771124822d6663814f7c1c9b45a6654d8fd964"
- integrity sha512-TMgXmy0v2xWyuCSCJM6NCna2snndD8yvQF67J29ipdzMcsPa9u+o0tjF5+EQNdhcuZplYuouYqpc4zcd5I6amQ==
+"@types/node@^16.11.6":
+ version "16.11.6"
+ resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
+ integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
"@types/pbkdf2@^3.0.0":
version "3.1.0"
@@ -2615,13 +2540,27 @@
dependencies:
"@types/yargs-parser" "*"
-"@typescript-eslint/eslint-plugin@5.1.0", "@typescript-eslint/eslint-plugin@^5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.1.0.tgz#381c188dfab12f7a2c7b6a8ba2402d6273eadeaa"
- integrity sha512-bekODL3Tqf36Yz8u+ilha4zGxL9mdB6LIsIoMAvvC5FAuWo4NpZYXtCbv7B2CeR1LhI/lLtLk+q4tbtxuoVuCg==
+"@typescript-eslint/eslint-plugin@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.2.0.tgz#2bdb247cc2e2afce7efbce09afb9a6f0a8a08434"
+ integrity sha512-qQwg7sqYkBF4CIQSyRQyqsYvP+g/J0To9ZPVNJpfxfekl5RmdvQnFFTVVwpRtaUDFNvjfe/34TgY/dpc3MgNTw==
+ dependencies:
+ "@typescript-eslint/experimental-utils" "5.2.0"
+ "@typescript-eslint/scope-manager" "5.2.0"
+ debug "^4.3.2"
+ functional-red-black-tree "^1.0.1"
+ ignore "^5.1.8"
+ regexpp "^3.2.0"
+ semver "^7.3.5"
+ tsutils "^3.21.0"
+
+"@typescript-eslint/eslint-plugin@^5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.3.0.tgz#a55ae72d28ffeb6badd817fe4566c9cced1f5e29"
+ integrity sha512-ARUEJHJrq85aaiCqez7SANeahDsJTD3AEua34EoQN9pHS6S5Bq9emcIaGGySt/4X2zSi+vF5hAH52sEen7IO7g==
dependencies:
- "@typescript-eslint/experimental-utils" "5.1.0"
- "@typescript-eslint/scope-manager" "5.1.0"
+ "@typescript-eslint/experimental-utils" "5.3.0"
+ "@typescript-eslint/scope-manager" "5.3.0"
debug "^4.3.2"
functional-red-black-tree "^1.0.1"
ignore "^5.1.8"
@@ -2629,59 +2568,107 @@
semver "^7.3.5"
tsutils "^3.21.0"
-"@typescript-eslint/experimental-utils@5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.1.0.tgz#918a1a3d30404cc1f8edcfdf0df200804ef90d31"
- integrity sha512-ovE9qUiZMOMgxQAESZsdBT+EXIfx/YUYAbwGUI6V03amFdOOxI9c6kitkgRvLkJaLusgMZ2xBhss+tQ0Y1HWxA==
+"@typescript-eslint/experimental-utils@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.2.0.tgz#e3b2cb9cd0aff9b50f68d9a414c299fd26b067e6"
+ integrity sha512-fWyT3Agf7n7HuZZRpvUYdFYbPk3iDCq6fgu3ulia4c7yxmPnwVBovdSOX7RL+k8u6hLbrXcdAehlWUVpGh6IEw==
+ dependencies:
+ "@types/json-schema" "^7.0.9"
+ "@typescript-eslint/scope-manager" "5.2.0"
+ "@typescript-eslint/types" "5.2.0"
+ "@typescript-eslint/typescript-estree" "5.2.0"
+ eslint-scope "^5.1.1"
+ eslint-utils "^3.0.0"
+
+"@typescript-eslint/experimental-utils@5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.3.0.tgz#ee56b4957547ed2b0fc7451205e41502e664f546"
+ integrity sha512-NFVxYTjKj69qB0FM+piah1x3G/63WB8vCBMnlnEHUsiLzXSTWb9FmFn36FD9Zb4APKBLY3xRArOGSMQkuzTF1w==
dependencies:
"@types/json-schema" "^7.0.9"
- "@typescript-eslint/scope-manager" "5.1.0"
- "@typescript-eslint/types" "5.1.0"
- "@typescript-eslint/typescript-estree" "5.1.0"
+ "@typescript-eslint/scope-manager" "5.3.0"
+ "@typescript-eslint/types" "5.3.0"
+ "@typescript-eslint/typescript-estree" "5.3.0"
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
-"@typescript-eslint/parser@5.1.0", "@typescript-eslint/parser@^5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.1.0.tgz#6c7f837d210d2bc0a811e7ea742af414f4e00908"
- integrity sha512-vx1P+mhCtYw3+bRHmbalq/VKP2Y3gnzNgxGxfEWc6OFpuEL7iQdAeq11Ke3Rhy8NjgB+AHsIWEwni3e+Y7djKA==
+"@typescript-eslint/parser@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.2.0.tgz#dc081aa89de16b5676b10215519af3aa7b58fb72"
+ integrity sha512-Uyy4TjJBlh3NuA8/4yIQptyJb95Qz5PX//6p8n7zG0QnN4o3NF9Je3JHbVU7fxf5ncSXTmnvMtd/LDQWDk0YqA==
dependencies:
- "@typescript-eslint/scope-manager" "5.1.0"
- "@typescript-eslint/types" "5.1.0"
- "@typescript-eslint/typescript-estree" "5.1.0"
+ "@typescript-eslint/scope-manager" "5.2.0"
+ "@typescript-eslint/types" "5.2.0"
+ "@typescript-eslint/typescript-estree" "5.2.0"
debug "^4.3.2"
-"@typescript-eslint/scope-manager@5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.1.0.tgz#6f1f26ad66a8f71bbb33b635e74fec43f76b44df"
- integrity sha512-yYlyVjvn5lvwCL37i4hPsa1s0ORsjkauhTqbb8MnpvUs7xykmcjGqwlNZ2Q5QpoqkJ1odlM2bqHqJwa28qV6Tw==
+"@typescript-eslint/parser@^5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.3.0.tgz#7879f15e26d370ed3f653fb7dd06479531ed3ab9"
+ integrity sha512-rKu/yAReip7ovx8UwOAszJVO5MgBquo8WjIQcp1gx4pYQCwYzag+I5nVNHO4MqyMkAo0gWt2gWUi+36gWAVKcw==
dependencies:
- "@typescript-eslint/types" "5.1.0"
- "@typescript-eslint/visitor-keys" "5.1.0"
+ "@typescript-eslint/scope-manager" "5.3.0"
+ "@typescript-eslint/types" "5.3.0"
+ "@typescript-eslint/typescript-estree" "5.3.0"
+ debug "^4.3.2"
+"@typescript-eslint/scope-manager@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.2.0.tgz#7ce8e4ab2baaa0ad5282913ea8e13ce03ec6a12a"
+ integrity sha512-RW+wowZqPzQw8MUFltfKYZfKXqA2qgyi6oi/31J1zfXJRpOn6tCaZtd9b5u9ubnDG2n/EMvQLeZrsLNPpaUiFQ==
+ dependencies:
+ "@typescript-eslint/types" "5.2.0"
+ "@typescript-eslint/visitor-keys" "5.2.0"
+
+"@typescript-eslint/scope-manager@5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.3.0.tgz#97d0ccc7c9158e89e202d5e24ce6ba49052d432e"
+ integrity sha512-22Uic9oRlTsPppy5Tcwfj+QET5RWEnZ5414Prby465XxQrQFZ6nnm5KnXgnsAJefG4hEgMnaxTB3kNEyjdjj6A==
+ dependencies:
+ "@typescript-eslint/types" "5.3.0"
+ "@typescript-eslint/visitor-keys" "5.3.0"
+
"@typescript-eslint/types@4.27.0":
version "4.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-4.27.0.tgz#712b408519ed699baff69086bc59cd2fc13df8d8"
integrity sha512-I4ps3SCPFCKclRcvnsVA/7sWzh7naaM/b4pBO2hVxnM3wrU51Lveybdw5WoIktU/V4KfXrTt94V9b065b/0+wA==
-"@typescript-eslint/types@5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.1.0.tgz#a8a75ddfc611660de6be17d3ad950302385607a9"
- integrity sha512-sEwNINVxcB4ZgC6Fe6rUyMlvsB2jvVdgxjZEjQUQVlaSPMNamDOwO6/TB98kFt4sYYfNhdhTPBEQqNQZjMMswA==
+"@typescript-eslint/types@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.2.0.tgz#7ad32d15abddb0ee968a330f0ea182ea544ef7cf"
+ integrity sha512-cTk6x08qqosps6sPyP2j7NxyFPlCNsJwSDasqPNjEQ8JMD5xxj2NHxcLin5AJQ8pAVwpQ8BMI3bTxR0zxmK9qQ==
+
+"@typescript-eslint/types@5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.3.0.tgz#af29fd53867c2df0028c57c36a655bd7e9e05416"
+ integrity sha512-fce5pG41/w8O6ahQEhXmMV+xuh4+GayzqEogN24EK+vECA3I6pUwKuLi5QbXO721EMitpQne5VKXofPonYlAQg==
-"@typescript-eslint/typescript-estree@5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.1.0.tgz#132aea34372df09decda961cb42457433aa6e83d"
- integrity sha512-SSz+l9YrIIsW4s0ZqaEfnjl156XQ4VRmJsbA0ZE1XkXrD3cRpzuZSVCyqeCMR3EBjF27IisWakbBDGhGNIOvfQ==
+"@typescript-eslint/typescript-estree@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.2.0.tgz#c22e0ff6f8a4a3f78504a80ebd686fe2870a68ae"
+ integrity sha512-RsdXq2XmVgKbm9nLsE3mjNUM7BTr/K4DYR9WfFVMUuozHWtH5gMpiNZmtrMG8GR385EOSQ3kC9HiEMJWimxd/g==
dependencies:
- "@typescript-eslint/types" "5.1.0"
- "@typescript-eslint/visitor-keys" "5.1.0"
+ "@typescript-eslint/types" "5.2.0"
+ "@typescript-eslint/visitor-keys" "5.2.0"
debug "^4.3.2"
globby "^11.0.4"
is-glob "^4.0.3"
semver "^7.3.5"
tsutils "^3.21.0"
+"@typescript-eslint/typescript-estree@5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.3.0.tgz#4f68ddd46dc2983182402d2ab21fb44ad94988cf"
+ integrity sha512-FJ0nqcaUOpn/6Z4Jwbtf+o0valjBLkqc3MWkMvrhA2TvzFXtcclIM8F4MBEmYa2kgcI8EZeSAzwoSrIC8JYkug==
+ dependencies:
+ "@typescript-eslint/types" "5.3.0"
+ "@typescript-eslint/visitor-keys" "5.3.0"
+ debug "^4.3.2"
+ globby "^11.0.4"
+ is-glob "^4.0.3"
+ semver "^7.3.5"
+ tsutils "^3.21.0"
+
"@typescript-eslint/typescript-estree@^4.8.2":
version "4.27.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-4.27.0.tgz#189a7b9f1d0717d5cccdcc17247692dedf7a09da"
@@ -2703,12 +2690,20 @@
"@typescript-eslint/types" "4.27.0"
eslint-visitor-keys "^2.0.0"
-"@typescript-eslint/visitor-keys@5.1.0":
- version "5.1.0"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.1.0.tgz#e01a01b27eb173092705ae983aa1451bd1842630"
- integrity sha512-uqNXepKBg81JVwjuqAxYrXa1Ql/YDzM+8g/pS+TCPxba0wZttl8m5DkrasbfnmJGHs4lQ2jTbcZ5azGhI7kK+w==
+"@typescript-eslint/visitor-keys@5.2.0":
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.2.0.tgz#03522d35df98474f08e0357171a7d1b259a88f55"
+ integrity sha512-Nk7HizaXWWCUBfLA/rPNKMzXzWS8Wg9qHMuGtT+v2/YpPij4nVXrVJc24N/r5WrrmqK31jCrZxeHqIgqRzs0Xg==
+ dependencies:
+ "@typescript-eslint/types" "5.2.0"
+ eslint-visitor-keys "^3.0.0"
+
+"@typescript-eslint/visitor-keys@5.3.0":
+ version "5.3.0"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.3.0.tgz#a6258790f3b7b2547f70ed8d4a1e0c3499994523"
+ integrity sha512-oVIAfIQuq0x2TFDNLVavUn548WL+7hdhxYn+9j3YdJJXB7mH9dAmZNJsPDa7Jc+B9WGqoiex7GUDbyMxV0a/aw==
dependencies:
- "@typescript-eslint/types" "5.1.0"
+ "@typescript-eslint/types" "5.3.0"
eslint-visitor-keys "^3.0.0"
"@ungap/promise-all-settled@1.1.2":
@@ -2716,10 +2711,10 @@
resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44"
integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==
-"@vue/component-compiler-utils@^3.2.2":
- version "3.2.2"
- resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-3.2.2.tgz#2f7ed5feed82ff7f0284acc11d525ee7eff22460"
- integrity sha512-rAYMLmgMuqJFWAOb3Awjqqv5X3Q3hVr4jH/kgrFJpiU0j3a90tnNBplqbj+snzrgZhC9W128z+dtgMifOiMfJg==
+"@vue/component-compiler-utils@^3.3.0":
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-3.3.0.tgz#f9f5fb53464b0c37b2c8d2f3fbfe44df60f61dc9"
+ integrity sha512-97sfH2mYNU+2PzGrmK2haqffDpVASuib9/w2/noxiFi31Z54hW+q3izKQXXQZSNhtiUpAI36uSuYepeBe4wpHQ==
dependencies:
consolidate "^0.15.1"
hash-sum "^1.0.2"
@@ -2730,7 +2725,7 @@
source-map "~0.6.1"
vue-template-es2015-compiler "^1.9.0"
optionalDependencies:
- prettier "^1.18.2"
+ prettier "^1.18.2 || ^2.0.0"
abab@^2.0.3, abab@^2.0.5:
version "2.0.5"
@@ -3383,7 +3378,7 @@
escalade "^3.1.1"
node-releases "^1.1.73"
-browserslist@^4.17.4, browserslist@^4.17.5:
+browserslist@^4.17.5:
version "4.17.5"
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.17.5.tgz#c827bbe172a4c22b123f5e337533ceebadfdd559"
integrity sha512-I3ekeB92mmpctWBoLXe0d5wPS2cBuRvvW0JyyJHMrk9/HmP2ZjrTboNAZ8iuGqaEIlKguljbQY32OkOJIRrgoA==
@@ -4681,10 +4676,10 @@
resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-7.0.0.tgz#a1dad262f46d2184a90095a60c66fef74727f0f8"
integrity sha512-U3vEDB5zhYPNfxT5TYR7u01dboFZp+HNpnGhkDB2g/2E4wZ/g1Q9Ton8UwCLfRV9yAKyYqDh62oHOamvkFxsvw==
-eslint-plugin-sort-destructure-keys@^1.3.5:
- version "1.3.5"
- resolved "https://registry.yarnpkg.com/eslint-plugin-sort-destructure-keys/-/eslint-plugin-sort-destructure-keys-1.3.5.tgz#c6f45c3e58d4435564025a6ca5f4a838010800fd"
- integrity sha512-JmVpidhDsLwZsmRDV7Tf/vZgOAOEQGkLtwToSvX5mD8fuWYS/xkgMRBsalW1fGlc8CgJJwnzropt4oMQ7YCHLg==
+eslint-plugin-sort-destructure-keys@^1.4.0:
+ version "1.4.0"
+ resolved "https://registry.yarnpkg.com/eslint-plugin-sort-destructure-keys/-/eslint-plugin-sort-destructure-keys-1.4.0.tgz#45924521e556692002522468a75b6a9fbac11316"
+ integrity sha512-txU9l22mblz7YpyjJNYFy4wb5PVXiRMbc9lqFPPhvY4wKyBBYQvb31TIcduf7iRb4Bv01aiXcJiuCkOOrVY48Q==
dependencies:
natural-compare-lite "^1.4.0"
@@ -8111,12 +8106,7 @@
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
integrity sha1-6SQ0v6XqjBn0HN/UAddBo8gZ2Jc=
-prettier@^1.18.2:
- version "1.19.1"
- resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.19.1.tgz#f7d7f5ff8a9cd872a7be4ca142095956a60797cb"
- integrity sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==
-
-prettier@^2.4.1:
+"prettier@^1.18.2 || ^2.0.0", prettier@^2.4.1:
version "2.4.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.4.1.tgz#671e11c89c14a4cfc876ce564106c4a6726c9f5c"
integrity sha512-9fbDAXSBcc6Bs1mZrDYb3XKzDLm4EXXL9sC1LqKP5rZkT6KRr/rf9amVUcODVXgguK/isJz0d0hP72WeaKWsvA==
@@ -8595,10 +8585,10 @@
dependencies:
bn.js "^5.2.0"
-rollup@^2.58.0:
- version "2.58.3"
- resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.58.3.tgz#71a08138d9515fb65043b6a18618b2ed9ac8d239"
- integrity sha512-ei27MSw1KhRur4p87Q0/Va2NAYqMXOX++FNEumMBcdreIRLURKy+cE2wcDJKBn0nfmhP2ZGrJkP1XPO+G8FJQw==
+rollup@^2.58.3:
+ version "2.59.0"
+ resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.59.0.tgz#108c61b0fa0a37ebc8d1f164f281622056f0db59"
+ integrity sha512-l7s90JQhCQ6JyZjKgo7Lq1dKh2RxatOM+Jr6a9F7WbS9WgKbocyUSeLmZl8evAse7y96Ae98L2k1cBOwWD8nHw==
optionalDependencies:
fsevents "~2.3.2"