Remove generated contract wrappers
This commit is contained in:
parent
37c8e21f25
commit
33ed5cd437
@ -1,84 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
|
||||||
* Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
|
|
||||||
*/
|
|
||||||
// tslint:disable:no-consecutive-blank-lines
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { BaseContract } from '@0xproject/base-contract';
|
|
||||||
import {
|
|
||||||
BlockParam,
|
|
||||||
BlockParamLiteral,
|
|
||||||
CallData,
|
|
||||||
ContractAbi,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
Provider,
|
|
||||||
TxData,
|
|
||||||
TxDataPayable,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as ethers from 'ethers';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
// tslint:disable:no-parameter-reassignment
|
|
||||||
export class DummyTokenContract extends BaseContract {
|
|
||||||
public setBalance = {
|
|
||||||
async sendTransactionAsync(_target: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as DummyTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs;
|
|
||||||
[_target, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_target, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setBalance(address,uint256)')
|
|
||||||
.functions.setBalance(_target, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.setBalance.estimateGasAsync.bind(self, _target, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_target: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as DummyTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs;
|
|
||||||
[_target, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_target, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setBalance(address,uint256)')
|
|
||||||
.functions.setBalance(_target, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_target: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as DummyTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('setBalance(address,uint256)').inputs;
|
|
||||||
[_target, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_target, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('setBalance(address,uint256)')
|
|
||||||
.functions.setBalance(_target, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
|
||||||
super(abi, address, provider, defaults);
|
|
||||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
|
@ -1,621 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
|
||||||
* Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
|
|
||||||
*/
|
|
||||||
// tslint:disable:no-consecutive-blank-lines
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { BaseContract } from '@0xproject/base-contract';
|
|
||||||
import {
|
|
||||||
BlockParam,
|
|
||||||
BlockParamLiteral,
|
|
||||||
CallData,
|
|
||||||
ContractAbi,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
Provider,
|
|
||||||
TxData,
|
|
||||||
TxDataPayable,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as ethers from 'ethers';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export type EtherTokenContractEventArgs =
|
|
||||||
| TransferContractEventArgs
|
|
||||||
| ApprovalContractEventArgs
|
|
||||||
| DepositContractEventArgs
|
|
||||||
| WithdrawalContractEventArgs;
|
|
||||||
|
|
||||||
export enum EtherTokenEvents {
|
|
||||||
Transfer = 'Transfer',
|
|
||||||
Approval = 'Approval',
|
|
||||||
Deposit = 'Deposit',
|
|
||||||
Withdrawal = 'Withdrawal',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransferContractEventArgs {
|
|
||||||
_from: string;
|
|
||||||
_to: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApprovalContractEventArgs {
|
|
||||||
_owner: string;
|
|
||||||
_spender: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DepositContractEventArgs {
|
|
||||||
_owner: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WithdrawalContractEventArgs {
|
|
||||||
_owner: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:no-parameter-reassignment
|
|
||||||
export class EtherTokenContract extends BaseContract {
|
|
||||||
public name = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'name()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.name() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'name' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public approve = {
|
|
||||||
async sendTransactionAsync(_spender: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.approve.estimateGasAsync.bind(self, _spender, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_spender: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_spender: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_spender: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'approve(address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.approve(_spender, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'approve' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public totalSupply = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'totalSupply()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.totalSupply() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'totalSupply' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transferFrom = {
|
|
||||||
async sendTransactionAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transferFrom.estimateGasAsync.bind(self, _from, _to, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'transferFrom(address,address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.transferFrom(_from, _to, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'transferFrom' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public withdraw = {
|
|
||||||
async sendTransactionAsync(amount: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
|
||||||
[amount] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[amount],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw(amount).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.withdraw.estimateGasAsync.bind(self, amount),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(amount: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
|
||||||
[amount] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[amount],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('withdraw(uint256)').functions.withdraw(amount).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(amount: BigNumber): string {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('withdraw(uint256)').inputs;
|
|
||||||
[amount] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[amount],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('withdraw(uint256)')
|
|
||||||
.functions.withdraw(amount).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public decimals = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'decimals()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.decimals() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'decimals' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public balanceOf = {
|
|
||||||
async callAsync(
|
|
||||||
_owner: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'balanceOf(address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_owner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_owner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.balanceOf(_owner) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'balanceOf' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public symbol = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'symbol()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.symbol() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'symbol' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transfer = {
|
|
||||||
async sendTransactionAsync(_to: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value)
|
|
||||||
.data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transfer.estimateGasAsync.bind(self, _to, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_to: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value)
|
|
||||||
.data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_to: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transfer(address,uint256)')
|
|
||||||
.functions.transfer(_to, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'transfer(address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.transfer(_to, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'transfer' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public deposit = {
|
|
||||||
async sendTransactionAsync(txData: Partial<TxDataPayable> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('deposit()').inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const encodedData = self._lookupEthersInterface('deposit()').functions.deposit().data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.deposit.estimateGasAsync.bind(self),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('deposit()').inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(this));
|
|
||||||
const encodedData = self._lookupEthersInterface('deposit()').functions.deposit().data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(): string {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('deposit()').inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const abiEncodedTransactionData = self._lookupEthersInterface('deposit()').functions.deposit().data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public allowance = {
|
|
||||||
async callAsync(
|
|
||||||
_owner: string,
|
|
||||||
_spender: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as EtherTokenContract;
|
|
||||||
const functionSignature = 'allowance(address,address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_owner, _spender] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_owner, _spender],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.allowance(_owner, _spender) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'allowance' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
|
||||||
super(abi, address, provider, defaults);
|
|
||||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
|
File diff suppressed because it is too large
Load Diff
@ -1,432 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
|
||||||
* Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
|
|
||||||
*/
|
|
||||||
// tslint:disable:no-consecutive-blank-lines
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { BaseContract } from '@0xproject/base-contract';
|
|
||||||
import {
|
|
||||||
BlockParam,
|
|
||||||
BlockParamLiteral,
|
|
||||||
CallData,
|
|
||||||
ContractAbi,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
Provider,
|
|
||||||
TxData,
|
|
||||||
TxDataPayable,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as ethers from 'ethers';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export type TokenContractEventArgs = TransferContractEventArgs | ApprovalContractEventArgs;
|
|
||||||
|
|
||||||
export enum TokenEvents {
|
|
||||||
Transfer = 'Transfer',
|
|
||||||
Approval = 'Approval',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransferContractEventArgs {
|
|
||||||
_from: string;
|
|
||||||
_to: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ApprovalContractEventArgs {
|
|
||||||
_owner: string;
|
|
||||||
_spender: string;
|
|
||||||
_value: BigNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:no-parameter-reassignment
|
|
||||||
export class TokenContract extends BaseContract {
|
|
||||||
public approve = {
|
|
||||||
async sendTransactionAsync(_spender: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.approve.estimateGasAsync.bind(self, _spender, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_spender: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_spender: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('approve(address,uint256)').inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('approve(address,uint256)')
|
|
||||||
.functions.approve(_spender, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_spender: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'approve(address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_spender, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_spender, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.approve(_spender, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'approve' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public totalSupply = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'totalSupply()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.totalSupply() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'totalSupply' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transferFrom = {
|
|
||||||
async sendTransactionAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transferFrom.estimateGasAsync.bind(self, _from, _to, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<number> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_from: string, _to: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,uint256)').inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,uint256)')
|
|
||||||
.functions.transferFrom(_from, _to, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_from: string,
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'transferFrom(address,address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_from, _to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_from, _to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.transferFrom(_from, _to, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'transferFrom' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public balanceOf = {
|
|
||||||
async callAsync(
|
|
||||||
_owner: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'balanceOf(address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_owner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_owner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.balanceOf(_owner) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'balanceOf' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transfer = {
|
|
||||||
async sendTransactionAsync(_to: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value)
|
|
||||||
.data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transfer.estimateGasAsync.bind(self, _to, _value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_to: string, _value: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self._lookupEthersInterface('transfer(address,uint256)').functions.transfer(_to, _value)
|
|
||||||
.data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_to: string, _value: BigNumber): string {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const inputAbi = self._lookupAbi('transfer(address,uint256)').inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transfer(address,uint256)')
|
|
||||||
.functions.transfer(_to, _value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
_to: string,
|
|
||||||
_value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'transfer(address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_to, _value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_to, _value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.transfer(_to, _value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'transfer' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public allowance = {
|
|
||||||
async callAsync(
|
|
||||||
_owner: string,
|
|
||||||
_spender: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<BigNumber> {
|
|
||||||
const self = (this as any) as TokenContract;
|
|
||||||
const functionSignature = 'allowance(address,address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_owner, _spender] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_owner, _spender],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.allowance(_owner, _spender) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'allowance' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
|
||||||
super(abi, address, provider, defaults);
|
|
||||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
|
@ -1,799 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
|
||||||
* Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
|
|
||||||
*/
|
|
||||||
// tslint:disable:no-consecutive-blank-lines
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { BaseContract } from '@0xproject/base-contract';
|
|
||||||
import {
|
|
||||||
BlockParam,
|
|
||||||
BlockParamLiteral,
|
|
||||||
CallData,
|
|
||||||
ContractAbi,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
Provider,
|
|
||||||
TxData,
|
|
||||||
TxDataPayable,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as ethers from 'ethers';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export type TokenRegistryContractEventArgs =
|
|
||||||
| LogAddTokenContractEventArgs
|
|
||||||
| LogRemoveTokenContractEventArgs
|
|
||||||
| LogTokenNameChangeContractEventArgs
|
|
||||||
| LogTokenSymbolChangeContractEventArgs
|
|
||||||
| LogTokenIpfsHashChangeContractEventArgs
|
|
||||||
| LogTokenSwarmHashChangeContractEventArgs;
|
|
||||||
|
|
||||||
export enum TokenRegistryEvents {
|
|
||||||
LogAddToken = 'LogAddToken',
|
|
||||||
LogRemoveToken = 'LogRemoveToken',
|
|
||||||
LogTokenNameChange = 'LogTokenNameChange',
|
|
||||||
LogTokenSymbolChange = 'LogTokenSymbolChange',
|
|
||||||
LogTokenIpfsHashChange = 'LogTokenIpfsHashChange',
|
|
||||||
LogTokenSwarmHashChange = 'LogTokenSwarmHashChange',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogAddTokenContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
name: string;
|
|
||||||
symbol: string;
|
|
||||||
decimals: number;
|
|
||||||
ipfsHash: string;
|
|
||||||
swarmHash: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogRemoveTokenContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
name: string;
|
|
||||||
symbol: string;
|
|
||||||
decimals: number;
|
|
||||||
ipfsHash: string;
|
|
||||||
swarmHash: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogTokenNameChangeContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
oldName: string;
|
|
||||||
newName: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogTokenSymbolChangeContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
oldSymbol: string;
|
|
||||||
newSymbol: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogTokenIpfsHashChangeContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
oldIpfsHash: string;
|
|
||||||
newIpfsHash: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogTokenSwarmHashChangeContractEventArgs {
|
|
||||||
token: string;
|
|
||||||
oldSwarmHash: string;
|
|
||||||
newSwarmHash: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:no-parameter-reassignment
|
|
||||||
export class TokenRegistryContract extends BaseContract {
|
|
||||||
public removeToken = {
|
|
||||||
async sendTransactionAsync(_token: string, _index: BigNumber, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs;
|
|
||||||
[_token, _index] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _index],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('removeToken(address,uint256)')
|
|
||||||
.functions.removeToken(_token, _index).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.removeToken.estimateGasAsync.bind(self, _token, _index),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_token: string, _index: BigNumber, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs;
|
|
||||||
[_token, _index] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _index],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('removeToken(address,uint256)')
|
|
||||||
.functions.removeToken(_token, _index).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_token: string, _index: BigNumber): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeToken(address,uint256)').inputs;
|
|
||||||
[_token, _index] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _index],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('removeToken(address,uint256)')
|
|
||||||
.functions.removeToken(_token, _index).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenAddressByName = {
|
|
||||||
async callAsync(_name: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenAddressByName(string)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_name] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_name],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenAddressByName(_name) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenAddressByName' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenAddressBySymbol = {
|
|
||||||
async callAsync(_symbol: string, callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenAddressBySymbol(string)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_symbol] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_symbol],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenAddressBySymbol(_symbol) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenAddressBySymbol' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public setTokenSwarmHash = {
|
|
||||||
async sendTransactionAsync(_token: string, _swarmHash: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs;
|
|
||||||
[_token, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenSwarmHash(address,bytes)')
|
|
||||||
.functions.setTokenSwarmHash(_token, _swarmHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.setTokenSwarmHash.estimateGasAsync.bind(self, _token, _swarmHash),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_token: string, _swarmHash: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs;
|
|
||||||
[_token, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenSwarmHash(address,bytes)')
|
|
||||||
.functions.setTokenSwarmHash(_token, _swarmHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_token: string, _swarmHash: string): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSwarmHash(address,bytes)').inputs;
|
|
||||||
[_token, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('setTokenSwarmHash(address,bytes)')
|
|
||||||
.functions.setTokenSwarmHash(_token, _swarmHash).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenMetaData = {
|
|
||||||
async callAsync(
|
|
||||||
_token: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<[string, string, string, number, string, string]> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenMetaData(address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_token] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenMetaData(_token) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenMetaData' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public owner = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'owner()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.owner() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'owner' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public addToken = {
|
|
||||||
async sendTransactionAsync(
|
|
||||||
_token: string,
|
|
||||||
_name: string,
|
|
||||||
_symbol: string,
|
|
||||||
_decimals: number | BigNumber,
|
|
||||||
_ipfsHash: string,
|
|
||||||
_swarmHash: string,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs;
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)')
|
|
||||||
.functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.addToken.estimateGasAsync.bind(self, _token, _name, _symbol, _decimals, _ipfsHash, _swarmHash),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(
|
|
||||||
_token: string,
|
|
||||||
_name: string,
|
|
||||||
_symbol: string,
|
|
||||||
_decimals: number | BigNumber,
|
|
||||||
_ipfsHash: string,
|
|
||||||
_swarmHash: string,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs;
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)')
|
|
||||||
.functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(
|
|
||||||
_token: string,
|
|
||||||
_name: string,
|
|
||||||
_symbol: string,
|
|
||||||
_decimals: number | BigNumber,
|
|
||||||
_ipfsHash: string,
|
|
||||||
_swarmHash: string,
|
|
||||||
): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('addToken(address,string,string,uint8,bytes,bytes)').inputs;
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('addToken(address,string,string,uint8,bytes,bytes)')
|
|
||||||
.functions.addToken(_token, _name, _symbol, _decimals, _ipfsHash, _swarmHash).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public setTokenName = {
|
|
||||||
async sendTransactionAsync(_token: string, _name: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs;
|
|
||||||
[_token, _name] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenName(address,string)')
|
|
||||||
.functions.setTokenName(_token, _name).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.setTokenName.estimateGasAsync.bind(self, _token, _name),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_token: string, _name: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs;
|
|
||||||
[_token, _name] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenName(address,string)')
|
|
||||||
.functions.setTokenName(_token, _name).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_token: string, _name: string): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenName(address,string)').inputs;
|
|
||||||
[_token, _name] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _name],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('setTokenName(address,string)')
|
|
||||||
.functions.setTokenName(_token, _name).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public tokens = {
|
|
||||||
async callAsync(
|
|
||||||
index_0: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<[string, string, string, number, string, string]> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'tokens(address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[index_0] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[index_0],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.tokens(index_0) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'tokens' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public tokenAddresses = {
|
|
||||||
async callAsync(
|
|
||||||
index_0: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'tokenAddresses(uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[index_0] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[index_0],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.tokenAddresses(index_0) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'tokenAddresses' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenByName = {
|
|
||||||
async callAsync(
|
|
||||||
_name: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<[string, string, string, number, string, string]> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenByName(string)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_name] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_name],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenByName(_name) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenByName' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenAddresses = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenAddresses()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenAddresses() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenAddresses' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public setTokenIpfsHash = {
|
|
||||||
async sendTransactionAsync(_token: string, _ipfsHash: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs;
|
|
||||||
[_token, _ipfsHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _ipfsHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenIpfsHash(address,bytes)')
|
|
||||||
.functions.setTokenIpfsHash(_token, _ipfsHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.setTokenIpfsHash.estimateGasAsync.bind(self, _token, _ipfsHash),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_token: string, _ipfsHash: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs;
|
|
||||||
[_token, _ipfsHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _ipfsHash],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenIpfsHash(address,bytes)')
|
|
||||||
.functions.setTokenIpfsHash(_token, _ipfsHash).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_token: string, _ipfsHash: string): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenIpfsHash(address,bytes)').inputs;
|
|
||||||
[_token, _ipfsHash] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _ipfsHash],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('setTokenIpfsHash(address,bytes)')
|
|
||||||
.functions.setTokenIpfsHash(_token, _ipfsHash).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getTokenBySymbol = {
|
|
||||||
async callAsync(
|
|
||||||
_symbol: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<[string, string, string, number, string, string]> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const functionSignature = 'getTokenBySymbol(string)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[_symbol] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_symbol],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getTokenBySymbol(_symbol) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getTokenBySymbol' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public setTokenSymbol = {
|
|
||||||
async sendTransactionAsync(_token: string, _symbol: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs;
|
|
||||||
[_token, _symbol] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _symbol],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenSymbol(address,string)')
|
|
||||||
.functions.setTokenSymbol(_token, _symbol).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.setTokenSymbol.estimateGasAsync.bind(self, _token, _symbol),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(_token: string, _symbol: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs;
|
|
||||||
[_token, _symbol] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _symbol],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('setTokenSymbol(address,string)')
|
|
||||||
.functions.setTokenSymbol(_token, _symbol).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(_token: string, _symbol: string): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('setTokenSymbol(address,string)').inputs;
|
|
||||||
[_token, _symbol] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[_token, _symbol],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('setTokenSymbol(address,string)')
|
|
||||||
.functions.setTokenSymbol(_token, _symbol).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transferOwnership = {
|
|
||||||
async sendTransactionAsync(newOwner: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transferOwnership.estimateGasAsync.bind(self, newOwner),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(newOwner: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(newOwner: string): string {
|
|
||||||
const self = (this as any) as TokenRegistryContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
|
||||||
super(abi, address, provider, defaults);
|
|
||||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
|
@ -1,447 +0,0 @@
|
|||||||
/**
|
|
||||||
* This file is auto-generated using abi-gen. Don't edit directly.
|
|
||||||
* Templates can be found at https://github.com/0xProject/0x-monorepo/tree/development/packages/contract_templates.
|
|
||||||
*/
|
|
||||||
// tslint:disable:no-consecutive-blank-lines
|
|
||||||
// tslint:disable-next-line:no-unused-variable
|
|
||||||
import { BaseContract } from '@0xproject/base-contract';
|
|
||||||
import {
|
|
||||||
BlockParam,
|
|
||||||
BlockParamLiteral,
|
|
||||||
CallData,
|
|
||||||
ContractAbi,
|
|
||||||
DataItem,
|
|
||||||
MethodAbi,
|
|
||||||
Provider,
|
|
||||||
TxData,
|
|
||||||
TxDataPayable,
|
|
||||||
} from '@0xproject/types';
|
|
||||||
import { BigNumber, classUtils, promisify } from '@0xproject/utils';
|
|
||||||
import { Web3Wrapper } from '@0xproject/web3-wrapper';
|
|
||||||
import * as ethers from 'ethers';
|
|
||||||
import * as _ from 'lodash';
|
|
||||||
|
|
||||||
export type TokenTransferProxyContractEventArgs =
|
|
||||||
| LogAuthorizedAddressAddedContractEventArgs
|
|
||||||
| LogAuthorizedAddressRemovedContractEventArgs;
|
|
||||||
|
|
||||||
export enum TokenTransferProxyEvents {
|
|
||||||
LogAuthorizedAddressAdded = 'LogAuthorizedAddressAdded',
|
|
||||||
LogAuthorizedAddressRemoved = 'LogAuthorizedAddressRemoved',
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogAuthorizedAddressAddedContractEventArgs {
|
|
||||||
target: string;
|
|
||||||
caller: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogAuthorizedAddressRemovedContractEventArgs {
|
|
||||||
target: string;
|
|
||||||
caller: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// tslint:disable:no-parameter-reassignment
|
|
||||||
export class TokenTransferProxyContract extends BaseContract {
|
|
||||||
public transferFrom = {
|
|
||||||
async sendTransactionAsync(
|
|
||||||
token: string,
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs;
|
|
||||||
[token, from, to, value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[token, from, to, value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,address,uint256)')
|
|
||||||
.functions.transferFrom(token, from, to, value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transferFrom.estimateGasAsync.bind(self, token, from, to, value),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(
|
|
||||||
token: string,
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
value: BigNumber,
|
|
||||||
txData: Partial<TxData> = {},
|
|
||||||
): Promise<number> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs;
|
|
||||||
[token, from, to, value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[token, from, to, value],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,address,uint256)')
|
|
||||||
.functions.transferFrom(token, from, to, value).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(token: string, from: string, to: string, value: BigNumber): string {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferFrom(address,address,address,uint256)').inputs;
|
|
||||||
[token, from, to, value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[token, from, to, value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transferFrom(address,address,address,uint256)')
|
|
||||||
.functions.transferFrom(token, from, to, value).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
async callAsync(
|
|
||||||
token: string,
|
|
||||||
from: string,
|
|
||||||
to: string,
|
|
||||||
value: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const functionSignature = 'transferFrom(address,address,address,uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[token, from, to, value] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[token, from, to, value],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.transferFrom(token, from, to, value) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'transferFrom' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public addAuthorizedAddress = {
|
|
||||||
async sendTransactionAsync(target: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('addAuthorizedAddress(address)')
|
|
||||||
.functions.addAuthorizedAddress(target).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.addAuthorizedAddress.estimateGasAsync.bind(self, target),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(target: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('addAuthorizedAddress(address)')
|
|
||||||
.functions.addAuthorizedAddress(target).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(target: string): string {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('addAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('addAuthorizedAddress(address)')
|
|
||||||
.functions.addAuthorizedAddress(target).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public authorities = {
|
|
||||||
async callAsync(
|
|
||||||
index_0: BigNumber,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const functionSignature = 'authorities(uint256)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[index_0] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[index_0],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.authorities(index_0) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'authorities' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public removeAuthorizedAddress = {
|
|
||||||
async sendTransactionAsync(target: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('removeAuthorizedAddress(address)')
|
|
||||||
.functions.removeAuthorizedAddress(target).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.removeAuthorizedAddress.estimateGasAsync.bind(self, target),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(target: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('removeAuthorizedAddress(address)')
|
|
||||||
.functions.removeAuthorizedAddress(target).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(target: string): string {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('removeAuthorizedAddress(address)').inputs;
|
|
||||||
[target] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[target],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('removeAuthorizedAddress(address)')
|
|
||||||
.functions.removeAuthorizedAddress(target).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public owner = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const functionSignature = 'owner()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.owner() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'owner' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public authorized = {
|
|
||||||
async callAsync(
|
|
||||||
index_0: string,
|
|
||||||
callData: Partial<CallData> = {},
|
|
||||||
defaultBlock?: BlockParam,
|
|
||||||
): Promise<boolean> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const functionSignature = 'authorized(address)';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[index_0] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[index_0],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.authorized(index_0) as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'authorized' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public getAuthorizedAddresses = {
|
|
||||||
async callAsync(callData: Partial<CallData> = {}, defaultBlock?: BlockParam): Promise<string[]> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const functionSignature = 'getAuthorizedAddresses()';
|
|
||||||
const inputAbi = self._lookupAbi(functionSignature).inputs;
|
|
||||||
[] = BaseContract._formatABIDataItemList(inputAbi, [], BaseContract._bigNumberToString.bind(self));
|
|
||||||
const ethersFunction = self
|
|
||||||
._lookupEthersInterface(functionSignature)
|
|
||||||
.functions.getAuthorizedAddresses() as ethers.CallDescription;
|
|
||||||
const encodedData = ethersFunction.data;
|
|
||||||
const callDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const rawCallResult = await self._web3Wrapper.callAsync(callDataWithDefaults, defaultBlock);
|
|
||||||
let resultArray = ethersFunction.parse(rawCallResult);
|
|
||||||
const outputAbi = (_.find(self.abi, { name: 'getAuthorizedAddresses' }) as MethodAbi).outputs;
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._lowercaseAddress.bind(this),
|
|
||||||
);
|
|
||||||
resultArray = BaseContract._formatABIDataItemList(
|
|
||||||
outputAbi,
|
|
||||||
resultArray,
|
|
||||||
BaseContract._bnToBigNumber.bind(this),
|
|
||||||
);
|
|
||||||
return resultArray[0];
|
|
||||||
},
|
|
||||||
};
|
|
||||||
public transferOwnership = {
|
|
||||||
async sendTransactionAsync(newOwner: string, txData: Partial<TxData> = {}): Promise<string> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync(
|
|
||||||
{
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
},
|
|
||||||
self.transferOwnership.estimateGasAsync.bind(self, newOwner),
|
|
||||||
);
|
|
||||||
const txHash = await self._web3Wrapper.sendTransactionAsync(txDataWithDefaults);
|
|
||||||
return txHash;
|
|
||||||
},
|
|
||||||
async estimateGasAsync(newOwner: string, txData: Partial<TxData> = {}): Promise<number> {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(this),
|
|
||||||
);
|
|
||||||
const encodedData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
const txDataWithDefaults = await self._applyDefaultsToTxDataAsync({
|
|
||||||
...txData,
|
|
||||||
data: encodedData,
|
|
||||||
});
|
|
||||||
const gas = await self._web3Wrapper.estimateGasAsync(txDataWithDefaults);
|
|
||||||
return gas;
|
|
||||||
},
|
|
||||||
getABIEncodedTransactionData(newOwner: string): string {
|
|
||||||
const self = (this as any) as TokenTransferProxyContract;
|
|
||||||
const inputAbi = self._lookupAbi('transferOwnership(address)').inputs;
|
|
||||||
[newOwner] = BaseContract._formatABIDataItemList(
|
|
||||||
inputAbi,
|
|
||||||
[newOwner],
|
|
||||||
BaseContract._bigNumberToString.bind(self),
|
|
||||||
);
|
|
||||||
const abiEncodedTransactionData = self
|
|
||||||
._lookupEthersInterface('transferOwnership(address)')
|
|
||||||
.functions.transferOwnership(newOwner).data;
|
|
||||||
return abiEncodedTransactionData;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
constructor(abi: ContractAbi, address: string, provider: Provider, defaults?: Partial<TxData>) {
|
|
||||||
super(abi, address, provider, defaults);
|
|
||||||
classUtils.bindAll(this, ['_ethersInterfacesByFunctionSignature', 'address', 'abi', '_web3Wrapper']);
|
|
||||||
}
|
|
||||||
} // tslint:disable:max-file-line-count
|
|
Loading…
x
Reference in New Issue
Block a user