Skip to content

Commit

Permalink
Simplified & Updated packages (#210)
Browse files Browse the repository at this point in the history
* simplified and updated packages

* updated polkadot-js libs

* removed types passed to polkadot-js api.
  • Loading branch information
Jimmy Chu authored Nov 10, 2021
1 parent daf38f1 commit aa7c4de
Show file tree
Hide file tree
Showing 8 changed files with 1,233 additions and 2,053 deletions.
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
EXTEND_ESLINT=true
PORT=8000
9 changes: 0 additions & 9 deletions config-overrides.js

This file was deleted.

80 changes: 35 additions & 45 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,51 +4,59 @@
"private": true,
"author": "Parity Technologies <admin@parity.io>",
"license": "Unlicense",
"homepage": "https://substrate-developer-hub.github.io/substrate-front-end-template",
"bugs": {
"url": "https://github.com/substrate-developer-hub/substrate-front-end-template/issues"
},
"keywords": [
"substrate",
"substrate-ui",
"polkadot-js"
],
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "CI=true react-app-rewired test --env=jsdom",
"eject": "react-app-rewired eject",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "CI=true react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src/**/*.js",
"lint:ci": "eslint src/**/*.js --max-warnings=0",
"lint:fix": "eslint --fix src/**/*.js",
"deploy": "gh-pages -d build -m '[ci skip] Updates'"
},
"dependencies": {
"@polkadot/api": "^6.3.1",
"@polkadot/extension-dapp": "^0.40.3",
"@polkadot/keyring": "^7.4.1",
"@polkadot/networks": "^7.4.1",
"@polkadot/types": "^6.3.1",
"@polkadot/ui-keyring": "^0.85.4",
"@polkadot/ui-settings": "^0.85.4",
"@polkadot/util": "^7.4.1",
"@polkadot/util-crypto": "^7.4.1",
"eslint-config-react-app": "^6.0.0",
"@polkadot/api": "^6.7.2",
"@polkadot/extension-dapp": "^0.41.1",
"@polkadot/keyring": "^7.8.2",
"@polkadot/networks": "^7.8.2",
"@polkadot/types": "^6.7.2",
"@polkadot/ui-keyring": "^0.86.5",
"@polkadot/ui-settings": "^0.86.5",
"@polkadot/util": "^7.8.2",
"@polkadot/util-crypto": "^7.8.2",
"prop-types": "^15.7.2",
"query-string": "^6.13.5",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-copy-to-clipboard": "^5.0.3",
"react-copy-to-clipboard": "^5.0.4",
"react-dom": "^17.0.2",
"react-scripts": "^4.0.3",
"semantic-ui-css": "^2.4.1",
"semantic-ui-react": "^2.0.3"
},
"devDependencies": {
"@babel/core": "^7.14.3",
"babel-preset-env": "^1.7.0",
"eslint": "^7.20.0",
"eslint-config-semistandard": "^15.0.1",
"eslint-config-standard": "^16.0.2",
"eslint-plugin-import": "^2.22.1",
"eslint": "^7.32.0",
"eslint-config-react-app": "^6.0.0",
"eslint-config-semistandard": "^16.0.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-only-warn": "^1.0.2",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-standard": "^5.0.0",
"gh-pages": "^3.1.0",
"react-app-rewired": "^2.1.8",
"eslint-plugin-only-warn": "^1.0.3",
"eslint-plugin-promise": "^5.1.1",
"gh-pages": "^3.2.3",
"semistandard": "^16.0.0"
},
"resolutions": {
"eslint-plugin-jsx-a11y": "6.4.1"
},
"eslintConfig": {
"extends": [
"react-app",
Expand All @@ -73,23 +81,5 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"homepage": "https://substrate-developer-hub.github.io/substrate-front-end-template",
"bugs": {
"url": "https://github.com/substrate-developer-hub/substrate-front-end-template/issues"
},
"keywords": [
"substrate",
"substrate-ui",
"polkadot-js"
],
"jest": {
"modulePathIgnorePatterns": [
"<rootDir>/src/__tests__/mock.js"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/src/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/src/__tests__/mock.js"
}
}
}
1 change: 0 additions & 1 deletion src/__tests__/mock.js

This file was deleted.

3 changes: 1 addition & 2 deletions src/config/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import configCommon from './common.json';
// Using `require` as `import` does not support dynamic loading (yet).
const configEnv = require(`./${process.env.NODE_ENV}.json`);
const types = require('./types.json');

// Accepting React env vars and aggregating them into `config` object.
const envVarNames = [
Expand All @@ -14,5 +13,5 @@ const envVars = envVarNames.reduce((mem, n) => {
return mem;
}, {});

const config = { ...configCommon, ...configEnv, ...envVars, types };
const config = { ...configCommon, ...configEnv, ...envVars };
export default config;
1 change: 0 additions & 1 deletion src/config/types.json

This file was deleted.

10 changes: 4 additions & 6 deletions src/substrate-lib/SubstrateContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ console.log(`Connected socket: ${connectedSocket}`);
const INIT_STATE = {
socket: connectedSocket,
jsonrpc: { ...jsonrpc, ...config.RPC },
types: config.types,
keyring: null,
keyringState: null,
api: null,
Expand Down Expand Up @@ -62,14 +61,14 @@ const reducer = (state, action) => {
// Connecting to the Substrate node

const connect = (state, dispatch) => {
const { apiState, socket, jsonrpc, types } = state;
const { apiState, socket, jsonrpc } = state;
// We only want this function to be performed once
if (apiState) return;

dispatch({ type: 'CONNECT_INIT' });

const provider = new WsProvider(socket);
const _api = new ApiPromise({ provider, types, rpc: jsonrpc });
const _api = new ApiPromise({ provider, rpc: jsonrpc });

// Set listeners for disconnection and reconnection event.
_api.on('connected', () => {
Expand Down Expand Up @@ -117,7 +116,7 @@ const SubstrateContext = React.createContext();
const SubstrateContextProvider = (props) => {
// filtering props and merge with default param value
const initState = { ...INIT_STATE };
const neededPropNames = ['socket', 'types'];
const neededPropNames = ['socket'];
neededPropNames.forEach(key => {
initState[key] = (typeof props[key] === 'undefined' ? initState[key] : props[key]);
});
Expand All @@ -133,8 +132,7 @@ const SubstrateContextProvider = (props) => {

// prop typechecking
SubstrateContextProvider.propTypes = {
socket: PropTypes.string,
types: PropTypes.object
socket: PropTypes.string
};

const useSubstrate = () => ({ ...useContext(SubstrateContext) });
Expand Down
Loading

0 comments on commit aa7c4de

Please sign in to comment.