Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function newBlockHeaderProcessor(kit: ContractKit): Promise<(block: BlockHeader) => void> {
const blockExplorer = await newBlockExplorer(kit)
const logExplorer = await newLogExplorer(kit)
function toMethodId(txInput: string, isKnownCall: boolean): string {
let methodId: string
if (txInput === '0x') {
methodId = EMPTY_INPUT
} else if (txInput.startsWith('0x')) {
methodId = isKnownCall ? txInput.slice(0, 10) : UNKNOWN_METHOD
} else {
// pretty much should never get here
methodId = NO_METHOD_ID
}
return methodId
}
function toTxMap(parsedBlock: ParsedBlock): Map {
const parsedTxMap: Map = new Map()
parsedBlock.parsedTx.forEach((ptx) => {
export const handler = async (argv: ListArgv) => {
await switchToClusterFromEnv(false)
await downloadArtifacts(argv.celoEnv)
await copyContractArtifacts(
argv.celoEnv,
'../transaction-metrics-exporter/src/contracts',
CONTRACTS_TO_COPY
)
const web3 = await getWeb3Client(argv.celoEnv)
const blockscoutURL = getBlockscoutUrl(argv.celoEnv)
const kit = await newKitFromWeb3(web3)
const blockExplorer = await newBlockExplorer(kit)
const logExplorer = await newLogExplorer(kit)
const resp = await fetch(
`${blockscoutURL}/api?module=account&action=txlist&address=${argv.address}&sort=desc`
)
const jsonResp = await resp.json()
if (jsonResp.result === undefined) {
return
}
for (const blockscoutTx of jsonResp.result) {
await fetchTx(web3, blockExplorer, logExplorer, blockscoutTx)
}
process.exit(0)
}
export const handler = async (argv: DescribeArgv) => {
await switchToClusterFromEnv(false)
const web3 = await getWeb3Client(argv.celoEnv)
const kit = await newKitFromWeb3(web3)
const blockExplorer = await newBlockExplorer(kit)
const logExplorer = await newLogExplorer(kit)
const transaction = await web3.eth.getTransaction(argv.transactionHash)
const receipt = await web3.eth.getTransactionReceipt(argv.transactionHash)
if (process.env.CELOTOOL_VERBOSE === 'true') {
console.info('Raw Transaction Data:')
console.info(transaction)
console.info('Raw Transaction Receipt')
console.info(receipt)
}
const parsedTransaction = blockExplorer.tryParseTx(transaction)
if (parsedTransaction === null) {
return
}