Skip to content

Commit

Permalink
Cleaned up after migration to typechain
Browse files Browse the repository at this point in the history
  • Loading branch information
superduck35 committed Feb 3, 2020
1 parent 653299c commit 047dcf9
Show file tree
Hide file tree
Showing 9 changed files with 2 additions and 180 deletions.
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@ This repo contains all contracts and tests relevant to the core mStable protocol

## Dev notes

### Typechain flow

`Name`Contract > .new() > `Name`Instance


### Setup

```
Expand All @@ -28,7 +23,6 @@ Required extensions:
- `Solidity`
- `TSLint`
- `ESLint`
- `Handlebars`

Suggested extensions:
- `Auto Import`
Expand Down Expand Up @@ -69,21 +63,14 @@ Nexus is the hub of the system and thus should be deployed first. Each subsequen

Tests are written in Typescript. This means we need to generate types for each of the contracts, then deploy a test version of the contract and then wrap it in this type. It is a reasonably sophisticated process but ensures that we remain type safe whilst undergoing tests.

As we use `@0x/abi-gen` to generate the typings for our contracts, we are locked into some dependencies as this is what is used in their `Base-contract` (which is essentially the backbone for all the test contracts).

NB: You should locally use the latest version of ganache-cli, as the test rely on recent opcodes

NB: The generated contracts consume magnitudes more gas due to some of the helper functions injected. Therefore we need to use a specific ganache environment


`ganache-cli -p 7545 -l 50000000 --allowUnlimitedContractSize`

### In-test terminology

`xxxArtifact` = The artifact created/retrieved through a truffle migration. This contains address of deployed contract through migrations.
`xxxContract` = The .TS contract type as imported from the `types/generated/xxx` as output by Typechain. Retrieved through require
`xxxInstance` = Deployed instance of the conrtact that will be used in the specific test file.
`xxxContract` = The .TS contract type as imported from the `types/generated/xxx`.
`<contract>` = The object we will use to do testing, this is the `INSTANCE` wrapped by the `CONTRACT`

### Rules

Expand All @@ -101,13 +88,8 @@ c = committed

Key folders:

- `/artifacts` [Stores the most recently, locally deployed versions of the contracts including their deployed address]
- `/index.ts` [(c)]
- `/build` [Contract build output
- `/scripts` [(c) Contains build and deploy bash scripts]
- `/test-utils` [(c) Core util files used throughout the test framework]
- `/machines` [(c) Mock contract machines for creating configurable instances of our contracts to support the simulation of test scenarios]
- `/transpiled` [Transpiled (JS) versions of the our TS files and generated types]
- `/types` [TS Types we use throughout the]
- `/contract_templates` [(c) Provided by `@0x/abi-gen` as part of the type generation (These are templates to use for converting ABI into Typescript and injecting functionality)]
- `/generated` [Output from abi-gen, used for transpiling build output into executable JS]
Expand Down
34 changes: 0 additions & 34 deletions artifacts/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion coverage.json

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"tslint": "^5.20.0",
"tslint-no-unused-expression-chai": "0.0.3",
"typechain": "^1.0.4",
"typechain-target-ethers": "^1.0.3",
"typechain-target-truffle": "^1.0.2",
"types-ethereumjs-util": "^0.0.8",
"typescript": "^3.6.3",
Expand Down
48 changes: 0 additions & 48 deletions scripts/deploy_development.sh

This file was deleted.

28 changes: 0 additions & 28 deletions test-utils/machines/bassetMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,4 @@ export class BassetMachine {

return mockInstance;
}

// public async deployTokensAsync(
// tokenCount: number,
// initialAccount: Address,
// ): Promise<StandardTokenMockContract[]> {
// const mockTokens: StandardTokenMockContract[] = [];
// const mockTokenPromises = _.times(tokenCount, async index => {
// return await StandardTokenMock.new(
// initialAccount,
// DEPLOYED_TOKEN_QUANTITY,
// `Component ${index}`,
// index.toString(),
// _.random(4, 18),
// { from: this._senderAccountAddress, gas: DEFAULT_GAS },
// );
// });

// await Promise.all(mockTokenPromises).then(tokenMocks => {
// _.each(tokenMocks, standardToken => {
// mockTokens.push(new StandardTokenMockContract(
// new web3.eth.Contract(standardToken.abi, standardToken.address),
// { from: this._senderAccountAddress }
// ));
// });
// });

// return mockTokens;
// }
}
6 changes: 1 addition & 5 deletions test-utils/machines/massetMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ import { BigNumber } from "@utils/tools";
import { DEFAULT_DECIMALS, DEFAULT_SUPPLY } from "@utils/constants";
import { Basset, BassetStatus } from "@utils/mstable-objects";

// import {
// MassetContract,
// } from "../contracts";

const MassetArtifact = artifacts.require("Masset");

export class MassetMachine {
Expand Down Expand Up @@ -46,5 +42,5 @@ export class MassetMachine {
status: bArrays[5][i],
};
});
}
};
}
43 changes: 0 additions & 43 deletions test-utils/machines/systemMachine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const NexusArtifact = artifacts.require("NexusMock");

const OracleHubArtifact = artifacts.require("SimpleOracleHubMock");

// const RecollateraliserArtifact = artifacts.require("Recollateraliser");

const SystokArtifact = artifacts.require("SystokMock");

/**
Expand Down Expand Up @@ -106,14 +104,6 @@ export class SystemMachine {
// add module
await this.addModuleToNexus(await this.manager.Key_Manager(), this.manager.address);

/** Recollateraliser */
// this.recollateraliser = await this.deployRecollateraliser();
// // add module
// await this.addModuleToNexus(
// await this.recollateraliser.Key_Recollateraliser(),
// this.recollateraliser.address,
// );

return Promise.resolve(true);
} catch (e) {
console.log(e);
Expand All @@ -128,12 +118,6 @@ export class SystemMachine {
try {
const nexus = await NexusArtifact.new(this.sa.governor, { from: deployer });

// this.nexus = new NexusMockContract(
// mockInstance.address,
// web3.currentProvider,
// this.TX_DEFAULTS,
// );

return nexus;
} catch (e) {
throw e;
Expand All @@ -154,12 +138,6 @@ export class SystemMachine {
{ from: deployer },
);

// this.oracleHub = new SimpleOracleHubMockContract(
// oracleHubInstance.address,
// web3.currentProvider,
// this.TX_DEFAULTS,
// );

return oracleHubInstance;
} catch (e) {
throw e;
Expand All @@ -179,12 +157,6 @@ export class SystemMachine {
},
);

// this.systok = new SystokMockContract(
// mockInstance.address,
// web3.currentProvider,
// this.TX_DEFAULTS,
// );

return systokInstance;
} catch (e) {
throw e;
Expand All @@ -206,12 +178,6 @@ export class SystemMachine {
{ from: this.sa.default },
);

// this.governancePortal = new GovernancePortalMockContract(
// mockInstance.address,
// web3.currentProvider,
// this.TX_DEFAULTS,
// );

return mockInstance;
} catch (e) {
throw e;
Expand All @@ -223,24 +189,15 @@ export class SystemMachine {
*/
public async deployManager(): Promise<ManagerMockInstance> {
try {
// const stableMathInstance = await StableMathArtifact.deployed();
// await ForgeLibArtifact.link(StableMathArtifact, stableMathInstance.address);
const forgeLibInstance = await ForgeLibArtifact.new();

// await ManagerArtifact.link(StableMathArtifact, stableMathInstance.address);

const mockInstance = await ManagerArtifact.new(
this.governancePortal.address,
this.nexus.address,
this.systok.address,
this.oracleHub.address,
forgeLibInstance.address,
);
// this.manager = new ManagerMockContract(
// mockInstance.address,
// web3.currentProvider,
// this.TX_DEFAULTS,
// );

return mockInstance;
} catch (e) {
Expand Down
1 change: 0 additions & 1 deletion truffle-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ module.exports = {
// for more about customizing your Truffle configuration!
migrations_directory: './migrations',
contracts_build_directory: './build',
// test_directory: "transpiled/test",
plugins: ["solidity-coverage"],
networks: {
development: {
Expand Down

0 comments on commit 047dcf9

Please sign in to comment.