Nostradamus Prophecy Machine

    This package has been deprecated

    Author message:

    Moved to @xgm/godmode

    godmode-for-test

    0.0.4 • Public • Published

    Godmode for Test

    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:

    Repositories of the Hackathon Project

    This project is built by Martinet Lee for ETHGlobal Hack The Money 2020, it consists of the following repositories:

    Installation

    npm install godmode-for-test

    Setting it up in the test environment

    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");

    General Interaction

    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 in hasOwnerShipContract = await HasOwnerShip.new({ from: Alice });.
    • replacementContractArtifact is the contract artifact produced by truffle, for example:
      • the HasOwnerShipInstrumented in const HasOwnerShipInstrumented = artifacts.require("HasOwnerShipInstrumented");
    • function_In_RC is the function that was defined in the replacementContractArtifact.

    Precompiles

    IMPORTANT: this only works on mainnet fork

    MakerDao

    Dai

    • mint Dai to an address: await GODMODE.mintDai(Bob, 10000);

    Uniswap

    • Enable Fee collection in UniswapV2: await GODMODE.uniswapV2Factory_setFeeTo(Bob);

    Compound

    • Give the address cTokens: await GODMODE.CToken_giveAddrTokens("0x6c8c6b02e7b2be14d4fa6022dfd6d75921d90e4e", Bob, 100);

    Install

    npm i godmode-for-test

    DownloadsWeekly Downloads

    3

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    139 MB

    Total Files

    49

    Last publish

    Collaborators

    • martinetlee