Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@parity/light.js
Advanced tools
Readme
A high-level reactive JS library optimized for light clients.
yarn add @parity/light.js rxjs # RxJS is a needed peer-dependency
Reactively observe JSONRPC methods:
import light, { defaultAccount$ } from '@parity/light.js';
light.setProvider(/* put your ethereum provider here */);
defaultAccount$().subscribe(publicAddress => console.log(publicAddress));
// Outputs your public address 0x...
// Everytime you change your default account (e.g. via MetaMask), it will output your new public address
All RxJS tools are available for manipulating Observables:
import { balanceOf$, blockNumber$, defaultAccount$ } from '@parity/light.js';
import { filter, map, switchMap } from 'rxjs/operators';
// Only log pair blocks
blockNumber$()
.pipe(filter(n => n % 2 === 0))
.subscribe(console.log);
// Get the balance of the default account
// Will update when balance or default account changes
defaultAccount$()
.pipe(
switchMap(balanceOf$),
map(value => +value) // Return number instead of BigNumber
)
.subscribe(console.log);
// There's actually an alias for the above Observable:
import { myBalance$ } from '@parity/light.js';
myBalance$().subscribe(console.log);
Contract support:
import { defaultAccount$, makeContract } from '@parity/light.js';
import { map, switchMap } from 'rxjs/operators';
defaultAccount$()
.pipe(
switchMap(defaultAccount =>
makeContract(/* contract address */, /* abi */)
.myMethod$(defaultAccount) // Calling method of contract with arguments
) )
.subscribe(console.log); // Will log the result, and everytime the result changes
All available methods are documented in the docs.
We provide another library, @parity/light.js-react
, with a higher-order component to use these Observables easily with React apps.
import light from 'parity/ligth.js-react';
import { syncStatus$ } from '@parity/light.js';
@light({
mySyncVariable: syncStatus$
})
class MyClass extends React.Component {
render() {
return <div>{JSON.stringify(this.props.mySyncVariable)}</div>;
}
}
The UI will automatically update when the syncing state changes.
FAQs
A high-level reactive JS library optimized for light clients
The npm package @parity/light.js receives a total of 14 weekly downloads. As such, @parity/light.js popularity was classified as not popular.
We found that @parity/light.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.