git.delta.rocks / unique-network / refs/commits / 950af3d1ff1e

difftreelog

Merge pull request #254 from UniqueNetwork/feature/decimals-18-v2

kozyrevdev2021-12-02parents: #0a9dcd5 #a3d7303.patch.diff
in: master
change decimals from 15 to 18

8 files changed

modifiedlaunch-config-westend.jsondiffbeforeafterboth
--- a/launch-config-westend.json
+++ b/launch-config-westend.json
@@ -79,9 +79,9 @@
     },
     "parachains": [
         {
-            "bin": "../unique-chain/target/release/nft",
+            "bin": "../unique-chain/target/release/unique-collator",
             "chain": "westend-local",
-            "balance": "1000000000000000000000",
+            "balance": "1000000000000000000000000",
             "nodes": [
                 {
                     "port": 31200,
modifiedlaunch-config.jsondiffbeforeafterboth
--- a/launch-config.json
+++ b/launch-config.json
@@ -57,7 +57,7 @@
         {
             "bin": "../unique-chain/target/release/unique-collator",
             "id": "2000",
-            "balance": "1000000000000000000000",
+            "balance": "1000000000000000000000000",
             "nodes": [
                 {
                     "port": 31200,
modifiednode/cli/src/chain_spec.rsdiffbeforeafterboth
--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -53,9 +53,9 @@
 
 pub fn development_config(id: ParaId) -> ChainSpec {
 	let mut properties = Map::new();
-	properties.insert("tokenSymbol".into(), "testUNQ".into());
+	properties.insert("tokenSymbol".into(), "OPL".into());
 	properties.insert("tokenDecimals".into(), 15.into());
-	properties.insert("ss58Format".into(), 42.into()); // Generic Substrate wildcard (SS58 checksum preimage)
+	properties.insert("ss58Format".into(), 42.into());
 
 	ChainSpec::from_genesis(
 		// Name
modifiedruntime/src/lib.rsdiffbeforeafterboth
--- a/runtime/src/lib.rs
+++ b/runtime/src/lib.rs
@@ -243,7 +243,7 @@
 impl FeeCalculator for FixedFee {
 	fn min_gas_price() -> U256 {
 		// Targeting 0.15 UNQ per transfer
-		1_024_947_215u32.into()
+		1_024_947_215_000u64.into()
 	}
 }
 
@@ -403,7 +403,7 @@
 	type WeightInfo = pallet_balances::weights::SubstrateWeight<Self>;
 }
 
-pub const MICROUNIQUE: Balance = 1_000_000_000;
+pub const MICROUNIQUE: Balance = 1_000_000_000_000;
 pub const MILLIUNIQUE: Balance = 1_000 * MICROUNIQUE;
 pub const CENTIUNIQUE: Balance = 10 * MILLIUNIQUE;
 pub const UNIQUE: Balance = 100 * CENTIUNIQUE;
@@ -481,7 +481,7 @@
 	fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
 		smallvec!(WeightToFeeCoefficient {
 			// Targeting 0.1 Unique per NFT transfer
-			coeff_integer: 142_688u32.into(),
+			coeff_integer: 142_688_000u32.into(),
 			coeff_frac: Perbill::zero(),
 			negative: false,
 			degree: 1,
modifiedtests/src/confirmSponsorship.test.tsdiffbeforeafterboth
before · tests/src/confirmSponsorship.test.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';9import {10  createCollectionExpectSuccess,11  setCollectionSponsorExpectSuccess,12  destroyCollectionExpectSuccess,13  confirmSponsorshipExpectSuccess,14  confirmSponsorshipExpectFailure,15  createItemExpectSuccess,16  findUnusedAddress,17  getGenericResult,18  enableAllowListExpectSuccess,19  enablePublicMintingExpectSuccess,20  addToAllowListExpectSuccess,21  normalizeAccountId,22  addCollectionAdminExpectSuccess,23  getCreatedCollectionCount,24} from './util/helpers';25import {Keyring} from '@polkadot/api';26import {IKeyringPair} from '@polkadot/types/types';2728chai.use(chaiAsPromised);29const expect = chai.expect;3031let alice: IKeyringPair;32let bob: IKeyringPair;33let charlie: IKeyringPair;3435describe('integration test: ext. confirmSponsorship():', () => {3637  before(async () => {38    await usingApi(async () => {39      const keyring = new Keyring({type: 'sr25519'});40      alice = keyring.addFromUri('//Alice');41      bob = keyring.addFromUri('//Bob');42      charlie = keyring.addFromUri('//Charlie');43    });44  });4546  it('Confirm collection sponsorship', async () => {47    const collectionId = await createCollectionExpectSuccess();48    await setCollectionSponsorExpectSuccess(collectionId, bob.address);49    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');50  });51  it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {52    const collectionId = await createCollectionExpectSuccess();53    await setCollectionSponsorExpectSuccess(collectionId, bob.address);54    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');55    await setCollectionSponsorExpectSuccess(collectionId, bob.address);56  });57  it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {58    const collectionId = await createCollectionExpectSuccess();59    await setCollectionSponsorExpectSuccess(collectionId, bob.address);60    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');61    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);62  });6364  it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {65    const collectionId = await createCollectionExpectSuccess();66    await setCollectionSponsorExpectSuccess(collectionId, bob.address);67    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6869    await usingApi(async (api) => {70      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();7172      // Find unused address73      const zeroBalance = await findUnusedAddress(api);7475      // Mint token for unused address76      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);7778      // Transfer this tokens from unused address to Alice79      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);80      const events = await submitTransactionAsync(zeroBalance, zeroToAlice);81      const result = getGenericResult(events);82      expect(result.success).to.be.true;8384      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();8586      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;87    });8889  });9091  it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {92    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});93    await setCollectionSponsorExpectSuccess(collectionId, bob.address);94    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');9596    await usingApi(async (api) => {97      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();9899      // Find unused address100      const zeroBalance = await findUnusedAddress(api);101102      // Mint token for unused address103      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);104105      // Transfer this tokens from unused address to Alice106      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);107      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);108      const result1 = getGenericResult(events1);109      expect(result1.success).to.be.true;110111      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();112113      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;114    });115  });116117  it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {118    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});119    await setCollectionSponsorExpectSuccess(collectionId, bob.address);120    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');121122    await usingApi(async (api) => {123      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();124125      // Find unused address126      const zeroBalance = await findUnusedAddress(api);127128      // Mint token for unused address129      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);130131      // Transfer this tokens from unused address to Alice132      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);133      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);134      const result1 = getGenericResult(events1);135136      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();137138      expect(result1.success).to.be.true;139      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;140    });141  });142143  it('CreateItem fees are paid by the sponsor after confirmation', async () => {144    const collectionId = await createCollectionExpectSuccess();145    await setCollectionSponsorExpectSuccess(collectionId, bob.address);146    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');147148    // Enable collection allow list149    await enableAllowListExpectSuccess(alice, collectionId);150151    // Enable public minting152    await enablePublicMintingExpectSuccess(alice, collectionId);153154    // Create Item155    await usingApi(async (api) => {156      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();157158      // Find unused address159      const zeroBalance = await findUnusedAddress(api);160161      // Add zeroBalance address to allow list162      await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);163164      // Mint token using unused address as signer165      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);166167      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();168169      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;170    });171  });172173  it('NFT: Sponsoring of transfers is rate limited', async () => {174    const collectionId = await createCollectionExpectSuccess();175    await setCollectionSponsorExpectSuccess(collectionId, bob.address);176    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');177178    await usingApi(async (api) => {179      // Find unused address180      const zeroBalance = await findUnusedAddress(api);181182      // Mint token for alice183      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);184185      // Transfer this token from Alice to unused address and back186      // Alice to Zero gets sponsored187      const aliceToZero = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);188      const events1 = await submitTransactionAsync(alice, aliceToZero);189      const result1 = getGenericResult(events1);190191      // Second transfer should fail192      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();193      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);194      const badTransaction = async function () {195        await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);196      };197      await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');198      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();199200      // Try again after Zero gets some balance - now it should succeed201      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);202      await submitTransactionAsync(alice, balancetx);203      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);204      const result2 = getGenericResult(events2);205206      expect(result1.success).to.be.true;207      expect(result2.success).to.be.true;208      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);209    });210  });211212  it('Fungible: Sponsoring is rate limited', async () => {213    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});214    await setCollectionSponsorExpectSuccess(collectionId, bob.address);215    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');216217    await usingApi(async (api) => {218      // Find unused address219      const zeroBalance = await findUnusedAddress(api);220221      // Mint token for unused address222      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);223224      // Transfer this tokens in parts from unused address to Alice225      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);226      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);227      const result1 = getGenericResult(events1);228      expect(result1.success).to.be.true;229230      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();231      await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejected;232      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();233234      // Try again after Zero gets some balance - now it should succeed235      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);236      await submitTransactionAsync(alice, balancetx);237      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);238      const result2 = getGenericResult(events2);239      expect(result2.success).to.be.true;240241      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);242    });243  });244245  it('ReFungible: Sponsoring is rate limited', async () => {246    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});247    await setCollectionSponsorExpectSuccess(collectionId, bob.address);248    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');249250    await usingApi(async (api) => {251      // Find unused address252      const zeroBalance = await findUnusedAddress(api);253254      // Mint token for alice255      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);256257      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);258259      // Zero to alice gets sponsored260      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);261      const result1 = getGenericResult(events1);262      expect(result1.success).to.be.true;263264      // Second transfer should fail265      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();266      await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejectedWith('Inability to pay some fees');267      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();268      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);269270      // Try again after Zero gets some balance - now it should succeed271      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);272      await submitTransactionAsync(alice, balancetx);273      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);274      const result2 = getGenericResult(events2);275      expect(result2.success).to.be.true;276    });277  });278279  it('NFT: Sponsoring of createItem is rate limited', async () => {280    const collectionId = await createCollectionExpectSuccess();281    await setCollectionSponsorExpectSuccess(collectionId, bob.address);282    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');283284    // Enable collection allow list285    await enableAllowListExpectSuccess(alice, collectionId);286287    // Enable public minting288    await enablePublicMintingExpectSuccess(alice, collectionId);289290    await usingApi(async (api) => {291      // Find unused address292      const zeroBalance = await findUnusedAddress(api);293294      // Add zeroBalance address to allow list295      await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);296297      // Mint token using unused address as signer - gets sponsored298      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);299300      // Second mint should fail301      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();302303      const badTransaction = async function () {304        await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);305      };306      await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');307      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();308309      // Try again after Zero gets some balance - now it should succeed310      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);311      await submitTransactionAsync(alice, balancetx);312      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);313314      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);315    });316  });317318});319320describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {321  before(async () => {322    await usingApi(async () => {323      const keyring = new Keyring({type: 'sr25519'});324      alice = keyring.addFromUri('//Alice');325      bob = keyring.addFromUri('//Bob');326      charlie = keyring.addFromUri('//Charlie');327    });328  });329330  it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {331    // Find the collection that never existed332    let collectionId = 0;333    await usingApi(async (api) => {334      collectionId = await getCreatedCollectionCount(api) + 1;335    });336337    await confirmSponsorshipExpectFailure(collectionId, '//Bob');338  });339340  it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {341    const collectionId = await createCollectionExpectSuccess();342    await setCollectionSponsorExpectSuccess(collectionId, bob.address);343344    await usingApi(async (api) => {345      const transfer = api.tx.balances.transfer(charlie.address, 1e15);346      await submitTransactionAsync(alice, transfer);347    });348349    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');350  });351352  it('(!negative test!) Confirm sponsorship using owner address', async () => {353    const collectionId = await createCollectionExpectSuccess();354    await setCollectionSponsorExpectSuccess(collectionId, bob.address);355    await confirmSponsorshipExpectFailure(collectionId, '//Alice');356  });357358  it('(!negative test!) Confirm sponsorship by collection admin', async () => {359    const collectionId = await createCollectionExpectSuccess();360    await setCollectionSponsorExpectSuccess(collectionId, bob.address);361    await addCollectionAdminExpectSuccess(alice, collectionId, charlie.address);362    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');363  });364365  it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {366    const collectionId = await createCollectionExpectSuccess();367    await confirmSponsorshipExpectFailure(collectionId, '//Bob');368  });369370  it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {371    const collectionId = await createCollectionExpectSuccess();372    await destroyCollectionExpectSuccess(collectionId);373    await confirmSponsorshipExpectFailure(collectionId, '//Bob');374  });375});
after · tests/src/confirmSponsorship.test.ts
1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import chai from 'chai';7import chaiAsPromised from 'chai-as-promised';8import {default as usingApi, submitTransactionAsync, submitTransactionExpectFailAsync} from './substrate/substrate-api';9import {10  createCollectionExpectSuccess,11  setCollectionSponsorExpectSuccess,12  destroyCollectionExpectSuccess,13  confirmSponsorshipExpectSuccess,14  confirmSponsorshipExpectFailure,15  createItemExpectSuccess,16  findUnusedAddress,17  getGenericResult,18  enableAllowListExpectSuccess,19  enablePublicMintingExpectSuccess,20  addToAllowListExpectSuccess,21  normalizeAccountId,22  addCollectionAdminExpectSuccess,23  getCreatedCollectionCount,24  UNIQUE,25} from './util/helpers';26import {Keyring} from '@polkadot/api';27import {IKeyringPair} from '@polkadot/types/types';2829chai.use(chaiAsPromised);30const expect = chai.expect;3132let alice: IKeyringPair;33let bob: IKeyringPair;34let charlie: IKeyringPair;3536describe('integration test: ext. confirmSponsorship():', () => {3738  before(async () => {39    await usingApi(async () => {40      const keyring = new Keyring({type: 'sr25519'});41      alice = keyring.addFromUri('//Alice');42      bob = keyring.addFromUri('//Bob');43      charlie = keyring.addFromUri('//Charlie');44    });45  });4647  it('Confirm collection sponsorship', async () => {48    const collectionId = await createCollectionExpectSuccess();49    await setCollectionSponsorExpectSuccess(collectionId, bob.address);50    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');51  });52  it('Add sponsor to a collection after the same sponsor was already added and confirmed', async () => {53    const collectionId = await createCollectionExpectSuccess();54    await setCollectionSponsorExpectSuccess(collectionId, bob.address);55    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');56    await setCollectionSponsorExpectSuccess(collectionId, bob.address);57  });58  it('Add new sponsor to a collection after another sponsor was already added and confirmed', async () => {59    const collectionId = await createCollectionExpectSuccess();60    await setCollectionSponsorExpectSuccess(collectionId, bob.address);61    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');62    await setCollectionSponsorExpectSuccess(collectionId, charlie.address);63  });6465  it('NFT: Transfer fees are paid by the sponsor after confirmation', async () => {66    const collectionId = await createCollectionExpectSuccess();67    await setCollectionSponsorExpectSuccess(collectionId, bob.address);68    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');6970    await usingApi(async (api) => {71      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();7273      // Find unused address74      const zeroBalance = await findUnusedAddress(api);7576      // Mint token for unused address77      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', zeroBalance.address);7879      // Transfer this tokens from unused address to Alice80      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);81      const events = await submitTransactionAsync(zeroBalance, zeroToAlice);82      const result = getGenericResult(events);83      expect(result.success).to.be.true;8485      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();8687      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;88    });8990  });9192  it('Fungible: Transfer fees are paid by the sponsor after confirmation', async () => {93    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});94    await setCollectionSponsorExpectSuccess(collectionId, bob.address);95    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');9697    await usingApi(async (api) => {98      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();99100      // Find unused address101      const zeroBalance = await findUnusedAddress(api);102103      // Mint token for unused address104      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);105106      // Transfer this tokens from unused address to Alice107      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);108      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);109      const result1 = getGenericResult(events1);110      expect(result1.success).to.be.true;111112      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();113114      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;115    });116  });117118  it('ReFungible: Transfer fees are paid by the sponsor after confirmation', async () => {119    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});120    await setCollectionSponsorExpectSuccess(collectionId, bob.address);121    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');122123    await usingApi(async (api) => {124      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();125126      // Find unused address127      const zeroBalance = await findUnusedAddress(api);128129      // Mint token for unused address130      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);131132      // Transfer this tokens from unused address to Alice133      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);134      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);135      const result1 = getGenericResult(events1);136137      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();138139      expect(result1.success).to.be.true;140      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;141    });142  });143144  it('CreateItem fees are paid by the sponsor after confirmation', async () => {145    const collectionId = await createCollectionExpectSuccess();146    await setCollectionSponsorExpectSuccess(collectionId, bob.address);147    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');148149    // Enable collection allow list150    await enableAllowListExpectSuccess(alice, collectionId);151152    // Enable public minting153    await enablePublicMintingExpectSuccess(alice, collectionId);154155    // Create Item156    await usingApi(async (api) => {157      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();158159      // Find unused address160      const zeroBalance = await findUnusedAddress(api);161162      // Add zeroBalance address to allow list163      await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);164165      // Mint token using unused address as signer166      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);167168      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();169170      expect(sponsorBalanceAfter < sponsorBalanceBefore).to.be.true;171    });172  });173174  it('NFT: Sponsoring of transfers is rate limited', async () => {175    const collectionId = await createCollectionExpectSuccess();176    await setCollectionSponsorExpectSuccess(collectionId, bob.address);177    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');178179    await usingApi(async (api) => {180      // Find unused address181      const zeroBalance = await findUnusedAddress(api);182183      // Mint token for alice184      const itemId = await createItemExpectSuccess(alice, collectionId, 'NFT', alice.address);185186      // Transfer this token from Alice to unused address and back187      // Alice to Zero gets sponsored188      const aliceToZero = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 0);189      const events1 = await submitTransactionAsync(alice, aliceToZero);190      const result1 = getGenericResult(events1);191192      // Second transfer should fail193      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();194      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 0);195      const badTransaction = async function () {196        await submitTransactionExpectFailAsync(zeroBalance, zeroToAlice);197      };198      await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');199      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();200201      // Try again after Zero gets some balance - now it should succeed202      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);203      await submitTransactionAsync(alice, balancetx);204      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);205      const result2 = getGenericResult(events2);206207      expect(result1.success).to.be.true;208      expect(result2.success).to.be.true;209      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);210    });211  });212213  it('Fungible: Sponsoring is rate limited', async () => {214    const collectionId = await createCollectionExpectSuccess({mode: {type: 'Fungible', decimalPoints: 0}});215    await setCollectionSponsorExpectSuccess(collectionId, bob.address);216    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');217218    await usingApi(async (api) => {219      // Find unused address220      const zeroBalance = await findUnusedAddress(api);221222      // Mint token for unused address223      const itemId = await createItemExpectSuccess(alice, collectionId, 'Fungible', zeroBalance.address);224225      // Transfer this tokens in parts from unused address to Alice226      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(zeroBalance.address), collectionId, itemId, 1);227      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);228      const result1 = getGenericResult(events1);229      expect(result1.success).to.be.true;230231      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();232      await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejected;233      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();234235      // Try again after Zero gets some balance - now it should succeed236      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);237      await submitTransactionAsync(alice, balancetx);238      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);239      const result2 = getGenericResult(events2);240      expect(result2.success).to.be.true;241242      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);243    });244  });245246  it('ReFungible: Sponsoring is rate limited', async () => {247    const collectionId = await createCollectionExpectSuccess({mode: {type: 'ReFungible'}});248    await setCollectionSponsorExpectSuccess(collectionId, bob.address);249    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');250251    await usingApi(async (api) => {252      // Find unused address253      const zeroBalance = await findUnusedAddress(api);254255      // Mint token for alice256      const itemId = await createItemExpectSuccess(alice, collectionId, 'ReFungible', zeroBalance.address);257258      const zeroToAlice = api.tx.unique.transfer(normalizeAccountId(alice.address), collectionId, itemId, 1);259260      // Zero to alice gets sponsored261      const events1 = await submitTransactionAsync(zeroBalance, zeroToAlice);262      const result1 = getGenericResult(events1);263      expect(result1.success).to.be.true;264265      // Second transfer should fail266      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();267      await expect(submitTransactionExpectFailAsync(zeroBalance, zeroToAlice)).to.be.rejectedWith('Inability to pay some fees');268      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();269      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);270271      // Try again after Zero gets some balance - now it should succeed272      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);273      await submitTransactionAsync(alice, balancetx);274      const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);275      const result2 = getGenericResult(events2);276      expect(result2.success).to.be.true;277    });278  });279280  it('NFT: Sponsoring of createItem is rate limited', async () => {281    const collectionId = await createCollectionExpectSuccess();282    await setCollectionSponsorExpectSuccess(collectionId, bob.address);283    await confirmSponsorshipExpectSuccess(collectionId, '//Bob');284285    // Enable collection allow list286    await enableAllowListExpectSuccess(alice, collectionId);287288    // Enable public minting289    await enablePublicMintingExpectSuccess(alice, collectionId);290291    await usingApi(async (api) => {292      // Find unused address293      const zeroBalance = await findUnusedAddress(api);294295      // Add zeroBalance address to allow list296      await addToAllowListExpectSuccess(alice, collectionId, zeroBalance.address);297298      // Mint token using unused address as signer - gets sponsored299      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);300301      // Second mint should fail302      const sponsorBalanceBefore = (await api.query.system.account(bob.address)).data.free.toBigInt();303304      const badTransaction = async function () {305        await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);306      };307      await expect(badTransaction()).to.be.rejectedWith('Inability to pay some fees');308      const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();309310      // Try again after Zero gets some balance - now it should succeed311      const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);312      await submitTransactionAsync(alice, balancetx);313      await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);314315      expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);316    });317  });318319});320321describe('(!negative test!) integration test: ext. confirmSponsorship():', () => {322  before(async () => {323    await usingApi(async () => {324      const keyring = new Keyring({type: 'sr25519'});325      alice = keyring.addFromUri('//Alice');326      bob = keyring.addFromUri('//Bob');327      charlie = keyring.addFromUri('//Charlie');328    });329  });330331  it('(!negative test!) Confirm sponsorship for a collection that never existed', async () => {332    // Find the collection that never existed333    let collectionId = 0;334    await usingApi(async (api) => {335      collectionId = await getCreatedCollectionCount(api) + 1;336    });337338    await confirmSponsorshipExpectFailure(collectionId, '//Bob');339  });340341  it('(!negative test!) Confirm sponsorship using a non-sponsor address', async () => {342    const collectionId = await createCollectionExpectSuccess();343    await setCollectionSponsorExpectSuccess(collectionId, bob.address);344345    await usingApi(async (api) => {346      const transfer = api.tx.balances.transfer(charlie.address, 1e15);347      await submitTransactionAsync(alice, transfer);348    });349350    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');351  });352353  it('(!negative test!) Confirm sponsorship using owner address', async () => {354    const collectionId = await createCollectionExpectSuccess();355    await setCollectionSponsorExpectSuccess(collectionId, bob.address);356    await confirmSponsorshipExpectFailure(collectionId, '//Alice');357  });358359  it('(!negative test!) Confirm sponsorship by collection admin', async () => {360    const collectionId = await createCollectionExpectSuccess();361    await setCollectionSponsorExpectSuccess(collectionId, bob.address);362    await addCollectionAdminExpectSuccess(alice, collectionId, charlie.address);363    await confirmSponsorshipExpectFailure(collectionId, '//Charlie');364  });365366  it('(!negative test!) Confirm sponsorship without sponsor being set with setCollectionSponsor', async () => {367    const collectionId = await createCollectionExpectSuccess();368    await confirmSponsorshipExpectFailure(collectionId, '//Bob');369  });370371  it('(!negative test!) Confirm sponsorship in a collection that was destroyed', async () => {372    const collectionId = await createCollectionExpectSuccess();373    await destroyCollectionExpectSuccess(collectionId);374    await confirmSponsorshipExpectFailure(collectionId, '//Bob');375  });376});
modifiedtests/src/creditFeesToTreasury.test.tsdiffbeforeafterboth
--- a/tests/src/creditFeesToTreasury.test.ts
+++ b/tests/src/creditFeesToTreasury.test.ts
@@ -154,8 +154,8 @@
       const aliceBalanceAfter: bigint = (await api.query.system.account(alicesPublicKey)).data.free.toBigInt();
       const fee = aliceBalanceBefore - aliceBalanceAfter;
 
-      expect(fee / 10n ** 15n < BigInt(Math.ceil(saneMaximumFee + createCollectionDeposit))).to.be.true;
-      expect(fee / 10n ** 15n < BigInt(Math.ceil(saneMinimumFee  + createCollectionDeposit))).to.be.true;
+      expect(fee / UNIQUE < BigInt(Math.ceil(saneMaximumFee + createCollectionDeposit))).to.be.true;
+      expect(fee / UNIQUE < BigInt(Math.ceil(saneMinimumFee  + createCollectionDeposit))).to.be.true;
     });
   });
 
modifiedtests/src/eth/payable.test.tsdiffbeforeafterboth
--- a/tests/src/eth/payable.test.ts
+++ b/tests/src/eth/payable.test.ts
@@ -54,7 +54,7 @@
     expect(await contract.methods.getUnaccounted().call()).to.be.equal('10000');
   });
 
-  itWeb3('Balance can be retrieved from evm contract', async({api, web3}) => {
+  itWeb3.only('Balance can be retrieved from evm contract', async({api, web3}) => {
     const FEE_BALANCE = 10n ** 18n;
     const CONTRACT_BALANCE = 10n ** 14n;
 
modifiedtests/src/util/helpers.tsdiffbeforeafterboth
--- a/tests/src/util/helpers.ts
+++ b/tests/src/util/helpers.ts
@@ -69,7 +69,7 @@
 
 export const U128_MAX = (1n << 128n) - 1n;
 
-const MICROUNIQUE = 1_000_000_000n;
+const MICROUNIQUE = 1_000_000_000_000n;
 const MILLIUNIQUE = 1_000n * MICROUNIQUE;
 const CENTIUNIQUE = 10n * MILLIUNIQUE;
 export const UNIQUE = 100n * CENTIUNIQUE;