Skip to content

Commit

Permalink
feat: getting transaction error message
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbn committed Jun 3, 2021
1 parent e1d90df commit ce924c8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
36 changes: 36 additions & 0 deletions subtasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { formatBytes32String, parseBytes32String } from 'ethers/lib/utils';
import axios from 'axios';
import { BigNumber } from 'ethers';
import { rpcQuantity } from 'hardhat/internal/core/jsonrpc/types/base-types';
import { TransactionRequest } from '@ethersproject/providers';

const prettier = require('prettier');
const { DataFile } = require('edit-config');
Expand Down Expand Up @@ -98,6 +99,7 @@ export enum SUB_TASK_NAMES {
REGISTRIES_CONFIGURATION = 'REGISTRIES_CONFIGURATION',
PREC_FULFILL_ANALYTICS = 'PREC_FULFILL_ANALYTICS',
GET_VALID_SLAS = 'GET_VALID_SLAS',
GET_REVERT_MESSAGE = 'GET_REVERT_MESSAGE',
}

subtask(SUB_TASK_NAMES.STOP_LOCAL_CHAINLINK_NODES, undefined).setAction(
Expand Down Expand Up @@ -1902,3 +1904,37 @@ subtask(SUB_TASK_NAMES.GET_VALID_SLAS, undefined).setAction(
console.log(allSLAs);
}
);

subtask(SUB_TASK_NAMES.GET_REVERT_MESSAGE, undefined).setAction(
async (taskArgs, hre: any) => {
const { ethers, network } = hre;
const transaction = await ethers.provider.getTransaction(
taskArgs.transactionHash
);
console.log('Transaction:');
console.log(transaction);
const { data } = await axios({
method: 'post',
url: network.config.url,
headers: {
'Content-Type': 'application/json',
},
data: {
jsonrpc: '2.0',
method: 'eth_call',
params: [
{
from: transaction.from,
to: transaction.to,
value: numberToHex(transaction.value.toString()),
data: transaction.data,
},
numberToHex(transaction.blockNumber),
],
id: 1,
},
});
console.log('Error data:');
console.log(data);
}
);
7 changes: 7 additions & 0 deletions tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ enum TASK_NAMES {
PREC_FULFILL_ANALYTICS = 'stacktical:prec-fulfill-analytics',
REGISTRIES_CONFIGURATION = 'stacktical:registries-config',
GET_VALID_SLAS = 'stacktical:get-valid-slas',
GET_REVERT_MESSAGE = 'stacktical:get-revert-message',
}

task(
Expand Down Expand Up @@ -255,4 +256,10 @@ task(TASK_NAMES.GET_VALID_SLAS, 'Get all valid SLAs by network').setAction(
}
);

task(TASK_NAMES.GET_REVERT_MESSAGE, 'Get revert message for transaction hash')
.addParam('transactionHash', 'Transaction hash to get message')
.setAction(async (taskArgs, hre: any) => {
await hre.run(SUB_TASK_NAMES.GET_REVERT_MESSAGE, taskArgs);
});

module.exports = {};

0 comments on commit ce924c8

Please sign in to comment.