fix open in etherscan link

pull/1897/head
yann300 3 years ago
parent 3f9953f4b3
commit 5b6c1444b3
  1. 22
      apps/remix-ide/src/app/udapp/make-udapp.js
  2. 13
      apps/remix-ide/src/blockchain/blockchain.js
  3. 13
      apps/remix-ide/src/blockchain/helper.ts

@ -1,31 +1,9 @@
import Registry from '../state/registry' import Registry from '../state/registry'
var remixLib = require('@remix-project/remix-lib') var remixLib = require('@remix-project/remix-lib')
var yo = require('yo-yo')
var EventsDecoder = remixLib.execution.EventsDecoder var EventsDecoder = remixLib.execution.EventsDecoder
const transactionDetailsLinks = {
Main: 'https://www.etherscan.io/tx/',
Rinkeby: 'https://rinkeby.etherscan.io/tx/',
Ropsten: 'https://ropsten.etherscan.io/tx/',
Kovan: 'https://kovan.etherscan.io/tx/',
Goerli: 'https://goerli.etherscan.io/tx/'
}
function txDetailsLink (network, hash) {
if (transactionDetailsLinks[network]) {
return transactionDetailsLinks[network] + hash
}
}
export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) { export function makeUdapp (blockchain, compilersArtefacts, logHtmlCallback) {
// ----------------- UniversalDApp -----------------
// TODO: to remove when possible
blockchain.event.register('transactionBroadcasted', (txhash, networkName) => {
var txLink = txDetailsLink(networkName, txhash)
if (txLink && logHtmlCallback) logHtmlCallback(yo`<a href="${txLink}" target="_blank">${txLink}</a>`)
})
// ----------------- Tx listener ----------------- // ----------------- Tx listener -----------------
const _transactionReceipts = {} const _transactionReceipts = {}
const transactionReceiptResolver = (tx, cb) => { const transactionReceiptResolver = (tx, cb) => {

@ -1,3 +1,5 @@
import React from 'react' // eslint-disable-line
import Web3 from 'web3' import Web3 from 'web3'
import { Plugin } from '@remixproject/engine' import { Plugin } from '@remixproject/engine'
import { toBuffer, addHexPrefix } from 'ethereumjs-util' import { toBuffer, addHexPrefix } from 'ethereumjs-util'
@ -9,6 +11,7 @@ import VMProvider from './providers/vm.js'
import InjectedProvider from './providers/injected.js' import InjectedProvider from './providers/injected.js'
import NodeProvider from './providers/node.js' import NodeProvider from './providers/node.js'
import { execution, EventManager, helpers } from '@remix-project/remix-lib' import { execution, EventManager, helpers } from '@remix-project/remix-lib'
import { etherScanLink } from './helper'
const { txFormat, txExecution, typeConversion, txListener: Txlistener, TxRunner, TxRunnerWeb3, txHelper } = execution const { txFormat, txExecution, typeConversion, txListener: Txlistener, TxRunner, TxRunnerWeb3, txHelper } = execution
const { txResultHelper: resultToRemixTx } = helpers const { txResultHelper: resultToRemixTx } = helpers
const packageJson = require('../../../../package.json') const packageJson = require('../../../../package.json')
@ -344,13 +347,17 @@ export class Blockchain extends Plugin {
} }
}, _ => this.executionContext.web3(), _ => this.executionContext.currentblockGasLimit()) }, _ => this.executionContext.web3(), _ => this.executionContext.currentblockGasLimit())
this.txRunner = new TxRunner(web3Runner, { runAsync: true }) web3Runner.event.register('transactionBroadcasted', (txhash) => {
this.txRunner.event.register('transactionBroadcasted', (txhash) => {
this.executionContext.detectNetwork((error, network) => { this.executionContext.detectNetwork((error, network) => {
if (error || !network) return if (error || !network) return
this.event.trigger('transactionBroadcasted', [txhash, network.name]) if (network.name === 'VM') return
this.call('terminal', 'logHtml',
(<a href={etherScanLink(network.name, txhash)} target="_blank">
open in etherscan
</a>))
}) })
}) })
this.txRunner = new TxRunner(web3Runner, { runAsync: true })
} }
/** /**

@ -0,0 +1,13 @@
const transactionDetailsLinks = {
Main: 'https://www.etherscan.io/tx/',
Rinkeby: 'https://rinkeby.etherscan.io/tx/',
Ropsten: 'https://ropsten.etherscan.io/tx/',
Kovan: 'https://kovan.etherscan.io/tx/',
Goerli: 'https://goerli.etherscan.io/tx/'
}
export function etherScanLink (network: string, hash: string): string {
if (transactionDetailsLinks[network]) {
return transactionDetailsLinks[network] + hash
}
}
Loading…
Cancel
Save