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 7 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
13 changes: 4 additions & 9 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"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 --stream",
"pretest": "npm run ganache:stop && npm run ganache:start && npm run truffle:migrate",
"test": "npx lerna run test --scope tasit-account --stream && npx lerna run test --scope tasit-action --stream && npx lerna run test --scope tasit-contracts --stream && npx lerna run test --scope tasit-identity-contract --stream && npx lerna run test --scope tasit-sdk --stream",
"test": "npx lerna run test --stream --concurrency 1",
"posttest": "npm run ganache:stop"
},
"repository": {
Expand Down
10 changes: 5 additions & 5 deletions packages/tasit-action/src/TasitAction.js
Original file line number Diff line number Diff line change
@@ -1,16 +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 DetailedERC20 from "./erc20/DetailedERC20";
import ERC20Detailed from "./erc20/ERC20Detailed";

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

export const ERC20 = { Mana, DetailedERC20 };
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
9 changes: 0 additions & 9 deletions packages/tasit-action/src/erc20/DetailedERC20.js

This file was deleted.

13 changes: 0 additions & 13 deletions packages/tasit-action/src/erc20/DetailedERC20.test.js

This file was deleted.

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");
});
});
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);
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import NFT from "./NFT";
import ERC721Full from "./ERC721Full";

// Note: Under the current `tasit-contracts` setup FullNFT aways will deployed with this address
// Note: Under the current `tasit-contracts` setup ERC721Full aways will deployed with this address
// See https://github.com/tasitlabs/TasitSDK/issues/138
const fullNFTAddress = "0x0E86f209729bf54763789CDBcA9E8b94f0FD5333";
const ERC721_FULL_ADDRESS = "0x0E86f209729bf54763789CDBcA9E8b94f0FD5333";

// Note: This contract is used not because of the particulars of this contract, but
// just because we needed a contract to send an NFT to and have it fail
// when using safeTransferFrom because this contract doesn't implement
// onERC721Received
const sampleContractAddress = "0x6C4A015797DDDd87866451914eCe1e8b19261931";
const SAMPLE_CONTRACT_ADDRESS = "0x6C4A015797DDDd87866451914eCe1e8b19261931";

describe("TasitAction.ERC721.NFT", () => {
describe("TasitAction.ERC721.ERC721Full", () => {
let owner;
let ana;
let bob;
let fullNFT;
let erc721;

let action;

Expand All @@ -25,20 +25,20 @@ describe("TasitAction.ERC721.NFT", () => {
beforeEach("", async () => {
action = undefined;

fullNFT = new NFT(fullNFTAddress, owner);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, owner);

expect(fullNFT).to.exist;
expect(fullNFT.getAddress()).to.equal(fullNFTAddress);
expect(fullNFT.name).to.exist;
expect(fullNFT.symbol).to.exist;
expect(fullNFT._getProvider()).to.exist;
expect(erc721).to.exist;
expect(erc721.getAddress()).to.equal(ERC721_FULL_ADDRESS);
expect(erc721.name).to.exist;
expect(erc721.symbol).to.exist;
expect(erc721._getProvider()).to.exist;

// This line ensures that a new event listener does not catch an existing event from last the block
// Two blocks to minimize the risk that polling doesn't occur.
await mineBlocks(provider, 2);

await confirmBalances(
fullNFT,
erc721,
[owner.address, ana.address, bob.address],
[0, 0, 0]
);
Expand All @@ -52,13 +52,13 @@ describe("TasitAction.ERC721.NFT", () => {
expect(provider._events, "ethers.js should not be listening to any events.")
.to.be.empty;

if (fullNFT) {
fullNFT.unsubscribe();
if (erc721) {
erc721.unsubscribe();

expect(fullNFT.subscribedEventNames()).to.be.empty;
expect(erc721.subscribedEventNames()).to.be.empty;

expect(
fullNFT.getEmitter()._events,
erc721.getEmitter()._events,
"ethers.js should not be listening to any events."
).to.be.empty;
}
Expand All @@ -75,13 +75,13 @@ describe("TasitAction.ERC721.NFT", () => {
).to.be.empty;
}

if (fullNFT) {
fullNFT.unsubscribe();
if (erc721) {
erc721.unsubscribe();

expect(fullNFT.subscribedEventNames()).to.be.empty;
expect(erc721.subscribedEventNames()).to.be.empty;

expect(
fullNFT.getEmitter()._events,
erc721.getEmitter()._events,
"ethers.js should not be listening to any events."
).to.be.empty;
}
Expand All @@ -102,20 +102,20 @@ describe("TasitAction.ERC721.NFT", () => {
});

it("should call a read-only contract method", async () => {
const name = await fullNFT.name();
const name = await erc721.name();
expect(name).to.exist;
expect(name).to.equal("Full NFT");
expect(name).to.equal("ERC721Full");
});

describe("ERC721 functions", () => {
const tokenId = 1;
const zeroAddress = "0x0000000000000000000000000000000000000000";

beforeEach("should mint one token to ana", async () => {
action = fullNFT.mint(ana.address, tokenId);
action = erc721.mint(ana.address, tokenId);

const event = await new Promise(function(resolve, reject) {
fullNFT.on("Transfer", message => {
erc721.on("Transfer", message => {
const { data } = message;
const { args } = data;
resolve(args);
Expand All @@ -126,24 +126,24 @@ describe("TasitAction.ERC721.NFT", () => {
}, 1000);
});

fullNFT.off("Transfer");
erc721.off("Transfer");

expect(event.from).to.equal(zeroAddress);
expect(event.to).to.equal(ana.address);
expect(event.tokenId.eq(tokenId)).to.be.true;

await confirmBalances(fullNFT, [ana.address], [1]);
await confirmBalances(erc721, [ana.address], [1]);
});

// Non-deterministic
// Note: This test failed recently on CI
it.skip("should transfer an owned token", async () => {
fullNFT = new NFT(fullNFTAddress, ana);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, ana);

action = fullNFT.transferFrom(ana.address, bob.address, tokenId);
action = erc721.transferFrom(ana.address, bob.address, tokenId);

const event = await new Promise(function(resolve, reject) {
fullNFT.on("Transfer", message => {
erc721.on("Transfer", message => {
const { data } = message;
const { args } = data;
resolve(args);
Expand All @@ -158,37 +158,37 @@ describe("TasitAction.ERC721.NFT", () => {
expect(event.to).to.equal(bob.address);
expect(event.tokenId.toNumber()).to.equal(tokenId);

await confirmBalances(fullNFT, [ana.address, bob.address], [0, 1]);
await confirmBalances(erc721, [ana.address, bob.address], [0, 1]);
});

it("should transfer an approved token", async () => {
fullNFT = new NFT(fullNFTAddress, ana);
action = fullNFT.approve(bob.address, tokenId);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, ana);
action = erc721.approve(bob.address, tokenId);

await action.waitForNonceToUpdate();

fullNFT.setWallet(bob);
action = fullNFT.transferFrom(ana.address, bob.address, tokenId);
erc721.setWallet(bob);
action = erc721.transferFrom(ana.address, bob.address, tokenId);

await action.waitForNonceToUpdate();

await confirmBalances(fullNFT, [bob.address], [1]);
await confirmBalances(erc721, [bob.address], [1]);
});

it("should transfer an owned token using safeTransferFrom", async () => {
fullNFT = new NFT(fullNFTAddress, ana);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, ana);

action = fullNFT.safeTransferFrom(ana.address, bob.address, tokenId);
action = erc721.safeTransferFrom(ana.address, bob.address, tokenId);

await action.waitForNonceToUpdate();

await confirmBalances(fullNFT, [ana.address, bob.address], [0, 1]);
await confirmBalances(erc721, [ana.address, bob.address], [0, 1]);
});

it("should trigger an error if the user is listening for errors from a contract and tries safeTransferFrom to a contract without onERC721Received", async () => {
const contractErrorFakeFn = sinon.fake();

fullNFT = new NFT(fullNFTAddress, ana);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, ana);

const contractErrorListener = message => {
const { error } = message;
Expand All @@ -198,28 +198,28 @@ describe("TasitAction.ERC721.NFT", () => {
contractErrorFakeFn();
};

fullNFT.on("error", contractErrorListener);
erc721.on("error", contractErrorListener);

action = fullNFT.safeTransferFrom(
action = erc721.safeTransferFrom(
ana.address,
sampleContractAddress,
SAMPLE_CONTRACT_ADDRESS,
tokenId
);
await action.waitForNonceToUpdate();

expect(contractErrorFakeFn.called).to.be.true;

await confirmBalances(
fullNFT,
[ana.address, sampleContractAddress],
erc721,
[ana.address, SAMPLE_CONTRACT_ADDRESS],
[1, 0]
);
});

it("should trigger an error if the user is listening for errors for an action and tries safeTransferFrom to a contract without onERC721Received", async () => {
const actionErrorFakeFn = sinon.fake();

fullNFT = new NFT(fullNFTAddress, ana);
erc721 = new ERC721Full(ERC721_FULL_ADDRESS, ana);

const actionErrorListener = message => {
const { error } = message;
Expand All @@ -229,9 +229,9 @@ describe("TasitAction.ERC721.NFT", () => {
actionErrorFakeFn();
};

action = fullNFT.safeTransferFrom(
action = erc721.safeTransferFrom(
ana.address,
sampleContractAddress,
SAMPLE_CONTRACT_ADDRESS,
tokenId
);
action.on("error", actionErrorListener);
Expand All @@ -241,8 +241,8 @@ describe("TasitAction.ERC721.NFT", () => {
expect(actionErrorFakeFn.called).to.be.true;

await confirmBalances(
fullNFT,
[ana.address, sampleContractAddress],
erc721,
[ana.address, SAMPLE_CONTRACT_ADDRESS],
[1, 0]
);
});
Expand Down
9 changes: 0 additions & 9 deletions packages/tasit-action/src/erc721/NFT.js

This file was deleted.

Loading