Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
takeAction() {
const param = {
address: this.token.address,
amount: new BigNumber(unit.toWei(this.amount, 'ether')).toString(),
}
if (!this.activeDepositTab) {
param['rate'] = this.selectStable ? 0 : 1;
}
param['referral'] = 0;// do i need to put referral code? is 0 mean no referral?
this.$emit('takeAction', param);
},
convertToUSD(balance) {
const toPeb = function(number, unit) {
// kaly unit to eth unit
unit = getKlayUnitValue(unit)
unit = unitKlayToEthMap[unit]
unit = getUnitValue(unit)
if (!utils.isBN(number) && !_.isString(number)) {
number = tryNumberToString(number)
}
return utils.isBN(number) ? ethjsUnit.toWei(number, unit) : ethjsUnit.toWei(number, unit).toString(10)
}
async generateTx() {
const raw = {
from: this.wallet.getAddressString(),
gas: this.localGas,
value:
this.selectedCoinType.symbol !== this.network.type.name
? 0
: unit.toWei(this.toAmt, 'ether'),
data: this.toData,
nonce: this.locNonce,
gasPrice: unit.toWei(this.gasPrice, 'gwei'),
to:
this.selectedCoinType.symbol !== this.network.type.name
? this.selectedCoinType.address
: this.address,
chainId: this.network.type.chainID,
generateOnly: true
};
this.raw = raw;
this.wallet
.signTransaction(this.raw)
.then(signed => {
this.signed = JSON.stringify(signed);
this.$emit('createdRawTx', this.signed);
next() {
const raw = {
from: this.wallet.getAddressString(),
gas: this.localGas,
value: unit.toWei(this.toAmt, 'ether'),
data: this.toData,
nonce: this.locNonce,
gasPrice: Number(unit.toWei(this.gasPrice, 'gwei')),
to:
this.resolvedAddress !== ''
? this.resolvedAddress
: this.address !== ''
? this.address
: '',
chainId: this.network.type.chainID || 1
};
this.web3.eth.signTransaction(raw).then(signedTx => {
this.$emit('createdRawTx', signedTx.rawTransaction);
this.raw = raw;
this.signed = signedTx.rawTransaction;
this.$refs.signedTxModal.$refs.signedTx.show();
window.scrollTo(0, 0);
});
}), async ({ deployed, minedTx, deployerAddress }) => {
const ds = await deployed( 'DifferentSender', { force: true } )
//const instance = await relink.getInstance()
const txReceipt = await minedTx( ds.send, [deployerAddress], {value: toWei('0.1', 'ether')} )
const owner = toChecksumAddress((await ds.owner())['0'])
const lastSender = toChecksumAddress((await ds.lastSender())['0'])
const lastPayer = toChecksumAddress((await ds.lastPayer())['0'])
const lastValue = (await ds.lastValue())['0']
assert.equal( owner , deployerAddress )
assert.equal( lastSender , deployerAddress )
assert.equal( lastPayer , deployerAddress )
assert.equal( lastValue.toString() , toWei('0.1', 'ether').toString() )
return 22
})
estimatedMaximumExecutionGasPrice() {
if (
!this.isValidFutureGasPrice ||
!this.isValidFutureGasLimit ||
!this.isValidTimeBounty
)
return 0;
const estimated = Util.estimateMaximumExecutionGasPrice(
new BigNumber(unit.toWei(this.timeBounty, 'ether')),
new BigNumber(unit.toWei(this.futureGasPrice, 'gwei')),
new BigNumber(this.futureGasLimit)
);
return Math.round(unit.fromWei(estimated.toString(), 'gwei'));
},
now() {
async generateTx() {
const symbol = this.network.type.currencyName;
const isToken = this.selectedCoinType.symbol !== symbol;
const amtWei = unit.toWei(this.toAmt, 'ether');
const raw = {
nonce: Misc.sanitizeHex(new BigNumber(this.localNonce).toString(16)),
gasLimit: Misc.sanitizeHex(new BigNumber(this.gasLimit).toString(16)),
gasPrice: Misc.sanitizeHex(
new BigNumber(unit.toWei(this.localGasPrice, 'gwei')).toString(16)
),
to: isToken
? this.selectedCoinType.address
: this.address.toLowerCase().trim(),
value: isToken ? 0 : amtWei,
data: this.toData,
chainId: this.network.type.chainID
};
this.raw = raw;
const signed = await this.wallet.signTransaction(this.raw);
this.signed = JSON.stringify(signed);
);
this.data = isEth
? this.data
: contract.methods
.transfer(this.address, unit.toWei(this.amount, 'ether'))
.encodeABI();
this.raw = {
from: this.$store.state.wallet.getAddressString(),
gas: this.gasLimit,
nonce: this.nonce,
gasPrice: Number(unit.toWei(this.$store.state.gasPrice, 'gwei')),
value: isEth
? this.amount === ''
? 0
: unit.toWei(this.amount, 'ether')
: 0,
to: isEth ? this.address : this.selectedCurrency.addr,
data: this.data,
chainId: this.$store.state.network.type.chainID || 1
};
if (this.address === '') {
delete this.raw['to'];
}
const fromAddress = this.raw.from;
this.$store.state.web3.eth
.sendTransaction(this.raw)
.once('transactionHash', hash => {
this.$store.dispatch('addNotification', [
fromAddress,
async getSafeSendFee() {
try {
this.safeSendPriceEstimate = await this.coralContract.methods
.checkFee(unit.toWei(this.amount, 'ether').toString())
.call();
} catch (e) {
this.safeSendPriceEstimate = new BigNumber(0).toFixed();
Toast.responseHandler(e, Toast.ERROR);
}
}
}
this.preparedSwap = swapDetails.dataForInitialization.map(entry => {
entry.from = this.account.address;
if (
+unit.toWei(this.gasPrice, 'gwei').toString() >
+swapDetails.kyberMaxGas
) {
entry.gasPrice = swapDetails.kyberMaxGas;
}
return entry;
});
}