Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gnosis Safe bootstrap #217

Merged
merged 49 commits into from
Feb 28, 2019
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
74c7817
Add Gnosis Safe contracts repository
marcelomorgado Feb 18, 2019
60bc0b8
Move 3rd-parties to a properly directory
marcelomorgado Feb 18, 2019
e933ed7
Third parties scripts refactoring
marcelomorgado Feb 18, 2019
32373e7
GnosisSafe basic test suite
marcelomorgado Feb 18, 2019
c3e2ef2
GnosisSafe deposit test case
marcelomorgado Feb 18, 2019
b810dbd
Dry tasit-contract GnosisSafe test suite (move test cases to tasit-id…
marcelomorgado Feb 19, 2019
aac6710
Renaming GnosisSafe test suite file
marcelomorgado Feb 19, 2019
c6cfd20
Bootstraping tasit-identity-contract
marcelomorgado Feb 19, 2019
be5e2be
Transfer/Withdraw ethers test case
marcelomorgado Feb 25, 2019
88a8c91
Merge branch 'develop' into feature/gnosis-safe
marcelomorgado Feb 25, 2019
13ee3f2
Add decentraland repositories
marcelomorgado Feb 25, 2019
85eded4
Transfer/Withdraw ERC20 test case
marcelomorgado Feb 25, 2019
4060c24
Refactoring ERC20 transfer implementation
marcelomorgado Feb 25, 2019
324514a
Refactoring
marcelomorgado Feb 26, 2019
42861c9
Test case with dispatch simulation (without waiting)
marcelomorgado Feb 26, 2019
67e0d66
Initial test cases for Gnosis Safe on identity-contract package
marcelomorgado Feb 27, 2019
20cf5e4
Move unit test helpers to tasit-action
marcelomorgado Feb 27, 2019
2885b14
Refactoring tasit-action test suites to use global hooks
marcelomorgado Feb 27, 2019
71fd4f2
Refactoring tasit-account test suites to use global hooks
marcelomorgado Feb 27, 2019
7b7f929
Refactoring tasit-identity-contract test suites to use global hooks
marcelomorgado Feb 27, 2019
efac39a
Forcing blockchain state reversion between test cases & suites
marcelomorgado Feb 27, 2019
419829a
Dry ropsten test suite
marcelomorgado Feb 27, 2019
d5abde3
Comment extra gas usage
marcelomorgado Feb 27, 2019
8ba8af5
Move accounts creation to helper
marcelomorgado Feb 27, 2019
9b8697e
Change Gnosis Safe owner
marcelomorgado Feb 28, 2019
cfa2d41
Fix test suite
marcelomorgado Feb 28, 2019
1518352
resolve conflict
marcelomorgado Feb 28, 2019
e4b2423
Resolving conflict
marcelomorgado Feb 28, 2019
ec6caa0
Merge branch 'develop' into feature/gnosis-safe
marcelomorgado Feb 28, 2019
92ab120
Mocha update
marcelomorgado Feb 28, 2019
d538b28
Returning with --no-timeouts option to tasit-sdk test suite script
marcelomorgado Feb 28, 2019
e23cb53
Fixing comment grammar
marcelomorgado Feb 28, 2019
4534eb0
Renaming ERC20 and ERC721 contracts files
marcelomorgado Feb 28, 2019
5a550d9
Renaming ERC20 and ERC721
marcelomorgado Feb 28, 2019
56ef03a
Disable parallelism from lerna test script
marcelomorgado Feb 28, 2019
96e7f84
Refactoring
marcelomorgado Feb 28, 2019
c02d296
Update package-lock.json
marcelomorgado Feb 28, 2019
b0015a8
Move test tasit-action config to helper
marcelomorgado Feb 28, 2019
97899b6
Using another account to send funds to the safe instead of the same a…
marcelomorgado Feb 28, 2019
6e41ca8
Add tasit-contracts/build folder removal to clean:all script
marcelomorgado Feb 28, 2019
34464ad
Renaming ERC20/ERC721 files - tasit-contract
marcelomorgado Feb 28, 2019
bc984bf
Renaming ERC20/ERC721 - tasit-contracts
marcelomorgado Feb 28, 2019
b043fcf
Renaming ERC20/ERC721 files - tasit-action
marcelomorgado Feb 28, 2019
373a720
Renaming ERC20/ERC721 - tasit-action
marcelomorgado Feb 28, 2019
52e3623
Renaming ERC20/ERC721 - tasit-identity-contract
marcelomorgado Feb 28, 2019
59e65b0
Refactoring
marcelomorgado Feb 28, 2019
b9d4323
Renaming some GnosisSafe test cases descriptions
marcelomorgado Feb 28, 2019
f5ead9a
CI fix
marcelomorgado Feb 28, 2019
b929ebd
GnosisSafe.setSigners()
marcelomorgado Feb 28, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
"publish": "npm run clean:all && npm run bootstrap && npm test && npm run clean:3rd-parties && npx lerna publish",
"bootstrap": "npx lerna bootstrap --hoist",
"ganache:start:ropsten": "npx ganache-cli --fork https://ropsten.infura.io/latest --blockTime 0.1 -m 'beach swap combine paper music cook electric bullet trust actress liquid asthma' --gasLimit 1000000000000 --host 0.0.0.0 > /dev/null 2>&1 &",
"ganache:start": "npx ganache-cli -m 'beach swap combine paper music cook electric bullet trust actress liquid asthma' --gasLimit 1000000000 --host 0.0.0.0 > /dev/null 2>&1 &",
"ganache:start": "npx ganache-cli --noVMErrorsOnRPCResponse true -m 'beach swap combine paper music cook electric bullet trust actress liquid asthma' --gasLimit 1000000000 --host 0.0.0.0 > /dev/null 2>&1 &",
pcowgill marked this conversation as resolved.
Show resolved Hide resolved
"ganache:stop": "kill `ps ax|grep ganache-cli|grep -v grep| awk '{print $1}'` 2> /dev/null; exit 0",
"truffle:migrate": "npx lerna run migrate --scope tasit-contracts",
"truffle:migrate": "npx lerna run migrate --scope tasit-contracts --stream",
"pretest": "npm run ganache:stop && npm run ganache:start && npm run truffle:migrate",
"test": "npx lerna run test",
"test": "npx lerna run test --stream --concurrency 1",
"posttest": "npm run ganache:stop"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/tasit-account/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"scripts": {
"prepare": "npx babel src --out-dir dist --ignore **/*.test.js",
"test": "npm run lint && npx mocha src/*.test.js --require @babel/register",
"test": "npm run lint && npx mocha src/*.test.js --require @babel/register --file src/testHelpers/mochaSetup.js",
"lint": "npx prettier src/* --write"
},
"bugs": {
Expand All @@ -34,6 +34,6 @@
"@babel/preset-env": "^7.1.6",
"@babel/register": "^7.0.0",
"chai": "^4.2.0",
"mocha": "^6.0.1"
"mocha": "^6.0.2"
}
}
4 changes: 4 additions & 0 deletions packages/tasit-account/src/TasitAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import "ethers/dist/shims.js";
// shims aren't injected with package import
import { ethers } from "ethers";

// Account creates an ethres.js Wallet, should it create an Account object that encapsulates the wallet?
pcowgill marked this conversation as resolved.
Show resolved Hide resolved
// TasitAcount.create()
// > Acount { wallet: ..., metaTxInfos..., etc }
// Related to: https://github.com/tasitlabs/TasitSDK/issues/220
const create = () => {
try {
const wallet = ethers.Wallet.createRandom();
Expand Down
17 changes: 6 additions & 11 deletions packages/tasit-account/src/ethers.test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { expect, assert } from "chai";
import { ethers } from "ethers";

const zero = ethers.utils.bigNumberify(0);
const { ZERO } = constants;

let wallet, provider;
let wallet;

// Note: We're intentionally not testing the `fromEncryptedJson` or `encrypt` functions
// from `ethers.js` because we don't plan to expose that functionality in the Tasit SDK.
// For a detailed explanation of why, see this GitHub issue:
// https://github.com/tasitlabs/TasitSDK/issues/24#issuecomment-443576993
describe("ethers.js", () => {
beforeEach("instantiate wallet and provider objects", async function() {
provider = new ethers.providers.JsonRpcProvider();
provider.pollingInterval = 50;
beforeEach("instantiate wallet and provider objects", async () => {
[wallet] = accounts;
wallet = wallet.connect(provider);

const privateKey =
"0x11d943d7649fbdeb146dc57bd9cfc80b086bfab2330c7b25651dbaf382392f60";

wallet = new ethers.Wallet(privateKey, provider);
expect(wallet.address).to.have.lengthOf(42);
expect(wallet.provider).to.be.not.undefined;
});
Expand All @@ -39,7 +34,7 @@ describe("ethers.js", () => {
);

expect(fundedWalletBalance).not.to.be.undefined;
assert(emptyWalletBalance.eq(zero));
expect(`${emptyWalletBalance}`).to.equal(`${ZERO}`);
});

it("should sign a message", async () => {
Expand Down
35 changes: 35 additions & 0 deletions packages/tasit-account/src/testHelpers/mochaSetup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { ethers } from "ethers";

// Chai
import { expect, assert } from "chai";
global.expect = expect;
//global.assert = assert;

// Helpers
import actionHelpers from "../../../tasit-action/dist/testHelpers/helpers";
global = Object.assign(global, actionHelpers);

// Global hooks
let snapshotId;

beforeEach("global beforeEach() hook", async () => {
const provider = new ethers.providers.JsonRpcProvider();
provider.pollingInterval = 50;
global.provider = provider;
snapshotId = await createSnapshot(provider);

while (snapshotId > 1) {
await revertFromSnapshot(provider, snapshotId--);
}

expect(snapshotId).to.equal(1);
});

afterEach("global afterEach() hook", async () => {
expect(snapshotId).to.equal(1);
await revertFromSnapshot(provider, snapshotId);

// Note: Without this the test suite is breaking.
// It is still unclear why
await mineBlocks(provider, 1);
});
6 changes: 2 additions & 4 deletions packages/tasit-action/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"scripts": {
"prepare": "rm -rf dist/* && npx babel src --out-dir dist --ignore src/*.test.js,src/**/*.test.js",
"test": "npm run lint && npx mocha \"src/**/*.test.js\" --recursive --require @babel/register --require src/testHelpers/mochaSetup.js --no-timeouts",
"test": "npm run lint && npx mocha \"src/**/*.test.js\" --recursive --require @babel/register --file src/testHelpers/mochaSetup.js",
"lint": "npx prettier src/* --write"
},
"bugs": {
Expand All @@ -34,11 +34,9 @@
"@babel/plugin-proposal-class-properties": "^7.2.3",
"@babel/preset-env": "^7.1.6",
"@babel/register": "^7.0.0",
"bn.js": "^4.11.8",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-bn": "^0.1.1",
"mocha": "^6.0.1",
"mocha": "^6.0.2",
"sinon": "^7.2.2",
"tasit-account": "^0.0.9"
}
Expand Down
9 changes: 5 additions & 4 deletions packages/tasit-action/src/TasitAction.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import ConfigLoader from "./ConfigLoader";
import Contract from "./contract/Contract";
import NFT from "./erc721/NFT";
import ERC721Full from "./erc721/ERC721Full";
import Land from "./erc721/Land";
import Decentraland from "./marketplace/Decentraland";
import Estate from "./erc721/Estate";
import Mana from "./erc20/Mana";
import ERC20Detailed from "./erc20/ERC20Detailed";

export { Contract, NFT, Land, Decentraland, Estate, Mana };
export { Contract, ERC721Full, Land, Decentraland, Estate, Mana };

export const ERC20 = { Mana };
export const ERC721 = { Land, Estate, NFT };
export const ERC20 = { Mana, ERC20Detailed };
export const ERC721 = { Land, Estate, ERC721Full };
export const Marketplace = { Decentraland };

export const TasitAction = {
Expand Down
4 changes: 4 additions & 0 deletions packages/tasit-action/src/contract/Contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export class Contract extends Subscription {
return this.#ethersContract.address;
};

getABI = () => {
return this.#ethersContract.interface.abi;
};

// For testing purposes
_getProvider = () => {
return this.#provider;
Expand Down
21 changes: 2 additions & 19 deletions packages/tasit-action/src/contract/Contract.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import Contract from "./Contract";
import Account from "tasit-account";

// Note: SampleContract.json is originally generated by `tasit-contracts` and was pasted here manually
// See https://github.com/tasitlabs/TasitSDK/issues/45
import { abi as contractABI } from "../../../tasit-contracts/build/contracts/SampleContract.json";

// Note: Under the current `tasit-contracts` setup SampleContract aways will deployed with this address
pcowgill marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -12,8 +10,6 @@ const sampleContractAddress = "0x6C4A015797DDDd87866451914eCe1e8b19261931";
describe("TasitAction.Contract", () => {
let sampleContract;
let wallet;
let testcaseSnaphotId;
let provider;
let action;

beforeEach("should connect to an existing contract", async () => {
Expand All @@ -23,31 +19,20 @@ describe("TasitAction.Contract", () => {

sampleContract = undefined;
wallet = undefined;
testcaseSnaphotId = undefined;
provider = undefined;
action = undefined;

// Account creates a wallet, should it create an account object that encapsulates the wallet?
// TasitAcount.create()
// > Acount { wallet: ..., metaTxInfos..., etc }
wallet = createFromPrivateKey(
"0x11d943d7649fbdeb146dc57bd9cfc80b086bfab2330c7b25651dbaf382392f60"
);
[wallet] = accounts;

sampleContract = new Contract(sampleContractAddress, contractABI);
expect(sampleContract).to.exist;
expect(sampleContract.getAddress()).to.equal(sampleContractAddress);
expect(sampleContract.getValue).to.exist;
expect(sampleContract.setValue).to.exist;
expect(sampleContract._getProvider()).to.exist;

provider = sampleContract._getProvider();
testcaseSnaphotId = await createSnapshot(provider);
expect(sampleContract.getABI()).to.deep.equal(contractABI);
});

afterEach("revert blockchain snapshot", async () => {
await mineBlocks(provider, 1);

if (sampleContract) {
sampleContract.unsubscribe();

Expand All @@ -66,8 +51,6 @@ describe("TasitAction.Contract", () => {
"ethers.js should not be listening to any events."
).to.be.empty;
}

await revertFromSnapshot(provider, testcaseSnaphotId);
});

describe("should throw error when instantiated with invalid args", () => {
Expand Down
8 changes: 8 additions & 0 deletions packages/tasit-action/src/erc20/ERC20Detailed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Contract from "../contract/Contract";
import abi from "../../../tasit-contracts/abi/ERC20Detailed.json";

export default class ERC20Detailed extends Contract {
constructor(address, wallet) {
super(address, abi, wallet);
}
}
13 changes: 13 additions & 0 deletions packages/tasit-action/src/erc20/ERC20Detailed.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ERC20Detailed from "./ERC20Detailed";

// Note: Under the current `tasit-contracts` setup ERC20Detailed aways will deployed with this address
// See https://github.com/tasitlabs/TasitSDK/issues/138
const ERC20_DETAILED_ADDRESS = "0x37E1A58dD465D33263D00185D065Ee36DD34CDb4";

describe("TasitAction.ERC20.ERC20Detailed", () => {
it("should get the ERC20Detailed name", async () => {
const erc20 = new ERC20Detailed(ERC20_DETAILED_ADDRESS);
const name = await erc20.name();
expect(name).to.equal("ERC20Detailed Token");
});
});
4 changes: 2 additions & 2 deletions packages/tasit-action/src/erc20/Mana.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import Mana from "./Mana";

import { local as localAddresses } from "../../../tasit-contracts/decentraland/addresses";
import { local as localAddresses } from "../../../tasit-contracts/3rd-parties/decentraland/addresses";
const { MANAToken: MANA_ADDRESS } = localAddresses;

describe("TasitAction.Decentraland.Mana", () => {
it("should get the MANAToken name", async function() {
it("should get the MANAToken name", async () => {
const mana = new Mana(MANA_ADDRESS);
const name = await mana.name();
expect(name).to.equal("Decentraland MANA");
Expand Down
8 changes: 8 additions & 0 deletions packages/tasit-action/src/erc721/ERC721Full.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Contract from "../contract/Contract";
import abi from "../../../tasit-contracts/abi/ERC721Full.json";

export default class ERC721Full extends Contract {
constructor(address, wallet) {
super(address, abi, wallet);
}
}
Loading