git.delta.rocks / unique-network / refs/commits / 2870ffebb9d9

difftreelog

Merge branch 'develop' of https://github.com/UniqueNetwork/unique-chain into develop

Dev2022-07-12parents: #efc3398 #12c8c8f.patch.diff
in: master

4 files changed

modifiedruntime/opal/src/lib.rsdiffbeforeafterboth
--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -707,7 +707,6 @@
 pub type Barrier = (
 	TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom<Everything>,
-	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
 	// ^^^ Parent & its unit plurality gets free execution
 );
 
modifiedruntime/quartz/src/lib.rsdiffbeforeafterboth
--- a/runtime/quartz/src/lib.rs
+++ b/runtime/quartz/src/lib.rs
@@ -706,7 +706,6 @@
 pub type Barrier = (
 	TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom<Everything>,
-	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
 	// ^^^ Parent & its unit plurality gets free execution
 );
 
modifiedruntime/unique/src/lib.rsdiffbeforeafterboth
--- a/runtime/unique/src/lib.rs
+++ b/runtime/unique/src/lib.rs
@@ -705,7 +705,6 @@
 pub type Barrier = (
 	TakeWeightCredit,
 	AllowTopLevelPaidExecutionFrom<Everything>,
-	AllowUnpaidExecutionFrom<ParentOrParentsUnitPlurality>,
 	// ^^^ Parent & its unit plurality gets free execution
 );
 
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';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031const UNIQUE_CHAIN = 1000;32const KARURA_CHAIN = 2000;33const KARURA_PORT = '9946';3435describe('Integration test: Exchanging QTZ with Karura', () => {36  let alice: IKeyringPair;37  38  before(async () => {39    await usingApi(async (api, privateKeyWrapper) => {40      alice = privateKeyWrapper('//Alice');41    });4243    const karuraApiOptions: ApiOptions = {44      provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT),45    };4647    await usingApi(async (api) => {48      const destination = {49        V0: {50          X2: [51            'Parent',52            {53              Parachain: UNIQUE_CHAIN,54            },55          ],56        },57      };5859      const metadata =60      {61        name: 'QTZ',62        symbol: 'QTZ',63        decimals: 18,64        minimalBalance: 1,65      };6667      const tx = api.tx.assetRegistry.registerForeignAsset(destination, metadata);68      const sudoTx = api.tx.sudo.sudo(tx as any);69      const events = await submitTransactionAsync(alice, sudoTx);70      const result = getGenericResult(events);71      expect(result.success).to.be.true;72    }, karuraApiOptions);73  });7475  it('Should connect and send QTZ to Karura', async () => {76    let balanceOnKaruraBefore: bigint;77    78    await usingApi(async (api) => {79      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;80      balanceOnKaruraBefore = free;81    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});8283    await usingApi(async (api) => {84      const destination = {85        V0: {86          X2: [87            'Parent',88            {89              Parachain: KARURA_CHAIN,90            },91          ],92        },93      };9495      const beneficiary = {96        V0: {97          X1: {98            AccountId32: {99              network: 'Any',100              id: alice.addressRaw,101            },102          },103        },104      };105106      const assets = {107        V1: [108          {109            id: {110              Concrete: {111                parents: 0,112                interior: 'Here',113              },114            },115            fun: {116              Fungible: 5000000000,117            },118          },119        ],120      };121122      const feeAssetItem = 0;123124      const weightLimit = {125        Limited: 5000000000,126      };127128      const tx = api.tx.polkadotXcm.limitedReserveTransferAssets(destination, beneficiary, assets, feeAssetItem, weightLimit);129      const events = await submitTransactionAsync(alice, tx);130      const result = getGenericResult(events);131      expect(result.success).to.be.true;132    });133134    await usingApi(async (api) => {135      // todo do something about instant sealing, where there might not be any new blocks136      await waitNewBlocks(api, 3);137      const {free} = (await api.query.tokens.accounts(alice.addressRaw, {ForeignAsset: 0})).toJSON() as any;138      expect(free > balanceOnKaruraBefore).to.be.true;139    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});140  });141142  it('Should connect to Karura and send QTZ back', async () => {143    let balanceBefore: bigint;144    145    await usingApi(async (api) => {146      [balanceBefore] = await getBalance(api, [alice.address]);147    });148149    await usingApi(async (api) => {150      const destination = {151        V0: {152          X3: [153            'Parent',154            {155              Parachain: UNIQUE_CHAIN,156            },157            {158              AccountId32: {159                network: 'Any',160                id: alice.addressRaw,161              },162            },163          ],164        },165      };166167      const id = {168        ForeignAsset: 0,169      };170171      const amount = 5000000000;172      const destWeight = 50000000;173174      const tx = api.tx.xTokens.transfer(id, amount, destination, destWeight);175      const events = await submitTransactionAsync(alice, tx);176      const result = getGenericResult(events);177      expect(result.success).to.be.true;178    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});179180    await usingApi(async (api) => {181      // todo do something about instant sealing, where there might not be any new blocks182      await waitNewBlocks(api, 3);183      const [balanceAfter] = await getBalance(api, [alice.address]);184      expect(balanceAfter > balanceBefore).to.be.true;185    });186  });187});
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';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031const UNIQUE_CHAIN = 1000;32const KARURA_CHAIN = 2000;33const KARURA_PORT = '9946';34const TRANSFER_AMOUNT = 2000000000000000000000000n;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: TRANSFER_AMOUNT,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, [alice.address]);148    });149150    await usingApi(async (api) => {151      const destination = {152        V1: {153          parents: 1,154          interior: {155            X2: [156              {Parachain: UNIQUE_CHAIN},157              {AccountId32: {158                network: 'Any',159                id: alice.addressRaw,160              }},161            ],162          },163        },164      };165166      const id = {167        ForeignAsset: 0,168      };169170      const amount = TRANSFER_AMOUNT;171      const destWeight = 50000000;172173      const tx = api.tx.xTokens.transfer(id, amount, destination, destWeight);174      const events = await submitTransactionAsync(alice, tx);175      const result = getGenericResult(events);176      expect(result.success).to.be.true;177    }, {provider: new WsProvider('ws://127.0.0.1:' + KARURA_PORT)});178179    await usingApi(async (api) => {180      // todo do something about instant sealing, where there might not be any new blocks181      await waitNewBlocks(api, 3);182      const [balanceAfter] = await getBalance(api, [alice.address]);183      expect(balanceAfter > balanceBefore).to.be.true;184    });185  });186});