From 78556af4d7206e303a4814660747782a48728bd7 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 Jun 2022 13:20:53 +0200 Subject: [PATCH 1/4] fix typescript error --- .../src/templates/ozerc20/scripts/web3-lib.ts | 2 +- .../src/templates/ozerc721/scripts/web3-lib.ts | 2 +- .../src/templates/remixDefault/scripts/web3-lib.ts | 2 +- .../src/templates/zeroxErc20/scripts/web3-lib.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts index 37ff2be99b6..3c1565a0721 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts @@ -2,7 +2,7 @@ import Web3 from 'web3' export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - const web3 = new Web3(window.web3Provider) + const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts index 37ff2be99b6..3c1565a0721 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts @@ -2,7 +2,7 @@ import Web3 from 'web3' export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - const web3 = new Web3(window.web3Provider) + const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts index 9ec1a2d864b..f9dcdc3f89c 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts @@ -2,7 +2,7 @@ import Web3 from 'web3' export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - const web3 = new Web3(window.web3Provider) + const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts index 37ff2be99b6..3c1565a0721 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts @@ -2,7 +2,7 @@ import Web3 from 'web3' export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { - const web3 = new Web3(window.web3Provider) + const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated From 69dd6e0dd4f374b042483ecd3e7be1be04480b95 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 Jun 2022 13:59:35 +0200 Subject: [PATCH 2/4] fix monaco typescript error with --- libs/remix-ui/editor/src/lib/web-types.ts | 4 ++++ .../templates/ozerc20/scripts/ethers-lib.ts | 21 +++++++++++-------- .../src/templates/ozerc20/scripts/web3-lib.ts | 17 +++++++++++---- .../templates/ozerc721/scripts/ethers-lib.ts | 21 +++++++++++-------- .../templates/ozerc721/scripts/web3-lib.ts | 17 +++++++++++---- .../remixDefault/scripts/ethers-lib.ts | 19 ++++++++++------- .../remixDefault/scripts/web3-lib.ts | 19 ++++++++++++----- .../zeroxErc20/scripts/ethers-lib.ts | 21 +++++++++++-------- .../templates/zeroxErc20/scripts/web3-lib.ts | 17 +++++++++++---- 9 files changed, 104 insertions(+), 52 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/web-types.ts b/libs/remix-ui/editor/src/lib/web-types.ts index 2ac05a5d260..065e4557bd1 100644 --- a/libs/remix-ui/editor/src/lib/web-types.ts +++ b/libs/remix-ui/editor/src/lib/web-types.ts @@ -199,6 +199,10 @@ export const loadTypes = async (monaco) => { const indexWeb3Personal = await import('raw-loader!web3-eth-personal/types/index.d.ts') monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Personal.default, `file:///node_modules/@types/web3-eth-personal/index.d.ts`) + // @ts-ignore + const indexWeb3Contract = await import('raw-loader!web3-eth-contract/types/index.d.ts') + monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Contract.default, `file:///node_modules/@types/web3-eth-contract/index.d.ts`) + // @ts-ignore const indexWeb3Net = await import('raw-loader!web3-net/types/index.d.ts') monaco.languages.typescript.typescriptDefaults.addExtraLib(indexWeb3Net.default, `file:///node_modules/@types/web3-net/index.d.ts`) diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts index 1c5f4c65486..99439abd496 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts @@ -1,24 +1,27 @@ import { ethers } from 'ethers' -export const deploy = async (contractName: string, args: Array, from?: string): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} acountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated - const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } + let contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts index 3c1565a0721..be0c09a4ab6 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts @@ -1,6 +1,15 @@ import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) @@ -12,14 +21,14 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract = new web3.eth.Contract(metadata.abi) + let contract: Contract = new web3.eth.Contract(metadata.abi) - contract = contract.deploy({ + let contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) - const newContractInstance = await contract.send({ + const newContractInstance = await contractSend.send({ from: from || accounts[0], gas: gas || 1500000 }) diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts index 1c5f4c65486..99439abd496 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts @@ -1,24 +1,27 @@ import { ethers } from 'ethers' -export const deploy = async (contractName: string, args: Array, from?: string): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} acountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated - const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } + let contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts index 3c1565a0721..be0c09a4ab6 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts @@ -1,6 +1,15 @@ import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) @@ -12,14 +21,14 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract = new web3.eth.Contract(metadata.abi) + let contract: Contract = new web3.eth.Contract(metadata.abi) - contract = contract.deploy({ + let contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) - const newContractInstance = await contract.send({ + const newContractInstance = await contractSend.send({ from: from || accounts[0], gas: gas || 1500000 }) diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts index 40a478efbb2..99439abd496 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts @@ -1,6 +1,13 @@ import { ethers } from 'ethers' -export const deploy = async (contractName: string, args: Array, from?: string): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} acountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -9,16 +16,12 @@ export const deploy = async (contractName: string, args: Array, from?: stri const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } + let contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts index f9dcdc3f89c..be0c09a4ab6 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts @@ -1,25 +1,34 @@ import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated - const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) const accounts = await web3.eth.getAccounts() - let contract = new web3.eth.Contract(metadata.abi) + let contract: Contract = new web3.eth.Contract(metadata.abi) - contract = contract.deploy({ + let contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) - const newContractInstance = await contract.send({ + const newContractInstance = await contractSend.send({ from: from || accounts[0], gas: gas || 1500000 }) diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts index 1c5f4c65486..99439abd496 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts @@ -1,24 +1,27 @@ import { ethers } from 'ethers' -export const deploy = async (contractName: string, args: Array, from?: string): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {Number} acountIndex account index from the exposed account + * @return {Contract} deployed contract + */ +export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. // Make sure contract is compiled and artifacts are generated - const artifactsPath = `browser/contracts/artifacts/${contractName}.json` + const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() + + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); - let contract - if (from) { - contract = await factory.connect(from).deploy(...args); - } else { - contract = await factory.deploy(...args); - } + let contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts index 3c1565a0721..be0c09a4ab6 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts @@ -1,6 +1,15 @@ import Web3 from 'web3' +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; -export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { +/** + * Deploy the given contract + * @param {string} contractName name of the contract to deploy + * @param {Array} args list of constructor' parameters + * @param {string} from account used to send the transaction + * @param {number} gas gas limit + * @return {Options} deployed contract + */ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { const web3 = new Web3(web3Provider) console.log(`deploying ${contractName}`) @@ -12,14 +21,14 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract = new web3.eth.Contract(metadata.abi) + let contract: Contract = new web3.eth.Contract(metadata.abi) - contract = contract.deploy({ + let contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) - const newContractInstance = await contract.send({ + const newContractInstance = await contractSend.send({ from: from || accounts[0], gas: gas || 1500000 }) From 65cb7af38b73caf253bdac2e64eac1b0120149a2 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 Jun 2022 14:24:38 +0200 Subject: [PATCH 3/4] fix e2e test --- apps/remix-ide-e2e/src/tests/search.test.ts | 4 ++-- apps/remix-ide-e2e/src/tests/workspace.test.ts | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/search.test.ts b/apps/remix-ide-e2e/src/tests/search.test.ts index f7925fb9ead..b2cff57b7cc 100644 --- a/apps/remix-ide-e2e/src/tests/search.test.ts +++ b/apps/remix-ide-e2e/src/tests/search.test.ts @@ -33,11 +33,11 @@ module.exports = { .clearValue('*[id="search_include"]').pause(2000) .setValue('*[id="search_include"]', '**').sendKeys('*[id="search_include"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 48) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 61) }) .setValue('*[id="search_exclude"]', ',contracts/**').sendKeys('*[id="search_exclude"]', browser.Keys.ENTER).pause(4000) .elements('css selector', '.search_plugin_search_line', (res) => { - Array.isArray(res.value) && browser.assert.equal(res.value.length, 42) + Array.isArray(res.value) && browser.assert.equal(res.value.length, 55) }) .clearValue('*[id="search_include"]').setValue('*[id="search_include"]', '*.sol, *.js, *.txt') .clearValue('*[id="search_exclude"]').setValue('*[id="search_exclude"]', '.*/**/*') diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 0c36951a76b..bfb210167e4 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -68,14 +68,14 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .pause(2000) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') @@ -145,14 +145,14 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') @@ -193,14 +193,14 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') From bfb90d554f70b0340a731fd1780fa4a05b3f1411 Mon Sep 17 00:00:00 2001 From: yann300 Date: Mon, 6 Jun 2022 16:14:03 +0200 Subject: [PATCH 4/4] linting --- apps/remix-ide-e2e/src/tests/terminal.test.ts | 8 ++++---- apps/remix-ide-e2e/src/tests/workspace.test.ts | 6 +++--- .../src/templates/ozerc20/scripts/ethers-lib.ts | 10 +++++----- .../src/templates/ozerc20/scripts/web3-lib.ts | 6 +++--- .../src/templates/ozerc721/scripts/ethers-lib.ts | 10 +++++----- .../src/templates/ozerc721/scripts/web3-lib.ts | 6 +++--- .../src/templates/remixDefault/scripts/ethers-lib.ts | 10 +++++----- .../src/templates/remixDefault/scripts/web3-lib.ts | 6 +++--- .../src/templates/zeroxErc20/scripts/ethers-lib.ts | 10 +++++----- .../src/templates/zeroxErc20/scripts/web3-lib.ts | 6 +++--- 10 files changed, 39 insertions(+), 39 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/terminal.test.ts b/apps/remix-ide-e2e/src/tests/terminal.test.ts index fb828248fe5..a824c7871fc 100644 --- a/apps/remix-ide-e2e/src/tests/terminal.test.ts +++ b/apps/remix-ide-e2e/src/tests/terminal.test.ts @@ -291,7 +291,7 @@ const deployWithEthersJs = ` // 'web3Provider' is a remix global variable object const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) let contract = await factory.deploy(...constructorArgs); @@ -320,7 +320,7 @@ describe("Storage with lib", function () { // Make sure contract is compiled and artifacts are generated const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json')) const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) let storage = await Storage.deploy(); console.log('storage contract Address: ' + storage.address); await storage.deployed() @@ -330,7 +330,7 @@ describe("Storage with lib", function () { it("test updating and retrieving updated value", async function () { const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json')) const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) let storage = await Storage.deploy(); await storage.deployed() const setValue = await storage.store(56); @@ -341,7 +341,7 @@ describe("Storage with lib", function () { it("fail test updating and retrieving updated value", async function () { const metadata = JSON.parse(await remix.call('fileManager', 'getFile', 'contracts/artifacts/Storage.json')) const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner() - let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) let storage = await Storage.deploy(); await storage.deployed() const setValue = await storage.store(56); diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index bfb210167e4..7e7cfbd55ee 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -75,7 +75,7 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') @@ -152,7 +152,7 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') @@ -200,7 +200,7 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(100) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => {`) !== -1, + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => {`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts index 99439abd496..e875db9a436 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts @@ -4,10 +4,10 @@ import { ethers } from 'ethers' * Deploy the given contract * @param {string} contractName name of the contract to deploy * @param {Array} args list of constructor' parameters - * @param {Number} acountIndex account index from the exposed account + * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -17,11 +17,11 @@ export const deploy = async (contractName: string, args: Array, acountIndex const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) - const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - let contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts index be0c09a4ab6..cbffde3aac8 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/scripts/web3-lib.ts @@ -1,5 +1,5 @@ import Web3 from 'web3' -import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' /** * Deploy the given contract @@ -21,9 +21,9 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) - let contractSend: ContractSendMethod = contract.deploy({ + const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts index 99439abd496..e875db9a436 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts @@ -4,10 +4,10 @@ import { ethers } from 'ethers' * Deploy the given contract * @param {string} contractName name of the contract to deploy * @param {Array} args list of constructor' parameters - * @param {Number} acountIndex account index from the exposed account + * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -17,11 +17,11 @@ export const deploy = async (contractName: string, args: Array, acountIndex const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) - const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - let contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts index be0c09a4ab6..cbffde3aac8 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts @@ -1,5 +1,5 @@ import Web3 from 'web3' -import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' /** * Deploy the given contract @@ -21,9 +21,9 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) - let contractSend: ContractSendMethod = contract.deploy({ + const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts index 99439abd496..e875db9a436 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts @@ -4,10 +4,10 @@ import { ethers } from 'ethers' * Deploy the given contract * @param {string} contractName name of the contract to deploy * @param {Array} args list of constructor' parameters - * @param {Number} acountIndex account index from the exposed account + * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -17,11 +17,11 @@ export const deploy = async (contractName: string, args: Array, acountIndex const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) - const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - let contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts index be0c09a4ab6..cbffde3aac8 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/scripts/web3-lib.ts @@ -1,5 +1,5 @@ import Web3 from 'web3' -import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' /** * Deploy the given contract @@ -21,9 +21,9 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) - let contractSend: ContractSendMethod = contract.deploy({ + const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args }) diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts index 99439abd496..e875db9a436 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts @@ -4,10 +4,10 @@ import { ethers } from 'ethers' * Deploy the given contract * @param {string} contractName name of the contract to deploy * @param {Array} args list of constructor' parameters - * @param {Number} acountIndex account index from the exposed account + * @param {Number} accountIndex account index from the exposed account * @return {Contract} deployed contract */ -export const deploy = async (contractName: string, args: Array, acountIndex?: number): Promise => { +export const deploy = async (contractName: string, args: Array, accountIndex?: number): Promise => { console.log(`deploying ${contractName}`) // Note that the script needs the ABI which is generated from the compilation artifact. @@ -17,11 +17,11 @@ export const deploy = async (contractName: string, args: Array, acountIndex const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) // 'web3Provider' is a remix global variable object - const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(acountIndex) + const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(accountIndex) - const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer); + const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer) - let contract = await factory.deploy(...args) + const contract = await factory.deploy(...args) // The contract is NOT deployed yet; we must wait until it is mined await contract.deployed() diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts index be0c09a4ab6..cbffde3aac8 100644 --- a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts @@ -1,5 +1,5 @@ import Web3 from 'web3' -import { Contract, ContractSendMethod, Options } from 'web3-eth-contract'; +import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' /** * Deploy the given contract @@ -21,9 +21,9 @@ export const deploy = async (contractName: string, args: Array, from?: stri const accounts = await web3.eth.getAccounts() - let contract: Contract = new web3.eth.Contract(metadata.abi) + const contract: Contract = new web3.eth.Contract(metadata.abi) - let contractSend: ContractSendMethod = contract.deploy({ + const contractSend: ContractSendMethod = contract.deploy({ data: metadata.data.bytecode.object, arguments: args })