Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
Web3 1.0 changes (#230)
Browse files Browse the repository at this point in the history
* Web3 1.0 changes

* Fix up some of the types

* Add changes to contract template for web3 1.0

* Fix contract template and some web3 eth changes to methods

* Allow for more rounding error

* Update some formatting

* Update truffle configs

* Remove unnecessary types-bn causing Buffer type issue

* Bump up version

* Remove unnecessary toString
  • Loading branch information
justinkchen authored and asoong committed Oct 16, 2018
1 parent abb8ece commit 1468207
Show file tree
Hide file tree
Showing 47 changed files with 2,946 additions and 423 deletions.
23 changes: 12 additions & 11 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "set-protocol-contracts",
"version": "0.3.9",
"version": "1.1.0-beta.1",
"description": "Smart contracts for {Set} Protocol",
"main": "dist/artifacts/index.js",
"typings": "dist/typings/artifacts/index.d.ts",
Expand All @@ -26,7 +26,7 @@
"test": "yarn prepare-test && truffle test `find transpiled/test -name '*.spec.js'`",
"test-continuous": "truffle test",
"transpile": "tsc",
"generate-typings": "abi-gen --abis './build/contracts/*.json' --out './types/generated' --template './types/contract_templates/contract.mustache' --partials './types/contract_templates/partials/*.mustache'",
"generate-typings": "set-abi-gen --abis './build/contracts/*.json' --out './types/generated' --template './types/contract_templates/contract.mustache' --partials './types/contract_templates/partials/*.mustache'",
"lint-ts": "tslint -c tslint.json -p tsconfig.json --fix test/**/*.ts utils/**/*.ts",
"lint-sol": "solium -d contracts/",
"lint": "yarn run lint-sol && yarn run lint-ts",
Expand All @@ -43,12 +43,10 @@
"author": "Felix Feng <felix@setprotocol.com>",
"license": "Apache-2.0",
"devDependencies": {
"@0xproject/abi-gen": "1.0.4",
"@0xproject/base-contract": "^1.0.4",
"@0xproject/order-utils": "^1.0.1-rc.3",
"@0xproject/types": "^1.0.1-rc.4",
"@0xproject/typescript-typings": "^1.0.4",
"@0xproject/utils": "^1.0.5",
"@0xproject/utils": "^2.0.2",
"@0xproject/web3-wrapper": "^1.1.2",
"@types/bignumber.js": "^4.0.3",
"@types/fs-extra": "^5.0.0",
Expand All @@ -71,31 +69,34 @@
"import-sort-style-eslint": "^4.2.0",
"json-stable-stringify": "^1.0.1",
"lodash": "^4.17.4",
"set-abi-gen": "1.1.0-beta.1",
"solc": "0.4.24",
"solidity-coverage": "^0.5.5",
"solidity-sha3": "^0.4.1",
"truffle": "4.1.11",
"truffle": "5.0.0-beta.1",
"tslint": "^5.8.0",
"tslint-no-unused-expression-chai": "0.0.3",
"types-bn": "^0.0.1",
"types-ethereumjs-util": "^0.0.5",
"typescript": "^2.9.2",
"web3": "0.20.0"
"typescript": "^3.1.2"
},
"dependencies": {
"bn-chai": "^1.0.1",
"cryptofin-solidity": "^0.0.5",
"eth-gas-reporter": "^0.1.10",
"ethers": "^4.0.5",
"fs-extra": "^5.0.0",
"husky": "^0.14.3",
"lint-staged": "^7.2.0",
"module-alias": "^2.1.0",
"set-protocol-utils": "^0.3.37",
"set-protocol-utils": "^1.0.0-beta.10",
"sol-trace-set": "^0.0.1",
"solium": "^1.1.7",
"tiny-promisify": "^1.0.0",
"truffle-hdwallet-provider": "^0.0.3",
"truffle-hdwallet-provider": "^1.0.0-web3one.0",
"tslint-eslint-rules": "^5.3.1",
"web3-utils": "1.0.0-beta.35",
"web3": "1.0.0-beta.36",
"web3-utils": "1.0.0-beta.36",
"zeppelin-solidity": "^1.10.0"
},
"husky": {
Expand Down
8 changes: 3 additions & 5 deletions test/core/core.spec.ts
Expand Up @@ -6,16 +6,14 @@ import { Address } from 'set-protocol-utils';

import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
TransferProxyContract,
VaultContract,
} from '@utils/contracts';
import { CoreContract, TransferProxyContract, VaultContract } from '@utils/contracts';
import { Blockchain } from '@utils/blockchain';
import { CoreWrapper } from '@utils/coreWrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const blockchain = new Blockchain(web3);
const Core = artifacts.require('Core');
Expand Down
8 changes: 3 additions & 5 deletions test/core/exchange-wrappers/kyberNetworkWrapper.spec.ts
Expand Up @@ -7,21 +7,19 @@ import { Address, Bytes, KyberTrade } from 'set-protocol-utils';

import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
StandardTokenMockContract,
KyberNetworkWrapperContract,
TransferProxyContract
} from '@utils/contracts';
import { StandardTokenMockContract, KyberNetworkWrapperContract, TransferProxyContract } from '@utils/contracts';
import { ether } from '@utils/units';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { ExchangeWrapper } from '@utils/exchangeWrapper';
import { Blockchain } from '@utils/blockchain';
import { DEFAULT_GAS, KYBER_RESERVE_CONFIGURED_RATE, UNLIMITED_ALLOWANCE_IN_BASE_UNITS } from '@utils/constants';
import { expectRevertError } from '@utils/tokenAssertions';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const { SetProtocolTestUtils: SetTestUtils } = setProtocolUtils;
const blockchain = new Blockchain(web3);
Expand Down
Expand Up @@ -15,9 +15,11 @@ import { expectRevertError } from '@utils/tokenAssertions';
import { LibraryMockWrapper } from '@utils/libraryMockWrapper';
import { Blockchain } from '@utils/blockchain';
import { ether } from '@utils/units';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const blockchain = new Blockchain(web3);
Expand Down
2 changes: 2 additions & 0 deletions test/core/exchange-wrappers/takerWalletWrapper.spec.ts
Expand Up @@ -24,9 +24,11 @@ import {
UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
} from '@utils/constants';
import { expectRevertError } from '@utils/tokenAssertions';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { SetProtocolUtils: SetUtils } = setProtocolUtils;
const { expect } = chai;
const blockchain = new Blockchain(web3);
Expand Down
14 changes: 4 additions & 10 deletions test/core/exchange-wrappers/zeroExExchangeWrapper.spec.ts
Expand Up @@ -9,25 +9,19 @@ import { Address, Bytes } from 'set-protocol-utils';

import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
StandardTokenMockContract,
TransferProxyContract,
ZeroExExchangeWrapperContract
} from '@utils/contracts';
import { StandardTokenMockContract, TransferProxyContract, ZeroExExchangeWrapperContract } from '@utils/contracts';
import { expectRevertError } from '@utils/tokenAssertions';
import { Blockchain } from '@utils/blockchain';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { ExchangeWrapper } from '@utils/exchangeWrapper';
import {
DEFAULT_GAS,
UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
ZERO
} from '@utils/constants';
import { DEFAULT_GAS, UNLIMITED_ALLOWANCE_IN_BASE_UNITS, ZERO } from '@utils/constants';
import { ether } from '@utils/units';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setUtils = new SetUtils(web3);
const { expect } = chai;
Expand Down
6 changes: 3 additions & 3 deletions test/core/extensions/coreAccounting.spec.ts
Expand Up @@ -19,19 +19,19 @@ import {
import { assertTokenBalanceAsync, expectRevertError } from '@utils/tokenAssertions';
import { Blockchain } from '@utils/blockchain';
import { CoreWrapper } from '@utils/coreWrapper';
import {
getExpectedTransferLogs,
} from '@utils/contract_logs/core';
import { getExpectedTransferLogs } from '@utils/contract_logs/core';
import {
DEFAULT_GAS,
DEPLOYED_TOKEN_QUANTITY,
UNLIMITED_ALLOWANCE_IN_BASE_UNITS,
ZERO,
} from '@utils/constants';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const StandardTokenMock = artifacts.require('StandardTokenMock');
const { SetProtocolTestUtils: SetTestUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
Expand Down
4 changes: 3 additions & 1 deletion test/core/extensions/coreExchangeDispatcher.spec.ts
Expand Up @@ -13,9 +13,11 @@ import { expectRevertError } from '@utils/tokenAssertions';
import { Blockchain } from '@utils/blockchain';
import { ExchangeRegistered } from '@utils/contract_logs/core';
import { CoreWrapper } from '@utils/coreWrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const Core = artifacts.require('Core');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
Expand Down Expand Up @@ -78,7 +80,7 @@ contract('CoreExchangeDispatcher', accounts => {
expect(exchangeAddress).to.eql(subjectExchangeAddress);
});

it('emits a IssuanceComponentDeposited even for each component deposited', async () => {
it('emits a IssuanceComponentDeposited event for each component deposited', async () => {
const txHash = await subject();
const formattedLogs = await setTestUtils.getLogsFromTxHash(txHash);

Expand Down
4 changes: 3 additions & 1 deletion test/core/extensions/coreFactory.spec.ts
Expand Up @@ -15,9 +15,11 @@ import { extractNewSetTokenAddressFromLogs, SetTokenCreated } from '@utils/contr
import { ONE } from '@utils/constants';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const Core = artifacts.require('Core');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
Expand Down Expand Up @@ -67,7 +69,7 @@ contract('CoreFactory', accounts => {
const asciiSubjectSymbol: string = 'SET';
const subjectName: Bytes = SetUtils.stringToBytes(asciiSubjectName);
const subjectSymbol: Bytes = SetUtils.stringToBytes(asciiSubjectSymbol);
const subjectCallData: Bytes = '';
const subjectCallData: Bytes = '0x0';

beforeEach(async () => {
mockToken = await erc20Wrapper.deployTokenAsync(ownerAccount);
Expand Down
2 changes: 2 additions & 0 deletions test/core/extensions/coreInternal.spec.ts
Expand Up @@ -19,9 +19,11 @@ import { Blockchain } from '@utils/blockchain';
import { STANDARD_NATURAL_UNIT } from '@utils/constants';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const blockchain = new Blockchain(web3);
const Core = artifacts.require('Core');
Expand Down
6 changes: 4 additions & 2 deletions test/core/extensions/coreIssuance.spec.ts
Expand Up @@ -34,9 +34,11 @@ import {
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { RebalancingWrapper } from '@utils/rebalancingWrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const Core = artifacts.require('Core');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
Expand Down Expand Up @@ -143,7 +145,7 @@ contract('CoreIssuance', accounts => {
expect(newBalance).to.be.bignumber.equal(expectedNewBalance);
});

it('emits a IssuanceComponentDeposited even for each component deposited', async () => {
it('emits a IssuanceComponentDeposited event for each component deposited', async () => {
const txHash = await subject();
const formattedLogs = await setTestUtils.getLogsFromTxHash(txHash);

Expand Down Expand Up @@ -417,7 +419,7 @@ contract('CoreIssuance', accounts => {
expect(newBalance).to.be.bignumber.equal(expectedNewBalance);
});

it('emits a IssuanceComponentDeposited even for each component deposited', async () => {
it('emits a IssuanceComponentDeposited event for each component deposited', async () => {
const txHash = await subject();
const formattedLogs = await setTestUtils.getLogsFromTxHash(txHash);

Expand Down
5 changes: 3 additions & 2 deletions test/core/extensions/coreIssuanceOrder.spec.ts
Expand Up @@ -34,9 +34,11 @@ import { ExchangeWrapper } from '@utils/exchangeWrapper';
import { generateOrdersDataWithIncorrectExchange } from '@utils/orders';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const Core = artifacts.require('Core');
const StandardTokenMock = artifacts.require('StandardTokenMock');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
Expand Down Expand Up @@ -393,7 +395,7 @@ contract('CoreIssuanceOrder', accounts => {
const expectedNewBalance = existingBalance.sub(issuanceOrder.makerTokenAmount.div(2))
.add(kyberTradeMakerTokenChange);
const newBalance = await makerToken.balanceOf.callAsync(issuanceOrderMaker);
await expect(newBalance.toPrecision(27)).to.be.bignumber.equal(expectedNewBalance.toPrecision(27));
await expect(newBalance.toPrecision(26)).to.be.bignumber.equal(expectedNewBalance.toPrecision(26));
});

it('transfers the remaining maker tokens to the taker', async () => {
Expand Down Expand Up @@ -883,7 +885,6 @@ contract('CoreIssuanceOrder', accounts => {

it('emits correct LogCancel event', async () => {
const txHash = await subject();

const formattedLogs = await setTestUtils.getLogsFromTxHash(txHash);
const expectedLogs = getExpectedCancelLog(
setToken.address,
Expand Down
2 changes: 2 additions & 0 deletions test/core/extensions/coreIssuanceOrderScenarios.spec.ts
Expand Up @@ -28,9 +28,11 @@ import { generateFillOrderParameters, generateOrdersDataWithTakerOrders } from '
import { getExpectedFillLog } from '@utils/contract_logs/coreIssuanceOrder';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const Core = artifacts.require('Core');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
Expand Down
8 changes: 3 additions & 5 deletions test/core/extensions/coreRebalanceAuction.spec.ts
Expand Up @@ -19,19 +19,17 @@ import {
VaultContract,
} from '@utils/contracts';
import { ether } from '@utils/units';
import {
DEFAULT_GAS,
ONE_DAY_IN_SECONDS,
DEFAULT_AUCTION_PRICE,
} from '@utils/constants';
import { DEFAULT_GAS, ONE_DAY_IN_SECONDS, DEFAULT_AUCTION_PRICE } from '@utils/constants';
import { expectRevertError } from '@utils/tokenAssertions';
import { Blockchain } from '@utils/blockchain';
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { RebalancingWrapper } from '@utils/rebalancingWrapper';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const CoreMock = artifacts.require('CoreMock');
const RebalancingSetToken = artifacts.require('RebalancingSetToken');
const { expect } = chai;
Expand Down
Expand Up @@ -13,9 +13,11 @@ import { RebalancingWrapper } from '@utils/rebalancingWrapper';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import ChaiSetup from '@utils/chaiSetup';
import { DEFAULT_GAS } from '@utils/constants';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { SetProtocolTestUtils: SetTestUtils } = setProtocolUtils;
const { expect } = chai;

Expand Down Expand Up @@ -88,4 +90,4 @@ contract('LinearAuctionPriceCurve', accounts => {
expect(returnedPrice).to.be.bignumber.equal(expectedPrice);
});
});
});
});
2 changes: 2 additions & 0 deletions test/core/lib/orderLibrary.spec.ts
Expand Up @@ -11,9 +11,11 @@ import { Blockchain } from '@utils/blockchain';
import { ether } from '@utils/units';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import ChaiSetup from '@utils/chaiSetup';
import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const { expect } = chai;
const blockchain = new Blockchain(web3);

Expand Down
5 changes: 3 additions & 2 deletions test/core/rebalancingSetToken.spec.ts
Expand Up @@ -39,10 +39,11 @@ import { expectRevertError, assertTokenBalanceAsync } from '@utils/tokenAssertio
import { CoreWrapper } from '@utils/coreWrapper';
import { ERC20Wrapper } from '@utils/erc20Wrapper';
import { RebalancingWrapper } from '@utils/rebalancingWrapper';

import { getWeb3 } from '@utils/web3Helper';

BigNumberSetup.configure();
ChaiSetup.configure();
const web3 = getWeb3();
const CoreMock = artifacts.require('CoreMock');
const RebalancingSetToken = artifacts.require('RebalancingSetToken');
const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
Expand Down Expand Up @@ -892,7 +893,7 @@ contract('RebalancingSetToken', accounts => {

it('resets the proposalStartTime', async () => {
const oldProposalStartTime = await rebalancingSetToken.proposalStartTime.callAsync();
const minNewProposalStartTime = oldProposalStartTime.add(timeJump);
const minNewProposalStartTime = oldProposalStartTime.add(timeJump);

await subject();
const newProposalStartTime = await rebalancingSetToken.proposalStartTime.callAsync();
Expand Down

0 comments on commit 1468207

Please sign in to comment.