diff --git a/.changeset/quiet-laws-run.md b/.changeset/quiet-laws-run.md
new file mode 100644
index 000000000..0589ab506
--- /dev/null
+++ b/.changeset/quiet-laws-run.md
@@ -0,0 +1,5 @@
+---
+'@usedapp/core': patch
+---
+
+Fix metamask auto-connect behaviour
diff --git a/.changeset/three-rivers-hunt.md b/.changeset/three-rivers-hunt.md
deleted file mode 100644
index e4da656ea..000000000
--- a/.changeset/three-rivers-hunt.md
+++ /dev/null
@@ -1,5 +0,0 @@
----
-"@usedapp/core": patch
----
-
-Add multicall2 function
diff --git a/.eslintrc.json b/.eslintrc.json
index 0845ab775..00ab5cae6 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -14,11 +14,13 @@
"project": "./tsconfig.json",
"sourceType": "module"
},
+ "ignorePatterns": [".eslintrc.js"],
"rules": {
"@typescript-eslint/explicit-module-boundary-types": "off",
"@typescript-eslint/no-explicit-any": "off",
"no-redeclare": "off",
"no-unused-vars": "off",
+ "@typescript-eslint/no-unused-vars": ["error"],
"prefer-const": ["error", {"destructuring": "all"}],
"semi": ["error", "never"],
"no-extra-semi": "off",
diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml
index c06ebd2f6..26f77860d 100644
--- a/.github/workflows/CI.yml
+++ b/.github/workflows/CI.yml
@@ -8,7 +8,7 @@ jobs:
test:
strategy:
matrix:
- node: ['10.x', '12.x']
+ node: ['14.x', '16.x']
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
@@ -17,8 +17,8 @@ jobs:
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- - run: yarn install --frozen-lockfile
+ - run: npm i -g pnpm@6.20.3
+ - run: pnpm install --frozen-lockfile
- run: yarn lint
- run: yarn build
- run: yarn test
-
diff --git a/.github/workflows/PR.yml b/.github/workflows/PR.yml
new file mode 100644
index 000000000..3d1950674
--- /dev/null
+++ b/.github/workflows/PR.yml
@@ -0,0 +1,22 @@
+name: PR Naming
+on:
+ pull_request:
+ types: [opened, edited, synchronize, reopened]
+jobs:
+ emoji:
+ name: Pull Request should start from emoji
+ runs-on: ubuntu-latest
+ steps:
+ - uses: deepakputhraya/action-pr-title@v1.0.2
+ with:
+ # Check if first character is an emoji, regex borrowed from https://medium.com/reactnative/emojis-in-javascript-f693d0eb79fb#.enomgcu63
+ regex: '^(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\u0023-\u0039]\ufe0f?\u20e3|\u3299|\u3297|\u303d|\u3030|\u24c2|\ud83c[\udd70-\udd71]|\ud83c[\udd7e-\udd7f]|\ud83c\udd8e|\ud83c[\udd91-\udd9a]|\ud83c[\udde6-\uddff]|[\ud83c[\ude01-\ude02]|\ud83c\ude1a|\ud83c\ude2f|[\ud83c[\ude32-\ude3a]|[\ud83c[\ude50-\ude51]|\u203c|\u2049|[\u25aa-\u25ab]|\u25b6|\u25c0|[\u25fb-\u25fe]|\u00a9|\u00ae|\u2122|\u2139|\ud83c\udc04|[\u2600-\u26FF]|\u2b05|\u2b06|\u2b07|\u2b1b|\u2b1c|\u2b50|\u2b55|\u231a|\u231b|\u2328|\u23cf|[\u23e9-\u23f3]|[\u23f8-\u23fa]|\ud83c\udccf|\u2934|\u2935|[\u2190-\u21ff])'
+ github_token: ${{ github.token }}
+ capitalised:
+ name: Pull Request name should start from Capital letter with space
+ runs-on: ubuntu-latest
+ steps:
+ - uses: deepakputhraya/action-pr-title@v1.0.2
+ with:
+ regex: '^[^a-z]* [A-Z]'
+ github_token: ${{ github.token }}
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 000000000..13b039074
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,54 @@
+name: Deploy
+on:
+ pull_request:
+ push:
+ branches:
+ - master
+jobs:
+ deploy-apps:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v2
+ - name: Use Node.js
+ uses: actions/setup-node@v1
+ with:
+ node-version: '16.14'
+ - run: npm i -g pnpm@6.20.3
+ - run: pnpm install --frozen-lockfile
+ - run: pnpm build
+ - name: Deploy usedapp-docs.netlify.app
+ uses: nwtgck/actions-netlify@v1.2
+ with:
+ enable-commit-comment: true
+ enable-pull-request-comment: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ overwrites-pull-request-comment: true
+ production-deploy: ${{ github.event_name != 'pull_request' }}
+ publish-dir: packages/docs/build
+ env:
+ NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
+ NETLIFY_SITE_ID: ${{ secrets.NETLIFY_DOCS_SITE_ID }}
+ - name: Deploy example.usedapp.io
+ uses: nwtgck/actions-netlify@v1.2
+ with:
+ enable-commit-comment: true
+ enable-pull-request-comment: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ overwrites-pull-request-comment: true
+ production-deploy: ${{ github.event_name != 'pull_request' }}
+ publish-dir: packages/example/build
+ env:
+ NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
+ NETLIFY_SITE_ID: ${{ secrets.NETLIFY_EXAMPLE_SITE_ID }}
+ - name: Deploy usedapp.io
+ uses: nwtgck/actions-netlify@v1.2
+ with:
+ enable-commit-comment: true
+ enable-pull-request-comment: true
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ overwrites-pull-request-comment: true
+ production-deploy: ${{ github.event_name != 'pull_request' }}
+ publish-dir: packages/website/dist
+ env:
+ NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
+ NETLIFY_SITE_ID: ${{ secrets.NETLIFY_LANDING_SITE_ID }}
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 9de78e220..05aabfc05 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -15,21 +15,36 @@ jobs:
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
+ # This allows the changesets/action step to override the default actions user,
+ # and allow CI jobs on commits coming from that step.
+ persist-credentials: false
- - name: Setup Node.js 12.x
+ - name: Setup Node.js 16.x
uses: actions/setup-node@master
with:
- node-version: 12.x
+ node-version: 16.x
+
+ - name: Install package manager
+ run: npm i -g pnpm@6.20.3
- name: Install Dependencies
- run: yarn install --frozen-lockfile
+ run: pnpm install --frozen-lockfile
+
+ - name: Set git user
+ run: |
+ git config user.name truefi-bot
+ git config user.email truefi-bot@trusttoken.com
- name: Create Release Pull Request or Publish to npm
id: changesets
- uses: changesets/action@master
+ uses: changesets/action@v1
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
- publish: yarn release
+ publish: pnpm run release
+ version: pnpm run version
+ commit: "🎉 Release new version"
+ title: "🎉 Release new version"
+ setupGitUser: false
env:
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GITHUB_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 719182753..09b71e2b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
node_modules
-dist
.DS_Store
.idea
+.swc
+packages/example/gen/types
+dist
diff --git a/.node-version b/.node-version
new file mode 100644
index 000000000..832d38506
--- /dev/null
+++ b/.node-version
@@ -0,0 +1 @@
+16.14.0
diff --git a/docs/Makefile b/docs/Makefile
deleted file mode 100644
index 38c282c2b..000000000
--- a/docs/Makefile
+++ /dev/null
@@ -1,26 +0,0 @@
-# Minimal makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line, and also
-# from the environment for the first two.
-SPHINXOPTS ?=
-SPHINXBUILD ?= sphinx-build
-SOURCEDIR = source
-BUILDDIR = dist
-
-
-# Put it first so that "make" without argument is like "make help".
-help:
- @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
-
-.PHONY: help Makefile
-
-# Runs "make html" in a loop every 3 seconds.
-# Useful for writing documentation.
-watch:
- while true; do make html -s; sleep 3; done
-
-# Catch-all target: route all unknown targets to Sphinx using the new
-# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
-%: Makefile
- @PYGMENTS_NODE_COMMAND=node $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
\ No newline at end of file
diff --git a/docs/internal/architecture.drawio.svg b/docs/internal/architecture.drawio.svg
new file mode 100644
index 000000000..14d98f249
--- /dev/null
+++ b/docs/internal/architecture.drawio.svg
@@ -0,0 +1,731 @@
+
\ No newline at end of file
diff --git a/docs/internal/styleguide.md b/docs/internal/styleguide.md
new file mode 100644
index 000000000..b92561546
--- /dev/null
+++ b/docs/internal/styleguide.md
@@ -0,0 +1,77 @@
+# Code style guide
+
+## Public APIs
+
+- All public symbols (functions, types, constants) should be annotated with `@public`.
+- Any types used in the **signature** of the exported symbol should also be exported.
+
+Example:
+
+```typescript
+/**
+ * @public
+ */
+export interface FooResult {
+ foo: string;
+}
+
+/**
+ * @public
+ */
+export function foo(): FooResult {}
+```
+
+- The main entry point of the module should explicitly list exported symbols:
+
+```typescript
+// Do
+export { foo, bar } from './foo';
+
+// Don't
+export * from './bar';
+```
+
+### Deprecating symbols
+
+- Add `@deprecated` to the symbol JSDoc.
+- Print warning to the console when the deprecated symbol is used.
+- Add migration guide to the docs.
+
+### Writing JSDocs
+
+All public symbols must have JSDoc documentation.
+It should be written in full sentences with proper punctuation.
+Prefer to add newlines after sentences so that lines don't get too long.
+
+- Use `@public` to mark public APIs.
+- Use `@deprecated` to mark deprecated APIs.
+- Use `@param name` to mark parameters.
+- Don't specify parameter types in JSDoc as it is already specified in the function signature.
+- Use `@returns` to provide documentation about return value.
+- Use `{@link Foo}` to link to other symbols.
+
+Example:
+
+```typescript
+/**
+ * Makes a call to a specific method of a specific contract and returns the value or an error if present.
+ * The hook will cause the component to refresh when a new block is mined and the return value changes.
+ * A syntax sugar for useRawCall that uses ABI, function name, and arguments instead of raw data.
+ * If typechain contract is used in call parameter then method name and arguments will be type checked.
+ * Result will be typed as well.
+ *
+ * @public
+ * @param call a single call to a contract , also see {@link Call}
+ * @returns The hook returns {@link CallResult} type.
+ * That is: undefined when call didn't return yet or a object { value | error } if it did,
+ * value: any[] | undefined - array of results or undefined if error occurred,
+ * error: Error | undefined - encountered error or undefined if call was successful.
+ *
+ */
+export function useCall>(
+ call: Call | Falsy
+): CallResult {
+ return useCalls([call])[0]
+}
+
+```
\ No newline at end of file
diff --git a/docs/requirements.txt b/docs/requirements.txt
deleted file mode 100644
index 92bbbb983..000000000
--- a/docs/requirements.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-Sphinx==3.5.1
-pygments-lexer-solidity==0.5.1
-sphinx-rtd-theme==0.4.3
-sphinx-tabs==2.0.1
-jsx-lexer==0.0.8
\ No newline at end of file
diff --git a/docs/source/_static/custom.css b/docs/source/_static/custom.css
deleted file mode 100644
index 7788dc645..000000000
--- a/docs/source/_static/custom.css
+++ /dev/null
@@ -1,290 +0,0 @@
-html {
- background-color: white;
- }
-
-body,
-body * {
- font-family: "Helvetica Neue", sans-serif;
-}
-
-h1, h2, h3, h4, h5, h6 {
- font-family: "Helvetica Neue", sans-serif;
- line-height: 150%;
-}
-
-h1 {
- font-size: 36px;
- padding-left: -10px;
-}
-
-h2 {
- font-size: 30px;
- padding-top: 30px;
- padding-left: -10px;
-}
-
-h3 {
- font-size: 20px;
- padding-top: 5px;
- margin-left: -10px;
- margin-top: 40px;
- border-top: 2px solid rgba(181,181,181,0.43);
-}
-
-section {
- padding-left: 10px;
-}
-
-.caption-text {
- font-size: 20px;
- line-height: 32px;
-}
-
- /* Center the page on wide displays for better readability */
- @media only screen and (min-width: 769px) {
- .wy-body-for-nav {
- max-width: 100%;
- margin: 0 auto;
- background-color: white;
- }
-
- .wy-nav-side {
- left: inherit;
- }
-
- .rst-versions {
- left: inherit;
- }
- }
-
- .wy-nav-content-wrap {
- background: transparent !important;
- }
-
- .wy-side-nav-search {
- background-color: transparent;
- background-image: linear-gradient(180deg, #FFF4D4, #FFFFFF);
- }
-
- .wy-side-nav-search input[type=text] {
- border-color: white;
- }
-
- .wy-nav-top {
- background: white;
- }
-
- .wy-nav-content {
- background-color: white;
- margin: 0 auto;
- }
-
- .wy-menu-vertical header, .wy-menu-vertical p.caption {
- color: white;
- }
-
- .wy-menu-vertical a:active {
- background-color: white;
- }
-
- /* NO VERSION */
-
- .wy-side-nav-search > div.version {
- display: none;
- }
-
- /* RESET PYGMENTS CSS */
-
- .highlight .c,
- .highlight .ch,
- .highlight .cm,
- .highlight .cpf,
- .highlight .c1,
- .highlight .cs,
- .highlight .sd,
- .highlight .k,
- .highlight .gh,
- .highlight .gp,
- .highlight .gu,
- .highlight .kc,
- .highlight .kd,
- .highlight .kn,
- .highlight .kr,
- .highlight .nc,
- .highlight .ni,
- .highlight .ne,
- .highlight .nn,
- .highlight .nt,
- .highlight .ow,
- .highlight .se,
- .highlight .si {
- font-style: normal;
- font-weight: normal;
- }
-
- /* CUSTOM SYNTAX HIGHLIGHTING */
-
- .rst-content div[class^='highlight'] {
- border: none;
- border-radius: 4px;
- }
-
- .highlight {
- background: #272822;
- color: #E8E8E3;
- }
-
- .highlight .hll {
- background-color: #211F1C;
- }
-
- /* comment */ .highlight .c,
- /* comment.multiline */ .highlight .cm,
- /* comment.preproc */ .highlight .cp,
- /* comment.single */ .highlight .c1,
- /* comment.special */ .highlight .cs {
- color: #75715E;
- font-style: italic;
- }
-
- /* punctuation */ .highlight .p {
- color: #d8d8d3;
- }
-
- /* error */ .highlight .err {
- border: 1px solid #e73c50;
- }
-
- /* generic.error */ .highlight .gr,
- /* literal.string.other */ .highlight .sx,
- /* literal.string.regex */ .highlight .sr,
- /* literal.string.symbol */ .highlight .ss {
- color: #e73c50;
- }
-
- /* name.constant */ .highlight .no,
- /* literal.number */ .highlight .m,
- /* literal.number.float */ .highlight .mf,
- /* literal.number.hex */ .highlight .mh,
- /* literal.number.integer */ .highlight .mi,
- /* literal.number.oct */ .highlight .mo,
- /* literal.number.integer.long */ .highlight .il,
- /* keyword.constant */ .highlight .kc {
- color: #ae81ff;
- }
-
- /* literal.string */ .highlight .s,
- /* literal.string.backtick */ .highlight .sb,
- /* literal.string.char */ .highlight .sc,
- /* literal.string.double */ .highlight .s2,
- /* literal.string.heredoc */ .highlight .sh,
- /* literal.string.single */ .highlight .s1,
- /* literal.string.doc */ .highlight .sd,
- /* literal.string.escape */ .highlight .se {
- color: #E6DB74;
- }
-
- /* keyword.type */ .highlight .kt,
- /* name.class */ .highlight .nc,
- /* name.variable.class */ .highlight .vc,
- /* literal.string.interpol */ .highlight .si,
- /* name.exception */ .highlight .ne,
- /* name.attribute */ .highlight .na,
- /* name.builtin */ .highlight .nb,
- /* name.entity */ .highlight .ni,
- /* name.label */ .highlight .nl,
- /* name.namespace */ .highlight .nn,
- /* name.variable */ .highlight .nv {
- color: #66d9ef;
- }
-
- /* name.function */ .highlight .nf,
- /* name.decorator */ .highlight .nd {
- color: #A6E22D;
- }
-
-
- /* keyword */ .highlight .k,
- /* keyword.declaration */ .highlight .kd,
- /* keyword.namespace */ .highlight .kn,
- /* keyword.pseudo */ .highlight .kp,
- /* keyword.reserved */ .highlight .kr,
- /* name.tag */ .highlight .nt {
- color: #F92772;
- font-weight: bold;
- }
-
- /* operator */ .highlight .o,
- /* operator.word */ .highlight .ow {
- color: #F92772;
- }
-
- /* generic.emph */ .highlight .ge { font-style: italic }
- /* generic.strong */ .highlight .gs { font-weight: bold }
-
- /* generic.deleted */ .highlight .gd,
- /* generic.heading */ .highlight .gh,
- /* generic.inserted */ .highlight .gi,
- /* generic.output */ .highlight .go,
- /* generic.prompt */ .highlight .gp,
- /* generic.subheading */ .highlight .gu,
- /* generic.traceback */ .highlight .gt,
- /* text.whitespace */ .highlight .w,
- /* name.builtin.pseudo */ .highlight .bp,
- /* name.variable.global */ .highlight .vg,
- /* name.variable.instance */ .highlight .vi {
- color: #E8E8E3;
- }
-
- /* SPHINX-TABS */
-
- .sphinx-tabs .sphinx-tab.tab.segment {
- padding: 0;
- margin: 0;
- border: none;
- }
-
- .sphinx-tabs .sphinx-menu.menu {
- border: none;
- display: flex;
- min-height: unset;
- }
-
- .sphinx-tabs .sphinx-menu.menu .item {
- border: none;
- padding: 8px 24px;
- background-color: #44463a;
- color: #e8e8e4 !important;
- border-radius: 0 !important;
- }
-
- .sphinx-tabs .sphinx-menu.menu .item.active,
- .sphinx-tabs .sphinx-menu.menu .item:hover {
- background-color: #272823;
- border-radius: 0 !important;
- margin: 0;
- }
-
- .sphinx-tabs .sphinx-menu.menu .item:first-child,
- .sphinx-tabs .sphinx-menu.menu .item.active:first-child,
- .sphinx-tabs .sphinx-menu.menu .item:hover:first-child {
- border-top-left-radius: 4px !important;
- border-right: 1px solid;
- border-color: black !important;
- }
-
- .sphinx-tabs .sphinx-menu.menu .item:last-child,
- .sphinx-tabs .sphinx-menu.menu .item.active:last-child,
- .sphinx-tabs .sphinx-menu.menu .item:hover:last-child {
- border-top-right-radius: 4px !important;
- border-right: 2px none;
- }
-
- .sphinx-tabs .sphinx-menu.menu::after {
- display: none;
- }
-
- .rst-content .sphinx-tabs .sphinx-tab.tab.segment div[class^='highlight'] {
- margin-top: 0;
- border-top-left-radius: 0;
- }
\ No newline at end of file
diff --git a/docs/source/_static/logo-square.png b/docs/source/_static/logo-square.png
deleted file mode 100644
index 5240b2d2a..000000000
Binary files a/docs/source/_static/logo-square.png and /dev/null differ
diff --git a/docs/source/conf.py b/docs/source/conf.py
deleted file mode 100644
index 14ddf6f8d..000000000
--- a/docs/source/conf.py
+++ /dev/null
@@ -1,60 +0,0 @@
-# Configuration file for the Sphinx documentation builder.
-#
-# This file only contains a selection of the most common options. For a full
-# list see the documentation:
-# https://www.sphinx-doc.org/en/master/usage/configuration.html
-
-# -- Path setup --------------------------------------------------------------
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#
-# import os
-# import sys
-# sys.path.insert(0, os.path.abspath('.'))
-
-
-# -- Project information -----------------------------------------------------
-
-project = 'usedapp'
-copyright = '2021 Ethworks sp z o.o.'
-author = 'Ethworks team'
-
-
-# -- General configuration ---------------------------------------------------
-
-# Add any Sphinx extension module names here, as strings. They can be
-# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
-# ones.
-extensions = [
- 'sphinx_tabs.tabs',
- 'sphinx.ext.autosectionlabel'
-]
-
-# Add any paths that contain templates here, relative to this directory.
-templates_path = ['_templates']
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-# This pattern also affects html_static_path and html_extra_path.
-exclude_patterns = []
-
-
-# -- Options for HTML output -------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages. See the documentation for
-# a list of builtin themes.
-#
-html_theme = 'sphinx_rtd_theme'
-html_static_path = ['_static']
-html_css_files = ['custom.css']
-html_favicon = '_static/favicon.ico'
-html_logo = '_static/logo-square.png'
-html_theme_options = {
- 'logo_only': True,
-}
-
-# Allows for cross-refs without refs ambiguity, e.g. :ref:`core/hooks`
-# https://www.sphinx-doc.org/en/master/usage/extensions/autosectionlabel.html#configuration
-autosectionlabel_prefix_document = True
\ No newline at end of file
diff --git a/docs/source/core.rst b/docs/source/core.rst
deleted file mode 100644
index 28d5409fa..000000000
--- a/docs/source/core.rst
+++ /dev/null
@@ -1,1038 +0,0 @@
-Core API
-########
-
-Providers
-*********
-
-
-==============
-
-Provides basic services for a DApp. It combines the following components: ````, ````, ````, ```` and ````
-
-
-*Properties:*
-
-- ``config: Partial``: configuration of the DApp, see `Config`_
-
-*Example:*
-
-.. code-block:: jsx
-
- import { Mainnet, DAppProvider } from '@usedapp/core'
-
- const config = {
- readOnlyChainId: Mainnet.chainId,
- readOnlyUrls: {
- [Mainnet.chainId]: `https://mainnet.infura.io/v3/${INFURA_ID}`,
- },
- }
-
- return (
-
-
-
- )
-
-
-
-
-================
-
-Stores configurations and makes them available via `useConfig`_ hook.
-
-
-
-================
-
-*Requires:* ``ConfigProvider``
-
-
-
-=====================
-
-
-
-=====================
-
-Ensures that a multicall contract address is available when developing on a local chain.
-A multicall contract will be deployed when a multicall address on a local chainID is not defined in the `Config`_.
-
-While the contract is being deployed, a temporary "Deploying multicall..." message will be rendered instead
-of the user's child components.
-
-
-
-====================
-
-
-
-===========================
-
-
-Hooks
-*****
-
-useBlock
-========
-
-useBlockMeta
-============
-
-useBlockNumber
-===============
-
-Get the current block number. Will update automatically when the new block is mined.
-
-useChainCall
-============
-
-Makes a call to a specific contract and returns the value. The hook will cause the component to refresh whenever a new block is mined and the value is changed.
-
-Calls will be combined into a single multicall across all uses of *useChainCall* and *useChainCalls*.
-
-It is recommended to use `useContractCall`_ where applicable instead of this method.
-
-*Parameters*
-
-- ``call: ChainCall | Falsy`` - a single call, also see `ChainCall`_. A call can be `Falsy`, as it is important to keep the same ordering of hooks even if in a given render cycle there might be not enough information to perform a call.
-
-
-useChainCalls
-=============
-
-Makes multiple calls to specific contracts and returns values. The hook will cause the component to refresh when values change.
-
-Calls will be combined into a single multicall across all uses of *useChainCall* and *useChainCalls*.
-It is recommended to use `useContractCall`_ where applicable instead of this method.
-
-*Parameters*
-
-- ``calls: ChainCall[]`` - list of calls, also see `ChainCall`_. Calls need to be in the same order across component renders.
-
-useContractCall
-===============
-Makes a call to a specific contract and returns the value. The hook will cause the component to refresh when a new block is mined and the return value changes.
-A syntax sugar for `useChainCall`_ that uses ABI, function name, and arguments instead of raw data.
-
-**Parameters**
-
-- ``calls: ContractCall | Falsy`` - a single call to a contract , also see `ContractCall`_
-
-**Returns**
-
-- ``any[] | undefined`` - the result of a call or undefined if call didn't return yet
-
-useContractCalls
-================
-Makes calls to specific contracts and returns values. The hook will cause the component to refresh when a new block is mined and the return values change.
-A syntax sugar for `useChainCalls`_ that uses ABI, function name, and arguments instead of raw data.
-
-**Parameters**
-
-- ``calls: ContractCall[]`` - a list of contract calls , also see `ContractCall`_
-
-**Returns**
-
-- ``any[] | undefined`` - array of results. Undefined if call didn't return yet
-
-.. _useContractFunction-label:
-
-useContractFunction
-===================
-Hook returns an object with three variables: ``state`` , ``send`` and ``events``.
-
-The ``state`` represents the status of transaction. See `TransactionStatus`_.
-
-The ``events`` is a array of parsed transaction events of type `LogDescription `_.
-
-To send a transaction use ``send`` function returned by ``useContractFunction``.
-The function forwards arguments to ethers.js contract object, so that arguments map 1 to 1 with Solidity function arguments.
-Additionally, there can be one extra argument - `TransactionOverrides `_, which can be used to manipulate transaction parameters like gasPrice, nonce, etc
-
-**Parameters**
-
-- ``contract: Contract`` - contract which function is to be called , also see `Contract `_
-- ``functionName: string`` - name of function to call
-- ``options?: Options`` - additional options of type `TransactionOptions`_.
-
-**Returns**
-
-- ``{ send: (...args: any[]) => void, state: TransactionStatus, events: LogDescription[] }`` - object with variables: ``send`` , ``state`` , ``events``
-
-**Example**
-
-.. code-block:: javascript
-
- const { state, send } = useContractFunction(contract, 'deposit', { transactionName: 'Wrap' })
-
- const depositEther = (etherAmount: string) => {
- send({ value: utils.parseEther(etherAmount) })
- }
-
-.. code-block:: javascript
-
- const { state, send } = useContractFunction(contract, 'withdraw', { transactionName: 'Unwrap' })
-
- const withdrawEther = (wethAmount: string) => {
- send(utils.parseEther(wethAmount))
- }
-
-.. _useSendTransaction:
-
-useSendTransaction
-==================
-Hook returns an object with two variables: ``state`` and ``sendTransaction``.
-
-The former represents the status of transaction. See `TransactionStatus`_.
-
-To send a transaction use ``sendTransaction`` function returned by ``useSendTransaction``.
-
-Function accepts a `Transaction Request `_ object as a parameter.
-
-**Parameters**
-
-- ``options?: Options`` - additional options of type `TransactionOptions`_.
-
-**Returns**
-
-- ``{ sendTransaction: (...args: any[]) => void, state: TransactionStatus }`` - object with two variables: ``sendTransaction`` and ``state``
-
-**Example**
-
-.. code-block:: javascript
-
- const { sendTransaction, state } = useSendTransaction({ transactionName: 'Send Ethereum' })
-
- const handleClick = () => {
-
- ...
-
- sendTransaction({ to: address, value: utils.parseEther(amount) })
- }
-
-useConfig
-=========
-
-Returns singleton instance of `Config`_.
-
-Function takes no parameters.
-
-
-useDebounce
-===========
-
-Debounce a value of type T.
-It stores a single value but returns after debounced time unless a new value is assigned before the debounce time elapses, in which case the process restarts.
-
-**Generic parameters**
-
-- ``T`` - type of stored value
-
-**Parameters**
-
-- ``value: T`` - variable to be debounced
-- ``delay: number`` - debounce time - amount of time in ms
-
-**Returns**
-
-- ``T`` - debounced value
-
-**Example**
-
-.. code-block:: javascript
-
- const [someValue, setValue] = useState(...)
- const debouncedValue = useDebounce(value, 1000)
-
-
-useDebouncePair
-===============
-
-Debounce a pair of values of types T and U.
-It stores a single value but returns after debounced time unless a new value is assigned before the debounce time elapses, in which case the process restarts.
-
-This function is used for debouncing multicall until enough calls are aggregated.
-
-
-**Generic parameters**
-
-- ``T`` - type of first stored value
-- ``U`` - type of second stored value
-
-**Parameters**
-
-- ``first: T`` - first variable to be debounced
-- ``second: U`` - second variable to be debounced
-- ``delay: number`` - debounce time - amount of time in ms
-
-**Returns**
-
-- ``[T, U]`` - debounced values
-
-useEtherBalance
-===============
-
-Returns ether balance of a given account.
-
-**Parameters**
-
-- ``address: string | Falsy`` - address of an account
-
-**Returns**
-
-- ``balance: BigNumber | undefined`` - a balance of the account which is BigNumber or *undefined* if not connected to network or address is a falsy value
-
-**Example**
-
-.. code-block:: javascript
-
- const { account } = useEthers()
- const etherBalance = useEtherBalance(account)
-
- return (
- {etherBalance &&
Ether balance: {formatEther(etherBalance)} ETH
}
- )
-
-.. _useEthers:
-
-useEthers
-=========
-
-Returns connection state and functions that allow to manipulate the state.
-
-**Returns:**
-
- - ``account: null | string`` - current user account (or *null* if not connected or connected in read-only mode)
- - ``chainId: ChainId`` - current chainId (or *undefined* if not connected)
- - ``library: Web3Provider`` - an instance of ethers `Web3Provider `_ (or *undefined* if not connected)
- - ``active: boolean`` - returns if provider is connected (read or write mode)
- - ``activateBrowserWallet(onError?: (error: Error) => void, throwErrors?: boolean)`` - function that will initiate connection to browser web3 extension (e.g. Metamask)
- - ``async activate(connector: AbstractConnector, onError?: (error: Error) => void, throwErrors?: boolean)`` - function that allows to connect to a wallet
- - ``async deactivate()`` - function that disconnects wallet
- - ``error?: Error`` - an error that occurred during connecting (e.g. connection is broken, unsupported network)
-
-
-*Requires:* ````
-
-useGasPrice
-===========
-
-Returns gas price of current network.
-
-**Returns**
-
-- ``gasPrice: BigNumber | undefined`` - gas price of current network. Undefined if not initialised
-
-useMulticallAddress
-===================
-
-.. _useNotifications:
-
-useNotifications
-================
-
-``useNotifications`` is a hook that is used to access notifications.
-Notifications include information about: new transactions, transaction success or failure, as well as connection to a new wallet.
-
-To use this hook call:
-
-.. code-block:: javascript
-
- const { notifications } = useNotifications()
-
-
-``notifications`` is an array of ``NotificationPayload``.
-
-Each notification is removed from ``notifications`` after time declared in
-config.notifications.expirationPeriod
-
-Each can be one of the following:
-
-.. code-block:: javascript
-
- {
- type: 'walletConnected';
- address: string
- }
-
-.. code-block:: javascript
-
- {
- type: 'transactionStarted';
- submittedAt: number
- transaction: TransactionResponse;
- transactionName?: string
- }
-
-.. code-block:: javascript
-
- {
- type: 'transactionSucceed'
- transaction: TransactionResponse
- originalTransaction?: TransactionResponse
- receipt: TransactionReceipt
- transactionName?: string
- }
-
-.. code-block:: javascript
-
- {
- type: 'transactionFailed'
- transaction: TransactionResponse
- originalTransaction?: TransactionResponse
- receipt: TransactionReceipt
- transactionName?: string
- }
-
-Link to: `Transaction Response `_.
-
-Link to: `Transaction Receipt `_.
-
-useToken
-===============
-
-Returns name, symbol, decimals and token supply of a given token.
-
-**Parameters**
-
-- ``tokenAddress: string | Falsy`` - address of a token contract.
-
-**Returns**
-
-- ``tokenInfo: TokenInfo | undefined`` - a token info object (see `TokenInfo`_) or undefined if all four methods don't exist on a token.
-
-**Example**
-
-.. code-block:: javascript
-
- const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f'
- const daiInfo = useToken(DAI_ADDRESS)
-
- return daiInfo ? (
- <>
-
Dai name: {daiInfo?.name}
-
Dai symbol: {daiInfo?.symbol}
-
Dai decimals: {daiInfo?.decimals}
-
Dai totalSupply: {daiInfo?.totalSupply ? formatUnits(daiInfo?.totalSupply, daiInfo?.decimals) : ''}
- >
- ) : null
-
-useTokenBalance
-===============
-
-Returns a balance of a given token for a given address.
-
-**Parameters**
-
-- ``tokenAddress: string | Falsy`` - address of a token contract
-- ``address: string | Falsy`` - address of an account
-
-**Returns**
-
-- ``balance: BigNumber | undefined`` - a balance which is BigNumber or undefined if address or token is *Falsy* or not connected
-
-**Example**
-
-.. code-block:: javascript
-
- const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f'
- const { account } = useEthers()
- const daiBalance = useTokenBalance(DAI_ADDRESS, account)
-
- return (
- {daiBalance &&
Dai balance: {formatUnits(daiBalance, 18)} DAI
}
- )
-
-useTokenAllowance
-=================
-
-Returns allowance (tokens left to use by spender) for given tokenOwner - spender relationship.
-
-**Parameters**
-
-- ``tokenAddress: string | Falsy`` - address of a token contract
-- ``ownerAddress: string | Falsy`` - address of an account to which tokens are linked
-- ``spenderAddress: string | Falsy`` - address of an account allowed to spend tokens
-
-**Returns**
-
-- ``remainingAllowance: BigNumber | undefined`` - an allowance which is BigNumber or undefined if any address or token is *Falsy* or not connected
-
-**Example**
-
-.. code-block:: javascript
-
- const TOKEN_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f'
- const SPENDER_ADDRESS = '0xA193E42526F1FEA8C99AF609dcEabf30C1c29fAA'
- const { account, chainId } = useEthers()
- const allowance = useTokenAllowance(TOKEN_ADDRESS, account, SPENDER_ADDRESS)
-
- return (
- {allowance &&
}
- )
-
-.. _useTransactions:
-
-useTokenList
-=============
-
-Fetches ERC20 token list under a given address and filters them by chain id. Optionally it can filter also by token tags.
-
-**Parameters**
-
-- ``tokenListURI: string`` - URI to fetch token list from
-- ``overrideChainId?: ChainId`` - chain id to filter tokens by (if not specified then current network is used)
-- ``tags?: string[]`` - list of tags to filter tokens by (token is included if it contains any of given tags)
-
-**Returns**
-
-- ``name: string`` - token list name
-- ``logoURI: string`` - URI to get token list logo from
-- ``tokens: TokenInfo[]`` - list of ``TokenInfo`` objects
-
-If an error occurs ``undefined`` is returned.
-
-**Example**
-
-.. code-block:: javascript
-
- const { name, logoURI, tokens } = useTokenList(UNISWAP_DEFAULT_TOKEN_LIST_URI) || {}
-
- const httpSource = logoURI && logoURI.startsWith('ipfs') ? logoURI.replace('ipfs://', 'https://ipfs.io/ipfs/') : logoURI
- return (
-
-
- {name}
- {httpSource && }
-
-
- {tokens?.map(token => (
-
-
-
Name: {token.name}
-
Symbol: {token.symbol}
-
Decimals: {token.decimals}
-
Address: {token.address}
-
-
- ))}
-
-
- )
-
-**See**
-
-- Token lists:
-- Token list json example:
-- ``TokenInfo`` object:
-
-.. _useTokenList
-
-useTransactions
-===============
-
-``useTransactions`` hook returns a list ``transactions``. This list contains
-all transactions that were sent using ``useContractFunction`` and ``useSendTransaction``.
-Transactions are stored in local storage and the status is rechecked on every new block.
-
-Each transaction has following type:
-
-.. code-block:: javascript
-
- export interface StoredTransaction {
- transaction: TransactionResponse
- submittedAt: number
- receipt?: TransactionReceipt
- lastCheckedBlockNumber?: number
- transactionName?: string
- originalTransaction?: TransactionResponse
- }
-
-Link to: `Transaction Response `_.
-
-Link to: `Transaction Receipt `_.
-
-
-useLookupAddress
-=================
-
-``useLookupAddress`` is a hook that is used to retrieve the ENS (e.g. `name.eth`) for the connected wallet.
-
-**Returns**
-
-- ``address: String | undefined`` - a string if the connected account has an ENS attached.
-
-**Example**
-
-.. code-block:: javascript
-
- const { account } = useEthers()
- const ens = useLookupAddress()
-
- return (
-
Account: {ens ?? account}
- )
-
-
-Models
-******
-
-
-.. _config:
-
-Config
-======
-
-**readOnlyChainId**
-
-``ChainId`` of a chain you want to connect to by default in a read-only mode
-
-**readOnlyUrls**
-
-Mapping of ``ChainId``'s to node URLs to use in read-only mode.
-
-***Example***
-
-.. code-block:: javascript
-
- {
- ...
- readOnlyUrls: {
- [Mainnet.chainID]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934'
- }
- }
-
-**multicallAddresses **
-
-**supportedChains (deprecated) **
-List of intended supported chains. If a user tries to connect to an unsupported chain an error value will be returned by `useEthers`.
-
-***Default value:***
--``[ChainId.Mainnet, ChainId.Goerli, ChainId.Kovan, ChainId.Rinkeby, ChainId.Ropsten, ChainId.xDai]``
-
-**networks**
-List of intended supported chain configs. If a user tries to connect to an unsupported chain an error value will be returned by `useEthers`.
-
-***Default value:***
-``[Localhost, Hardhat, Mainnet, Ropsten, Rinkeby, Goerli, Kovan...]``
-
-Check the full list in https://github.com/EthWorks/useDApp/tree/master/packages/core/src/model/chain
-
-**pollingInterval**
-Polling interval for a new block.
-
-**localStorage**
-Paths to locations in local storage
-
-***Default value:***
-
-.. code-block:: javascript
-
- {
- transactionPath: 'transactions'
- }
-
-
-**autoConnect**
-Enables reconnecting to last used provider when user revisits the page.
-
-***Default value:***
-
-.. code-block:: javascript
-
- {
- autoConnect: true
- }
-
-
-ChainCall
-=========
-
-Represents a single call on the blockchain that can be included in multicall.
-
-Fields:
-
-- ``address: string`` - address of a contract to call
-
-- ``data: string`` - calldata of the call that encodes function call
-
-ContractCall
-============
-Represents a single call to a contract that can be included in multicall.
-
-Fields:
-
-- ``abi: Interface`` - ABI of a contract, see `Interface `_
-
-- ``address: string`` - address of a contract to call
-
-- ``method: string`` - function name
-
-- ``args: any[]`` - arguments for the function
-
-Currency
-========
-
-The ``Currency`` class is tasked with representing the individual currencies as well as handling formatting.
-
-The base ``Currency`` class is constructed with the following parameters:
-- ``name`` - name of the currency
-- ``ticker`` - e.g. USD, EUR, BTC
-- ``decimals`` - number of decimal places (e.g. 2 for USD, 18 for ETH)
-- ``formattingOptions`` - define how the currency values are formatted
-
-The following formatting options are supported:
-
-- ``decimals`` - Defaults to the decimals of the currency.
-- ``thousandSeparator`` - Defaults to ``','``. Used for separating thousands.
-- ``decimalSeparator`` - Defaults to ``'.'``. Used for separating the integer part from the decimal part.
-- ``significantDigits`` - Defaults to Infinity. Can limit the number of digits on the decimal part, such that either the total number of displayed digits is equal to this parameter or more digits are displayed, but the decimal part is missing.
-- ``useFixedPrecision`` - Defaults to false. Switches from using significant digits to fixed precision digits.
-- ``fixedPrecisionDigits`` - Defaults to 0. Can specify the number of digits on the decimal part.
-- ``prefix`` - Defaults to ``''``. Prepended to the result.
-- ``suffix`` - Defaults to ``''``. Appended to the result.
-
-Other variants of ``Currency`` include ``FiatCurrency``, ``NativeCurrency`` and ``Token``.
-
-``FiatCurrency`` takes the same parameters as ``Currency`` but uses fixed precision digits by default.
-
-``NativeCurrency`` additionally takes a ``chainId`` parameter. The format function is configured with the ticker prefix and 6 significant digits by default.
-
-``Token`` additionally takes a ``chainId`` parameter as well as an ``address`` parameter. The format function is configured with the ticker prefix and 6 significant digits by default.
-
-CurrencyValue
-=============
-
-The ``CurrencyValue`` class represents a value tied to a currency. The methods include:
-
-- ``static fromString(currency, value)`` - creates a new CurrencyValue from string.
-- ``static zero(currency)`` - creates a new CurrencyValue equal to 0.
-- ``toString()`` - returns the value of the CurrencyValue as a decimal string with no formatting.
-- ``format(overrideOptions?)`` - formats the value according to the currency. The caller can override the formatting options.
-- ``map(fn)`` - returns a new CurrencyValue with value transformed by the callback.
-- ``add(other)`` - returns a new CurrencyValue with value being the sum of this value and other value. The argument must be a CurrencyValue with the same Currency.
-- ``sub(other)`` - returns a new CurrencyValue with value being the difference of this value and other value. The argument must be a CurrencyValue with the same Currency.
-- ``mul(value)`` - returns a new CurrencyValue with value multiplied by the argument.
-- ``div(value)`` - returns a new CurrencyValue with value divided by the argument.
-- ``mod(value)`` - returns a new CurrencyValue with value modulo the argument.
-- ``equals(other)`` - performs an equality check on the currencies and the values of both objects.
-- ``lt(other)`` - checks if this value is less than the other value. The argument must be a CurrencyValue with the same Currency.
-- ``lte(other)`` - checks if this value is less than or equal to the other value. The argument must be a CurrencyValue with the same Currency.
-- ``gt(other)`` - checks if this value is greater than the other value. The argument must be a CurrencyValue with the same Currency.
-- ``gte(other)`` - checks if this value is greater than or equal to the other value. The argument must be a CurrencyValue with the same Currency.
-- ``isZero()`` - returns true if the value is zero.
-
-.. _TokenInfo:
-
-TokenInfo
-=========
-
-Represents general token information.
-
-Fields:
-
-- ``name: string`` - token name or an empty string.
-
-- ``symbol: string`` - token symbol or an empty string.
-
-- ``decimals?: numbers`` - optional field that contains token decimals.
-
-- ``totalSupply?: BigNumberish`` - optional field that contains total supply of the token.
-
-.. _TransactionOptions:
-
-TransactionOptions
-==================
-
-Represents a options for sending transactions.
-All fields are optional.
-
-Fields:
-
-- ``signer?: Signer`` - specifies `signer `_ for a transaction.
-
-- ``transactionName?: string`` - specifies a transaction name. Used by notifications and history hooks.
-
-.. _TransactionStatus:
-
-TransactionStatus
-=================
-
-Represents a state of a single transaction.
-
-Fields:
-
-- ``status: TransactionState`` - string that can contain one of ``None`` ``Mining`` ``Success`` ``Fail`` ``Exception``
-
-- ``transaction?: TransactionResponse`` - optional field. See `Transaction Response `_.
-
-- ``originalTransaction?: TransactionResponse`` - optional field that contains the original transaction if it has been dropped and replaced. See `Transaction Response `_.
-
-- ``receipt?: TransactionReceipt`` - optional field. See `Transaction Receipt `_.
-
-- ``chainId?: ChainId`` - optional field. See `chainId`_.
-
-- ``errorMessage?: string`` - optional field that contains error message when transaction fails or throws.
-
-``status`` can be one of the following:
-
-- **None** - before a transaction is created.
-- **Mining** - when a transaction is sent to the network, but not yet mined. In this state ``transaction: TransactionResponse`` is available.
-- **Success** - when a transaction has been mined successfully. In this state ``transaction: TransactionResponse`` and ``receipt: TransactionReceipt`` are available.
-- **Failed** - when a transaction has been mined, but ended up reverted. Again ``transaction: TransactionResponse`` and ``receipt: TransactionReceipt`` are available.
-- **Exception** - when a transaction hasn't started, due to the exception that was thrown before the transaction was propagated to the network. The exception can come from application/library code (e.g. unexpected exception like malformed arguments) or externally (e.g user discarded transaction in Metamask). In this state the ``errorMessage: string`` is available (as well as exception object).
-
-Additionally all states except ``None``, contain ``chainId: ChainId``.
-
-Change in ``state`` will update the component so you can use it in useEffect.
-
-Constants
-*********
-
-.. _chainId:
-
-ChainId
-=======
-
-Enum that represents chain ids.
-
-**Values:**
-
-``Mainnet, Goerli, Kovan, Rinkeby, Ropsten, BSC, xDai, Polygon, Moonriver, Mumbai, Harmony, Theta, Palm, Fantom, Avalanche, Songbird``
-
-Helpers
-*******
-
-getExplorerAddressLink (deprecated)
-====================================
-
-> can call with Chain directly, ex:
-> import { Mainnet } from '@usedapp/core'
-> Mainnet.getExplorerAddressLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987')
-> // https://etherscan.io/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987
-
-Returns URL to blockchain explorer for an address on a given chain.
-
-**Parameters**
-
-- ``address: string`` - account address
-- ``chainId: ChainId`` - id of a chain
-
-
-**Example**
-
-.. code-block:: javascript
-
- getExplorerAddressLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Mainnet.chainID)
- // https://etherscan.io/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987
-
- getExplorerAddressLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Ropsten.chainID)
- // https://ropsten.etherscan.io/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987
-
- getExplorerAddressLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', xDai.chainID)
- // https://blockscout.com/poa/xdai/address/0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987/transactions
-
- getExplorerAddressLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Harmony.chainID)
- // https://explorer.harmony.one/address/0xc7095a52c403ee3625ce8b9ae8e2e46083b81987
-
-
-getExplorerTransactionLink (deprecated)
-==========================================
-
-> can call with Chain directly, ex:
-> import { Mainnet } from '@usedapp/core'
-> Mainnet.getExplorerTransactionLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987')
-> // https://etherscan.io/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a
-
-Returns URL to blockchain explorer for a transaction hash on a given chain.
-
-**Parameters**
-
-- ``transactionHash: string`` - hash of a transaction
-- ``chainId: ChainId`` - id of a chain
-
-**Example**
-
-.. code-block:: javascript
-
- getExplorerTransactionLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Mainnet.chainID)
- // https://etherscan.io/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a
-
- getExplorerTransactionLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Ropsten.chainID)
- // https://ropsten.etherscan.io/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a
-
- getExplorerTransactionLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', xDai.chainID)
- // https://blockscout.com/poa/xdai/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a/internal-transactions
-
- getExplorerTransactionLink('0xC7095A52C403ee3625Ce8B9ae8e2e46083b81987', Harmony.chainID)
- // https://explorer.harmony.one/tx/0x5d53558791c9346d644d077354420f9a93600acf54eb6a279f12b43025392c3a
-
-getChainName (deprecated)
-================================
-
-> can call with Chain directly, ex:
-> import { Mainnet } from '@usedapp/core'
-> Mainnet.chainName
-> // Mainnet
-
-Returns name of a chain for a given `chainId`.
-
-**Parameters**
-
-- ``chainId: ChainId`` - id of a chain
-
-**Example**
-
-.. code-block:: javascript
-
- getChainName(Mainnet.chainID) // Mainnet
- getChainName(Ropsten.chainID) // Ropsten
- getChainName(xDai.chainID) // xDai
- getChainName(Theta.chainID) // Theta
- getChainName(Harmony.chainID) // Harmony
- getChainName(Moonriver.chainID) // Moonriver
- getChainName(Fantom.chainID) // Fantom
-
-isTestChain (deprecated)
-=========================
-
-> can call with Chain directly, ex:
-> import { Mainnet } from '@usedapp/core'
-> Mainnet.isTestChain
-> // false
-> Ropsten.isTestChain
-> // true
-
-Returns if a given chain is a testnet.
-
-**Parameters**
-
-- ``chainId: ChainId`` - id of a chain
-
-**Example**
-
-.. code-block:: javascript
-
- isTestChain(Mainnet.chainId) // false
- isTestChain(Ropsten.chainId) // true
- isTestChain(xDai.chainId) // false
-
-shortenAddress
-==============
-
-Returns short representation of address or throws an error if address is incorrect.
-
-**Parameters**
-
-- ``address: string`` - address to shorten
-
-**Example**
-
-.. code-block:: javascript
-
- shortenAddress('0x6E9e7A8Fb61b0e1Bc3cB30e6c8E335046267D3A0')
- // 0x6E9e...D3A0
-
- shortenAddress('6E9e7A8Fb61b0e1Bc3cB30e6c8E335046267D3A0')
- // 0x6E9e...D3A0
-
- shortenAddress("i'm not an address")
- // TypeError("Invalid input, address can't be parsed")
-
-shortenIfAddress
-================
-
-Returns short representation of address or throws an error if address is incorrect.
-Returns empty string if no address is provided.
-
-**Parameters**
-
-- ``address: string | 0 | null | undefined | false`` - address to shorten
-
-**Example**
-
-.. code-block:: javascript
-
- shortenIfAddress('0x6E9e7A8Fb61b0e1Bc3cB30e6c8E335046267D3A0')
- // 0x6E9e...D3A0
-
- shortenIfAddress('')
- // ''
-
- shortenIfAddress(undefined)
- // ''
-
- shortenIfAddress("i'm not an address")
- // TypeError("Invalid input, address can't be parsed")
-
-transactionErrored
-==================
-
-Returns true if transaction failed or had an exception
-
-**Parameters**
-
-- ``transaction: TransactionStatus`` - transaction to check.
-
-compareAddress
-==============
-
-Returns 1 if first address is bigger than second address.
-Returns 0 if both addresses are equal.
-Returns -1 if first address is smaller than second address.
-If any address can't be parsed throws an error.
-
-**Parameters**
-
-- ``firstAddress`` - first address to compare
-- ``secondAddress`` - second address to compare
-
-**Example**
-
-.. code-block:: javascript
-
- address1 = '0x24d53843ce280bbae7d47635039a94b471547fd5'
- address2 = '0x24d53843ce280bbae7d47635039a94b471000000'
- compareAddress(address1, address2)
- // 1
-
- address1 = '0x000000440ad484f55997750cfae3e13ca1751283'
- address2 = '0xe24212440ad484f55997750cfae3e13ca1751283'
- compareAddress(address1, address2)
- // -1
-
- address1 = 'im not an address'
- address2 = '0xb293c3b2b4596824c57ad642ea2da4e146cca4cf'
- compareAddress(address1, address2)
- // TypeError("Invalid input, address can't be parsed")
-
-addressEqual
-==============
-
-Returns true if both addresses are them same.
-Returns false if addresses are different.
-Throws an error if address can't be parsed.
-
-**Parameters**
-
-- ``firstAddress`` - first address to compare
-- ``secondAddress`` - second address to compare
-
-**Example**
-
-.. code-block:: javascript
-
- address1 = '0x24d53843ce280bbae7d47635039a94b471547fd5'
- address2 = '0x24d53843ce280bbae7d47635039a94b471547fd5'
- addressEqual(address1, address2)
- // true
-
- address1 = '0x24d53843ce280bbae7d47635039a94b471547fd5'
- address2 = '0xe24212440ad484f55997750cfae3e13ca1751283'
- addressEqual(address1, address2)
- // false
-
- address1 = 'im not an address'
- address2 = '0xb293c3b2b4596824c57ad642ea2da4e146cca4cf'
- compareAddress(address1, address2)
- // TypeError("Invalid input, address can't be parsed")
diff --git a/docs/source/getting-started.rst b/docs/source/getting-started.rst
deleted file mode 100644
index 0ea17a465..000000000
--- a/docs/source/getting-started.rst
+++ /dev/null
@@ -1,196 +0,0 @@
-Getting started
-===============
-
-Installation
-------------
-
-To start working with useDapp you need to have a working React environment.
-
-To get started, add the following npm package :code:`@usedapp/core` to your project:
-
-.. tabs::
-
- .. group-tab:: Yarn
-
- .. code-block:: text
-
- yarn add @usedapp/core
-
- .. group-tab:: NPM
-
- .. code-block:: text
-
- npm install @usedapp/core
-
-Example
--------
-
-Below is a simple example:
-
-.. code-block:: javascript
-
- import { Mainnet, DAppProvider, useEtherBalance, useEthers, Config } from '@usedapp/core'
- import { formatEther } from '@ethersproject/units'
-
- const config: Config = {
- readOnlyChainId: Mainnet.chainId,
- readOnlyUrls: {
- [Mainnet.chainId]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934',
- },
- }
-
- ReactDOM.render(
-
-
-
-
- ,
- document.getElementById('root')
- )
-
- export function App() {
- const { activateBrowserWallet, account } = useEthers()
- const etherBalance = useEtherBalance(account)
- return (
-
-
-
-
- {account &&
Account: {account}
}
- {etherBalance &&
Balance: {formatEther(etherBalance)}
}
-
- )
- }
-
-
-Example is available `here `_ and full example code is available `here `_.
-
-Let's go over it step by step.
-
-Setup
------
-
-The first thing you need to do is set up **DAppProvider** with optional config and wrap your whole App in it. You can read about config :ref:`here`.
-
-.. code-block:: jsx
-
-
- {/* Wrap your app with the Provider */}
-
-
-
-Connecting to a network
------------------------
-
-Then you need to activate the provider using **activateBrowserWallet**. It's best to do when the user clicks "Connect" button.
-
-.. code-block:: jsx
-
- export function App() {
- const { activateBrowserWallet, account } = useEthers()
- return (
-
-
-
-
- {account &&
Account: {account}
}
-
- )
- }
-
-After the activation (i.e. user connects to a wallet like MetaMask) the component will show the user's address.
-
-If you need to use another connector than a browser wallet, use the `activate` method from `useEthers`. See the `web3-react ` doc for that one.
-
-Ether balance
--------------
-
-`useEtherBalance(address: string)`
-
-Provides a way to fetch the account balance. Takes the account address as an argument and returns ``BigNumber`` or ``undefined`` when data is not available (i.e. not connected).
-To obtain currently connected ``account`` employ ``useEthers()``.
-
-.. code-block:: jsx
-
- import { formatEther } from '@ethersproject/units'
-
- export function EtherBalance() {
- const { account } = useEthers()
- const etherBalance = useEtherBalance(account)
-
- return (
-
- {etherBalance &&
Balance: {formatEther(etherBalance)}
}
-
- )
- }
-
-Token balance
--------------
-
-`useTokenBalance(address: string, tokenAddress: string)`
-
-Provides a way to fetch balance of ERC20 token specified by ``tokenAddress`` for provided ``address``. Returns ``BigNumber`` or ``undefined`` when data is not available.
-
-.. code-block:: jsx
-
- import { formatUnits } from '@ethersproject/units'
-
- const DAI = '0x6b175474e89094c44da98b954eedeac495271d0f'
-
- export function TokenBalance() {
- const { account } = useEthers()
- const tokenBalance = useTokenBalance(DAI, account)
-
- return (
-
- {tokenBalance &&
Balance: {formatUnits(tokenBalance, 18)}
}
-
- )
- }
-
-
-Troubleshooting
----------------
-
-Type mismatch when building
-***************************
-
-If when building an app you see errors about type mismatch in ``@ethersproject``.
-
-For example:
-
-.. code-block::
-
- $ yarn build
- yarn run v1.22.10
- $ tsc --noEmit && rimraf build && webpack --mode production --progress
- src/components/Transactions/Forms.tsx:12:52 - error TS2345: Argument of type 'Interface' is not assignable to parameter of type 'ContractInterface'.
- Property 'getError' is missing in type 'import("github.com/ethworks/usedapp/packages/example/node_modules/@ethersproject/abi/lib/interface").Interface' but required in type 'import("github.com/ethworks/usedapp/packages/example/node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/lib/interface").Interface'.
-
- 12 const contract = new Contract(wethContractAddress, wethInterface)
- ~~~~~~~~~~~~~
-
- node_modules/@ethersproject/contracts/node_modules/@ethersproject/abi/lib/interface.d.ts:53:5
- 53 getError(nameOrSignatureOrSighash: string): ErrorFragment;
- ~~~~~~~~
- 'getError' is declared here.
-
-
- Found 1 error.
-
- error Command failed with exit code 2.
- info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
-
-It may be an error of yarn getting internal versions of ``@ethersproject`` that are higher then specified in useDApp.
-To fix this you need to add resolutions to your ``package.json`` with etherspoject packages that cause an error, with correct version.
-Resolutions force yarn to install specified versions of packages.
-
-For example:
-
-.. code-block::
-
- "resolutions": {
- "@ethersproject/abi": "5.2.0",
- "@ethersproject/contracts": "5.2.0"
- }
diff --git a/docs/source/guide.rst b/docs/source/guide.rst
deleted file mode 100644
index e73a88a7b..000000000
--- a/docs/source/guide.rst
+++ /dev/null
@@ -1,515 +0,0 @@
-Guides
-######
-
-Connecting to network
-*********************
-
-Read-only
-=========
-To connect to the network in read-only mode, provide ``readOnlyChainId`` and ``readOnlyUrls`` fields in application configuration.
-
-See example configuration below:
-
-.. code-block:: javascript
- import { Mainnet } from '@usedapp/core'
-
- const config = {
- readOnlyChainId: Mainnet.chainID,
- readOnlyUrls: {
- [Mainnet.chainID]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934',
- },
- }
-
-
-Browser wallet
-==============
-
-To connect to a wallet in a web3-enabled browser, use ``activateBrowserWallet`` returned by ``useEthers()``.
-Once connected ``account`` variable will be available.
-
-See example below:
-
-.. code-block:: javascript
-
- export function App() {
- const { activateBrowserWallet, account } = useEthers()
- return (
-
- {!account && }
- {account &&
Account: {account}
}
-
- )
- }
-
-
-useEthers
-=========
-
-``useEthers`` hook returns a number of useful functions and variables, see below:
-
-- ``account`` - current user account (or ``null`` if not connected or connected in read-only mode)
-
-- ``chainId`` - current chainId (or ``undefined`` if not connected)
-
-- ``library`` - an instance of ethers `Web3Provider `_ (or ``undefined`` if not connected). Read more about ethers providers `here `_.
-
-- ``active`` - boolean that indicates if provider is connected (read or write mode)
-
-- ``activate`` - function that allows to connect to a wallet. This is a `web3-react `_ function that can take various connectors.
-
-- ``deactivate`` - function that disconnects wallet
-
-- ``error`` - an error that occurred during connecting (e.g. connection is broken, unsupported network)
-
-
-
-Example
-=======
-
-Example below demonstrates how to manage and use connection.
-
-Application allow to see the balance of Ethereum 2.0 staking contracts in read-only mode.
-When wallet is connected additionally it shows user's account along with it's balance.
-
-Example is available `here `_.
-
-.. code-block:: javascript
- import { Mainnet } from '@usedapp/core'
-
- const config = {
- readOnlyChainId: Mainnet.chainId,
- readOnlyUrls: {
- [Mainnet.chainId]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934',
- },
- }
-
- ReactDOM.render(
-
-
-
- document.getElementById('root')
- )
-
- const STAKING_CONTRACT = '0x00000000219ab540356cBB839Cbe05303d7705Fa'
-
- export function App() {
- const { activateBrowserWallet, deactivate, account } = useEthers()
- const userBalance = useEtherBalance(account)
- const stakingBalance = useEtherBalance(STAKING_CONTRACT)
-
- return (
-