difftreelog
Merge pull request #254 from UniqueNetwork/feature/decimals-18-v2
in: master
change decimals from 15 to 18
8 files changed
launch-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,
launch-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,
node/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
runtime/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,
tests/src/confirmSponsorship.test.tsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56import 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});tests/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;
});
});
tests/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;
tests/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;