Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(
factory: Contracts,
code?: string,
abi?: ABI,
address?: string,
init?: any,
state?: any,
) {
this.factory = factory;
this.provider = factory.provider;
this.signer = factory.signer;
// assume that we are accessing an existing contract
if (address) {
this.abi = abi;
this.address = normaliseAddress(address);
this.init = init;
this.state = state;
this.status = ContractStatus.Deployed;
} else {
// assume we're deploying
this.abi = abi;
this.code = code;
this.init = init;
this.status = ContractStatus.Initialised;
}
}
constructor(
params: TxParams,
provider: Provider,
status: TxStatus = TxStatus.Initialised,
toDS: boolean = false,
) {
// private members
this.version = params.version;
this.toAddr = normaliseAddress(params.toAddr);
this.nonce = params.nonce;
this.pubKey = params.pubKey;
this.amount = params.amount;
this.code = params.code || '';
this.data = params.data || '';
this.signature = params.signature;
this.gasPrice = params.gasPrice;
this.gasLimit = params.gasLimit;
this.receipt = params.receipt;
// public members
this.provider = provider;
this.status = status;
this.toDS = toDS;
this.blockConfirmation = 0;
this.eventEmitter = new EventEmitter();
}
private setParams(params: TxParams) {
this.version = params.version;
this.toAddr = normaliseAddress(params.toAddr);
this.nonce = params.nonce;
this.pubKey = params.pubKey;
this.amount = params.amount;
this.code = params.code || '';
this.data = params.data || '';
this.signature = params.signature;
this.gasPrice = params.gasPrice;
this.gasLimit = params.gasLimit;
this.receipt = params.receipt;
}
get txParams(): TxParams {
return {
version: this.version,
toAddr: normaliseAddress(this.toAddr),
nonce: this.nonce,
pubKey: this.pubKey,
amount: this.amount,
gasPrice: this.gasPrice,
gasLimit: this.gasLimit,
code: this.code,
data: this.data,
signature: this.signature,
receipt: this.receipt,
};
}