Make sure you clone submodules together.
git clone --recurse-submodules
If you already pulled using just git clone
, you can use below command to update submodules.
git submodule update --init --recursive
From fresh clone:
yarn
yarn workspace @midas-capital/sdk forge install
yarn workspace @midas-capital/sdk build
Run everything from the top level.
Ask for .env file from the team and add it under packages/sdk
If you want to add packages to modules, you can do so like:
yarn workspace @midas-capital/sdk add ethers
To run forge
commands inside the sdk
package, run:
yarn workspace @midas-capital/sdk forge install <SOME_DEP>
yarn workspace @midas-capital/sdk forge build
packages/my-new-package
.tsconfig.json
:{
...
"references": [
...
{
"path": "./packages/my-new-package"
}
]
}
package.json
inside the package:{
...
"dependencies": {
...
"@midas-capital/some-other-package": "workspace:*"
}
}
- `yarn` from top-level to update dependencies/symlinks.
Forking requires access to a archive RPC node. For BSC we had a great experience using an RPC Node from NodeReals MegaNode service - https://nodereal.io/meganode .
For forking Polygon we haven't found a free service to use an archive node yet.
You general purpose forking you have to set FORK_RPC_URL
and FORK_CHAIN_ID
in your packages/sdk/.env
file.
And than start a forked local node by running.
> yarn dev:node:fork
In order to start multiple forks at once we streamlined the process a bit. In your executing shell make sure to set BSC_RPC_URL
and or POLYGON_RPC_URL
.
> yarn dev:node:bsc
// Will start a CHAIN_ID=56 fork using $BSC_RPC_URL at https://localhost:8545
> yarn dev:node:polygon
// Will start a CHAIN_ID=137 fork using $POLYGON_RPC_URL at https://localhost:8546
The idea is to increase the port number with each fork we want to support.
8545: BSC
8546: Polygon
8547: Moonbeam?
For convenience we have a Hardhat task to make some token swaps to on the forked node for you.
> yarn workspace @midas-capital/sdk hardhat fork:fund-accounts --network fork
// Works with https://localhost:8545
> yarn workspace @midas-capital/sdk hardhat fork:fund-accounts --network localbsc
// Works with https://localhost:8545
> yarn workspace @midas-capital/sdk hardhat fork:fund-accounts --network localpolygon
// Works with https://localhost:8546
We are using ChainSafe/dappeteer to test our UI with Metamask. The test are expecting to work on a fork of BSC mainnet for now.
Follow this step to run the UI test locally
> yarn dev:node:fork
> yarn dev:ui
> yarn workspace @midas-capital/sdk hardhat fork:fund-accounts --network fork
> yarn test:ui
If you are on windows you need an X-server to run dappeteer. These instructions were taken from here: https://www.rickmakes.com/windows-subsystem-for-linux-2-installing-vcxrv-x-server/
Follow these steps before running yarn test:ui
Multiple Windows -> Start No Client -> Check All Boxes in Extra Settings -> Finish
If Windows Defender Firewall prompts you, check both Private & Public Networks and Allow Access
cat /etc/resolv.conf
export DISPLAY=ip_address:0.0
export LIBGL_ALWAYS_INDIRECT=1