git.delta.rocks / unique-network / refs/commits / fbf17896e9db

difftreelog

Merge branch 'develop' into feature/NFTPAR-240

Greg Zaitsev2020-12-23parents: #3db9a79 #8686594.patch.diff
in: master

33 files changed

modifiedCargo.lockdiffbeforeafterboth
1227source = "registry+https://github.com/rust-lang/crates.io-index"1227source = "registry+https://github.com/rust-lang/crates.io-index"
1228checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"1228checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
1229
1230[[package]]
1231name = "enumflags2"
1232version = "0.6.4"
1233source = "registry+https://github.com/rust-lang/crates.io-index"
1234checksum = "83c8d82922337cd23a15f88b70d8e4ef5f11da38dd7cdb55e84dd5de99695da0"
1235dependencies = [
1236 "enumflags2_derive",
1237]
1238
1239[[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]
12291249
1230[[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]
4044
4045[[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]
40214058
4022[[package]]4059[[package]]
4023name = "parity-db"4060name = "parity-db"
modifiedLICENSEdiffbeforeafterboth
1This is free and unencumbered software released into the public domain.1USETECH PROFESSIONAL CONFIDENTIAL
2__________________
23
3Anyone 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 any
6means.
76
8In jurisdictions that recognize copyright laws, the author or authors7NOTICE: All information contained herein is, and remains
9of 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 contained
11of the public at large and to the detriment of our heirs and
12successors. 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.
15
16THE 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 material
20OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,14is strictly forbidden unless prior written permission is obtained
21ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR15from UseTech Professional LTD..
22OTHER DEALINGS IN THE SOFTWARE.
23
24For more information, please refer to <http://unlicense.org>
2516
modifiedREADME.mddiffbeforeafterboth
5252
532. 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>`.
5454
553. Install Rust Toolchain 1.44.0:553. Install Toolchain and make it default:
5656
57```bash57```bash
58rustup install 1.44.058rustup toolchain install nightly-2020-10-01
59rustup default nightly-2020-10-01
59```60```
6061
614. Make it default (actual toochain version may be different, so do a `rustup toolchain list` first)624. Add wasm target for default toolchain:
63
62```bash64```bash
63rustup toolchain list65rustup target add wasm32-unknown-unknown
64rustup default 1.44.0-x86_64-unknown-linux-gnu
65```66```
6667
675. Install nightly toolchain and add wasm target for it:685. Build:
68
69```bash69```bash
70rustup toolchain install nightly-2020-05-0170cargo build
71rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-01-x86_64-unknown-linux-gnu
72```71```
7372
746. Build:73optionally, build in release:
75```bash74```bash
76cargo build75cargo build --release
77```76```
7877
79## Run78## Run
133```132```
134133
135## UI custom types134## UI custom types
135
136Moved to [runtime_types.json](./runtime_types.json).
137
138## Running Integration Tests
136139
137Moved to [runtime_types.json](./runtime_types.json).140See [tests/README.md](./tests/README.md).
modifiednode/Cargo.tomldiffbeforeafterboth
58substrate-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'}
60
61serde = { version = "1.0.102", features = ["derive"] }
62serde_json = "1.0.41"
6063
61[features]64[features]
62default = []65default = []
modifiednode/build.rsdiffbeforeafterboth
1//
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
1use 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};
27
modifiednode/src/chain_spec.rsdiffbeforeafterboth
1//
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
1// 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;
1218
13// Note this is the URL for the telemetry server19// Note this is the URL for the telemetry server
14//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())?;
49
50 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)
4354
44 Ok(ChainSpec::from_genesis(55 Ok(ChainSpec::from_genesis(
45 // Name56 // Name
71 // Protocol ID82 // Protocol ID
72 None,83 None,
73 // Properties84 // Properties
74 None,85 Some(properties),
75 // Extensions86 // Extensions
76 None,87 None,
77 ))88 ))
133 enable_println: bool,144 enable_println: bool,
134) -> GenesisConfig {145) -> GenesisConfig {
146
147 let vested_accounts = vec![
148 get_account_id_from_seed::<sr25519::Public>("Bob"),
149 ];
150
135 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_accounts
176 .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,
modifiednode/src/main.rsdiffbeforeafterboth
1//
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
1//! Substrate Node Template CLI library.6//! Substrate Node Template CLI library.
2#![warn(missing_docs)]7#![warn(missing_docs)]
modifiednode/src/service.rsdiffbeforeafterboth
1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.1//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
2
3//
4// This file is subject to the terms and conditions defined in
5// file 'LICENSE', which is part of this source code package.
6//
27
3use std::sync::Arc;8use std::sync::Arc;
4use std::time::Duration;9use std::time::Duration;
modifiedpallets/nft/src/lib.rsdiffbeforeafterboth
1//
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
1#![recursion_limit = "1024"]6#![recursion_limit = "1024"]
27
modifiedruntime/Cargo.tomldiffbeforeafterboth
45pallet-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' }
59
60pallet-treasury = { version = "2.0.0", default-features = false, git = 'https://github.com/usetech-llc/substrate.git', branch = 'release_flexi' }
6161
62[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',
95
93 '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',
105108
106 'pallet-treasury/std',
107]109]
108110
modifiedruntime/src/lib.rsdiffbeforeafterboth
1//
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
1//! 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.
27
17use 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}
419
420parameter_types! {
421 pub const MinVestedTransfer: Balance = 100 * DOLLARS;
422}
423
424impl 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}
414431
415/// 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);
440458
modifiedruntime/src/nft_weights.rsdiffbeforeafterboth
1//
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
1use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};6use frame_support::weights::{Weight, constants::RocksDbWeight as DbWeight};
27
deletedtests/READMEdiffbeforeafterboth

no changes

addedtests/README.mddiffbeforeafterboth

no changes

modifiedtests/src/accounts.tsdiffbeforeafterboth
1//
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
1export 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';
modifiedtests/src/blocks-production.test.tsdiffbeforeafterboth
1//
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 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";
49
5describe('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, () => {
modifiedtests/src/config.tsdiffbeforeafterboth
1//
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 process from 'process';6import process from 'process';
27
modifiedtests/src/connection.test.tsdiffbeforeafterboth
1//
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 usingApi from "./substrate/substrate-api";6import usingApi from "./substrate/substrate-api";
2import { WsProvider } from '@polkadot/api';7import { WsProvider } from '@polkadot/api';
712
8const expect = chai.expect;13const expect = chai.expect;
914
10describe('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 });
1722
18 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 () {};
26
19 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;
33
34 delete console.log;
35 delete console.error;
25 });36 });
26});37});
modifiedtests/src/contracts.test.tsdiffbeforeafterboth
1//
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
6import { 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'
816
9const value = 0;17const value = 0;
10const gasLimit = 3000n * 1000000n;18const gasLimit = 3000n * 1000000n;
19const endowment = `1000000000000000`;
1120
12function 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) => {
2534
26function 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;
3038
31 const unsub = await blueprint.tx39 const unsub = await blueprint.tx
39 });47 });
40}48}
4149
42function runTransaction(privateKey: IKeyringPair, extrinsic: SubmittableExtrinsic<ApiTypes>) {50async function prepareDeployer(api: ApiPromise) {
43 return new Promise<void>(async (resolve, reject) => {51 // Find unused address
52 const deployer = await findUnusedAddress(api);
53
54 // Transfer balance to it
55 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;61
47 }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}
5864
59describe('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
6974
70 const code = new CodePromise(api, abi, wasm);75 const code = new CodePromise(api, abi, wasm);
7176
72 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'];
7479
75 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);
7782
78 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;
8691
87 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);
8994
90 const afterFlipGetResponse = await getFlipValue();95 const afterFlipGetResponse = await getFlipValue();
9196
112 // const bob = new GenericAccountId(api.registry, bobsPublicKey);117 // const bob = new GenericAccountId(api.registry, bobsPublicKey);
113118
114 // 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);
116121
117 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);122 // const [alicesBalanceAfter, bobsBalanceAfter] = await getBalance(api, [alicesPublicKey, bobsPublicKey]);
118123
modifiedtests/src/createCollection.test.tsdiffbeforeafterboth
1//
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';
modifiedtests/src/createMultipleItems.test.tsdiffbeforeafterboth
1//
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 { assert } from 'chai';6import { assert } from 'chai';
2import { alicesPublicKey } from './accounts';7import { alicesPublicKey } from './accounts';
addedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth

no changes

deletedtests/src/crefitFeesToTreasury.test.tsdiffbeforeafterboth

no changes

addedtests/src/destroyCollection.test.tsdiffbeforeafterboth

no changes

modifiedtests/src/pallet-presence.test.tsdiffbeforeafterboth
1//
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 { 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}
13
14// Pallets that must always be present
15const requiredPallets = [
16 'nft', 'balances', 'contracts', 'randomnesscollectiveflip', 'system', 'timestamp', 'transactionpayment', 'treasury', 'vesting'
17];
18
19// Pallets that depend on consensus and governance configuration
20const consensusPallets = [
21 'sudo', 'grandpa', 'aura'
22];
823
9describe('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});
modifiedtests/src/substrate/get-balance.tsdiffbeforeafterboth
1//
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 { ApiPromise } from "@polkadot/api";6import { ApiPromise } from "@polkadot/api";
2import promisifySubstrate from "./promisify-substrate";7import promisifySubstrate from "./promisify-substrate";
modifiedtests/src/substrate/privateKey.tsdiffbeforeafterboth
1//
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 { Keyring } from "@polkadot/api";6import { Keyring } from "@polkadot/api";
2import { IKeyringPair } from "@polkadot/types/types";7import { IKeyringPair } from "@polkadot/types/types";
modifiedtests/src/substrate/promisify-substrate.tsdiffbeforeafterboth
1//
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 ApiPromise from "@polkadot/api/promise/Api";6import ApiPromise from "@polkadot/api/promise/Api";
27
modifiedtests/src/substrate/substrate-api.tsdiffbeforeafterboth
1//
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 { 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';
modifiedtests/src/substrate/wait-new-blocks.tsdiffbeforeafterboth
1//
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 { ApiPromise } from "@polkadot/api";6import { ApiPromise } from "@polkadot/api";
27
modifiedtests/src/transfer.test.tsdiffbeforeafterboth
1//
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 { 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'
613
7describe('Transfer', () => {14describe('Transfer', () => {
8 it('Balance transfers', async () => {15 it('Balance transfers', async () => {
2330
24 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 address
26 const pk = privateKey('//Ferdie');34 const pk = await findUnusedAddress(api);
2735
28 console.log = function () {};36 console.log = function () {};
29 console.error = function () {};37 console.error = function () {};
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
1//
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';
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';
816
9chai.use(chaiAsPromised);17chai.use(chaiAsPromised);
10const expect = chai.expect;18const expect = chai.expect;
49 return result;57 return result;
50}58}
5159
52export 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 transaction
55 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);
87
88 collectionId = result.collectionId;
78 });89 });
90
91 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}
modifiedtests/src/util/util.tsdiffbeforeafterboth
1//
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
1export function strToUTF16(str: string): any {6export function strToUTF16(str: string): any {
2 let buf: number[] = [];7 let buf: number[] = [];