Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@substrate/context

Package Overview
Dependencies
Maintainers
3
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@substrate/context - npm Package Compare versions

Comparing version 0.3.20 to 0.3.21

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [0.3.21](https://github.com/paritytech/Nomidot/compare/v0.3.20...v0.3.21) (2020-02-21)
### Bug Fixes
* **context:** Create a new {Api,System}Context on new provider ([#196](https://github.com/paritytech/Nomidot/issues/196)) ([2270a25](https://github.com/paritytech/Nomidot/commit/2270a25600ee2d6bb4a301e08b45a21db543e44d))
## [0.3.20](https://github.com/paritytech/Nomidot/compare/v0.3.19...v0.3.20) (2020-02-11)

@@ -8,0 +19,0 @@

7

lib/ApiContext.d.ts
import { ApiRx } from '@polkadot/api';
import { ProviderInterface } from '@polkadot/rpc-provider/types';
import React from 'react';
interface State {
export interface ApiContextType {
api: ApiRx;
isApiReady: boolean;
}
export interface ApiContextType extends State {
api: ApiRx;
}
export declare const ApiContext: React.Context<ApiContextType>;

@@ -16,2 +14,1 @@ export interface ApiContextProviderProps {

export declare function ApiContextProvider(props: ApiContextProviderProps): React.ReactElement;
export {};

@@ -36,6 +36,4 @@ "use strict";

var _a = props.children, children = _a === void 0 ? null : _a, provider = props.provider;
var _b = __read(react_1.useState({ isApiReady: false }), 2), state = _b[0], setState = _b[1];
var isApiReady = state.isApiReady;
var apiRef = react_1.useRef(new api_1.ApiRx({ provider: provider }));
var api = apiRef.current;
var _b = __read(react_1.useState(new api_1.ApiRx({ provider: provider })), 2), api = _b[0], setApi = _b[1];
var _c = __read(react_1.useState(false), 2), isReady = _c[0], setIsReady = _c[1];
react_1.useEffect(function () {

@@ -45,9 +43,17 @@ // We want to fetch all the information again each time we reconnect. We

// settings.
api.isReady.subscribe(function () {
setApi(new api_1.ApiRx({ provider: provider }));
setIsReady(false);
}, [provider]);
react_1.useEffect(function () {
// We want to fetch all the information again each time we reconnect. We
// might be connecting to a different node, or the node might have changed
// settings.
var subscription = api.isReady.subscribe(function () {
l.log("Api ready, app is ready to use");
setState({ isApiReady: true });
setIsReady(true);
});
}, [api, provider]);
return (react_1.default.createElement(exports.ApiContext.Provider, { value: { api: api, isApiReady: isApiReady } }, children));
return function () { return subscription.unsubscribe(); };
}, [api]);
return (react_1.default.createElement(exports.ApiContext.Provider, { value: { api: api, isApiReady: isReady } }, children));
}
exports.ApiContextProvider = ApiContextProvider;

@@ -58,5 +58,8 @@ "use strict";

var registryRef = react_1.useRef(new types_1.TypeRegistry());
var rpcRef = react_1.useRef(new rpc_core_1.default(registryRef.current, provider));
var rpc = rpcRef.current;
var _j = __read(react_1.useState(new rpc_core_1.default(registryRef.current, provider)), 2), rpc = _j[0], setRpc = _j[1];
react_1.useEffect(function () {
// Create a new RPC client each time we change provider
setRpc(new rpc_core_1.default(registryRef.current, provider));
}, [provider]);
react_1.useEffect(function () {
// We want to fetch all the information again each time we reconnect. We

@@ -63,0 +66,0 @@ // might be connecting to a different node, or the node might have changed

{
"name": "@substrate/context",
"version": "0.3.20",
"version": "0.3.21",
"author": "Parity Technologies <admin@parity.io>",

@@ -27,3 +27,3 @@ "description": "Wrapper to connect React components to PolkadotJS Api",

},
"gitHead": "db36bd078daa82f4edd8ece51e93d585f5dbc6ad"
"gitHead": "f44183f05ca8680e1568d51d820202408ce6022b"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc