This library provides a truffle framework friendly api that allows developers to use the "Godmode Ganache" within the javascript testing environment provided in the truffle framework. The library also precompiles Godmode contracts for popular defi projects such as MakerDao, Uniswap, and Compound. It provides an easy way to modify the state of the projects through a set of API.
When using this library, you would need to run the Godmode ganache as well.
To see a sample project that uses this library, see this repo:
This project is built by Martinet Lee for ETHGlobal Hack The Money 2020, it consists of the following repositories:
npm install godmode-for-test
In the javascript test file, import the library through:
const GM = require("godmode-for-test");
Initialize it with the provider, which should be the "Godmode Ganache".
The first argument indicates the network name -- use mainnet
if you want to use precompile contracts.
let GODMODE = new GM("development", "ws://localhost:8545");
await GODMODE.executeAs(
targetContract,
replacementContractArtifact,
"function_In_RC",
/* some arguments for the function, */
{from: Bob} // Transaction meta info
);
Variable explanation:
targetContract
is the deployed contract, for example:- the
hasOwnerShipContract
inhasOwnerShipContract = await HasOwnerShip.new({ from: Alice });
.
- the
replacementContractArtifact
is the contract artifact produced by truffle, for example:- the
HasOwnerShipInstrumented
inconst HasOwnerShipInstrumented = artifacts.require("HasOwnerShipInstrumented");
- the
function_In_RC
is the function that was defined in the replacementContractArtifact.
IMPORTANT: this only works on mainnet fork
- mint Dai to an address:
await GODMODE.mintDai(Bob, 10000);
- Enable Fee collection in UniswapV2:
await GODMODE.uniswapV2Factory_setFeeTo(Bob);
- Give the address cTokens:
await GODMODE.CToken_giveAddrTokens("0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e", Bob, 100);