You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Remove the traces on custom type and update to based on Node v16
* webpack 5 migration
* Rm eslint related dev-dependencies & use URLSearchParams over querystring
* Updated to the latest polkadot-js libs
* Integrate with prettier
* Friendlier connection failure message.
* Refactored current selected account into SubstrateContext
* bugfix
* Fix console warning
* Update README
* Update to solve a yarn berry issue
The template is built with [Create React App](https://github.com/facebook/create-react-app)
9
9
and [Polkadot js API](https://polkadot.js.org/docs/api/). Familiarity with these tools
@@ -13,7 +13,7 @@ will be helpful, but the template strives to be self-explanatory.
13
13
14
14
### Installation
15
15
16
-
The codebase is installed using [git](https://git-scm.com/) and [yarn](https://yarnpkg.com/). This tutorial assumes you have installed yarn globally prior to installing it within the subdirectories.For the most recent version and how to install yarn, please refer to [yarn](https://yarnpkg.com/) documentation and installation guides.
16
+
The codebase is installed using [git](https://git-scm.com/) and [yarn](https://yarnpkg.com/). This tutorial assumes you have installed yarn globally prior to installing it within the subdirectories.For the most recent version and how to install yarn, please refer to [yarn](https://yarnpkg.com/) documentation and installation guides.
17
17
18
18
```bash
19
19
# Clone the repository
@@ -35,6 +35,7 @@ You can also build the app in production mode,
35
35
```bash
36
36
yarn build
37
37
```
38
+
38
39
and open `build/index.html` in your favorite browser.
39
40
40
41
## Configuration
@@ -43,71 +44,70 @@ The template's configuration is stored in the `src/config` directory, with
43
44
`common.json` being loaded first, then the environment-specific json file,
44
45
and finally environment variables, with precedence.
45
46
46
-
*`development.json` affects the development environment
47
-
*`test.json` affects the test environment, triggered in `yarn test` command.
48
-
*`production.json` affects the production environment, triggered in
49
-
`yarn build` command.
47
+
-`development.json` affects the development environment
48
+
-`test.json` affects the test environment, triggered in `yarn test` command.
49
+
-`production.json` affects the production environment, triggered in
50
+
`yarn build` command.
50
51
51
52
Some environment variables are read and integrated in the template `config` object,
*`PROVIDER_SOCKET` in `src/config/production.json` pointing to your own
62
+
-`PROVIDER_SOCKET` in `src/config/production.json` pointing to your own
64
63
deployed node.
65
-
*`DEVELOPMENT_KEYRING` in `src/config/common.json` be set to `false`.
64
+
-`DEVELOPMENT_KEYRING` in `src/config/common.json` be set to `false`.
66
65
See [Keyring](https://polkadot.js.org/docs/api/start/keyring).
67
66
68
67
### Specifying Connecting Node
69
68
70
69
There are two ways to specify it:
71
70
72
-
* With `PROVIDER_SOCKET` in `{common, development, production}.json`.
73
-
* With `rpc=<ws or wss connection>` query paramter after the URL. This overrides the above setting.
71
+
- With `PROVIDER_SOCKET` in `{common, development, production}.json`.
72
+
- With `rpc=<ws or wss connection>` query paramter after the URL. This overrides the above setting.
74
73
75
74
## Reusable Components
76
75
77
76
### useSubstrate Custom Hook
78
77
79
-
The custom hook `useSubstrate` provides access to the Polkadot js API and thus the
78
+
The custom hook `useSubstrate()` provides access to the Polkadot js API and thus the
80
79
keyring and the blockchain itself. Specifically it exposes this API.
81
80
82
81
```js
83
82
{
84
-
socket,
85
-
types,
86
-
keyring,
87
-
keyringState,
88
-
api,
89
-
apiState,
83
+
setCurrentAccount:func(acct) {...}
84
+
state: {
85
+
socket,
86
+
keyring,
87
+
keyringState,
88
+
api,
89
+
apiState,
90
+
currentAccount
91
+
}
90
92
}
91
93
```
92
94
93
95
-`socket` - The remote provider socket it is connecting to.
94
-
-`types` - The custom types used in the connected node.
95
96
-`keyring` - A keyring of accounts available to the user.
96
97
-`keyringState` - One of `"READY"` or `"ERROR"` states. `keyring` is valid
97
-
only when `keyringState === "READY"`.
98
+
only when `keyringState === "READY"`.
98
99
-`api` - The remote api to the connected node.
99
100
-`apiState` - One of `"CONNECTING"`, `"READY"`, or `"ERROR"` states. `api` is valid
100
-
only when `apiState === "READY"`.
101
+
only when `apiState === "READY"`.
102
+
-`currentAccount` - The current selected account pair in the application context.
103
+
-`setCurrentAccount` - Function to update the `currentAccount` value in the application context.
101
104
105
+
If you are only interested in reading the `state`, there is a shorthand `useSubstrateState()` just to retrieve the state.
102
106
103
107
### TxButton Component
104
108
105
-
The [TxButton](./src/substrate-lib/components/TxButton.js) handles basic
106
-
[query](https://polkadot.js.org/docs/api/start/api.query) and
107
-
[transaction](https://polkadot.js.org/docs/api/start/api.tx) requests to the
108
-
connected node. You can reuse this component for a wide variety of queries and
109
-
transactions. See [src/Transfer.js](./src/Transfer.js) for a transaction example
110
-
and [src/ChainState.js](./src/ChainState.js) for a query example.
109
+
The [TxButton](./src/substrate-lib/components/TxButton.js) handles basic [query](https://polkadot.js.org/docs/api/start/api.query) and [transaction](https://polkadot.js.org/docs/api/start/api.tx) requests to the connected node.
110
+
You can reuse this component for a wide variety of queries and transactions. See [src/Transfer.js](./src/Transfer.js) for a transaction example and [src/Balances.js](./src/ChainState.js) for a query example.
To begin the development, run `npm start` or `yarn start`.
39
42
To create a production bundle, use `npm run build` or `yarn build`.
40
43
-->
41
-
<aclass="github-fork-ribbon right-bottom fixed" target='_blank' href="https://github.com/substrate-developer-hub/substrate-front-end-template" data-ribbon="Fork me on GitHub" title="Fork me on GitHub">Fork me on GitHub</a>
0 commit comments