Skip to content

Commit 059e20a

Browse files
authored
Merge branch 'master' into vsIcons
2 parents 2a44a1d + 72aed44 commit 059e20a

File tree

4 files changed

+109
-39
lines changed

4 files changed

+109
-39
lines changed

apps/remix-ide-e2e/src/tests/matomo-consent.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ module.exports = {
734734
/**
735735
* Simple pattern: User accepts cookies → has cookies + visitor ID → reload → same state
736736
*/
737-
'User accepts cookies #pr #group1': function (browser: NightwatchBrowser) {
737+
'User accepts cookies #group1': function (browser: NightwatchBrowser) {
738738
browser
739739
.perform(() => startFreshTest(browser))
740740
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -753,7 +753,7 @@ module.exports = {
753753
/**
754754
* Simple pattern: User rejects cookies → no cookies + no visitor ID → reload → same anonymous state
755755
*/
756-
'User rejects cookies (anonymous mode) #pr #group2': function (browser: NightwatchBrowser) {
756+
'User rejects cookies (anonymous mode) #group2': function (browser: NightwatchBrowser) {
757757
browser
758758
.perform(() => startFreshTest(browser))
759759
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -770,7 +770,7 @@ module.exports = {
770770
/**
771771
* Settings tab pattern: User switches preferences via Settings → Analytics
772772
*/
773-
'User switches settings via Settings tab #pr #group3': function (browser: NightwatchBrowser) {
773+
'User switches settings via Settings tab #group3': function (browser: NightwatchBrowser) {
774774
browser
775775
.perform(() => startFreshTest(browser))
776776
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -800,7 +800,7 @@ module.exports = {
800800
/**
801801
* Simple pattern: Prequeue → Accept → Queue flush to cookie mode
802802
*/
803-
'Prequeue flush to cookie mode #pr #group4': function (browser: NightwatchBrowser) {
803+
'Prequeue flush to cookie mode #group4': function (browser: NightwatchBrowser) {
804804
browser
805805
.perform(() => startFreshTest(browser))
806806
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -817,7 +817,7 @@ module.exports = {
817817
/**
818818
* Simple pattern: Prequeue → Reject → Queue flush to anonymous mode
819819
*/
820-
'Prequeue flush to anonymous mode #pr #group5': function (browser: NightwatchBrowser) {
820+
'Prequeue flush to anonymous mode #group5': function (browser: NightwatchBrowser) {
821821
browser
822822
.perform(() => startFreshTest(browser))
823823
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -834,7 +834,7 @@ module.exports = {
834834
/**
835835
* Simple pattern: Test both tracking methods work with dimension 3
836836
*/
837-
'Event tracking verification (plugin + context) #pr #group6': function (browser: NightwatchBrowser) {
837+
'Event tracking verification (plugin + context) #group6': function (browser: NightwatchBrowser) {
838838
browser
839839
.perform(() => startFreshTest(browser))
840840
.perform(() => setupAndCheckState(browser, 'Initial state'))
@@ -868,7 +868,7 @@ module.exports = {
868868
* 3. Refresh page to trigger expiration check
869869
* 4. Verify consent dialog appears again
870870
*/
871-
'Consent expiration after 6 months #pr #group7': function (browser: NightwatchBrowser) {
871+
'Consent expiration after 6 months #group7': function (browser: NightwatchBrowser) {
872872
browser
873873
.perform(() => startFreshTest(browser))
874874

@@ -952,7 +952,7 @@ module.exports = {
952952
* 3. Test 7 months ago timestamp → should BE expired
953953
* 4. Validate the boundary calculation works correctly
954954
*/
955-
'Consent timestamp boundary test #pr #group8': function (browser: NightwatchBrowser) {
955+
'Consent timestamp boundary test #group8': function (browser: NightwatchBrowser) {
956956
browser
957957
.perform(() => startFreshTest(browser))
958958
.perform(() => rejectConsent(browser)) // User declines analytics

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

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,24 @@ const tests = {
269269
.switchBrowserTab(0) // back to remix
270270
.pause(1000)
271271
.journalChildIncludes('0xec72bbabeb47a3a766af449674a45a91a6e94e35ebf0ae3c644b66def7bd387f1c0b34d970c9f4a1e9398535e5860b35e82b2a8931b7c9046b7766a53e66db3d1b')
272+
},
273+
'Should add and run sendETH script on Sepolia using MetaMask': function (browser: NightwatchBrowser) {
274+
browser
275+
.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
276+
.clickLaunchIcon('filePanel')
277+
.addFile('sendETH.ts', { content: sendETHExample })
278+
.openFile('sendETH.ts')
279+
.pause(2000)
280+
.clearConsole()
281+
.rightClick('li[data-id="treeViewLitreeViewItemsendETH.ts"]')
282+
.waitForElementVisible('*[id="menuitemrun"]')
283+
.click('*[id="menuitemrun"]')
284+
.pause(2000)
285+
.switchBrowserTab(extension_url, true)
286+
.waitForElementPresent('[data-testid="confirm-footer-button"]', 60000)
287+
.scrollAndClick('[data-testid="confirm-footer-button"]')
288+
.switchBrowserTab(0) // back to remix
289+
.waitForElementContainsText('*[data-id="terminalJournal"]', 'Transaction confirmed for', 120000)
272290
} // main network tests
273291
, 'Should connect to Ethereum Main Network using MetaMask': function (browser: NightwatchBrowser) {
274292
browser.waitForElementPresent('*[data-id="remixIdeSidePanel"]')
@@ -341,6 +359,43 @@ const EIP712_Example = {
341359
},
342360
}
343361

362+
const sendETHExample = `
363+
"use strict"
364+
365+
import { ethers } from "ethers"
366+
367+
async function sendEth() {
368+
// Replace these with actual recipient addresses
369+
const recipientAddresses = [
370+
"0xefeaf7647997cc11ae1f99f6add557fa9d70a552"
371+
];
372+
373+
// Amount of ETH to send (0.05 ETH in wei)
374+
const amount = ethers.parseEther("0.005");
375+
376+
// Get provider and signer from Remix environment
377+
const provider = new ethers.BrowserProvider(web3Provider);
378+
const signer = await provider.getSigner();
379+
380+
// Send ETH to each address
381+
for (const address of recipientAddresses) {
382+
383+
try {
384+
const tx = await signer.sendTransaction({
385+
to: address,
386+
value: amount
387+
});
388+
await tx.wait();
389+
console.log("Transaction confirmed for");
390+
} catch (error) {
391+
console.error("Failed to send to ");
392+
}
393+
}
394+
}
395+
396+
sendEth().catch(console.error);
397+
`
398+
344399
const sources = [
345400
{
346401
'Greet.sol': {

apps/remix-ide/src/app/tabs/web3-provider.js

Lines changed: 43 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,52 @@ export class Web3ProviderModule extends Plugin {
2222
this.blockchain = blockchain
2323
}
2424

25+
async updateRemix(txHash) {
26+
const receipt = await this.tryTillReceiptAvailable(txHash)
27+
if (!receipt.contractAddress) {
28+
console.log('receipt available but contract address not present', receipt)
29+
return
30+
}
31+
const contractAddressStr = addressToString(receipt.contractAddress)
32+
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', contractAddressStr)
33+
if (contractData) {
34+
const data = await this.call('compilerArtefacts', 'getCompilerAbstract', contractData.file)
35+
const contractObject = {
36+
name: contractData.name,
37+
abi: contractData.contract.abi,
38+
compiler: data,
39+
contract: {
40+
file : contractData.file,
41+
object: contractData.contract
42+
}
43+
}
44+
this.call('udapp', 'addInstance', contractAddressStr, contractData.contract.abi, contractData.name, contractObject)
45+
await this.call('compilerArtefacts', 'addResolvedContract', contractAddressStr, data)
46+
}
47+
}
48+
49+
async request (payload) {
50+
const res = await this.sendAsync(payload)
51+
if (res && res.error) throw new Error(res.error)
52+
return res.result
53+
}
54+
55+
send (payload) {
56+
return this.sendAsync(payload)
57+
}
58+
2559
/*
2660
that is used by plugins to call the current ethereum provider.
2761
Should be taken carefully and probably not be release as it is now.
2862
*/
2963
sendAsync(payload) {
30-
3164
return new Promise((resolve, reject) => {
3265
this.askUserPermission('sendAsync', `Calling ${payload.method} with parameters ${JSON.stringify(payload.params, replacer, '\t')}`).then(
3366
async (result) => {
3467
if (result) {
35-
const provider = this.blockchain.web3()
68+
const provider = this.blockchain.getProviderObject().provider
3669
const resultFn = async (error, response) => {
37-
let message
38-
// For a non-array of payload, result will be at index 0
39-
if (Array.isArray(response) && !Array.isArray(payload)) message = response[0]
70+
const message = response && response.result && response.result.jsonrpc ? response.result : response
4071
if (error) {
4172
// Handle 'The method "debug_traceTransaction" does not exist / is not available.' error
4273
if(error.message && error.code && error.code === -32601) {
@@ -55,39 +86,20 @@ export class Web3ProviderModule extends Plugin {
5586
return reject(errorMsg)
5687
}
5788
if (payload.method === 'eth_sendTransaction') {
58-
if (payload.params.length && !payload.params[0].to && message.result) {
89+
const txHash = response && response.result && response.result.jsonrpc ? response.result.result : response.result
90+
if (payload.params.length && !payload.params[0].to && txHash) {
91+
this.emit('transactionBroadcasted', txHash)
5992
setTimeout(async () => {
60-
this.emit('transactionBroadcasted', message.result)
61-
const receipt = await this.tryTillReceiptAvailable(message.result)
62-
if (!receipt.contractAddress) {
63-
console.log('receipt available but contract address not present', receipt)
64-
return
65-
}
66-
const contractAddressStr = addressToString(receipt.contractAddress)
67-
const contractData = await this.call('compilerArtefacts', 'getContractDataFromAddress', contractAddressStr)
68-
if (contractData) {
69-
const data = await this.call('compilerArtefacts', 'getCompilerAbstract', contractData.file)
70-
const contractObject = {
71-
name: contractData.name,
72-
abi: contractData.contract.abi,
73-
compiler: data,
74-
contract: {
75-
file : contractData.file,
76-
object: contractData.contract
77-
}
78-
}
79-
this.call('udapp', 'addInstance', contractAddressStr, contractData.contract.abi, contractData.name, contractObject)
80-
await this.call('compilerArtefacts', 'addResolvedContract', contractAddressStr, data)
81-
}
82-
}, 50)
83-
await this.call('blockchain', 'dumpState')
93+
this.updateRemix(txHash)
94+
}, 1000)
95+
this.call('blockchain', 'dumpState')
8496
}
8597
}
8698
resolve(message)
8799
}
88100
try {
89101
// browserProvider._send(payload: JsonRpcPayload | Array<JsonRpcPayload>) => Promise<Array<JsonRpcResult | JsonRpcError>>
90-
resultFn(null, await provider._send(payload))
102+
resultFn(null, await provider.send(payload))
91103
} catch (e) {
92104
resultFn(e.error ? e.error : e)
93105
}

apps/remix-ide/src/app/udapp/run-tab.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,9 @@ class Provider {
462462
sendAsync (payload) {
463463
return this.udapp.call(this.name, 'sendAsync', payload)
464464
}
465+
send (payload) {
466+
return this.udapp.call(this.name, 'sendAsync', payload)
467+
}
465468
request (payload): Promise<any> {
466469
return new Promise((resolve, reject) => {
467470
this.udapp.call(this.name, 'sendAsync', payload).then((response) => {

0 commit comments

Comments
 (0)