Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Carlos/fix linux crash #25

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions eth_transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { default_http_options, default_ws_options } = require('./properties');
const nonce_helper_fn = require('./nonce_helper');
const Web3WsProvider = require('web3-providers-ws');
const Big = require('big.js')
const HDWalletProvider = require("@truffle/hdwallet-provider");
const HDWalletProvider = require("@puremoney/hdwallet-provider");

class EthTransfer {
constructor(
Expand All @@ -17,7 +17,8 @@ class EthTransfer {
nonce_helper = null,
http_options = default_http_options,
ws_options = default_ws_options,
src_mnemonic = null
src_mnemonic = null,
chain_id = null
) {
this.network_provider = network_provider;
this.contract_address = contract_address;
Expand All @@ -38,6 +39,7 @@ class EthTransfer {
this.http_options = http_options;
this.ws_options = ws_options;
this.src_mnemonic = src_mnemonic;
this.chain_id = chain_id
}

async init() {
Expand Down Expand Up @@ -75,7 +77,8 @@ class EthTransfer {
transactionCount,
roks_eth_src_same,
localNonceIncrement,
nonce_helper
nonce_helper,
chain_id
} = this;

const bigAmount = Big(amount);
Expand Down Expand Up @@ -123,14 +126,17 @@ class EthTransfer {
// Get gas price
const gasPrice = await web3.eth.getGasPrice();

const {chain, chainId} = (chain_id == null) ? {chain: 'bsc-mainnet', chainId: 56} : chain_id;

const txObj = {
nonce,
from: this.eth_src_address,
to: recipient,
value: web3.utils.toHex(web3.utils.toWei(amount.toString(), 'ether').toString()),
gasPrice: web3.utils.toHex(gasPrice.toString()),
gasLimit: web3.utils.toHex(this.gas_limit),
chain: 'bsc-testnet', // FIXME: must be a configurable variable
chain,
chainId,
}

return web3.eth.sendTransaction(txObj)
Expand All @@ -140,7 +146,7 @@ class EthTransfer {
})
.catch((reason) => {
console.log("Reason: ", reason);
throw new Error(reason);
throw new Error(reason.message);
});
}
}
Expand Down
Loading