From 2f5f9c6cd4b41ea1cf3c136a02f1f98b0168c5f9 Mon Sep 17 00:00:00 2001 From: xianny Date: Wed, 28 Aug 2019 14:09:41 -0700 Subject: [PATCH 1/7] add local evm for pure functions --- contracts/coordinator/test/mixins.ts | 12 +- contracts/utils/test/lib_address_array.ts | 12 +- contracts/utils/test/lib_bytes.ts | 107 +-- packages/0x.js/webpack.config.js | 3 + .../generated-wrappers/asset_proxy_owner.ts | 186 ++-- .../src/generated-wrappers/coordinator.ts | 80 +- .../coordinator_registry.ts | 16 +- .../src/generated-wrappers/dev_utils.ts | 126 +-- .../generated-wrappers/dummy_erc20_token.ts | 100 +- .../generated-wrappers/dummy_erc721_token.ts | 156 ++-- .../src/generated-wrappers/dutch_auction.ts | 128 +-- .../src/generated-wrappers/erc1155_proxy.ts | 92 +- .../src/generated-wrappers/erc20_proxy.ts | 70 +- .../src/generated-wrappers/erc20_token.ts | 56 +- .../src/generated-wrappers/erc721_proxy.ts | 70 +- .../src/generated-wrappers/erc721_token.ts | 110 +-- .../src/generated-wrappers/exchange.ts | 876 +++++++++--------- .../src/generated-wrappers/forwarder.ts | 254 ++--- .../src/generated-wrappers/i_asset_proxy.ts | 92 +- .../generated-wrappers/multi_asset_proxy.ts | 86 +- .../generated-wrappers/static_call_proxy.ts | 14 +- .../src/generated-wrappers/weth9.ts | 76 +- .../src/generated-wrappers/zrx_token.ts | 56 +- packages/abi-gen/package.json | 4 +- .../templates/TypeScript/contract.handlebars | 19 +- .../TypeScript/partials/call.handlebars | 3 - .../partials/method_abi_helper.handlebars | 34 + ...sync.handlebars => method_call.handlebars} | 34 - .../partials/method_call_pure.handlebars | 37 + .../{tx.handlebars => method_tx.handlebars} | 117 ++- .../output/typescript/abi_gen_dummy.ts | 394 ++------ .../output/typescript/test_lib_dummy.ts | 28 +- .../test/abi_gen_dummy_test.ts | 21 +- packages/base-contract/package.json | 2 + packages/base-contract/src/globals.d.ts | 2 + packages/base-contract/src/index.ts | 41 + packages/instant/webpack.config.js | 3 + yarn.lock | 137 ++- 38 files changed, 1612 insertions(+), 2042 deletions(-) delete mode 100644 packages/abi-gen/templates/TypeScript/partials/call.handlebars create mode 100644 packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars rename packages/abi-gen/templates/TypeScript/partials/{callAsync.handlebars => method_call.handlebars} (54%) create mode 100644 packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars rename packages/abi-gen/templates/TypeScript/partials/{tx.handlebars => method_tx.handlebars} (54%) diff --git a/contracts/coordinator/test/mixins.ts b/contracts/coordinator/test/mixins.ts index 9ccf2d28f8..e804a80d21 100644 --- a/contracts/coordinator/test/mixins.ts +++ b/contracts/coordinator/test/mixins.ts @@ -104,8 +104,7 @@ describe('Mixins tests', () => { transaction.signature.length - 2, )}${illegalSignatureByte}`; const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expectContractCallFailedAsync( - mixins.getSignerAddress.callAsync(transactionHash, transaction.signature), + expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith( RevertReason.SignatureIllegal, ); }); @@ -115,8 +114,7 @@ describe('Mixins tests', () => { const invalidSignatureByte = ethUtil.toBuffer(SignatureType.Invalid).toString('hex'); transaction.signature = `0x${invalidSignatureByte}`; const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expectContractCallFailedAsync( - mixins.getSignerAddress.callAsync(transactionHash, transaction.signature), + expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith( RevertReason.SignatureInvalid, ); }); @@ -129,8 +127,7 @@ describe('Mixins tests', () => { transaction.signature.length - 2, )}${invalidSignatureByte}`; const transactionHash = transactionHashUtils.getTransactionHashHex(transaction); - expectContractCallFailedAsync( - mixins.getSignerAddress.callAsync(transactionHash, transaction.signature), + expect(mixins.getSignerAddress.callAsync(transactionHash, transaction.signature)).to.be.rejectedWith( RevertReason.SignatureUnsupported, ); }); @@ -193,8 +190,7 @@ describe('Mixins tests', () => { }); it('should revert if data is less than 4 bytes long', async () => { const data = '0x010203'; - await expectContractCallFailedAsync( - mixins.decodeOrdersFromFillData.callAsync(data), + expect(mixins.decodeOrdersFromFillData.callAsync(data)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo4LengthRequired, ); }); diff --git a/contracts/utils/test/lib_address_array.ts b/contracts/utils/test/lib_address_array.ts index 4b96262a63..4289e24042 100644 --- a/contracts/utils/test/lib_address_array.ts +++ b/contracts/utils/test/lib_address_array.ts @@ -1,11 +1,4 @@ -import { - addressUtils, - chaiSetup, - expectContractCallFailedAsync, - provider, - txDefaults, - web3Wrapper, -} from '@0x/contracts-test-utils'; +import { addressUtils, chaiSetup, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { RevertReason } from '@0x/types'; import { BigNumber } from '@0x/utils'; @@ -55,8 +48,7 @@ describe('LibAddressArray', () => { const arr = _.times(3, () => addressUtils.generatePseudoRandomAddress()); const addr = addressUtils.generatePseudoRandomAddress(); const freeMemOffset = new BigNumber(-1); - return expectContractCallFailedAsync( - lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr), + return expect(lib.testAppendRealloc.callAsync(arr, freeMemOffset, addr)).to.be.rejectedWith( RevertReason.InvalidFreeMemoryPtr, ); }); diff --git a/contracts/utils/test/lib_bytes.ts b/contracts/utils/test/lib_bytes.ts index 69aa650803..a675d4b956 100644 --- a/contracts/utils/test/lib_bytes.ts +++ b/contracts/utils/test/lib_bytes.ts @@ -1,12 +1,4 @@ -import { - chaiSetup, - constants, - expectContractCallFailedAsync, - provider, - txDefaults, - typeEncodingUtils, - web3Wrapper, -} from '@0x/contracts-test-utils'; +import { chaiSetup, constants, provider, txDefaults, typeEncodingUtils, web3Wrapper } from '@0x/contracts-test-utils'; import { BlockchainLifecycle } from '@0x/dev-utils'; import { generatePseudoRandomSalt } from '@0x/order-utils'; import { RevertReason } from '@0x/types'; @@ -111,8 +103,7 @@ describe('LibBytes', () => { describe('popLastByte', () => { it('should revert if length is 0', async () => { - return expectContractCallFailedAsync( - libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES), + expect(libBytes.publicPopLastByte.callAsync(constants.NULL_BYTES)).to.be.rejectedWith( RevertReason.LibBytesGreaterThanZeroLengthRequired, ); }); @@ -133,8 +124,7 @@ describe('LibBytes', () => { describe('popLast20Bytes', () => { it('should revert if length is less than 20', async () => { - return expectContractCallFailedAsync( - libBytes.publicPopLast20Bytes.callAsync(byteArrayShorterThan20Bytes), + expect(libBytes.publicPopLast20Bytes.callAsync(byteArrayShorterThan20Bytes)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo20LengthRequired, ); }); @@ -208,10 +198,9 @@ describe('LibBytes', () => { describe('deepCopyBytes', () => { it('should revert if dest is shorter than source', async () => { - return expectContractCallFailedAsync( + return expect( libBytes.publicDeepCopyBytes.callAsync(byteArrayShorterThan32Bytes, byteArrayLongerThan32Bytes), - RevertReason.LibBytesGreaterOrEqualToSourceBytesLengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualToSourceBytesLengthRequired); }); it('should overwrite dest with source if source and dest have equal length', async () => { const zeroedByteArrayLongerThan32Bytes = `0x${_.repeat('0', byteArrayLongerThan32Bytes.length - 2)}`; @@ -261,16 +250,14 @@ describe('LibBytes', () => { it('should fail if the byte array is too short to hold an address', async () => { const shortByteArray = '0xabcdef'; const offset = new BigNumber(0); - return expectContractCallFailedAsync( - libBytes.publicReadAddress.callAsync(shortByteArray, offset), + return expect(libBytes.publicReadAddress.callAsync(shortByteArray, offset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo20LengthRequired, ); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { const byteArray = testAddress; const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); - return expectContractCallFailedAsync( - libBytes.publicReadAddress.callAsync(byteArray, badOffset), + return expect(libBytes.publicReadAddress.callAsync(byteArray, badOffset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo20LengthRequired, ); }); @@ -305,16 +292,14 @@ describe('LibBytes', () => { }); it('should fail if the byte array is too short to hold an address', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( + return expect( libBytes.publicWriteAddress.callAsync(byteArrayShorterThan20Bytes, offset, testAddress), - RevertReason.LibBytesGreaterOrEqualTo20LengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualTo20LengthRequired); }); it('should fail if the length between the offset and end of the byte array is too short to hold an address', async () => { const byteArray = byteArrayLongerThan32Bytes; const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); - return expectContractCallFailedAsync( - libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress), + return expect(libBytes.publicWriteAddress.callAsync(byteArray, badOffset, testAddress)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo20LengthRequired, ); }); @@ -337,15 +322,13 @@ describe('LibBytes', () => { }); it('should fail if the byte array is too short to hold a bytes32', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( - libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset), + return expect(libBytes.publicReadBytes32.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => { const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength); - return expectContractCallFailedAsync( - libBytes.publicReadBytes32.callAsync(testBytes32, badOffset), + return expect(libBytes.publicReadBytes32.callAsync(testBytes32, badOffset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -380,16 +363,14 @@ describe('LibBytes', () => { }); it('should fail if the byte array is too short to hold a bytes32', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( + return expect( libBytes.publicWriteBytes32.callAsync(byteArrayShorterThan32Bytes, offset, testBytes32), - RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualTo32LengthRequired); }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes32', async () => { const byteArray = byteArrayLongerThan32Bytes; const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); - return expectContractCallFailedAsync( - libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32), + return expect(libBytes.publicWriteBytes32.callAsync(byteArray, badOffset, testBytes32)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -416,8 +397,7 @@ describe('LibBytes', () => { }); it('should fail if the byte array is too short to hold a uint256', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( - libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset), + return expect(libBytes.publicReadUint256.callAsync(byteArrayShorterThan32Bytes, offset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -426,8 +406,7 @@ describe('LibBytes', () => { const testUint256AsBuffer = ethUtil.toBuffer(formattedTestUint256); const byteArray = ethUtil.bufferToHex(testUint256AsBuffer); const badOffset = new BigNumber(testUint256AsBuffer.byteLength); - return expectContractCallFailedAsync( - libBytes.publicReadUint256.callAsync(byteArray, badOffset), + return expect(libBytes.publicReadUint256.callAsync(byteArray, badOffset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -466,16 +445,14 @@ describe('LibBytes', () => { }); it('should fail if the byte array is too short to hold a uint256', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( + return expect( libBytes.publicWriteUint256.callAsync(byteArrayShorterThan32Bytes, offset, testUint256), - RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualTo32LengthRequired); }); it('should fail if the length between the offset and end of the byte array is too short to hold a uint256', async () => { const byteArray = byteArrayLongerThan32Bytes; const badOffset = new BigNumber(ethUtil.toBuffer(byteArray).byteLength); - return expectContractCallFailedAsync( - libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256), + return expect(libBytes.publicWriteUint256.callAsync(byteArray, badOffset, testUint256)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -486,8 +463,7 @@ describe('LibBytes', () => { it('should revert if byte array has a length < 4', async () => { const byteArrayLessThan4Bytes = '0x010101'; const offset = new BigNumber(0); - return expectContractCallFailedAsync( - libBytes.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, offset), + return expect(libBytes.publicReadBytes4.callAsync(byteArrayLessThan4Bytes, offset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo4LengthRequired, ); }); @@ -512,8 +488,7 @@ describe('LibBytes', () => { }); it('should fail if the length between the offset and end of the byte array is too short to hold a bytes4', async () => { const badOffset = new BigNumber(ethUtil.toBuffer(testBytes4).byteLength); - return expectContractCallFailedAsync( - libBytes.publicReadBytes4.callAsync(testBytes4, badOffset), + return expect(libBytes.publicReadBytes4.callAsync(testBytes4, badOffset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo4LengthRequired, ); }); @@ -562,29 +537,25 @@ describe('LibBytes', () => { it('should fail if the byte array is too short to hold the length of a nested byte array', async () => { // The length of the nested array is 32 bytes. By storing less than 32 bytes, a length cannot be read. const offset = new BigNumber(0); - return expectContractCallFailedAsync( + return expect( libBytes.publicReadBytesWithLength.callAsync(byteArrayShorterThan32Bytes, offset), - RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualTo32LengthRequired); }); it('should fail if we store a nested byte array length, without a nested byte array', async () => { const offset = new BigNumber(0); - return expectContractCallFailedAsync( - libBytes.publicReadBytesWithLength.callAsync(testBytes32, offset), + return expect(libBytes.publicReadBytesWithLength.callAsync(testBytes32, offset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired, ); }); it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => { const badOffset = new BigNumber(ethUtil.toBuffer(byteArrayShorterThan32Bytes).byteLength); - return expectContractCallFailedAsync( + return expect( libBytes.publicReadBytesWithLength.callAsync(byteArrayShorterThan32Bytes, badOffset), - RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualTo32LengthRequired); }); it('should fail if the length between the offset and end of the byte array is too short to hold the nested byte array', async () => { const badOffset = new BigNumber(ethUtil.toBuffer(testBytes32).byteLength); - return expectContractCallFailedAsync( - libBytes.publicReadBytesWithLength.callAsync(testBytes32, badOffset), + return expect(libBytes.publicReadBytesWithLength.callAsync(testBytes32, badOffset)).to.be.rejectedWith( RevertReason.LibBytesGreaterOrEqualTo32LengthRequired, ); }); @@ -695,18 +666,16 @@ describe('LibBytes', () => { it('should fail if the byte array is too short to hold the length of a nested byte array', async () => { const offset = new BigNumber(0); const emptyByteArray = ethUtil.bufferToHex(new Buffer(1)); - return expectContractCallFailedAsync( + return expect( libBytes.publicWriteBytesWithLength.callAsync(emptyByteArray, offset, longData), - RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired); }); it('should fail if the length between the offset and end of the byte array is too short to hold the length of a nested byte array', async () => { const emptyByteArray = ethUtil.bufferToHex(new Buffer(shortTestBytesAsBuffer.byteLength)); const badOffset = new BigNumber(ethUtil.toBuffer(shortTestBytesAsBuffer).byteLength); - return expectContractCallFailedAsync( + return expect( libBytes.publicWriteBytesWithLength.callAsync(emptyByteArray, badOffset, shortData), - RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired, - ); + ).to.be.rejectedWith(RevertReason.LibBytesGreaterOrEqualToNestedBytesLengthRequired); }); }); @@ -880,8 +849,7 @@ describe('LibBytes', () => { it('should revert if from > to', async () => { const from = new BigNumber(1); const to = new BigNumber(0); - expectContractCallFailedAsync( - libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to), + expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.be.rejectedWith( RevertReason.FromLessThanToRequired, ); }); @@ -904,8 +872,7 @@ describe('LibBytes', () => { const byteLen = (byteArrayLongerThan32Bytes.length - 2) / 2; const from = new BigNumber(0); const to = new BigNumber(byteLen).plus(1); - expectContractCallFailedAsync( - libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to), + expect(libBytes.publicSlice.callAsync(byteArrayLongerThan32Bytes, from, to)).to.be.rejectedWith( RevertReason.ToLessThanLengthRequired, ); }); @@ -931,8 +898,7 @@ describe('LibBytes', () => { it('should revert if from > to', async () => { const from = new BigNumber(1); const to = new BigNumber(0); - expectContractCallFailedAsync( - libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to), + expect(libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to)).to.be.rejectedWith( RevertReason.FromLessThanToRequired, ); }); @@ -953,8 +919,7 @@ describe('LibBytes', () => { const byteLen = (byteArrayLongerThan32Bytes.length - 2) / 2; const from = new BigNumber(0); const to = new BigNumber(byteLen).plus(1); - expectContractCallFailedAsync( - libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to), + expect(libBytes.publicSliceDestructive.callAsync(byteArrayLongerThan32Bytes, from, to)).to.be.rejectedWith( RevertReason.ToLessThanLengthRequired, ); }); diff --git a/packages/0x.js/webpack.config.js b/packages/0x.js/webpack.config.js index 397faa76f4..f9279315f4 100644 --- a/packages/0x.js/webpack.config.js +++ b/packages/0x.js/webpack.config.js @@ -39,6 +39,9 @@ module.exports = { }), ], }, + node: { + fs: 'empty', + }, module: { rules: [ { diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts index e66adcd72f..e8adfd5f6b 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/asset_proxy_owner.ts @@ -270,6 +270,11 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(owner: string, txData?: Partial | undefined): Promise { + await (this as any).removeOwner.callAsync(owner, txData); + const txHash = await (this as any).removeOwner.sendTransactionAsync(owner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -336,11 +341,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(owner: string, txData?: Partial | undefined): Promise { - await (this as any).removeOwner.callAsync(owner, txData); - const txHash = await (this as any).removeOwner.sendTransactionAsync(owner, txData); - return txHash; - }, }; /** * Allows an owner to revoke a confirmation for a transaction. @@ -427,6 +427,14 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + transactionId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).revokeConfirmation.callAsync(transactionId, txData); + const txHash = await (this as any).revokeConfirmation.sendTransactionAsync(transactionId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -497,14 +505,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).revokeConfirmation.callAsync(transactionId, txData); - const txHash = await (this as any).revokeConfirmation.sendTransactionAsync(transactionId, txData); - return txHash; - }, }; public isOwner = { /** @@ -743,6 +743,17 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + transactionId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).executeRemoveAuthorizedAddressAtIndex.callAsync(transactionId, txData); + const txHash = await (this as any).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync( + transactionId, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -816,17 +827,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).executeRemoveAuthorizedAddressAtIndex.callAsync(transactionId, txData); - const txHash = await (this as any).executeRemoveAuthorizedAddressAtIndex.sendTransactionAsync( - transactionId, - txData, - ); - return txHash; - }, }; public secondsTimeLocked = { /** @@ -1083,6 +1083,19 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetProxyContract: string, + isRegistered: boolean, + txData?: Partial | undefined, + ): Promise { + await (this as any).registerAssetProxy.callAsync(assetProxyContract, isRegistered, txData); + const txHash = await (this as any).registerAssetProxy.sendTransactionAsync( + assetProxyContract, + isRegistered, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1162,19 +1175,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetProxyContract: string, - isRegistered: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).registerAssetProxy.callAsync(assetProxyContract, isRegistered, txData); - const txHash = await (this as any).registerAssetProxy.sendTransactionAsync( - assetProxyContract, - isRegistered, - txData, - ); - return txHash; - }, }; /** * Allows to add a new owner. Transaction has to be sent by wallet. @@ -1261,6 +1261,11 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(owner: string, txData?: Partial | undefined): Promise { + await (this as any).addOwner.callAsync(owner, txData); + const txHash = await (this as any).addOwner.sendTransactionAsync(owner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1325,11 +1330,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(owner: string, txData?: Partial | undefined): Promise { - await (this as any).addOwner.callAsync(owner, txData); - const txHash = await (this as any).addOwner.sendTransactionAsync(owner, txData); - return txHash; - }, }; /** * Returns the confirmation status of a transaction. @@ -1496,6 +1496,14 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _secondsTimeLocked: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).changeTimeLock.callAsync(_secondsTimeLocked, txData); + const txHash = await (this as any).changeTimeLock.sendTransactionAsync(_secondsTimeLocked, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1568,14 +1576,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _secondsTimeLocked: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).changeTimeLock.callAsync(_secondsTimeLocked, txData); - const txHash = await (this as any).changeTimeLock.sendTransactionAsync(_secondsTimeLocked, txData); - return txHash; - }, }; public isAssetProxyRegistered = { /** @@ -2177,6 +2177,14 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _required: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).changeRequirement.callAsync(_required, txData); + const txHash = await (this as any).changeRequirement.sendTransactionAsync(_required, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2245,14 +2253,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _required: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).changeRequirement.callAsync(_required, txData); - const txHash = await (this as any).changeRequirement.sendTransactionAsync(_required, txData); - return txHash; - }, }; /** * Allows an owner to confirm a transaction. @@ -2339,6 +2339,14 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + transactionId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).confirmTransaction.callAsync(transactionId, txData); + const txHash = await (this as any).confirmTransaction.sendTransactionAsync(transactionId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2409,14 +2417,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).confirmTransaction.callAsync(transactionId, txData); - const txHash = await (this as any).confirmTransaction.sendTransactionAsync(transactionId, txData); - return txHash; - }, }; /** * Allows an owner to submit and confirm a transaction. @@ -2540,6 +2540,16 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + destination: string, + value: BigNumber, + data: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).submitTransaction.callAsync(destination, value, data, txData); + const txHash = await (this as any).submitTransaction.sendTransactionAsync(destination, value, data, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2627,16 +2637,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - destination: string, - value: BigNumber, - data: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).submitTransaction.callAsync(destination, value, data, txData); - const txHash = await (this as any).submitTransaction.sendTransactionAsync(destination, value, data, txData); - return txHash; - }, }; public confirmationTimes = { /** @@ -2936,6 +2936,15 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + owner: string, + newOwner: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).replaceOwner.callAsync(owner, newOwner, txData); + const txHash = await (this as any).replaceOwner.sendTransactionAsync(owner, newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -3015,15 +3024,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - owner: string, - newOwner: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).replaceOwner.callAsync(owner, newOwner, txData); - const txHash = await (this as any).replaceOwner.sendTransactionAsync(owner, newOwner, txData); - return txHash; - }, }; /** * Allows anyone to execute a confirmed transaction. @@ -3110,6 +3110,14 @@ export class AssetProxyOwnerContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + transactionId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).executeTransaction.callAsync(transactionId, txData); + const txHash = await (this as any).executeTransaction.sendTransactionAsync(transactionId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -3180,14 +3188,6 @@ export class AssetProxyOwnerContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - transactionId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).executeTransaction.callAsync(transactionId, txData); - const txHash = await (this as any).executeTransaction.sendTransactionAsync(transactionId, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts index 63dbf4eed6..bd3aded61e 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator.ts @@ -57,19 +57,9 @@ export class CoordinatorContract extends BaseContract { } const self = (this as any) as CoordinatorContract; const encodedData = self._strictEncodeArguments('getSignerAddress(bytes32,bytes)', [hash, signature]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getSignerAddress(bytes32,bytes)'); // tslint:disable boolean-naming @@ -444,6 +434,32 @@ export class CoordinatorContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + transaction: { salt: BigNumber; signerAddress: string; data: string }, + txOrigin: string, + transactionSignature: string, + approvalExpirationTimeSeconds: BigNumber[], + approvalSignatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).executeTransaction.callAsync( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + txData, + ); + const txHash = await (this as any).executeTransaction.sendTransactionAsync( + transaction, + txOrigin, + transactionSignature, + approvalExpirationTimeSeconds, + approvalSignatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -568,32 +584,6 @@ export class CoordinatorContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - transaction: { salt: BigNumber; signerAddress: string; data: string }, - txOrigin: string, - transactionSignature: string, - approvalExpirationTimeSeconds: BigNumber[], - approvalSignatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).executeTransaction.callAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - txData, - ); - const txHash = await (this as any).executeTransaction.sendTransactionAsync( - transaction, - txOrigin, - transactionSignature, - approvalExpirationTimeSeconds, - approvalSignatures, - txData, - ); - return txHash; - }, }; public EIP712_EXCHANGE_DOMAIN_HASH = { /** @@ -829,19 +819,9 @@ export class CoordinatorContract extends BaseContract { } const self = (this as any) as CoordinatorContract; const encodedData = self._strictEncodeArguments('decodeOrdersFromFillData(bytes)', [data]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeOrdersFromFillData(bytes)'); // tslint:disable boolean-naming diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts index 62a22a1164..26c1fffaa0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/coordinator_registry.ts @@ -131,6 +131,14 @@ export class CoordinatorRegistryContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + coordinatorEndpoint: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txData); + const txHash = await (this as any).setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -201,14 +209,6 @@ export class CoordinatorRegistryContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - coordinatorEndpoint: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txData); - const txHash = await (this as any).setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData); - return txHash; - }, }; /** * Gets the endpoint for a Coordinator. diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts index a6881e4cd5..bad171c643 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dev_utils.ts @@ -56,19 +56,9 @@ export class DevUtilsContract extends BaseContract { } const self = (this as any) as DevUtilsContract; const encodedData = self._strictEncodeArguments('decodeERC721AssetData(bytes)', [assetData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeERC721AssetData(bytes)'); // tslint:disable boolean-naming @@ -457,19 +447,9 @@ export class DevUtilsContract extends BaseContract { const encodedData = self._strictEncodeArguments('encodeERC20AssetData(address)', [ tokenAddress.toLowerCase(), ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('encodeERC20AssetData(address)'); // tslint:disable boolean-naming @@ -555,19 +535,9 @@ export class DevUtilsContract extends BaseContract { } const self = (this as any) as DevUtilsContract; const encodedData = self._strictEncodeArguments('decodeZeroExTransactionData(bytes)', [transactionData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeZeroExTransactionData(bytes)'); // tslint:disable boolean-naming @@ -1041,19 +1011,9 @@ export class DevUtilsContract extends BaseContract { } const self = (this as any) as DevUtilsContract; const encodedData = self._strictEncodeArguments('decodeERC20AssetData(bytes)', [assetData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeERC20AssetData(bytes)'); // tslint:disable boolean-naming @@ -1250,19 +1210,9 @@ export class DevUtilsContract extends BaseContract { } const self = (this as any) as DevUtilsContract; const encodedData = self._strictEncodeArguments('decodeERC1155AssetData(bytes)', [assetData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeERC1155AssetData(bytes)'); // tslint:disable boolean-naming @@ -1474,19 +1424,9 @@ export class DevUtilsContract extends BaseContract { tokenAddress.toLowerCase(), tokenId, ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('encodeERC721AssetData(address,uint256)'); // tslint:disable boolean-naming @@ -1630,19 +1570,9 @@ export class DevUtilsContract extends BaseContract { 'encodeERC1155AssetData(address,uint256[],uint256[],bytes)', [tokenAddress.toLowerCase(), tokenIds, tokenValues, callbackData], ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('encodeERC1155AssetData(address,uint256[],uint256[],bytes)'); // tslint:disable boolean-naming @@ -1805,19 +1735,9 @@ export class DevUtilsContract extends BaseContract { } const self = (this as any) as DevUtilsContract; const encodedData = self._strictEncodeArguments('decodeMultiAssetData(bytes)', [assetData]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('decodeMultiAssetData(bytes)'); // tslint:disable boolean-naming @@ -2062,19 +1982,9 @@ export class DevUtilsContract extends BaseContract { amounts, nestedAssetData, ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('encodeMultiAssetData(uint256[],bytes[])'); // tslint:disable boolean-naming diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts index 0931972e21..7502ce1e5a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc20_token.ts @@ -222,6 +222,15 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _spender: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(_spender, _value, txData); + const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -302,15 +311,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(_spender, _value, txData); - const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); - return txHash; - }, }; /** * Query total supply of token @@ -500,6 +500,16 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(_from, _to, _value, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -587,16 +597,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(_from, _to, _value, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); - return txHash; - }, }; public decimals = { /** @@ -943,6 +943,14 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).mint.callAsync(_value, txData); + const txHash = await (this as any).mint.sendTransactionAsync(_value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1007,14 +1015,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).mint.callAsync(_value, txData); - const txHash = await (this as any).mint.sendTransactionAsync(_value, txData); - return txHash; - }, }; /** * send `value` token to `to` from `msg.sender` @@ -1112,6 +1112,15 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transfer.callAsync(_to, _value, txData); + const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1189,15 +1198,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transfer.callAsync(_to, _value, txData); - const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); - return txHash; - }, }; public allowance = { /** @@ -1387,6 +1387,15 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _target: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).setBalance.callAsync(_target, _value, txData); + const txHash = await (this as any).setBalance.sendTransactionAsync(_target, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1466,15 +1475,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _target: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).setBalance.callAsync(_target, _value, txData); - const txHash = await (this as any).setBalance.sendTransactionAsync(_target, _value, txData); - return txHash; - }, }; public transferOwnership = { /** @@ -1555,6 +1555,11 @@ export class DummyERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1619,11 +1624,6 @@ export class DummyERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; public MAX_MINT_AMOUNT = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts index bf1e60f20a..50fe787f5a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dummy_erc721_token.ts @@ -308,6 +308,15 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _approved: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(_approved, _tokenId, txData); + const txHash = await (this as any).approve.sendTransactionAsync(_approved, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -387,15 +396,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(_approved, _tokenId, txData); - const txHash = await (this as any).approve.sendTransactionAsync(_approved, _tokenId, txData); - return txHash; - }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -522,6 +522,16 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(_from, _to, _tokenId, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -608,16 +618,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(_from, _to, _tokenId, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _tokenId, txData); - return txHash; - }, }; /** * Function to mint a new token @@ -720,6 +720,15 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _to: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).mint.callAsync(_to, _tokenId, txData); + const txHash = await (this as any).mint.sendTransactionAsync(_to, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -796,15 +805,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).mint.callAsync(_to, _tokenId, txData); - const txHash = await (this as any).mint.sendTransactionAsync(_to, _tokenId, txData); - return txHash; - }, }; /** * This works identically to the other function with an extra data parameter, @@ -929,6 +929,16 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).safeTransferFrom1.callAsync(_from, _to, _tokenId, txData); + const txHash = await (this as any).safeTransferFrom1.sendTransactionAsync(_from, _to, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1015,16 +1025,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeTransferFrom1.callAsync(_from, _to, _tokenId, txData); - const txHash = await (this as any).safeTransferFrom1.sendTransactionAsync(_from, _to, _tokenId, txData); - return txHash; - }, }; /** * NFTs assigned to zero address are considered invalid, and queries @@ -1401,6 +1401,15 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _owner: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).burn.callAsync(_owner, _tokenId, txData); + const txHash = await (this as any).burn.sendTransactionAsync(_owner, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1477,15 +1486,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _owner: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).burn.callAsync(_owner, _tokenId, txData); - const txHash = await (this as any).burn.sendTransactionAsync(_owner, _tokenId, txData); - return txHash; - }, }; /** * Emits the ApprovalForAll event. The contract MUST allow @@ -1598,6 +1598,15 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _operator: string, + _approved: boolean, + txData?: Partial | undefined, + ): Promise { + await (this as any).setApprovalForAll.callAsync(_operator, _approved, txData); + const txHash = await (this as any).setApprovalForAll.sendTransactionAsync(_operator, _approved, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1677,15 +1686,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).setApprovalForAll.callAsync(_operator, _approved, txData); - const txHash = await (this as any).setApprovalForAll.sendTransactionAsync(_operator, _approved, txData); - return txHash; - }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -1833,6 +1833,23 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txData); + const txHash = await (this as any).safeTransferFrom2.sendTransactionAsync( + _from, + _to, + _tokenId, + _data, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1924,23 +1941,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txData); - const txHash = await (this as any).safeTransferFrom2.sendTransactionAsync( - _from, - _to, - _tokenId, - _data, - txData, - ); - return txHash; - }, }; public isApprovedForAll = { /** @@ -2103,6 +2103,11 @@ export class DummyERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2167,11 +2172,6 @@ export class DummyERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts index 5347dbd215..b8763b729a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/dutch_auction.ts @@ -161,6 +161,27 @@ export class DutchAuctionContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + txData?: Partial | undefined, + ): Promise { + await (this as any).getAuctionDetails.callAsync(order, txData); + const txHash = await (this as any).getAuctionDetails.sendTransactionAsync(order, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -312,27 +333,6 @@ export class DutchAuctionContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - txData?: Partial | undefined, - ): Promise { - await (this as any).getAuctionDetails.callAsync(order, txData); - const txHash = await (this as any).getAuctionDetails.sendTransactionAsync(order, txData); - return txHash; - }, }; /** * Matches the buy and sell orders at an amount given the following: the current block time, the auction @@ -556,6 +556,49 @@ export class DutchAuctionContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + buyOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + sellOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + buySignature: string, + sellSignature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).matchOrders.callAsync(buyOrder, sellOrder, buySignature, sellSignature, txData); + const txHash = await (this as any).matchOrders.sendTransactionAsync( + buyOrder, + sellOrder, + buySignature, + sellSignature, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -797,49 +840,6 @@ export class DutchAuctionContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - buyOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - sellOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - buySignature: string, - sellSignature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).matchOrders.callAsync(buyOrder, sellOrder, buySignature, sellSignature, txData); - const txHash = await (this as any).matchOrders.sendTransactionAsync( - buyOrder, - sellOrder, - buySignature, - sellSignature, - txData, - ); - return txHash; - }, }; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts index bcb89ef0c8..cad0a8dffe 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc1155_proxy.ts @@ -139,6 +139,11 @@ export class ERC1155ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).addAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -205,11 +210,6 @@ export class ERC1155ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).addAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public authorities = { /** @@ -364,6 +364,11 @@ export class ERC1155ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).removeAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -430,11 +435,6 @@ export class ERC1155ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).removeAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public owner = { /** @@ -608,6 +608,19 @@ export class ERC1155ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + target: string, + index: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); + const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( + target, + index, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -687,19 +700,6 @@ export class ERC1155ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); - const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( - target, - index, - txData, - ); - return txHash; - }, }; /** * Transfers batch of ERC1155 assets. Either succeeds or throws. @@ -841,6 +841,17 @@ export class ERC1155ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetData: string, + from: string, + to: string, + amount: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(assetData, from, to, amount, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(assetData, from, to, amount, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -936,17 +947,6 @@ export class ERC1155ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(assetData, from, to, amount, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(assetData, from, to, amount, txData); - return txHash; - }, }; /** * Gets the proxy id associated with the proxy address. @@ -969,19 +969,9 @@ export class ERC1155ProxyContract extends BaseContract { } const self = (this as any) as ERC1155ProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming @@ -1229,6 +1219,11 @@ export class ERC1155ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1293,11 +1288,6 @@ export class ERC1155ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts index 07b27febca..ef802a6f31 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_proxy.ts @@ -139,6 +139,11 @@ export class ERC20ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).addAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -205,11 +210,6 @@ export class ERC20ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).addAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public authorities = { /** @@ -364,6 +364,11 @@ export class ERC20ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).removeAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -430,11 +435,6 @@ export class ERC20ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).removeAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public owner = { /** @@ -608,6 +608,19 @@ export class ERC20ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + target: string, + index: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); + const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( + target, + index, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -687,19 +700,6 @@ export class ERC20ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); - const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( - target, - index, - txData, - ); - return txHash; - }, }; /** * Gets the proxy id associated with the proxy address. @@ -722,19 +722,9 @@ export class ERC20ProxyContract extends BaseContract { } const self = (this as any) as ERC20ProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming @@ -982,6 +972,11 @@ export class ERC20ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1046,11 +1041,6 @@ export class ERC20ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts index fb471e3ce8..21a30aedcc 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc20_token.ts @@ -160,6 +160,15 @@ export class ERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _spender: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(_spender, _value, txData); + const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -240,15 +249,6 @@ export class ERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(_spender, _value, txData); - const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); - return txHash; - }, }; /** * Query total supply of token @@ -438,6 +438,16 @@ export class ERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(_from, _to, _value, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -525,16 +535,6 @@ export class ERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(_from, _to, _value, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); - return txHash; - }, }; /** * Query the balance of owner @@ -706,6 +706,15 @@ export class ERC20TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transfer.callAsync(_to, _value, txData); + const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -783,15 +792,6 @@ export class ERC20TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transfer.callAsync(_to, _value, txData); - const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); - return txHash; - }, }; public allowance = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts index 971cc0fe69..92f32c3906 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_proxy.ts @@ -139,6 +139,11 @@ export class ERC721ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).addAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -205,11 +210,6 @@ export class ERC721ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).addAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public authorities = { /** @@ -364,6 +364,11 @@ export class ERC721ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).removeAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -430,11 +435,6 @@ export class ERC721ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).removeAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public owner = { /** @@ -608,6 +608,19 @@ export class ERC721ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + target: string, + index: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); + const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( + target, + index, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -687,19 +700,6 @@ export class ERC721ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); - const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( - target, - index, - txData, - ); - return txHash; - }, }; /** * Gets the proxy id associated with the proxy address. @@ -722,19 +722,9 @@ export class ERC721ProxyContract extends BaseContract { } const self = (this as any) as ERC721ProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming @@ -982,6 +972,11 @@ export class ERC721ProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1046,11 +1041,6 @@ export class ERC721ProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts index 499e2ebfd7..a358886ec1 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/erc721_token.ts @@ -246,6 +246,15 @@ export class ERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _approved: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(_approved, _tokenId, txData); + const txHash = await (this as any).approve.sendTransactionAsync(_approved, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -325,15 +334,6 @@ export class ERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _approved: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(_approved, _tokenId, txData); - const txHash = await (this as any).approve.sendTransactionAsync(_approved, _tokenId, txData); - return txHash; - }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -460,6 +460,16 @@ export class ERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(_from, _to, _tokenId, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -546,16 +556,6 @@ export class ERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(_from, _to, _tokenId, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _tokenId, txData); - return txHash; - }, }; /** * This works identically to the other function with an extra data parameter, @@ -680,6 +680,16 @@ export class ERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).safeTransferFrom1.callAsync(_from, _to, _tokenId, txData); + const txHash = await (this as any).safeTransferFrom1.sendTransactionAsync(_from, _to, _tokenId, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -766,16 +776,6 @@ export class ERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeTransferFrom1.callAsync(_from, _to, _tokenId, txData); - const txHash = await (this as any).safeTransferFrom1.sendTransactionAsync(_from, _to, _tokenId, txData); - return txHash; - }, }; /** * NFTs assigned to zero address are considered invalid, and queries @@ -1038,6 +1038,15 @@ export class ERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _operator: string, + _approved: boolean, + txData?: Partial | undefined, + ): Promise { + await (this as any).setApprovalForAll.callAsync(_operator, _approved, txData); + const txHash = await (this as any).setApprovalForAll.sendTransactionAsync(_operator, _approved, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1117,15 +1126,6 @@ export class ERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _operator: string, - _approved: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).setApprovalForAll.callAsync(_operator, _approved, txData); - const txHash = await (this as any).setApprovalForAll.sendTransactionAsync(_operator, _approved, txData); - return txHash; - }, }; /** * Throws unless `msg.sender` is the current owner, an authorized @@ -1273,6 +1273,23 @@ export class ERC721TokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _tokenId: BigNumber, + _data: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txData); + const txHash = await (this as any).safeTransferFrom2.sendTransactionAsync( + _from, + _to, + _tokenId, + _data, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1364,23 +1381,6 @@ export class ERC721TokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _tokenId: BigNumber, - _data: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).safeTransferFrom2.callAsync(_from, _to, _tokenId, _data, txData); - const txHash = await (this as any).safeTransferFrom2.sendTransactionAsync( - _from, - _to, - _tokenId, - _data, - txData, - ); - return txHash; - }, }; public isApprovedForAll = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts index 9a71caee8c..86a85e76d9 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/exchange.ts @@ -320,6 +320,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).batchFillOrders.callAsync(orders, takerAssetFillAmounts, signatures, txData); + const txHash = await (this as any).batchFillOrders.sendTransactionAsync( + orders, + takerAssetFillAmounts, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -477,34 +505,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).batchFillOrders.callAsync(orders, takerAssetFillAmounts, signatures, txData); - const txHash = await (this as any).batchFillOrders.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - ); - return txHash; - }, }; public cancelled = { /** @@ -694,6 +694,16 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + hash: string, + signerAddress: string, + signature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).preSign.callAsync(hash, signerAddress, signature, txData); + const txHash = await (this as any).preSign.sendTransactionAsync(hash, signerAddress, signature, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -778,16 +788,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - hash: string, - signerAddress: string, - signature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).preSign.callAsync(hash, signerAddress, signature, txData); - const txHash = await (this as any).preSign.sendTransactionAsync(hash, signerAddress, signature, txData); - return txHash; - }, }; /** * Match two complementary orders that have a profitable spread. @@ -994,6 +994,49 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + leftOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + rightOrder: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + leftSignature: string, + rightSignature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).matchOrders.callAsync(leftOrder, rightOrder, leftSignature, rightSignature, txData); + const txHash = await (this as any).matchOrders.sendTransactionAsync( + leftOrder, + rightOrder, + leftSignature, + rightSignature, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1231,49 +1274,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - leftOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - rightOrder: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - leftSignature: string, - rightSignature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).matchOrders.callAsync(leftOrder, rightOrder, leftSignature, rightSignature, txData); - const txHash = await (this as any).matchOrders.sendTransactionAsync( - leftOrder, - rightOrder, - leftSignature, - rightSignature, - txData, - ); - return txHash; - }, }; /** * Fills the input order. @@ -1432,6 +1432,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + takerAssetFillAmount: BigNumber, + signature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).fillOrderNoThrow.callAsync(order, takerAssetFillAmount, signature, txData); + const txHash = await (this as any).fillOrderNoThrow.sendTransactionAsync( + order, + takerAssetFillAmount, + signature, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1585,34 +1613,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).fillOrderNoThrow.callAsync(order, takerAssetFillAmount, signature, txData); - const txHash = await (this as any).fillOrderNoThrow.sendTransactionAsync( - order, - takerAssetFillAmount, - signature, - txData, - ); - return txHash; - }, }; public assetProxies = { /** @@ -1814,6 +1814,27 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + txData?: Partial | undefined, + ): Promise { + await (this as any).batchCancelOrders.callAsync(orders, txData); + const txHash = await (this as any).batchCancelOrders.sendTransactionAsync(orders, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1922,27 +1943,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - txData?: Partial | undefined, - ): Promise { - await (this as any).batchCancelOrders.callAsync(orders, txData); - const txHash = await (this as any).batchCancelOrders.sendTransactionAsync(orders, txData); - return txHash; - }, }; /** * Synchronously executes multiple calls of fillOrKill. @@ -2106,6 +2106,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).batchFillOrKillOrders.callAsync(orders, takerAssetFillAmounts, signatures, txData); + const txHash = await (this as any).batchFillOrKillOrders.sendTransactionAsync( + orders, + takerAssetFillAmounts, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2263,34 +2291,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).batchFillOrKillOrders.callAsync(orders, takerAssetFillAmounts, signatures, txData); - const txHash = await (this as any).batchFillOrKillOrders.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - ); - return txHash; - }, }; /** * Cancels all orders created by makerAddress with a salt less than or equal to the targetOrderEpoch @@ -2381,6 +2381,14 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + targetOrderEpoch: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).cancelOrdersUpTo.callAsync(targetOrderEpoch, txData); + const txHash = await (this as any).cancelOrdersUpTo.sendTransactionAsync(targetOrderEpoch, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -2453,14 +2461,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - targetOrderEpoch: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).cancelOrdersUpTo.callAsync(targetOrderEpoch, txData); - const txHash = await (this as any).cancelOrdersUpTo.sendTransactionAsync(targetOrderEpoch, txData); - return txHash; - }, }; /** * Fills an order with specified parameters and ECDSA signature. @@ -2618,12 +2618,40 @@ export class ExchangeContract extends BaseContract { }, self._web3Wrapper.getContractDefaults(), ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAssetFillAmounts: BigNumber[], + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).batchFillOrdersNoThrow.callAsync(orders, takerAssetFillAmounts, signatures, txData); + const txHash = await (this as any).batchFillOrdersNoThrow.sendTransactionAsync( + orders, + takerAssetFillAmounts, + signatures, + txData, + ); + return txHash; }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an @@ -2782,34 +2810,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAssetFillAmounts: BigNumber[], - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).batchFillOrdersNoThrow.callAsync(orders, takerAssetFillAmounts, signatures, txData); - const txHash = await (this as any).batchFillOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmounts, - signatures, - txData, - ); - return txHash; - }, }; /** * Gets an asset proxy. @@ -3109,6 +3109,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + takerAssetFillAmount: BigNumber, + signature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).fillOrKillOrder.callAsync(order, takerAssetFillAmount, signature, txData); + const txHash = await (this as any).fillOrKillOrder.sendTransactionAsync( + order, + takerAssetFillAmount, + signature, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -3261,34 +3289,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).fillOrKillOrder.callAsync(order, takerAssetFillAmount, signature, txData); - const txHash = await (this as any).fillOrKillOrder.sendTransactionAsync( - order, - takerAssetFillAmount, - signature, - txData, - ); - return txHash; - }, }; /** * Approves/unnapproves a Validator contract to verify signatures on signer's behalf. @@ -3404,6 +3404,19 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + validatorAddress: string, + approval: boolean, + txData?: Partial | undefined, + ): Promise { + await (this as any).setSignatureValidatorApproval.callAsync(validatorAddress, approval, txData); + const txHash = await (this as any).setSignatureValidatorApproval.sendTransactionAsync( + validatorAddress, + approval, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -3483,19 +3496,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - validatorAddress: string, - approval: boolean, - txData?: Partial | undefined, - ): Promise { - await (this as any).setSignatureValidatorApproval.callAsync(validatorAddress, approval, txData); - const txHash = await (this as any).setSignatureValidatorApproval.sendTransactionAsync( - validatorAddress, - approval, - txData, - ); - return txHash; - }, }; public allowedValidators = { /** @@ -3733,6 +3733,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAssetFillAmount: BigNumber, + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).marketSellOrders.callAsync(orders, takerAssetFillAmount, signatures, txData); + const txHash = await (this as any).marketSellOrders.sendTransactionAsync( + orders, + takerAssetFillAmount, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -3888,34 +3916,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).marketSellOrders.callAsync(orders, takerAssetFillAmount, signatures, txData); - const txHash = await (this as any).marketSellOrders.sendTransactionAsync( - orders, - takerAssetFillAmount, - signatures, - txData, - ); - return txHash; - }, }; /** * Fetches information for all passed in orders. @@ -4432,6 +4432,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + makerAssetFillAmount: BigNumber, + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).marketBuyOrdersNoThrow.callAsync(orders, makerAssetFillAmount, signatures, txData); + const txHash = await (this as any).marketBuyOrdersNoThrow.sendTransactionAsync( + orders, + makerAssetFillAmount, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -4587,34 +4615,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).marketBuyOrdersNoThrow.callAsync(orders, makerAssetFillAmount, signatures, txData); - const txHash = await (this as any).marketBuyOrdersNoThrow.sendTransactionAsync( - orders, - makerAssetFillAmount, - signatures, - txData, - ); - return txHash; - }, }; /** * Fills the input order. @@ -4760,12 +4760,40 @@ export class ExchangeContract extends BaseContract { }, self._web3Wrapper.getContractDefaults(), ); - if (txDataWithDefaults.from !== undefined) { - txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); - } - - const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); - return gas; + if (txDataWithDefaults.from !== undefined) { + txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); + } + + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); + return gas; + }, + async validateAndSendTransactionAsync( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + takerAssetFillAmount: BigNumber, + signature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).fillOrder.callAsync(order, takerAssetFillAmount, signature, txData); + const txHash = await (this as any).fillOrder.sendTransactionAsync( + order, + takerAssetFillAmount, + signature, + txData, + ); + return txHash; }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an @@ -4920,34 +4948,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - takerAssetFillAmount: BigNumber, - signature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).fillOrder.callAsync(order, takerAssetFillAmount, signature, txData); - const txHash = await (this as any).fillOrder.sendTransactionAsync( - order, - takerAssetFillAmount, - signature, - txData, - ); - return txHash; - }, }; /** * Executes an exchange method call in the context of signer. @@ -5083,6 +5083,23 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + salt: BigNumber, + signerAddress: string, + data: string, + signature: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).executeTransaction.callAsync(salt, signerAddress, data, signature, txData); + const txHash = await (this as any).executeTransaction.sendTransactionAsync( + salt, + signerAddress, + data, + signature, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -5174,23 +5191,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - salt: BigNumber, - signerAddress: string, - data: string, - signature: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).executeTransaction.callAsync(salt, signerAddress, data, signature, txData); - const txHash = await (this as any).executeTransaction.sendTransactionAsync( - salt, - signerAddress, - data, - signature, - txData, - ); - return txHash; - }, }; /** * Registers an asset proxy to its asset proxy id. @@ -5278,6 +5278,14 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetProxy: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).registerAssetProxy.callAsync(assetProxy, txData); + const txHash = await (this as any).registerAssetProxy.sendTransactionAsync(assetProxy, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -5348,14 +5356,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetProxy: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).registerAssetProxy.callAsync(assetProxy, txData); - const txHash = await (this as any).registerAssetProxy.sendTransactionAsync(assetProxy, txData); - return txHash; - }, }; /** * Gets information about an order: status, hash, and amount filled. @@ -5617,6 +5617,27 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + order: { + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }, + txData?: Partial | undefined, + ): Promise { + await (this as any).cancelOrder.callAsync(order, txData); + const txHash = await (this as any).cancelOrder.sendTransactionAsync(order, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -5721,27 +5742,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - order: { - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }, - txData?: Partial | undefined, - ): Promise { - await (this as any).cancelOrder.callAsync(order, txData); - const txHash = await (this as any).cancelOrder.sendTransactionAsync(order, txData); - return txHash; - }, }; public orderEpoch = { /** @@ -6042,6 +6042,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + takerAssetFillAmount: BigNumber, + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).marketSellOrdersNoThrow.callAsync(orders, takerAssetFillAmount, signatures, txData); + const txHash = await (this as any).marketSellOrdersNoThrow.sendTransactionAsync( + orders, + takerAssetFillAmount, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -6197,34 +6225,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - takerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).marketSellOrdersNoThrow.callAsync(orders, takerAssetFillAmount, signatures, txData); - const txHash = await (this as any).marketSellOrdersNoThrow.sendTransactionAsync( - orders, - takerAssetFillAmount, - signatures, - txData, - ); - return txHash; - }, }; public EIP712_DOMAIN_HASH = { /** @@ -6447,6 +6447,34 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + makerAssetFillAmount: BigNumber, + signatures: string[], + txData?: Partial | undefined, + ): Promise { + await (this as any).marketBuyOrders.callAsync(orders, makerAssetFillAmount, signatures, txData); + const txHash = await (this as any).marketBuyOrders.sendTransactionAsync( + orders, + makerAssetFillAmount, + signatures, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -6602,34 +6630,6 @@ export class ExchangeContract extends BaseContract { }>(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - txData?: Partial | undefined, - ): Promise { - await (this as any).marketBuyOrders.callAsync(orders, makerAssetFillAmount, signatures, txData); - const txHash = await (this as any).marketBuyOrders.sendTransactionAsync( - orders, - makerAssetFillAmount, - signatures, - txData, - ); - return txHash; - }, }; public currentContextAddress = { /** @@ -6772,6 +6772,11 @@ export class ExchangeContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -6836,11 +6841,6 @@ export class ExchangeContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; public VERSION = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts index 36c9a53aa8..2842b35bd0 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/forwarder.ts @@ -302,6 +302,64 @@ export class ForwarderContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + makerAssetFillAmount: BigNumber, + signatures: string[], + feeOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).marketBuyOrdersWithEth.callAsync( + orders, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient, + txData, + ); + const txHash = await (this as any).marketBuyOrdersWithEth.sendTransactionAsync( + orders, + makerAssetFillAmount, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -585,64 +643,6 @@ export class ForwarderContract extends BaseContract { >(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - makerAssetFillAmount: BigNumber, - signatures: string[], - feeOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - feeSignatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).marketBuyOrdersWithEth.callAsync( - orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient, - txData, - ); - const txHash = await (this as any).marketBuyOrdersWithEth.sendTransactionAsync( - orders, - makerAssetFillAmount, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient, - txData, - ); - return txHash; - }, }; /** * Withdraws assets from this contract. The contract requires a ZRX balance in order to @@ -746,6 +746,15 @@ export class ForwarderContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetData: string, + amount: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).withdrawAsset.callAsync(assetData, amount, txData); + const txHash = await (this as any).withdrawAsset.sendTransactionAsync(assetData, amount, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -822,15 +831,6 @@ export class ForwarderContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetData: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).withdrawAsset.callAsync(assetData, amount, txData); - const txHash = await (this as any).withdrawAsset.sendTransactionAsync(assetData, amount, txData); - return txHash; - }, }; public owner = { /** @@ -1142,6 +1142,61 @@ export class ForwarderContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + orders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + signatures: string[], + feeOrders: Array<{ + makerAddress: string; + takerAddress: string; + feeRecipientAddress: string; + senderAddress: string; + makerAssetAmount: BigNumber; + takerAssetAmount: BigNumber; + makerFee: BigNumber; + takerFee: BigNumber; + expirationTimeSeconds: BigNumber; + salt: BigNumber; + makerAssetData: string; + takerAssetData: string; + }>, + feeSignatures: string[], + feePercentage: BigNumber, + feeRecipient: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).marketSellOrdersWithEth.callAsync( + orders, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient, + txData, + ); + const txHash = await (this as any).marketSellOrdersWithEth.sendTransactionAsync( + orders, + signatures, + feeOrders, + feeSignatures, + feePercentage, + feeRecipient, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1403,61 +1458,6 @@ export class ForwarderContract extends BaseContract { >(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - orders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - signatures: string[], - feeOrders: Array<{ - makerAddress: string; - takerAddress: string; - feeRecipientAddress: string; - senderAddress: string; - makerAssetAmount: BigNumber; - takerAssetAmount: BigNumber; - makerFee: BigNumber; - takerFee: BigNumber; - expirationTimeSeconds: BigNumber; - salt: BigNumber; - makerAssetData: string; - takerAssetData: string; - }>, - feeSignatures: string[], - feePercentage: BigNumber, - feeRecipient: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).marketSellOrdersWithEth.callAsync( - orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient, - txData, - ); - const txHash = await (this as any).marketSellOrdersWithEth.sendTransactionAsync( - orders, - signatures, - feeOrders, - feeSignatures, - feePercentage, - feeRecipient, - txData, - ); - return txHash; - }, }; public transferOwnership = { /** @@ -1538,6 +1538,11 @@ export class ForwarderContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1602,11 +1607,6 @@ export class ForwarderContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts index 4b75d5c2ee..93197cac6a 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/i_asset_proxy.ts @@ -113,6 +113,11 @@ export class IAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).addAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -179,11 +184,6 @@ export class IAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).addAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; /** * Removes authorizion of an address. @@ -270,6 +270,11 @@ export class IAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).removeAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -336,11 +341,6 @@ export class IAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).removeAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; /** * Removes authorizion of an address. @@ -452,6 +452,19 @@ export class IAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + target: string, + index: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); + const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( + target, + index, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -531,19 +544,6 @@ export class IAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); - const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( - target, - index, - txData, - ); - return txHash; - }, }; /** * Transfers assets. Either succeeds or throws. @@ -679,6 +679,17 @@ export class IAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetData: string, + from: string, + to: string, + amount: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(assetData, from, to, amount, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(assetData, from, to, amount, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -770,17 +781,6 @@ export class IAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetData: string, - from: string, - to: string, - amount: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(assetData, from, to, amount, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(assetData, from, to, amount, txData); - return txHash; - }, }; /** * Gets the proxy id associated with the proxy address. @@ -803,19 +803,9 @@ export class IAssetProxyContract extends BaseContract { } const self = (this as any) as IAssetProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming @@ -993,6 +983,11 @@ export class IAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1057,11 +1052,6 @@ export class IAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; public static async deployFrom0xArtifactAsync( artifact: ContractArtifact | SimpleContractArtifact, diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts index 22db6965ae..5bf911a593 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/multi_asset_proxy.ts @@ -210,6 +210,11 @@ export class MultiAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).addAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -276,11 +281,6 @@ export class MultiAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).addAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).addAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public authorities = { /** @@ -509,6 +509,11 @@ export class MultiAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { + await (this as any).removeAuthorizedAddress.callAsync(target, txData); + const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -575,11 +580,6 @@ export class MultiAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(target: string, txData?: Partial | undefined): Promise { - await (this as any).removeAuthorizedAddress.callAsync(target, txData); - const txHash = await (this as any).removeAuthorizedAddress.sendTransactionAsync(target, txData); - return txHash; - }, }; public owner = { /** @@ -753,6 +753,19 @@ export class MultiAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + target: string, + index: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); + const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( + target, + index, + txData, + ); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -832,19 +845,6 @@ export class MultiAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - target: string, - index: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).removeAuthorizedAddressAtIndex.callAsync(target, index, txData); - const txHash = await (this as any).removeAuthorizedAddressAtIndex.sendTransactionAsync( - target, - index, - txData, - ); - return txHash; - }, }; /** * Gets the proxy id associated with the proxy address. @@ -867,19 +867,9 @@ export class MultiAssetProxyContract extends BaseContract { } const self = (this as any) as MultiAssetProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming @@ -1068,6 +1058,14 @@ export class MultiAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + assetProxy: string, + txData?: Partial | undefined, + ): Promise { + await (this as any).registerAssetProxy.callAsync(assetProxy, txData); + const txHash = await (this as any).registerAssetProxy.sendTransactionAsync(assetProxy, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1138,14 +1136,6 @@ export class MultiAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - assetProxy: string, - txData?: Partial | undefined, - ): Promise { - await (this as any).registerAssetProxy.callAsync(assetProxy, txData); - const txHash = await (this as any).registerAssetProxy.sendTransactionAsync(assetProxy, txData); - return txHash; - }, }; /** * Gets all authorized addresses. @@ -1292,6 +1282,11 @@ export class MultiAssetProxyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { + await (this as any).transferOwnership.callAsync(newOwner, txData); + const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1356,11 +1351,6 @@ export class MultiAssetProxyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(newOwner: string, txData?: Partial | undefined): Promise { - await (this as any).transferOwnership.callAsync(newOwner, txData); - const txHash = await (this as any).transferOwnership.sendTransactionAsync(newOwner, txData); - return txHash; - }, }; private readonly _subscriptionManager: SubscriptionManager; public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts index edca12db7b..b05a62fc8c 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/static_call_proxy.ts @@ -147,19 +147,9 @@ export class StaticCallProxyContract extends BaseContract { } const self = (this as any) as StaticCallProxyContract; const encodedData = self._strictEncodeArguments('getProxyId()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('getProxyId()'); // tslint:disable boolean-naming diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts index e42f67d8ef..139377c676 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/weth9.ts @@ -215,6 +215,15 @@ export class WETH9Contract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + guy: string, + wad: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(guy, wad, txData); + const txHash = await (this as any).approve.sendTransactionAsync(guy, wad, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -287,15 +296,6 @@ export class WETH9Contract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - guy: string, - wad: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(guy, wad, txData); - const txHash = await (this as any).approve.sendTransactionAsync(guy, wad, txData); - return txHash; - }, }; public totalSupply = { /** @@ -469,6 +469,16 @@ export class WETH9Contract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + src: string, + dst: string, + wad: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(src, dst, wad, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(src, dst, wad, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -549,16 +559,6 @@ export class WETH9Contract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - src: string, - dst: string, - wad: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(src, dst, wad, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(src, dst, wad, txData); - return txHash; - }, }; public withdraw = { /** @@ -639,6 +639,11 @@ export class WETH9Contract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(wad: BigNumber, txData?: Partial | undefined): Promise { + await (this as any).withdraw.callAsync(wad, txData); + const txHash = await (this as any).withdraw.sendTransactionAsync(wad, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -701,11 +706,6 @@ export class WETH9Contract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(wad: BigNumber, txData?: Partial | undefined): Promise { - await (this as any).withdraw.callAsync(wad, txData); - const txHash = await (this as any).withdraw.sendTransactionAsync(wad, txData); - return txHash; - }, }; public decimals = { /** @@ -984,6 +984,15 @@ export class WETH9Contract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + dst: string, + wad: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transfer.callAsync(dst, wad, txData); + const txHash = await (this as any).transfer.sendTransactionAsync(dst, wad, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1056,15 +1065,6 @@ export class WETH9Contract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - dst: string, - wad: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transfer.callAsync(dst, wad, txData); - const txHash = await (this as any).transfer.sendTransactionAsync(dst, wad, txData); - return txHash; - }, }; public deposit = { /** @@ -1141,6 +1141,11 @@ export class WETH9Contract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { + await (this as any).deposit.callAsync(txData); + const txHash = await (this as any).deposit.sendTransactionAsync(txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1201,11 +1206,6 @@ export class WETH9Contract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { - await (this as any).deposit.callAsync(txData); - const txHash = await (this as any).deposit.sendTransactionAsync(txData); - return txHash; - }, }; public allowance = { /** diff --git a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts index 7049a2d987..9f2e336ed7 100644 --- a/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts +++ b/packages/abi-gen-wrappers/src/generated-wrappers/zrx_token.ts @@ -213,6 +213,15 @@ export class ZRXTokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _spender: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).approve.callAsync(_spender, _value, txData); + const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -288,15 +297,6 @@ export class ZRXTokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _spender: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).approve.callAsync(_spender, _value, txData); - const txHash = await (this as any).approve.sendTransactionAsync(_spender, _value, txData); - return txHash; - }, }; public totalSupply = { /** @@ -482,6 +482,16 @@ export class ZRXTokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transferFrom.callAsync(_from, _to, _value, txData); + const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -569,16 +579,6 @@ export class ZRXTokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _from: string, - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transferFrom.callAsync(_from, _to, _value, txData); - const txHash = await (this as any).transferFrom.sendTransactionAsync(_from, _to, _value, txData); - return txHash; - }, }; public decimals = { /** @@ -859,6 +859,15 @@ export class ZRXTokenContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync( + _to: string, + _value: BigNumber, + txData?: Partial | undefined, + ): Promise { + await (this as any).transfer.callAsync(_to, _value, txData); + const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -931,15 +940,6 @@ export class ZRXTokenContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync( - _to: string, - _value: BigNumber, - txData?: Partial | undefined, - ): Promise { - await (this as any).transfer.callAsync(_to, _value, txData); - const txHash = await (this as any).transfer.sendTransactionAsync(_to, _value, txData); - return txHash; - }, }; public allowance = { /** diff --git a/packages/abi-gen/package.json b/packages/abi-gen/package.json index a363b48f80..6998ef3d32 100644 --- a/packages/abi-gen/package.json +++ b/packages/abi-gen/package.json @@ -13,12 +13,12 @@ "clean": "shx rm -rf lib && yarn test_cli:clean", "build": "tsc -b && yarn generate_contract_wrappers && yarn prettier_contract_wrappers && yarn test_cli:build", "build:ci": "yarn build", - "test": "yarn run_mocha && yarn test_cli", + "test": "run-p run_mocha && yarn test_cli", "test:circleci": "yarn test:coverage && yarn test_cli", "run_mocha": "(uname -s | grep -q Darwin && echo 'HACK! skipping mocha run due to https://github.com/0xProject/0x-monorepo/issues/2000') || mocha --require source-map-support/register --require make-promises-safe lib/test/*_test.js --timeout 100000 --bail --exit", "test:coverage": "nyc npm run test --all && yarn coverage:report:lcov", "coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info", - "test_cli": "run-p test_cli:test_typescript diff_contract_wrappers", + "test_cli": "run-s test_cli:test_typescript diff_contract_wrappers", "test_cli:clean": "rm -rf test-cli/test_typescript/lib", "test_cli:build": "tsc --project test-cli/tsconfig.json", "test_cli:test_typescript": "mocha --require source-map-support/register --require make-promises-safe test-cli/test_typescript/lib/**/*_test.js --timeout 100000 --bail --exit", diff --git a/packages/abi-gen/templates/TypeScript/contract.handlebars b/packages/abi-gen/templates/TypeScript/contract.handlebars index 9298540a03..af40c0468c 100644 --- a/packages/abi-gen/templates/TypeScript/contract.handlebars +++ b/packages/abi-gen/templates/TypeScript/contract.handlebars @@ -55,13 +55,18 @@ export class {{contractName}}Contract extends BaseContract { /** * {{formatDocstringForMethodTs this.devdoc.details}} */ - {{/if}} - {{#this.constant}} - {{> call contractName=../contractName}} - {{/this.constant}} - {{^this.constant}} - {{> tx contractName=../contractName}} - {{/this.constant}} + {{/if}} + public {{languageSpecificName}} = { + {{^this.constant}} + {{> method_tx contractName=../contractName}} + {{/this.constant}} + {{#ifEquals this.stateMutability "pure"}} + {{> method_call_pure contractName=../contractName}} + {{else}} + {{> method_call contractName=../contractName}} + {{/ifEquals}} + {{> method_abi_helper contractName=../contractName}} + }; {{/each}} {{#if events}}private readonly _subscriptionManager: SubscriptionManager<{{contractName}}EventArgs, {{contractName}}Events>; {{/if}}public static async deployFrom0xArtifactAsync( diff --git a/packages/abi-gen/templates/TypeScript/partials/call.handlebars b/packages/abi-gen/templates/TypeScript/partials/call.handlebars deleted file mode 100644 index 702f747d60..0000000000 --- a/packages/abi-gen/templates/TypeScript/partials/call.handlebars +++ /dev/null @@ -1,3 +0,0 @@ -public {{languageSpecificName}} = { - {{> callAsync}} -}; diff --git a/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars new file mode 100644 index 0000000000..a172707fc5 --- /dev/null +++ b/packages/abi-gen/templates/TypeScript/partials/method_abi_helper.handlebars @@ -0,0 +1,34 @@ +/** + * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before + * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used + * to create a 0x transaction (see protocol spec for more details). +{{> params_docstring inputs=inputs docstrings=devdoc.params}} + */ +getABIEncodedTransactionData( + {{> typed_params inputs=inputs}} + ): string { + {{#each inputs}} + {{#assertionType name type}}{{/assertionType}} + {{/each}} + const self = this as any as {{contractName}}Contract; + const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); + return abiEncodedTransactionData; +}, +getABIDecodedTransactionData( + callData: string +): ({{> return_type inputs=inputs ~}}) { + const self = this as any as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + // tslint:disable boolean-naming + const abiDecodedCallData = abiEncoder.strictDecode<{{> return_type inputs=inputs}}>(callData); + return abiDecodedCallData; +}, +getABIDecodedReturnData( + returnData: string +): ({{> return_type outputs=outputs ~}}) { + const self = this as any as {{contractName}}Contract; + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + // tslint:disable boolean-naming + const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData); + return abiDecodedReturnData; +}, diff --git a/packages/abi-gen/templates/TypeScript/partials/callAsync.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars similarity index 54% rename from packages/abi-gen/templates/TypeScript/partials/callAsync.handlebars rename to packages/abi-gen/templates/TypeScript/partials/method_call.handlebars index c307c8ffb9..92fad498a5 100644 --- a/packages/abi-gen/templates/TypeScript/partials/callAsync.handlebars +++ b/packages/abi-gen/templates/TypeScript/partials/method_call.handlebars @@ -43,37 +43,3 @@ async callAsync( // tslint:enable boolean-naming return result; }, -/** - * Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before - * sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used - * to create a 0x transaction (see protocol spec for more details). -{{> params_docstring inputs=inputs docstrings=devdoc.params}} - */ -getABIEncodedTransactionData( - {{> typed_params inputs=inputs}} - ): string { - {{#each inputs}} - {{#assertionType name type}}{{/assertionType}} - {{/each}} - const self = this as any as {{contractName}}Contract; - const abiEncodedTransactionData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); - return abiEncodedTransactionData; -}, -getABIDecodedTransactionData( - callData: string -): ({{> return_type inputs=inputs ~}}) { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - // tslint:disable boolean-naming - const abiDecodedCallData = abiEncoder.strictDecode<{{> return_type inputs=inputs}}>(callData); - return abiDecodedCallData; -}, -getABIDecodedReturnData( - returnData: string -): ({{> return_type outputs=outputs ~}}) { - const self = this as any as {{contractName}}Contract; - const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); - // tslint:disable boolean-naming - const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(returnData); - return abiDecodedReturnData; -}, diff --git a/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars new file mode 100644 index 0000000000..d66f1194bb --- /dev/null +++ b/packages/abi-gen/templates/TypeScript/partials/method_call_pure.handlebars @@ -0,0 +1,37 @@ +/** + * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an + * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas + * since they don't modify state. +{{> params_docstring inputs=inputs docstrings=devdoc.params}} +{{#if devdoc.return}} + * @returns {{devdoc.return}} +{{/if}} + */ +async callAsync( +{{> typed_params inputs=inputs}} + callData: Partial = {}, + defaultBlock?: BlockParam, +): Promise<{{> return_type outputs=outputs}}> { + {{#each inputs}} + {{#assertionType name type}}{{/assertionType}} + {{/each}} + assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [ + schemas.addressSchema, + schemas.numberSchema, + schemas.jsNumber, + ]); + if (defaultBlock !== undefined) { + assert.isBlockParam('defaultBlock', defaultBlock); + } + const self = this as any as {{contractName}}Contract; + const encodedData = self._strictEncodeArguments('{{this.functionSignature}}', [{{> normalized_params inputs=inputs}}]); + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); + + const rawCallResult = await self.evmExecAsync(encodedDataBytes); + BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); + const abiEncoder = self._lookupAbiEncoder('{{this.functionSignature}}'); + // tslint:disable boolean-naming + const result = abiEncoder.strictDecodeReturnValue<{{> return_type outputs=outputs}}>(rawCallResult); + // tslint:enable boolean-naming + return result; +}, diff --git a/packages/abi-gen/templates/TypeScript/partials/tx.handlebars b/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars similarity index 54% rename from packages/abi-gen/templates/TypeScript/partials/tx.handlebars rename to packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars index aa1d41bd08..2f5c780dd3 100644 --- a/packages/abi-gen/templates/TypeScript/partials/tx.handlebars +++ b/packages/abi-gen/templates/TypeScript/partials/method_tx.handlebars @@ -1,15 +1,14 @@ -public {{languageSpecificName}} = { - /** - * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write - * Ethereum operation and will cost gas. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async sendTransactionAsync( - {{> typed_params inputs=inputs}} - txData?: Partial | undefined, - ): Promise { +/** + * Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write + * Ethereum operation and will cost gas. + {{> params_docstring inputs=inputs docstrings=devdoc.params}} + * @param txData Additional data for transaction + * @returns The hash of the transaction + */ +async sendTransactionAsync( +{{> typed_params inputs=inputs}} +txData?: Partial | undefined, +): Promise { {{#each inputs}} {{#assertionType name type}}{{/assertionType}} {{/each}} @@ -33,21 +32,21 @@ public {{languageSpecificName}} = { const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults); return txHash; - }, - /** - * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. - * If the transaction was mined, but reverted, an error is thrown. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @param pollingIntervalMs Interval at which to poll for success - * @returns A promise that resolves when the transaction is successful - */ - awaitTransactionSuccessAsync( - {{> typed_params inputs=inputs}} - txData?: Partial, - pollingIntervalMs?: number, - timeoutMs?: number, - ): PromiseWithTransactionHash { +}, +/** + * Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting. + * If the transaction was mined, but reverted, an error is thrown. + {{> params_docstring inputs=inputs docstrings=devdoc.params}} + * @param txData Additional data for transaction + * @param pollingIntervalMs Interval at which to poll for success + * @returns A promise that resolves when the transaction is successful + */ +awaitTransactionSuccessAsync( +{{> typed_params inputs=inputs}} + txData?: Partial, + pollingIntervalMs?: number, + timeoutMs?: number, +): PromiseWithTransactionHash { {{#each inputs}} {{#assertionType name type}}{{/assertionType}} {{/each}} @@ -68,17 +67,17 @@ public {{languageSpecificName}} = { ); })(), ); - }, - /** - * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. - {{> params_docstring inputs=inputs docstrings=devdoc.params}} - * @param txData Additional data for transaction - * @returns The hash of the transaction - */ - async estimateGasAsync( - {{> typed_params inputs=inputs}} - txData?: Partial | undefined, - ): Promise { +}, +/** + * Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments. + {{> params_docstring inputs=inputs docstrings=devdoc.params}} + * @param txData Additional data for transaction + * @returns The hash of the transaction + */ +async estimateGasAsync( +{{> typed_params inputs=inputs}} + txData?: Partial | undefined, +): Promise { {{#each inputs}} {{#assertionType name type}}{{/assertionType}} {{/each}} @@ -95,27 +94,25 @@ public {{languageSpecificName}} = { if (txDataWithDefaults.from !== undefined) { txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase(); } - + const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; - }, - {{> callAsync}} - async validateAndSendTransactionAsync( - {{> typed_params inputs=inputs}} - txData?: Partial | undefined, - ): Promise { - await (this as any).{{languageSpecificName}}.callAsync( - {{#each inputs~}} - {{name}}, - {{/each~}} - txData, - ); - const txHash = await (this as any).{{languageSpecificName}}.sendTransactionAsync( - {{#each inputs~}} - {{name}}, - {{/each~}} - txData, - ); - return txHash; - } -}; +}, +async validateAndSendTransactionAsync( + {{> typed_params inputs=inputs}} + txData?: Partial | undefined, + ): Promise { + await (this as any).{{languageSpecificName}}.callAsync( + {{#each inputs~}} + {{name}}, + {{/each~}} + txData, + ); + const txHash = await (this as any).{{languageSpecificName}}.sendTransactionAsync( + {{#each inputs~}} + {{name}}, + {{/each~}} + txData, + ); + return txHash; +}, diff --git a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts index f537f16e56..c2dd88ce96 100644 --- a/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/abi_gen_dummy.ts @@ -68,19 +68,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simpleRequire()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simpleRequire()'); // tslint:disable boolean-naming @@ -135,19 +125,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('acceptsAnArrayOfBytes(bytes[])', [a]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('acceptsAnArrayOfBytes(bytes[])'); // tslint:disable boolean-naming @@ -207,19 +187,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simpleInputSimpleOutput(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simpleInputSimpleOutput(uint256)'); // tslint:disable boolean-naming @@ -334,6 +304,11 @@ export class AbiGenDummyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(wad: BigNumber, txData?: Partial | undefined): Promise { + await (this as any).withdraw.callAsync(wad, txData); + const txHash = await (this as any).withdraw.sendTransactionAsync(wad, txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -396,11 +371,6 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(wad: BigNumber, txData?: Partial | undefined): Promise { - await (this as any).withdraw.callAsync(wad, txData); - const txHash = await (this as any).withdraw.sendTransactionAsync(wad, txData); - return txHash; - }, }; /** * Tests decoding when the input and output are complex and have more than one argument. @@ -435,19 +405,9 @@ export class AbiGenDummyContract extends BaseContract { index_1, index_2, ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('multiInputMultiOutput(uint256,bytes,string)'); // tslint:disable boolean-naming @@ -530,19 +490,9 @@ export class AbiGenDummyContract extends BaseContract { r, s, ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('ecrecoverFn(bytes32,uint8,bytes32,bytes32)'); // tslint:disable boolean-naming @@ -606,19 +556,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('acceptsBytes(bytes)', [a]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('acceptsBytes(bytes)'); // tslint:disable boolean-naming @@ -672,19 +612,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('noInputSimpleOutput()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('noInputSimpleOutput()'); // tslint:disable boolean-naming @@ -734,19 +664,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('revertWithConstant()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('revertWithConstant()'); // tslint:disable boolean-naming @@ -796,19 +716,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simpleRevert()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simpleRevert()'); // tslint:disable boolean-naming @@ -864,19 +774,9 @@ export class AbiGenDummyContract extends BaseContract { 'methodUsingNestedStructWithInnerStructNotUsedElsewhere()', [], ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('methodUsingNestedStructWithInnerStructNotUsedElsewhere()'); // tslint:disable boolean-naming @@ -937,19 +837,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('nestedStructOutput()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('nestedStructOutput()'); // tslint:disable boolean-naming @@ -1018,19 +908,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('requireWithConstant()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('requireWithConstant()'); // tslint:disable boolean-naming @@ -1096,19 +976,9 @@ export class AbiGenDummyContract extends BaseContract { 'withAddressInput(address,uint256,uint256,address,uint256)', [x.toLowerCase(), a, b, y.toLowerCase(), c], ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('withAddressInput(address,uint256,uint256,address,uint256)'); // tslint:disable boolean-naming @@ -1170,19 +1040,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('structInput((bytes,uint32,bytes[],string))', [s]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('structInput((bytes,uint32,bytes[],string))'); // tslint:disable boolean-naming @@ -1298,6 +1158,11 @@ export class AbiGenDummyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { + await (this as any).nonPureMethod.callAsync(txData); + const txHash = await (this as any).nonPureMethod.sendTransactionAsync(txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1358,11 +1223,6 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { - await (this as any).nonPureMethod.callAsync(txData); - const txHash = await (this as any).nonPureMethod.sendTransactionAsync(txData); - return txHash; - }, }; /** * Tests decoding when the input and output are complex. @@ -1395,19 +1255,9 @@ export class AbiGenDummyContract extends BaseContract { const encodedData = self._strictEncodeArguments('complexInputComplexOutput((uint256,bytes,string))', [ complexInput, ]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('complexInputComplexOutput((uint256,bytes,string))'); // tslint:disable boolean-naming @@ -1482,19 +1332,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('noInputNoOutput()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('noInputNoOutput()'); // tslint:disable boolean-naming @@ -1545,19 +1385,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simplePureFunctionWithInput(uint256)', [x]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simplePureFunctionWithInput(uint256)'); // tslint:disable boolean-naming @@ -1666,6 +1496,11 @@ export class AbiGenDummyContract extends BaseContract { const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults); return gas; }, + async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { + await (this as any).nonPureMethodThatReturnsNothing.callAsync(txData); + const txHash = await (this as any).nonPureMethodThatReturnsNothing.sendTransactionAsync(txData); + return txHash; + }, /** * Sends a read-only call to the contract method. Returns the result that would happen if one were to send an * Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas @@ -1726,11 +1561,6 @@ export class AbiGenDummyContract extends BaseContract { const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue(returnData); return abiDecodedReturnData; }, - async validateAndSendTransactionAsync(txData?: Partial | undefined): Promise { - await (this as any).nonPureMethodThatReturnsNothing.callAsync(txData); - const txHash = await (this as any).nonPureMethodThatReturnsNothing.sendTransactionAsync(txData); - return txHash; - }, }; public simplePureFunction = { /** @@ -1749,19 +1579,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simplePureFunction()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simplePureFunction()'); // tslint:disable boolean-naming @@ -1826,19 +1646,9 @@ export class AbiGenDummyContract extends BaseContract { 'nestedStructInput(((bytes,uint32,bytes[],string),string))', [n], ); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('nestedStructInput(((bytes,uint32,bytes[],string),string))'); // tslint:disable boolean-naming @@ -1899,19 +1709,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('methodReturningMultipleValues()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('methodReturningMultipleValues()'); // tslint:disable boolean-naming @@ -1964,19 +1764,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('methodReturningArrayOfStructs()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('methodReturningArrayOfStructs()'); // tslint:disable boolean-naming @@ -2043,19 +1833,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('structOutput()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('structOutput()'); // tslint:disable boolean-naming @@ -2124,19 +1904,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('pureFunctionWithConstant()', []); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('pureFunctionWithConstant()'); // tslint:disable boolean-naming @@ -2194,19 +1964,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('simpleInputNoOutput(uint256)', [index_0]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('simpleInputNoOutput(uint256)'); // tslint:disable boolean-naming @@ -2258,19 +2018,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('overloadedMethod(string)', [a]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('overloadedMethod(string)'); // tslint:disable boolean-naming @@ -2322,19 +2072,9 @@ export class AbiGenDummyContract extends BaseContract { } const self = (this as any) as AbiGenDummyContract; const encodedData = self._strictEncodeArguments('overloadedMethod(int256)', [a]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('overloadedMethod(int256)'); // tslint:disable boolean-naming diff --git a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts index 6b2db7e5a8..35d4659936 100644 --- a/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts +++ b/packages/abi-gen/test-cli/output/typescript/test_lib_dummy.ts @@ -46,19 +46,9 @@ export class TestLibDummyContract extends BaseContract { } const self = (this as any) as TestLibDummyContract; const encodedData = self._strictEncodeArguments('publicAddConstant(uint256)', [x]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('publicAddConstant(uint256)'); // tslint:disable boolean-naming @@ -110,19 +100,9 @@ export class TestLibDummyContract extends BaseContract { } const self = (this as any) as TestLibDummyContract; const encodedData = self._strictEncodeArguments('publicAddOne(uint256)', [x]); - const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync( - { - to: self.address, - ...callData, - data: encodedData, - }, - self._web3Wrapper.getContractDefaults(), - ); - callDataWithDefaults.from = callDataWithDefaults.from - ? callDataWithDefaults.from.toLowerCase() - : callDataWithDefaults.from; + const encodedDataBytes = Buffer.from(encodedData.substr(2), 'hex'); - const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock); + const rawCallResult = await self.evmExecAsync(encodedDataBytes); BaseContract._throwIfRevertWithReasonCallResult(rawCallResult); const abiEncoder = self._lookupAbiEncoder('publicAddOne(uint256)'); // tslint:disable boolean-naming diff --git a/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts b/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts index 33fce30f72..4aaeb5f675 100644 --- a/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts +++ b/packages/abi-gen/test-cli/test_typescript/test/abi_gen_dummy_test.ts @@ -75,22 +75,22 @@ describe('AbiGenDummy Contract', () => { }); describe('simpleRevert', () => { it('should call simpleRevert', async () => { - return expectContractCallFailedAsync(abiGenDummy.simpleRevert.callAsync(), 'SIMPLE_REVERT'); + expect(abiGenDummy.simpleRevert.callAsync()).to.be.rejectedWith('SIMPLE_REVERT'); }); }); describe('revertWithConstant', () => { it('should call revertWithConstant', async () => { - return expectContractCallFailedAsync(abiGenDummy.revertWithConstant.callAsync(), 'REVERT_WITH_CONSTANT'); + expect(abiGenDummy.revertWithConstant.callAsync()).to.be.rejectedWith('REVERT_WITH_CONSTANT'); }); }); describe('simpleRequire', () => { it('should call simpleRequire', async () => { - return expectContractCallFailedAsync(abiGenDummy.simpleRequire.callAsync(), 'SIMPLE_REQUIRE'); + expect(abiGenDummy.simpleRequire.callAsync()).to.be.rejectedWith('SIMPLE_REQUIRE'); }); }); describe('requireWithConstant', () => { it('should call requireWithConstant', async () => { - return expectContractCallFailedAsync(abiGenDummy.requireWithConstant.callAsync(), 'REQUIRE_WITH_CONSTANT'); + expect(abiGenDummy.requireWithConstant.callAsync()).to.be.rejectedWith('REQUIRE_WITH_CONSTANT'); }); }); @@ -267,16 +267,3 @@ describe('Lib dummy contract', () => { expect(result).to.deep.equal(new BigNumber(1235)); }); }); - -// HACK(xianny): copied from @0x/contracts-test-utils to avoid circular dependency -/** - * Resolves if the the contract call fails with the given revert reason. - * @param p a Promise resulting from a contract call - * @param reason a specific revert reason - * @returns a new Promise which will reject if the conditions are not met and - * otherwise resolve with no value. - */ -function expectContractCallFailedAsync(p: Promise, reason: string): Chai.PromisedAssertion { - const rejectionMessageRegex = new RegExp(`^VM Exception while processing transaction: revert ${reason}$`); - return expect(p).to.be.rejectedWith(rejectionMessageRegex); -} diff --git a/packages/base-contract/package.json b/packages/base-contract/package.json index 58de5038ed..63d4a00bea 100644 --- a/packages/base-contract/package.json +++ b/packages/base-contract/package.json @@ -48,8 +48,10 @@ "@0x/utils": "^4.5.1", "@0x/web3-wrapper": "^6.0.12", "ethereum-types": "^2.1.5", + "ethereumjs-account": "^3.0.0", "ethereumjs-blockstream": "^7.0.0", "ethereumjs-util": "^5.1.1", + "ethereumjs-vm": "^4.0.0", "ethers": "~4.0.4", "js-sha3": "^0.7.0", "lodash": "^4.17.11", diff --git a/packages/base-contract/src/globals.d.ts b/packages/base-contract/src/globals.d.ts index 94e63a32de..b3d0c15e8a 100644 --- a/packages/base-contract/src/globals.d.ts +++ b/packages/base-contract/src/globals.d.ts @@ -4,3 +4,5 @@ declare module '*.json' { export default json; /* tslint:enable */ } + +declare module 'ethereumjs-vm'; diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index dddf5a2dcd..b12796c9bd 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -14,6 +14,10 @@ import { TxData, TxDataPayable, } from 'ethereum-types'; +import Account from 'ethereumjs-account'; +import * as util from 'ethereumjs-util'; +import * as ethereumJsVm from 'ethereumjs-vm'; +import PStateManager from 'ethereumjs-vm/dist/state/promisified'; import * as ethers from 'ethers'; import * as _ from 'lodash'; @@ -27,6 +31,9 @@ export interface AbiEncoderByFunctionSignature { [key: string]: AbiEncoder.Method; } +const VM = ethereumJsVm.default; +const ARBITRARY_PRIVATE_KEY = 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109'; + // tslint:disable: max-classes-per-file /** * @dev A promise-compatible type that exposes a `txHash` field. @@ -61,6 +68,8 @@ export class BaseContract { public address: string; public contractName: string; public constructorArgs: any[] = []; + private _evmIfExists?: any; // hack (xianny): VM is also used as a namespace + private _evmAccountIfExists?: Buffer; protected static _formatABIDataItemList( abis: DataItem[], values: any[], @@ -150,6 +159,38 @@ export class BaseContract { } return rawEncoded; } + public async evmExecAsync(input: Buffer): Promise { + // should only run once, the first time it is called + if (this._evmIfExists === undefined) { + const vm = new VM(); + const psm = new PStateManager(vm.stateManager); + + // create an account with 1 ETH + const accountPk = Buffer.from(ARBITRARY_PRIVATE_KEY, 'hex'); + const accountAddress = util.privateToAddress(accountPk); + const account = new Account({ balance: 1e18 }); + await psm.putAccount(accountAddress, account); + + // 'deploy' the contract + const contractCode = await this._web3Wrapper.getContractCodeAsync(this.address); + const address = Buffer.from(this.address.substr(2), 'hex'); + const deployedBytecode = Buffer.from(contractCode.substr(2), 'hex'); + await psm.putContractCode(address, deployedBytecode); + + // save for later + this._evmIfExists = vm; + this._evmAccountIfExists = accountAddress; + } + const result = await this._evmIfExists.runCall({ + to: this.address.substr(2), + caller: this._evmAccountIfExists, + origin: this._evmAccountIfExists, + data: input, + }); + + const hexReturnValue = `0x${result.execResult.returnValue.toString('hex')}`; + return hexReturnValue; + } protected _lookupAbiEncoder(functionSignature: string): AbiEncoder.Method { const abiEncoder = this._abiEncoderByFunctionSignature[functionSignature]; if (abiEncoder === undefined) { diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index becd38ef26..0de9af11f1 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -135,6 +135,9 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions resolve: { extensions: ['.js', '.json', '.ts', '.tsx'], }, + node: { + fs: 'empty', + }, module: { rules: [ { diff --git a/yarn.lock b/yarn.lock index bf8231c09d..56d085d739 100644 --- a/yarn.lock +++ b/yarn.lock @@ -758,7 +758,6 @@ "@0x/json-schemas@^3.0.1", "@0x/json-schemas@^3.0.11", "@0x/json-schemas@^3.0.2", "@0x/json-schemas@^3.0.3", "@0x/json-schemas@^3.1.11": version "3.1.13" resolved "https://registry.yarnpkg.com/@0x/json-schemas/-/json-schemas-3.1.13.tgz#4b9010f1bdeaf2aef1daba1753aa2e5ecf57f654" - integrity sha512-V93sF6seHDHFCSLZOOEhgY5k+w+78tLmxJRhj8XvsW4+EnXcgpshxK38P6SQAmBoNLDutmM8Wk1inf6ghiW0qA== dependencies: "@0x/typescript-typings" "^4.2.4" "@types/node" "*" @@ -819,7 +818,6 @@ "@0x/ts-doc-gen@^0.0.21": version "0.0.21" resolved "https://registry.yarnpkg.com/@0x/ts-doc-gen/-/ts-doc-gen-0.0.21.tgz#771a6e268a30d82eea3848b2d6b778a7872643a8" - integrity sha512-z5GUwcEWp5NaVTYph4Xiub+Z4itVQ7x51AUW1ad1iXMSwVP0HuwhfFlFUarMtj92ul0ZFnh+0VIEUYd9XHSV9Q== dependencies: "@0x/typescript-typings" "^4.2.2" "@0x/utils" "^4.3.3" @@ -892,7 +890,6 @@ "@babel/runtime@^7.1.5": version "7.5.5" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.5.5.tgz#74fba56d35efbeca444091c7850ccd494fd2f132" - integrity sha512-28QvEGyQyNkB0/m2B4FU7IEZGK2NUrcMtT6BZEFALTguLk+AUT6ofsHtPk5QyjAdUkpMJ+/Em+quwz4HOt30AQ== dependencies: regenerator-runtime "^0.13.2" @@ -1564,7 +1561,6 @@ "@mrmlnc/readdir-enhanced@^2.2.1": version "2.2.1" resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" - integrity sha512-bPHp6Ji8b41szTOcaP63VlnbbO5Ny6dwAATtY6JTjh5N2OLrb5Qk/Th5cRkRQhkWCt+EJsYrNB0MiL+Gpn6e3g== dependencies: call-me-maybe "^1.0.1" glob-to-regexp "^0.3.0" @@ -1572,12 +1568,10 @@ "@nodelib/fs.stat@^1.1.2": version "1.1.3" resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b" - integrity sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw== "@octokit/endpoint@^5.1.0": version "5.3.2" resolved "https://registry.yarnpkg.com/@octokit/endpoint/-/endpoint-5.3.2.tgz#2deda2d869cac9ba7f370287d55667be2a808d4b" - integrity sha512-gRjteEM9I6f4D8vtwU2iGUTn9RX/AJ0SVXiqBUEuYEWVGGAVjSXdT0oNmghH5lvQNWs8mwt6ZaultuG6yXivNw== dependencies: deepmerge "4.0.0" is-plain-object "^3.0.0" @@ -1587,12 +1581,10 @@ "@octokit/plugin-enterprise-rest@^3.6.1": version "3.6.2" resolved "https://registry.yarnpkg.com/@octokit/plugin-enterprise-rest/-/plugin-enterprise-rest-3.6.2.tgz#74de25bef21e0182b4fa03a8678cd00a4e67e561" - integrity sha512-3wF5eueS5OHQYuAEudkpN+xVeUsg8vYEMMenEzLphUZ7PRZ8OJtDcsreL3ad9zxXmBbaFWzLmFcdob5CLyZftA== "@octokit/request-error@^1.0.1", "@octokit/request-error@^1.0.2": version "1.0.4" resolved "https://registry.yarnpkg.com/@octokit/request-error/-/request-error-1.0.4.tgz#15e1dc22123ba4a9a4391914d80ec1e5303a23be" - integrity sha512-L4JaJDXn8SGT+5G0uX79rZLv0MNJmfGa4vb4vy1NnpjSnWDLJRy6m90udGwvMmavwsStgbv2QNkPzzTCMmL+ig== dependencies: deprecation "^2.0.0" once "^1.4.0" @@ -1600,7 +1592,6 @@ "@octokit/request@^5.0.0": version "5.0.2" resolved "https://registry.yarnpkg.com/@octokit/request/-/request-5.0.2.tgz#59a920451f24811c016ddc507adcc41aafb2dca5" - integrity sha512-z1BQr43g4kOL4ZrIVBMHwi68Yg9VbkRUyuAgqCp1rU3vbYa69+2gIld/+gHclw15bJWQnhqqyEb7h5a5EqgZ0A== dependencies: "@octokit/endpoint" "^5.1.0" "@octokit/request-error" "^1.0.1" @@ -1613,7 +1604,6 @@ "@octokit/rest@^16.28.4": version "16.28.7" resolved "https://registry.yarnpkg.com/@octokit/rest/-/rest-16.28.7.tgz#a2c2db5b318da84144beba82d19c1a9dbdb1a1fa" - integrity sha512-cznFSLEhh22XD3XeqJw51OLSfyL2fcFKUO+v2Ep9MTAFfFLS1cK1Zwd1yEgQJmJoDnj4/vv3+fGGZweG+xsbIA== dependencies: "@octokit/request" "^5.0.0" "@octokit/request-error" "^1.0.2" @@ -1858,7 +1848,6 @@ "@types/react-dom@16.0.6": version "16.0.6" resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-16.0.6.tgz#f1a65a4e7be8ed5d123f8b3b9eacc913e35a1a3c" - integrity sha512-M+1zmwa5KxUpkCuxA4whlDJKYTGNvNQW4pIoCLH16xGbClicD9CzPry4y94kTjCCk/bJZCZ/GVqUsP7eKcO/mQ== dependencies: "@types/node" "*" "@types/react" "*" @@ -1886,7 +1875,6 @@ "@types/react-redux@^6.0.9": version "6.0.14" resolved "https://registry.yarnpkg.com/@types/react-redux/-/react-redux-6.0.14.tgz#8ffeb52c4f4d578bf74418d9aff5af7289924e4f" - integrity sha512-bvpWqBOvz2V+EfZ9Qu1d3gFKYCIn/BYoGWAVt1c526tbiI9rtfaBbjutbbapmtEZaEfLuHj3Ljg9qho0SBSwUg== dependencies: "@types/react" "*" redux "^4.0.0" @@ -1894,7 +1882,6 @@ "@types/react-router-dom@^4.3.4": version "4.3.4" resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-4.3.4.tgz#63a7a8558129d2f4ff76e4bdd099bf4b98e25a0d" - integrity sha512-xrwaWHpnxKk/TTRe7pmoGy3E4SyF/ojFqNfFJacw7OLdfLXRvGfk4r/XePVaZNVfeJzL8fcnNilPN7xOdJ/vGw== dependencies: "@types/history" "*" "@types/react" "*" @@ -2323,7 +2310,6 @@ ajv@^6.1.0: ajv@^6.5.3, ajv@^6.6.1: version "6.10.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.10.2.tgz#d3cea04d6b017b2894ad69040fec8b623eb4bd52" - integrity sha512-TXtUUEYHuaTEbLZWIKUr5pmBuhDLy+8KYtPYdcV8qC+pOZL+NKqYwvWSRrVXHn+ZmRRAu8vJTAznH7Oag6RVRw== dependencies: fast-deep-equal "^2.0.1" fast-json-stable-stringify "^2.0.0" @@ -2333,7 +2319,6 @@ ajv@^6.5.3, ajv@^6.6.1: alphanum-sort@^1.0.1, alphanum-sort@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3" - integrity sha1-l6ERlkmyEa0zaR2fn0hqjsn74KM= amdefine@>=0.0.4: version "1.0.1" @@ -2550,7 +2535,6 @@ array-ify@^1.0.0: array-initial@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/array-initial/-/array-initial-1.1.0.tgz#2fa74b26739371c3947bd7a7adc73be334b3d795" - integrity sha1-L6dLJnOTccOUe9enrcc74zSz15U= dependencies: array-slice "^1.0.0" is-number "^4.0.0" @@ -2558,7 +2542,6 @@ array-initial@^1.0.0: array-last@^1.1.1: version "1.3.0" resolved "https://registry.yarnpkg.com/array-last/-/array-last-1.3.0.tgz#7aa77073fec565ddab2493f5f88185f404a9d336" - integrity sha512-eOCut5rXlI6aCOS7Z7kCplKRKyiFQ6dHFBem4PwlwKeNFk2/XxTrhRh5T9PyaEWGy/NHTZWbY+nsZlNFJu9rYg== dependencies: is-number "^4.0.0" @@ -2692,7 +2675,6 @@ async-limiter@~1.0.0: async-settle@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-settle/-/async-settle-1.0.0.tgz#1d0a914bb02575bec8a8f3a74e5080f72b2c0c6b" - integrity sha1-HQqRS7Aldb7IqPOnTlCA9yssDGs= dependencies: async-done "^1.2.2" @@ -3525,7 +3507,6 @@ bach@^1.0.0: backbone@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/backbone/-/backbone-1.4.0.tgz#54db4de9df7c3811c3f032f34749a4cd27f3bd12" - integrity sha512-RLmDrRXkVdouTg38jcgHhyQ/2zjg7a8E6sz2zxfz21Hh17xDJYUHBZimVIt5fUyS8vbfpeSmTL3gUjTEvUV3qQ== dependencies: underscore ">=1.8.3" @@ -3915,7 +3896,6 @@ braces@^2.3.1, braces@^2.3.2: braces@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== dependencies: fill-range "^7.0.1" @@ -5147,7 +5127,6 @@ conventional-recommended-bump@^4.0.1: conventional-recommended-bump@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/conventional-recommended-bump/-/conventional-recommended-bump-5.0.1.tgz#5af63903947b6e089e77767601cb592cabb106ba" - integrity sha512-RVdt0elRcCxL90IrNP0fYCpq1uGt2MALko0eyeQ+zQuDVWtMGAy9ng6yYn3kax42lCj9+XBxQ8ZN6S9bdKxDhQ== dependencies: concat-stream "^2.0.0" conventional-changelog-preset-loader "^2.1.1" @@ -5232,6 +5211,10 @@ copyfiles@^2.0.0: through2 "^2.0.1" yargs "^11.0.0" +core-js-pure@^3.0.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.2.1.tgz#879a23699cff46175bfd2d09158b5c50645a3c45" + core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" @@ -5605,7 +5588,6 @@ debug@3.1.0, debug@=3.1.0, debug@^3.1.0: debug@3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" - integrity sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ== dependencies: ms "^2.1.1" @@ -6227,7 +6209,6 @@ elliptic@=6.4.0, elliptic@^6.0.0, elliptic@^6.2.3, elliptic@^6.4.0: elliptic@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-3.1.0.tgz#c21682ef762769b56a74201609105da11d5f60cc" - integrity sha1-whaC73YnabVqdCAWCRBdoR1fYMw= dependencies: bn.js "^2.0.3" brorand "^1.0.1" @@ -6297,7 +6278,6 @@ entities@^1.1.1, entities@~1.1.1: env-paths@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/env-paths/-/env-paths-1.0.0.tgz#4168133b42bb05c38a35b1ae4397c8298ab369e0" - integrity sha1-QWgTO0K7BcOKNbGuQ5fIKYqzaeA= enzyme-adapter-react-16@^1.5.0: version "1.5.0" @@ -6781,7 +6761,7 @@ ethereumjs-account@2.0.5: rlp "^2.0.0" safe-buffer "^5.1.1" -ethereumjs-account@3.0.0: +ethereumjs-account@3.0.0, ethereumjs-account@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ethereumjs-account/-/ethereumjs-account-3.0.0.tgz#728f060c8e0c6e87f1e987f751d3da25422570a9" dependencies: @@ -6841,6 +6821,21 @@ ethereumjs-blockchain@^3.4.0: safe-buffer "^5.1.2" semaphore "^1.1.0" +ethereumjs-blockchain@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/ethereumjs-blockchain/-/ethereumjs-blockchain-4.0.1.tgz#db113dfed4fcc5197d223391f10adbc5a1b3536b" + dependencies: + async "^2.6.1" + ethashjs "~0.0.7" + ethereumjs-block "~2.2.0" + ethereumjs-common "^1.1.0" + ethereumjs-util "~6.1.0" + flow-stoplight "^1.0.0" + level-mem "^3.0.1" + lru-cache "^5.1.1" + rlp "^2.2.2" + semaphore "^1.1.0" + ethereumjs-blockstream@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/ethereumjs-blockstream/-/ethereumjs-blockstream-6.0.0.tgz#79d726d1f358935eb65195e91d40344c31e87eff" @@ -6865,6 +6860,10 @@ ethereumjs-common@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.1.0.tgz#5ec9086c314d619d8f05e79a0525829fcb0e93cb" +ethereumjs-common@^1.3.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/ethereumjs-common/-/ethereumjs-common-1.3.1.tgz#a5cffac41beb7ad393283b2e5aa71fadf8a9cc73" + ethereumjs-tx@1.3.7: version "1.3.7" resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-1.3.7.tgz#88323a2d875b10549b8347e09f4862b546f3d89a" @@ -6879,6 +6878,13 @@ ethereumjs-tx@^1.1.1, ethereumjs-tx@^1.2.0, ethereumjs-tx@^1.2.2, ethereumjs-tx@ ethereum-common "^0.0.18" ethereumjs-util "^5.0.0" +ethereumjs-tx@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/ethereumjs-tx/-/ethereumjs-tx-2.1.0.tgz#36b9e6a46383b18941644ba5264e1b506115c002" + dependencies: + ethereumjs-common "^1.3.0" + ethereumjs-util "^6.0.0" + ethereumjs-util@5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-5.2.0.tgz#3e0c0d1741471acf1036052d048623dee54ad642" @@ -6891,7 +6897,7 @@ ethereumjs-util@5.2.0: safe-buffer "^5.1.1" secp256k1 "^3.0.1" -ethereumjs-util@6.1.0, ethereumjs-util@^6.0.0: +ethereumjs-util@6.1.0, ethereumjs-util@^6.0.0, ethereumjs-util@^6.1.0, ethereumjs-util@~6.1.0: version "6.1.0" resolved "https://registry.yarnpkg.com/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz#e9c51e5549e8ebd757a339cc00f5380507e799c8" dependencies: @@ -6986,6 +6992,26 @@ ethereumjs-vm@^2.0.2, ethereumjs-vm@^2.1.0, ethereumjs-vm@^2.3.4: rustbn.js "~0.1.1" safe-buffer "^5.1.1" +ethereumjs-vm@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/ethereumjs-vm/-/ethereumjs-vm-4.0.0.tgz#cede265f4d3262782ef7b7faccdf6af1e49eb58d" + dependencies: + async "^2.1.2" + async-eventemitter "^0.2.2" + core-js-pure "^3.0.1" + ethereumjs-account "^3.0.0" + ethereumjs-block "~2.2.0" + ethereumjs-blockchain "^4.0.1" + ethereumjs-common "^1.3.0" + ethereumjs-tx "^2.1.0" + ethereumjs-util "^6.1.0" + fake-merkle-patricia-tree "^1.0.1" + functional-red-black-tree "^1.0.1" + merkle-patricia-tree "^2.3.2" + rustbn.js "~0.2.0" + safe-buffer "^5.1.1" + util.promisify "^1.0.0" + ethereumjs-wallet@0.6.3: version "0.6.3" resolved "https://registry.yarnpkg.com/ethereumjs-wallet/-/ethereumjs-wallet-0.6.3.tgz#b0eae6f327637c2aeb9ccb9047b982ac542e6ab1" @@ -7081,7 +7107,6 @@ eventemitter3@^3.0.0: eventemitter3@^3.1.0: version "3.1.2" resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-3.1.2.tgz#2d3d48f9c346698fce83a85d7d664e98535df6e7" - integrity sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q== events@1.1.1, events@^1.0.0: version "1.1.1" @@ -7309,7 +7334,6 @@ extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: extend@~3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.2.tgz#f8b1136b4071fbd8eb140aff858b1019ec2915fa" - integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== external-editor@^2.0.4: version "2.2.0" @@ -8152,7 +8176,6 @@ git-semver-tags@^2.0.2: git-semver-tags@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/git-semver-tags/-/git-semver-tags-2.0.3.tgz#48988a718acf593800f99622a952a77c405bfa34" - integrity sha512-tj4FD4ww2RX2ae//jSrXZzrocla9db5h0V7ikPl1P/WwoZar9epdUhwR7XHXSgc+ZkNq72BEEerqQuicoEQfzA== dependencies: meow "^4.0.0" semver "^6.0.0" @@ -8309,7 +8332,6 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, gl glob@^7.1.4: version "7.1.4" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.4.tgz#aa608a2f6c577ad357e1ae5a5c26d9a8d1969255" - integrity sha512-hkLPepehmnKk41pUGm3sYxoFs/umurYfYJCerbXEyFIWcAzvpipAgVkBqqT9RBKMGjnq6kMuyYwha6csxbiM1A== dependencies: fs.realpath "^1.0.0" inflight "^1.0.4" @@ -8482,26 +8504,22 @@ got@^6.7.1: url-parse-lax "^1.0.0" graceful-fs@^3.0.0: - version "3.0.11" - resolved "http://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.11.tgz#7613c778a1afea62f25c630a086d7f3acbbdd818" - integrity sha1-dhPHeKGv6mLyXGMKCG1/Osu92Bg= + version "3.0.12" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-3.0.12.tgz#0034947ce9ed695ec8ab0b854bc919e82b1ffaef" dependencies: - natives "^1.1.0" + natives "^1.1.3" graceful-fs@^4.0.0, graceful-fs@^4.1.10, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6, graceful-fs@^4.1.9: version "4.1.15" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" - integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== graceful-fs@^4.2.0: - version "4.2.1" - resolved "http://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.1.tgz#1c1f0c364882c868f5bff6512146328336a11b1d" - integrity sha512-b9usnbDGnD928gJB3LrCmxoibr3VE4U2SMo5PBuBnokWyDADTqDPXg4YpwKF1trpH+UbGp7QLicO3+aWEy0+mw== + version "4.2.2" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.2.tgz#6f0952605d0140c1cfdb138ed005775b92d67b02" graceful-fs@~1.2.0: version "1.2.3" - resolved "http://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" - integrity sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q= + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-1.2.3.tgz#15a4806a57547cb2d2dbf27f42e89a8c3451b364" "graceful-readlink@>= 1.0.0": version "1.0.1" @@ -8800,14 +8818,13 @@ heap@0.2.6: version "0.2.6" resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.6.tgz#087e1f10b046932fc8594dd9e6d378afc9d1e5ac" -highlight.js@^9.13.1, highlight.js@^9.6.0: +highlight.js@^9.13.1: version "9.13.1" resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.13.1.tgz#054586d53a6863311168488a0f58d6c505ce641e" -highlight.js@^9.15.8: - version "9.15.10" - resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.15.10.tgz#7b18ed75c90348c045eef9ed08ca1319a2219ad2" - integrity sha512-RoV7OkQm0T3os3Dd2VHLNMoaoDVx77Wygln3n9l5YV172XonWG6rgQD3XnF/BuFFZw9A0TJgmMSO8FEWQgvcXw== +highlight.js@^9.15.8, highlight.js@^9.6.0: + version "9.15.9" + resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.15.9.tgz#865257da1dbb4a58c4552d46c4b3854f77f0e6d5" hmac-drbg@^1.0.0: version "1.0.1" @@ -10182,7 +10199,6 @@ jmespath@0.15.0: jquery@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.1.tgz#714f1f8d9dde4bdfa55764ba37ef214630d80ef2" - integrity sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw== js-base64@^2.1.9: version "2.4.3" @@ -10836,7 +10852,6 @@ load-json-file@^4.0.0: load-json-file@^5.3.0: version "5.3.0" resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-5.3.0.tgz#4d3c1e01fa1c03ea78a60ac7af932c9ce53403f3" - integrity sha512-cJGP40Jc/VXUsp8/OrnyKyTZ1y6v/dphm3bioS+RrKXjK2BB6wHUd6JptZEFDGgGahMT+InnZO5i1Ei9mpC8Bw== dependencies: graceful-fs "^4.1.15" parse-json "^4.0.0" @@ -11118,17 +11133,14 @@ lodash@4.17.11, lodash@=4.17.11: lodash@4.17.14: version "4.17.14" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba" - integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw== lodash@=4.17.4: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" - integrity sha1-eCA6TRwyiuHYbcpkYONptX9AVa4= lodash@^4.0.0, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.5.1: version "4.17.15" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" - integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== lodash@~1.0.1: version "1.0.2" @@ -11260,7 +11272,6 @@ lunr@^2.3.0: lunr@^2.3.6: version "2.3.6" resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.6.tgz#f278beee7ffd56ad86e6e478ce02ab2b98c78dd5" - integrity sha512-swStvEyDqQ85MGpABCMBclZcLI/pBIlu8FFDtmX197+oEgKloJ67QnB+Tidh0340HmLMs39c4GrkPY3cmkXp6Q== macaddress@^0.2.8: version "0.2.8" @@ -11378,7 +11389,6 @@ marked@0.3.18: marked@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/marked/-/marked-0.7.0.tgz#b64201f051d271b1edc10a04d1ae9b74bb8e5c0e" - integrity sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg== matchdep@^2.0.0: version "2.0.0" @@ -11948,10 +11958,9 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -natives@^1.1.0: +natives@^1.1.3: version "1.1.6" - resolved "http://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" - integrity sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA== + resolved "https://registry.yarnpkg.com/natives/-/natives-1.1.6.tgz#a603b4a498ab77173612b9ea1acdec4d980f00bb" natural-compare@^1.4.0: version "1.4.0" @@ -12304,7 +12313,6 @@ normalize-url@^1.4.0: normalize-url@^3.3.0: version "3.3.0" resolved "https://registry.yarnpkg.com/normalize-url/-/normalize-url-3.3.0.tgz#b2e1c4dc4f7c6d57743df733a4f5978d18650559" - integrity sha512-U+JJi7duF1o+u2pynbp2zXDW2/PADgC30f0GsHZtRh+HOcXHnw137TrNlyxxRvWW5fjKd3bcLHPxofWuCjaeZg== now-and-later@^2.0.0: version "2.0.0" @@ -13252,7 +13260,6 @@ performance-now@^2.1.0: picomatch@^2.0.4: version "2.0.7" resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.0.7.tgz#514169d8c7cd0bdbeecc8a2609e34a7163de69f6" - integrity sha512-oLHIdio3tZ0qH76NybpeneBhYVj0QFTfXEFTc/B3zKQspYfYYkWYgFsmzo+4kvId/bQRcNkVeguI3y+CD22BtA== pify@^2.0.0, pify@^2.2.0, pify@^2.3.0: version "2.3.0" @@ -13713,7 +13720,6 @@ progress@^2.0.0: progress@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" - integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== promise-inflight@^1.0.1: version "1.0.1" @@ -13746,7 +13752,6 @@ promisify-child-process@^1.0.5: promisify-child-process@^3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/promisify-child-process/-/promisify-child-process-3.1.1.tgz#3a029c1d97bdb8bbcc8862c765b91f1cee0f2691" - integrity sha512-683UHZEP4Bm75BvBujEe87AdE9lxnoWpcU5pEw4FG9HCSwwZC9pF7HUj3QmlDAvhyvulkWHLZs1lVRBNTvkbXQ== dependencies: "@babel/runtime" "^7.1.5" @@ -14167,7 +14172,6 @@ react-dom@^16.3.2: react-dom@^16.5.2: version "16.9.0" resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.9.0.tgz#5e65527a5e26f22ae3701131bcccaee9fb0d3962" - integrity sha512-YFT2rxO9hM70ewk9jq0y6sQk8cL02xm4+IzYBz75CQGlClQQ1Bxq0nhHF6OtSbit+AIahujJgb/CPRibFkMNJQ== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -14225,7 +14229,6 @@ react-loadable@^5.5.0: react-lottie@^1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/react-lottie/-/react-lottie-1.2.3.tgz#8544b96939e088658072eea5e12d912cdaa3acc1" - integrity sha512-qLCERxUr8M+4mm1LU0Ruxw5Y5Fn/OmYkGfnA+JDM/dZb3oKwVAJCjwnjkj9TMHtzR2U6sMEUD3ZZ1RaHagM7kA== dependencies: babel-runtime "^6.26.0" lottie-web "^5.1.3" @@ -14295,7 +14298,6 @@ react@^16.3.2: react@^16.5.2: version "16.9.0" resolved "https://registry.yarnpkg.com/react/-/react-16.9.0.tgz#40ba2f9af13bc1a38d75dbf2f4359a5185c4f7aa" - integrity sha512-+7LQnFBwkiw+BobzOF6N//BdoNw0ouwmSJTEm9cglOOmsg/TMiFHZLe2sEoN5M7LgJTj9oHH0gxklfnQe66S1w== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -14959,7 +14961,7 @@ rlp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.0.0.tgz#9db384ff4b89a8f61563d92395d8625b18f3afb0" -rlp@^2.2.1: +rlp@^2.2.1, rlp@^2.2.2: version "2.2.3" resolved "https://registry.yarnpkg.com/rlp/-/rlp-2.2.3.tgz#7f94aef86cec412df87d5ea1d8cb116a47d45f0e" dependencies: @@ -15115,7 +15117,6 @@ scheduler@^0.13.6: scheduler@^0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.15.0.tgz#6bfcf80ff850b280fed4aeecc6513bc0b4f17f8e" - integrity sha512-xAefmSfN6jqAa7Kuq7LIJY0bwAPG3xlCj0HMEBQk1lxYiDKZscY2xJ5U/61ZTrYbmNQbXa+gc7czPkVo11tnCg== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -15272,12 +15273,10 @@ semver@^5.5.1: semver@^5.6.0, semver@^5.7.0: version "5.7.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.0.tgz#790a7cf6fea5459bac96110b29b60412dc8ff96b" - integrity sha512-Ya52jSX2u7QKghxeoFGpLwCtGlt7j0oY9DYb5apt9nPlJ42ID+ulTXESnt/qAQcoSERyZ5sl3LDIOw0nAn/5DA== semver@^6.0.0, semver@^6.2.0: version "6.3.0" resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" - integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== semver@~5.3.0: version "5.3.0" @@ -15440,7 +15439,6 @@ shelljs@^0.7.3: shelljs@^0.8.3: version "0.8.3" resolved "https://registry.yarnpkg.com/shelljs/-/shelljs-0.8.3.tgz#a7f3319520ebf09ee81275b2368adb286659b097" - integrity sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A== dependencies: glob "^7.0.0" interpret "^1.0.0" @@ -16909,7 +16907,6 @@ typedarray@^0.0.6: typedoc-default-themes@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.6.0.tgz#7e73bf54dd9e11550dd0fb576d5176b758f8f8b5" - integrity sha512-MdTROOojxod78CEv22rIA69o7crMPLnVZPefuDLt/WepXqJwgiSu8Xxq+H36x0Jj3YGc7lOglI2vPJ2GhoOybw== dependencies: backbone "^1.4.0" jquery "^3.4.1" @@ -16919,12 +16916,10 @@ typedoc-default-themes@^0.6.0: typedoc-plugin-markdown@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.1.0.tgz#17b7b97415b97214985d1a61ef7b9a4dce3e8305" - integrity sha512-f7CgreapeUIpm85BnC4ec9PZp10INOpLpItSCV4YFlZS4VaBA/a1D2nYv9+7TVJugc084XlSFUY+OX9fwGAUpA== typedoc@^0.15.0: version "0.15.0" resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.15.0.tgz#21eaf4db41cf2797bad027a74f2a75cd08ae0c2d" - integrity sha512-NOtfq5Tis4EFt+J2ozhVq9RCeUnfEYMFKoU6nCXCXUULJz1UQynOM+yH3TkfZCPLzigbqB0tQYGVlktUWweKlw== dependencies: "@types/minimatch" "3.0.3" fs-extra "^8.1.0" @@ -16977,7 +16972,6 @@ typescript@3.0.1: typescript@3.5.x: version "3.5.3" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.3.tgz#c830f657f93f1ea846819e929092f5fe5983e977" - integrity sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g== typewise-core@^1.2, typewise-core@^1.2.0: version "1.2.0" @@ -17084,7 +17078,6 @@ underscore@1.8.3: underscore@>=1.8.3, underscore@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961" - integrity sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg== underscore@~1.4.4: version "1.4.4" From e0a4c82970911084fd15c464668bcbde3bd2709b Mon Sep 17 00:00:00 2001 From: xianny Date: Thu, 29 Aug 2019 11:02:07 -0700 Subject: [PATCH 2/7] increase container size to >=8gb for static-tests --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 30e1b71741..faea642077 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -282,6 +282,7 @@ jobs: ./install ./lint static-tests: + resource_class: large working_directory: ~/repo docker: - image: nikolaik/python-nodejs:python3.7-nodejs8 From 1c5de77ecdcc813d661bfe246b3187e796dc2a14 Mon Sep 17 00:00:00 2001 From: xianny Date: Thu, 29 Aug 2019 12:07:32 -0700 Subject: [PATCH 3/7] increase max bundle size because of ethereumjs-vm dependency --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 18439ecbd0..395d7d0c70 100644 --- a/package.json +++ b/package.json @@ -58,11 +58,11 @@ "files": [ { "path": "packages/0x.js/_bundles/index.min.js", - "maxSize": "800kB" + "maxSize": "1150kB" }, { "path": "packages/instant/umd/instant.js", - "maxSize": "1000kB" + "maxSize": "1350kB" } ], "ci": { From 62d7cd559c89f717bb7a0e8b144ce4560d2aeee3 Mon Sep 17 00:00:00 2001 From: xianny Date: Thu, 29 Aug 2019 17:38:14 -0700 Subject: [PATCH 4/7] add declarations for ethereumjs-vm in @0x/typescript-typings --- packages/base-contract/src/globals.d.ts | 2 - packages/base-contract/src/index.ts | 13 +- packages/base-contract/tsconfig.json | 1 + .../types/ethereumjs-vm/index.d.ts | 334 ++++++++++++++++++ 4 files changed, 341 insertions(+), 9 deletions(-) create mode 100644 packages/typescript-typings/types/ethereumjs-vm/index.d.ts diff --git a/packages/base-contract/src/globals.d.ts b/packages/base-contract/src/globals.d.ts index b3d0c15e8a..94e63a32de 100644 --- a/packages/base-contract/src/globals.d.ts +++ b/packages/base-contract/src/globals.d.ts @@ -4,5 +4,3 @@ declare module '*.json' { export default json; /* tslint:enable */ } - -declare module 'ethereumjs-vm'; diff --git a/packages/base-contract/src/index.ts b/packages/base-contract/src/index.ts index b12796c9bd..648457899f 100644 --- a/packages/base-contract/src/index.ts +++ b/packages/base-contract/src/index.ts @@ -16,7 +16,7 @@ import { } from 'ethereum-types'; import Account from 'ethereumjs-account'; import * as util from 'ethereumjs-util'; -import * as ethereumJsVm from 'ethereumjs-vm'; +import { default as VM } from 'ethereumjs-vm'; import PStateManager from 'ethereumjs-vm/dist/state/promisified'; import * as ethers from 'ethers'; import * as _ from 'lodash'; @@ -31,7 +31,6 @@ export interface AbiEncoderByFunctionSignature { [key: string]: AbiEncoder.Method; } -const VM = ethereumJsVm.default; const ARBITRARY_PRIVATE_KEY = 'e331b6d69882b4cb4ea581d88e0b604039a3de5967688d3dcffdd2270c0fd109'; // tslint:disable: max-classes-per-file @@ -68,7 +67,7 @@ export class BaseContract { public address: string; public contractName: string; public constructorArgs: any[] = []; - private _evmIfExists?: any; // hack (xianny): VM is also used as a namespace + private _evmIfExists?: VM; private _evmAccountIfExists?: Buffer; protected static _formatABIDataItemList( abis: DataItem[], @@ -160,9 +159,10 @@ export class BaseContract { return rawEncoded; } public async evmExecAsync(input: Buffer): Promise { + const addressBuf = Buffer.from(this.address.substr(2), 'hex'); // should only run once, the first time it is called if (this._evmIfExists === undefined) { - const vm = new VM(); + const vm = new VM({}); const psm = new PStateManager(vm.stateManager); // create an account with 1 ETH @@ -173,16 +173,15 @@ export class BaseContract { // 'deploy' the contract const contractCode = await this._web3Wrapper.getContractCodeAsync(this.address); - const address = Buffer.from(this.address.substr(2), 'hex'); const deployedBytecode = Buffer.from(contractCode.substr(2), 'hex'); - await psm.putContractCode(address, deployedBytecode); + await psm.putContractCode(addressBuf, deployedBytecode); // save for later this._evmIfExists = vm; this._evmAccountIfExists = accountAddress; } const result = await this._evmIfExists.runCall({ - to: this.address.substr(2), + to: addressBuf, caller: this._evmAccountIfExists, origin: this._evmAccountIfExists, data: input, diff --git a/packages/base-contract/tsconfig.json b/packages/base-contract/tsconfig.json index 718e623c74..bf70fcb4cd 100644 --- a/packages/base-contract/tsconfig.json +++ b/packages/base-contract/tsconfig.json @@ -4,5 +4,6 @@ "outDir": "lib", "rootDir": "." }, + "typeRoots": ["node_modules/@0x/typescript-typings/types", "node_modules/@types"], "include": ["src/**/*", "test/**/*"] } diff --git a/packages/typescript-typings/types/ethereumjs-vm/index.d.ts b/packages/typescript-typings/types/ethereumjs-vm/index.d.ts new file mode 100644 index 0000000000..b5cd6ffa37 --- /dev/null +++ b/packages/typescript-typings/types/ethereumjs-vm/index.d.ts @@ -0,0 +1,334 @@ +declare module 'ethereumjs-vm' { + import BN = require('bn.js'); + type Common = any; // from ethereumjs-common + type Account = any; // from ethereumjs-account + type Blockchain = any; // from ethereumjs-blockchain + + export default class VM { + opts: VmOpts; + stateManager: StateManager; + constructor(opts: VmOpts); + runCall(opts: RunCallOpts): Promise; + } + + interface VmOpts { + chain?: string; + hardfork?: string; + stateManager?: StateManager; + state?: any; + blockchain?: Blockchain; + activatePrecompiles?: boolean; + allowUnlimitedContractSize?: boolean; + common?: Common; + } + + interface RunCallOpts { + block?: any; + gasPrice?: Buffer; + origin?: Buffer; + caller?: Buffer; + gasLimit?: Buffer; + to?: Buffer; + value?: Buffer; + data?: Buffer; + code?: Buffer; + depth?: number; + compiled?: boolean; + static?: boolean; + salt?: Buffer; + selfdestruct?: { [k: string]: boolean }; + delegatecall?: boolean; + } + + interface EVMResult { + gasUsed: BN; + createdAddress?: Buffer; + execResult: ExecResult; + } + + interface ExecResult { + runState?: RunState; + exceptionError?: VmError; + gas?: BN; + gasUsed: BN; + returnValue: Buffer; + logs?: any[]; + gasRefund?: BN; + selfdestruct?: { [k: string]: Buffer }; + } + interface RunState { + programCounter: number; + opCode: number; + memory: Memory; + memoryWordCount: BN; + highestMemCost: BN; + stack: Stack; + code: Buffer; + validJumps: number[]; + _common: Common; + stateManager: StateManager; + eei: EEI; + } + + class Memory { + _store: number[]; + constructor(); + extend(offset: number, size: number): void; + write(offset: number, size: number, value: Buffer): void; + read(offset: number, size: number): Buffer; + } + + class Stack { + _store: BN[]; + constructor(); + length(): number; + push(value: BN): void; + pop(): BN; + popN(num: number): BN[]; + swap(position: number): void; + dup(position: number): void; + } + + class StateManager { + _common: Common; + _trie: any; + _storageTries: any; + _cache: Cache; + _touched: Set; + _touchedStack: Set[]; + _checkpointCount: number; + _originalStorageCache: Map>; + + constructor(opts: StateManagerOpts); + copy(): StateManager; + getAccount(address: Buffer, cb: any): void; + putAccount(address: Buffer, account: Account, cb: any): void; + putContractCode(address: Buffer, value: Buffer, cb: any): void; + getContractCode(address: Buffer, cb: any): void; + _lookupStorageTrie(address: Buffer, cb: any): void; + _getStorageTrie(address: Buffer, cb: any): void; + getContractStorage(address: Buffer, key: Buffer, cb: any): void; + getOriginalContractStorage(address: Buffer, key: Buffer, cb: any): void; + _modifyContractStorage(address: Buffer, modifyTrie: any, cb: any): void; + putContractStorage(address: Buffer, key: Buffer, value: Buffer, cb: any): void; + clearContractStorage(address: Buffer, cb: any): void; + checkpoint(cb: any): void; + commit(cb: any): void; + revert(cb: any): void; + getStateRoot(cb: any): void; + setStateRoot(stateRoot: Buffer, cb: any): void; + dumpStorage(address: Buffer, cb: any): void; + hasGenesisState(cb: any): void; + generateCanonicalGenesis(cb: any): void; + generateGenesis(initState: any, cb: any): void; + accountIsEmpty(address: Buffer, cb: any): void; + cleanupTouchedAccounts(cb: any): void; + _clearOriginalStorageCache(): void; + } + + class Cache { + _cache: any; + _checkpoints: any[]; + _trie: any; + constructor(trie: any); + put(key: Buffer, val: Account, fromTrie: boolean): void; + get(key: Buffer): Account; + lookup(key: Buffer): Account | undefined; + _lookupAccount(address: Buffer, cb: any): void; + getOrLoad(key: Buffer, cb: any): void; + warm(addresses: string[], cb: any): void; + flush(cb: any): void; + checkpoint(): void; + revert(): void; + commit(): void; + clear(): void; + del(key: Buffer): void; + _update(key: Buffer, val: Account, modified: boolean, deleted: boolean): void; + } + + interface StateManagerOpts { + common?: Common; + trie?: any; + } + + class EEI { + _env: Env; + _result: RunResult; + _state: PStateManager; + _evm: EVM; + _lastReturned: Buffer; + _common: Common; + _gasLeft: BN; + constructor(env: Env, state: PStateManager, evm: EVM, common: Common, gasLeft: BN); + useGas(amount: BN): void; + refundGas(amount: BN): void; + getAddress(): Buffer; + getExternalBalance(address: Buffer): Promise; + getSelfBalance(): BN; + getCaller(): BN; + getCallValue(): BN; + getCallData(): Buffer; + getCallDataSize(): BN; + getCodeSize(): BN; + getCode(): Buffer; + isStatic(): boolean; + getExternalCodeSize(address: BN): Promise; + getExternalCode(address: BN | Buffer): Promise; + getReturnDataSize(): BN; + getReturnData(): Buffer; + getTxGasPrice(): BN; + getTxOrigin(): BN; + getBlockNumber(): BN; + getBlockCoinbase(): BN; + getBlockTimestamp(): BN; + getBlockDifficulty(): BN; + getBlockGasLimit(): BN; + getChainId(): BN; + getBlockHash(num: BN): Promise; + storageStore(key: Buffer, value: Buffer): Promise; + storageLoad(key: Buffer): Promise; + getGasLeft(): BN; + finish(returnData: Buffer): void; + revert(returnData: Buffer): void; + selfDestruct(toAddress: Buffer): Promise; + _selfDestruct(toAddress: Buffer): Promise; + log(data: Buffer, numberOfTopics: number, topics: Buffer[]): void; + call(gasLimit: BN, address: Buffer, value: BN, data: Buffer): Promise; + callCode(gasLimit: BN, address: Buffer, value: BN, data: Buffer): Promise; + callStatic(gasLimit: BN, address: Buffer, value: BN, data: Buffer): Promise; + callDelegate(gasLimit: BN, address: Buffer, value: BN, data: Buffer): Promise; + _baseCall(msg: Message): Promise; + create(gasLimit: BN, value: BN, data: Buffer, salt: Buffer | null): Promise; + create2(gasLimit: BN, value: BN, data: Buffer, salt: Buffer): Promise; + isAccountEmpty(address: Buffer): Promise; + private _getReturnCode(results: EVMResult): any; + } + + interface Env { + blockchain: Blockchain; + address: Buffer; + caller: Buffer; + callData: Buffer; + callValue: BN; + code: Buffer; + isStatic: boolean; + depth: number; + gasPrice: Buffer; + origin: Buffer; + block: any; + contract: Account; + } + + interface RunResult { + logs: any; + returnValue?: Buffer; + gasRefund: BN; + selfdestruct: { [k: string]: Buffer }; + } + + export class PStateManager { + _wrapped: StateManager; + constructor(wrapped: StateManager); + copy(): PStateManager; + getAccount(addr: Buffer): Promise; + putAccount(addr: Buffer, account: Account): Promise; + putContractCode(addr: Buffer, code: Buffer): Promise; + getContractCode(addr: Buffer): Promise; + getContractStorage(addr: Buffer, key: Buffer): Promise; + getOriginalContractStorage(addr: Buffer, key: Buffer): Promise; + putContractStorage(addr: Buffer, key: Buffer, value: Buffer): Promise; + clearContractStorage(addr: Buffer): Promise; + checkpoint(): Promise; + commit(): Promise; + revert(): Promise; + getStateRoot(): Promise; + setStateRoot(root: Buffer): Promise; + dumpStorage(address: Buffer): Promise; + hasGenesisState(): Promise; + generateCanonicalGenesis(): Promise; + generateGenesis(initState: any): Promise; + accountIsEmpty(address: Buffer): Promise; + cleanupTouchedAccounts(): Promise; + } + + interface StorageDump { + [key: string]: string; + } + + class EVM { + _vm: any; + _state: PStateManager; + _tx: TxContext; + _block: any; + constructor(vm: any, txContext: TxContext, block: any); + executeMessage(message: Message): Promise; + _executeCall(message: Message): Promise; + _executeCreate(message: Message): Promise; + runInterpreter(message: Message, opts: InterpreterOpts): Promise; + getPrecompile(address: Buffer): PrecompileFunc; + runPrecompile(code: PrecompileFunc, data: Buffer, gasLimit: BN): ExecResult; + _loadCode(message: Message): Promise; + _generateAddress(message: Message): Promise; + _reduceSenderBalance(account: Account, message: Message): Promise; + _addToBalance(toAccount: Account, message: Message): Promise; + _touchAccount(address: Buffer): Promise; + } + + class TxContext { + gasPrice: Buffer; + origin: Buffer; + constructor(gasPrice: Buffer, origin: Buffer); + } + + class Message { + to: Buffer; + value: BN; + caller: Buffer; + gasLimit: BN; + data: Buffer; + depth: number; + code: Buffer | PrecompileFunc; + _codeAddress: Buffer; + isStatic: boolean; + isCompiled: boolean; + salt: Buffer; + selfdestruct: any; + delegatecall: boolean; + constructor(opts: any); + codeAddress(): Buffer; + } + + interface InterpreterOpts { + pc?: number; + } + + interface PrecompileFunc { + (opts: PrecompileInput): ExecResult; + } + + interface PrecompileInput { + data: Buffer; + gasLimit: BN; + _common: Common; + } + + class VmError { + error: ERROR; + errorType: string; + constructor(error: ERROR); + } + + enum ERROR { + OUT_OF_GAS = 'out of gas', + STACK_UNDERFLOW = 'stack underflow', + STACK_OVERFLOW = 'stack overflow', + INVALID_JUMP = 'invalid JUMP', + INVALID_OPCODE = 'invalid opcode', + OUT_OF_RANGE = 'value out of range', + REVERT = 'revert', + STATIC_STATE_CHANGE = 'static state change', + INTERNAL_ERROR = 'internal error', + CREATE_COLLISION = 'create collision', + STOP = 'stop', + } +} From 5ead509172e4438b5a860f039ee475403205dea5 Mon Sep 17 00:00:00 2001 From: xianny Date: Fri, 6 Sep 2019 12:03:26 -0700 Subject: [PATCH 5/7] add changelogs --- packages/abi-gen-wrappers/CHANGELOG.json | 9 +++++++++ packages/abi-gen/CHANGELOG.json | 9 +++++++++ packages/base-contract/CHANGELOG.json | 9 +++++++++ packages/typescript-typings/CHANGELOG.json | 9 +++++++++ 4 files changed, 36 insertions(+) diff --git a/packages/abi-gen-wrappers/CHANGELOG.json b/packages/abi-gen-wrappers/CHANGELOG.json index 80b6250997..3dfe780445 100644 --- a/packages/abi-gen-wrappers/CHANGELOG.json +++ b/packages/abi-gen-wrappers/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "5.3.2", + "changes": [ + { + "note": "Redirect `callAsync` to use local EVM instead of eth_call for pure functions", + "pr": 2108 + } + ] + }, { "timestamp": 1567521715, "version": "5.3.1", diff --git a/packages/abi-gen/CHANGELOG.json b/packages/abi-gen/CHANGELOG.json index 26ab55793d..b956869de2 100644 --- a/packages/abi-gen/CHANGELOG.json +++ b/packages/abi-gen/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.2.1", + "changes": [ + { + "note": "Redirect to `evmExecAsync` to use local EVM instead of eth_call for pure functions", + "pr": 2108 + } + ] + }, { "version": "4.2.0", "changes": [ diff --git a/packages/base-contract/CHANGELOG.json b/packages/base-contract/CHANGELOG.json index 72118cd075..7e43a1afb5 100644 --- a/packages/base-contract/CHANGELOG.json +++ b/packages/base-contract/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "5.4.0", + "changes": [ + { + "note": "Add `evmExecAsync` to use local EVM instead of eth_call for pure functions", + "pr": 2108 + } + ] + }, { "timestamp": 1567521715, "version": "5.3.3", diff --git a/packages/typescript-typings/CHANGELOG.json b/packages/typescript-typings/CHANGELOG.json index d964eae7fc..f047b62ef8 100644 --- a/packages/typescript-typings/CHANGELOG.json +++ b/packages/typescript-typings/CHANGELOG.json @@ -1,4 +1,13 @@ [ + { + "version": "4.3.0", + "changes": [ + { + "note": "Add declaration for `ethereumjs-vm`", + "pr": 2108 + } + ] + }, { "timestamp": 1567521715, "version": "4.2.5", From 456669f77a71cbce441014a3d01bc22737db8db7 Mon Sep 17 00:00:00 2001 From: xianny Date: Mon, 9 Sep 2019 11:48:03 -0700 Subject: [PATCH 6/7] tweak to webpack configs and README --- packages/0x.js/README.md | 26 ++++++++++++++++++++++++++ packages/0x.js/webpack.config.js | 8 ++++++-- packages/instant/webpack.config.js | 8 ++++++-- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/packages/0x.js/README.md b/packages/0x.js/README.md index d120aef8a6..1ea12cd9d5 100644 --- a/packages/0x.js/README.md +++ b/packages/0x.js/README.md @@ -49,6 +49,32 @@ Download the UMD module from our [releases page](https://github.com/0xProject/0x ``` +#### Webpack config + +If bundling your project with [Webpack](https://webpack.js.org/), add the following to your `webpack.config.js`: + +If building for web: + +```js +node: { + fs: 'empty'; +} +``` + +If building a node library: + +```js +externals: { + fs: true; +} +``` + +`ContractWrappers` uses WebAssembly to simulate Ethereum calls. This toolchain involves generated 'glue' code that requires the `fs` built-in, but won't actually use it in a web environment. We tell Webpack not to resolve them since we won't need them. The specific dependency is [here](https://github.com/ethereumjs/rustbn.js/blob/master/lib/index.asm.js). + +Also see: +* https://webpack.js.org/configuration/externals +* https://webpack.js.org/configuration/node + ## Contributing We strongly recommend that the community help us make improvements and determine the future direction of 0x protocol. To report bugs within this package, please create an issue in this repository. diff --git a/packages/0x.js/webpack.config.js b/packages/0x.js/webpack.config.js index f9279315f4..fbdc404121 100644 --- a/packages/0x.js/webpack.config.js +++ b/packages/0x.js/webpack.config.js @@ -39,8 +39,12 @@ module.exports = { }), ], }, - node: { - fs: 'empty', + // This supports the ethereumjs-vm dependency in `@0x/base-contract` + // The .wasm 'glue' code generated by Emscripten requires these node builtins, + // but won't actually use them in a web environment. We tell Webpack to not resolve those + // require statements since we know we won't need them. + externals: { + fs: true, }, module: { rules: [ diff --git a/packages/instant/webpack.config.js b/packages/instant/webpack.config.js index 0de9af11f1..12742607e1 100644 --- a/packages/instant/webpack.config.js +++ b/packages/instant/webpack.config.js @@ -135,8 +135,12 @@ const generateConfig = (dischargeTarget, heapConfigOptions, rollbarConfigOptions resolve: { extensions: ['.js', '.json', '.ts', '.tsx'], }, - node: { - fs: 'empty', + // This supports the ethereumjs-vm dependency in `@0x/base-contract` + // The .wasm 'glue' code generated by Emscripten requires these node builtins, + // but won't actually use them in a web environment. We tell Webpack to not resolve those + // require statements since we know we won't need them. + externals: { + fs: true, }, module: { rules: [ From c53002a03e60cd33bccb8c1322425db6ad59e9b2 Mon Sep 17 00:00:00 2001 From: xianny Date: Mon, 9 Sep 2019 12:00:06 -0700 Subject: [PATCH 7/7] prettier --- packages/0x.js/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/0x.js/README.md b/packages/0x.js/README.md index 1ea12cd9d5..ba3288b5d5 100644 --- a/packages/0x.js/README.md +++ b/packages/0x.js/README.md @@ -72,8 +72,9 @@ externals: { `ContractWrappers` uses WebAssembly to simulate Ethereum calls. This toolchain involves generated 'glue' code that requires the `fs` built-in, but won't actually use it in a web environment. We tell Webpack not to resolve them since we won't need them. The specific dependency is [here](https://github.com/ethereumjs/rustbn.js/blob/master/lib/index.asm.js). Also see: -* https://webpack.js.org/configuration/externals -* https://webpack.js.org/configuration/node + +- https://webpack.js.org/configuration/externals +- https://webpack.js.org/configuration/node ## Contributing