fix open in etherscan link

pull/5370/head
yann300 3 years ago
parent 3397ea75f9
commit 7a397d5261
  1. 22
      apps/remix-ide/src/app/udapp/make-udapp.js
  2. 15
      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'
var remixLib = require('@remix-project/remix-lib')
var yo = require('yo-yo')
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) {
// ----------------- 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 -----------------
const _transactionReceipts = {}
const transactionReceiptResolver = (tx, cb) => {

@ -1,3 +1,5 @@
import React from 'react' // eslint-disable-line
import Web3 from 'web3'
import { Plugin } from '@remixproject/engine'
import { toBuffer, addHexPrefix } from 'ethereumjs-util'
@ -9,6 +11,7 @@ import VMProvider from './providers/vm.js'
import InjectedProvider from './providers/injected.js'
import NodeProvider from './providers/node.js'
import { execution, EventManager, helpers } from '@remix-project/remix-lib'
import { etherScanLink } from './helper'
const { txFormat, txExecution, typeConversion, txListener: Txlistener, TxRunner, TxRunnerWeb3, txHelper } = execution
const { txResultHelper: resultToRemixTx } = helpers
const packageJson = require('../../../../package.json')
@ -343,14 +346,18 @@ export class Blockchain extends Plugin {
return this.getProvider() === 'web3' ? this.config.get('settings/personal-mode') : false
}
}, _ => this.executionContext.web3(), _ => this.executionContext.currentblockGasLimit())
this.txRunner = new TxRunner(web3Runner, { runAsync: true })
this.txRunner.event.register('transactionBroadcasted', (txhash) => {
web3Runner.event.register('transactionBroadcasted', (txhash) => {
this.executionContext.detectNetwork((error, network) => {
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