Ran prettier
This commit is contained in:
@@ -16,11 +16,7 @@ describe('LibAddress', () => {
|
|||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
nonContract = (await web3Wrapper.getAvailableAddressesAsync())[0];
|
nonContract = (await web3Wrapper.getAvailableAddressesAsync())[0];
|
||||||
// Deploy LibAddress
|
// Deploy LibAddress
|
||||||
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(
|
lib = await TestLibAddressContract.deployFrom0xArtifactAsync(artifacts.TestLibAddress, provider, txDefaults);
|
||||||
artifacts.TestLibAddress,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
|
@@ -52,12 +52,11 @@ async function testHashEIP712MessageAsync(
|
|||||||
domainHash: string,
|
domainHash: string,
|
||||||
hashStruct: string,
|
hashStruct: string,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const input = '0x1901'.concat(domainHash.slice(2, domainHash.length).concat(hashStruct.slice(2, hashStruct.length)));
|
const input = '0x1901'.concat(
|
||||||
const expectedHash = '0x'.concat(ethUtil.sha3(input).toString('hex'));
|
domainHash.slice(2, domainHash.length).concat(hashStruct.slice(2, hashStruct.length)),
|
||||||
const actualHash = await lib.externalHashEIP712Message.callAsync(
|
|
||||||
domainHash,
|
|
||||||
hashStruct,
|
|
||||||
);
|
);
|
||||||
|
const expectedHash = '0x'.concat(ethUtil.sha3(input).toString('hex'));
|
||||||
|
const actualHash = await lib.externalHashEIP712Message.callAsync(domainHash, hashStruct);
|
||||||
expect(actualHash).to.be.eq(expectedHash);
|
expect(actualHash).to.be.eq(expectedHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,11 +66,7 @@ describe('LibEIP712', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
// Deploy SafeMath
|
// Deploy SafeMath
|
||||||
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(
|
lib = await TestLibEIP712Contract.deployFrom0xArtifactAsync(artifacts.TestLibEIP712, provider, txDefaults);
|
||||||
artifacts.TestLibEIP712,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
@@ -80,13 +75,7 @@ describe('LibEIP712', () => {
|
|||||||
|
|
||||||
describe('_hashEIP712Domain', async () => {
|
describe('_hashEIP712Domain', async () => {
|
||||||
it('should correctly hash empty input', async () => {
|
it('should correctly hash empty input', async () => {
|
||||||
await testHashEIP712DomainAsync(
|
await testHashEIP712DomainAsync(lib, '', '', 0, constants.NULL_ADDRESS);
|
||||||
lib,
|
|
||||||
'',
|
|
||||||
'',
|
|
||||||
0,
|
|
||||||
constants.NULL_ADDRESS,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -97,11 +86,7 @@ describe('LibEIP712', () => {
|
|||||||
const actualHash = await lib.externalHashEIP712Message.callAsync(constants.NULL_BYTES32, constants.NULL_BYTES32);
|
const actualHash = await lib.externalHashEIP712Message.callAsync(constants.NULL_BYTES32, constants.NULL_BYTES32);
|
||||||
expect(actualHash).to.be.eq(expectedHash);
|
expect(actualHash).to.be.eq(expectedHash);
|
||||||
*/
|
*/
|
||||||
await testHashEIP712MessageAsync(
|
await testHashEIP712MessageAsync(lib, constants.NULL_BYTES32, constants.NULL_BYTES32);
|
||||||
lib,
|
|
||||||
constants.NULL_BYTES32,
|
|
||||||
constants.NULL_BYTES32,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -22,11 +22,7 @@ describe('Ownable', () => {
|
|||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
// Deploy SafeMath from the owner address
|
// Deploy SafeMath from the owner address
|
||||||
txDefaults.from = owner;
|
txDefaults.from = owner;
|
||||||
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(
|
ownable = await TestOwnableContract.deployFrom0xArtifactAsync(artifacts.TestOwnable, provider, txDefaults);
|
||||||
artifacts.TestOwnable,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
@@ -36,10 +32,7 @@ describe('Ownable', () => {
|
|||||||
// tslint:disable:no-unused-expression
|
// tslint:disable:no-unused-expression
|
||||||
describe('onlyOwner', () => {
|
describe('onlyOwner', () => {
|
||||||
it('should throw if sender is not owner', async () => {
|
it('should throw if sender is not owner', async () => {
|
||||||
const expectedError = new OwnableRevertErrors.OnlyOwnerError(
|
const expectedError = new OwnableRevertErrors.OnlyOwnerError(nonOwner, owner);
|
||||||
nonOwner,
|
|
||||||
owner,
|
|
||||||
);
|
|
||||||
return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError);
|
return expect(ownable.externalOnlyOwner.callAsync({ from: nonOwner })).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -50,7 +43,8 @@ describe('Ownable', () => {
|
|||||||
|
|
||||||
describe('transferOwnership', () => {
|
describe('transferOwnership', () => {
|
||||||
it('should not transfer ownership if the specified new owner is the zero address', async () => {
|
it('should not transfer ownership if the specified new owner is the zero address', async () => {
|
||||||
expect(ownable.transferOwnership.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner })).to.be.fulfilled;
|
expect(ownable.transferOwnership.sendTransactionAsync(constants.NULL_ADDRESS, { from: owner })).to.be
|
||||||
|
.fulfilled;
|
||||||
const updatedOwner = await ownable.owner.callAsync();
|
const updatedOwner = await ownable.owner.callAsync();
|
||||||
expect(updatedOwner).to.be.eq(owner);
|
expect(updatedOwner).to.be.eq(owner);
|
||||||
});
|
});
|
||||||
|
@@ -20,11 +20,7 @@ describe('SafeMath', () => {
|
|||||||
before(async () => {
|
before(async () => {
|
||||||
await blockchainLifecycle.startAsync();
|
await blockchainLifecycle.startAsync();
|
||||||
// Deploy SafeMath
|
// Deploy SafeMath
|
||||||
safeMath = await TestSafeMathContract.deployFrom0xArtifactAsync(
|
safeMath = await TestSafeMathContract.deployFrom0xArtifactAsync(artifacts.TestSafeMath, provider, txDefaults);
|
||||||
artifacts.TestSafeMath,
|
|
||||||
provider,
|
|
||||||
txDefaults,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
after(async () => {
|
after(async () => {
|
||||||
@@ -53,7 +49,7 @@ describe('SafeMath', () => {
|
|||||||
return expect(safeMath.externalSafeMul.callAsync(a, b)).to.revertWith(expectedError);
|
return expect(safeMath.externalSafeMul.callAsync(a, b)).to.revertWith(expectedError);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should calculate correct value for values that don\'t overflow', async () => {
|
it("should calculate correct value for values that don't overflow", async () => {
|
||||||
const result = await safeMath.externalSafeMul.callAsync(toBN(15), toBN(13));
|
const result = await safeMath.externalSafeMul.callAsync(toBN(15), toBN(13));
|
||||||
expect(result).bignumber.to.be.eq(toBN(195));
|
expect(result).bignumber.to.be.eq(toBN(195));
|
||||||
});
|
});
|
||||||
|
@@ -1,11 +1,16 @@
|
|||||||
import { EIP712DomainWithDefaultSchema, EIP712Object, EIP712ObjectValue, EIP712TypedData, EIP712Types } from '@0x/types';
|
import {
|
||||||
|
EIP712DomainWithDefaultSchema,
|
||||||
|
EIP712Object,
|
||||||
|
EIP712ObjectValue,
|
||||||
|
EIP712TypedData,
|
||||||
|
EIP712Types,
|
||||||
|
} from '@0x/types';
|
||||||
import * as ethUtil from 'ethereumjs-util';
|
import * as ethUtil from 'ethereumjs-util';
|
||||||
import * as ethers from 'ethers';
|
import * as ethers from 'ethers';
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
import { BigNumber } from './configured_bignumber';
|
import { BigNumber } from './configured_bignumber';
|
||||||
|
|
||||||
|
|
||||||
export const signTypedDataUtils = {
|
export const signTypedDataUtils = {
|
||||||
/**
|
/**
|
||||||
* Generates the EIP712 Typed Data hash for signing
|
* Generates the EIP712 Typed Data hash for signing
|
||||||
@@ -39,7 +44,7 @@ export const signTypedDataUtils = {
|
|||||||
{ name: 'version', type: 'string' },
|
{ name: 'version', type: 'string' },
|
||||||
{ name: 'chainId', type: 'uint256' },
|
{ name: 'chainId', type: 'uint256' },
|
||||||
{ name: 'verifyingContractAddress', type: 'address' },
|
{ name: 'verifyingContractAddress', type: 'address' },
|
||||||
]
|
],
|
||||||
} as EIP712Types,
|
} as EIP712Types,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user