From 3cc45847edda0e958cab3dbfa43e7668fb84293a Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 20 Dec 2023 14:40:00 +0100 Subject: [PATCH] onload strategy --- .circleci/config.yml | 2 +- apps/etherscan/src/app/app.tsx | 35 ++++++++++++------- .../src/tests/etherscan_api.test.ts | 2 +- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 37f51f6747..3437b7e9a7 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -3,7 +3,7 @@ version: 2.1 parameters: run_flaky_tests: type: boolean - default: false + default: true orbs: browser-tools: circleci/browser-tools@1.4.4 win: circleci/windows@5.0 diff --git a/apps/etherscan/src/app/app.tsx b/apps/etherscan/src/app/app.tsx index 39e89e00d7..eacffaf600 100644 --- a/apps/etherscan/src/app/app.tsx +++ b/apps/etherscan/src/app/app.tsx @@ -40,22 +40,31 @@ const App = () => { contractsRef.current = contracts - useEffect(() => { - plugin.internalEvents.on('etherscan_activated', () => { - plugin.on('solidity', 'compilationFinished', (fileName: string, source: CompilationFileSources, languageVersion: string, data: CompilationResult) => { - const newContractsNames = getNewContractNames(data) + const setListeners = () => { + plugin.on('solidity', 'compilationFinished', (fileName: string, source: CompilationFileSources, languageVersion: string, data: CompilationResult) => { + const newContractsNames = getNewContractNames(data) + + const newContractsToSave: string[] = [...contractsRef.current, ...newContractsNames] - const newContractsToSave: string[] = [...contractsRef.current, ...newContractsNames] + const uniqueContracts: string[] = [...new Set(newContractsToSave)] + + setContracts(uniqueContracts) + }) + plugin.on('blockchain' as any, 'networkStatus', (result) => { + setNetworkName(`${result.network.name} ${result.network.id !== '-' ? `(Chain id: ${result.network.id})` : '(Not supported)'}`) + }) + // @ts-ignore + plugin.call('blockchain', 'getCurrentNetworkStatus').then((result: any) => setNetworkName(`${result.network.name} ${result.network.id !== '-' ? `(Chain id: ${result.network.id})` : '(Not supported)'}`)) - const uniqueContracts: string[] = [...new Set(newContractsToSave)] + } - setContracts(uniqueContracts) - }) - plugin.on('blockchain' as any, 'networkStatus', (result) => { - setNetworkName(`${result.network.name} ${result.network.id !== '-' ? `(Chain id: ${result.network.id})` : '(Not supported)'}`) - }) - // @ts-ignore - plugin.call('blockchain', 'getCurrentNetworkStatus').then((result: any) => setNetworkName(`${result.network.name} ${result.network.id !== '-' ? `(Chain id: ${result.network.id})` : '(Not supported)'}`)) + useEffect(() => { + plugin.onload(() => { + console.log('plugin loaded') + console.log(plugin.isLoaded) + setListeners() + }) + plugin.internalEvents.on('etherscan_activated', () => { }) }, []) diff --git a/apps/remix-ide-e2e/src/tests/etherscan_api.test.ts b/apps/remix-ide-e2e/src/tests/etherscan_api.test.ts index 6157d77ca2..14e2891f98 100644 --- a/apps/remix-ide-e2e/src/tests/etherscan_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/etherscan_api.test.ts @@ -24,7 +24,7 @@ module.exports = { .click('[data-id="save-api-key"]') }, - 'Should verify a contract (contract is already verified) #group1': function (browser: NightwatchBrowser) { + 'Should verify a contract (contract is already verified) #group1 #flaky': function (browser: NightwatchBrowser) { browser .frameParent() .clickLaunchIcon('udapp') // switch to Goerli