How to use the @celo/contractkit/lib/explorer/block-explorer.newBlockExplorer function in @celo/contractkit

To help you get started, we’ve selected a few @celo/contractkit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github celo-org / celo-monorepo / packages / transaction-metrics-exporter / src / blockchain.ts View on Github external
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()
github celo-org / celo-monorepo / packages / celotool / src / cmds / transactions / list.ts View on Github external
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)
}
github celo-org / celo-monorepo / packages / celotool / src / cmds / transactions / describe.ts View on Github external
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