From 013e29f77b61fae081c1408f68df7b284cad3c75 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Mon, 18 Feb 2019 12:27:27 +0100 Subject: [PATCH] Example for formatBalance (#77) --- packages/ui-identicon/package.json | 4 +-- packages/ui-keyring/package.json | 6 ++-- packages/ui-util/README.md | 13 ++++++++ packages/ui-util/package.json | 2 +- yarn.lock | 48 +++++++++++++++++------------- 5 files changed, 46 insertions(+), 27 deletions(-) diff --git a/packages/ui-identicon/package.json b/packages/ui-identicon/package.json index b387a613..1a278213 100644 --- a/packages/ui-identicon/package.json +++ b/packages/ui-identicon/package.json @@ -22,8 +22,8 @@ "react": "*" }, "devDependencies": { - "@polkadot/keyring": "^0.34.19", - "@polkadot/util-crypto": "^0.34.19", + "@polkadot/keyring": "^0.34.20", + "@polkadot/util-crypto": "^0.34.20", "xmlserializer": "^0.6.1" } } diff --git a/packages/ui-keyring/package.json b/packages/ui-keyring/package.json index cf662c2c..0e1d5bb5 100644 --- a/packages/ui-keyring/package.json +++ b/packages/ui-keyring/package.json @@ -16,9 +16,9 @@ "store": "^2.0.12" }, "devDependencies": { - "@polkadot/keyring": "^0.34.19", - "@polkadot/types": "^0.43.10", - "@polkadot/util": "^0.34.19" + "@polkadot/keyring": "^0.34.20", + "@polkadot/types": "^0.43.15", + "@polkadot/util": "^0.34.20" }, "peerDependencies": { "@polkadot/keyring": "*", diff --git a/packages/ui-util/README.md b/packages/ui-util/README.md index 2545010a..d41025d5 100644 --- a/packages/ui-util/README.md +++ b/packages/ui-util/README.md @@ -1,3 +1,16 @@ # @polkadot/ui-util Various utility and formatting functions + +## formatBalance + +```js +const props = await api.rpc.system.properties(); + +formatBalance.setDefaults({ + decimals: props.tokenDecimals, + unit: props.tokenSymbol +}); + +formatBalance('12345'); // 12.345z DOT +``` diff --git a/packages/ui-util/package.json b/packages/ui-util/package.json index eac185ed..5e7bc828 100644 --- a/packages/ui-util/package.json +++ b/packages/ui-util/package.json @@ -12,7 +12,7 @@ "@babel/runtime": "^7.3.1" }, "devDependencies": { - "@polkadot/types": "^0.43.10" + "@polkadot/types": "^0.43.15" }, "peerDependencies": { "@polkadot/types": "*" diff --git a/yarn.lock b/yarn.lock index e1005b79..fff566b1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1528,39 +1528,45 @@ typedoc-plugin-no-inherit "^1.1.6" typescript "^3.3.3" -"@polkadot/keyring@^0.34.19": - version "0.34.19" - resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.34.19.tgz#86caadfa4fcc0efb799749f73a5486a1a946161f" - integrity sha512-HLlAeQKqytX0YTHag0u51S1n4BC1nORtrV4s+EsMQ7//DVE6iuksTSRU0eOv80tinPSKkKv0v0aaZ+3y+HpJXw== +"@polkadot/keyring@^0.34.20": + version "0.34.20" + resolved "https://registry.yarnpkg.com/@polkadot/keyring/-/keyring-0.34.20.tgz#b6a9a36620b6ce668f568053870e7942175e551b" + integrity sha512-ZFhgPr2F+WqLuP3jfiReqSHaxYrxfS+tBtdsy4CdmShtRXZ115aoVhTaSXiCnNysdgZQryW6HJBlxGDgU7mSvg== dependencies: "@babel/runtime" "^7.3.1" - "@polkadot/util" "^0.34.19" - "@polkadot/util-crypto" "^0.34.19" + "@polkadot/util" "^0.34.20" + "@polkadot/util-crypto" "^0.34.20" "@types/bs58" "^4.0.0" bs58 "^4.0.1" +"@polkadot/schnorrkel-js@^0.1.2-1": + version "0.1.2-1" + resolved "https://registry.yarnpkg.com/@polkadot/schnorrkel-js/-/schnorrkel-js-0.1.2-1.tgz#90e4e8bca54157513cf5192f4581491bcbf5c44e" + integrity sha512-Y6cJWOOJyQ6TPzWzfgPrZlWzcR89X2tOgLIrCXOyEE72+CFiBfyAQDqG2jBzxolEqqN/Fz0AUdxqPT45BzionQ== + "@polkadot/ts@^0.1.52": version "0.1.52" resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.52.tgz#6fb09e494d244dad4b3a9ca581bfe13beec66565" integrity sha512-sij1O0x4CY51A394RYD4/aQwDPwIxIeTOpYI4AZgdF/vq5nvF14b4XFq9vAcSnblaIosf0sYKoz1f3dkN3QqLw== -"@polkadot/types@^0.43.10": - version "0.43.10" - resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.43.10.tgz#eccba24b938a36e193d789e52f21786732db0bc1" - integrity sha512-6yUfy2fmGIfTZXT0ff/RXXD9uHt7PjwwKH+LTi/tTPOKNJy7P9ltVVfbaMIi9J9DgBrTLYgJssGUHHvCjmXX2A== +"@polkadot/types@^0.43.15": + version "0.43.15" + resolved "https://registry.yarnpkg.com/@polkadot/types/-/types-0.43.15.tgz#5d69e741167b185eb34ca3fc3153fb1b539dc64d" + integrity sha512-/TtRdTSxXnmJDkfJcBWs78c5CLd4FZ8C0H0CFaolX0HylDu9NJP49BRD3Ol7dLGWheWym2jY/PpCo7WS/rRCgQ== dependencies: "@babel/runtime" "^7.3.1" - "@polkadot/keyring" "^0.34.19" - "@polkadot/util" "^0.34.19" + "@polkadot/keyring" "^0.34.20" + "@polkadot/util" "^0.34.20" core-js "^2.6.5" -"@polkadot/util-crypto@^0.34.19": - version "0.34.19" - resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.34.19.tgz#776fbefe5bee80f32281d6b61c2cb8d5c608f03d" - integrity sha512-tY5V7GPAt8gHNlpGDV787wnZefvQeIxNbC/eo0liE/WEaCaU4DRbvV3VnbcsRlBvLg4tpuqSqlXYMELoqTNSig== +"@polkadot/util-crypto@^0.34.20": + version "0.34.20" + resolved "https://registry.yarnpkg.com/@polkadot/util-crypto/-/util-crypto-0.34.20.tgz#4b4776833b5a6a2ce4c1307be29694c3d47e24ea" + integrity sha512-FXQqI67vhmu6+ZJBQm5aMttW3AopZyT+xgOGYpCZzuYOj1ODHEvrCrLxjRsgiYQw1tr92OTjbKeN0MRGaG6QGA== dependencies: "@babel/runtime" "^7.3.1" - "@polkadot/util" "^0.34.19" + "@polkadot/schnorrkel-js" "^0.1.2-1" + "@polkadot/util" "^0.34.20" "@types/bip39" "^2.4.2" "@types/webassembly-js-api" "^0.0.2" "@types/xxhashjs" "^0.2.0" @@ -1570,10 +1576,10 @@ tweetnacl "^1.0.1" xxhashjs "^0.2.2" -"@polkadot/util@^0.34.19": - version "0.34.19" - resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.34.19.tgz#46e690e2cc732a64e0a1ba859135afc9cad844ab" - integrity sha512-bLWXrkrZr4aNMvpdsElE3G4ZtJFV+1zXciOFM9jTHmVMt1f5KCHO6BdNkLC16RPToGmMDYB0bD+waTadQ6QW6g== +"@polkadot/util@^0.34.20": + version "0.34.20" + resolved "https://registry.yarnpkg.com/@polkadot/util/-/util-0.34.20.tgz#3ebc10c8989c488220bece1b01028f740c5df5a7" + integrity sha512-MbMQw3qG9rfUpcCmcCEB1ZWqeXUocSnDng1CDF6n7jdqpt+KsTG4LghWXjdnvEIdKZMamfNaE4r8TZ+2iEQfJA== dependencies: "@babel/runtime" "^7.3.1" "@types/bn.js" "^4.11.4"