Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
#127 comments and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ShravanSunder committed Jan 17, 2022
1 parent d571b00 commit 8a3a27b
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 59 deletions.
86 changes: 83 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,82 @@
# 🖇 Eth-Hooks Overview
# 🖇 Eth-Hooks

Commonly used Ethereum hooks.
## Overview

Commonly used Ethereum hooks to supercharge your web3 dev!

Used by 🏗 [scaffold-eth](https://github.com/scaffold-eth/scaffold-eth) and 🏭 [scaffold-eth-typescript](https://github.com/scaffold-eth/scaffold-eth-typescript)

Used by ⚙ [eth-components](https://github.com/scaffold-eth/eth-components)

Created by 🏰 [BuidlGuidl.eth](https://BuidlGuidl.com)

## Authors
### Author

[@shravansunder](https://github.com/ShravanSunder)

### Contributors

- [@ss6]()

# Features

> See this [video summary on v4 features](https://www.youtube.com/watch?v=STxAdE8wQwY)!
## EthersAppContext

A context that allows you to access the current ethers.js context and information such as provider, signer, account. This allows your user to easily log into web3 account using web3modal. You can setup up overrides and multiple providers.

## ContractAppContext

Gives you a `contractContextFactory` that allows you to easily setup typed contracts, load typed contracts, create connectors, and access them with hooks anywhere in your app.

## Caching & optional updates

Caches the network RPC calls so that unecessary requests to the network is prevented. You can setup an update interval from every block, every (n) blocks, polling, onMount, onWindow focus and other react-query update options.

## Hooks!

Ethers App Context

- useBlockNumberContext
- useEthersContext

Network

- useBalance
- useBlockNumber
- useContractExistsAtAddress
- useEventListener
- useGasPrice
- useNonce
- useSignerAddress

Contracts

- useContractReader
- contractContextFactory
- useLoadAppContracts
- useConnectAppContracts
- useConnectAppContracts
- legacy (eth-hooks v2+)
- useContractLoader
- useContractReaderUntyped

ERC

- useTokenBalance

Dapps

- useDexEthPrice
- useDexTokenList
- useResolveEnsAddress
- useResolveEnsName

Utility

- useBurnerSigner

# Quickstart

## Install
Expand Down Expand Up @@ -229,3 +294,18 @@ const [purpose, update] = useContractReader(
Check out [the documentation here!](https://scaffold-eth.github.io/eth-hooks/)

The documentation are also available on [scaffold-eth's gitbook](https://docs.scaffoldeth.io/scaffold-eth-libraries/v/eth-hooks-v3/)

# Dependencies

## Main package dependencies

- ethers.js
- @uniswap/token-lists
- @web3-react: core, abstractconnector, types
- web3modal
- react-query

## Peer dependencies

- react, react/dom
- uniswap/sdk
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
"lodash.isequal": "^4.5.0",
"merge-anything": "^4.0.2",
"react-query": "^3.34.7",
"react-use-promise": "^0.4.1",
"ts-invariant": "^0.9.4",
"use-debounce": "^7.0.1",
"usehooks-ts": "^2.2.0",
Expand Down
7 changes: 7 additions & 0 deletions src/context/app-contracts/contractsContextFactory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ import {
} from '~~/models';
import { keyNamespace } from '~~/models/constants';

/**
* i've added comment headers since this is a large file due to the factory function
*/

/**
* Props for the ContractContext generated by the contractContextFactory
*/
export type TContractsContextProps = {
ethersContextKey?: string | undefined;
};
Expand Down
50 changes: 0 additions & 50 deletions src/functions/sortContracts.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions src/models/contractAppContextTypes.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { Provider } from '@ethersproject/providers';
import { BaseContract, Signer } from 'ethers';

Expand Down Expand Up @@ -28,10 +27,6 @@ export type TConnectorList<GContractNames extends string, GContracts extends TBa
[contractName in GContractNames]: TContractConnector<GContractNames, GContracts>;
};

// export type TConnectorList<GContactNames extends string, GContracts extends TBaseContractExtended> = {
// [contractName in GContactNames]: TContractConnector<GContactNames, GContracts>;
// };

export type TTypedContract<
GContractNames extends string,
GAppContractConnectorList
Expand Down

0 comments on commit 8a3a27b

Please sign in to comment.