diff options
Diffstat (limited to 'packages')
-rw-r--r-- | packages/abi-gen/CHANGELOG.md | 1 | ||||
-rw-r--r-- | packages/abi-gen/src/index.ts | 18 | ||||
-rw-r--r-- | packages/contracts/contract_templates/contract.handlebars | 25 | ||||
-rw-r--r-- | packages/contracts/contract_templates/partials/call.handlebars | 15 | ||||
-rw-r--r-- | packages/contracts/contract_templates/partials/params.handlebars | 3 | ||||
-rw-r--r-- | packages/contracts/contract_templates/partials/return_type.handlebars | 6 | ||||
-rw-r--r-- | packages/contracts/contract_templates/partials/tx.handlebars | 51 | ||||
-rw-r--r-- | packages/contracts/contract_templates/partials/typed_params.handlebars | 3 | ||||
-rw-r--r-- | packages/contracts/package.json | 1 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/DummyToken.json (renamed from packages/contracts/artifacts/DummyToken.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/ERC20Token.json (renamed from packages/contracts/artifacts/ERC20Token.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/ERC20Token_v1.json (renamed from packages/contracts/artifacts/ERC20Token_v1.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Exchange.json (renamed from packages/contracts/artifacts/Exchange.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/MaliciousToken.json (renamed from packages/contracts/artifacts/MaliciousToken.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Mintable.json (renamed from packages/contracts/artifacts/Mintable.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/MultiSigWallet.json (renamed from packages/contracts/artifacts/MultiSigWallet.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/MultiSigWalletWithTimeLock.json (renamed from packages/contracts/artifacts/MultiSigWalletWithTimeLock.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json (renamed from packages/contracts/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Ownable.json (renamed from packages/contracts/artifacts/Ownable.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Ownable_v1.json (renamed from packages/contracts/artifacts/Ownable_v1.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/SafeMath.json (renamed from packages/contracts/artifacts/SafeMath.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/SafeMath_v1.json (renamed from packages/contracts/artifacts/SafeMath_v1.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Token.json (renamed from packages/contracts/artifacts/Token.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/TokenRegistry.json (renamed from packages/contracts/artifacts/TokenRegistry.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/TokenTransferProxy.json (renamed from packages/contracts/artifacts/TokenTransferProxy.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/Token_v1.json (renamed from packages/contracts/artifacts/Token_v1.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/UnlimitedAllowanceToken.json (renamed from packages/contracts/artifacts/UnlimitedAllowanceToken.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/UnlimitedAllowanceToken_v1.json (renamed from packages/contracts/artifacts/UnlimitedAllowanceToken_v1.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/WETH9.json (renamed from packages/contracts/artifacts/WETH9.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/artifacts/ZRXToken.json (renamed from packages/contracts/artifacts/ZRXToken.json) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contract_wrappers/generated/dummy_token.ts | 434 | ||||
-rw-r--r-- | packages/contracts/src/contract_wrappers/generated/exchange.ts | 728 | ||||
-rw-r--r-- | packages/contracts/src/contract_wrappers/generated/token.ts | 215 | ||||
-rw-r--r-- | packages/contracts/src/contract_wrappers/generated/token_registry.ts | 548 | ||||
-rw-r--r-- | packages/contracts/src/contract_wrappers/generated/token_transfer_proxy.ts | 283 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol (renamed from packages/contracts/src/current/multisig/MultiSigWallet/MultiSigWallet.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol (renamed from packages/contracts/src/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol (renamed from packages/contracts/src/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol (renamed from packages/contracts/src/current/protocol/Exchange/Exchange.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol (renamed from packages/contracts/src/current/protocol/TokenRegistry/TokenRegistry.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol (renamed from packages/contracts/src/current/protocol/TokenTransferProxy/TokenTransferProxy.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol (renamed from packages/contracts/src/current/test/DummyToken/DummyToken.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol (renamed from packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/test/Mintable/Mintable.sol (renamed from packages/contracts/src/current/test/Mintable/Mintable.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol (renamed from packages/contracts/src/current/tokens/ERC20Token/ERC20Token.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/Token/Token.sol (renamed from packages/contracts/src/current/tokens/Token/Token.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol (renamed from packages/contracts/src/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol (renamed from packages/contracts/src/current/tokens/WETH9/WETH9.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol (renamed from packages/contracts/src/current/tokens/ZRXToken/ZRXToken.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol (renamed from packages/contracts/src/current/utils/Ownable/Ownable.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol (renamed from packages/contracts/src/current/utils/SafeMath/SafeMath.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol (renamed from packages/contracts/src/previous/ERC20Token/ERC20Token_v1.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol (renamed from packages/contracts/src/previous/Ownable/Ownable_v1.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol (renamed from packages/contracts/src/previous/SafeMath/SafeMath_v1.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/Token/Token_v1.sol (renamed from packages/contracts/src/previous/Token/Token_v1.sol) | 0 | ||||
-rw-r--r-- | packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol (renamed from packages/contracts/src/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol) | 0 |
56 files changed, 2328 insertions, 3 deletions
diff --git a/packages/abi-gen/CHANGELOG.md b/packages/abi-gen/CHANGELOG.md index ffa8a7a35..570c76bdd 100644 --- a/packages/abi-gen/CHANGELOG.md +++ b/packages/abi-gen/CHANGELOG.md @@ -3,6 +3,7 @@ ## v0.2.0 - _???_ * Added CLI options for explicit specifying location of partials and main template (#346) +* Added CLI option to specify networkId, adding support for the JSON artifact format found in @0xproject/contracts ## v0.1.0 - _January 11, 2018_ diff --git a/packages/abi-gen/src/index.ts b/packages/abi-gen/src/index.ts index fe2b56524..85cc67daf 100644 --- a/packages/abi-gen/src/index.ts +++ b/packages/abi-gen/src/index.ts @@ -17,6 +17,7 @@ import { utils } from './utils'; const ABI_TYPE_CONSTRUCTOR = 'constructor'; const ABI_TYPE_METHOD = 'function'; const ABI_TYPE_EVENT = 'event'; +const DEFAULT_NETWORK_ID = 50; const args = yargs .option('abis', { @@ -42,6 +43,12 @@ const args = yargs demandOption: true, normalize: true, }) + .option('network-id', { + describe: 'ID of the network where contract ABIs are nested in artifacts', + type: 'number', + default: DEFAULT_NETWORK_ID, + + }) .example( "$0 --abis 'src/artifacts/**/*.json' --out 'src/contracts/generated/' --partials 'src/templates/partials/**/*.handlebars' --template 'src/templates/contract.handlebars'", 'Full usage example', @@ -87,9 +94,14 @@ for (const abiFileName of abiFileNames) { const namedContent = utils.getNamedContent(abiFileName); utils.log(`Processing: ${chalk.bold(namedContent.name)}...`); const parsedContent = JSON.parse(namedContent.content); - const ABI = _.isArray(parsedContent) - ? parsedContent // ABI file - : parsedContent.abi; // Truffle contracts file + let ABI; + if (_.isArray(parsedContent)) { + ABI = parsedContent; // ABI file + } else if (!_.isUndefined(parsedContent.abi)) { + ABI = parsedContent.abi; // Truffle artifact + } else if (!_.isUndefined(parsedContent.networks) && !_.isUndefined(parsedContent.networks[args.networkId])) { + ABI = parsedContent.networks[args.networkId]; // 0x contracts package artifact + } if (_.isUndefined(ABI)) { utils.log(`${chalk.red(`ABI not found in ${abiFileName}.`)}`); utils.log(`Please make sure your ABI file is either an array with ABI entries or an object with the abi key`); diff --git a/packages/contracts/contract_templates/contract.handlebars b/packages/contracts/contract_templates/contract.handlebars new file mode 100644 index 000000000..d3fe1b8cc --- /dev/null +++ b/packages/contracts/contract_templates/contract.handlebars @@ -0,0 +1,25 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class {{contractName}}Contract extends BaseContract { +{{#each methods}} + {{#this.constant}} + {{> call contractName=../contractName}} + {{/this.constant}} + {{^this.constant}} + {{> tx contractName=../contractName}} + {{/this.constant}} +{{/each}} + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/contract_templates/partials/call.handlebars b/packages/contracts/contract_templates/partials/call.handlebars new file mode 100644 index 000000000..0475136f0 --- /dev/null +++ b/packages/contracts/contract_templates/partials/call.handlebars @@ -0,0 +1,15 @@ +public {{this.name}} = { + async callAsync( + {{> typed_params inputs=inputs}} + defaultBlock?: Web3.BlockParam, + ): Promise<{{> return_type outputs=outputs}}> { + const self = this as {{contractName}}Contract; + const result = await promisify<{{> return_type outputs=outputs}}>( + self._web3ContractInstance.{{this.name}}.call, + self._web3ContractInstance, + )( + {{> params inputs=inputs}} + ); + return result; + }, +}; diff --git a/packages/contracts/contract_templates/partials/params.handlebars b/packages/contracts/contract_templates/partials/params.handlebars new file mode 100644 index 000000000..ac5d4ae85 --- /dev/null +++ b/packages/contracts/contract_templates/partials/params.handlebars @@ -0,0 +1,3 @@ +{{#each inputs}} +{{name}}, +{{/each}} diff --git a/packages/contracts/contract_templates/partials/return_type.handlebars b/packages/contracts/contract_templates/partials/return_type.handlebars new file mode 100644 index 000000000..383961a40 --- /dev/null +++ b/packages/contracts/contract_templates/partials/return_type.handlebars @@ -0,0 +1,6 @@ +{{#singleReturnValue}} +{{#returnType outputs.0.type}}{{/returnType}} +{{/singleReturnValue}} +{{^singleReturnValue}} +[{{#each outputs}}{{#returnType type}}{{/returnType}}{{#unless @last}}, {{/unless}}{{/each}}] +{{/singleReturnValue}} diff --git a/packages/contracts/contract_templates/partials/tx.handlebars b/packages/contracts/contract_templates/partials/tx.handlebars new file mode 100644 index 000000000..9df83266a --- /dev/null +++ b/packages/contracts/contract_templates/partials/tx.handlebars @@ -0,0 +1,51 @@ +public {{this.name}} = { + async sendTransactionAsync( + {{> typed_params inputs=inputs}} + {{#this.payable}} + txData: TxDataPayable = {}, + {{/this.payable}} + {{^this.payable}} + txData: TxData = {}, + {{/this.payable}} + ): Promise<string> { + const self = this as {{contractName}}Contract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.{{this.name}}.estimateGasAsync.bind( + self, + {{> params inputs=inputs}} + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.{{this.name}}, self._web3ContractInstance, + )( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + {{> typed_params inputs=inputs}} + txData: TxData = {}, + ): Promise<number> { + const self = this as {{contractName}}Contract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.{{this.name}}.estimateGas, self._web3ContractInstance, + )( + {{> params inputs=inputs}} + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + {{> typed_params inputs=inputs}} + txData: TxData = {}, + ): string { + const self = this as {{contractName}}Contract; + const abiEncodedTransactionData = self._web3ContractInstance.{{this.name}}.getData(); + return abiEncodedTransactionData; + }, +}; diff --git a/packages/contracts/contract_templates/partials/typed_params.handlebars b/packages/contracts/contract_templates/partials/typed_params.handlebars new file mode 100644 index 000000000..3ea4b2e95 --- /dev/null +++ b/packages/contracts/contract_templates/partials/typed_params.handlebars @@ -0,0 +1,3 @@ +{{#each inputs}} + {{name}}: {{#parameterType type}}{{/parameterType}}, +{{/each}} diff --git a/packages/contracts/package.json b/packages/contracts/package.json index b4074193d..712b220ec 100644 --- a/packages/contracts/package.json +++ b/packages/contracts/package.json @@ -17,6 +17,7 @@ "compile:comment": "Yarn workspaces do not link binaries correctly so we need to reference them directly https://github.com/yarnpkg/yarn/issues/3846", "compile": "node ../deployer/lib/src/cli.js compile", "clean": "rm -rf ./lib", + "generate_contract_wrappers": "node ../abi-gen/lib/index.js --abis 'src/artifacts/@(Exchange|Token|TokenTransferProxy|EtherToken|TokenRegistry|DummyToken).json' --template contract_templates/contract.handlebars --partials 'contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated", "migrate": "node ../deployer/lib/src/cli.js migrate", "lint": "tslint --project . 'migrations/**/*.ts' 'test/**/*.ts' 'util/**/*.ts' 'deploy/**/*.ts'", "test:circleci": "yarn test" diff --git a/packages/contracts/artifacts/DummyToken.json b/packages/contracts/src/artifacts/DummyToken.json index 8be276389..8be276389 100644 --- a/packages/contracts/artifacts/DummyToken.json +++ b/packages/contracts/src/artifacts/DummyToken.json diff --git a/packages/contracts/artifacts/ERC20Token.json b/packages/contracts/src/artifacts/ERC20Token.json index fc0dd5259..fc0dd5259 100644 --- a/packages/contracts/artifacts/ERC20Token.json +++ b/packages/contracts/src/artifacts/ERC20Token.json diff --git a/packages/contracts/artifacts/ERC20Token_v1.json b/packages/contracts/src/artifacts/ERC20Token_v1.json index 757962064..757962064 100644 --- a/packages/contracts/artifacts/ERC20Token_v1.json +++ b/packages/contracts/src/artifacts/ERC20Token_v1.json diff --git a/packages/contracts/artifacts/Exchange.json b/packages/contracts/src/artifacts/Exchange.json index ea3891d94..ea3891d94 100644 --- a/packages/contracts/artifacts/Exchange.json +++ b/packages/contracts/src/artifacts/Exchange.json diff --git a/packages/contracts/artifacts/MaliciousToken.json b/packages/contracts/src/artifacts/MaliciousToken.json index 000cb890d..000cb890d 100644 --- a/packages/contracts/artifacts/MaliciousToken.json +++ b/packages/contracts/src/artifacts/MaliciousToken.json diff --git a/packages/contracts/artifacts/Mintable.json b/packages/contracts/src/artifacts/Mintable.json index 9877fce84..9877fce84 100644 --- a/packages/contracts/artifacts/Mintable.json +++ b/packages/contracts/src/artifacts/Mintable.json diff --git a/packages/contracts/artifacts/MultiSigWallet.json b/packages/contracts/src/artifacts/MultiSigWallet.json index 47bca568e..47bca568e 100644 --- a/packages/contracts/artifacts/MultiSigWallet.json +++ b/packages/contracts/src/artifacts/MultiSigWallet.json diff --git a/packages/contracts/artifacts/MultiSigWalletWithTimeLock.json b/packages/contracts/src/artifacts/MultiSigWalletWithTimeLock.json index 2c97612ac..2c97612ac 100644 --- a/packages/contracts/artifacts/MultiSigWalletWithTimeLock.json +++ b/packages/contracts/src/artifacts/MultiSigWalletWithTimeLock.json diff --git a/packages/contracts/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json b/packages/contracts/src/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json index d65371cf2..d65371cf2 100644 --- a/packages/contracts/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json +++ b/packages/contracts/src/artifacts/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.json diff --git a/packages/contracts/artifacts/Ownable.json b/packages/contracts/src/artifacts/Ownable.json index 5a2a84a6d..5a2a84a6d 100644 --- a/packages/contracts/artifacts/Ownable.json +++ b/packages/contracts/src/artifacts/Ownable.json diff --git a/packages/contracts/artifacts/Ownable_v1.json b/packages/contracts/src/artifacts/Ownable_v1.json index 250952533..250952533 100644 --- a/packages/contracts/artifacts/Ownable_v1.json +++ b/packages/contracts/src/artifacts/Ownable_v1.json diff --git a/packages/contracts/artifacts/SafeMath.json b/packages/contracts/src/artifacts/SafeMath.json index cbe88bef6..cbe88bef6 100644 --- a/packages/contracts/artifacts/SafeMath.json +++ b/packages/contracts/src/artifacts/SafeMath.json diff --git a/packages/contracts/artifacts/SafeMath_v1.json b/packages/contracts/src/artifacts/SafeMath_v1.json index bad4834c0..bad4834c0 100644 --- a/packages/contracts/artifacts/SafeMath_v1.json +++ b/packages/contracts/src/artifacts/SafeMath_v1.json diff --git a/packages/contracts/artifacts/Token.json b/packages/contracts/src/artifacts/Token.json index 601facc28..601facc28 100644 --- a/packages/contracts/artifacts/Token.json +++ b/packages/contracts/src/artifacts/Token.json diff --git a/packages/contracts/artifacts/TokenRegistry.json b/packages/contracts/src/artifacts/TokenRegistry.json index b4264430b..b4264430b 100644 --- a/packages/contracts/artifacts/TokenRegistry.json +++ b/packages/contracts/src/artifacts/TokenRegistry.json diff --git a/packages/contracts/artifacts/TokenTransferProxy.json b/packages/contracts/src/artifacts/TokenTransferProxy.json index 1815458f8..1815458f8 100644 --- a/packages/contracts/artifacts/TokenTransferProxy.json +++ b/packages/contracts/src/artifacts/TokenTransferProxy.json diff --git a/packages/contracts/artifacts/Token_v1.json b/packages/contracts/src/artifacts/Token_v1.json index a2f3f6a24..a2f3f6a24 100644 --- a/packages/contracts/artifacts/Token_v1.json +++ b/packages/contracts/src/artifacts/Token_v1.json diff --git a/packages/contracts/artifacts/UnlimitedAllowanceToken.json b/packages/contracts/src/artifacts/UnlimitedAllowanceToken.json index f6415840b..f6415840b 100644 --- a/packages/contracts/artifacts/UnlimitedAllowanceToken.json +++ b/packages/contracts/src/artifacts/UnlimitedAllowanceToken.json diff --git a/packages/contracts/artifacts/UnlimitedAllowanceToken_v1.json b/packages/contracts/src/artifacts/UnlimitedAllowanceToken_v1.json index 731a4e4ee..731a4e4ee 100644 --- a/packages/contracts/artifacts/UnlimitedAllowanceToken_v1.json +++ b/packages/contracts/src/artifacts/UnlimitedAllowanceToken_v1.json diff --git a/packages/contracts/artifacts/WETH9.json b/packages/contracts/src/artifacts/WETH9.json index ffe11ce40..ffe11ce40 100644 --- a/packages/contracts/artifacts/WETH9.json +++ b/packages/contracts/src/artifacts/WETH9.json diff --git a/packages/contracts/artifacts/ZRXToken.json b/packages/contracts/src/artifacts/ZRXToken.json index 285cc1dfd..285cc1dfd 100644 --- a/packages/contracts/artifacts/ZRXToken.json +++ b/packages/contracts/src/artifacts/ZRXToken.json diff --git a/packages/contracts/src/contract_wrappers/generated/dummy_token.ts b/packages/contracts/src/contract_wrappers/generated/dummy_token.ts new file mode 100644 index 000000000..788cbfe3f --- /dev/null +++ b/packages/contracts/src/contract_wrappers/generated/dummy_token.ts @@ -0,0 +1,434 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class DummyTokenContract extends BaseContract { + public name = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as DummyTokenContract; + const result = await promisify<string + >( + self._web3ContractInstance.name.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public approve = { + async sendTransactionAsync( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.approve.estimateGasAsync.bind( + self, + _spender, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.approve, self._web3ContractInstance, + )( + _spender, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.approve.estimateGas, self._web3ContractInstance, + )( + _spender, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.approve.getData(); + return abiEncodedTransactionData; + }, + }; + public totalSupply = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as DummyTokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.totalSupply.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferFrom, self._web3ContractInstance, + )( + _from, + _to, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferFrom.estimateGas, self._web3ContractInstance, + )( + _from, + _to, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferFrom.getData(); + return abiEncodedTransactionData; + }, + }; + public decimals = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as DummyTokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.decimals.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as DummyTokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.balanceOf.call, + self._web3ContractInstance, + )( + _owner, + ); + return result; + }, + }; + public owner = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as DummyTokenContract; + const result = await promisify<string + >( + self._web3ContractInstance.owner.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public symbol = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as DummyTokenContract; + const result = await promisify<string + >( + self._web3ContractInstance.symbol.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public mint = { + async sendTransactionAsync( + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.mint.estimateGasAsync.bind( + self, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.mint, self._web3ContractInstance, + )( + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.mint.estimateGas, self._web3ContractInstance, + )( + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.mint.getData(); + return abiEncodedTransactionData; + }, + }; + public transfer = { + async sendTransactionAsync( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transfer.estimateGasAsync.bind( + self, + _to, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transfer, self._web3ContractInstance, + )( + _to, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transfer.estimateGas, self._web3ContractInstance, + )( + _to, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.transfer.getData(); + return abiEncodedTransactionData; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as DummyTokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.allowance.call, + self._web3ContractInstance, + )( + _owner, + _spender, + ); + return result; + }, + }; + public setBalance = { + async sendTransactionAsync( + _target: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.setBalance.estimateGasAsync.bind( + self, + _target, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.setBalance, self._web3ContractInstance, + )( + _target, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _target: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.setBalance.estimateGas, self._web3ContractInstance, + )( + _target, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _target: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.setBalance.getData(); + return abiEncodedTransactionData; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferOwnership.estimateGasAsync.bind( + self, + newOwner, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferOwnership, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as DummyTokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferOwnership.estimateGas, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + newOwner: string, + txData: TxData = {}, + ): string { + const self = this as DummyTokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferOwnership.getData(); + return abiEncodedTransactionData; + }, + }; + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/src/contract_wrappers/generated/exchange.ts b/packages/contracts/src/contract_wrappers/generated/exchange.ts new file mode 100644 index 000000000..c328ec725 --- /dev/null +++ b/packages/contracts/src/contract_wrappers/generated/exchange.ts @@ -0,0 +1,728 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class ExchangeContract extends BaseContract { + public isRoundingError = { + async callAsync( + numerator: BigNumber, + denominator: BigNumber, + target: BigNumber, + defaultBlock?: Web3.BlockParam, + ): Promise<boolean + > { + const self = this as ExchangeContract; + const result = await promisify<boolean + >( + self._web3ContractInstance.isRoundingError.call, + self._web3ContractInstance, + )( + numerator, + denominator, + target, + ); + return result; + }, + }; + public filled = { + async callAsync( + index: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as ExchangeContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.filled.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public cancelled = { + async callAsync( + index: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as ExchangeContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.cancelled.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public fillOrdersUpTo = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.fillOrdersUpTo.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.fillOrdersUpTo, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.fillOrdersUpTo.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.fillOrdersUpTo.getData(); + return abiEncodedTransactionData; + }, + }; + public cancelOrder = { + async sendTransactionAsync( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.cancelOrder.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + cancelTakerTokenAmount, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.cancelOrder, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + cancelTakerTokenAmount, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.cancelOrder.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + cancelTakerTokenAmount, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + cancelTakerTokenAmount: BigNumber, + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.cancelOrder.getData(); + return abiEncodedTransactionData; + }, + }; + public ZRX_TOKEN_CONTRACT = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as ExchangeContract; + const result = await promisify<string + >( + self._web3ContractInstance.ZRX_TOKEN_CONTRACT.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public batchFillOrKillOrders = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.batchFillOrKillOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmounts, + v, + r, + s, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.batchFillOrKillOrders, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + v, + r, + s, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.batchFillOrKillOrders.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + v, + r, + s, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.batchFillOrKillOrders.getData(); + return abiEncodedTransactionData; + }, + }; + public fillOrKillOrder = { + async sendTransactionAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.fillOrKillOrder.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + v, + r, + s, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.fillOrKillOrder, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + v, + r, + s, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.fillOrKillOrder.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + v, + r, + s, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.fillOrKillOrder.getData(); + return abiEncodedTransactionData; + }, + }; + public getUnavailableTakerTokenAmount = { + async callAsync( + orderHash: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as ExchangeContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.getUnavailableTakerTokenAmount.call, + self._web3ContractInstance, + )( + orderHash, + ); + return result; + }, + }; + public isValidSignature = { + async callAsync( + signer: string, + hash: string, + v: number|BigNumber, + r: string, + s: string, + defaultBlock?: Web3.BlockParam, + ): Promise<boolean + > { + const self = this as ExchangeContract; + const result = await promisify<boolean + >( + self._web3ContractInstance.isValidSignature.call, + self._web3ContractInstance, + )( + signer, + hash, + v, + r, + s, + ); + return result; + }, + }; + public getPartialAmount = { + async callAsync( + numerator: BigNumber, + denominator: BigNumber, + target: BigNumber, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as ExchangeContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.getPartialAmount.call, + self._web3ContractInstance, + )( + numerator, + denominator, + target, + ); + return result; + }, + }; + public TOKEN_TRANSFER_PROXY_CONTRACT = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as ExchangeContract; + const result = await promisify<string + >( + self._web3ContractInstance.TOKEN_TRANSFER_PROXY_CONTRACT.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public batchFillOrders = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.batchFillOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.batchFillOrders, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.batchFillOrders.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmounts, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + fillTakerTokenAmounts: BigNumber[], + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: Array<number|BigNumber>, + r: string[], + s: string[], + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.batchFillOrders.getData(); + return abiEncodedTransactionData; + }, + }; + public batchCancelOrders = { + async sendTransactionAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.batchCancelOrders.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + cancelTakerTokenAmounts, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.batchCancelOrders, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + cancelTakerTokenAmounts, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.batchCancelOrders.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + cancelTakerTokenAmounts, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[][], + orderValues: BigNumber[][], + cancelTakerTokenAmounts: BigNumber[], + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.batchCancelOrders.getData(); + return abiEncodedTransactionData; + }, + }; + public fillOrder = { + async sendTransactionAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.fillOrder.estimateGasAsync.bind( + self, + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.fillOrder, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as ExchangeContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.fillOrder.estimateGas, self._web3ContractInstance, + )( + orderAddresses, + orderValues, + fillTakerTokenAmount, + shouldThrowOnInsufficientBalanceOrAllowance, + v, + r, + s, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + orderAddresses: string[], + orderValues: BigNumber[], + fillTakerTokenAmount: BigNumber, + shouldThrowOnInsufficientBalanceOrAllowance: boolean, + v: number|BigNumber, + r: string, + s: string, + txData: TxData = {}, + ): string { + const self = this as ExchangeContract; + const abiEncodedTransactionData = self._web3ContractInstance.fillOrder.getData(); + return abiEncodedTransactionData; + }, + }; + public getOrderHash = { + async callAsync( + orderAddresses: string[], + orderValues: BigNumber[], + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as ExchangeContract; + const result = await promisify<string + >( + self._web3ContractInstance.getOrderHash.call, + self._web3ContractInstance, + )( + orderAddresses, + orderValues, + ); + return result; + }, + }; + public EXTERNAL_QUERY_GAS_LIMIT = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as ExchangeContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.EXTERNAL_QUERY_GAS_LIMIT.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public VERSION = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as ExchangeContract; + const result = await promisify<string + >( + self._web3ContractInstance.VERSION.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/src/contract_wrappers/generated/token.ts b/packages/contracts/src/contract_wrappers/generated/token.ts new file mode 100644 index 000000000..5ad96da1e --- /dev/null +++ b/packages/contracts/src/contract_wrappers/generated/token.ts @@ -0,0 +1,215 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class TokenContract extends BaseContract { + public approve = { + async sendTransactionAsync( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.approve.estimateGasAsync.bind( + self, + _spender, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.approve, self._web3ContractInstance, + )( + _spender, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.approve.estimateGas, self._web3ContractInstance, + )( + _spender, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _spender: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as TokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.approve.getData(); + return abiEncodedTransactionData; + }, + }; + public transferFrom = { + async sendTransactionAsync( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferFrom.estimateGasAsync.bind( + self, + _from, + _to, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferFrom, self._web3ContractInstance, + )( + _from, + _to, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferFrom.estimateGas, self._web3ContractInstance, + )( + _from, + _to, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _from: string, + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as TokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferFrom.getData(); + return abiEncodedTransactionData; + }, + }; + public balanceOf = { + async callAsync( + _owner: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as TokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.balanceOf.call, + self._web3ContractInstance, + )( + _owner, + ); + return result; + }, + }; + public transfer = { + async sendTransactionAsync( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transfer.estimateGasAsync.bind( + self, + _to, + _value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transfer, self._web3ContractInstance, + )( + _to, + _value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transfer.estimateGas, self._web3ContractInstance, + )( + _to, + _value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _to: string, + _value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as TokenContract; + const abiEncodedTransactionData = self._web3ContractInstance.transfer.getData(); + return abiEncodedTransactionData; + }, + }; + public allowance = { + async callAsync( + _owner: string, + _spender: string, + defaultBlock?: Web3.BlockParam, + ): Promise<BigNumber + > { + const self = this as TokenContract; + const result = await promisify<BigNumber + >( + self._web3ContractInstance.allowance.call, + self._web3ContractInstance, + )( + _owner, + _spender, + ); + return result; + }, + }; + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/src/contract_wrappers/generated/token_registry.ts b/packages/contracts/src/contract_wrappers/generated/token_registry.ts new file mode 100644 index 000000000..635f9f214 --- /dev/null +++ b/packages/contracts/src/contract_wrappers/generated/token_registry.ts @@ -0,0 +1,548 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class TokenRegistryContract extends BaseContract { + public removeToken = { + async sendTransactionAsync( + _token: string, + _index: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.removeToken.estimateGasAsync.bind( + self, + _token, + _index, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.removeToken, self._web3ContractInstance, + )( + _token, + _index, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _index: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.removeToken.estimateGas, self._web3ContractInstance, + )( + _token, + _index, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _index: BigNumber, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.removeToken.getData(); + return abiEncodedTransactionData; + }, + }; + public getTokenAddressByName = { + async callAsync( + _name: string, + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenRegistryContract; + const result = await promisify<string + >( + self._web3ContractInstance.getTokenAddressByName.call, + self._web3ContractInstance, + )( + _name, + ); + return result; + }, + }; + public getTokenAddressBySymbol = { + async callAsync( + _symbol: string, + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenRegistryContract; + const result = await promisify<string + >( + self._web3ContractInstance.getTokenAddressBySymbol.call, + self._web3ContractInstance, + )( + _symbol, + ); + return result; + }, + }; + public setTokenSwarmHash = { + async sendTransactionAsync( + _token: string, + _swarmHash: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.setTokenSwarmHash.estimateGasAsync.bind( + self, + _token, + _swarmHash, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.setTokenSwarmHash, self._web3ContractInstance, + )( + _token, + _swarmHash, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _swarmHash: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.setTokenSwarmHash.estimateGas, self._web3ContractInstance, + )( + _token, + _swarmHash, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _swarmHash: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.setTokenSwarmHash.getData(); + return abiEncodedTransactionData; + }, + }; + public getTokenMetaData = { + async callAsync( + _token: string, + defaultBlock?: Web3.BlockParam, + ): Promise<[string, string, string, BigNumber, string, string] + > { + const self = this as TokenRegistryContract; + const result = await promisify<[string, string, string, BigNumber, string, string] + >( + self._web3ContractInstance.getTokenMetaData.call, + self._web3ContractInstance, + )( + _token, + ); + return result; + }, + }; + public owner = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenRegistryContract; + const result = await promisify<string + >( + self._web3ContractInstance.owner.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public addToken = { + async sendTransactionAsync( + _token: string, + _name: string, + _symbol: string, + _decimals: number|BigNumber, + _ipfsHash: string, + _swarmHash: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.addToken.estimateGasAsync.bind( + self, + _token, + _name, + _symbol, + _decimals, + _ipfsHash, + _swarmHash, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.addToken, self._web3ContractInstance, + )( + _token, + _name, + _symbol, + _decimals, + _ipfsHash, + _swarmHash, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _name: string, + _symbol: string, + _decimals: number|BigNumber, + _ipfsHash: string, + _swarmHash: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.addToken.estimateGas, self._web3ContractInstance, + )( + _token, + _name, + _symbol, + _decimals, + _ipfsHash, + _swarmHash, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _name: string, + _symbol: string, + _decimals: number|BigNumber, + _ipfsHash: string, + _swarmHash: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.addToken.getData(); + return abiEncodedTransactionData; + }, + }; + public setTokenName = { + async sendTransactionAsync( + _token: string, + _name: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.setTokenName.estimateGasAsync.bind( + self, + _token, + _name, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.setTokenName, self._web3ContractInstance, + )( + _token, + _name, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _name: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.setTokenName.estimateGas, self._web3ContractInstance, + )( + _token, + _name, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _name: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.setTokenName.getData(); + return abiEncodedTransactionData; + }, + }; + public tokens = { + async callAsync( + index: string, + defaultBlock?: Web3.BlockParam, + ): Promise<[string, string, string, BigNumber, string, string] + > { + const self = this as TokenRegistryContract; + const result = await promisify<[string, string, string, BigNumber, string, string] + >( + self._web3ContractInstance.tokens.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public tokenAddresses = { + async callAsync( + index: BigNumber, + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenRegistryContract; + const result = await promisify<string + >( + self._web3ContractInstance.tokenAddresses.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public getTokenByName = { + async callAsync( + _name: string, + defaultBlock?: Web3.BlockParam, + ): Promise<[string, string, string, BigNumber, string, string] + > { + const self = this as TokenRegistryContract; + const result = await promisify<[string, string, string, BigNumber, string, string] + >( + self._web3ContractInstance.getTokenByName.call, + self._web3ContractInstance, + )( + _name, + ); + return result; + }, + }; + public getTokenAddresses = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string[] + > { + const self = this as TokenRegistryContract; + const result = await promisify<string[] + >( + self._web3ContractInstance.getTokenAddresses.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public setTokenIpfsHash = { + async sendTransactionAsync( + _token: string, + _ipfsHash: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.setTokenIpfsHash.estimateGasAsync.bind( + self, + _token, + _ipfsHash, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.setTokenIpfsHash, self._web3ContractInstance, + )( + _token, + _ipfsHash, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _ipfsHash: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.setTokenIpfsHash.estimateGas, self._web3ContractInstance, + )( + _token, + _ipfsHash, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _ipfsHash: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.setTokenIpfsHash.getData(); + return abiEncodedTransactionData; + }, + }; + public getTokenBySymbol = { + async callAsync( + _symbol: string, + defaultBlock?: Web3.BlockParam, + ): Promise<[string, string, string, BigNumber, string, string] + > { + const self = this as TokenRegistryContract; + const result = await promisify<[string, string, string, BigNumber, string, string] + >( + self._web3ContractInstance.getTokenBySymbol.call, + self._web3ContractInstance, + )( + _symbol, + ); + return result; + }, + }; + public setTokenSymbol = { + async sendTransactionAsync( + _token: string, + _symbol: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.setTokenSymbol.estimateGasAsync.bind( + self, + _token, + _symbol, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.setTokenSymbol, self._web3ContractInstance, + )( + _token, + _symbol, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + _token: string, + _symbol: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.setTokenSymbol.estimateGas, self._web3ContractInstance, + )( + _token, + _symbol, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + _token: string, + _symbol: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.setTokenSymbol.getData(); + return abiEncodedTransactionData; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferOwnership.estimateGasAsync.bind( + self, + newOwner, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferOwnership, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenRegistryContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferOwnership.estimateGas, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + newOwner: string, + txData: TxData = {}, + ): string { + const self = this as TokenRegistryContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferOwnership.getData(); + return abiEncodedTransactionData; + }, + }; + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/src/contract_wrappers/generated/token_transfer_proxy.ts b/packages/contracts/src/contract_wrappers/generated/token_transfer_proxy.ts new file mode 100644 index 000000000..a5a40d47f --- /dev/null +++ b/packages/contracts/src/contract_wrappers/generated/token_transfer_proxy.ts @@ -0,0 +1,283 @@ +/** + * This file is auto-generated using abi-gen. Don't edit directly. + * Templates can be found at https://github.com/0xProject/0x.js/tree/development/packages/abi-gen-templates. + */ +// tslint:disable-next-line:no-unused-variable +import { TxData, TxDataPayable } from '@0xproject/types'; +import { BigNumber, classUtils, promisify } from '@0xproject/utils'; +import * as Web3 from 'web3'; + +import {BaseContract} from './base_contract'; + +export class TokenTransferProxyContract extends BaseContract { + public transferFrom = { + async sendTransactionAsync( + token: string, + from: string, + to: string, + value: BigNumber, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferFrom.estimateGasAsync.bind( + self, + token, + from, + to, + value, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferFrom, self._web3ContractInstance, + )( + token, + from, + to, + value, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + token: string, + from: string, + to: string, + value: BigNumber, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferFrom.estimateGas, self._web3ContractInstance, + )( + token, + from, + to, + value, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + token: string, + from: string, + to: string, + value: BigNumber, + txData: TxData = {}, + ): string { + const self = this as TokenTransferProxyContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferFrom.getData(); + return abiEncodedTransactionData; + }, + }; + public addAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.addAuthorizedAddress.estimateGasAsync.bind( + self, + target, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.addAuthorizedAddress, self._web3ContractInstance, + )( + target, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + target: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.addAuthorizedAddress.estimateGas, self._web3ContractInstance, + )( + target, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + target: string, + txData: TxData = {}, + ): string { + const self = this as TokenTransferProxyContract; + const abiEncodedTransactionData = self._web3ContractInstance.addAuthorizedAddress.getData(); + return abiEncodedTransactionData; + }, + }; + public authorities = { + async callAsync( + index: BigNumber, + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenTransferProxyContract; + const result = await promisify<string + >( + self._web3ContractInstance.authorities.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public removeAuthorizedAddress = { + async sendTransactionAsync( + target: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.removeAuthorizedAddress.estimateGasAsync.bind( + self, + target, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.removeAuthorizedAddress, self._web3ContractInstance, + )( + target, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + target: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.removeAuthorizedAddress.estimateGas, self._web3ContractInstance, + )( + target, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + target: string, + txData: TxData = {}, + ): string { + const self = this as TokenTransferProxyContract; + const abiEncodedTransactionData = self._web3ContractInstance.removeAuthorizedAddress.getData(); + return abiEncodedTransactionData; + }, + }; + public owner = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string + > { + const self = this as TokenTransferProxyContract; + const result = await promisify<string + >( + self._web3ContractInstance.owner.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public authorized = { + async callAsync( + index: string, + defaultBlock?: Web3.BlockParam, + ): Promise<boolean + > { + const self = this as TokenTransferProxyContract; + const result = await promisify<boolean + >( + self._web3ContractInstance.authorized.call, + self._web3ContractInstance, + )( + index, + ); + return result; + }, + }; + public getAuthorizedAddresses = { + async callAsync( + defaultBlock?: Web3.BlockParam, + ): Promise<string[] + > { + const self = this as TokenTransferProxyContract; + const result = await promisify<string[] + >( + self._web3ContractInstance.getAuthorizedAddresses.call, + self._web3ContractInstance, + )( + ); + return result; + }, + }; + public transferOwnership = { + async sendTransactionAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<string> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + self.transferOwnership.estimateGasAsync.bind( + self, + newOwner, + ), + ); + const txHash = await promisify<string>( + self._web3ContractInstance.transferOwnership, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return txHash; + }, + async estimateGasAsync( + newOwner: string, + txData: TxData = {}, + ): Promise<number> { + const self = this as TokenTransferProxyContract; + const txDataWithDefaults = await self._applyDefaultsToTxDataAsync( + txData, + ); + const gas = await promisify<number>( + self._web3ContractInstance.transferOwnership.estimateGas, self._web3ContractInstance, + )( + newOwner, + txDataWithDefaults, + ); + return gas; + }, + getABIEncodedTransactionData( + newOwner: string, + txData: TxData = {}, + ): string { + const self = this as TokenTransferProxyContract; + const abiEncodedTransactionData = self._web3ContractInstance.transferOwnership.getData(); + return abiEncodedTransactionData; + }, + }; + constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<TxData>) { + super(web3ContractInstance, defaults); + classUtils.bindAll(this, ['_web3ContractInstance', '_defaults']); + } +} // tslint:disable:max-file-line-count diff --git a/packages/contracts/src/current/multisig/MultiSigWallet/MultiSigWallet.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol index 997bb86c0..997bb86c0 100644 --- a/packages/contracts/src/current/multisig/MultiSigWallet/MultiSigWallet.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWallet/MultiSigWallet.sol diff --git a/packages/contracts/src/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol index a545d9813..a545d9813 100644 --- a/packages/contracts/src/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLock/MultiSigWalletWithTimeLock.sol diff --git a/packages/contracts/src/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol index 3c6a3d2ef..3c6a3d2ef 100644 --- a/packages/contracts/src/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol +++ b/packages/contracts/src/contracts/current/multisig/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress/MultiSigWalletWithTimeLockExceptRemoveAuthorizedAddress.sol diff --git a/packages/contracts/src/current/protocol/Exchange/Exchange.sol b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol index 8dacf797c..8dacf797c 100644 --- a/packages/contracts/src/current/protocol/Exchange/Exchange.sol +++ b/packages/contracts/src/contracts/current/protocol/Exchange/Exchange.sol diff --git a/packages/contracts/src/current/protocol/TokenRegistry/TokenRegistry.sol b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol index 3bd2fbfaf..3bd2fbfaf 100644 --- a/packages/contracts/src/current/protocol/TokenRegistry/TokenRegistry.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenRegistry/TokenRegistry.sol diff --git a/packages/contracts/src/current/protocol/TokenTransferProxy/TokenTransferProxy.sol b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol index 1ce949fa6..1ce949fa6 100644 --- a/packages/contracts/src/current/protocol/TokenTransferProxy/TokenTransferProxy.sol +++ b/packages/contracts/src/contracts/current/protocol/TokenTransferProxy/TokenTransferProxy.sol diff --git a/packages/contracts/src/current/test/DummyToken/DummyToken.sol b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol index ab04f4d16..ab04f4d16 100644 --- a/packages/contracts/src/current/test/DummyToken/DummyToken.sol +++ b/packages/contracts/src/contracts/current/test/DummyToken/DummyToken.sol diff --git a/packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol index 9e502616c..9e502616c 100644 --- a/packages/contracts/src/current/test/MaliciousToken/MaliciousToken.sol +++ b/packages/contracts/src/contracts/current/test/MaliciousToken/MaliciousToken.sol diff --git a/packages/contracts/src/current/test/Mintable/Mintable.sol b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol index cf7ee35a5..cf7ee35a5 100644 --- a/packages/contracts/src/current/test/Mintable/Mintable.sol +++ b/packages/contracts/src/contracts/current/test/Mintable/Mintable.sol diff --git a/packages/contracts/src/current/tokens/ERC20Token/ERC20Token.sol b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol index 0e5b87aa4..0e5b87aa4 100644 --- a/packages/contracts/src/current/tokens/ERC20Token/ERC20Token.sol +++ b/packages/contracts/src/contracts/current/tokens/ERC20Token/ERC20Token.sol diff --git a/packages/contracts/src/current/tokens/Token/Token.sol b/packages/contracts/src/contracts/current/tokens/Token/Token.sol index bf4e71dcd..bf4e71dcd 100644 --- a/packages/contracts/src/current/tokens/Token/Token.sol +++ b/packages/contracts/src/contracts/current/tokens/Token/Token.sol diff --git a/packages/contracts/src/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol index 699f535d2..699f535d2 100644 --- a/packages/contracts/src/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol +++ b/packages/contracts/src/contracts/current/tokens/UnlimitedAllowanceToken/UnlimitedAllowanceToken.sol diff --git a/packages/contracts/src/current/tokens/WETH9/WETH9.sol b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol index 733ca414b..733ca414b 100644 --- a/packages/contracts/src/current/tokens/WETH9/WETH9.sol +++ b/packages/contracts/src/contracts/current/tokens/WETH9/WETH9.sol diff --git a/packages/contracts/src/current/tokens/ZRXToken/ZRXToken.sol b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol index 7f5e1f849..7f5e1f849 100644 --- a/packages/contracts/src/current/tokens/ZRXToken/ZRXToken.sol +++ b/packages/contracts/src/contracts/current/tokens/ZRXToken/ZRXToken.sol diff --git a/packages/contracts/src/current/utils/Ownable/Ownable.sol b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol index 9b3d6b9cf..9b3d6b9cf 100644 --- a/packages/contracts/src/current/utils/Ownable/Ownable.sol +++ b/packages/contracts/src/contracts/current/utils/Ownable/Ownable.sol diff --git a/packages/contracts/src/current/utils/SafeMath/SafeMath.sol b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol index 955a9e379..955a9e379 100644 --- a/packages/contracts/src/current/utils/SafeMath/SafeMath.sol +++ b/packages/contracts/src/contracts/current/utils/SafeMath/SafeMath.sol diff --git a/packages/contracts/src/previous/ERC20Token/ERC20Token_v1.sol b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol index e05ee2d5e..e05ee2d5e 100644 --- a/packages/contracts/src/previous/ERC20Token/ERC20Token_v1.sol +++ b/packages/contracts/src/contracts/previous/ERC20Token/ERC20Token_v1.sol diff --git a/packages/contracts/src/previous/Ownable/Ownable_v1.sol b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol index c87438fa4..c87438fa4 100644 --- a/packages/contracts/src/previous/Ownable/Ownable_v1.sol +++ b/packages/contracts/src/contracts/previous/Ownable/Ownable_v1.sol diff --git a/packages/contracts/src/previous/SafeMath/SafeMath_v1.sol b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol index 341d611ec..341d611ec 100644 --- a/packages/contracts/src/previous/SafeMath/SafeMath_v1.sol +++ b/packages/contracts/src/contracts/previous/SafeMath/SafeMath_v1.sol diff --git a/packages/contracts/src/previous/Token/Token_v1.sol b/packages/contracts/src/contracts/previous/Token/Token_v1.sol index de619fb7e..de619fb7e 100644 --- a/packages/contracts/src/previous/Token/Token_v1.sol +++ b/packages/contracts/src/contracts/previous/Token/Token_v1.sol diff --git a/packages/contracts/src/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol index 6376f3f2c..6376f3f2c 100644 --- a/packages/contracts/src/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol +++ b/packages/contracts/src/contracts/previous/UnlimitedAllowanceToken/UnlimitedAllowanceToken_v1.sol |