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

@ensuro/ethereum-store

v0.2.10

Published

Ethereum Store for React Redux

Downloads

84

Readme

Ethereum-store

Ethereum store for react redux

How to use

Install

npm install --save @ensuro/ethereum-store

Configure

Add the reducer

In the reducers.js file:

import EthereumReducer from "@ensuro/ethereum-store/src/store/ethereum/reducer";

export default combineReducers({
  // ...
  EthereumReducer,
});

Add the saga

In the sagas.js file:

import { ethereumSaga, initializeEthereumStore } from "@ensuro/ethereum-store/src/package-index";

const clockCount = 15;
initializeEthereumStore({
  getEncodedCall,
  getContract,
  getAbiName,
  getABI,
  getFormatter,
  getSignerContract,
  getTxReceiptStatus,
  selectUserAddress,
  selectChainId,
  selectProvider,
  chain,
  clockCount, // clockCount is the amount of times an ETH_CALL will be skipped - default is 10
});

export default function* rootSaga() {
  yield all([
    // ...
    fork(ethereumSaga),
  ]);
}

Add the dispatch clock

In the App.js add this useEffect to dispatch the clock every Xms. This clock will dispatch an action in the saga every Xms and that action will call the blockchain.

useEffect(() => {
  const interval = setInterval(() => {
    dispatch({ type: "ETH_DISPATCH_CLOCK" });
  }, 500);
  return () => clearInterval(interval);
}, [dispatch]);

Actions

/** Ethereum Calls */
/**
 * {type: ETH_CALL, address: eToken.address, abi: "EToken", method: "totalSupply", args: []}
 * {type: ETH_CALL, address: usdc.address, abi: "ERC20Permit", method: "balanceOf", args: [user.address]}
 */
export const ETH_CALL = "ETH_CALL";

/**
 * {type: ETH_CALL_SUCCESS, call_key: "0x...", method: "totalSupply", args: []}
 */
export const ETH_CALL_SUCCESS = "ETH_CALL_SUCCESS";

/**
 * {type: ETH_CALL_FAIL, call_key: "0x...", payload: "error message" }
 */
export const ETH_CALL_FAIL = "ETH_CALL_FAIL";

/**
 * {type: ETH_ADD_SUBSCRIPTION, key: "positions", componentEthCalls: [{address: "0x...", abi: "AavePool", method: "getUserAccountData", args: [user.address]}]}
 */
export const ETH_ADD_SUBSCRIPTION = "ETH_ADD_SUBSCRIPTION";

/**
 * {type: ETH_REMOVE_SUBSCRIPTION, key: "positions" }
 */
export const ETH_REMOVE_SUBSCRIPTION = "ETH_REMOVE_SUBSCRIPTION";

/**
 * ETH_SUBSCRIPTION_INCREASE_CLOCK -> This action sets when to call each subscription again
 */
export const ETH_SUBSCRIPTION_INCREASE_CLOCK = "ETH_SUBSCRIPTION_INCREASE_CLOCK";

/**
 * ETH_INCREASE_CLOCK -> Increase the general clock to check if the saga should call the blockchain again
 */
export const ETH_INCREASE_CLOCK = "ETH_INCREASE_CLOCK";

/**
 * ETH_DISPATCH_CLOCK -> This clock will dispatch an action in the saga every Xms and that action will call the blockchain.
 */
export const ETH_DISPATCH_CLOCK = "ETH_DISPATCH_CLOCK";

/** Ethereum Transactions */
/**
 * {type: ETH_TRANSACT, address: "0x...", method: "approve", abi: "ERC20Permit" args: []}
 */
export const ETH_TRANSACT = "ETH_TRANSACT";

/**
 * {type: ETH_TRANSACT_QUEUED, id: 0, txHash: "0x..." }
 */
export const ETH_TRANSACT_QUEUED = "ETH_TRANSACT_QUEUED";

/**
 * {type: ETH_TRANSACT_REJECTED, id: 0, error: error.message }
 */
export const ETH_TRANSACT_REJECTED = "ETH_TRANSACT_REJECTED";

/**
 * {type: ETH_TRANSACT_MINED, id:  0}
 */
export const ETH_TRANSACT_MINED = "ETH_TRANSACT_MINED";

/**
 * {type: ETH_TRANSACT_REVERTED, id: 0 }
 */
export const ETH_TRANSACT_REVERTED = "ETH_TRANSACT_REVERTED";

/**
 * {type: ETH_TRANSACT_EXPIRED, id: 0 }
 */
export const ETH_TRANSACT_EXPIRED = "ETH_TRANSACT_EXPIRED";

/**
 * ETH Sign
 * ERC-2612: Permit Extension for EIP-20 Signed Approvals
 * https://eips.ethereum.org/EIPS/eip-2612
 */

/**
 * {type: ETH_EIP_712_SIGN, key: encode(domain, types, value),  state: "PENDING" }
 */
export const ETH_EIP_712_SIGN = "ETH_EIP_712_SIGN";

/**
 * {type: ETH_EIP_712_SIGN_PROCESSED, key: encode(domain, types, value), signature: "0x1234...", userAddress: "0x...", spender: pool.address, amount: amount, deadline: 1234, nonce: 1}
 */
export const ETH_EIP_712_SIGN_PROCESSED = "ETH_EIP_712_SIGN_PROCESSED";

/**
 * {type: ETH_EIP_712_SIGN_FAILED, key: encode(domain, types, value), payload: error.message  }
 */
export const ETH_EIP_712_SIGN_FAILED = "ETH_EIP_712_SIGN_FAILED";

/**
 * {type: ETH_PLAIN_SIGN, key: "key", message: "Welcome! By signing, you agree to the Terms of Service.", userAddress: "0x.."}
 */
export const ETH_PLAIN_SIGN = "ETH_PLAIN_SIGN";

/**
 * {type: ETH_PLAIN_SIGN_PROCESSED, key: "key", userAddress: "0x..", signature: "0x1234...", message: "message to sign"}
 */
export const ETH_PLAIN_SIGN_PROCESSED = "ETH_PLAIN_SIGN_PROCESSED";

/**
 * {type: ETH_PLAIN_SIGN_FAILED, key: "key", payload: error.message  }
 */
export const ETH_PLAIN_SIGN_FAILED = "ETH_PLAIN_SIGN_FAILED";

/**
 * {type: SET_USER_CURRENT_CHAIN, name: "Sepolia", id: 11155111, rpc: rpcUrl  }
 */
export const SET_USER_CURRENT_CHAIN = "SET_USER_CURRENT_CHAIN";