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.rsdiffbeforeafterboth1//2// This file is subject to the terms and conditions defined in3// file 'LICENSE', which is part of this source code package.4//56use cumulus_primitives_core::ParaId;7use unique_runtime::*;8use sc_chain_spec::{ChainSpecExtension, ChainSpecGroup};9use sc_service::ChainType;10use sp_core::{sr25519, Pair, Public};11use sp_runtime::traits::{IdentifyAccount, Verify};12use std::collections::BTreeMap;1314use serde::{Deserialize, Serialize};15use serde_json::map::Map;1617/// Specialized `ChainSpec`. This is a specialization of the general Substrate ChainSpec type.18pub type ChainSpec = sc_service::GenericChainSpec<unique_runtime::GenesisConfig, Extensions>;1920/// Helper function to generate a crypto pair from seed21pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {22 TPublic::Pair::from_string(&format!("//{}", seed), None)23 .expect("static values are valid; qed")24 .public()25}2627/// The extensions for the [`ChainSpec`].28#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, ChainSpecGroup, ChainSpecExtension)]29#[serde(deny_unknown_fields)]30pub struct Extensions {31 /// The relay chain of the Parachain.32 pub relay_chain: String,33 /// The id of the Parachain.34 pub para_id: u32,35}3637impl Extensions {38 /// Try to get the extension from the given `ChainSpec`.39 pub fn try_get(chain_spec: &dyn sc_service::ChainSpec) -> Option<&Self> {40 sc_chain_spec::get_extension(chain_spec.extensions())41 }42}4344type AccountPublic = <Signature as Verify>::Signer;4546/// Helper function to generate an account ID from seed47pub fn get_account_id_from_seed<TPublic: Public>(seed: &str) -> AccountId48where49 AccountPublic: From<<TPublic::Pair as Pair>::Public>,50{51 AccountPublic::from(get_from_seed::<TPublic>(seed)).into_account()52}5354pub fn development_config(id: ParaId) -> ChainSpec {55 let mut properties = Map::new();56 properties.insert("tokenSymbol".into(), "testUNQ".into());57 properties.insert("tokenDecimals".into(), 15.into());58 properties.insert("ss58Format".into(), 42.into()); // Generic Substrate wildcard (SS58 checksum preimage)5960 ChainSpec::from_genesis(61 // Name62 "Development",63 // ID64 "dev",65 ChainType::Local,66 move || {67 testnet_genesis(68 // Sudo account69 get_account_id_from_seed::<sr25519::Public>("Alice"),70 vec![71 get_from_seed::<AuraId>("Alice"),72 get_from_seed::<AuraId>("Bob"),73 ],74 // Pre-funded accounts75 vec![76 get_account_id_from_seed::<sr25519::Public>("Alice"),77 get_account_id_from_seed::<sr25519::Public>("Bob"),78 ],79 id,80 )81 },82 // Bootnodes83 vec![],84 // Telemetry85 None,86 // Protocol ID87 None,88 // Properties89 Some(properties),90 // Extensions91 Extensions {92 relay_chain: "rococo-dev".into(),93 para_id: id.into(),94 },95 )96}9798pub fn local_testnet_rococo_config(id: ParaId) -> ChainSpec {99 ChainSpec::from_genesis(100 // Name101 "Local Testnet",102 // ID103 "local_testnet",104 ChainType::Local,105 move || {106 testnet_genesis(107 // Sudo account108 get_account_id_from_seed::<sr25519::Public>("Alice"),109 vec![110 get_from_seed::<AuraId>("Alice"),111 get_from_seed::<AuraId>("Bob"),112 ],113 // Pre-funded accounts114 vec![115 get_account_id_from_seed::<sr25519::Public>("Alice"),116 get_account_id_from_seed::<sr25519::Public>("Bob"),117 get_account_id_from_seed::<sr25519::Public>("Charlie"),118 get_account_id_from_seed::<sr25519::Public>("Dave"),119 get_account_id_from_seed::<sr25519::Public>("Eve"),120 get_account_id_from_seed::<sr25519::Public>("Ferdie"),121 get_account_id_from_seed::<sr25519::Public>("Alice//stash"),122 get_account_id_from_seed::<sr25519::Public>("Bob//stash"),123 get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),124 get_account_id_from_seed::<sr25519::Public>("Dave//stash"),125 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),126 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),127 ],128 id,129 )130 },131 // Bootnodes132 vec![],133 // Telemetry134 None,135 // Protocol ID136 None,137 // Properties138 None,139 // Extensions140 Extensions {141 relay_chain: "rococo-local".into(),142 para_id: id.into(),143 },144 )145}146147pub fn local_testnet_westend_config(id: ParaId) -> ChainSpec {148 ChainSpec::from_genesis(149 // Name150 "Local Testnet",151 // ID152 "local_testnet",153 ChainType::Local,154 move || {155 testnet_genesis(156 // Sudo account157 get_account_id_from_seed::<sr25519::Public>("Alice"),158 vec![159 get_from_seed::<AuraId>("Alice"),160 get_from_seed::<AuraId>("Bob"),161 get_from_seed::<AuraId>("Charlie"),162 get_from_seed::<AuraId>("Dave"),163 get_from_seed::<AuraId>("Eve"),164 ],165 // Pre-funded accounts166 vec![167 get_account_id_from_seed::<sr25519::Public>("Alice"),168 get_account_id_from_seed::<sr25519::Public>("Bob"),169 get_account_id_from_seed::<sr25519::Public>("Charlie"),170 get_account_id_from_seed::<sr25519::Public>("Dave"),171 get_account_id_from_seed::<sr25519::Public>("Eve"),172 get_account_id_from_seed::<sr25519::Public>("Ferdie"),173 get_account_id_from_seed::<sr25519::Public>("Alice//stash"),174 get_account_id_from_seed::<sr25519::Public>("Bob//stash"),175 get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),176 get_account_id_from_seed::<sr25519::Public>("Dave//stash"),177 get_account_id_from_seed::<sr25519::Public>("Eve//stash"),178 get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),179 ],180 id,181 )182 },183 // Bootnodes184 vec![],185 // Telemetry186 None,187 // Protocol ID188 None,189 // Properties190 None,191 // Extensions192 Extensions {193 relay_chain: "westend-local".into(),194 para_id: id.into(),195 },196 )197}198199fn testnet_genesis(200 root_key: AccountId,201 initial_authorities: Vec<AuraId>,202 endowed_accounts: Vec<AccountId>,203 id: ParaId,204) -> GenesisConfig {205 GenesisConfig {206 system: unique_runtime::SystemConfig {207 code: unique_runtime::WASM_BINARY208 .expect("WASM binary was not build, please build it!")209 .to_vec(),210 changes_trie_config: Default::default(),211 },212 balances: BalancesConfig {213 balances: endowed_accounts214 .iter()215 .cloned()216 // 1e13 UNQ217 .map(|k| (k, 1 << 100))218 .collect(),219 },220 treasury: Default::default(),221 sudo: SudoConfig { key: root_key },222 vesting: VestingConfig { vesting: vec![] },223 parachain_info: unique_runtime::ParachainInfoConfig { parachain_id: id },224 aura: unique_runtime::AuraConfig {225 authorities: initial_authorities,226 },227 aura_ext: Default::default(),228 evm: EVMConfig {229 accounts: BTreeMap::new(),230 },231 ethereum: EthereumConfig {},232 }233}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.tsdiffbeforeafterboth--- a/tests/src/confirmSponsorship.test.ts
+++ b/tests/src/confirmSponsorship.test.ts
@@ -21,6 +21,7 @@
normalizeAccountId,
addCollectionAdminExpectSuccess,
getCreatedCollectionCount,
+ UNIQUE,
} from './util/helpers';
import {Keyring} from '@polkadot/api';
import {IKeyringPair} from '@polkadot/types/types';
@@ -198,7 +199,7 @@
const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
- const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
+ const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
await submitTransactionAsync(alice, balancetx);
const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result2 = getGenericResult(events2);
@@ -232,7 +233,7 @@
const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
- const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
+ const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
await submitTransactionAsync(alice, balancetx);
const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result2 = getGenericResult(events2);
@@ -268,7 +269,7 @@
expect(sponsorBalanceAfter).to.be.equal(sponsorBalanceBefore);
// Try again after Zero gets some balance - now it should succeed
- const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
+ const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
await submitTransactionAsync(alice, balancetx);
const events2 = await submitTransactionAsync(zeroBalance, zeroToAlice);
const result2 = getGenericResult(events2);
@@ -307,7 +308,7 @@
const sponsorBalanceAfter = (await api.query.system.account(bob.address)).data.free.toBigInt();
// Try again after Zero gets some balance - now it should succeed
- const balancetx = api.tx.balances.transfer(zeroBalance.address, 1e15);
+ const balancetx = api.tx.balances.transfer(zeroBalance.address, 1n * UNIQUE);
await submitTransactionAsync(alice, balancetx);
await createItemExpectSuccess(zeroBalance, collectionId, 'NFT', zeroBalance.address);
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;