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

difftreelog

Merge branch 'master' into release-v922000

kozyrevdev2022-06-03parents: #3d5365c #9bbb154.patch.diff
in: master

9 files changed

modifiedREADME.mddiffbeforeafterboth
--- a/README.md
+++ b/README.md
@@ -62,8 +62,18 @@
 ```
 
 5. Build:
+
+Opal
+```bash
+cargo build --release
+```
+Quartz
+```bash
+cargo build --features=quartz-runtime --release
+```
+Unique
 ```bash
-cargo build --features=unique-runtime,quartz-runtime --release
+cargo build --features=unique-runtime --release
 ```
 
 ## Building as Parachain locally
@@ -155,13 +165,13 @@
 location:
 	V0(X2(Parent, Parachain(PARA_ID)))
 metadata:
-	name         OPL
-	symbol       OPL
+	name         QTZ
+	symbol       QTZ
 	decimals     18
 minimalBalance	 1
 ```
 
-### Next, we can send tokens from Opal to Karura:
+### Next, we can send tokens from Quartz to Karura:
 ```
 polkadotXcm -> reserveTransferAssets
 dest:
@@ -179,7 +189,7 @@
 The result will be displayed in ChainState
 tokens -> accounts
 
-### To send tokens from Karura to Opal:
+### To send tokens from Karura to Quartz:
 ```
 xtokens -> transfer
 
modifiedclient/rpc/src/lib.rsdiffbeforeafterboth
--- a/client/rpc/src/lib.rs
+++ b/client/rpc/src/lib.rs
@@ -14,6 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+// Original License
 use std::sync::Arc;
 
 use codec::{Decode, Encode};
modifiednode/cli/src/service.rsdiffbeforeafterboth
--- a/node/cli/src/service.rs
+++ b/node/cli/src/service.rs
@@ -14,8 +14,6 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-//! Service and ServiceFactory implementation. Specialized wrapper over substrate service.
-
 // std
 use std::sync::Arc;
 use std::sync::Mutex;
modifiedpallets/scheduler/src/lib.rsdiffbeforeafterboth
--- a/pallets/scheduler/src/lib.rs
+++ b/pallets/scheduler/src/lib.rs
@@ -1,3 +1,20 @@
+// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.
+// This file is part of Unique Network.
+
+// Unique Network is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+
+// Unique Network is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
+
+// Original license:
 // This file is part of Substrate.
 
 // Copyright (C) 2017-2022 Parity Technologies (UK) Ltd.
modifiedtests/flipper-src/lib.rsdiffbeforeafterboth
--- a/tests/flipper-src/lib.rs
+++ b/tests/flipper-src/lib.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-// Original license
+// Original License
 // Copyright 2018-2020 Parity Technologies (UK) Ltd.
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
modifiedtests/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth
--- a/tests/ink-types-node-runtime/src/calls.rs
+++ b/tests/ink-types-node-runtime/src/calls.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-// Original license
+// Original License
 // Copyright 2019 Parity Technologies (UK) Ltd.
 // This file is part of ink!.
 //
modifiedtests/ink-types-node-runtime/src/lib.rsdiffbeforeafterboth
--- a/tests/ink-types-node-runtime/src/lib.rs
+++ b/tests/ink-types-node-runtime/src/lib.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
-// Original license
+// Original License
 // Copyright 2018-2019 Parity Technologies (UK) Ltd.
 // This file is part of ink!.
 //
modifiedtests/loadtester-src/lib.rsdiffbeforeafterboth
--- a/tests/loadtester-src/lib.rs
+++ b/tests/loadtester-src/lib.rs
@@ -14,6 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Unique Network. If not, see <http://www.gnu.org/licenses/>.
 
+// Original License
 #![cfg_attr(not(feature = "std"), no_std)]
 
 use ink_lang as ink;
modifiedtests/src/xcmTransfer.test.tsdiffbeforeafterboth
before · tests/src/xcmTransfer.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';1920import {WsProvider} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from './substrate/substrate-api';24import {getGenericResult} from './util/helpers';25import waitNewBlocks from './substrate/wait-new-blocks';26import getBalance from './substrate/get-balance';27import {alicesPublicKey} from './accounts';2829chai.use(chaiAsPromised);30const expect = chai.expect;3132const UNIQUE_CHAIN = 1000;33const KARURA_CHAIN = 2000;34const KARURA_PORT = '9946';3536describe('Integration test: Exchanging OPL with Karura', () => {37  let alice: IKeyringPair;38  39  before(async () => {40    await usingApi(async (api, privateKeyWrapper) => {41      alice = privateKeyWrapper('//Alice');42    });4344    const karuraApiOptions: ApiOptions = {45      provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT),46    };4748    await usingApi(async (api) => {49      const destination = {50        V0: {51          X2: [52            'Parent',53            {54              Parachain: UNIQUE_CHAIN,55            },56          ],57        },58      };5960      const metadata =61      {62        name: 'OPL',63        symbol: 'OPL',64        decimals: 18,65        minimalBalance: 1,66      };6768      const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);69      const sudoTx = api.tx.sudo.sudo(tx as any);70      const events = await submitTransactionAsync(alice, sudoTx);71      const result = getGenericResult(events);72      expect(result.success).to.be.true;73    }, karuraApiOptions);74  });7576  it('Should connect and send OPL to Karura', async () => {77    let balanceOnKaruraBefore: bigint;78    79    await usingApi(async (api) => {80      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;81      balanceOnKaruraBefore = free;82    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});8384    await usingApi(async (api) => {85      const destination = {86        V0: {87          X2: [88            'Parent',89            {90              Parachain: KARURA_CHAIN,91            },92          ],93        },94      };9596      const beneficiary = {97        V0: {98          X1: {99            AccountId32: {100              network: 'Any',101              id: alice.addressRaw,102            },103          },104        },105      };106107      const assets = {108        V1: [109          {110            id: {111              Concrete: {112                parents: 0,113                interior: 'Here',114              },115            },116            fun: {117              Fungible: 5000000000,118            },119          },120        ],121      };122123      const feeAssetItem = 0;124125      const weightLimit = {126        Limited: 5000000000,127      };128129      const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);130      const events = await submitTransactionAsync(alice, tx);131      const result = getGenericResult(events);132      expect(result.success).to.be.true;133    });134135    await usingApi(async (api) => {136      // todo do something about instant sealing, where there might not be any new blocks137      await waitNewBlocks(api, 3);138      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;139      expect(free > balanceOnKaruraBefore).to.be.true;140    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});141  });142143  it('Should connect to Karura and send OPL back', async () => {144    let balanceBefore: bigint;145    146    await usingApi(async (api) => {147      [balanceBefore] = await getBalance(api, [alicesPublicKey]);148    });149150    await usingApi(async (api) => {151      const destination = {152        V0: {153          X3: [154            'Parent',155            {156              Parachain: UNIQUE_CHAIN,157            },158            {159              AccountId32: {160                network: 'Any',161                id: alice.addressRaw,162              },163            },164          ],165        },166      };167168      const id = {169        ForeignAsset: 0,170      };171172      const amount = 5000000000;173      const destWeight = 50000000;174175      const tx = api.tx.xTokens.transfer(id, amount, destination, destWeight);176      const events = await submitTransactionAsync(alice, tx);177      const result = getGenericResult(events);178      expect(result.success).to.be.true;179    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});180181    await usingApi(async (api) => {182      // todo do something about instant sealing, where there might not be any new blocks183      await waitNewBlocks(api, 3);184      const [balanceAfter] = await getBalance(api, [alicesPublicKey]);185      expect(balanceAfter > balanceBefore).to.be.true;186    });187  });188});
after · tests/src/xcmTransfer.test.ts
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617import chai from 'chai';18import chaiAsPromised from 'chai-as-promised';1920import {WsProvider} from '@polkadot/api';21import {ApiOptions} from '@polkadot/api/types';22import {IKeyringPair} from '@polkadot/types/types';23import usingApi, {submitTransactionAsync} from './substrate/substrate-api';24import {getGenericResult} from './util/helpers';25import waitNewBlocks from './substrate/wait-new-blocks';26import getBalance from './substrate/get-balance';27import {alicesPublicKey} from './accounts';2829chai.use(chaiAsPromised);30const expect = chai.expect;3132const UNIQUE_CHAIN = 1000;33const KARURA_CHAIN = 2000;34const KARURA_PORT = '9946';3536describe('Integration test: Exchanging QTZ with Karura', () => {37  let alice: IKeyringPair;38  39  before(async () => {40    await usingApi(async (api, privateKeyWrapper) => {41      alice = privateKeyWrapper('//Alice');42    });4344    const karuraApiOptions: ApiOptions = {45      provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT),46    };4748    await usingApi(async (api) => {49      const destination = {50        V0: {51          X2: [52            'Parent',53            {54              Parachain: UNIQUE_CHAIN,55            },56          ],57        },58      };5960      const metadata =61      {62        name: 'QTZ',63        symbol: 'QTZ',64        decimals: 18,65        minimalBalance: 1,66      };6768      const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);69      const sudoTx = api.tx.sudo.sudo(tx as any);70      const events = await submitTransactionAsync(alice, sudoTx);71      const result = getGenericResult(events);72      expect(result.success).to.be.true;73    }, karuraApiOptions);74  });7576  it('Should connect and send QTZ to Karura', async () => {77    let balanceOnKaruraBefore: bigint;78    79    await usingApi(async (api) => {80      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;81      balanceOnKaruraBefore = free;82    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});8384    await usingApi(async (api) => {85      const destination = {86        V0: {87          X2: [88            'Parent',89            {90              Parachain: KARURA_CHAIN,91            },92          ],93        },94      };9596      const beneficiary = {97        V0: {98          X1: {99            AccountId32: {100              network: 'Any',101              id: alice.addressRaw,102            },103          },104        },105      };106107      const assets = {108        V1: [109          {110            id: {111              Concrete: {112                parents: 0,113                interior: 'Here',114              },115            },116            fun: {117              Fungible: 5000000000,118            },119          },120        ],121      };122123      const feeAssetItem = 0;124125      const weightLimit = {126        Limited: 5000000000,127      };128129      const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);130      const events = await submitTransactionAsync(alice, tx);131      const result = getGenericResult(events);132      expect(result.success).to.be.true;133    });134135    await usingApi(async (api) => {136      // todo do something about instant sealing, where there might not be any new blocks137      await waitNewBlocks(api, 3);138      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;139      expect(free > balanceOnKaruraBefore).to.be.true;140    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});141  });142143  it('Should connect to Karura and send QTZ back', async () => {144    let balanceBefore: bigint;145    146    await usingApi(async (api) => {147      [balanceBefore] = await getBalance(api, [alicesPublicKey]);148    });149150    await usingApi(async (api) => {151      const destination = {152        V0: {153          X3: [154            'Parent',155            {156              Parachain: UNIQUE_CHAIN,157            },158            {159              AccountId32: {160                network: 'Any',161                id: alice.addressRaw,162              },163            },164          ],165        },166      };167168      const id = {169        ForeignAsset: 0,170      };171172      const amount = 5000000000;173      const destWeight = 50000000;174175      const tx = api.tx.xTokens.transfer(id, amount, destination, destWeight);176      const events = await submitTransactionAsync(alice, tx);177      const result = getGenericResult(events);178      expect(result.success).to.be.true;179    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});180181    await usingApi(async (api) => {182      // todo do something about instant sealing, where there might not be any new blocks183      await waitNewBlocks(api, 3);184      const [balanceAfter] = await getBalance(api, [alicesPublicKey]);185      expect(balanceAfter > balanceBefore).to.be.true;186    });187  });188});