forked from tahowallet/extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure Hardhat project for running extension on a forked Mainnet
In this commit we create a Hardhat project that allows for running Taho extension on a forked Mainnet. As part of this we're configuring a `hardhat` network in the Hardhat config file. The fork will begin on a block specified in the `blockNumber` parameter. The `url` parameter should hold an url to a JSON-RPC node that's based on your personal Infura/Alchemy API key (e.g. `https://mainnet.infura.io/v3/<key>`). The suggested value for `chainId` is `1337`. The steps to run the network are described in the README file. Any actions performed on the `hardhat` network will only be applied locally, they will not affect the real Mainnet network.
- Loading branch information
1 parent
bd75368
commit cfccbfe
Showing
8 changed files
with
1,486 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ app/extension-scripts/api/playground/ | |
.vscode | ||
playwright-report | ||
test-results/ | ||
ci/cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist | |
# Ignore weblate json translation formatting | ||
ui/_locales/**/*.json | ||
!.github | ||
ci/cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Running Taho extension on a forked Mainnet | ||
|
||
## Configuration / running | ||
|
||
To run the extension on a forked Mainnet: | ||
|
||
1. Configure required environment variables (either by setting them in `../.env` | ||
or directly in the console): | ||
`USE_MAINNET_FORK=true` (needed for building the package) | ||
`MAINNET_FORK_CHAIN_ID=1337` (needed for running Hardhat, `1337` is the | ||
suggested and a default value) | ||
`CHAIN_API_URL=<Insert_your_API_URL_here>` (needed for running Hardhat, may | ||
be e.g. Alchemy or Infura API URL) | ||
`FORKING_BLOCK=<Insert_forking_block_here>` (needed for running Hardhat, if | ||
not specified, current block will be used) | ||
|
||
2. Run the following commands from root: | ||
`yarn install` | ||
`yarn start` (or `yarn build`) | ||
`cd ci` | ||
`npx hardhat node --network hardhat` | ||
|
||
3. Unpack `./dist/chrome` to Chrome Extensions. | ||
|
||
## What wallet features work / don't work on the `hardhat` network | ||
|
||
When run on `1337`: | ||
|
||
:heavy_plus_sign: we can use specific block as a start. | ||
:heavy_plus_sign: we can send txs and do swaps (balances updated) | ||
:heavy_plus_sign: we can browse NFTs | ||
:heavy_minus_sign: the activities are not loading | ||
:heavy_minus_sign: wallet shows strange assets | ||
:heavy_minus_sign: if no cache exists, loading assets takes long, account | ||
avatars may look strange | ||
|
||
State of the network is lost after Hardhat reset. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { HardhatUserConfig } from "hardhat/config" | ||
import "dotenv-defaults/config" | ||
|
||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
require(`dotenv-defaults`).config({ | ||
path: "../.env", | ||
defaults: "../.env.defaults", | ||
}) | ||
|
||
const config: HardhatUserConfig = { | ||
networks: { | ||
hardhat: { | ||
forking: { | ||
enabled: true, | ||
url: process.env.CHAIN_API_URL || "", | ||
blockNumber: parseInt(process.env.FORKING_BLOCK ?? "", 10), | ||
}, | ||
chainId: parseInt(process.env.MAINNET_FORK_CHAIN_ID ?? "1337", 10), | ||
}, | ||
}, | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@tallyho/ci", | ||
"version": "0.0.1", | ||
"description": "Taho, the community owned and operated Web3 wallet: window provider is responsible for creating the in-page object for communication.", | ||
"repository": "[email protected]:thesis/tally-extension.git", | ||
"author": "Michalina Cienciala", | ||
"license": "GPL-3.0", | ||
"keywords": [ | ||
"ethereum", | ||
"bitcoin", | ||
"cryptocurrency", | ||
"wallet", | ||
"web3", | ||
"dapp" | ||
], | ||
"devDependencies": { | ||
"dotenv-defaults": "^5.0.2", | ||
"hardhat": "^2.14.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.