aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/deploy/src/utils/contract.ts
diff options
context:
space:
mode:
Diffstat (limited to 'packages/contracts/deploy/src/utils/contract.ts')
-rw-r--r--packages/contracts/deploy/src/utils/contract.ts46
1 files changed, 23 insertions, 23 deletions
diff --git a/packages/contracts/deploy/src/utils/contract.ts b/packages/contracts/deploy/src/utils/contract.ts
index 7b6098cea..ffad9ed70 100644
--- a/packages/contracts/deploy/src/utils/contract.ts
+++ b/packages/contracts/deploy/src/utils/contract.ts
@@ -8,55 +8,55 @@ import {AbiType} from './types';
export class Contract implements Web3.ContractInstance {
public address: string;
public abi: Web3.ContractAbi;
- private contract: Web3.ContractInstance;
- private defaults: Partial<Web3.TxData>;
- private validator: SchemaValidator;
+ private _contract: Web3.ContractInstance;
+ private _defaults: Partial<Web3.TxData>;
+ private _validator: SchemaValidator;
// This class instance is going to be populated with functions and events depending on the ABI
// and we don't know their types in advance
[name: string]: any;
constructor(web3ContractInstance: Web3.ContractInstance, defaults: Partial<Web3.TxData>) {
- this.contract = web3ContractInstance;
+ this._contract = web3ContractInstance;
this.address = web3ContractInstance.address;
this.abi = web3ContractInstance.abi;
- this.defaults = defaults;
- this.populateEvents();
- this.populateFunctions();
- this.validator = new SchemaValidator();
+ this._defaults = defaults;
+ this._populateEvents();
+ this._populateFunctions();
+ this._validator = new SchemaValidator();
}
- private populateFunctions(): void {
+ private _populateFunctions(): void {
const functionsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Function);
_.forEach(functionsAbi, (functionAbi: Web3.MethodAbi) => {
if (functionAbi.constant) {
- const cbStyleCallFunction = this.contract[functionAbi.name].call;
+ const cbStyleCallFunction = this._contract[functionAbi.name].call;
this[functionAbi.name] = {
- callAsync: promisify(cbStyleCallFunction, this.contract),
+ callAsync: promisify(cbStyleCallFunction, this._contract),
};
} else {
- const cbStyleFunction = this.contract[functionAbi.name];
- const cbStyleEstimateGasFunction = this.contract[functionAbi.name].estimateGas;
+ const cbStyleFunction = this._contract[functionAbi.name];
+ const cbStyleEstimateGasFunction = this._contract[functionAbi.name].estimateGas;
this[functionAbi.name] = {
- estimateGasAsync: promisify(cbStyleEstimateGasFunction, this.contract),
- sendTransactionAsync: this.promisifyWithDefaultParams(cbStyleFunction),
+ estimateGasAsync: promisify(cbStyleEstimateGasFunction, this._contract),
+ sendTransactionAsync: this._promisifyWithDefaultParams(cbStyleFunction),
};
}
});
}
- private populateEvents(): void {
+ private _populateEvents(): void {
const eventsAbi = _.filter(this.abi, abiPart => abiPart.type === AbiType.Event);
_.forEach(eventsAbi, (eventAbi: Web3.EventAbi) => {
- this[eventAbi.name] = this.contract[eventAbi.name];
+ this[eventAbi.name] = this._contract[eventAbi.name];
});
}
- private promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise<any> {
+ private _promisifyWithDefaultParams(fn: (...args: any[]) => void): (...args: any[]) => Promise<any> {
const promisifiedWithDefaultParams = async (...args: any[]) => {
const promise = new Promise((resolve, reject) => {
const lastArg = args[args.length - 1];
let txData: Partial<Web3.TxData> = {};
- if (this.isTxData(lastArg)) {
+ if (this._isTxData(lastArg)) {
txData = args.pop();
}
txData = {
- ...this.defaults,
+ ...this._defaults,
...txData,
};
const callback = (err: Error, data: any) => {
@@ -68,14 +68,14 @@ export class Contract implements Web3.ContractInstance {
};
args.push(txData);
args.push(callback);
- fn.apply(this.contract, args);
+ fn.apply(this._contract, args);
});
return promise;
};
return promisifiedWithDefaultParams;
}
- private isTxData(lastArg: any): boolean {
- const isValid = this.validator.isValid(lastArg, schemas.txDataSchema);
+ private _isTxData(lastArg: any): boolean {
+ const isValid = this._validator.isValid(lastArg, schemas.txDataSchema);
return isValid;
}
}