difftreelog
Merge branch 'develop' into feature/NFTPAR-240
in: master
33 files changed
Cargo.lockdiffbeforeafterboth1227source = "registry+https://github.com/rust-lang/crates.io-index"1227source = "registry+https://github.com/rust-lang/crates.io-index"1228checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"1228checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"12291230[[package]]1231name = "enumflags2"1232version = "0.6.4"1233source = "registry+https://github.com/rust-lang/crates.io-index"1234checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0"1235dependencies = [1236 "enumflags2_derive",1237]12381239[[package]]1240name = "enumflags2_derive"1241version = "0.6.4"1242source = "registry+https://github.com/rust-lang/crates.io-index"1243checksum = "946ee94e3dbf58fdd324f9ce245c7b238d46a66f00e86a020b71996349e46cce"1244dependencies = [1245 "proc-macro2",1246 "quote",1247 "syn",1248]122912491230[[package]]1250[[package]]1231name = "env_logger"1251name = "env_logger"3502 "sc-rpc-api",3522 "sc-rpc-api",3503 "sc-service",3523 "sc-service",3504 "sc-transaction-pool",3524 "sc-transaction-pool",3525 "serde",3526 "serde_json",3505 "sp-api",3527 "sp-api",3506 "sp-block-builder",3528 "sp-block-builder",3507 "sp-blockchain",3529 "sp-blockchain",3541 "pallet-transaction-payment",3563 "pallet-transaction-payment",3542 "pallet-transaction-payment-rpc-runtime-api",3564 "pallet-transaction-payment-rpc-runtime-api",3543 "pallet-treasury",3565 "pallet-treasury",3566 "pallet-vesting",3544 "parity-scale-codec",3567 "parity-scale-codec",3545 "serde",3568 "serde",3546 "sp-api",3569 "sp-api",4019 "sp-std",4042 "sp-std",4020]4043]40444045[[package]]4046name = "pallet-vesting"4047version = "2.0.0"4048source = "git+https://github.com/usetech-llc/substrate.git?branch=release_flexi#59646c902484d9c5e8933a80cbed551228b81274"4049dependencies = [4050 "enumflags2",4051 "frame-support",4052 "frame-system",4053 "parity-scale-codec",4054 "serde",4055 "sp-runtime",4056 "sp-std",4057]402140584022[[package]]4059[[package]]4023name = "parity-db"4060name = "parity-db"LICENSEdiffbeforeafterboth1This is free and unencumbered software released into the public domain.1USETECH PROFESSIONAL CONFIDENTIAL2__________________233Anyone is free to copy, modify, publish, use, compile, sell, or4 [2019] - [2020] UseTech Professional LTD. 4distribute this software, either in source code form or as a compiled5 All Rights Reserved.5binary, for any purpose, commercial or non-commercial, and by any6means.768In jurisdictions that recognize copyright laws, the author or authors7NOTICE: All information contained herein is, and remains9of this software dedicate any and all copyright interest in the8the property of UseTech Professional LTD. and its suppliers,10software to the public domain. We make this dedication for the benefit9if any. The intellectual and technical concepts contained11of the public at large and to the detriment of our heirs and12successors. We intend this dedication to be an overt act of10herein are proprietary to UseTech Professional LTD.13relinquishment in perpetuity of all present and future rights to this11and its suppliers and may be covered by U.S. and Foreign Patents,14software under copyright law.1516THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,17EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF12patents in process, and are protected by trade secret or copyright law.18MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.19IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR13Dissemination of this information or reproduction of this material20OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,14is strictly forbidden unless prior written permission is obtained21ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR15from UseTech Professional LTD..22OTHER DEALINGS IN THE SOFTWARE.2324For more information, please refer to <http://unlicense.org>2516README.mddiffbeforeafterboth5252532. Remove all installed toolchains with `rustup toolchain list` and `rustup toolchain uninstall <toolchain>`.532. Remove all installed toolchains with `rustup toolchain list` and `rustup toolchain uninstall <toolchain>`.5454553. Install Rust Toolchain 1.44.0:553. Install Toolchain and make it default:565657```bash57```bash58rustup install 1.44.058rustup toolchain install nightly-2020-10-0159rustup default nightly-2020-10-0159```60```6061614. Make it default (actual toochain version may be different, so do a `rustup toolchain list` first)624. Add wasm target for default toolchain:6362```bash64```bash63rustup toolchain list65rustup target add wasm32-unknown-unknown64rustup default 1.44.0-x86_64-unknown-linux-gnu65```66```6667675. Install nightly toolchain and add wasm target for it:685. Build:6869```bash69```bash70rustup toolchain install nightly-2020-05-0170cargo build71rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-01-x86_64-unknown-linux-gnu72```71```7372746. Build:73optionally, build in release:75```bash74```bash76cargo build75cargo build --release77```76```787779## Run78## Run133```132```134133135## UI custom types134## UI custom types135136Moved to [runtime_types.json](./runtime_types.json).137138## Running Integration Tests136139137Moved to [runtime_types.json](./runtime_types.json).140See [tests/README.md](./tests/README.md).node/Cargo.tomldiffbeforeafterboth58substrate-frame-rpc-system = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi'}58substrate-frame-rpc-system = {version = '2.0.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi'}59pallet-contracts-rpc = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi'} 59pallet-contracts-rpc = {version = '0.8.0', git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi'} 6061serde = { version = "1.0.102", features = ["derive"] }62serde_json = "1.0.41"606361[features]64[features]62default = []65default = []node/build.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};6use substrate_build_script_utils::{generate_cargo_keys, rerun_if_git_head_changed};27node/src/chain_spec.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51// use nft_runtime::{6// use nft_runtime::{2// AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,7// AccountId, AuraConfig, BalancesConfig, GenesisConfig, GrandpaConfig, Signature, SudoConfig,9use sp_core::{sr25519, Pair, Public};14use sp_core::{sr25519, Pair, Public};10use sp_finality_grandpa::AuthorityId as GrandpaId;15use sp_finality_grandpa::AuthorityId as GrandpaId;11use sp_runtime::traits::{IdentifyAccount, Verify};16use sp_runtime::traits::{IdentifyAccount, Verify};17use serde_json::map::Map;121813// Note this is the URL for the telemetry server19// Note this is the URL for the telemetry server14//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";20//const STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";41pub fn development_config() -> Result<ChainSpec, String> {47pub fn development_config() -> Result<ChainSpec, String> {42 let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;48 let wasm_binary = WASM_BINARY.ok_or("Development wasm binary not available".to_string())?;4950 let mut properties = Map::new();51 properties.insert("tokenSymbol".into(), "UniqueTest".into());52 properties.insert("tokenDecimals".into(), 15.into());53 properties.insert("ss58Format".into(), 42.into()); // Generic Substrate wildcard (SS58 checksum preimage)435444 Ok(ChainSpec::from_genesis(55 Ok(ChainSpec::from_genesis(45 // Name56 // Name71 // Protocol ID82 // Protocol ID72 None,83 None,73 // Properties84 // Properties74 None,85 Some(properties),75 // Extensions86 // Extensions76 None,87 None,77 ))88 ))133 enable_println: bool,144 enable_println: bool,134) -> GenesisConfig {145) -> GenesisConfig {146147 let vested_accounts = vec![148 get_account_id_from_seed::<sr25519::Public>("Bob"),149 ];150135 GenesisConfig {151 GenesisConfig {136 system: Some(SystemConfig {152 system: Some(SystemConfig {155 }),171 }),156 pallet_treasury: Some(Default::default()),172 pallet_treasury: Some(Default::default()),157 pallet_sudo: Some(SudoConfig { key: root_key }),173 pallet_sudo: Some(SudoConfig { key: root_key }),174 pallet_vesting: Some(VestingConfig {175 vesting: vested_accounts176 .iter()177 .cloned()178 .map(|k| (k, 1000, 100, 1 << 98))179 .collect(),180 }),158 pallet_nft: Some(NftConfig {181 pallet_nft: Some(NftConfig {159 collection: vec![(182 collection: vec![(160 1,183 1,node/src/main.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51//! Substrate Node Template CLI library.6//! Substrate Node Template CLI library.2#![warn(missing_docs)]7#![warn(missing_docs)]node/src/service.rsdiffbeforeafterboth1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.23//4// This file is subject to the terms and conditions defined in5// file 'LICENSE', which is part of this source code package.6//273use std::sync::Arc;8use std::sync::Arc;4use std::time::Duration;9use std::time::Duration;pallets/nft/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//51#![recursion_limit = "1024"]6#![recursion_limit = "1024"]27runtime/Cargo.tomldiffbeforeafterboth45pallet-timestamp = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }45pallet-timestamp = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }46pallet-transaction-payment = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }46pallet-transaction-payment = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }47pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }47pallet-transaction-payment-rpc-runtime-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }48pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }49pallet-vesting = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }48sp-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }50sp-api = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }49sp-block-builder = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }51sp-block-builder = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }50sp-consensus-aura = { default-features = false, version = '0.8.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }52sp-consensus-aura = { default-features = false, version = '0.8.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }57sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }59sp-transaction-pool = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }58sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }60sp-version = { default-features = false, version = '2.0.0' , git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }5960pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }616162[features]62[features]63default = ['std']63default = ['std']90 'pallet-timestamp/std',90 'pallet-timestamp/std',91 'pallet-transaction-payment/std',91 'pallet-transaction-payment/std',92 'pallet-transaction-payment-rpc-runtime-api/std',92 'pallet-transaction-payment-rpc-runtime-api/std',93 'pallet-treasury/std',94 'pallet-vesting/std',9593 'pallet-nft/std',96 'pallet-nft/std',94 'sp-api/std',97 'sp-api/std',103 'sp-transaction-pool/std',106 'sp-transaction-pool/std',104 'sp-version/std',107 'sp-version/std',105108106 'pallet-treasury/std',107]109]108110runtime/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//51//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.6//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.2717use sp_runtime::{22use sp_runtime::{18 create_runtime_str, generic, impl_opaque_keys,23 create_runtime_str, generic, impl_opaque_keys,19 traits::{24 traits::{20 Convert, BlakeTwo256, Block as BlockT, IdentifyAccount, 25 Convert, ConvertInto, BlakeTwo256, Block as BlockT, IdentifyAccount, 21 IdentityLookup, NumberFor, Saturating, Verify,26 IdentityLookup, NumberFor, Saturating, Verify,22 },27 },23 transaction_validity::{TransactionSource, TransactionValidity},28 transaction_validity::{TransactionSource, TransactionValidity},412 type Call = Call;417 type Call = Call;413}418}419420parameter_types! {421 pub const MinVestedTransfer: Balance = 100 * DOLLARS;422}423424impl pallet_vesting::Trait for Runtime {425 type Event = Event;426 type Currency = Balances;427 type BlockNumberToBalance = ConvertInto;428 type MinVestedTransfer = MinVestedTransfer;429 type WeightInfo = ();430}414431415/// Used for the module nft in `./nft.rs`432/// Used for the module nft in `./nft.rs`416impl pallet_nft::Trait for Runtime {433impl pallet_nft::Trait for Runtime {435 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},452 Sudo: pallet_sudo::{Module, Call, Config<T>, Storage, Event<T>},436 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},453 Nft: pallet_nft::{Module, Call, Config<T>, Storage, Event<T>},437 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},454 Treasury: pallet_treasury::{Module, Call, Storage, Config, Event<T>},455 Vesting: pallet_vesting::{Module, Call, Config<T>, Storage, Event<T>},438 }456 }439);457);440458runtime/src/nft_weights.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};6use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};27tests/READMEdiffbeforeafterbothno changes
tests/README.mddiffbeforeafterbothno changes
tests/src/accounts.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51export const bobsPublicKey = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';6export const bobsPublicKey = '5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty';2export const alicesPublicKey = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';7export const alicesPublicKey = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY';3export const ferdiesPublicKey = '5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL';8export const ferdiesPublicKey = '5CiPPseXPECbkjWCa6MnjNokrgYjMqmKndv2rSnekmSK2DjL';49export const nullPublicKey = '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM';tests/src/blocks-production.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import usingApi from "./substrate/substrate-api";6import usingApi from "./substrate/substrate-api";2import promisifySubstrate from "./substrate/promisify-substrate";7import promisifySubstrate from "./substrate/promisify-substrate";3import { expect } from "chai";8import { expect } from "chai";495describe('Blocks Production', () => {10describe('Blocks Production smoke test', () => {6 it('Node produces new blocks', async () => {11 it('Node produces new blocks', async () => {7 await usingApi(async api => {12 await usingApi(async api => {8 const blocksPromise = promisifySubstrate(api, () => {13 const blocksPromise = promisifySubstrate(api, () => {tests/src/config.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import process from 'process';6import process from 'process';27tests/src/connection.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import usingApi from "./substrate/substrate-api";6import usingApi from "./substrate/substrate-api";2import { WsProvider } from '@polkadot/api';7import { WsProvider } from '@polkadot/api';7128const expect = chai.expect;13const expect = chai.expect;91410describe('Connection', () => {15describe('Connection smoke test', () => {11 it('Connection can be established', async () => {16 it('Connection can be established', async () => {12 await usingApi(async api => {17 await usingApi(async api => {13 const health = await api.rpc.system.health();18 const health = await api.rpc.system.health();16 });21 });172218 it('Cannot connect to 255.255.255.255', async () => {23 it('Cannot connect to 255.255.255.255', async () => {24 console.log = function () {};25 console.error = function () {};2619 const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');27 const neverConnectProvider = new WsProvider('ws://255.255.255.255:9944');20 await expect((async () => {28 await expect((async () => {23 }, { provider: neverConnectProvider });31 }, { provider: neverConnectProvider });24 })()).to.be.eventually.rejected;32 })()).to.be.eventually.rejected;3334 delete console.log;35 delete console.error;25 });36 });26});37});tests/src/contracts.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import { ApiPromise } from "@polkadot/api";1import { expect } from "chai";7import { expect } from "chai";2import usingApi from "./substrate/substrate-api";8import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";3import fs from "fs";9import fs from "fs";4import { Abi, BlueprintPromise, CodePromise } from "@polkadot/api-contract";10import { Abi, BlueprintPromise, CodePromise } from "@polkadot/api-contract";5import { IKeyringPair } from "@polkadot/types/types";11import { IKeyringPair } from "@polkadot/types/types";6import { Keyring } from "@polkadot/api";12import { Keyring } from "@polkadot/api";7import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";13import { ApiTypes, SubmittableExtrinsic } from "@polkadot/api/types";14import { BigNumber } from 'bignumber.js';15import { findUnusedAddress } from './util/helpers'8169const value = 0;17const value = 0;10const gasLimit = 3000n * 1000000n;18const gasLimit = 3000n * 1000000n;19const endowment = `1000000000000000`;112012function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<BlueprintPromise> {21function deployBlueprint(alice: IKeyringPair, code: CodePromise): Promise<BlueprintPromise> {13 return new Promise<BlueprintPromise>(async (resolve, reject) => {22 return new Promise<BlueprintPromise>(async (resolve, reject) => {253426function deployContract(alice: IKeyringPair, blueprint: BlueprintPromise) : Promise<any> {35function deployContract(alice: IKeyringPair, blueprint: BlueprintPromise) : Promise<any> {27 return new Promise<any>(async (resolve, reject) => {36 return new Promise<any>(async (resolve, reject) => {28 const endowment = 1000000000000000n;29 const initValue = true;37 const initValue = true;303831 const unsub = await blueprint.tx39 const unsub = await blueprint.tx39 });47 });40}48}414942function runTransaction(privateKey: IKeyringPair, extrinsic: SubmittableExtrinsic<ApiTypes>) {50async function prepareDeployer(api: ApiPromise) {43 return new Promise<void>(async (resolve, reject) => {51 // Find unused address52 const deployer = await findUnusedAddress(api);5354 // Transfer balance to it55 const keyring = new Keyring({ type: 'sr25519' });56 const alice = keyring.addFromUri(`//Alice`);57 let amount = new BigNumber(endowment);58 amount = amount.plus(1e15);44 extrinsic.signAndSend(privateKey, async result => {59 const tx = api.tx.balances.transfer(deployer.address, amount.toFixed());45 if(!result.isInBlock) {60 await submitTransactionAsync(alice, tx);46 return;6147 }62 return deployer;4863}49 if(result.findRecord('system', 'ExtrinsicSuccess')) {50 resolve();51 }52 else {53 reject('Failed to flip value.');54 }55 })56 });57}586459describe('Contracts', () => {65describe('Contracts smoke test', () => {60 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {66 it(`Can deploy smart contract Flipper, instantiate it and call it's get and flip messages.`, async () => {61 await usingApi(async api => {67 await usingApi(async api => {62 const keyring = new Keyring({ type: 'sr25519' });63 const alice = keyring.addFromUri("//Alice");68 const deployer = await prepareDeployer(api);64 69 65 const wasm = fs.readFileSync('./src/flipper/flipper.wasm');70 const wasm = fs.readFileSync('./src/flipper/flipper.wasm');66 71 697470 const code = new CodePromise(api, abi, wasm);75 const code = new CodePromise(api, abi, wasm);717672 const blueprint = await deployBlueprint(alice, code);77 const blueprint = await deployBlueprint(deployer, code);73 const contract = (await deployContract(alice, blueprint))['contract'];78 const contract = (await deployContract(deployer, blueprint))['contract'];747975 const getFlipValue = async () => {80 const getFlipValue = async () => {76 const result = await contract.query.get(alice.address, value, gasLimit);81 const result = await contract.query.get(deployer.address, value, gasLimit);778278 if(!result.result.isSuccess) {83 if(!result.result.isSuccess) {79 throw `Failed to get flipper value`;84 throw `Failed to get flipper value`;85 expect(initialGetResponse).to.be.true;90 expect(initialGetResponse).to.be.true;869187 const flip = contract.exec('flip', value, gasLimit);92 const flip = contract.exec('flip', value, gasLimit);88 await runTransaction(alice, flip);93 await submitTransactionAsync(deployer, flip);899490 const afterFlipGetResponse = await getFlipValue();95 const afterFlipGetResponse = await getFlipValue();9196112 // const bob = new GenericAccountId(api.registry, bobsPublicKey);117 // const bob = new GenericAccountId(api.registry, bobsPublicKey);113118114 // const transfer = contractInstance.exec('balance_transfer', 0, 1000000000000n, [bob, new u128(api.registry, 1000000)]);119 // const transfer = contractInstance.exec('balance_transfer', 0, 1000000000000n, [bob, new u128(api.registry, 1000000)]);115 // await runTransaction(alicesPrivateKey, transfer);120 // await submitTransactionAsync(alicesPrivateKey, transfer);116121117 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);122 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);118123tests/src/createCollection.test.tsdiffbeforeafterboth1//
2// This file is subject to the terms and conditions defined in
3// file 'LICENSE', which is part of this source code package.
4//
5
1import chai from 'chai';
6import chai from 'chai';
2import chaiAsPromised from 'chai-as-promised';
7import chaiAsPromised from 'chai-as-promised';
tests/src/createMultipleItems.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { assert } from 'chai';6import { assert } from 'chai';2import { alicesPublicKey } from './accounts';7import { alicesPublicKey } from './accounts';tests/src/creditFeesToTreasury.test.tsdiffbeforeafterbothno changes
tests/src/crefitFeesToTreasury.test.tsdiffbeforeafterbothno changes
tests/src/destroyCollection.test.tsdiffbeforeafterbothno changes
tests/src/pallet-presence.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { ApiPromise } from "@polkadot/api";6import { ApiPromise } from "@polkadot/api";2import { expect } from "chai";7import { expect } from "chai";6 return api.runtimeMetadata.asLatest.modules.map(m => m.name.toString().toLowerCase());11 return api.runtimeMetadata.asLatest.modules.map(m => m.name.toString().toLowerCase());7}12}1314// Pallets that must always be present15const requiredPallets = [16 'nft', 'balances', 'contracts', 'randomnesscollectiveflip', 'system', 'timestamp', 'transactionpayment', 'treasury', 'vesting'17];1819// Pallets that depend on consensus and governance configuration20const consensusPallets = [21 'sudo', 'grandpa', 'aura'22];8239describe('Pallet presence.', () => {24describe('Pallet presence', () => {10 it('NFT pallet is present.', async () => {25 it('Required pallets are present', async () => {11 await usingApi(async api => {26 await usingApi(async api => {27 for (let i=0; i<requiredPallets.length; i++) {12 expect(getModuleNames(api)).to.include('nft');28 expect(getModuleNames(api)).to.include(requiredPallets[i]);29 }13 });30 });14 });31 });15 it('Balances pallet is present.', async () => {32 it('Governance and consensus pallets are present', async () => {16 await usingApi(async api => {33 await usingApi(async api => {34 for (let i=0; i<consensusPallets.length; i++) {17 expect(getModuleNames(api)).to.include('balances');35 expect(getModuleNames(api)).to.include(consensusPallets[i]);36 }18 });37 });19 });38 });20 it('Contracts pallet is present.', async () => {39 it('No extra pallets are included', async () => {21 await usingApi(async api => {40 await usingApi(async api => {22 expect(getModuleNames(api)).to.include('contracts');41 expect(getModuleNames(api).length).to.be.equal(requiredPallets.length + consensusPallets.length);23 });42 });24 });43 });25});44});tests/src/substrate/get-balance.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { ApiPromise } from "@polkadot/api";6import { ApiPromise } from "@polkadot/api";2import promisifySubstrate from "./promisify-substrate";7import promisifySubstrate from "./promisify-substrate";tests/src/substrate/privateKey.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { Keyring } from "@polkadot/api";6import { Keyring } from "@polkadot/api";2import { IKeyringPair } from "@polkadot/types/types";7import { IKeyringPair } from "@polkadot/types/types";tests/src/substrate/promisify-substrate.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import ApiPromise from "@polkadot/api/promise/Api";6import ApiPromise from "@polkadot/api/promise/Api";27tests/src/substrate/substrate-api.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { WsProvider, ApiPromise } from "@polkadot/api";6import { WsProvider, ApiPromise } from "@polkadot/api";2import type { AccountId, Address, ApplyExtrinsicResult, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces';7import type { AccountId, Address, ApplyExtrinsicResult, DispatchError, DispatchInfo, EventRecord, Extrinsic, ExtrinsicStatus, Hash, RuntimeDispatchInfo } from '@polkadot/types/interfaces';tests/src/substrate/wait-new-blocks.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { ApiPromise } from "@polkadot/api";6import { ApiPromise } from "@polkadot/api";27tests/src/transfer.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import { expect, assert } from "chai";6import { expect, assert } from "chai";2import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";7import { default as usingApi, submitTransactionAsync } from "./substrate/substrate-api";3import { alicesPublicKey, bobsPublicKey, ferdiesPublicKey } from "./accounts";8import { alicesPublicKey, bobsPublicKey, ferdiesPublicKey } from "./accounts";4import privateKey from "./substrate/privateKey";9import privateKey from "./substrate/privateKey";5import getBalance from "./substrate/get-balance";10import getBalance from "./substrate/get-balance";11import { BigNumber } from 'bignumber.js';12import { findUnusedAddress } from './util/helpers'6137describe('Transfer', () => {14describe('Transfer', () => {8 it('Balance transfers', async () => {15 it('Balance transfers', async () => {233024 it('Inability to pay fees error message is correct', async () => {31 it('Inability to pay fees error message is correct', async () => {25 await usingApi(async api => {32 await usingApi(async api => {33 // Find unused address26 const pk = privateKey('//Ferdie');34 const pk = await findUnusedAddress(api);273528 console.log = function () {};36 console.log = function () {};29 console.error = function () {};37 console.error = function () {};tests/src/util/helpers.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51import chai from 'chai';6import chai from 'chai';2import chaiAsPromised from 'chai-as-promised';7import chaiAsPromised from 'chai-as-promised';3import type { EventRecord } from '@polkadot/types/interfaces';8import type { AccountId, EventRecord } from '@polkadot/types/interfaces';9import { ApiPromise, Keyring } from "@polkadot/api";4import { default as usingApi, submitTransactionAsync } from "../substrate/substrate-api";10import { default as usingApi, submitTransactionAsync } from "../substrate/substrate-api";5import privateKey from '../substrate/privateKey';11import privateKey from '../substrate/privateKey';6import { alicesPublicKey } from "../accounts";12import { alicesPublicKey } from "../accounts";7import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';13import { strToUTF16, utf16ToStr, hexToStr } from '../util/util';14import { IKeyringPair } from "@polkadot/types/types";15import { BigNumber } from 'bignumber.js';8169chai.use(chaiAsPromised);17chai.use(chaiAsPromised);10const expect = chai.expect;18const expect = chai.expect;49 return result;57 return result;50}58}515952export async function createCollectionExpectSuccess(name: string, description: string, tokenPrefix: string, mode: string) {60export async function createCollectionExpectSuccess(name: string, description: string, tokenPrefix: string, mode: string): Promise<number> {61 let collectionId: number = 0;53 await usingApi(async (api) => {62 await usingApi(async (api) => {54 // Get number of collections before the transaction63 // Get number of collections before the transaction55 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());64 const AcollectionCount = parseInt((await api.query.nft.createdCollectionCount()).toString());76 expect(utf16ToStr(collection.Description)).to.be.equal(description);85 expect(utf16ToStr(collection.Description)).to.be.equal(description);77 expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);86 expect(hexToStr(collection.TokenPrefix)).to.be.equal(tokenPrefix);8788 collectionId = result.collectionId;78 });89 });9091 return collectionId;79}92}80 93 81export async function createCollectionExpectFailure(name: string, description: string, tokenPrefix: string, mode: string) {94export async function createCollectionExpectFailure(name: string, description: string, tokenPrefix: string, mode: string) {98 });111 });99}112}100 113 101114export async function findUnusedAddress(api: ApiPromise): Promise<IKeyringPair> {115 let bal = new BigNumber(0);116 let unused;117 do {118 const randomSeed = 'seed' + Math.floor(Math.random() * Math.floor(10000));119 const keyring = new Keyring({ type: 'sr25519' });120 unused = keyring.addFromUri(`//${randomSeed}`);121 bal = new BigNumber((await api.query.system.account(unused.address)).data.free.toString());122 } while (bal.toFixed() != '0');123 return unused; 124}tests/src/util/util.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//51export function strToUTF16(str: string): any {6export function strToUTF16(str: string): any {2 let buf: number[] = [];7 let buf: number[] = [];