[Multilang] hardcode ABI into abi-gen-wrappers (#1883)
* Export artifacts and addresses from abi-gen-wrappers * only export addresses, not artifacts * abi-gen-wrappers no longer accept ContractAbi as constructor param ABI is now hardcoded when wrapper is generated * remove unused imports * remove unused import * changes after review * fix method ordering * update constructor args * prettier * statically enumerate ABI properties * remove abi-gen-wrappers generated-wrappers from prettierignore * add template for recursive components * add `indexed` field for EventParameter * prettier * update known-good wrappers with ABIs and fix Python ABI loading * remove generated-artifacts and update gitignore
This commit is contained in:
parent
d9378e9a8f
commit
048f5c2771
4
.gitignore
vendored
4
.gitignore
vendored
@ -95,8 +95,8 @@ contracts/erc1155/generated-artifacts/
|
||||
contracts/extensions/generated-artifacts/
|
||||
contracts/exchange-forwarder/generated-artifacts/
|
||||
contracts/dev-utils/generated-artifacts/
|
||||
/packages/abi-gen/test/generated-test/generated-artifacts
|
||||
/packages/abi-gen/test/generated-test/output
|
||||
packages/abi-gen/test/generated-test/generated-artifacts
|
||||
packages/abi-gen/test/generated-test/output
|
||||
packages/sol-tracing-utils/test/fixtures/artifacts/
|
||||
packages/metacoin/artifacts/
|
||||
python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/
|
||||
|
@ -44,16 +44,8 @@ import {
|
||||
chaiSetup.configure();
|
||||
const expect = chai.expect;
|
||||
const blockchainLifecycle = new BlockchainLifecycle(web3Wrapper);
|
||||
const assetProxyInterface = new IAssetProxyContract(
|
||||
artifacts.IAssetProxy.compilerOutput.abi,
|
||||
constants.NULL_ADDRESS,
|
||||
provider,
|
||||
);
|
||||
const assetDataInterface = new IAssetDataContract(
|
||||
artifacts.IAssetData.compilerOutput.abi,
|
||||
constants.NULL_ADDRESS,
|
||||
provider,
|
||||
);
|
||||
const assetProxyInterface = new IAssetProxyContract(constants.NULL_ADDRESS, provider);
|
||||
const assetDataInterface = new IAssetDataContract(constants.NULL_ADDRESS, provider);
|
||||
|
||||
// tslint:disable:no-unnecessary-type-assertion
|
||||
describe('Asset Transfer Proxies', () => {
|
||||
|
@ -42,12 +42,7 @@ describe('StaticCallProxy', () => {
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
staticCallProxy = new IAssetProxyContract(
|
||||
artifacts.IAssetProxy.compilerOutput.abi,
|
||||
staticCallProxyWithoutTransferFrom.address,
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
staticCallProxy = new IAssetProxyContract(staticCallProxyWithoutTransferFrom.address, provider, txDefaults);
|
||||
staticCallTarget = await TestStaticCallTargetContract.deployFrom0xArtifactAsync(
|
||||
artifacts.TestStaticCallTarget,
|
||||
provider,
|
||||
|
@ -36,11 +36,7 @@ export class ERC1155ProxyWrapper {
|
||||
const allArtifacts = _.merge(artifacts, erc1155Artifacts);
|
||||
this._logDecoder = new LogDecoder(this._web3Wrapper, allArtifacts);
|
||||
this._dummyTokenWrappers = [];
|
||||
this._assetProxyInterface = new IAssetProxyContract(
|
||||
artifacts.IAssetProxy.compilerOutput.abi,
|
||||
constants.NULL_ADDRESS,
|
||||
provider,
|
||||
);
|
||||
this._assetProxyInterface = new IAssetProxyContract(constants.NULL_ADDRESS, provider);
|
||||
this._tokenOwnerAddresses = tokenOwnerAddresses;
|
||||
this._contractOwnerAddress = contractOwnerAddress;
|
||||
this._fungibleTokenIds = [];
|
||||
|
@ -71,7 +71,7 @@
|
||||
"@0x/base-contract": "^5.1.0",
|
||||
"@0x/contracts-asset-proxy": "^2.1.5",
|
||||
"@0x/contracts-erc20": "^2.2.5",
|
||||
"@0x/contracts-exchange": "1.0.2",
|
||||
"@0x/contracts-exchange": "^2.1.5",
|
||||
"@0x/contracts-exchange-libs": "^2.1.6",
|
||||
"@0x/contracts-utils": "^3.1.6",
|
||||
"@0x/order-utils": "^8.1.1",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { artifacts, IExchangeContract } from '@0x/contracts-exchange';
|
||||
import { IExchangeContract } from '@0x/contracts-exchange';
|
||||
import { constants as devConstants, provider } from '@0x/contracts-test-utils';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
|
||||
@ -6,11 +6,7 @@ import { constants } from './index';
|
||||
|
||||
export const exchangeDataEncoder = {
|
||||
encodeOrdersToExchangeData(fnName: string, orders: SignedOrder[]): string {
|
||||
const exchangeInstance = new IExchangeContract(
|
||||
artifacts.IExchange.compilerOutput.abi,
|
||||
devConstants.NULL_ADDRESS,
|
||||
provider,
|
||||
);
|
||||
const exchangeInstance = new IExchangeContract(devConstants.NULL_ADDRESS, provider);
|
||||
let data;
|
||||
if (constants.SINGLE_FILL_FN_NAMES.indexOf(fnName) !== -1) {
|
||||
data = (exchangeInstance as any)[fnName].getABIEncodedTransactionData(
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { artifacts as exchangeArtifacts, IExchangeContract } from '@0x/contracts-exchange';
|
||||
import { IExchangeContract } from '@0x/contracts-exchange';
|
||||
import { chaiSetup, constants, provider, txDefaults, web3Wrapper } from '@0x/contracts-test-utils';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
@ -30,12 +30,7 @@ const signature =
|
||||
|
||||
describe('LibTransactionDecoder', () => {
|
||||
let libTxDecoder: LibTransactionDecoderContract;
|
||||
const exchangeInterface = new IExchangeContract(
|
||||
exchangeArtifacts.Exchange.compilerOutput.abi,
|
||||
constants.NULL_ADDRESS,
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
const exchangeInterface = new IExchangeContract(constants.NULL_ADDRESS, provider, txDefaults);
|
||||
before(async () => {
|
||||
await blockchainLifecycle.startAsync();
|
||||
libTxDecoder = await LibTransactionDecoderContract.deployFrom0xArtifactAsync(
|
||||
|
@ -89,7 +89,7 @@ describe(ContractName.Forwarder, () => {
|
||||
erc721MakerAssetIds = erc721Balances[makerAddress][erc721Token.address];
|
||||
|
||||
wethContract = await WETH9Contract.deployFrom0xArtifactAsync(erc20Artifacts.WETH9, provider, txDefaults);
|
||||
weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider);
|
||||
weth = new DummyERC20TokenContract(wethContract.address, provider);
|
||||
erc20Wrapper.addDummyTokenContract(weth);
|
||||
|
||||
wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address);
|
||||
@ -135,7 +135,7 @@ describe(ContractName.Forwarder, () => {
|
||||
zrxAssetData,
|
||||
wethAssetData,
|
||||
);
|
||||
forwarderContract = new ForwarderContract(forwarderInstance.abi, forwarderInstance.address, provider);
|
||||
forwarderContract = new ForwarderContract(forwarderInstance.address, provider);
|
||||
forwarderWrapper = new ForwarderWrapper(forwarderContract, provider);
|
||||
const zrxDepositAmount = Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18);
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
|
@ -109,11 +109,7 @@ describe(ContractName.DutchAuction, () => {
|
||||
txDefaults,
|
||||
exchangeInstance.address,
|
||||
);
|
||||
dutchAuctionContract = new DutchAuctionContract(
|
||||
dutchAuctionInstance.abi,
|
||||
dutchAuctionInstance.address,
|
||||
provider,
|
||||
);
|
||||
dutchAuctionContract = new DutchAuctionContract(dutchAuctionInstance.address, provider);
|
||||
dutchAuctionTestWrapper = new DutchAuctionTestWrapper(dutchAuctionInstance, provider);
|
||||
|
||||
defaultMakerAssetAddress = erc20TokenA.address;
|
||||
|
@ -53,5 +53,5 @@ class {{contractName}}(BaseContractWrapper):
|
||||
def abi():
|
||||
"""Return the ABI to the underlying contract."""
|
||||
return json.loads(
|
||||
'{{{ABI}}}' # noqa: E501 (line-too-long)
|
||||
'{{{ABIString}}}' # noqa: E501 (line-too-long)
|
||||
)
|
||||
|
@ -105,14 +105,46 @@ export class {{contractName}}Contract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`{{contractName}} successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new {{contractName}}Contract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new {{contractName}}Contract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [{{> params inputs=ctor.inputs}}];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('{{contractName}}', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{{#each ABI}}
|
||||
{ {{#if (isDefined this.constant)}}
|
||||
constant: {{constant}},{{/if}}{{#if (isDefined this.anonymous)}}
|
||||
anonymous: {{anonymous}},{{/if}}
|
||||
inputs: [
|
||||
{{#each inputs}}
|
||||
{{> abi_type this}}
|
||||
{{/each}}
|
||||
],{{#this.name}}
|
||||
name: '{{{this}}}',{{/this.name}}
|
||||
outputs: [
|
||||
{{#each outputs}}
|
||||
{{> abi_type this}}
|
||||
{{/each}}
|
||||
],{{#if (isDefined this.payable)}}
|
||||
payable: {{payable}},{{/if}}{{#this.stateMutability}}
|
||||
stateMutability: '{{this}}',{{/this.stateMutability}}
|
||||
type: '{{type}}',
|
||||
},
|
||||
{{/each}}
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('{{contractName}}', {{contractName}}Contract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
12
packages/abi-gen-templates/partials/abi_type.handlebars
Normal file
12
packages/abi-gen-templates/partials/abi_type.handlebars
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
name: '{{name}}',
|
||||
type: '{{type}}',
|
||||
{{#if (isDefined indexed)}}indexed: {{indexed}},{{/if}}
|
||||
{{#if components}}
|
||||
components: [
|
||||
{{#each components}}
|
||||
{{> abi_type this}}
|
||||
{{/each}}
|
||||
]
|
||||
{{/if}}
|
||||
},
|
@ -1,7 +1,15 @@
|
||||
[
|
||||
{
|
||||
"version": "4.4.0",
|
||||
"version": "5.0.0",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Wrappers no longer require passing in the contract ABI at instantiation",
|
||||
"pr": 1883
|
||||
},
|
||||
{
|
||||
"note": "Contract addresses now re-exported from @0x/contract-addresses",
|
||||
"pr": 1883
|
||||
},
|
||||
{
|
||||
"note": "Update wrappers to include parameter assertions",
|
||||
"pr": 1823
|
||||
|
@ -15,6 +15,7 @@
|
||||
"lint": "tslint --format stylish --project .",
|
||||
"fix": "tslint --fix --format stylish --project .",
|
||||
"pre_build": "yarn generate_contract_wrappers",
|
||||
"prettier": "prettier --write src/**/* --config ../../.prettierrc",
|
||||
"clean": "shx rm -rf lib src/generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --template ../../node_modules/@0x/abi-gen-templates/contract.handlebars --partials '../../node_modules/@0x/abi-gen-templates/partials/**/*.handlebars' --output src/generated-wrappers --backend ethers"
|
||||
},
|
||||
@ -46,6 +47,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/base-contract": "^5.1.0",
|
||||
"@0x/contract-addresses": "^2.3.3",
|
||||
"@0x/contract-artifacts": "^1.5.1"
|
||||
},
|
||||
"publishConfig": {
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,7 @@ import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
export type CoordinatorRegistryEventArgs =
|
||||
| CoordinatorRegistryCoordinatorEndpointSetEventArgs;
|
||||
export type CoordinatorRegistryEventArgs = CoordinatorRegistryCoordinatorEndpointSetEventArgs;
|
||||
|
||||
export enum CoordinatorRegistryEvents {
|
||||
CoordinatorEndpointSet = 'CoordinatorEndpointSet',
|
||||
@ -35,34 +34,26 @@ export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends Deco
|
||||
coordinatorEndpoint: string;
|
||||
}
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class CoordinatorRegistryContract extends BaseContract {
|
||||
public setCoordinatorEndpoint = {
|
||||
async sendTransactionAsync(
|
||||
coordinatorEndpoint: string,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<string> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.setCoordinatorEndpoint.estimateGasAsync.bind(
|
||||
self,
|
||||
coordinatorEndpoint
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
async sendTransactionAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<string> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.setCoordinatorEndpoint.estimateGasAsync.bind(self, coordinatorEndpoint),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
coordinatorEndpoint: string,
|
||||
@ -70,47 +61,41 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
pollingIntervalMs?: number,
|
||||
timeoutMs?: number,
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint
|
||||
, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const txHashPromise = self.setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
},
|
||||
async estimateGasAsync(
|
||||
coordinatorEndpoint: string,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<number> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
async estimateGasAsync(coordinatorEndpoint: string, txData?: Partial<TxData> | undefined): Promise<number> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
async callAsync(
|
||||
coordinatorEndpoint: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<void
|
||||
> {
|
||||
): Promise<void> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
@ -120,9 +105,8 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||
]);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -135,18 +119,16 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<void
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
coordinatorEndpoint: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(coordinatorEndpoint: string): string {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint
|
||||
]);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [
|
||||
coordinatorEndpoint,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -155,8 +137,7 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
coordinatorOperator: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<string
|
||||
> {
|
||||
): Promise<string> {
|
||||
assert.isString('coordinatorOperator', coordinatorOperator);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
@ -166,9 +147,8 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator
|
||||
]);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -181,18 +161,16 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<string
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
coordinatorOperator: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(coordinatorOperator: string): string {
|
||||
assert.isString('coordinatorOperator', coordinatorOperator);
|
||||
const self = this as any as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [coordinatorOperator
|
||||
]);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [
|
||||
coordinatorOperator,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -212,7 +190,7 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
return CoordinatorRegistryContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@ -228,17 +206,13 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
@ -246,14 +220,85 @@ export class CoordinatorRegistryContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new CoordinatorRegistryContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new CoordinatorRegistryContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('CoordinatorRegistry', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: 'coordinatorEndpoint',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
name: 'setCoordinatorEndpoint',
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'coordinatorOperator',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'getCoordinatorEndpoint',
|
||||
outputs: [
|
||||
{
|
||||
name: 'coordinatorEndpoint',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
inputs: [],
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'constructor',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
name: 'coordinatorOperator',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'coordinatorEndpoint',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
name: 'CoordinatorEndpointSet',
|
||||
outputs: [],
|
||||
type: 'event',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('CoordinatorRegistry', CoordinatorRegistryContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -23,9 +23,7 @@ import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
export type ERC20TokenEventArgs =
|
||||
| ERC20TokenTransferEventArgs
|
||||
| ERC20TokenApprovalEventArgs;
|
||||
export type ERC20TokenEventArgs = ERC20TokenTransferEventArgs | ERC20TokenApprovalEventArgs;
|
||||
|
||||
export enum ERC20TokenEvents {
|
||||
Transfer = 'Transfer',
|
||||
@ -44,7 +42,6 @@ export interface ERC20TokenApprovalEventArgs extends DecodedLogArgs {
|
||||
_value: BigNumber;
|
||||
}
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
@ -53,29 +50,23 @@ export class ERC20TokenContract extends BaseContract {
|
||||
async sendTransactionAsync(
|
||||
_spender: string,
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<string> {
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.approve.estimateGasAsync.bind(
|
||||
self,
|
||||
_spender,
|
||||
_value
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.approve.estimateGasAsync.bind(self, _spender, _value),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
_spender: string,
|
||||
@ -84,53 +75,48 @@ export class ERC20TokenContract extends BaseContract {
|
||||
pollingIntervalMs?: number,
|
||||
timeoutMs?: number,
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const txHashPromise = self.approve.sendTransactionAsync(_spender,
|
||||
_value
|
||||
, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const txHashPromise = self.approve.sendTransactionAsync(_spender, _value, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
},
|
||||
async estimateGasAsync(
|
||||
_spender: string,
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<number> {
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
async callAsync(
|
||||
_spender: string,
|
||||
_value: BigNumber,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<boolean
|
||||
> {
|
||||
): Promise<boolean> {
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
@ -141,10 +127,8 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('approve(address,uint256)', [_spender, _value]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -157,30 +141,23 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('approve(address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
_spender: string,
|
||||
_value: BigNumber,
|
||||
): string {
|
||||
getABIEncodedTransactionData(_spender: string, _value: BigNumber): string {
|
||||
assert.isString('_spender', _spender);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [_spender,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('approve(address,uint256)', [
|
||||
_spender,
|
||||
_value,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
public totalSupply = {
|
||||
async callAsync(
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<BigNumber
|
||||
> {
|
||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
@ -189,7 +166,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('totalSupply()', []);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
@ -203,14 +180,12 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('totalSupply()');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
): string {
|
||||
const self = this as any as ERC20TokenContract;
|
||||
getABIEncodedTransactionData(): string {
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('totalSupply()', []);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
@ -220,32 +195,28 @@ export class ERC20TokenContract extends BaseContract {
|
||||
_from: string,
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<string> {
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from,
|
||||
_to,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.transferFrom.estimateGasAsync.bind(
|
||||
self,
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [
|
||||
_from,
|
||||
_to,
|
||||
_value
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
_value,
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.transferFrom.estimateGasAsync.bind(self, _from, _to, _value),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
_from: string,
|
||||
@ -255,25 +226,22 @@ export class ERC20TokenContract extends BaseContract {
|
||||
pollingIntervalMs?: number,
|
||||
timeoutMs?: number,
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const txHashPromise = self.transferFrom.sendTransactionAsync(_from,
|
||||
_to,
|
||||
_value
|
||||
, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const txHashPromise = self.transferFrom.sendTransactionAsync(_from, _to, _value, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
},
|
||||
async estimateGasAsync(
|
||||
_from: string,
|
||||
@ -281,24 +249,25 @@ export class ERC20TokenContract extends BaseContract {
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<number> {
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from,
|
||||
_to,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [
|
||||
_from,
|
||||
_to,
|
||||
_value,
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
async callAsync(
|
||||
_from: string,
|
||||
@ -306,8 +275,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
_value: BigNumber,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<boolean
|
||||
> {
|
||||
): Promise<boolean> {
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
@ -319,11 +287,12 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from,
|
||||
_to,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [
|
||||
_from,
|
||||
_to,
|
||||
_value,
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -336,24 +305,20 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(address,address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
_from: string,
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
): string {
|
||||
getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string {
|
||||
assert.isString('_from', _from);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [_from,
|
||||
_to,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('transferFrom(address,address,uint256)', [
|
||||
_from,
|
||||
_to,
|
||||
_value,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -362,8 +327,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
_owner: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<BigNumber
|
||||
> {
|
||||
): Promise<BigNumber> {
|
||||
assert.isString('_owner', _owner);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
@ -373,9 +337,8 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('balanceOf(address)', [_owner]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -388,18 +351,14 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('balanceOf(address)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
_owner: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(_owner: string): string {
|
||||
assert.isString('_owner', _owner);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('balanceOf(address)', [_owner]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -407,29 +366,23 @@ export class ERC20TokenContract extends BaseContract {
|
||||
async sendTransactionAsync(
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<string> {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.transfer.estimateGasAsync.bind(
|
||||
self,
|
||||
_to,
|
||||
_value
|
||||
),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
self.transfer.estimateGasAsync.bind(self, _to, _value),
|
||||
);
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
awaitTransactionSuccessAsync(
|
||||
_to: string,
|
||||
@ -438,53 +391,44 @@ export class ERC20TokenContract extends BaseContract {
|
||||
pollingIntervalMs?: number,
|
||||
timeoutMs?: number,
|
||||
): PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs> {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const txHashPromise = self.transfer.sendTransactionAsync(_to,
|
||||
_value
|
||||
, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const txHashPromise = self.transfer.sendTransactionAsync(_to, _value, txData);
|
||||
return new PromiseWithTransactionHash<TransactionReceiptWithDecodedLogs>(
|
||||
txHashPromise,
|
||||
(async (): Promise<TransactionReceiptWithDecodedLogs> => {
|
||||
// When the transaction hash resolves, wait for it to be mined.
|
||||
return self._web3Wrapper.awaitTransactionSuccessAsync(
|
||||
await txHashPromise,
|
||||
pollingIntervalMs,
|
||||
timeoutMs,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
},
|
||||
async estimateGasAsync(
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<number> {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to,
|
||||
_value
|
||||
]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
async estimateGasAsync(_to: string, _value: BigNumber, txData?: Partial<TxData> | undefined): Promise<number> {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value]);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...txData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
async callAsync(
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<boolean
|
||||
> {
|
||||
): Promise<boolean> {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
@ -495,10 +439,8 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -511,21 +453,15 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('transfer(address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
_to: string,
|
||||
_value: BigNumber,
|
||||
): string {
|
||||
getABIEncodedTransactionData(_to: string, _value: BigNumber): string {
|
||||
assert.isString('_to', _to);
|
||||
assert.isBigNumber('_value', _value);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to,
|
||||
_value
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('transfer(address,uint256)', [_to, _value]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -535,8 +471,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
_spender: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<BigNumber
|
||||
> {
|
||||
): Promise<BigNumber> {
|
||||
assert.isString('_owner', _owner);
|
||||
assert.isString('_spender', _spender);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
@ -547,10 +482,8 @@ export class ERC20TokenContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner,
|
||||
_spender
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const encodedData = self._strictEncodeArguments('allowance(address,address)', [_owner, _spender]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -563,21 +496,18 @@ export class ERC20TokenContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('allowance(address,address)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
_owner: string,
|
||||
_spender: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(_owner: string, _spender: string): string {
|
||||
assert.isString('_owner', _owner);
|
||||
assert.isString('_spender', _spender);
|
||||
const self = this as any as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [_owner,
|
||||
_spender
|
||||
]);
|
||||
const self = (this as any) as ERC20TokenContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('allowance(address,address)', [
|
||||
_owner,
|
||||
_spender,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -597,7 +527,7 @@ export class ERC20TokenContract extends BaseContract {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
return ERC20TokenContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@ -613,17 +543,13 @@ export class ERC20TokenContract extends BaseContract {
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
@ -631,14 +557,194 @@ export class ERC20TokenContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`ERC20Token successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new ERC20TokenContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new ERC20TokenContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Token', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_spender',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'approve',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [],
|
||||
name: 'totalSupply',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_from',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'transferFrom',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: '_owner',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'balanceOf',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'transfer',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'nonpayable',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: '_owner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_spender',
|
||||
type: 'address',
|
||||
},
|
||||
],
|
||||
name: 'allowance',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_from',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Transfer',
|
||||
outputs: [],
|
||||
type: 'event',
|
||||
},
|
||||
{
|
||||
anonymous: false,
|
||||
inputs: [
|
||||
{
|
||||
name: '_owner',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_spender',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: '_value',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'Approval',
|
||||
outputs: [],
|
||||
type: 'event',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('ERC20Token', ERC20TokenContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,6 @@ import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
@ -33,8 +32,7 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
addresses: string[],
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<BigNumber[]
|
||||
> {
|
||||
): Promise<BigNumber[]> {
|
||||
assert.isArray('addresses', addresses);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
@ -44,9 +42,8 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as EthBalanceCheckerContract;
|
||||
const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
|
||||
]);
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -59,18 +56,14 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber[]
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber[]>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
addresses: string[],
|
||||
): string {
|
||||
getABIEncodedTransactionData(addresses: string[]): string {
|
||||
assert.isArray('addresses', addresses);
|
||||
const self = this as any as EthBalanceCheckerContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses
|
||||
]);
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -90,7 +83,7 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@ -106,17 +99,13 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
@ -124,14 +113,48 @@ export class EthBalanceCheckerContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new EthBalanceCheckerContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new EthBalanceCheckerContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('EthBalanceChecker', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'addresses',
|
||||
type: 'address[]',
|
||||
},
|
||||
],
|
||||
name: 'getEthBalances',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
type: 'uint256[]',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('EthBalanceChecker', EthBalanceCheckerContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -23,7 +23,6 @@ import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
@ -35,8 +34,7 @@ export class IValidatorContract extends BaseContract {
|
||||
signature: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<boolean
|
||||
> {
|
||||
): Promise<boolean> {
|
||||
assert.isString('hash', hash);
|
||||
assert.isString('signerAddress', signerAddress);
|
||||
assert.isString('signature', signature);
|
||||
@ -48,11 +46,12 @@ export class IValidatorContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as IValidatorContract;
|
||||
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
|
||||
signerAddress,
|
||||
signature
|
||||
]);
|
||||
const self = (this as any) as IValidatorContract;
|
||||
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [
|
||||
hash,
|
||||
signerAddress,
|
||||
signature,
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -65,24 +64,20 @@ export class IValidatorContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
hash: string,
|
||||
signerAddress: string,
|
||||
signature: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(hash: string, signerAddress: string, signature: string): string {
|
||||
assert.isString('hash', hash);
|
||||
assert.isString('signerAddress', signerAddress);
|
||||
assert.isString('signature', signature);
|
||||
const self = this as any as IValidatorContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [hash,
|
||||
signerAddress,
|
||||
signature
|
||||
]);
|
||||
const self = (this as any) as IValidatorContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,address,bytes)', [
|
||||
hash,
|
||||
signerAddress,
|
||||
signature,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -102,7 +97,7 @@ export class IValidatorContract extends BaseContract {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@ -118,17 +113,13 @@ export class IValidatorContract extends BaseContract {
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
@ -136,14 +127,52 @@ export class IValidatorContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new IValidatorContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new IValidatorContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IValidator', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
name: 'signerAddress',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'isValidSignature',
|
||||
outputs: [
|
||||
{
|
||||
name: 'isValid',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
@ -23,7 +23,6 @@ import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
@ -34,8 +33,7 @@ export class IWalletContract extends BaseContract {
|
||||
signature: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<boolean
|
||||
> {
|
||||
): Promise<boolean> {
|
||||
assert.isString('hash', hash);
|
||||
assert.isString('signature', signature);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
@ -46,10 +44,8 @@ export class IWalletContract extends BaseContract {
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = this as any as IWalletContract;
|
||||
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
|
||||
signature
|
||||
]);
|
||||
const self = (this as any) as IWalletContract;
|
||||
const encodedData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash, signature]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
@ -62,21 +58,18 @@ export class IWalletContract extends BaseContract {
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,bytes)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean
|
||||
>(rawCallResult);
|
||||
const result = abiEncoder.strictDecodeReturnValue<boolean>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
getABIEncodedTransactionData(
|
||||
hash: string,
|
||||
signature: string,
|
||||
): string {
|
||||
getABIEncodedTransactionData(hash: string, signature: string): string {
|
||||
assert.isString('hash', hash);
|
||||
assert.isString('signature', signature);
|
||||
const self = this as any as IWalletContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [hash,
|
||||
signature
|
||||
]);
|
||||
const self = (this as any) as IWalletContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('isValidSignature(bytes32,bytes)', [
|
||||
hash,
|
||||
signature,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
};
|
||||
@ -96,7 +89,7 @@ export class IWalletContract extends BaseContract {
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults, );
|
||||
return IWalletContract.deployAsync(bytecode, abi, provider, txDefaults);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@ -112,17 +105,13 @@ export class IWalletContract extends BaseContract {
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = BaseContract._formatABIDataItemList(
|
||||
constructorAbi.inputs,
|
||||
[],
|
||||
BaseContract._bigNumberToString,
|
||||
);
|
||||
[] = BaseContract._formatABIDataItemList(constructorAbi.inputs, [], BaseContract._bigNumberToString);
|
||||
const iface = new ethers.utils.Interface(abi);
|
||||
const deployInfo = iface.deployFunction;
|
||||
const txData = deployInfo.encode(bytecode, []);
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const txDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{data: txData},
|
||||
{ data: txData },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
@ -130,14 +119,48 @@ export class IWalletContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`IWallet successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new IWalletContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new IWalletContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IWallet', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'bytes32',
|
||||
},
|
||||
{
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
},
|
||||
],
|
||||
name: 'isValidSignature',
|
||||
outputs: [
|
||||
{
|
||||
name: 'isValid',
|
||||
type: 'bool',
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('IWallet', IWalletContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -18,3 +18,5 @@ export * from './generated-wrappers/zrx_token';
|
||||
export * from './generated-wrappers/coordinator';
|
||||
export * from './generated-wrappers/coordinator_registry';
|
||||
export * from './generated-wrappers/eth_balance_checker';
|
||||
|
||||
export * from '@0x/contract-addresses';
|
||||
|
@ -4,7 +4,7 @@ import { AbiEncoder, abiUtils, logUtils } from '@0x/utils';
|
||||
import chalk from 'chalk';
|
||||
import * as changeCase from 'change-case';
|
||||
import * as cliFormat from 'cli-format';
|
||||
import { AbiDefinition, ConstructorAbi, DevdocOutput, EventAbi, MethodAbi } from 'ethereum-types';
|
||||
import { AbiDefinition, ConstructorAbi, ContractAbi, DevdocOutput, EventAbi, MethodAbi } from 'ethereum-types';
|
||||
import { sync as globSync } from 'glob';
|
||||
import * as Handlebars from 'handlebars';
|
||||
import * as _ from 'lodash';
|
||||
@ -79,11 +79,21 @@ function registerPartials(): void {
|
||||
}
|
||||
}
|
||||
|
||||
if (args.language === 'TypeScript') {
|
||||
function registerTypeScriptHelpers(): void {
|
||||
Handlebars.registerHelper('parameterType', utils.solTypeToTsType.bind(utils, ParamKind.Input, args.backend));
|
||||
Handlebars.registerHelper('assertionType', utils.solTypeToAssertion.bind(utils));
|
||||
Handlebars.registerHelper('returnType', utils.solTypeToTsType.bind(utils, ParamKind.Output, args.backend));
|
||||
} else if (args.language === 'Python') {
|
||||
|
||||
// Check if 0 or false exists
|
||||
Handlebars.registerHelper(
|
||||
'isDefined',
|
||||
(context: any): boolean => {
|
||||
return context !== undefined;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function registerPythonHelpers(): void {
|
||||
Handlebars.registerHelper('equal', (lhs, rhs, options) => {
|
||||
return lhs === rhs;
|
||||
});
|
||||
@ -109,6 +119,11 @@ if (args.language === 'TypeScript') {
|
||||
},
|
||||
);
|
||||
}
|
||||
if (args.language === 'TypeScript') {
|
||||
registerTypeScriptHelpers();
|
||||
} else if (args.language === 'Python') {
|
||||
registerPythonHelpers();
|
||||
}
|
||||
registerPartials();
|
||||
|
||||
function makeLanguageSpecificName(methodName: string): string {
|
||||
@ -207,7 +222,8 @@ for (const abiFileName of abiFileNames) {
|
||||
const contextData = {
|
||||
contractName: namedContent.name,
|
||||
ctor,
|
||||
ABI: JSON.stringify(ABI),
|
||||
ABI: ABI as ContractAbi,
|
||||
ABIString: JSON.stringify(ABI),
|
||||
methods: methodsData,
|
||||
events: eventsData,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { EventAbi, MethodAbi } from 'ethereum-types';
|
||||
import { ContractAbi, EventAbi, MethodAbi } from 'ethereum-types';
|
||||
|
||||
export enum ParamKind {
|
||||
Input = 'input',
|
||||
@ -19,6 +19,7 @@ export interface Method extends MethodAbi {
|
||||
|
||||
export interface ContextData {
|
||||
contractName: string;
|
||||
ABI: ContractAbi;
|
||||
methods: Method[];
|
||||
events: EventAbi[];
|
||||
}
|
||||
|
@ -428,14 +428,159 @@ export class AbiGenDummyContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`AbiGenDummy successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new AbiGenDummyContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new AbiGenDummyContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('AbiGenDummy', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'simpleRequire',
|
||||
outputs: [
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'bytes32',
|
||||
|
||||
},
|
||||
{
|
||||
name: 'v',
|
||||
type: 'uint8',
|
||||
|
||||
},
|
||||
{
|
||||
name: 'r',
|
||||
type: 'bytes32',
|
||||
|
||||
},
|
||||
{
|
||||
name: 's',
|
||||
type: 'bytes32',
|
||||
|
||||
},
|
||||
],
|
||||
name: 'ecrecoverFn',
|
||||
outputs: [
|
||||
{
|
||||
name: 'signerAddress',
|
||||
type: 'address',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'revertWithConstant',
|
||||
outputs: [
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'simpleRevert',
|
||||
outputs: [
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'requireWithConstant',
|
||||
outputs: [
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'x',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
name: 'simplePureFunctionWithInput',
|
||||
outputs: [
|
||||
{
|
||||
name: 'sum',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'simplePureFunction',
|
||||
outputs: [
|
||||
{
|
||||
name: 'result',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
],
|
||||
name: 'pureFunctionWithConstant',
|
||||
outputs: [
|
||||
{
|
||||
name: 'someConstant',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('AbiGenDummy', AbiGenDummyContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
@ -78,14 +78,26 @@ export class LibDummyContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`LibDummy successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new LibDummyContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new LibDummyContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('LibDummy', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('LibDummy', LibDummyContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
@ -170,14 +170,68 @@ export class TestLibDummyContract extends BaseContract {
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`TestLibDummy successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new TestLibDummyContract(abi, txReceipt.contractAddress as string, provider, txDefaults);
|
||||
const contractInstance = new TestLibDummyContract(txReceipt.contractAddress as string, provider, txDefaults);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
constructor(abi: ContractAbi, address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('TestLibDummy', abi, address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
||||
|
||||
|
||||
/**
|
||||
* @returns The contract ABI
|
||||
*/
|
||||
public static ABI(): ContractAbi {
|
||||
const abi = [
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'x',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
name: 'publicAddConstant',
|
||||
outputs: [
|
||||
{
|
||||
name: 'result',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'x',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
name: 'publicAddOne',
|
||||
outputs: [
|
||||
{
|
||||
name: 'result',
|
||||
type: 'uint256',
|
||||
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
} // tslint:disable:max-file-line-count
|
||||
constructor(address: string, supportedProvider: SupportedProvider, txDefaults?: Partial<TxData>) {
|
||||
super('TestLibDummy', TestLibDummyContract.ABI(), address, supportedProvider, txDefaults);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
|
||||
// tslint:disable:max-file-line-count
|
||||
// tslint:enable:no-unbound-method no-parameter-reassignment no-consecutive-blank-lines ordered-imports align
|
||||
// tslint:enable:trailing-comma whitespace no-trailing-whitespace
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
|
||||
import { Coordinator, CoordinatorRegistry, Exchange } from '@0x/contract-artifacts';
|
||||
import { Coordinator } from '@0x/contract-artifacts';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import { generatePseudoRandomSalt, signatureUtils } from '@0x/order-utils';
|
||||
import { Order, SignedOrder, SignedZeroExTransaction, ZeroExTransaction } from '@0x/types';
|
||||
@ -69,19 +69,16 @@ export class CoordinatorWrapper extends ContractWrapper {
|
||||
this.registryAddress = registryAddress === undefined ? contractAddresses.coordinatorRegistry : registryAddress;
|
||||
|
||||
this._contractInstance = new CoordinatorContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._registryInstance = new CoordinatorRegistryContract(
|
||||
CoordinatorRegistry.compilerOutput.abi,
|
||||
this.registryAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
this._exchangeInstance = new ExchangeContract(
|
||||
Exchange.compilerOutput.abi,
|
||||
this.exchangeAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -171,7 +171,6 @@ export class DutchAuctionWrapper extends ContractWrapper {
|
||||
return this._dutchAuctionContractIfExists;
|
||||
}
|
||||
const contractInstance = new DutchAuctionContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -66,7 +66,6 @@ export class ERC20ProxyWrapper extends ContractWrapper {
|
||||
return this._erc20ProxyContractIfExists;
|
||||
}
|
||||
const contractInstance = new ERC20ProxyContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -431,7 +431,6 @@ export class ERC20TokenWrapper extends ContractWrapper {
|
||||
return tokenContract;
|
||||
}
|
||||
const contractInstance = new ERC20TokenContract(
|
||||
this.abi,
|
||||
normalizedTokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -66,7 +66,6 @@ export class ERC721ProxyWrapper extends ContractWrapper {
|
||||
return this._erc721ProxyContractIfExists;
|
||||
}
|
||||
const contractInstance = new ERC721ProxyContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -458,7 +458,6 @@ export class ERC721TokenWrapper extends ContractWrapper {
|
||||
return tokenContract;
|
||||
}
|
||||
const contractInstance = new ERC721TokenContract(
|
||||
this.abi,
|
||||
normalizedTokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -199,7 +199,6 @@ export class EtherTokenWrapper extends ContractWrapper {
|
||||
return etherTokenContract;
|
||||
}
|
||||
const contractInstance = new WETH9Contract(
|
||||
this.abi,
|
||||
etherTokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ExchangeContract, ExchangeEventArgs, ExchangeEvents, IAssetProxyContract } from '@0x/abi-gen-wrappers';
|
||||
import { Exchange, IAssetProxy } from '@0x/contract-artifacts';
|
||||
import { Exchange } from '@0x/contract-artifacts';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
assetDataUtils,
|
||||
@ -1212,11 +1212,7 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
const makerAssetData = signedOrder.makerAssetData;
|
||||
const makerAssetDataProxyId = assetDataUtils.decodeAssetProxyId(signedOrder.makerAssetData);
|
||||
const assetProxyAddress = await exchangeInstance.assetProxies.callAsync(makerAssetDataProxyId);
|
||||
const assetProxy = new IAssetProxyContract(
|
||||
IAssetProxy.compilerOutput.abi,
|
||||
assetProxyAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
);
|
||||
const assetProxy = new IAssetProxyContract(assetProxyAddress, this._web3Wrapper.getProvider());
|
||||
|
||||
const result = await assetProxy.transferFrom.callAsync(
|
||||
makerAssetData,
|
||||
@ -1285,7 +1281,6 @@ export class ExchangeWrapper extends ContractWrapper {
|
||||
return this._exchangeContractIfExists;
|
||||
}
|
||||
const contractInstance = new ExchangeContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -241,7 +241,6 @@ export class ForwarderWrapper extends ContractWrapper {
|
||||
return this._forwarderContractIfExists;
|
||||
}
|
||||
const contractInstance = new ForwarderContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -174,7 +174,6 @@ export class OrderValidatorWrapper extends ContractWrapper {
|
||||
return this._orderValidatorContractIfExists;
|
||||
}
|
||||
const contractInstance = new OrderValidatorContract(
|
||||
this.abi,
|
||||
this.address,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { CoordinatorRegistryContract } from '@0x/abi-gen-wrappers';
|
||||
import { CoordinatorRegistry } from '@0x/contract-artifacts';
|
||||
import { constants } from '@0x/contracts-test-utils';
|
||||
import { defaultOrmConfig, getAppAsync } from '@0x/coordinator-server';
|
||||
import { BlockchainLifecycle } from '@0x/dev-utils';
|
||||
@ -162,11 +161,7 @@ describe('CoordinatorWrapper', () => {
|
||||
});
|
||||
|
||||
// setup coordinator registry
|
||||
coordinatorRegistryInstance = new CoordinatorRegistryContract(
|
||||
CoordinatorRegistry.compilerOutput.abi,
|
||||
contractAddresses.coordinatorRegistry,
|
||||
provider,
|
||||
);
|
||||
coordinatorRegistryInstance = new CoordinatorRegistryContract(contractAddresses.coordinatorRegistry, provider);
|
||||
|
||||
// register coordinator server
|
||||
await web3Wrapper.awaitTransactionSuccessAsync(
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DummyERC20TokenContract } from '@0x/abi-gen-wrappers';
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||
import { SignedOrder } from '@0x/types';
|
||||
@ -122,7 +121,6 @@ export class DutchAuctionUtils {
|
||||
}
|
||||
private async _increaseERC20BalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
@ -138,7 +136,6 @@ export class DutchAuctionUtils {
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DummyERC721TokenContract } from '@0x/abi-gen-wrappers';
|
||||
import { DummyERC721Token } from '@0x/contract-artifacts';
|
||||
import { generatePseudoRandomSalt } from '@0x/order-utils';
|
||||
import { BigNumber } from '@0x/utils';
|
||||
|
||||
@ -26,7 +25,7 @@ export const tokenUtils = {
|
||||
return DUMMY_ERC_721_ADRESSES;
|
||||
},
|
||||
async mintDummyERC721Async(address: string, tokenOwner: string): Promise<BigNumber> {
|
||||
const erc721 = new DummyERC721TokenContract(DummyERC721Token.compilerOutput.abi, address, provider, txDefaults);
|
||||
const erc721 = new DummyERC721TokenContract(address, provider, txDefaults);
|
||||
const tokenId = generatePseudoRandomSalt();
|
||||
const txHash = await erc721.mint.sendTransactionAsync(tokenOwner, tokenId);
|
||||
web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
|
@ -31,7 +31,6 @@
|
||||
"dependencies": {
|
||||
"@0x/abi-gen-wrappers": "^4.3.0",
|
||||
"@0x/base-contract": "^5.1.0",
|
||||
"@0x/contract-artifacts": "^1.5.1",
|
||||
"@0x/order-utils": "^8.1.1",
|
||||
"@0x/types": "^2.2.2",
|
||||
"@0x/typescript-typings": "^4.2.2",
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DummyERC20TokenContract, DummyERC721TokenContract, ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { assetDataUtils } from '@0x/order-utils';
|
||||
import { orderFactory } from '@0x/order-utils/lib/src/order_factory';
|
||||
import { OrderWithoutExchangeAddress, SignedOrder } from '@0x/types';
|
||||
@ -120,7 +119,6 @@ export class FillScenarios {
|
||||
fillableAmount,
|
||||
);
|
||||
const exchangeInstance = new ExchangeContract(
|
||||
artifacts.Exchange.compilerOutput.abi,
|
||||
signedOrder.exchangeAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
@ -195,7 +193,6 @@ export class FillScenarios {
|
||||
tokenId: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc721Token = new DummyERC721TokenContract(
|
||||
artifacts.DummyERC721Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
@ -211,7 +208,6 @@ export class FillScenarios {
|
||||
tokenId: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc721Token = new DummyERC721TokenContract(
|
||||
artifacts.DummyERC721Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
@ -241,7 +237,6 @@ export class FillScenarios {
|
||||
}
|
||||
private async _increaseERC20BalanceAsync(tokenAddress: string, address: string, amount: BigNumber): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
@ -257,7 +252,6 @@ export class FillScenarios {
|
||||
amount: BigNumber,
|
||||
): Promise<void> {
|
||||
const erc20Token = new DummyERC20TokenContract(
|
||||
artifacts.DummyERC20Token.compilerOutput.abi,
|
||||
tokenAddress,
|
||||
this._web3Wrapper.getProvider(),
|
||||
this._web3Wrapper.getContractDefaults(),
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { ExchangeContract, IValidatorContract, IWalletContract } from '@0x/abi-gen-wrappers';
|
||||
import { getContractAddressesForNetworkOrThrow } from '@0x/contract-addresses';
|
||||
import * as artifacts from '@0x/contract-artifacts';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
ECSignature,
|
||||
@ -111,11 +110,7 @@ export const signatureUtils = {
|
||||
const web3Wrapper = new Web3Wrapper(provider);
|
||||
const networkId = await web3Wrapper.getNetworkIdAsync();
|
||||
const addresses = getContractAddressesForNetworkOrThrow(networkId);
|
||||
const exchangeContract = new ExchangeContract(
|
||||
artifacts.Exchange.compilerOutput.abi,
|
||||
addresses.exchange,
|
||||
provider,
|
||||
);
|
||||
const exchangeContract = new ExchangeContract(addresses.exchange, provider);
|
||||
const isValid = await exchangeContract.preSigned.callAsync(data, signerAddress);
|
||||
return isValid;
|
||||
},
|
||||
@ -139,7 +134,7 @@ export const signatureUtils = {
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
// tslint:disable-next-line:custom-no-magic-numbers
|
||||
const signatureWithoutType = signature.slice(0, -2);
|
||||
const walletContract = new IWalletContract(artifacts.IWallet.compilerOutput.abi, signerAddress, provider);
|
||||
const walletContract = new IWalletContract(signerAddress, provider);
|
||||
const isValid = await walletContract.isValidSignature.callAsync(data, signatureWithoutType);
|
||||
return isValid;
|
||||
},
|
||||
@ -162,7 +157,7 @@ export const signatureUtils = {
|
||||
assert.isHexString('signature', signature);
|
||||
assert.isETHAddressHex('signerAddress', signerAddress);
|
||||
const validatorSignature = parseValidatorSignature(signature);
|
||||
const exchangeContract = new ExchangeContract(artifacts.Exchange.compilerOutput.abi, signerAddress, provider);
|
||||
const exchangeContract = new ExchangeContract(signerAddress, provider);
|
||||
const isValidatorApproved = await exchangeContract.allowedValidators.callAsync(
|
||||
signerAddress,
|
||||
validatorSignature.validatorAddress,
|
||||
@ -173,11 +168,7 @@ export const signatureUtils = {
|
||||
);
|
||||
}
|
||||
|
||||
const validatorContract = new IValidatorContract(
|
||||
artifacts.IValidator.compilerOutput.abi,
|
||||
signerAddress,
|
||||
provider,
|
||||
);
|
||||
const validatorContract = new IValidatorContract(signerAddress, provider);
|
||||
const isValid = await validatorContract.isValidSignature.callAsync(
|
||||
data,
|
||||
signerAddress,
|
||||
|
108
yarn.lock
108
yarn.lock
@ -512,97 +512,6 @@
|
||||
lodash "^4.17.11"
|
||||
uuid "^3.3.2"
|
||||
|
||||
"@0x/contracts-asset-proxy@^1.0.2":
|
||||
version "1.0.9"
|
||||
resolved "https://registry.npmjs.org/@0x/contracts-asset-proxy/-/contracts-asset-proxy-1.0.9.tgz#3a48e64b93ddc642834bde1bd09cdd84ca688a2b"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.0.2"
|
||||
"@0x/contracts-erc20" "^1.0.9"
|
||||
"@0x/contracts-erc721" "^1.0.9"
|
||||
"@0x/contracts-utils" "2.0.1"
|
||||
"@0x/order-utils" "^7.0.2"
|
||||
"@0x/types" "^2.1.1"
|
||||
"@0x/typescript-typings" "^4.1.0"
|
||||
"@0x/utils" "^4.2.2"
|
||||
"@0x/web3-wrapper" "^6.0.2"
|
||||
ethereum-types "^2.1.0"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/contracts-erc20@^1.0.2", "@0x/contracts-erc20@^1.0.9":
|
||||
version "1.0.9"
|
||||
resolved "https://registry.npmjs.org/@0x/contracts-erc20/-/contracts-erc20-1.0.9.tgz#366ce8222dcae5ade0ea7ca95332416a080f6abf"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.0.2"
|
||||
"@0x/contracts-exchange-libs" "1.0.2"
|
||||
"@0x/contracts-utils" "2.0.1"
|
||||
"@0x/types" "^2.1.1"
|
||||
"@0x/typescript-typings" "^4.1.0"
|
||||
"@0x/utils" "^4.2.2"
|
||||
"@0x/web3-wrapper" "^6.0.2"
|
||||
ethereum-types "^2.1.0"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/contracts-erc721@^1.0.2", "@0x/contracts-erc721@^1.0.9":
|
||||
version "1.0.9"
|
||||
resolved "https://registry.npmjs.org/@0x/contracts-erc721/-/contracts-erc721-1.0.9.tgz#3991858a3bf5a80dcd6e5fd65e938f8adc3b347c"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.0.2"
|
||||
"@0x/contracts-utils" "2.0.1"
|
||||
"@0x/types" "^2.1.1"
|
||||
"@0x/typescript-typings" "^4.1.0"
|
||||
"@0x/utils" "^4.2.2"
|
||||
"@0x/web3-wrapper" "^6.0.2"
|
||||
ethereum-types "^2.1.0"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/contracts-exchange-libs@1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@0x/contracts-exchange-libs/-/contracts-exchange-libs-1.0.2.tgz#0682c01cdb3e36100bda0ffbdf9badb5b8a01fc4"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^4.0.1"
|
||||
"@0x/contracts-utils" "^2.0.1"
|
||||
"@0x/order-utils" "^5.0.0"
|
||||
"@0x/types" "^2.0.1"
|
||||
"@0x/typescript-typings" "^4.0.0"
|
||||
"@0x/utils" "^4.0.2"
|
||||
"@0x/web3-wrapper" "^4.0.1"
|
||||
ethereum-types "^2.0.0"
|
||||
lodash "^4.17.5"
|
||||
|
||||
"@0x/contracts-exchange-libs@^1.0.2":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.npmjs.org/@0x/contracts-exchange-libs/-/contracts-exchange-libs-1.1.3.tgz#dc9429e9c5fc750e9f5006e5ad53ebd7aa577c28"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.0.2"
|
||||
"@0x/contracts-utils" "^2.0.8"
|
||||
"@0x/order-utils" "^7.0.2"
|
||||
"@0x/types" "^2.1.1"
|
||||
"@0x/typescript-typings" "^4.1.0"
|
||||
"@0x/utils" "^4.2.2"
|
||||
"@0x/web3-wrapper" "^6.0.2"
|
||||
ethereum-types "^2.1.0"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/contracts-exchange@1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@0x/contracts-exchange/-/contracts-exchange-1.0.2.tgz#4c02378b26a7bf6324e16a41f2851c43fed82c63"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^4.0.1"
|
||||
"@0x/contracts-asset-proxy" "^1.0.2"
|
||||
"@0x/contracts-erc20" "^1.0.2"
|
||||
"@0x/contracts-erc721" "^1.0.2"
|
||||
"@0x/contracts-exchange-libs" "^1.0.2"
|
||||
"@0x/contracts-test-utils" "^3.0.1"
|
||||
"@0x/contracts-utils" "^2.0.1"
|
||||
"@0x/order-utils" "^5.0.0"
|
||||
"@0x/types" "^2.0.1"
|
||||
"@0x/typescript-typings" "^4.0.0"
|
||||
"@0x/utils" "^4.0.2"
|
||||
"@0x/web3-wrapper" "^4.0.1"
|
||||
ethereum-types "^2.0.0"
|
||||
ethereumjs-util "^5.1.1"
|
||||
lodash "^4.17.5"
|
||||
|
||||
"@0x/contracts-utils@2.0.1":
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@0x/contracts-utils/-/contracts-utils-2.0.1.tgz#32e298ab5e6edb045c37294063ff928b629db0a4"
|
||||
@ -618,21 +527,6 @@
|
||||
ethereumjs-util "^5.1.1"
|
||||
lodash "^4.17.5"
|
||||
|
||||
"@0x/contracts-utils@^2.0.1", "@0x/contracts-utils@^2.0.8":
|
||||
version "2.0.8"
|
||||
resolved "https://registry.npmjs.org/@0x/contracts-utils/-/contracts-utils-2.0.8.tgz#b6a3775296e04c7ca9ebea7eae56fda48a43239d"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.0.2"
|
||||
"@0x/order-utils" "^7.0.2"
|
||||
"@0x/types" "^2.1.1"
|
||||
"@0x/typescript-typings" "^4.1.0"
|
||||
"@0x/utils" "^4.2.2"
|
||||
"@0x/web3-wrapper" "^6.0.2"
|
||||
bn.js "^4.11.8"
|
||||
ethereum-types "^2.1.0"
|
||||
ethereumjs-util "^5.1.1"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/coordinator-server@0.1.1":
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@0x/coordinator-server/-/coordinator-server-0.1.1.tgz#7eeb74959dc72b76756b95ccd14fd9fa8d072ede"
|
||||
@ -684,7 +578,7 @@
|
||||
ethers "~4.0.4"
|
||||
lodash "^4.17.11"
|
||||
|
||||
"@0x/order-utils@^7.0.2", "@0x/order-utils@^7.1.1", "@0x/order-utils@^7.2.0":
|
||||
"@0x/order-utils@^7.1.1", "@0x/order-utils@^7.2.0":
|
||||
version "7.2.0"
|
||||
resolved "https://registry.npmjs.org/@0x/order-utils/-/order-utils-7.2.0.tgz#c73d81e3225e9ec7736f9789e14388c9fe2b831c"
|
||||
dependencies:
|
||||
|
Loading…
x
Reference in New Issue
Block a user