merge development
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -98,7 +98,6 @@ packages/sol-tracing-utils/test/fixtures/artifacts/
|
||||
python-packages/contract_artifacts/src/zero_ex/contract_artifacts/artifacts/
|
||||
|
||||
# generated contract wrappers
|
||||
packages/abi-gen-wrappers/src/generated-wrappers/
|
||||
packages/python-contract-wrappers/generated/
|
||||
contracts/coordinator/generated-wrappers/
|
||||
contracts/exchange/generated-wrappers/
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -26,30 +26,33 @@ import * as ethers from 'ethers';
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class IValidatorContract extends BaseContract {
|
||||
export class StaticCallProxyContract extends BaseContract {
|
||||
/**
|
||||
* Verifies that a signature is valid.
|
||||
* Makes a staticcall to a target address and verifies that the data returned matches the expected return data.
|
||||
*/
|
||||
public isValidSignature = {
|
||||
public transferFrom = {
|
||||
/**
|
||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||
* since they don't modify state.
|
||||
* @param hash Message hash that is signed.
|
||||
* @param signerAddress Address that should have signed the given hash.
|
||||
* @param signature Proof of signing.
|
||||
* @returns Magic bytes4 value if the signature is valid. Magic value is bytes4(keccak256("isValidValidatorSignature(address,bytes32,address,bytes)"))
|
||||
* @param assetData Byte array encoded with staticCallTarget, staticCallData,
|
||||
* and expectedCallResultHash
|
||||
* @param from This value is ignored.
|
||||
* @param to This value is ignored.
|
||||
* @param amount This value is ignored.
|
||||
*/
|
||||
async callAsync(
|
||||
hash: string,
|
||||
signerAddress: string,
|
||||
signature: string,
|
||||
assetData: string,
|
||||
from: string,
|
||||
to: string,
|
||||
amount: BigNumber,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<string> {
|
||||
assert.isString('hash', hash);
|
||||
assert.isString('signerAddress', signerAddress);
|
||||
assert.isString('signature', signature);
|
||||
): Promise<void> {
|
||||
assert.isString('assetData', assetData);
|
||||
assert.isString('from', from);
|
||||
assert.isString('to', to);
|
||||
assert.isBigNumber('amount', amount);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
@@ -58,11 +61,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.toLowerCase(),
|
||||
signature,
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const encodedData = self._strictEncodeArguments('transferFrom(bytes,address,address,uint256)', [
|
||||
assetData,
|
||||
from.toLowerCase(),
|
||||
to.toLowerCase(),
|
||||
amount,
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
@@ -78,7 +82,85 @@ export class IValidatorContract extends BaseContract {
|
||||
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||
* to create a 0x transaction (see protocol spec for more details).
|
||||
* @param assetData Byte array encoded with staticCallTarget, staticCallData,
|
||||
* and expectedCallResultHash
|
||||
* @param from This value is ignored.
|
||||
* @param to This value is ignored.
|
||||
* @param amount This value is ignored.
|
||||
*/
|
||||
getABIEncodedTransactionData(assetData: string, from: string, to: string, amount: BigNumber): string {
|
||||
assert.isString('assetData', assetData);
|
||||
assert.isString('from', from);
|
||||
assert.isString('to', to);
|
||||
assert.isBigNumber('amount', amount);
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments(
|
||||
'transferFrom(bytes,address,address,uint256)',
|
||||
[assetData, from.toLowerCase(), to.toLowerCase(), amount],
|
||||
);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
getABIDecodedTransactionData(callData: string): void {
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
||||
return abiDecodedCallData;
|
||||
},
|
||||
getABIDecodedReturnData(returnData: string): void {
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('transferFrom(bytes,address,address,uint256)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
||||
return abiDecodedReturnData;
|
||||
},
|
||||
};
|
||||
/**
|
||||
* Gets the proxy id associated with the proxy address.
|
||||
*/
|
||||
public getProxyId = {
|
||||
/**
|
||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||
* since they don't modify state.
|
||||
* @returns Proxy id.
|
||||
*/
|
||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const encodedData = self._strictEncodeArguments('getProxyId()', []);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
callDataWithDefaults.from = callDataWithDefaults.from
|
||||
? callDataWithDefaults.from.toLowerCase()
|
||||
: callDataWithDefaults.from;
|
||||
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
@@ -88,32 +170,22 @@ export class IValidatorContract extends BaseContract {
|
||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||
* to create a 0x transaction (see protocol spec for more details).
|
||||
* @param hash Message hash that is signed.
|
||||
* @param signerAddress Address that should have signed the given hash.
|
||||
* @param signature Proof of signing.
|
||||
*/
|
||||
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.toLowerCase(),
|
||||
signature,
|
||||
]);
|
||||
getABIEncodedTransactionData(): string {
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getProxyId()', []);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
getABIDecodedTransactionData(callData: string): string {
|
||||
const self = (this as any) as IValidatorContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
||||
return abiDecodedCallData;
|
||||
},
|
||||
getABIDecodedReturnData(returnData: string): string {
|
||||
const self = (this as any) as IValidatorContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('isValidSignature(bytes32,address,bytes)');
|
||||
const self = (this as any) as StaticCallProxyContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getProxyId()');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
||||
return abiDecodedReturnData;
|
||||
@@ -124,7 +196,7 @@ export class IValidatorContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
|
||||
): Promise<IValidatorContract> {
|
||||
): Promise<StaticCallProxyContract> {
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
@@ -142,7 +214,7 @@ export class IValidatorContract extends BaseContract {
|
||||
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
|
||||
}
|
||||
}
|
||||
return IValidatorContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
|
||||
return StaticCallProxyContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
@@ -150,7 +222,7 @@ export class IValidatorContract extends BaseContract {
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractAbi },
|
||||
): Promise<IValidatorContract> {
|
||||
): Promise<StaticCallProxyContract> {
|
||||
assert.isHexString('bytecode', bytecode);
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
@@ -172,8 +244,8 @@ export class IValidatorContract extends BaseContract {
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`IValidator successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new IValidatorContract(
|
||||
logUtils.log(`StaticCallProxy successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new StaticCallProxyContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
@@ -192,19 +264,32 @@ export class IValidatorContract extends BaseContract {
|
||||
constant: true,
|
||||
inputs: [
|
||||
{
|
||||
name: 'hash',
|
||||
type: 'bytes32',
|
||||
name: 'assetData',
|
||||
type: 'bytes',
|
||||
},
|
||||
{
|
||||
name: 'signerAddress',
|
||||
name: 'from',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'signature',
|
||||
type: 'bytes',
|
||||
name: 'to',
|
||||
type: 'address',
|
||||
},
|
||||
{
|
||||
name: 'amount',
|
||||
type: 'uint256',
|
||||
},
|
||||
],
|
||||
name: 'isValidSignature',
|
||||
name: 'transferFrom',
|
||||
outputs: [],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
type: 'function',
|
||||
},
|
||||
{
|
||||
constant: true,
|
||||
inputs: [],
|
||||
name: 'getProxyId',
|
||||
outputs: [
|
||||
{
|
||||
name: '',
|
||||
@@ -212,7 +297,7 @@ export class IValidatorContract extends BaseContract {
|
||||
},
|
||||
],
|
||||
payable: false,
|
||||
stateMutability: 'view',
|
||||
stateMutability: 'pure',
|
||||
type: 'function',
|
||||
},
|
||||
] as ContractAbi;
|
||||
@@ -224,7 +309,14 @@ export class IValidatorContract extends BaseContract {
|
||||
txDefaults?: Partial<TxData>,
|
||||
logDecodeDependencies?: { [contractName: string]: ContractAbi },
|
||||
) {
|
||||
super('IValidator', IValidatorContract.ABI(), address, supportedProvider, txDefaults, logDecodeDependencies);
|
||||
super(
|
||||
'StaticCallProxy',
|
||||
StaticCallProxyContract.ABI(),
|
||||
address,
|
||||
supportedProvider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,13 @@
|
||||
[
|
||||
{
|
||||
"version": "11.1.1",
|
||||
"changes": [
|
||||
{
|
||||
"note": "Import wrappers from @0x/abi-gen-wrappers instead of directly implementing within this package.",
|
||||
"pr": 2086
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"version": "11.1.0",
|
||||
"changes": [
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"test": "test"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "yarn pre_build && tsc -b",
|
||||
"build": "tsc -b",
|
||||
"build:ci": "yarn build",
|
||||
"lint": "tslint --format stylish --project . --exclude **/lib/**/*",
|
||||
"fix": "tslint --fix --format stylish --project .--exclude **/lib/**/*",
|
||||
@@ -26,11 +26,8 @@
|
||||
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
|
||||
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
|
||||
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
|
||||
"pre_build": "yarn generate_contract_wrappers && yarn prettier_contract_wrappers",
|
||||
"prettier": "prettier --write **/* --config ../../.prettierrc",
|
||||
"prettier_contract_wrappers": "prettier --write src/generated-wrappers/* --config ../../.prettierrc",
|
||||
"clean": "shx rm -rf lib src/generated-wrappers",
|
||||
"generate_contract_wrappers": "abi-gen --abis ${npm_package_config_abis} --output src/generated-wrappers --backend ethers",
|
||||
"clean": "shx rm -rf lib",
|
||||
"docs_test": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --out generated_docs ./src/generated-wrappers/*",
|
||||
"s3:sync_md_docs": "aws s3 sync ./docs s3://docs-markdown/${npm_package_name}/v${npm_package_version} --profile 0xproject --region us-east-1 --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers",
|
||||
"docs:md": "ts-doc-gen --sourceDir=./src --output=./docs --fileExtension=mdx --tsconfig=./typedoc-tsconfig.json"
|
||||
@@ -48,7 +45,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-wrappers/README.md",
|
||||
"devDependencies": {
|
||||
"@0x/abi-gen": "^4.1.1",
|
||||
"@0x/assert": "^2.1.4",
|
||||
"@0x/ts-doc-gen": "^0.0.16",
|
||||
"@0x/contracts-test-utils": "^3.1.14",
|
||||
@@ -74,6 +70,7 @@
|
||||
"typescript": "3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@0x/abi-gen-wrappers": "^5.2.0",
|
||||
"@0x/base-contract": "^5.3.2",
|
||||
"@0x/contract-addresses": "^3.1.0",
|
||||
"@0x/contract-artifacts": "^2.2.0",
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
import {
|
||||
DutchAuctionContract,
|
||||
ERC20ProxyContract,
|
||||
ERC721ProxyContract,
|
||||
ExchangeContract,
|
||||
ForwarderContract,
|
||||
OrderValidatorContract,
|
||||
WETH9Contract,
|
||||
} from '@0x/abi-gen-wrappers';
|
||||
import { ContractAddresses } from '@0x/contract-addresses';
|
||||
import {
|
||||
Coordinator,
|
||||
@@ -17,13 +26,6 @@ import { SupportedProvider } from 'ethereum-types';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { CoordinatorWrapper } from './coordinator_wrapper';
|
||||
import { DutchAuctionContract } from './generated-wrappers/dutch_auction';
|
||||
import { ERC20ProxyContract } from './generated-wrappers/erc20_proxy';
|
||||
import { ERC721ProxyContract } from './generated-wrappers/erc721_proxy';
|
||||
import { ExchangeContract } from './generated-wrappers/exchange';
|
||||
import { ForwarderContract } from './generated-wrappers/forwarder';
|
||||
import { OrderValidatorContract } from './generated-wrappers/order_validator';
|
||||
import { WETH9Contract } from './generated-wrappers/weth9';
|
||||
import { ContractWrappersConfigSchema } from './schemas/contract_wrappers_config_schema';
|
||||
import { ContractWrappersConfig } from './types';
|
||||
import { assert } from './utils/assert';
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ContractAbi } from 'ethereum-types';
|
||||
import * as HttpStatus from 'http-status-codes';
|
||||
import { flatten } from 'lodash';
|
||||
|
||||
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from './index';
|
||||
import { CoordinatorContract, CoordinatorRegistryContract, ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||
|
||||
import { orderTxOptsSchema } from './schemas/order_tx_opts_schema';
|
||||
import { txOptsSchema } from './schemas/tx_opts_schema';
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,519 +0,0 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
|
||||
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
|
||||
// tslint:disable:no-unused-variable
|
||||
import {
|
||||
BaseContract,
|
||||
BlockRange,
|
||||
EventCallback,
|
||||
IndexedFilterValues,
|
||||
SubscriptionManager,
|
||||
PromiseWithTransactionHash,
|
||||
} from '@0x/base-contract';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
LogWithDecodedArgs,
|
||||
MethodAbi,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
import { assert } from '@0x/assert';
|
||||
import * as ethers from 'ethers';
|
||||
// tslint:enable:no-unused-variable
|
||||
|
||||
export type CoordinatorRegistryEventArgs = CoordinatorRegistryCoordinatorEndpointSetEventArgs;
|
||||
|
||||
export enum CoordinatorRegistryEvents {
|
||||
CoordinatorEndpointSet = 'CoordinatorEndpointSet',
|
||||
}
|
||||
|
||||
export interface CoordinatorRegistryCoordinatorEndpointSetEventArgs extends DecodedLogArgs {
|
||||
coordinatorOperator: string;
|
||||
coordinatorEndpoint: string;
|
||||
}
|
||||
|
||||
/* istanbul ignore next */
|
||||
// tslint:disable:no-parameter-reassignment
|
||||
// tslint:disable-next-line:class-name
|
||||
export class CoordinatorRegistryContract extends BaseContract {
|
||||
/**
|
||||
* Called by a Coordinator operator to set the endpoint of their Coordinator.
|
||||
*/
|
||||
public setCoordinatorEndpoint = {
|
||||
/**
|
||||
* Sends an Ethereum transaction executing this method with the supplied parameters. This is a read/write
|
||||
* Ethereum operation and will cost gas.
|
||||
* @param coordinatorEndpoint endpoint of the Coordinator.
|
||||
* @param txData Additional data for transaction
|
||||
* @returns The hash of the transaction
|
||||
*/
|
||||
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),
|
||||
);
|
||||
if (txDataWithDefaults.from !== undefined) {
|
||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||
}
|
||||
|
||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
return txHash;
|
||||
},
|
||||
/**
|
||||
* Sends an Ethereum transaction and waits until the transaction has been successfully mined without reverting.
|
||||
* If the transaction was mined, but reverted, an error is thrown.
|
||||
* @param coordinatorEndpoint endpoint of the Coordinator.
|
||||
* @param txData Additional data for transaction
|
||||
* @param pollingIntervalMs Interval at which to poll for success
|
||||
* @returns A promise that resolves when the transaction is successful
|
||||
*/
|
||||
awaitTransactionSuccessAsync(
|
||||
coordinatorEndpoint: string,
|
||||
txData?: Partial<TxData>,
|
||||
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,
|
||||
);
|
||||
})(),
|
||||
);
|
||||
},
|
||||
/**
|
||||
* Estimates the gas cost of sending an Ethereum transaction calling this method with these arguments.
|
||||
* @param coordinatorEndpoint endpoint of the Coordinator.
|
||||
* @param txData Additional data for transaction
|
||||
* @returns The hash of the transaction
|
||||
*/
|
||||
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(),
|
||||
);
|
||||
if (txDataWithDefaults.from !== undefined) {
|
||||
txDataWithDefaults.from = txDataWithDefaults.from.toLowerCase();
|
||||
}
|
||||
|
||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
||||
return gas;
|
||||
},
|
||||
/**
|
||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||
* since they don't modify state.
|
||||
* @param coordinatorEndpoint endpoint of the Coordinator.
|
||||
*/
|
||||
async callAsync(
|
||||
coordinatorEndpoint: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<void> {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [coordinatorEndpoint]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
callDataWithDefaults.from = callDataWithDefaults.from
|
||||
? callDataWithDefaults.from.toLowerCase()
|
||||
: callDataWithDefaults.from;
|
||||
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<void>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||
* to create a 0x transaction (see protocol spec for more details).
|
||||
* @param coordinatorEndpoint endpoint of the Coordinator.
|
||||
*/
|
||||
getABIEncodedTransactionData(coordinatorEndpoint: string): string {
|
||||
assert.isString('coordinatorEndpoint', coordinatorEndpoint);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('setCoordinatorEndpoint(string)', [
|
||||
coordinatorEndpoint,
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
getABIDecodedTransactionData(callData: string): void {
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<void>(callData);
|
||||
return abiDecodedCallData;
|
||||
},
|
||||
getABIDecodedReturnData(returnData: string): void {
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('setCoordinatorEndpoint(string)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<void>(returnData);
|
||||
return abiDecodedReturnData;
|
||||
},
|
||||
async validateAndSendTransactionAsync(
|
||||
coordinatorEndpoint: string,
|
||||
txData?: Partial<TxData> | undefined,
|
||||
): Promise<string> {
|
||||
await (this as any).setCoordinatorEndpoint.callAsync(coordinatorEndpoint, txData);
|
||||
const txHash = await (this as any).setCoordinatorEndpoint.sendTransactionAsync(coordinatorEndpoint, txData);
|
||||
return txHash;
|
||||
},
|
||||
};
|
||||
/**
|
||||
* Gets the endpoint for a Coordinator.
|
||||
*/
|
||||
public getCoordinatorEndpoint = {
|
||||
/**
|
||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||
* since they don't modify state.
|
||||
* @param coordinatorOperator operator of the Coordinator endpoint.
|
||||
*/
|
||||
async callAsync(
|
||||
coordinatorOperator: string,
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<string> {
|
||||
assert.isString('coordinatorOperator', coordinatorOperator);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const encodedData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [
|
||||
coordinatorOperator.toLowerCase(),
|
||||
]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
callDataWithDefaults.from = callDataWithDefaults.from
|
||||
? callDataWithDefaults.from.toLowerCase()
|
||||
: callDataWithDefaults.from;
|
||||
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<string>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||
* to create a 0x transaction (see protocol spec for more details).
|
||||
* @param coordinatorOperator operator of the Coordinator endpoint.
|
||||
*/
|
||||
getABIEncodedTransactionData(coordinatorOperator: string): string {
|
||||
assert.isString('coordinatorOperator', coordinatorOperator);
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getCoordinatorEndpoint(address)', [
|
||||
coordinatorOperator.toLowerCase(),
|
||||
]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
getABIDecodedTransactionData(callData: string): string {
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<string>(callData);
|
||||
return abiDecodedCallData;
|
||||
},
|
||||
getABIDecodedReturnData(returnData: string): string {
|
||||
const self = (this as any) as CoordinatorRegistryContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getCoordinatorEndpoint(address)');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<string>(returnData);
|
||||
return abiDecodedReturnData;
|
||||
},
|
||||
};
|
||||
private readonly _subscriptionManager: SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>;
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
|
||||
): Promise<CoordinatorRegistryContract> {
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
|
||||
if (Object.keys(logDecodeDependencies) !== undefined) {
|
||||
for (const key of Object.keys(logDecodeDependencies)) {
|
||||
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
|
||||
}
|
||||
}
|
||||
return CoordinatorRegistryContract.deployAsync(
|
||||
bytecode,
|
||||
abi,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependenciesAbiOnly,
|
||||
);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractAbi },
|
||||
): Promise<CoordinatorRegistryContract> {
|
||||
assert.isHexString('bytecode', bytecode);
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = 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 },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`CoordinatorRegistry successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new CoordinatorRegistryContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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',
|
||||
indexed: false,
|
||||
},
|
||||
{
|
||||
name: 'coordinatorEndpoint',
|
||||
type: 'string',
|
||||
indexed: false,
|
||||
},
|
||||
],
|
||||
name: 'CoordinatorEndpointSet',
|
||||
outputs: [],
|
||||
type: 'event',
|
||||
},
|
||||
] as ContractAbi;
|
||||
return abi;
|
||||
}
|
||||
/**
|
||||
* Subscribe to an event type emitted by the CoordinatorRegistry contract.
|
||||
* @param eventName The CoordinatorRegistry contract event you would like to subscribe to.
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{maker: aUserAddressHex}`
|
||||
* @param callback Callback that gets called when a log is added/removed
|
||||
* @param isVerbose Enable verbose subscription warnings (e.g recoverable network issues encountered)
|
||||
* @return Subscription token used later to unsubscribe
|
||||
*/
|
||||
public subscribe<ArgsType extends CoordinatorRegistryEventArgs>(
|
||||
eventName: CoordinatorRegistryEvents,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
callback: EventCallback<ArgsType>,
|
||||
isVerbose: boolean = false,
|
||||
blockPollingIntervalMs?: number,
|
||||
): string {
|
||||
assert.doesBelongToStringEnum('eventName', eventName, CoordinatorRegistryEvents);
|
||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||
assert.isFunction('callback', callback);
|
||||
const subscriptionToken = this._subscriptionManager.subscribe<ArgsType>(
|
||||
this.address,
|
||||
eventName,
|
||||
indexFilterValues,
|
||||
CoordinatorRegistryContract.ABI(),
|
||||
callback,
|
||||
isVerbose,
|
||||
blockPollingIntervalMs,
|
||||
);
|
||||
return subscriptionToken;
|
||||
}
|
||||
/**
|
||||
* Cancel a subscription
|
||||
* @param subscriptionToken Subscription token returned by `subscribe()`
|
||||
*/
|
||||
public unsubscribe(subscriptionToken: string): void {
|
||||
this._subscriptionManager.unsubscribe(subscriptionToken);
|
||||
}
|
||||
/**
|
||||
* Cancels all existing subscriptions
|
||||
*/
|
||||
public unsubscribeAll(): void {
|
||||
this._subscriptionManager.unsubscribeAll();
|
||||
}
|
||||
/**
|
||||
* Gets historical logs without creating a subscription
|
||||
* @param eventName The CoordinatorRegistry contract event you would like to subscribe to.
|
||||
* @param blockRange Block range to get logs from.
|
||||
* @param indexFilterValues An object where the keys are indexed args returned by the event and
|
||||
* the value is the value you are interested in. E.g `{_from: aUserAddressHex}`
|
||||
* @return Array of logs that match the parameters
|
||||
*/
|
||||
public async getLogsAsync<ArgsType extends CoordinatorRegistryEventArgs>(
|
||||
eventName: CoordinatorRegistryEvents,
|
||||
blockRange: BlockRange,
|
||||
indexFilterValues: IndexedFilterValues,
|
||||
): Promise<Array<LogWithDecodedArgs<ArgsType>>> {
|
||||
assert.doesBelongToStringEnum('eventName', eventName, CoordinatorRegistryEvents);
|
||||
assert.doesConformToSchema('blockRange', blockRange, schemas.blockRangeSchema);
|
||||
assert.doesConformToSchema('indexFilterValues', indexFilterValues, schemas.indexFilterValuesSchema);
|
||||
const logs = await this._subscriptionManager.getLogsAsync<ArgsType>(
|
||||
this.address,
|
||||
eventName,
|
||||
blockRange,
|
||||
indexFilterValues,
|
||||
CoordinatorRegistryContract.ABI(),
|
||||
);
|
||||
return logs;
|
||||
}
|
||||
constructor(
|
||||
address: string,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
logDecodeDependencies?: { [contractName: string]: ContractAbi },
|
||||
) {
|
||||
super(
|
||||
'CoordinatorRegistry',
|
||||
CoordinatorRegistryContract.ABI(),
|
||||
address,
|
||||
supportedProvider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
classUtils.bindAll(this, ['_abiEncoderByFunctionSignature', 'address', '_web3Wrapper']);
|
||||
this._subscriptionManager = new SubscriptionManager<CoordinatorRegistryEventArgs, CoordinatorRegistryEvents>(
|
||||
CoordinatorRegistryContract.ABI(),
|
||||
this._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
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
@@ -1,215 +0,0 @@
|
||||
// tslint:disable:no-consecutive-blank-lines ordered-imports align trailing-comma
|
||||
// tslint:disable:whitespace no-unbound-method no-trailing-whitespace
|
||||
// tslint:disable:no-unused-variable
|
||||
import { BaseContract, PromiseWithTransactionHash } from '@0x/base-contract';
|
||||
import { schemas } from '@0x/json-schemas';
|
||||
import {
|
||||
BlockParam,
|
||||
BlockParamLiteral,
|
||||
CallData,
|
||||
ContractAbi,
|
||||
ContractArtifact,
|
||||
DecodedLogArgs,
|
||||
MethodAbi,
|
||||
TransactionReceiptWithDecodedLogs,
|
||||
TxData,
|
||||
TxDataPayable,
|
||||
SupportedProvider,
|
||||
} from 'ethereum-types';
|
||||
import { BigNumber, classUtils, logUtils, providerUtils } from '@0x/utils';
|
||||
import { SimpleContractArtifact } from '@0x/types';
|
||||
import { Web3Wrapper } from '@0x/web3-wrapper';
|
||||
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
|
||||
export class EthBalanceCheckerContract extends BaseContract {
|
||||
/**
|
||||
* Batch fetches ETH balances
|
||||
*/
|
||||
public getEthBalances = {
|
||||
/**
|
||||
* Sends a read-only call to the contract method. Returns the result that would happen if one were to send an
|
||||
* Ethereum transaction to this method, given the current state of the blockchain. Calls do not cost gas
|
||||
* since they don't modify state.
|
||||
* @param addresses Array of addresses.
|
||||
* @returns Array of ETH balances.
|
||||
*/
|
||||
async callAsync(
|
||||
addresses: string[],
|
||||
callData: Partial<CallData> = {},
|
||||
defaultBlock?: BlockParam,
|
||||
): Promise<BigNumber[]> {
|
||||
assert.isArray('addresses', addresses);
|
||||
assert.doesConformToSchema('callData', callData, schemas.callDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (defaultBlock !== undefined) {
|
||||
assert.isBlockParam('defaultBlock', defaultBlock);
|
||||
}
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const encodedData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]);
|
||||
const callDataWithDefaults = await BaseContract._applyDefaultsToTxDataAsync(
|
||||
{
|
||||
to: self.address,
|
||||
...callData,
|
||||
data: encodedData,
|
||||
},
|
||||
self._web3Wrapper.getContractDefaults(),
|
||||
);
|
||||
callDataWithDefaults.from = callDataWithDefaults.from
|
||||
? callDataWithDefaults.from.toLowerCase()
|
||||
: callDataWithDefaults.from;
|
||||
|
||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
||||
BaseContract._throwIfRevertWithReasonCallResult(rawCallResult);
|
||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
||||
// tslint:disable boolean-naming
|
||||
const result = abiEncoder.strictDecodeReturnValue<BigNumber[]>(rawCallResult);
|
||||
// tslint:enable boolean-naming
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Returns the ABI encoded transaction data needed to send an Ethereum transaction calling this method. Before
|
||||
* sending the Ethereum tx, this encoded tx data can first be sent to a separate signing service or can be used
|
||||
* to create a 0x transaction (see protocol spec for more details).
|
||||
* @param addresses Array of addresses.
|
||||
*/
|
||||
getABIEncodedTransactionData(addresses: string[]): string {
|
||||
assert.isArray('addresses', addresses);
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const abiEncodedTransactionData = self._strictEncodeArguments('getEthBalances(address[])', [addresses]);
|
||||
return abiEncodedTransactionData;
|
||||
},
|
||||
getABIDecodedTransactionData(callData: string): BigNumber[] {
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedCallData = abiEncoder.strictDecode<BigNumber[]>(callData);
|
||||
return abiDecodedCallData;
|
||||
},
|
||||
getABIDecodedReturnData(returnData: string): BigNumber[] {
|
||||
const self = (this as any) as EthBalanceCheckerContract;
|
||||
const abiEncoder = self._lookupAbiEncoder('getEthBalances(address[])');
|
||||
// tslint:disable boolean-naming
|
||||
const abiDecodedReturnData = abiEncoder.strictDecodeReturnValue<BigNumber[]>(returnData);
|
||||
return abiDecodedReturnData;
|
||||
},
|
||||
};
|
||||
public static async deployFrom0xArtifactAsync(
|
||||
artifact: ContractArtifact | SimpleContractArtifact,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractArtifact | SimpleContractArtifact },
|
||||
): Promise<EthBalanceCheckerContract> {
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
if (artifact.compilerOutput === undefined) {
|
||||
throw new Error('Compiler output not found in the artifact file');
|
||||
}
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const bytecode = artifact.compilerOutput.evm.bytecode.object;
|
||||
const abi = artifact.compilerOutput.abi;
|
||||
const logDecodeDependenciesAbiOnly: { [contractName: string]: ContractAbi } = {};
|
||||
if (Object.keys(logDecodeDependencies) !== undefined) {
|
||||
for (const key of Object.keys(logDecodeDependencies)) {
|
||||
logDecodeDependenciesAbiOnly[key] = logDecodeDependencies[key].compilerOutput.abi;
|
||||
}
|
||||
}
|
||||
return EthBalanceCheckerContract.deployAsync(bytecode, abi, provider, txDefaults, logDecodeDependenciesAbiOnly);
|
||||
}
|
||||
public static async deployAsync(
|
||||
bytecode: string,
|
||||
abi: ContractAbi,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults: Partial<TxData>,
|
||||
logDecodeDependencies: { [contractName: string]: ContractAbi },
|
||||
): Promise<EthBalanceCheckerContract> {
|
||||
assert.isHexString('bytecode', bytecode);
|
||||
assert.doesConformToSchema('txDefaults', txDefaults, schemas.txDataSchema, [
|
||||
schemas.addressSchema,
|
||||
schemas.numberSchema,
|
||||
schemas.jsNumber,
|
||||
]);
|
||||
const provider = providerUtils.standardizeOrThrow(supportedProvider);
|
||||
const constructorAbi = BaseContract._lookupConstructorAbi(abi);
|
||||
[] = 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 },
|
||||
txDefaults,
|
||||
web3Wrapper.estimateGasAsync.bind(web3Wrapper),
|
||||
);
|
||||
const txHash = await web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
||||
logUtils.log(`transactionHash: ${txHash}`);
|
||||
const txReceipt = await web3Wrapper.awaitTransactionSuccessAsync(txHash);
|
||||
logUtils.log(`EthBalanceChecker successfully deployed at ${txReceipt.contractAddress}`);
|
||||
const contractInstance = new EthBalanceCheckerContract(
|
||||
txReceipt.contractAddress as string,
|
||||
provider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
contractInstance.constructorArgs = [];
|
||||
return contractInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
constructor(
|
||||
address: string,
|
||||
supportedProvider: SupportedProvider,
|
||||
txDefaults?: Partial<TxData>,
|
||||
logDecodeDependencies?: { [contractName: string]: ContractAbi },
|
||||
) {
|
||||
super(
|
||||
'EthBalanceChecker',
|
||||
EthBalanceCheckerContract.ABI(),
|
||||
address,
|
||||
supportedProvider,
|
||||
txDefaults,
|
||||
logDecodeDependencies,
|
||||
);
|
||||
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
1728
packages/contract-wrappers/src/generated-wrappers/weth9.ts
generated
1728
packages/contract-wrappers/src/generated-wrappers/weth9.ts
generated
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,4 @@
|
||||
export * from './generated-wrappers/asset_proxy_owner';
|
||||
export * from './generated-wrappers/dev_utils';
|
||||
export * from './generated-wrappers/dummy_erc20_token';
|
||||
export * from './generated-wrappers/dummy_erc721_token';
|
||||
export * from './generated-wrappers/dutch_auction';
|
||||
export * from './generated-wrappers/erc20_proxy';
|
||||
export * from './generated-wrappers/erc20_token';
|
||||
export * from './generated-wrappers/erc721_proxy';
|
||||
export * from './generated-wrappers/erc721_token';
|
||||
export * from './generated-wrappers/exchange';
|
||||
export * from './generated-wrappers/forwarder';
|
||||
export * from './generated-wrappers/i_asset_proxy';
|
||||
export * from './generated-wrappers/i_validator';
|
||||
export * from './generated-wrappers/i_wallet';
|
||||
export * from './generated-wrappers/multi_asset_proxy';
|
||||
export * from './generated-wrappers/order_validator';
|
||||
export * from './generated-wrappers/weth9';
|
||||
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/abi-gen-wrappers';
|
||||
|
||||
export * from '@0x/contract-addresses';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ExchangeContract } from '../index';
|
||||
import { ExchangeContract } from '@0x/abi-gen-wrappers';
|
||||
|
||||
/**
|
||||
* Returns the ABI encoded transaction hash for a given method and arguments
|
||||
|
||||
@@ -649,6 +649,13 @@
|
||||
dependencies:
|
||||
"@0x/base-contract" "^4.0.3"
|
||||
|
||||
"@0x/abi-gen-wrappers@^5.3.0":
|
||||
version "5.2.0"
|
||||
dependencies:
|
||||
"@0x/base-contract" "^5.3.1"
|
||||
"@0x/contract-addresses" "^3.0.3"
|
||||
"@0x/contract-artifacts" "^2.0.4"
|
||||
|
||||
"@0x/asset-buyer@6.1.8":
|
||||
version "6.1.8"
|
||||
resolved "https://registry.yarnpkg.com/@0x/asset-buyer/-/asset-buyer-6.1.8.tgz#71f6abb366e89e62457c256644edb37e12113e94"
|
||||
|
||||
Reference in New Issue
Block a user