Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"mixedcase": 0,
"no-experimental": 0,
"lbrace": 0,
"max-len": ["error", 100],
"max-len": ["warning", 120],
"indentation": ["error", 4],
"quotes": ["error", "double"],
"arg-overflow": ["warning", 3],
Expand Down
3 changes: 2 additions & 1 deletion contracts/core/Core.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
Copyright 2018 Set Labs Inc.

Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -32,6 +32,7 @@ import { CoreIssuanceOrder } from "./extensions/CoreIssuanceOrder.sol";
* The Core contract acts as a coordinator handling issuing, redeeming, and
* creating Sets, as well as all collateral flows throughout the system.
*/
/* solium-disable-next-line no-empty-blocks */
contract Core is
CoreExchangeDispatcher,
CoreIssuanceOrder,
Expand Down
1 change: 1 addition & 0 deletions contracts/core/SetToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ contract SetToken is
);

// Figure out which of the components has the minimum decimal value
/* solium-disable-next-line security/no-low-level-calls */
if (currentComponent.call(bytes4(keccak256("decimals()")))) {
currentDecimals = DetailedERC20(currentComponent).decimals();
minDecimals = currentDecimals < minDecimals ? currentDecimals : minDecimals;
Expand Down
10 changes: 6 additions & 4 deletions contracts/core/exchange-wrappers/ZeroExExchangeWrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ contract ZeroExExchangeWrapper
SET_PROXY = _setProxy;
}


/* ============ Public Functions ============ */


Expand All @@ -82,7 +81,7 @@ contract ZeroExExchangeWrapper
/* ============ Getters ============ */

/* ============ Private ============ */

function fillZeroExOrder(
bytes _zeroExOrderData
)
Expand All @@ -95,14 +94,17 @@ contract ZeroExExchangeWrapper

// Ensure the maker token is allowed to be approved to the ZeroEx proxy


ZeroExFillResults.FillResults memory fillResults =
// TODO: Still being handled in Felix's PR
/* solium-disable-next-line operator-whitespace */
ZeroExFillResults.FillResults memory fillResults =
ZeroExExchange(ZERO_EX_EXCHANGE).fillOrKillOrder(
order,
fillAmount,
signature
);

// Temporary to satisfy Solium
return fillResults;
// Ensure the taker token is allowed to be approved to the TransferProxy
}
}
1 change: 1 addition & 0 deletions contracts/lib/ERC20Wrapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ library ERC20Wrapper {
// ============ Constants ============

string constant INVALID_RETURN_TRANSFER = "Transferred token does not return null or true on successful transfer.";
/* solium-disable-next-line max-len */
string constant INVALID_RETURN_TRANSFERFROM = "Transferred token does not return null or true on successful transferFrom.";
string constant INVALID_RETURN_APPROVE = "Approved token does not return null or true on successful approve.";

Expand Down
24 changes: 23 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
"chain": "yarn clean-chain && ganache-cli --db blockchain --networkId 50 --accounts 20 -l 10000000 -e 1000000 -m 'concert load couple harbor equip island argue ramp clarify fence smart topic'",
"coverage-setup": "cp -r transpiled/test/* test/. && cp -r transpiled/types/* types/. && cp -r transpiled/utils/* utils/.",
"coverage-cleanup": "find test -name \\*.js* -type f -delete && find types -name \\*.js* -type f -delete && find utils -name \\*.js* -type f -delete",
"coverage": "yarn coverage-setup && ./node_modules/.bin/solidity-coverage && yarn coverage-cleanup"
"coverage": "yarn coverage-setup && ./node_modules/.bin/solidity-coverage && yarn coverage-cleanup",
"precommit": "lint-staged"
},
"repository": "git@github.com:SetProtocol/set-protocol-contracts.git",
"author": "Felix Feng <felix@setprotocol.com>",
Expand Down Expand Up @@ -78,6 +79,8 @@
},
"dependencies": {
"fs-extra": "^5.0.0",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"openzeppelin-zos": "^1.9.1",
"sol-trace-set": "^0.0.1",
"solium": "^1.1.7",
Expand All @@ -86,5 +89,24 @@
"tslint-eslint-rules": "^5.3.1",
"zeppelin-solidity": "^1.10.0",
"zos-lib": "^1.0.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"contracts/**/*.sol": [
"yarn lint-sol --fix",
"git add"
],
"test/**/*.ts": [
"yarn lint-ts --fix",
"git add"
],
"utils/**/*.ts": [
"yarn lint-ts --fix",
"git add"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import * as chai from 'chai';
import * as _ from 'lodash';
import * as ethUtil from 'ethereumjs-util';

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';

// Types
Expand Down Expand Up @@ -32,7 +29,7 @@ import { BigNumberSetup } from '../../../../../utils/bigNumberSetup';
import ChaiSetup from '../../../../../utils/chaiSetup';
BigNumberSetup.configure();
ChaiSetup.configure();
const { expect, assert } = chai;
const { expect } = chai;

import {
expectRevertError,
Expand Down
20 changes: 11 additions & 9 deletions test/contracts/core/exchange-wrappers/takerWalletWrapper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import * as chai from 'chai';
import * as _ from 'lodash';
import * as ethUtil from 'ethereumjs-util';

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';

// Types
Expand All @@ -24,7 +22,7 @@ import { BigNumberSetup } from '../../../../utils/bigNumberSetup';
import ChaiSetup from '../../../../utils/chaiSetup';
BigNumberSetup.configure();
ChaiSetup.configure();
const { expect, assert } = chai;
const { expect } = chai;

import {
DEFAULT_GAS,
Expand All @@ -40,7 +38,6 @@ import {
contract('TakerWalletWrapper', accounts => {
const [
deployerAccount,
issuerAccount,
takerAccount,
authorizedAddress,
unauthorizedAddress,
Expand Down Expand Up @@ -116,12 +113,14 @@ contract('TakerWalletWrapper', accounts => {
});

it('approves the tokens for transfer to the transferProxy with unlimited allowance', async () => {
const existingAllowance = await componentToken.allowance.callAsync(takerWalletWrapper.address, transferProxy.address);
const existingAllowance =
await componentToken.allowance.callAsync(takerWalletWrapper.address, transferProxy.address);

await subject();

const expectedNewAllowance = existingAllowance.add(UNLIMITED_ALLOWANCE_IN_BASE_UNITS);
const newBalance = await componentToken.allowance.callAsync(takerWalletWrapper.address, transferProxy.address);
const newBalance =
await componentToken.allowance.callAsync(takerWalletWrapper.address, transferProxy.address);
expect(newBalance).to.be.bignumber.equal(expectedNewAllowance);
});

Expand Down Expand Up @@ -161,12 +160,15 @@ contract('TakerWalletWrapper', accounts => {
});

it('approves the tokens for transfer to the transferProxy with unlimited allowance', async () => {
const existingAllowances = await erc20Wrapper.getTokenAllowances(components, takerWalletWrapper.address, transferProxy.address);
const existingAllowances =
await erc20Wrapper.getTokenAllowances(components, takerWalletWrapper.address, transferProxy.address);

await subject();

const expectedNewAllowances = _.map(existingAllowances, allowance => allowance.add(UNLIMITED_ALLOWANCE_IN_BASE_UNITS));
const newAllowances = await erc20Wrapper.getTokenAllowances(components, takerWalletWrapper.address, transferProxy.address);
const expectedNewAllowances =
_.map(existingAllowances, allowance => allowance.add(UNLIMITED_ALLOWANCE_IN_BASE_UNITS));
const newAllowances =
await erc20Wrapper.getTokenAllowances(components, takerWalletWrapper.address, transferProxy.address);
expect(newAllowances).to.eql(expectedNewAllowances);
});
});
Expand Down
31 changes: 16 additions & 15 deletions test/contracts/core/exchange-wrappers/zeroExExchangeWrapper.spec.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,37 @@
import * as chai from 'chai';
import * as _ from 'lodash';
import * as ethUtil from 'ethereumjs-util';
/* tslint:disable */
import * as chai from "chai";
import * as _ from "lodash";
import * as ethUtil from "ethereumjs-util";

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';
import * as ABIDecoder from "abi-decoder";
import { BigNumber } from "bignumber.js";

// Types
import { Address, Bytes32, Log, UInt } from '../../../../types/common.js';
import { ZeroExOrderHeader, ZeroExOrder } from '../../../../types/zeroEx';
import { Address, Bytes32, Log, UInt } from "../../../../types/common.js";
import { ZeroExOrderHeader, ZeroExOrder } from "../../../../types/zeroEx";

// Contract types
import { ZeroExExchangeWrapperContract } from '../../../../types/generated/zero_ex_exchange_wrapper';
import { ZeroExExchangeWrapperContract } from "../../../../types/generated/zero_ex_exchange_wrapper";

// Artifacts
const ZeroExExchangeWrapper = artifacts.require('ZeroExExchangeWrapper');
const ZeroExExchangeWrapper = artifacts.require("ZeroExExchangeWrapper");

import {
createZeroExOrder,
} from '../../../../utils/zeroExExchangeWrapper';
} from "../../../../utils/zeroExExchangeWrapper";

// Testing Set up
import { BigNumberSetup } from '../../../../utils/bigNumberSetup';
import ChaiSetup from '../../../../utils/chaiSetup';
import { BigNumberSetup } from "../../../../utils/bigNumberSetup";
import ChaiSetup from "../../../../utils/chaiSetup";
BigNumberSetup.configure();
ChaiSetup.configure();
const { expect, assert } = chai;

import {
DEFAULT_GAS,
} from '../../../../utils/constants';
} from "../../../../utils/constants";

contract('ZeroExExchangeWrapper', accounts => {
contract("ZeroExExchangeWrapper", (accounts) => {
const [ownerAccount, takerAddress, feeRecipientAddress, senderAddress] = accounts;
let zeroExExchangeWrapper: ZeroExExchangeWrapperContract;

Expand All @@ -45,7 +46,7 @@ contract('ZeroExExchangeWrapper', accounts => {
);
});

describe('#exchange', async () => {
describe("#exchange", async () => {
// Deploy a mock 0x exchange
// Deploy a mock 0x proxy
});
Expand Down
16 changes: 6 additions & 10 deletions test/contracts/core/extensions/coreAccounting.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import * as chai from 'chai';
import * as _ from 'lodash';

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';

// Types
import { Address } from '../../../../types/common.js';

// Contract types
import { AuthorizableContract } from '../../../../types/generated/authorizable';
import { CoreContract } from '../../../../types/generated/core';
import { SetTokenContract } from '../../../../types/generated/set_token';
import { SetTokenFactoryContract } from '../../../../types/generated/set_token_factory';
import { StandardTokenMockContract } from '../../../../types/generated/standard_token_mock';
import { TransferProxyContract } from '../../../../types/generated/transfer_proxy';
Expand All @@ -25,7 +22,7 @@ import { BigNumberSetup } from '../../../../utils/bigNumberSetup';
import ChaiSetup from '../../../../utils/chaiSetup';
BigNumberSetup.configure();
ChaiSetup.configure();
const { expect, assert } = chai;
const { expect } = chai;

import {
assertTokenBalance,
Expand All @@ -41,7 +38,6 @@ contract('CoreAccounting', accounts => {
const [
ownerAccount,
otherAccount,
unauthorizedAccount,
] = accounts;

let core: CoreContract;
Expand Down Expand Up @@ -97,7 +93,7 @@ contract('CoreAccounting', accounts => {
await subject();

const newVaultBalance = existingVaultTokenBalance.add(amountToDeposit);
assertTokenBalance(mockToken, amountToDeposit, vault.address);
assertTokenBalance(mockToken, newVaultBalance, vault.address);
});

it('increments the vault balance of the token of the owner by the correct amount', async () => {
Expand Down Expand Up @@ -253,8 +249,8 @@ contract('CoreAccounting', accounts => {
});

afterEach(async () => {
tokenAddresses = null;
amountsToDeposit = null;
tokenAddresses = undefined;
amountsToDeposit = undefined;
});

let tokenAddresses: Address[];
Expand Down Expand Up @@ -389,8 +385,8 @@ contract('CoreAccounting', accounts => {
});

afterEach(async () => {
tokenAddresses = null;
amountsToWithdraw = null;
tokenAddresses = undefined;
amountsToWithdraw = undefined;
});

let tokenAddresses: Address[];
Expand Down
11 changes: 4 additions & 7 deletions test/contracts/core/extensions/coreExchangeDispatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import * as chai from 'chai';
import * as _ from 'lodash';

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';
import { ether } from '../../../../utils/units';

// Types
import { Address, Log, UInt } from '../../../../types/common.js';
import { Address, Log } from '../../../../types/common.js';

// Contract types
import { CoreContract } from '../../../../types/generated/core';
Expand All @@ -16,7 +14,6 @@ const Core = artifacts.require('Core');

// Core wrapper
import { CoreWrapper } from '../../../../utils/coreWrapper';
import { ERC20Wrapper } from '../../../../utils/erc20Wrapper';

// Testing Set up
import { BigNumberSetup } from '../../../../utils/bigNumberSetup';
Expand Down Expand Up @@ -64,12 +61,12 @@ contract('CoreExchangeDispatcher', accounts => {

describe('#registerExchange', async () => {
let subjectCaller: Address;
let subjectExchangeId: UInt;
let subjectExchangeId: BigNumber;
let subjectExchangeAddress: Address;

beforeEach(async () => {
subjectCaller = ownerAccount;
subjectExchangeId = EXCHANGES.ZERO_EX;
subjectExchangeId = new BigNumber(EXCHANGES.ZERO_EX);
subjectExchangeAddress = zeroExWrapperAddress;
});

Expand All @@ -95,7 +92,7 @@ contract('CoreExchangeDispatcher', accounts => {
const expectedLogs: Log[] = [
ExchangeRegistered(
core.address,
new BigNumber(subjectExchangeId),
subjectExchangeId,
subjectExchangeAddress,
),
];
Expand Down
4 changes: 0 additions & 4 deletions test/contracts/core/extensions/coreFactory.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import * as chai from 'chai';
import * as _ from 'lodash';

import * as ABIDecoder from 'abi-decoder';
import { BigNumber } from 'bignumber.js';
import { ether } from '../../../../utils/units';

// Types
import { Address, Log } from '../../../../types/common.js';

// Contract types
import { CoreContract } from '../../../../types/generated/core';
import { SetTokenContract } from '../../../../types/generated/set_token';
import { SetTokenFactoryContract } from '../../../../types/generated/set_token_factory';
import { StandardTokenMockContract } from '../../../../types/generated/standard_token_mock';

Expand Down Expand Up @@ -50,7 +47,6 @@ import {
contract('CoreFactory', accounts => {
const [
ownerAccount,
otherAccount,
] = accounts;

let core: CoreContract;
Expand Down
Loading