Skip to content

Commit d133926

Browse files
authored
Merge pull request #2744 from ethereum/fix_misc
Fix logging to the terminal & Update Security Message
2 parents 3b2bb68 + ac6aece commit d133926

File tree

3 files changed

+54
-4
lines changed

3 files changed

+54
-4
lines changed

apps/remix-ide-e2e/src/tests/terminal.test.ts

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,35 @@ module.exports = {
202202
.sendKeys('body', [browser.Keys.CONTROL, browser.Keys.SHIFT, 's'])
203203
.pause(15000)
204204
.journalLastChildIncludes('147')
205-
}
205+
},
206+
207+
'Should run a script which log transaction and block using web3.js and ethers #group7': function (browser: NightwatchBrowser) {
208+
browser
209+
.clickLaunchIcon('udapp')
210+
.switchEnvironment('External Http Provider')
211+
.waitForElementPresent('[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]')
212+
.waitForElementVisible('[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]')
213+
.pause(1000)
214+
.execute(() => {
215+
(document.querySelector('*[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]') as any).focus()
216+
}, [], () => {})
217+
.clearValue('[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]')
218+
.setValue('[data-id="basic-http-providerModalDialogContainer-react"] input[data-id="modalDialogCustomPromp"]', 'https://remix-goerli.ethdevops.io')
219+
.modalFooterOKClick('basic-http-provider')
220+
.pause(1000)
221+
.clickLaunchIcon('filePanel')
222+
.openFile('README.txt')
223+
.addFile('scripts/log_tx_block.js', { content: scriptBlockAndTransaction } )
224+
.pause(1000)
225+
.executeScript('remix.execute(\'scripts/log_tx_block.js\')')
226+
.pause(10000)
227+
// check if the input of the transaction is being logged (web3 call)
228+
.journalChildIncludes('0x775526410000000000000000000000000000000000000000000000000000000000000060464c0335b2f1609abd9de25141c0a3b49db516fc7375970dc737c32b986e88e3000000000000000000000000000000000000000000000000000000000000039e000000000000000000000000000000000000000000000000000000000000000602926b30b10e7a514d92bc71e085f5bff2687fac2856ae43ef7621bf1756fa370516d310bec5727543089be9a4d5f68471174ee528e95a2520b0ca36c2b6c6eb0000000000000000000000000000000000000000000000000000000000046f49036f5e4ea4dd042801c8841e3db8e654124305da0f11824fc1db60c405dbb39f00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000')
229+
// check if the logsBloom is being logged (web3 call)
230+
.journalChildIncludes('0x00000000000000000000000000100000000000000000020000000000002000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000000040000000060000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000100000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000001')
231+
// check if the logsBloom is being logged (ethers.js call)
232+
.journalChildIncludes('"hex":"0x025cd8"')
233+
}
206234
}
207235

208236
const asyncAwait = `
@@ -607,3 +635,17 @@ const scriptAutoExec = {
607635
})()
608636
`
609637
}
638+
639+
const scriptBlockAndTransaction = `
640+
// Right click on the script name and hit "Run" to execute
641+
(async () => {
642+
try {
643+
web3.eth.getTransaction('0x022ccd55747677ac50f8d9dfd1bf5b843fa2f36438a28c1d0a0958e057bb3e2a').then(console.log)
644+
web3.eth.getBlock('7367447').then(console.log);
645+
let ethersProvider = new ethers.providers.Web3Provider(web3Provider)
646+
ethersProvider.getBlock(7367447).then(console.log)
647+
} catch (e) {
648+
console.log(e.message)
649+
}
650+
})()
651+
`

libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {
237237
<div>
238238
<i className="pl-4 text-danger fas fa-exclamation-triangle"></i>
239239
<span className="px-2 remixui_home_text text-danger mt-4 pt-4">
240-
Scam Alert: Beware of online videos promoting "liquidity front runner bots".
240+
Scam Alert: There are video tutorials going around that provide urls other than remix.ethereum.org, and could be scams. Also, beware of online videos promoting "liquidity front runner bots".
241241
</span>
242242
<a className="remixui_home_text" target="__blank" href="https://medium.com/remix-ide/remix-in-youtube-crypto-scams-71c338da32d">Learn more</a>
243243
</div>

libs/remix-ui/terminal/src/lib/remix-ui-terminal.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,17 +543,25 @@ export const RemixUiTerminal = (props: RemixUiTerminalProps) => {
543543
})
544544
} else if (Array.isArray(x.message)) {
545545
return x.message.map((msg, i) => {
546+
if (!msg) msg = 'null'
546547
if (React.isValidElement(msg)) {
547548
return (
548549
<div className="px-4 block" data-id="block" key={i}><span className={x.style}>{ msg }</span></div>
549550
)
550551
} else if (typeof msg === 'object') {
552+
let stringified
553+
try {
554+
stringified = JSON.stringify(msg)
555+
} catch (e) {
556+
console.error(e)
557+
stringified = '< value not displayable >'
558+
}
551559
return (
552-
<div className={classNameBlock} data-id="block" key={i}><span className={x.style}>{ msg.value && typeof msg.value !== 'object' ? parse(msg.value) : JSON.stringify(msg) } </span></div>
560+
<div className={classNameBlock} data-id="block" key={i}><span className={x.style}>{ stringified } </span></div>
553561
)
554562
} else {
555563
return (
556-
<div className={classNameBlock} data-id="block" key={i}><span className={x.style}>{msg? msg.toString() : null}</span></div>
564+
<div className={classNameBlock} data-id="block" key={i}><span className={x.style}>{msg ? msg.toString() : null}</span></div>
557565
)
558566
}
559567
})

0 commit comments

Comments
 (0)