Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0c9412c55f | ||
|
|
a3ece8770c | ||
|
|
77a9377503 | ||
|
|
e63b08f053 | ||
|
|
6356f9d0b7 | ||
|
|
01d753ff99 | ||
|
|
8e151b721a | ||
|
|
ff1a31a336 | ||
|
|
2b0dac8097 | ||
|
|
7b640d4503 | ||
|
|
f4659fb67c | ||
|
|
c0393bcc7c | ||
|
|
0f5108ca90 | ||
|
|
fffbbdcb55 | ||
|
|
16d29df52a | ||
|
|
4ba9e97386 | ||
|
|
3a8d9c3fcb | ||
|
|
15c73e6e07 | ||
|
|
122e2c40ce | ||
|
|
14ac686780 | ||
|
|
8e4ecac74b | ||
|
|
a1808f590e | ||
|
|
72127121ca | ||
|
|
d77dddfda0 | ||
|
|
42877edd0b | ||
|
|
c077dfe24e | ||
|
|
7f4e90a2cf | ||
|
|
4d7b19e64b | ||
|
|
127c937e5d | ||
|
|
a0fc946ee7 | ||
|
|
35dd0b2561 | ||
|
|
33ef29361f | ||
|
|
7953d92bfc | ||
|
|
4089bca9d5 | ||
|
|
fea7424a7d | ||
|
|
d4923b80fc | ||
|
|
678d4dc524 | ||
|
|
4e92aab586 | ||
|
|
1833b1a28f | ||
|
|
3ca640fd3c | ||
|
|
0017139d69 | ||
|
|
87fd12c002 | ||
|
|
723641ac57 | ||
|
|
4155547c0b | ||
|
|
262b8ad7c3 | ||
|
|
64f630d904 | ||
|
|
8525c59b9a | ||
|
|
0288421cef | ||
|
|
8f1ae11d9c | ||
|
|
8f61882bf7 | ||
|
|
12cba3f23d | ||
|
|
05d8d95991 | ||
|
|
adbaa6caf4 | ||
|
|
db6948d658 | ||
|
|
6ca5ac62eb | ||
|
|
0b63b9eaf9 | ||
|
|
b62cfcaf94 | ||
|
|
e24cf09608 | ||
|
|
815bbd647c | ||
|
|
54a325f306 | ||
|
|
d5b9362c85 | ||
|
|
55f3ca652d | ||
|
|
1cce48ef53 | ||
|
|
44bf1f4260 |
@@ -1 +0,0 @@
|
||||
module.exports = require('./babel.config.js');
|
||||
@@ -1,5 +0,0 @@
|
||||
.eslintrc.js
|
||||
**/build/*
|
||||
**/coverage/*
|
||||
**/node_modules/*
|
||||
**/*.d.ts
|
||||
@@ -1,7 +1,20 @@
|
||||
// Copyright 2017-2020 @polkadot/ui authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/eslint');
|
||||
|
||||
module.exports = {
|
||||
...base,
|
||||
ignorePatterns: [
|
||||
'.eslintrc.js',
|
||||
'.github/**',
|
||||
'.vscode/**',
|
||||
'.yarn/**',
|
||||
'**/build/*',
|
||||
'**/coverage/*',
|
||||
'**/node_modules/*',
|
||||
'**/*.d.ts'
|
||||
],
|
||||
parserOptions: {
|
||||
...base.parserOptions,
|
||||
project: [
|
||||
|
||||
@@ -5,11 +5,11 @@ jobs:
|
||||
pr:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['lint', 'test', 'build', 'docs']
|
||||
step: ['lint', 'test', 'build']
|
||||
name: ${{ matrix.step }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
- name: ${{ matrix.step }}
|
||||
run: |
|
||||
yarn install --immutable | grep -v 'YN0013'
|
||||
|
||||
@@ -8,18 +8,17 @@ jobs:
|
||||
master:
|
||||
strategy:
|
||||
matrix:
|
||||
step: ['build:release', 'docs:release']
|
||||
step: ['build:release']
|
||||
name: ${{ matrix.step }}
|
||||
if: "! startsWith(github.event.head_commit.message, '[CI Skip]') && github.repository == 'polkadot-js/ui'"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
token: ${{ secrets.GH_PAT }}
|
||||
- name: ${{ matrix.step }}
|
||||
env:
|
||||
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
|
||||
GH_PAGES_SRC: build-docs
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
GH_RELEASE_GITHUB_API_TOKEN: ${{ secrets.GH_PAT }}
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
Vendored
-11
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"editor.tabSize": 2,
|
||||
"files.eol": "\n",
|
||||
"npm.packageManager": "yarn",
|
||||
"eslint.enable": true,
|
||||
"eslint.validate": [
|
||||
"javascript",
|
||||
"typescript",
|
||||
"typescriptreact"
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+52
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Vendored
-86
File diff suppressed because one or more lines are too long
+55
File diff suppressed because one or more lines are too long
+6
-2
@@ -5,7 +5,11 @@ enableProgressBars: false
|
||||
nodeLinker: node-modules
|
||||
|
||||
plugins:
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.js
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
|
||||
spec: "@yarnpkg/plugin-interactive-tools"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-version.cjs
|
||||
spec: "@yarnpkg/plugin-version"
|
||||
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
|
||||
spec: "@yarnpkg/plugin-workspace-tools"
|
||||
|
||||
yarnPath: .yarn/releases/yarn-2.1.1.cjs
|
||||
yarnPath: .yarn/releases/yarn-2.3.3.cjs
|
||||
|
||||
+125
@@ -1,15 +1,64 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 0.62.1 Nov 9, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Update address checks to allow for Ethereum-compatible chains
|
||||
- Add Ethereum icon type (uses blockies underneath)
|
||||
- Updated to `@polkadot/{keyring, util, util-crypto}` 4.0.1
|
||||
- Updated to `@polkadot/api` 2.6.1
|
||||
|
||||
|
||||
## 0.61.1 Oct 19, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Darwinia ss58 (Thanks to https://github.com/WoeOm)
|
||||
- Swap network identifiers to `@polkadot/networks` (Thanks to https://github.com/Tbaut)
|
||||
|
||||
Changes:
|
||||
|
||||
- Explicit deps versions (with peerDependencies as provided)
|
||||
- Bump to `@polkadot/api` 2.3.1
|
||||
- Bump to `@polkadot/util` 3.6.1
|
||||
|
||||
|
||||
## 0.60.1 Oct 7, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for custom IdentityIcon overrides
|
||||
- Move docs to docs repo
|
||||
- Bump to `@polkadot/api` 2.1.1
|
||||
|
||||
|
||||
## 0.59.1 Sep 28, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Expose createFromJson on keyring to compliment createFromUri
|
||||
- Support Account/address indexes for Ledger
|
||||
- Bump to `@polkadot/api` 2.0.1
|
||||
- Bump to `@polkadot/util` 3.5.1
|
||||
|
||||
|
||||
## 0.58.1 Aug 31, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Subsocial to ss58 defaults (Thanks to https://github.com/F3Joule)
|
||||
|
||||
Changes:
|
||||
|
||||
- Support QR scanning where name contains ":"
|
||||
- Support for Moonbeam ETH-compatible crypto types
|
||||
|
||||
|
||||
## 0.57.3 Jul 27, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for JSON v3 kdf-enabled format
|
||||
- Adjust password validity checks (alongside v3)
|
||||
- Bump to `@polkadot/api` 1.26.1
|
||||
@@ -18,8 +67,12 @@
|
||||
|
||||
## 0.56.1 Jul 20, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Kulupu to ss58 options (https://github.com/carumusan)
|
||||
|
||||
Changes:
|
||||
|
||||
- Remove CC1 naming for Polkadot (as applicable)
|
||||
- Flatten React IdentityIcon (no extra wrapping)
|
||||
- Bump to `@polkadot/api` 1.25.1
|
||||
@@ -28,8 +81,12 @@
|
||||
|
||||
## 0.55.1 Jul 2, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Better error-handling for invalid FileStore accounts (Thanks to https://github.com/yuhui1208)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust react-qr `Scan*` making `onScan` callbacks required
|
||||
- Rework the react-qr display to use functional components
|
||||
- Bump to `@polkadot/api` 1.21.1
|
||||
@@ -38,9 +95,13 @@
|
||||
|
||||
## 0.54.1 Jun 16, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add genesisHash to signer payload (Thanks to https://github.com/hanwencheng)
|
||||
- Allow QR scanning to parse mini keys (Thanks to https://github.com/hanwencheng)
|
||||
|
||||
Changes:
|
||||
|
||||
- Adjust ordering of available crypto types (native first)
|
||||
- Rename Substrate prefix entry (42) to "generic"
|
||||
- Bump to `@polkadot/api` 1.19.1
|
||||
@@ -49,9 +110,13 @@
|
||||
|
||||
## 0.53.1 May 14, 2020
|
||||
|
||||
Contributed:
|
||||
|
||||
- Add Ecdsa to the supported crypto types options (Thanks to https://github.com/akru)
|
||||
- Add Egedware to network prefix settings (Thanks to https://github.com/jnaviask)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add `addMultisig` into keyring (with all options to re-create address)
|
||||
- Bump to `@polkadot/api` 1.14.1
|
||||
- Bump to `@polkadot/util` 2.10.1
|
||||
@@ -61,9 +126,13 @@
|
||||
|
||||
- **Breaking change** (TypeScript only) The `*.d.ts` files now contain TypeScript 3.8 features, `#private`, which is not usable in older versions
|
||||
|
||||
Contributed:
|
||||
|
||||
- Allow for the encoding of chain-settings via QR (Thanks to https://github.com/hanwencheng)
|
||||
- Enhance checks for ws url in settings (Thanks to https://github.com/kwingram25)
|
||||
|
||||
Changes:
|
||||
|
||||
- Start of `isAlternative` implementations for identicons to react, react-native & vue (currently only Polkadot sixPoint)
|
||||
- Bump to `@polkadot/api` 1.10 & `@polkadot/util` 2.8
|
||||
- Convert `private <field>` to `#<field>`
|
||||
@@ -72,6 +141,8 @@
|
||||
|
||||
## 0.51.1 Feb 18, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Support formatting of addresses via createPair base on latest upstream keyring
|
||||
- Bump to `@polkadot/api` 1.3.1
|
||||
- Bump to `@polkadot/util` 2.4.1
|
||||
@@ -79,6 +150,8 @@
|
||||
|
||||
## 0.50.1 Feb 16, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- ui-settings does not expose pre-configured endpoints by default (only local dev node)
|
||||
- Bump to `@polkadot/api` 1.2.1
|
||||
- Bump to `@polkadot/util` 2.3.1
|
||||
@@ -86,11 +159,15 @@
|
||||
|
||||
## 0.49.1 Feb 06, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add resolver for jest requires (tests from src)
|
||||
|
||||
|
||||
## 0.48.1 Jan 30, 2020
|
||||
|
||||
Changes:
|
||||
|
||||
- Add Westend & Kulupulu, remove Alexander
|
||||
- Update Edgeware wss uri
|
||||
- Change display name for Kusama
|
||||
@@ -99,6 +176,8 @@
|
||||
|
||||
## 0.47.1 Nov 29, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for Kusama CC3 (network endpoints)
|
||||
- Genesis hashes for accounts can now lookup against a range (so CC2-locked accounts will show on CC3)
|
||||
- Language options have been removed from settings (these will be app-specific)
|
||||
@@ -109,6 +188,8 @@
|
||||
|
||||
- Add an example for using React Native (thanks to https://github.com/cameronfr)
|
||||
|
||||
Changes:
|
||||
|
||||
- Add base documentation for getting started
|
||||
- Add camera access to the setting structure
|
||||
|
||||
@@ -117,6 +198,8 @@
|
||||
|
||||
- **Breaking change** The subscription subject for `ui-keyring` does not return a pre-formatted React object anymore. This is SUI-specific, so had limited use and therefore should not even be split into a `react-keyring` component. Rather users of this functionality should construct their own options for their framework.
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for Kusama CC2
|
||||
- Experimental support for signing via Ledger HW
|
||||
- Add specific settings for the icon type to `ui-settings`
|
||||
@@ -127,12 +210,16 @@
|
||||
|
||||
## 0.44.1 Sep 12, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Update `@polkadot/util` to 1.4.1
|
||||
- Upddate to Babel 7.6
|
||||
|
||||
|
||||
## 0.43.1 Sep 10, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add W3F Node for Kusama
|
||||
- Add extended info to ui-settings, i.e. info on each option
|
||||
- Adjust logos in ui-assets (incl. updated Substrate logo)
|
||||
@@ -145,6 +232,8 @@
|
||||
- **Breaking Change** The `@polkadot/ui-identicon` package has been renamed to `@polkadot/react-identicon`
|
||||
- **Breaking change** For `@polkadot/ui-keyring` the stores are now not exported from the index, imports should be changed to either `ui-keyring/stores` or explicitly to `ui-keyring/stores/Extension`
|
||||
|
||||
Changes:
|
||||
|
||||
- Support for Kusama with endpoints and settings
|
||||
- The `@polkadot/reactnative-identicon` package has been added (only Polkadot support atm)
|
||||
- The `@polkadot/react-qr` package has been added to display/scan QR codes
|
||||
@@ -154,6 +243,8 @@
|
||||
|
||||
## 0.41.1 Jun 14, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Adapt interface to cater for new `@polkadot/keyring`, where pairs -
|
||||
- expose `address` getter instead of `address()`
|
||||
- expose `publicKey` getter instead of `publicKey()`
|
||||
@@ -167,17 +258,23 @@
|
||||
|
||||
## 0.40.1 Jun 04, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Address encoding changes, use encoded address instead of supplied
|
||||
|
||||
|
||||
## 0.39.1 May 22, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for externally injected accounts
|
||||
- @polkadot/util 0.91.1 & @polkadot/api 0.79.1
|
||||
|
||||
|
||||
## 0.38.1 May 08, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Sorting of keyring addresses
|
||||
- Fix JSON import defaults (previously detection was not working for old accounts)
|
||||
- Display icons using publicKey (not the encoded address)
|
||||
@@ -187,27 +284,37 @@
|
||||
|
||||
## 0.37.1 Apr 03, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add Emberic Elm (Dried Danta discontinued)
|
||||
- @polkadot/util & @polkadot/api 0.75.1
|
||||
|
||||
|
||||
## 0.36.1 Mar 29, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Small fixes, latest @polkadot/wasm-* packages
|
||||
|
||||
|
||||
## 0.35.1 Mar 29, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- @polkadot/util & @polkadot/api 0.75.1
|
||||
|
||||
|
||||
## 0.34.1 Mar 28, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Fix for blake2 in Polkadot identicon generation
|
||||
|
||||
|
||||
## 0.33.1 Mar 23, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Rename createUri and createExternal to addExternal and addUri
|
||||
- Rename addAccountPair to addPair
|
||||
- Add additional createFromUri function to create pair, but not add it
|
||||
@@ -216,6 +323,8 @@
|
||||
|
||||
## 0.32.1 Mar 20, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Add createUri to create an account from a path uri
|
||||
- Add createExternal as an alias for createAccountExternal
|
||||
- Deprecate createAccount, createAccountExternal and createAccountMnemonic
|
||||
@@ -224,37 +333,51 @@
|
||||
|
||||
## 0.31.1 Mar 18, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Allow for latest keyring with sr25519 derived support
|
||||
- When using dev mode, it assumes the substrate node has sr25519 derived keys
|
||||
|
||||
|
||||
## 0.30.1 Mar 14, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
- Swap to publishing -beta.x on merge (non-breaking testing)
|
||||
|
||||
|
||||
## 0.29.1 Mar 13, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
Swap to using a dev HDKD keyring (only available on latest substrate master, only affects nodes running with --dev, normal operation unaffected)
|
||||
|
||||
|
||||
## 0.28.1 Feb 21, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
Default Substrate icon is Jdenticon
|
||||
|
||||
|
||||
## 0.27.1 Feb 20, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
Replace Charred Cherry with Dried Danta, remove old decimals and token name configs
|
||||
|
||||
|
||||
## 0.26.1 Feb 14, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
Add keyring support for sd25519 (schnorrkel)
|
||||
|
||||
|
||||
## 0.25.1 Jan 09, 2019
|
||||
|
||||
Changes:
|
||||
|
||||
Add `@polkadot/{keyring,util,util-crypto,types}` as peerDependencies for the various packages as used. Thie should allow less churn on this repo with version bumps, although it does add some extra effort onto the users of these libraries. (But the assumption is that they use these anyway)
|
||||
|
||||
|
||||
@@ -264,4 +387,6 @@ Add `@polkadot/{keyring,util,util-crypto,types}` as peerDependencies for the var
|
||||
|
||||
## 0.22.1 Dec 05, 2018
|
||||
|
||||
Changes:
|
||||
|
||||
- Split from apps
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const base = require('@polkadot/dev/config/babel');
|
||||
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../apps/node_modules/@polkadot/$1"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "react-identicon"
|
||||
copy_folder "react-qr"
|
||||
copy_folder "ui-assets"
|
||||
copy_folder "ui-keyring"
|
||||
copy_folder "ui-settings"
|
||||
copy_folder "ui-shared"
|
||||
@@ -1,20 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
function copy_folder () {
|
||||
SRC="packages/$1/build"
|
||||
DST="../extension/node_modules/@polkadot/$1"
|
||||
|
||||
echo "** Copying $SRC to $DST"
|
||||
|
||||
rm -rf $DST
|
||||
cp -r $SRC $DST
|
||||
}
|
||||
|
||||
yarn polkadot-dev-build-ts
|
||||
|
||||
copy_folder "react-identicon"
|
||||
copy_folder "react-qr"
|
||||
copy_folder "ui-assets"
|
||||
copy_folder "ui-keyring"
|
||||
copy_folder "ui-settings"
|
||||
copy_folder "ui-shared"
|
||||
@@ -1,50 +0,0 @@
|
||||
module.exports = {
|
||||
base: '/ui/',
|
||||
title: 'polkadot-js/ui',
|
||||
description: 'UI utilities, libraries and React components in use across @polkadot projects',
|
||||
markdown: {
|
||||
lineNumbers: true
|
||||
},
|
||||
themeConfig: {
|
||||
displayAllHeaders: true,
|
||||
nav: [
|
||||
{ text: 'Polkadot/Substrate Apps', link: 'https://polkadot.js.org/apps/' },
|
||||
{ text: 'Project family', link: 'https://polkadot.js.org/' },
|
||||
{
|
||||
text: 'Documentation',
|
||||
items: [
|
||||
{ text: 'API Reference', link: 'https://polkadot.js.org/api/' },
|
||||
{ text: 'Utility Reference', link: 'https://polkadot.js.org/common/' },
|
||||
{ text: 'UI Libs Reference (this)', link: 'https://polkadot.js.org/ui/' },
|
||||
]
|
||||
},
|
||||
{ text: 'GitHub', link: 'https://github.com/polkadot-js/ui' }
|
||||
],
|
||||
search: false,
|
||||
sidebar: [
|
||||
{
|
||||
title: 'Getting started',
|
||||
path: '/start/',
|
||||
collapsable: false,
|
||||
sidebarDepth: 0,
|
||||
children: [
|
||||
['start/packages.md', 'Available packages'],
|
||||
['start/keyring.md', 'Keyring'],
|
||||
['start/keyring.accounts.md', 'Keyring accounts'],
|
||||
['start/keyring.derivation.md', 'Account derivation'],
|
||||
['start/keyring.retrieve.md', 'Account retrieval'],
|
||||
['start/keyring.other.md', 'Other addresses'],
|
||||
['start/FAQ.md', 'FAQ']
|
||||
]
|
||||
},
|
||||
['/react-identicon/', '@polkadot/react-identicon'],
|
||||
['/react-qr/', '@polkadot/react-qr'],
|
||||
['/reactnative-identicon/', '@polkadot/reactnative-identicon'],
|
||||
['/ui-keyring/', '@polkadot/ui-keyring'],
|
||||
['/ui-settings/', '@polkadot/ui-settings'],
|
||||
['/ui-shared/', '@polkadot/ui-shared'],
|
||||
['/vue-identicon/', '@polkadot/vue-identicon'],
|
||||
'/CONTRIBUTING.md'
|
||||
]
|
||||
}
|
||||
};
|
||||
@@ -1,9 +0,0 @@
|
||||
$accentColor = #fd8824
|
||||
$textColor = #2c3e50
|
||||
|
||||
.home .hero .description,
|
||||
.home .feature h2,
|
||||
.home .feature p {
|
||||
color: $textColor
|
||||
opacity: 0.75
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/">https://polkadot.js.org/docs/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
home: true
|
||||
heroText:
|
||||
tagline:
|
||||
# Bringing JavaScript to the Polkadot world.
|
||||
# actionText: Repository Overview
|
||||
# actionLink: /REPOS.md
|
||||
features:
|
||||
- title: Frameworks
|
||||
details: We support multiple UI frameworks, including React, React Native and Vue.
|
||||
- title: Identicon
|
||||
details: A flexible identity icon generator supporting a number of display styles based on theme.
|
||||
- title: Keyring
|
||||
details: An extension to the base keyring that allows for additions such as browser storage.
|
||||
|
||||
footer: Apache-2 Licensed | Copyright © 2017-2019 polkadot-js authors and contributors
|
||||
---
|
||||
|
||||
## Welcome
|
||||
|
||||
This is a collection of UI libraries, utilities and classes that allows for easier use of the Polkadot JS infrastructure inside your apps.
|
||||
|
||||
::: tip Getting started
|
||||
For those new to these repose, we provide a [getting started](start/README.md) guide to take you from the tame to the insane.
|
||||
:::
|
||||
|
||||
## Available packages
|
||||
|
||||
This repository split up into a number of internal packages, namely -
|
||||
|
||||
- Examples take a short dive into some functionality, either for [React](example-react/README.md), [React Native](exampleReactNative) and [Vue](example-vue/README.md).
|
||||
- Identicons display identity icons based on theme, available for [React](react-identicon/README.md) also availble for [React Native](reactnative-identicon/README.md) and [Vue](vue-identicon/README.md)
|
||||
- [keyring](ui-keyring/README.md) A keyring with browser-specific extensions
|
||||
- [settings](ui-settings/README.md) Setting management and defaults
|
||||
|
||||
## The Polkadot Project
|
||||
|
||||
You can read more about the Polkadot Network at [https://polkadot.network/](https://polkadot.network/) and more about the polkadot-js projects at [https://polkadot.js.org](https://polkadot.js.org)
|
||||
|
||||
## Github repositories
|
||||
|
||||
You can find the Polkadot repositories at:
|
||||
|
||||
- [https://github.com/polkadot-js](https://github.com/polkadot-js)
|
||||
- [https://github.com/paritytech/polkadot](https://github.com/paritytech/polkadot)
|
||||
- [https://github.com/paritytech/substrate](https://github.com/paritytech/substrate)
|
||||
|
||||
This documentation is generated from [https://github.com/polkadot-js/ui](https://github.com/polkadot-js/ui)
|
||||
|
||||
## Contributing
|
||||
|
||||
Contribution to the Polkadot JS projects are more than welcome. You can [report issues](https://github.com/polkadot-js/ui/issues/new) and [log feature requests](https://github.com/polkadot-js/ui/issues/new).
|
||||
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="initial-scale=0.5, maximum-scale=1">
|
||||
<meta http-equiv="refresh" content="0;URL='https://polkadot.js.org/docs/'" />
|
||||
<title>Redirecting to https://polkadot.js.org/docs/</title>
|
||||
</head>
|
||||
<body>
|
||||
Redirecting to <a href="https://polkadot.js.org/docs/">https://polkadot.js.org/docs/</a>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,11 +0,0 @@
|
||||
# FAQ
|
||||
|
||||
The list will be updated/expanded as questions come up, dealing with some common issues that users find.
|
||||
|
||||
## I have a crypto has not been initialized error
|
||||
|
||||
When using the keyring, make sure that you are [initializing the keyring](keyring.md#initialization) before attempting to use it. Generally you would hook this into the async API creation (which transparently caters for the WASM load).
|
||||
|
||||
## My React Native build runs out of memory
|
||||
|
||||
When using the keyring packages with RN, due to a lack of support, an [asm.js fallback](https://github.com/polkadot-js/wasm/issues/19) is provided. This does however all some memory load to the application build process (and is by no means fast), ensure that you adjust your build flags to include `NODE_OPTIONS=--max_old_space_size=8192`, for instance doing `NODE_OPTIONS=--max_old_space_size=8192 yarn run ios`
|
||||
@@ -1,15 +0,0 @@
|
||||
# Getting started
|
||||
|
||||
These sections should provide you with all the information needed to install any packages in this repo, understand the structure of the interfaces and allow you to start using it. It really focusses on the general packages with any framework-specific packages such as icons as detailed in their own section.
|
||||
|
||||
## What this is not
|
||||
|
||||
This is not line-by-line documentation of all the existing function calls available, nor it is tied to a specific framework that you may end up using. We have users using frameworks such as Angular, Electron, React, React Native, Next.js and Vue and even support direct environments such as browser extensions, Electron apps in addition to the normal web applications you may be used to. There will be some things in the libraries that are probably not covered, which brings us to the next point...
|
||||
|
||||
## Help us help others
|
||||
|
||||
If you spot gaps in the information provided, or are uncertain about any specific area, please do [log an issue](https://github.com/polkadot-js/ui/issues) or if you are that way inclined, make a pull-request. We really want to have good documentation in these areas and allow people to be productive right from the start.
|
||||
|
||||
## Ready? Steady? Go!
|
||||
|
||||
If you already have a good grasp on the API and are just looking for a specific answer, you may want to take a look at the [Frequently Asked Questions](FAQ.md). With all that said, let's get started... [What are all these things and what can I do with it](packages.md)
|
||||
@@ -1,49 +0,0 @@
|
||||
# Keyring accounts
|
||||
|
||||
With our keyring setup completed in the previous section, and all available accounts loaded, we are ready to proceed. However we have not actually loaded any accounts yet, since well, we have not created or stored any previously. So let's change that.
|
||||
|
||||
## Adding accounts
|
||||
|
||||
The keyring has a number of ways to add accounts, but in 99% of the cases, you should need only a single method to add an account to the keyring - `addUri(suri: string, password?: string, meta: KeyringPair$Meta = {}, type?: KeypairType)`. Let's jump in with some explicit examples -
|
||||
|
||||
```js
|
||||
import { mnemonicGenerate } from '@polkadot/util-crypto';
|
||||
|
||||
...
|
||||
// generate a random mnemonic, 12 words in length
|
||||
const mnemonic = mnemonicGenerate(12);
|
||||
|
||||
// add the account, encrypt the stored JSON with an account-specific password
|
||||
const { pair, json } = keyring.addUri(mnemonic, 'myStr0ngP@ssworD', { name: 'mnemonic acc' });
|
||||
```
|
||||
|
||||
The above example is relatively straight-forward. Create an account with the specified mnemonic, encrypt the account (as stored) with the password and attach some metadata to the account. It returns a pair instance (we will work with these later) as well as the encrypted json as is saved to the store.
|
||||
|
||||
Metadata is free form, with any indicators that you would find useful in your application. Some fields that are known to be used in (and also exists other keyring entries such as contacts & contracts) includes -
|
||||
|
||||
- `genesisHash` - a hex value of the genesis this accounts belong to. If specified, the account will only be loaded when the same genesisHash is available in the keyring options
|
||||
|
||||
- `name` - a human-readable description for the account
|
||||
|
||||
## Non-mnemonic accounts
|
||||
|
||||
Generally, we would encourage all wallets and users to only support mnemonic phrases - these are portable between crypto implementations, has built-in checksums and is a standard across the blockchain environment.
|
||||
|
||||
In some cases however, either due to the need to provide backwards compatibility or for closed environments, other seed types may be used. The `addUri` will detect the type of input, i.e. if a hex-encoded value is provided, it will treat it as a raw seed. With this in mind, we can rewrite our example above to generate a random raw seed -
|
||||
|
||||
```js
|
||||
import { randomAsHex } from '@polkadot/util-crypto';
|
||||
|
||||
...
|
||||
// generate a random hex raw seed, this needs to be 32 bytes in length
|
||||
const seed = randomAsHex(32);
|
||||
|
||||
// add the account, encrypting it, override to ed25519
|
||||
const { pair, json } = keyring.addUri(seed, 'weakpass', { name: 'hex seed acc' }, 'ed25519');
|
||||
```
|
||||
|
||||
In addition to creating the account in the same fashion as in the preceding section, we are overriding the type of the account created here. Assuming we created the keyring with the `type: 'sr25519'` option, the first mnemonic account was created with an `sr25519` type. Here we specify the type of crypto explicitly, and therefore create a non-default (for this keyring instance) `ed25519` type.
|
||||
|
||||
## Deriving accounts
|
||||
|
||||
In the next section, we will expand our account creation capabilities and take a look at [account derivation and passing suri options](keyring.derivation.md).
|
||||
@@ -1,29 +0,0 @@
|
||||
# Account derivation
|
||||
|
||||
[Secret URIs](https://github.com/paritytech/substrate/wiki/Secret-URI-Test-Vectors) are a way of describing the phrase/seed along with derivation paths. This explains the naming of the default add as `addUri(...)`, it can handle mnemonics, seeds and apply suri derivations on these.
|
||||
|
||||
## Diving in
|
||||
|
||||
As a follow-up on what we have done in the preceding section, we take a dive into expanding our account addition with derivation, in this case we are applying two hard paths, `hard` followed by `derivation` -
|
||||
|
||||
```js
|
||||
...
|
||||
// add the account with hard derivation paths
|
||||
keyring.addUri(`${mnemonic}//hard//derivation`, 'donotcare', { name: 'testing derive' });
|
||||
```
|
||||
|
||||
This format is standard across the `@polkadot/keyring`, `@polkadot/ui-keyring` as well as [Substrate subkey](https://github.com/paritytech/substrate/tree/master/subkey), so it is a Polkadot/Substrate specific way of defining derivation paths.
|
||||
|
||||
## Understanding paths
|
||||
|
||||
To build a suri, you paths, the format is always `<mnemonic or seed>[//hard][/soft][///password]` and it is passed as-is to the `addUri(...)` function. the derivation types are -
|
||||
|
||||
- Soft derivation, i.e `/<soft path>` - Here a single slash, `/`, denotes a soft derivation. Please note that any pair with an `ed25519` type does not support soft derivations, these are only applicable to `sr25519` types.
|
||||
|
||||
- Hard derivation, i.e. `//<hard path>` - Here two slashes, `//`, denoted a hard derivation. This is available to both `sr25519` and `ed25519` pairs. Underlying it will apply a hashing function on the secret, generating a new secret for the remainder of the derivations.
|
||||
|
||||
- Password, i.e. `///<password>` - Here three slashed, `///`, denoted the (optional) password. Unlike hard and soft derivations that can be mixed, only a single password should be specified. The password here applies to the actual uri, not be be confused by the JSON encryption password. It is an additional security layer - if your full mnemonic and all paths do leak without the password, a bad actor would still not be able to generate a compatible secret to access funds without the password.
|
||||
|
||||
## Retrieving accounts
|
||||
|
||||
With a fim grasp on adding accounts, next we will take a look at [retrieving account and account subscriptions](keyring.retrieve.md).
|
||||
@@ -1,104 +0,0 @@
|
||||
# Keyring
|
||||
|
||||
The [@polkadot/ui-keyring](https://www.npmjs.com/package/@polkadot/ui-keyring) package provides a wrapper around the [@polkadot/keyring](https://www.npmjs.com/package/@polkadot/keyring) package, specifically for use in browser environments. The `ui-keyring` only extends the `keyring`, but does not replace it. All underlying account management functions are provided by the base keyring, the browser-specific extensions allows for transparent management of account state in storage.
|
||||
|
||||
Additionally where the base keyring is focussed on accounts, the `ui-keyring` extends this to cater for an address-book, contracts and allows for accounts to be tied to a specific chain. Since UIs are typically split into different parts, it also allows for subscriptions on accounts, so notifications are available when accounts are added or removed.
|
||||
|
||||
## Installation
|
||||
|
||||
If you already use the [@polkadot/api](https://www.npmjs.com/package/@polkadot/api) in your project (which is true in most cases), you don't need anything more than `yarn add @polkadot/ui-keyring`.
|
||||
|
||||
If however you use the `ui-keyring` independently (i.e. in an address generator, like the examples) you would need the `keyring` dependency as well, `yarn add @polkadot/keyring @polkadot/ui-keyring`. (In the first case the `@polkadot/api` already comes bundled with the base keyring, so no additional dependencies are needed).
|
||||
|
||||
## Initialization
|
||||
|
||||
To understand the initialization process, some background on the underlying libraries are required. For the [Schnorrkel sr25519](https://github.com/w3f/schnorrkel) a WASM library is used. This means that before `sr25519` can be used, the WASM libraries needs to be loaded and initialized. This is not an issue when the keyring only uses `ed25519`.
|
||||
|
||||
With this in mind, we take care of the initialization as before we load our keyring, yielding -
|
||||
|
||||
```js
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
import { cryptoWaitReady } from '@polkadot/util-crypto';
|
||||
|
||||
cryptoWaitReady().then(() => {
|
||||
// load all available addresses and accounts
|
||||
keyring.loadAll({ ss58Format: 42, type: 'sr25519' });
|
||||
|
||||
// additional initialization here, including rendering
|
||||
});
|
||||
```
|
||||
|
||||
The `cryptoWaitReady()` promise resolves as soon as the underlying WASM libraries have been made available. This is followed by `keyring.loadAll(...)` which is the main initialization for the keyring, which
|
||||
|
||||
- initializes the underlying `@polkadot/keyring`
|
||||
- loads all available accounts, addresses band contracts previously stored
|
||||
- sets up the default address format with `42` (This is the substrate development default. When not specified, this defaults to `42`)
|
||||
- defaults to `sr25519` accounts (We can still add `ed25519` accounts, more on this later. When not specified this defaults to `ed25519`)
|
||||
|
||||
Since you would generally want the keyring available before rendering the UI (although it can be done elsewhere, showing some info while loading), the following pattern is used in our examples, both React and Vue shown here -
|
||||
|
||||
```js
|
||||
...
|
||||
cryptoWaitReady().then(() => {
|
||||
keyring.loadAll({ ... });
|
||||
|
||||
// mount React and render
|
||||
ReactDOM.render(<App />, document.getElementById('app'));
|
||||
});
|
||||
```
|
||||
|
||||
```js
|
||||
...
|
||||
cryptoWaitReady().then(() => {
|
||||
keyring.loadAll({ ... });
|
||||
|
||||
// mount Vue and render
|
||||
new Vue({ render: (h) => h(App) }).$mount('#app');
|
||||
});
|
||||
```
|
||||
|
||||
When using the keyring together with the Polkadot-js API, the above would be adapted since the API itself already has a check for the WASM availability. In this case, we can adapt the interface to follow the following pattern -
|
||||
|
||||
```js
|
||||
import { ApiPromise } from '@polkadot/api';
|
||||
import keyring from '@polkadot/ui-keyring';
|
||||
|
||||
...
|
||||
ApiPromise.create({ ... }).then(() => {
|
||||
keyring.loadAll({ ... });
|
||||
|
||||
// additional initialization here, including rendering
|
||||
});
|
||||
```
|
||||
|
||||
The above pattern is how initialization is done in some applications such as the [polkadot-js apps UI](https://polkadot.js.org/apps/).
|
||||
|
||||
## Additional create options
|
||||
|
||||
In addition to the `ss58Format` and `type` options (both optional), the following additional configuration options are available to the `loadAll(...)` call -
|
||||
|
||||
- `filter?: (json: KeyringJson) => boolean` - An optional filter that is executed on account loading. This allows us to check the loaded account and apply rules on it before including it in the keyring. Generally this would be used for advanced cases, any account that is filtered with `false` won't appear.
|
||||
|
||||
- `genesisHash?: Hash` - The `genesisHash` of accounts to should be loaded. The meta property of the account _may_ contain a `genesisHash`, when both are available and non-matching, the account will not be included. To populate this option, the easiest way is to pass the `api.genesisHash` property.
|
||||
|
||||
- `isDevelopment?: boolean` - This flag, when set to `true` loads the keyring in development mode. This means that the default development accounts such as "Alice", "Bob", ..., "Ferdie" are included in the keyring. Generally you would only specify this when actually connected to a development chain.
|
||||
|
||||
- `store?: KeyringStore` - An optional store to be used. By default the `ui-keyring` will user browser localStorage, but with a specific store this behavior can be adjusted. For instance, for an extension we would default to the extension store (although localStorage is available) and for Electron apps, we may want to default to file storage.
|
||||
|
||||
```js
|
||||
import { ExtensionStore } from '@polkadot/ui-keyring/stores';
|
||||
|
||||
// For file storage where available, e.g. in Electron environments.
|
||||
// This takes an path in the constructor, new FileStore('~./keyring-data')
|
||||
// import { FileStore } from '@polkadot/ui-keyring/stores';
|
||||
|
||||
// When the store is not specified, it defaults to new BrowserStore()
|
||||
// import { BrowserStore } from '@polkadot/ui-keyring/stores';
|
||||
|
||||
...
|
||||
keyring.loadAll({ store: new ExtensionStore(), ... });
|
||||
```
|
||||
|
||||
## Managing accounts
|
||||
|
||||
With the keyring installed and ready for use, [next we will dive into adding and managing accounts](keyring.accounts.md).
|
||||
@@ -1,41 +0,0 @@
|
||||
# Other addresses
|
||||
|
||||
As mentioned in previous sections, the keyring not only has the ability to manage accounts (i.e. keypairs), but also allows you to add addresses/contacts as well as contracts to the keyring. This is very useful in the case where you are developing a wallet and want to save external addresses to interact with.
|
||||
|
||||
Here we will give an overview of working with addresses, the same concepts can be expanded to work with contracts.
|
||||
|
||||
## Adding an address
|
||||
|
||||
For accounts, we have the `addUri(...)` endpoint that allows us to create and save an account. For addresses, we the keyring exposes `saveAddress (address: string, meta: KeyringPair$Meta)`, which we can use to save any address -
|
||||
|
||||
```js
|
||||
...
|
||||
// add the address
|
||||
const FAUCET_ADDR = 'FvnazYM5KAetYpXoVDfqt9WFcJogKbekXVJ3Fz5oW2Dv82P';
|
||||
const json = keyring.saveAddress(FAUCET_ADDR, { name: 'Alex faucet' });
|
||||
|
||||
// the faucet will now be in the list of available addresses
|
||||
keyring.getAddresses().forEach(...)
|
||||
```
|
||||
|
||||
From this point forward, the address is in your keyring and can be retrieved via the `getAddresses()` interface. The same call can be used to update the meta for the address, for instance if we wish to change the name above, we can do -
|
||||
|
||||
```js
|
||||
...
|
||||
const json = keyring.saveAddress(FAUCET_ADDR, { name: 'Alexander Faucet' });
|
||||
```
|
||||
|
||||
And the already-saved address will be updated with the new metadata.
|
||||
|
||||
## Removing an address
|
||||
|
||||
To clear and address and remove it from the keyring, we can use the `forgetAddress(address: string)` call, this mirrors the `forgetAccount(address: string)` and `forgetContract(address: string)` calls. For instance -
|
||||
|
||||
```js
|
||||
...
|
||||
// remove the specific address
|
||||
keyring.forgetAddress(FAUCET_ADDR);
|
||||
|
||||
/// the faucet will not be in the list of addresses anymore
|
||||
keyring.getAddresses().forEach(...)
|
||||
```
|
||||
@@ -1,57 +0,0 @@
|
||||
# Account retrieval
|
||||
|
||||
Adding accounts is good. Having access to these accounts when added via `const { pair } = keyring.addUr(...)` is better, but being able to access these to iterate over at a later point (even after reload), is magic. Here we will try to add some magic to your experience, allowing you to retrieve accounts as well as subscribe to changes as they happen.
|
||||
|
||||
## Loading all available
|
||||
|
||||
As we've seen in the keyring init section, when we can `loadAll`, it loads all added added - this includes those added via `addUri(...)` which transparently saves to the provided storage. Loading means it is available in the keyring, to get a list of the accounts, we can then do -
|
||||
|
||||
```js
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
|
||||
...
|
||||
const accounts = keyring.getAccounts();
|
||||
|
||||
accounts.forEach(({ address, meta, publicKey }) =>
|
||||
console.log(address, JSON.stringify(meta), u8aToHex(publicKey))
|
||||
);
|
||||
```
|
||||
|
||||
The above interface was probably not quite what you have been expecting, rather you would have expected to get back a list of the pairs, but rather you received a list of the account descriptors. Some rationale for this approach - since we have `getAccounts()`, `getAddresses()` (for contacts) and `getContracts()` the consistent interface here is applicable. Instead based on an address, you can then retrieve a specific pair -
|
||||
|
||||
```js
|
||||
accounts.forEach(({ address }) => {
|
||||
// retrieve via address or publicKey
|
||||
const pair = getPair(address);
|
||||
|
||||
// display the locked account status
|
||||
console.log(address, pair.isLocked);
|
||||
});
|
||||
```
|
||||
|
||||
Similarly we have a `getPairs()` that mirrors `getAccounts()`, but retrieves the list of available pairs - which is the output you probably expected from the initial `getAccounts()` call.
|
||||
|
||||
## Subscriptions (Optional)
|
||||
|
||||
In addition to the retrieving of accounts on demand, we can actually subscribe to accounts for the keyring. This subscription returns a list of all accounts as they are updated, i.e. when a new account is added it will callback with a list of all the account, including the new one, when an account is removed, it will callback with a list of accounts, excluding the removed member.
|
||||
|
||||
```js
|
||||
...
|
||||
// create a subscription to all available accounts, updated real-time
|
||||
const sub = keyring.accounts.subject.subscribe((accounts) => {
|
||||
accounts.forEach(({ json, option }) =>
|
||||
// json is the stored data, including address
|
||||
// option is a { name: meta.name, value: address }
|
||||
);
|
||||
});
|
||||
|
||||
...
|
||||
// at some point when we are not interested anymore, we can unsubscribe
|
||||
sub.unsubscribe();
|
||||
```
|
||||
|
||||
As with the `get{Accounts|Addresses|Contracts}()` functions, similarly we have in addition to `keyring.accounts.subject` the `keyring.addresses.subject` and `keyring.contracts.subject` subscriptions available, with the same generic result set.
|
||||
|
||||
## Other address types
|
||||
|
||||
We have been referencing contacts and contracts and number of times up till now, up next we will take a look at [how to store other addresses, be if for an address book or contract](keyring.other.md).
|
||||
@@ -1,35 +0,0 @@
|
||||
# Available Packages
|
||||
|
||||
Let's take a slightly deeper diver into the available packages that we provide. While we won't (yet) cover the specifics of Frameworks-specifics (such as React, React Native or Vue), we will also take a slight detour from the rest of the getting started sections, just allowing a comprehensive overview of everything provided... including the framework-specifics.
|
||||
|
||||
## Organization
|
||||
|
||||
Before we get to the available packages, just a note on the organization of the available items. We have a number of types of packages, with the following prefixes -
|
||||
|
||||
- `@polkadot/example-*` - These are very basic examples that shows how to actually use the libraries in your own applications. for instance the `@polkadot/example-vue` shows step-by-step how to build a simple key generator with the keyring and the Vue-specific icons. (The `@polkadot/example-react` is equivalent... and we would love to see the same for React Native...)
|
||||
|
||||
- `@polkadot/ui-*` - These packages are all framework agnostic. It doesn't matter if you use Angular, React or Vue - these packages are designed to be framework independent and should work in any environment that has the intent of being displayed in a browser window, yes, including Electron.
|
||||
|
||||
- `@polkadot/react-*` - As the name suggests, these packages are meant for use with React. In some cases (e.g. UOS support), these may be slightly ahead of other frameworks. However where an equivalent package exists, we always aim for feature parity.
|
||||
|
||||
- `@polkadot/reactnative-*` - Specifically for React Native applications.
|
||||
|
||||
- `@polkadot/vue-*` - Specifically for Vue applications.
|
||||
|
||||
With the above in mind, let's take an initial tour through the various generic implementations.
|
||||
|
||||
## Generic UI libraries
|
||||
|
||||
As indicated, all of the `@polkadot/ui-*` packages are meant to be framework independent. The only common thread between these are that they are designed for use inside a browser, with no requirement for using a development framework.
|
||||
|
||||
The first package we will look at is the [@polkadot/ui-assets package](https://www.npmjs.com/package/@polkadot/ui-assets). It really is just a collection of images that are available for various chains & nodes and makes no assumption about how you are including it in your app, or rather which packager you use.
|
||||
|
||||
Up next is a critical component of any non-trivial app that also manages accounts, [@polkadot/ui-keyring](https://www.npmjs.com/package/@polkadot/ui-keyring). It is a browser-specific wrapper around the [@polkadot/keyring pcakge](https://www.npmjs.com/package/@polkadot/keyring) that transparently handles access to accounts, addresses, contracts and storage (saving accounts between use) all while allowing for swapable storage depending on your environment, be it browser, extension or Electron.
|
||||
|
||||
[@polkadot/ui-settings](https://www.npmjs.com/package/@polkadot/ui-settings) provides a set of default settings, UI end network related, that could be useful to application developers in certain circumstances. The relates to settings such are ss58 formats, network endpoints and other.
|
||||
|
||||
Last-up is the [@polkadot/ui-shared](https://www.npmjs.com/package/@polkadot/ui-shared) package. It is not deemed as generally useful to building apps, but rather contains shared code that is used within other packages, for instance in the generation of icons.
|
||||
|
||||
## Diving in
|
||||
|
||||
Now that we have some bearing of where we are, it is time to take a dive in, [let's start with the keyring and see what we can do](keyring.md).
|
||||
+2
-3
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const config = require('@polkadot/dev/config/jest');
|
||||
|
||||
@@ -12,5 +11,5 @@ module.exports = Object.assign({}, config, {
|
||||
'\\.(css|less)$': 'empty/object',
|
||||
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': 'empty/object'
|
||||
},
|
||||
resolver: './jest.resolver.js'
|
||||
resolver: '@polkadot/dev/config/jest-resolver'
|
||||
});
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
// Copyright 2017-2020 @polkadot/ui authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = function resolver (file, config) {
|
||||
return file.includes('package.json')
|
||||
? path.join(config.basedir.replace('/src', '/'), file)
|
||||
: config.defaultResolver(file, config);
|
||||
};
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"npmClient": "yarn",
|
||||
"useWorkspaces": true,
|
||||
"command": {
|
||||
"publish": {
|
||||
"allowBranch": "master"
|
||||
}
|
||||
},
|
||||
"packages": [
|
||||
"packages/*"
|
||||
],
|
||||
"version": "0.58.1"
|
||||
}
|
||||
+13
-16
@@ -8,13 +8,11 @@
|
||||
"packages/*"
|
||||
],
|
||||
"resolutions": {
|
||||
"babel-core": "^7.0.0-bridge.0"
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "polkadot-dev-build-ts",
|
||||
"build:release": "polkadot-ci-ghact-build",
|
||||
"docs": "polkadot-dev-build-docs",
|
||||
"docs:release": "polkadot-ci-ghact-docs",
|
||||
"lint": "polkadot-dev-run-lint",
|
||||
"clean": "polkadot-dev-clean-build",
|
||||
"demo:identicon:react": "yarn build && webpack-serve --config packages/react-identicon/webpack.config.js --content packages/react-identicon --port 8080",
|
||||
@@ -29,22 +27,21 @@
|
||||
"test:one": "polkadot-dev-run-test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/dev": "^0.55.43",
|
||||
"@polkadot/ts": "^0.3.40",
|
||||
"@types/jest": "^26.0.10",
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/dev": "^0.59.20",
|
||||
"@polkadot/ts": "^0.3.53",
|
||||
"@types/jest": "^26.0.15",
|
||||
"babel-plugin-transform-vue-template": "^0.4.2",
|
||||
"empty": "^0.10.1",
|
||||
"react": "^16.13.1",
|
||||
"react-dom": "^16.13.1",
|
||||
"react-is": "^16.13.1",
|
||||
"react-native": "^0.63.2",
|
||||
"typedoc": "^0.18.0",
|
||||
"typedoc-plugin-markdown": "^2.4.2",
|
||||
"typedoc-plugin-no-inherit": "^1.1.10",
|
||||
"react": "^17.0.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-is": "^17.0.1",
|
||||
"react-native": "^0.63.3",
|
||||
"vue-template-compiler": "^2.6.12",
|
||||
"webpack": "^4.44.2",
|
||||
"webpack-cli": "^3.3.12",
|
||||
"webpack-serve": "^3.2.0"
|
||||
},
|
||||
"version": "0.58.1"
|
||||
"version": "0.62.1"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/example-react",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "A very basic example with ui-* & react-* packages",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,6 +9,6 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2"
|
||||
"@babel/runtime": "^7.12.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-react authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-react authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const path = require('path');
|
||||
const { WebpackPluginServe } = require('webpack-plugin-serve');
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/example-vue",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "A very basic example with ui-* & vue-* packages",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,6 +9,6 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2"
|
||||
"@babel/runtime": "^7.12.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-vue authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-vue authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const path = require('path');
|
||||
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-react authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, View } from 'react-native';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-reactnative authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
module.exports = {
|
||||
presets: ['module:metro-react-native-babel-preset']
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-react authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import './nodeGlobalsShim.js';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-reactnative authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const path = require('path');
|
||||
const getWorkspaces = require('get-yarn-workspaces');
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/example-reactnative authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
/* eslint-disable no-global-assign */
|
||||
|
||||
|
||||
@@ -1,18 +1,7 @@
|
||||
{
|
||||
"name": "exampleReactNative",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"private": true,
|
||||
"workspaces": {
|
||||
"nohoist": [
|
||||
"react-native",
|
||||
"react-native/**",
|
||||
"react-native-randombytes",
|
||||
"react-native-randombytes/**",
|
||||
"@react-native-community/**",
|
||||
"react-native-svg",
|
||||
"react-native-svg/**"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"copy-workspace-packages": "yarn copy-identicon && yarn copy-ui-shared",
|
||||
"copy-identicon": "mkdir -p node_modules/@polkadot/reactnative-identicon && cp -r ../reactnative-identicon/build/* ./node_modules/@polkadot/reactnative-identicon",
|
||||
@@ -23,36 +12,31 @@
|
||||
"test": "jest"
|
||||
},
|
||||
"dependencies": {
|
||||
"@polkadot/reactnative-identicon": "0.58.1",
|
||||
"@polkadot/ui-keyring": "0.58.1",
|
||||
"@polkadot/ui-settings": "0.58.1",
|
||||
"@react-native-community/async-storage": "^1.12.0",
|
||||
"@polkadot/keyring": "^4.0.1",
|
||||
"@polkadot/reactnative-identicon": "0.62.1",
|
||||
"@polkadot/ui-keyring": "0.62.1",
|
||||
"@polkadot/ui-settings": "0.62.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@polkadot/util-crypto": "^4.0.1",
|
||||
"@react-native-community/async-storage": "^1.12.1",
|
||||
"fast-text-encoding": "^1.0.3",
|
||||
"get-yarn-workspaces": "^1.0.2",
|
||||
"os-browserify": "^0.3.0",
|
||||
"process": "^0.11.10",
|
||||
"react": "16.13.1",
|
||||
"react-native": "^0.63.2",
|
||||
"react": "^17.0.1",
|
||||
"react-native": "^0.63.3",
|
||||
"react-native-crypto": "^2.2.0",
|
||||
"react-native-randombytes": "^3.5.3",
|
||||
"react-native-randombytes": "^3.6.0",
|
||||
"stream-http": "^3.1.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.11.4",
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@react-native-community/cli-platform-ios": "^4.11.0",
|
||||
"@babel/core": "^7.12.3",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@react-native-community/cli-platform-ios": "^4.13.0",
|
||||
"@types/react-test-renderer": "16.9.3",
|
||||
"babel-jest": "^26.3.0",
|
||||
"metro-react-native-babel-preset": "^0.63.0",
|
||||
"react-test-renderer": "16.13.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/keyring": "*",
|
||||
"@polkadot/util": "*",
|
||||
"@polkadot/util-crypto": "*"
|
||||
"babel-jest": "^26.6.3",
|
||||
"metro-react-native-babel-preset": "^0.64.0",
|
||||
"react-test-renderer": "17.0.1"
|
||||
},
|
||||
"jest": {
|
||||
"preset": "react-native",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/react-identicon",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "Renders an SVG picture representing an address",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,12 +9,17 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/ui-settings": "0.58.1",
|
||||
"@polkadot/ui-shared": "0.58.1",
|
||||
"color": "^3.1.2",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/keyring": "^4.0.1",
|
||||
"@polkadot/ui-settings": "0.62.1",
|
||||
"@polkadot/ui-shared": "0.62.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@polkadot/util-crypto": "^4.0.1",
|
||||
"color": "^3.1.3",
|
||||
"ethereum-blockies-base64": "^1.0.2",
|
||||
"jdenticon": "2.2.0",
|
||||
"react-copy-to-clipboard": "^5.0.2"
|
||||
"react-copy-to-clipboard": "^5.0.2",
|
||||
"styled-components": "^5.2.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/keyring": "*",
|
||||
@@ -26,13 +31,10 @@
|
||||
"styled-components": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@types/react-copy-to-clipboard": "^4.3.0",
|
||||
"@types/react-dom": "^16.9.8",
|
||||
"@types/styled-components": "^5.1.2",
|
||||
"styled-components": "^5.1.1",
|
||||
"@types/react-dom": "^16.9.9",
|
||||
"@types/styled-components": "^5.1.4",
|
||||
"styled-components": "^5.2.1",
|
||||
"xmlserializer": "^0.6.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import { IdentityProps as Props, Props as ComponentProps } from './types';
|
||||
@@ -10,9 +9,9 @@ import CopyToClipboard from 'react-copy-to-clipboard';
|
||||
import styled from 'styled-components';
|
||||
import settings, { ICON_DEFAULT_HOST } from '@polkadot/ui-settings';
|
||||
import { isHex, isU8a, u8aToHex } from '@polkadot/util';
|
||||
import { decodeAddress, encodeAddress } from '@polkadot/util-crypto';
|
||||
import { decodeAddress, encodeAddress, ethereumEncode } from '@polkadot/util-crypto';
|
||||
|
||||
import { Beachball, Empty, Jdenticon, Polkadot } from './icons';
|
||||
import { Beachball, Empty, Ethereum, Jdenticon, Polkadot } from './icons';
|
||||
|
||||
const Fallback = Beachball;
|
||||
|
||||
@@ -25,6 +24,7 @@ const DEFAULT_SIZE = 64;
|
||||
const Components: Record<string, React.ComponentType<ComponentProps>> = {
|
||||
beachball: Beachball,
|
||||
empty: Empty,
|
||||
ethereum: Ethereum,
|
||||
jdenticon: Jdenticon,
|
||||
polkadot: Polkadot,
|
||||
substrate: Jdenticon
|
||||
@@ -68,7 +68,15 @@ class BaseIcon extends React.PureComponent<Props, State> {
|
||||
BaseIcon.prefix = prefix;
|
||||
}
|
||||
|
||||
public static getDerivedStateFromProps ({ prefix = BaseIcon.prefix, value }: Props, prevState: State): State | null {
|
||||
public static getDerivedStateFromProps ({ prefix = BaseIcon.prefix, theme, value }: Props, prevState: State): State | null {
|
||||
if (theme === 'ethereum') {
|
||||
const address = isU8a(value)
|
||||
? ethereumEncode(value)
|
||||
: value || '';
|
||||
|
||||
return { address, publicKey: '' };
|
||||
}
|
||||
|
||||
try {
|
||||
const address = isU8a(value) || isHex(value)
|
||||
? encodeAddress(value, prefix)
|
||||
@@ -91,7 +99,7 @@ class BaseIcon extends React.PureComponent<Props, State> {
|
||||
|
||||
public render (): React.ReactNode {
|
||||
const { address } = this.state;
|
||||
const wrapped = this.getWrapped(this.state);
|
||||
const wrapped = this.getWrapped(this.state, this.props);
|
||||
|
||||
return !address
|
||||
? wrapped
|
||||
@@ -105,11 +113,11 @@ class BaseIcon extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
private getWrapped ({ address, publicKey }: State): React.ReactNode {
|
||||
private getWrapped ({ address, publicKey }: State, { Custom }: Props): React.ReactNode {
|
||||
const { className = '', isAlternative, isHighlight, size = DEFAULT_SIZE, style, theme = settings.icon } = this.props;
|
||||
const Component = !address
|
||||
? Empty
|
||||
: Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
|
||||
: Custom || Components[theme === 'default' ? ICON_DEFAULT_HOST : theme] || Fallback;
|
||||
|
||||
return (
|
||||
<Wrapper
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Props } from '../types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Props } from '../types';
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Props } from '../types';
|
||||
|
||||
import makeBlockie from 'ethereum-blockies-base64';
|
||||
import React, { useMemo } from 'react';
|
||||
import styled from 'styled-components';
|
||||
|
||||
function Ethereum ({ address, className = '', style }: Props): React.ReactElement<Props> {
|
||||
const imgSrc = useMemo(
|
||||
() => makeBlockie(address),
|
||||
[address]
|
||||
);
|
||||
|
||||
return (
|
||||
<img
|
||||
className={className}
|
||||
src={imgSrc}
|
||||
style={style}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(styled(Ethereum)(({ size }: Props) => `
|
||||
display: block;
|
||||
height: ${size}px;
|
||||
width: ${size}px;
|
||||
`));
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Props } from '../types';
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
// Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
|
||||
// Copyright 2018-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
// Copyright 2018 Paritytech via paritytech/oo7/polkadot-identicon
|
||||
|
||||
// This has been converted from the original version that can be found at
|
||||
//
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Beachball } from './Beachball';
|
||||
export { default as Empty } from './Empty';
|
||||
export { default as Ethereum } from './Ethereum';
|
||||
export { default as Jdenticon } from './Jdenticon';
|
||||
export { default as Polkadot } from './Polkadot';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Identicon from './Identicon';
|
||||
export * from './icons';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2018-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import React from 'react';
|
||||
@@ -20,11 +19,12 @@ export interface Props extends BaseProps {
|
||||
}
|
||||
|
||||
export interface IdentityProps extends BaseProps {
|
||||
Custom?: React.ComponentType<Props>;
|
||||
isAlternative?: boolean;
|
||||
isHighlight?: boolean;
|
||||
onCopy?: (value: string) => void;
|
||||
prefix?: Prefix;
|
||||
size?: number;
|
||||
theme?: 'beachball' | 'empty' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||
theme?: 'beachball' | 'empty' | 'ethereum' | 'jdenticon' | 'polkadot' | 'substrate';
|
||||
value?: string | Uint8Array | null;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const path = require('path');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/react-qr",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "Generates and reads QR codes",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,13 +9,16 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@polkadot/util-crypto": "^4.0.1",
|
||||
"qrcode-generator": "^1.4.4",
|
||||
"react-qr-reader": "^2.2.1"
|
||||
"react-qr-reader": "^2.2.1",
|
||||
"styled-components": "^5.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react-qr-reader": "^2.1.3",
|
||||
"@types/styled-components": "^5.1.2"
|
||||
"@types/styled-components": "^5.1.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import { xxhashAsHex } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -46,9 +45,13 @@ function getDataUrl (value: Uint8Array): string {
|
||||
|
||||
function Display ({ className, size, skipEncoding, style, value }: Props): React.ReactElement<Props> | null {
|
||||
const [{ image }, setFrameState] = useState<FrameState>({ frameIdx: 0, frames: [], image: null, valueHash: null });
|
||||
const [containerStyle, setContainerStyle] = useState(createImgSize(size));
|
||||
const timerRef = useRef<TimerState>({ timerDelay: FRAME_DELAY, timerId: null });
|
||||
|
||||
const containerStyle = useMemo(
|
||||
() => createImgSize(size),
|
||||
[size]
|
||||
);
|
||||
|
||||
// run on initial load to setup the global timer and provide and unsubscribe
|
||||
useEffect((): () => void => {
|
||||
const nextFrame = () => setFrameState((state): FrameState => {
|
||||
@@ -86,10 +89,6 @@ function Display ({ className, size, skipEncoding, style, value }: Props): React
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
useEffect((): void => {
|
||||
setContainerStyle(createImgSize(size));
|
||||
}, [size]);
|
||||
|
||||
useEffect((): void => {
|
||||
setFrameState((state): FrameState => {
|
||||
const valueHash = xxhashAsHex(value);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { createAddressPayload } from './util';
|
||||
import QrDisplay from './Display';
|
||||
@@ -16,11 +15,10 @@ interface Props {
|
||||
}
|
||||
|
||||
function DisplayExtrinsic ({ address, className, genesisHash, size, style }: Props): React.ReactElement<Props> | null {
|
||||
const [data, setData] = useState<Uint8Array | null>(null);
|
||||
|
||||
useEffect((): void => {
|
||||
setData(createAddressPayload(address, genesisHash));
|
||||
}, [address, genesisHash]);
|
||||
const data = useMemo(
|
||||
() => createAddressPayload(address, genesisHash),
|
||||
[address, genesisHash]
|
||||
);
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
|
||||
import { createSignPayload } from './util';
|
||||
import QrDisplay from './Display';
|
||||
@@ -18,11 +17,10 @@ interface Props {
|
||||
}
|
||||
|
||||
function DisplayPayload ({ address, className, cmd, genesisHash, payload, size, style }: Props): React.ReactElement<Props> | null {
|
||||
const [data, setData] = useState<Uint8Array | null>(null);
|
||||
|
||||
useEffect((): void => {
|
||||
setData(createSignPayload(address, cmd, payload, genesisHash));
|
||||
}, [address, cmd, payload, genesisHash]);
|
||||
const data = useMemo(
|
||||
() => createSignPayload(address, cmd, payload, genesisHash),
|
||||
[address, cmd, payload, genesisHash]
|
||||
);
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { NetworkSpecsStruct } from '@polkadot/ui-settings';
|
||||
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import React, { useMemo } from 'react';
|
||||
import QrDisplay from './Display';
|
||||
|
||||
import { encodeString } from './util';
|
||||
@@ -17,11 +16,10 @@ interface Props {
|
||||
}
|
||||
|
||||
function DisplayNetworkSpecs ({ className, networkSpecs, size, style }: Props): React.ReactElement<Props> | null {
|
||||
const [data, setData] = useState<Uint8Array | null>(null);
|
||||
|
||||
useEffect((): void => {
|
||||
setData(encodeString(JSON.stringify(networkSpecs)));
|
||||
}, [networkSpecs]);
|
||||
const data = useMemo(
|
||||
() => encodeString(JSON.stringify(networkSpecs)),
|
||||
[networkSpecs]
|
||||
);
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
import Reader from 'react-qr-reader';
|
||||
import styled from 'styled-components';
|
||||
|
||||
@@ -24,11 +23,10 @@ const DEFAULT_ERROR = (error: Error): void => {
|
||||
};
|
||||
|
||||
function Scan ({ className, delay = DEFAULT_DELAY, onError = DEFAULT_ERROR, onScan, size, style }: Props): React.ReactElement<Props> {
|
||||
const [containerStyle, setContainerStyle] = useState(createImgSize(size));
|
||||
|
||||
useEffect((): void => {
|
||||
setContainerStyle(createImgSize(size));
|
||||
}, [size]);
|
||||
const containerStyle = useMemo(
|
||||
() => createImgSize(size),
|
||||
[size]
|
||||
);
|
||||
|
||||
const _onError = useCallback(
|
||||
(error: Error) => onError(error),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useCallback } from 'react';
|
||||
import { assert } from '@polkadot/util';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import React, { useCallback } from 'react';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
const ADDRESS_PREFIX = 'substrate';
|
||||
const SEED_PREFIX = 'secret';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as QrDisplayAddress } from './DisplayAddress';
|
||||
export { default as QrDisplayPayload } from './DisplayPayload';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import _qrcode from 'qrcode-generator';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { u8aConcat, u8aToHex, u8aToString } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/react-qr authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { isString, u8aConcat, u8aToU8a } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/util-crypto';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/reactnative-identicon",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "Renders an SVG picture representing an address",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,17 +9,19 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@polkadot/ui-shared": "0.58.1",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@polkadot/ui-shared": "0.62.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@polkadot/util-crypto": "^4.0.1",
|
||||
"react-native-svg": "^12.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/util": "*",
|
||||
"@polkadot/util-crypto": "*",
|
||||
"react": "*",
|
||||
"react-native": "*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/util-crypto": "^3.4.1",
|
||||
"@types/react-native": "^0.63.10"
|
||||
"@types/react-native": "^0.63.32"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
import { Props as ComponentProps } from './types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Props } from '../types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2018-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { Circle as CircleType } from '@polkadot/ui-shared/icons/types';
|
||||
import { Props } from '../types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export { default as Empty } from './Empty';
|
||||
export { default as Polkadot } from './Polkadot';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Identicon from './Identicon';
|
||||
export * from './icons';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2018-2020 @polkadot/reactnative-identicon authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
export interface Props {
|
||||
address: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/ui-assets",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"description": "Static assets shared accross projects",
|
||||
"main": "index.js",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -9,6 +9,6 @@
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2"
|
||||
"@babel/runtime": "^7.12.5"
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-2
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-assets authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
declare module '*.svg' {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@polkadot/ui-keyring",
|
||||
"version": "0.58.1",
|
||||
"version": "0.62.1",
|
||||
"main": "index.js",
|
||||
"repository": "https://github.com/polkadot-js/apps.git",
|
||||
"author": "Jaco Greeff <jacogr@gmail.com>",
|
||||
@@ -17,24 +17,25 @@
|
||||
"./ledger/transportsWeb": "./ledger/transportsEmpty"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.11.2",
|
||||
"@ledgerhq/hw-transport-webusb": "^5.22.0",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"@ledgerhq/hw-transport-webusb": "^5.28.0",
|
||||
"@polkadot/keyring": "^4.0.1",
|
||||
"@polkadot/ui-settings": "0.62.1",
|
||||
"@polkadot/util": "^4.0.1",
|
||||
"@zondax/ledger-polkadot": "^0.11.0",
|
||||
"mkdirp": "^1.0.4",
|
||||
"rxjs": "^6.6.2",
|
||||
"rxjs": "^6.6.3",
|
||||
"store": "^2.0.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@polkadot/keyring": "^3.4.1",
|
||||
"@polkadot/types": "^1.31.1",
|
||||
"@polkadot/util": "^3.4.1",
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.1",
|
||||
"@types/ledgerhq__hw-transport-webusb": "^4.70.0",
|
||||
"@polkadot/types": "^2.6.1",
|
||||
"@types/ledgerhq__hw-transport-node-hid": "^4.22.2",
|
||||
"@types/ledgerhq__hw-transport-webusb": "^4.70.1",
|
||||
"@types/mkdirp": "^1.0.1",
|
||||
"@types/store": "^2.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@ledgerhq/hw-transport-node-hid": "^5.22.0"
|
||||
"@ledgerhq/hw-transport-node-hid": "^5.28.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@polkadot/keyring": "*",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringInstance, KeyringPair } from '@polkadot/keyring/types';
|
||||
import { Prefix } from '@polkadot/util-crypto/address/types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringPair, KeyringPair$Meta, KeyringPair$Json } from '@polkadot/keyring/types';
|
||||
import { KeypairType } from '@polkadot/util-crypto/types';
|
||||
@@ -80,6 +79,10 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
return pair.toJson(password);
|
||||
}
|
||||
|
||||
public createFromJson (json: KeyringPair$Json, meta: KeyringPair$Meta = {}): KeyringPair {
|
||||
return this.keyring.createFromJson({ ...json, meta: { ...(json.meta || {}), meta } });
|
||||
}
|
||||
|
||||
public createFromUri (suri: string, meta: KeyringPair$Meta = {}, type?: KeypairType): KeyringPair {
|
||||
return this.keyring.createFromUri(suri, meta, type);
|
||||
}
|
||||
@@ -192,12 +195,17 @@ export class Keyring extends Base implements KeyringStruct {
|
||||
return;
|
||||
}
|
||||
|
||||
const address = this.encodeAddress(
|
||||
isHex(json.address)
|
||||
? hexToU8a(json.address)
|
||||
// FIXME Just for the transition period (ignoreChecksum)
|
||||
: this.decodeAddress(json.address, true)
|
||||
);
|
||||
// We assume anything hex that is not 32bytes (64 + 2 bytes hex) is an Ethereum-like address
|
||||
// (this caters for both H160 addresses as well as full or compressed publicKeys) - in the case
|
||||
// of both ecdsa and ethereum, we keep it as-is
|
||||
const address = isHex(json.address) && json.address.length !== 66
|
||||
? json.address
|
||||
: this.encodeAddress(
|
||||
isHex(json.address)
|
||||
? hexToU8a(json.address)
|
||||
// FIXME Just for the transition period (ignoreChecksum)
|
||||
: this.decodeAddress(json.address, true)
|
||||
);
|
||||
const [, hexAddr] = key.split(':');
|
||||
|
||||
this.addresses.add(this._store, address, json);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { u8aToHex } from '@polkadot/util';
|
||||
import { decodeAddress } from '@polkadot/keyring';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { detectPackage } from '@polkadot/util';
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Transport from '@ledgerhq/hw-transport';
|
||||
import { LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
|
||||
import { AccountOptions, LedgerAddress, LedgerSignature, LedgerTypes, LedgerVersion } from './types';
|
||||
|
||||
import { ResponseBase, SubstrateApp, newKusamaApp, newPolkadotApp } from '@zondax/ledger-polkadot';
|
||||
import { assert, bufferToU8a, u8aToBuffer, u8aToHex } from '@polkadot/util';
|
||||
@@ -47,7 +46,41 @@ export default class Ledger {
|
||||
this.#transport = transport;
|
||||
}
|
||||
|
||||
private async _getApp (): Promise<SubstrateApp> {
|
||||
public async getAddress (confirm = false, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerAddress> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this.#wrapError(app.getAddress(account + accountOffset, change, addressIndex + addressOffset, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
publicKey: `0x${pubKey}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this.#wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
isTestMode,
|
||||
version: [major, minor, patch]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, accountOffset = 0, addressOffset = 0, { account = LEDGER_DEFAULT_ACCOUNT, addressIndex = LEDGER_DEFAULT_INDEX, change = LEDGER_DEFAULT_CHANGE }: Partial<AccountOptions> = {}): Promise<LedgerSignature> {
|
||||
return this.#withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this.#wrapError(app.sign(account + accountOffset, change, addressIndex + addressOffset, buffer));
|
||||
|
||||
return {
|
||||
signature: u8aToHex(bufferToU8a(signature))
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
#getApp = async (): Promise<SubstrateApp> => {
|
||||
if (!this.#app) {
|
||||
const def = transports.find(({ type }) => type === this.#transport);
|
||||
|
||||
@@ -59,11 +92,11 @@ export default class Ledger {
|
||||
}
|
||||
|
||||
return this.#app;
|
||||
}
|
||||
};
|
||||
|
||||
private async _withApp <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> {
|
||||
#withApp = async <T> (fn: (app: SubstrateApp) => Promise<T>): Promise<T> => {
|
||||
try {
|
||||
const app = await this._getApp();
|
||||
const app = await this.#getApp();
|
||||
|
||||
return await fn(app);
|
||||
} catch (error) {
|
||||
@@ -71,47 +104,13 @@ export default class Ledger {
|
||||
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private async _wrapError <T extends ResponseBase> (promise: Promise<T>): Promise<T> {
|
||||
#wrapError = async <T extends ResponseBase> (promise: Promise<T>): Promise<T> => {
|
||||
const result = await promise;
|
||||
|
||||
assert(result.return_code === SUCCESS_CODE, result.error_message);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async getAddress (confirm = false, account = LEDGER_DEFAULT_ACCOUNT, change = LEDGER_DEFAULT_CHANGE, addressIndex = LEDGER_DEFAULT_INDEX): Promise<LedgerAddress> {
|
||||
return this._withApp(async (app: SubstrateApp): Promise<LedgerAddress> => {
|
||||
const { address, pubKey } = await this._wrapError(app.getAddress(account, change, addressIndex, confirm));
|
||||
|
||||
return {
|
||||
address,
|
||||
publicKey: `0x${pubKey}`
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async getVersion (): Promise<LedgerVersion> {
|
||||
return this._withApp(async (app: SubstrateApp): Promise<LedgerVersion> => {
|
||||
const { device_locked: isLocked, major, minor, patch, test_mode: isTestMode } = await this._wrapError(app.getVersion());
|
||||
|
||||
return {
|
||||
isLocked,
|
||||
isTestMode,
|
||||
version: [major, minor, patch]
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public async sign (message: Uint8Array, account = LEDGER_DEFAULT_ACCOUNT, change = LEDGER_DEFAULT_CHANGE, addressIndex = LEDGER_DEFAULT_INDEX): Promise<LedgerSignature> {
|
||||
return this._withApp(async (app: SubstrateApp): Promise<LedgerSignature> => {
|
||||
const buffer = u8aToBuffer(message);
|
||||
const { signature } = await this._wrapError(app.sign(account, change, addressIndex, buffer));
|
||||
|
||||
return {
|
||||
signature: u8aToHex(bufferToU8a(signature))
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TransportDef } from './types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TransportDef } from './types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { TransportDef } from './types';
|
||||
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import Transport from '@ledgerhq/hw-transport';
|
||||
|
||||
export type LedgerTypes = 'hid' | 'u2f' | 'webusb';
|
||||
|
||||
export interface AccountOptions {
|
||||
account: number;
|
||||
addressIndex: number;
|
||||
change: number;
|
||||
}
|
||||
|
||||
export interface LedgerAddress {
|
||||
address: string;
|
||||
publicKey: string;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { accountKey } from '../defaults';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { addressKey } from '../defaults';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { contractKey } from '../defaults';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { SubjectInfo, AddressSubject, SingleAddress } from './types';
|
||||
import { KeyringJson, KeyringStore } from '../types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { SubjectInfo } from './types';
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { KeyringSectionOption } from '../options/types';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringStruct } from '../types';
|
||||
import keyringOptionInstance from '.';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
// Copyright 2017-2020 @polkadot/ui-keyring authors & contributors
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { KeyringStruct } from '../types';
|
||||
import { SingleAddress } from '../observable/types';
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user