Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(transaction => {
if (transaction.blockNumber > this.highestBlock) {
this.lastReadBlock = transaction.blockNumber;
}
if (!transaction.input) {
return logger.error(new Error("no transaction input found"));
}
let decodedData;
try {
decodedData = abiDecoder.decodeMethod(transaction.input);
} catch (e) {
return logger.error(e);
}
this.eventCount++;
if (!decodedData || !decodedData.name) {
return logger.error(new Error("error decoding method"));
}
// updateAccount(_ipfsHash string)
// reply(_ipfsHash string)
// share(_ipfsHash string)
// saveBatch(_ipfsHash string)
// post(_ipfsHash string)
// createAccount(_name bytes16,_ipfsHash string)
// tip(_author address,_messageID string,_ownerTip uint256,_ipfsHash string)
getFromToTokenAmountByTxDataAndType(txData: any, type: string): FromToTokenAmount {
let from = this.web3.utils.toChecksumAddress(txData.from);
let to = null;
let tokenAmount = null;
// direct transfer calls of tokens
if (type === TOKEN_TRANSFER) {
abiDecoder.addABI(config.contracts.token.abi);
const decodedData = abiDecoder.decodeMethod(txData.input);
if (decodedData.name === 'transfer') {
to = this.web3.utils.toChecksumAddress(decodedData.params[0].value);
tokenAmount = this.web3.utils.fromWei(decodedData.params[1].value).toString();
}
} else if (txData.to) {
to = this.web3.utils.toChecksumAddress(txData.to);
}
return {
from,
to,
tokenAmount
};
}
index: 'transaction',
type: 'block',
id: block.number,
body: json
}, function (error, response) {
console.log(error);
console.log(response);
});
if(transactionList.length!==0) {
for(var j=0;j
eth_call: (args, _, contracts) => {
console.log('eth_call');
console.log(args);
const contractAddress = `${args[1][0].to.toLowerCase()}`;
const methodSig = args[1][0].data.slice(0, 10);
let decodedInput; let name; let
params;
if (contracts[contractAddress]) {
abiDecoder.addABI(contracts[contractAddress].abi);
decodedInput = abiDecoder.decodeMethod(methodSig);
name = `${decodedInput.name}(${decodedInput.params.map((p) => p.type).join(',')})`;
params = decodedInput.params.length ? decodedInput.params : null;
} else {
name = methodSig;
params = methodSig;
}
const foo = {
to: contractAddress,
name,
params,
};
console.log('add eth call with this data', foo);
return foo;
},
eth_gasPrice: (args) => {
paymentId,
userEmail,
tokenName
) {
switch (tokenName) {
case "xdce": {
try {
const web3 = new Web3(
new Web3.providers.WebsocketProvider("wss://mainnet.infura.io/ws")
);
let course = await CoursePrice.findOne({ courseId: courseId });
let getTx = await web3.eth.getTransaction(txHash);
let paymentLog = await PaymentToken.findOne({ payment_id: paymentId });
let txInputData = getTx.input;
let decodedMethod = abiDecoder.decodeMethod(txInputData);
let receivedXdce = decodedMethod.params[1].value;
const contractInst = new web3.eth.Contract(xdceABI, xdceAddrMainnet);
const allWallet = await AllWallet.findOne({
burnActive: {
$elemMatch: {
wallet_network: paymentLog.payment_network,
wallet_token_name: tokenName
}
}
});
let xdceOwnerPubAddr = null;
getTransactionDetailsFromSigned(signedTx: SignedEthereumTransaction): IAirGapTransaction {
const ethTx = super.getTransactionDetailsFromSigned(signedTx)
const extractedTx = new EthereumTransaction(signedTx.transaction)
const tokenTransferDetails = abiDecoder.decodeMethod('0x' + extractedTx.data.toString('hex'))
ethTx.to = [ethUtil.toChecksumAddress(tokenTransferDetails.params[0].value)]
ethTx.amount = new BigNumber(tokenTransferDetails.params[1].value)
return ethTx
}
var tx = new ethJsTx({
nonce: returned_tx.nonce,
gasPrice: returned_tx.gasPrice,
gasLimit: returned_tx.gas,
to: returned_tx.to,
value: returned_tx.value,
data: returned_tx.input,
});
let message = tx.hash(false);
let tx_v = Buffer.from(removeHexPrefix(returned_tx.v), "hex");
let tx_r = Buffer.from(padTo64(removeHexPrefix(returned_tx.r)), "hex");
let tx_s = Buffer.from(padTo64(removeHexPrefix(returned_tx.s)), "hex");
let signer = ethUtils.bufferToHex(ethUtils.pubToAddress(ethUtils.ecrecover(message, tx_v[0], tx_r, tx_s)));
let request_decoded_params = abi_decoder.decodeMethod(returned_tx.input).params;
let returned_tx_params_hash = utils.getTransactionHash(
request_decoded_params[0].value,
request_decoded_params[1].value,
request_decoded_params[2].value,
request_decoded_params[3].value,
request_decoded_params[4].value,
request_decoded_params[5].value,
request_decoded_params[6].value,
returned_tx.to,
signer
);
let transaction_orig_params_hash = utils.getTransactionHash(
from, to, transaction_orig, transaction_fee, gas_price, gas_limit, nonce, relay_hub_address, relay_address);
if (returned_tx_params_hash === transaction_orig_params_hash && address_relay === signer) {
if (this.config.verbose) {