npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reflux-tx

v0.2.4

Published

Reflux store and component wrapper to store and retrieve ethereum transactions and related info

Downloads

37

Readme

reflux-tx

Reflux store & higher order component for monitoring Ethereum transactions in real-time.

Features

  • Serverless (excluding eth client)
  • Persistent - uses localstorage, retains state over page refreshes
  • Associate arbitrary data with any transaction
  • Detect chain reorgs and failed transactions
  • States filterable by extra properties you can associate w txs
  • Multiple chain support

TX States

states

Installation

npm install reflux-tx

or for the browserified version which exposes global refluxTX:

<script type='text/javascript' src='./dist/refluxTX.min.js'></script>

If using with webpack, you'll need these config additions to support localforage:

	module: {
		noParse: [ /localforage\/dist\/localforage.js/ ],
		loaders: [ {test: /localforage\/dist\/localforage.js/, loader: 'exports?localforage'} ]
	},
	resolve: {
		alias: { 'localforage': 'localforage/dist/localforage.js' }
	}
	

Usage

initialization

Before connecting to the store, you must first initialize it in a toplevel component with TXActions.connect(). This loads the genesis identifier required for storing any transaction data.

Available options

versions >= 0.2.0

Note: for version 0.2.0 and above, web3 is a required parameter for TXStore.connect so the provider option is removed

Field Name | Description | Default ------------- | ------------- | ------------ confirmCount | Number of blocks before a tx is sufficiently confirmed | 12 bufferSize | Max number of resolved transactions (failed + confirmed) to keep in localstorage per-account | 100

Example:

TXActions.connect(web3, {confirmCount: 10, bufferSize: 5})

versions < 0.2.0

Field Name | Description | Default ------------- | ------------- | ------------ provider | web3 http provider | assumes already set confirmCount | Number of blocks before a tx is sufficiently confirmed | 12 bufferSize | Max number of resolved transactions (failed + confirmed) to keep in localstorage per-account | 100

Example:

TXActions.connect({provider: 'http://localhost:8545', confirmCount: 10, bufferSize: 5})

create a transaction

Add transaction to TXStore with TXActions.add(txInfo) where txInfo is an object or array of objects containing at least a {hash: '0x..'} property referencing a transaction hash. Any additional properties will be saved and can be used to filter out transactions by arbitrary data.

Example:

TXActions.add({
	hash: '0x30f42ba1f7d816d850fd172e128ffbacee7564e0cb41cc27c1e9af743aace6bc',
	txType: 'deposit',
	parentAddress: '0x26ac60acb581516b175010730a2bcee041bb0099'
});

view transactions

React components can use the TXComponent wrapper to inherit the latest blockNumber, timestamp (block.timesamp), and blockHash along with array representations of each transaction state as its properties.

Transaction state objects have 3 possible fields

Field Name | Value | In tx states ------------- | ------------- | ------------ info | txInfo added via TXActions.add() | * data | object returned from web3.eth.getTransaction | * receipt | object returned from web3.eth.getTransactionReceipt | pending, received, confirmed

Example:

	render() {
		<TXComponent filter={{txType: 'deposit'}} >
			<MyComponent />
		</TXComponent>
	}

Would be represented in MyComponent as

console.log(this.props.received)
[{info: {...}, receipt: {...}, data: {...}}, ...]

console.log(this.props.confirmed)
[{info: {...}, receipt: {...}, data: {...}}, ...]

console.log(this.props.pending)
[{info: {...}, data: {...}}, ...]

console.log(this.props.dropped)
[{info: {...}, data: {...}}, ...]

console.log(this.props.failed)
[{info: {...}, data: {...}}, ...]

console.log(this.props.blockNumber)
30000

Example

For another example check out reflux-tx-example

Notes

reflux-tx will only subscribe to new block info when it's needed for tx confirmations. For that reason, a component's block properties (blockNumber, timestamp, blockHash) will update only while you have pending or received transactions matching the wrapping TXComponent's filter and keys.