From b56a210f7bef39a2eccd264136e0641af4db98c9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 23 May 2022 14:10:27 +0530 Subject: [PATCH 01/24] oxProject ws template --- .../workspace/src/lib/remix-ui-workspace.tsx | 1 + libs/remix-ws-templates/src/index.ts | 1 + .../templates/ozerc721/scripts/ethers-lib.ts | 2 ++ .../templates/ozerc721/scripts/web3-lib.ts | 3 ++ .../zeroxErc20/contracts/SampleERC20.sol | 31 +++++++++++++++++++ .../src/templates/zeroxErc20/index.ts | 16 ++++++++++ .../zeroxErc20/scripts/deploy_with_ethers.ts | 10 ++++++ .../zeroxErc20/scripts/deploy_with_web3.ts | 10 ++++++ .../zeroxErc20/scripts/ethers-lib.ts | 26 ++++++++++++++++ .../templates/zeroxErc20/scripts/web3-lib.ts | 27 ++++++++++++++++ .../zeroxErc20/tests/SampleERC20_test.sol | 18 +++++++++++ 11 files changed, 145 insertions(+) create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/contracts/SampleERC20.sol create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/index.ts create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_ethers.ts create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_web3.ts create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts create mode 100644 libs/remix-ws-templates/src/templates/zeroxErc20/tests/SampleERC20_test.sol diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index 293b6d63cc..a32aec4b0a 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -134,6 +134,7 @@ export function Workspace () { + diff --git a/libs/remix-ws-templates/src/index.ts b/libs/remix-ws-templates/src/index.ts index 011ddba170..9e12a868c8 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,4 +1,5 @@ export { default as remixDefault } from './templates/remixDefault' export { default as blank } from './templates/blank' export { default as ozerc20 } from './templates/ozerc20' +export { default as zeroxErc20 } from './templates/zeroxErc20' export { default as ozerc721 } from './templates/ozerc721' 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 0cb00c7e47..1c5f4c6548 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,3 +1,5 @@ +import { ethers } from 'ethers' + export const deploy = async (contractName: string, args: Array, from?: string): Promise => { console.log(`deploying ${contractName}`) 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 62f43b6611..37ff2be99b 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,8 @@ +import Web3 from 'web3' + export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + const web3 = new Web3(window.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/contracts/SampleERC20.sol b/libs/remix-ws-templates/src/templates/zeroxErc20/contracts/SampleERC20.sol new file mode 100644 index 0000000000..ecea8b4aa3 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/contracts/SampleERC20.sol @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity ^0.5.9; + +import "@0x/contracts-erc20/contracts/src/ERC20Token.sol"; + +/** + * @title SampleERC20 + * @dev Create a sample ERC20 standard token + */ +contract SampleERC20 is ERC20Token { + + string public name; + string public symbol; + uint256 public decimals; + + constructor ( + string memory _name, + string memory _symbol, + uint256 _decimals, + uint256 _totalSupply + ) + public + { + name = _name; + symbol = _symbol; + decimals = _decimals; + _totalSupply = _totalSupply; + balances[msg.sender] = _totalSupply; + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/index.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/index.ts new file mode 100644 index 0000000000..48ffb45341 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/index.ts @@ -0,0 +1,16 @@ +export default async () => { + return { + // @ts-ignore + 'contracts/SampleERC20.sol': (await import('raw-loader!./contracts/SampleERC20.sol')).default, + // @ts-ignore + 'scripts/deploy_with_ethers.ts': (await import('!!raw-loader!./scripts/deploy_with_ethers.ts')).default, + // @ts-ignore + 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, + // @ts-ignore + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, + // @ts-ignore + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, + // @ts-ignore + 'tests/SampleERC20_test.sol': (await import('raw-loader!./tests/SampleERC20_test.sol')).default + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_ethers.ts new file mode 100644 index 0000000000..ad2fd4597a --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_ethers.ts @@ -0,0 +1,10 @@ +import { deploy } from './ethers-lib' + +(async () => { + try { + const result = await deploy('SampleERC20', ["TestToken", "TST", 18, 1000]) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } + })() \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_web3.ts new file mode 100644 index 0000000000..af6af1c8a4 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_web3.ts @@ -0,0 +1,10 @@ +import { deploy } from './web3-lib' + +(async () => { + try { + const result = await deploy('SampleERC20', ["TestToken", "TST", 18, 1000]) + console.log(`address: ${result.address}`) + } catch (e) { + console.log(e.message) + } +})() \ No newline at end of file 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 new file mode 100644 index 0000000000..1c5f4c6548 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts @@ -0,0 +1,26 @@ +import { ethers } from 'ethers' + +export const deploy = async (contractName: string, args: Array, from?: string): 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 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 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); + } + + // The contract is NOT deployed yet; we must wait until it is mined + await contract.deployed() + return contract +} \ No newline at end of file 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 new file mode 100644 index 0000000000..37ff2be99b --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/scripts/web3-lib.ts @@ -0,0 +1,27 @@ +import Web3 from 'web3' + +export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { + + const web3 = new Web3(window.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` + + const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) + + const accounts = await web3.eth.getAccounts() + + let contract = new web3.eth.Contract(metadata.abi) + + contract = contract.deploy({ + data: metadata.data.bytecode.object, + arguments: args + }) + + const newContractInstance = await contract.send({ + from: from || accounts[0], + gas: gas || 1500000 + }) + return newContractInstance.options +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/zeroxErc20/tests/SampleERC20_test.sol b/libs/remix-ws-templates/src/templates/zeroxErc20/tests/SampleERC20_test.sol new file mode 100644 index 0000000000..b167e1a478 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/zeroxErc20/tests/SampleERC20_test.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity ^0.5.9; +import "remix_tests.sol"; +import "../contracts/SampleERC20.sol"; + +contract SampleERC20Test { + + SampleERC20 s; + function beforeAll () public { + s = new SampleERC20("TestToken", "TST", 18, 1000); + } + + function testTokenNameAndSymbol () public { + Assert.equal(s.name(), "TestToken", "token name did not match"); + Assert.equal(s.symbol(), "TST", "token symbol did not match"); + } +} \ No newline at end of file From 687019e2ac3183947bdfc5411e3aff06f7f9ec29 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 23 May 2022 18:49:25 +0530 Subject: [PATCH 02/24] removed unneccessary logging --- libs/remix-ui/editor/src/lib/web-types.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libs/remix-ui/editor/src/lib/web-types.ts b/libs/remix-ui/editor/src/lib/web-types.ts index 1c82788d30..2ac05a5d26 100644 --- a/libs/remix-ui/editor/src/lib/web-types.ts +++ b/libs/remix-ui/editor/src/lib/web-types.ts @@ -156,13 +156,11 @@ export const loadTypes = async (monaco) => { // @ts-ignore const versionEthers = await import('raw-loader!ethers/lib/_version.d.ts') versionEthers.default = versionEthers.default.replace(/@ethersproject\//g, '@ethersproject_') - console.log(versionEthers.default) monaco.languages.typescript.typescriptDefaults.addExtraLib(versionEthers.default, `file:///node_modules/@types/_version-ethers-lib/index.d.ts`) // @ts-ignore const utilEthers = await import('raw-loader!ethers/lib/utils.d.ts') utilEthers.default = utilEthers.default.replace(/@ethersproject\//g, '@ethersproject_') - console.log(utilEthers.default) monaco.languages.typescript.typescriptDefaults.addExtraLib(utilEthers.default, `file:///node_modules/@types/utils-ethers-lib/index.d.ts`) // @ts-ignore @@ -171,14 +169,12 @@ export const loadTypes = async (monaco) => { ethers.default = ethers.default.replace(/.\/_version/g, '_version-ethers-lib') ethers.default = ethers.default.replace(/.\/ethers/g, 'ethers-lib') ethers.default = ethers.default.replace(/@ethersproject\//g, '@ethersproject_') - console.log(ethers.default) monaco.languages.typescript.typescriptDefaults.addExtraLib(ethers.default, `file:///node_modules/@types/ethers-lib/index.d.ts`) // @ts-ignore const indexEthers = await import('raw-loader!ethers/lib/index.d.ts') indexEthers.default = indexEthers.default.replace(/.\/ethers/g, 'ethers-lib') indexEthers.default = indexEthers.default.replace(/@ethersproject\//g, '@ethersproject_') - console.log(indexEthers.default) monaco.languages.typescript.typescriptDefaults.addExtraLib(indexEthers.default, `file:///node_modules/@types/ethers/index.d.ts`) // Web3 From 8b5e7a53f7c3474b80d9eca2bb787ea167b9501a Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 24 May 2022 10:20:50 +0200 Subject: [PATCH 03/24] Update compiler_api.test.ts --- apps/remix-ide-e2e/src/tests/compiler_api.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts index 8a6ca27cd3..2adc5a4c62 100644 --- a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts @@ -46,7 +46,7 @@ module.exports = { browser .addFile('test_updateConfiguration.js', { content: updateConfiguration }) .executeScript('remix.exeCurrent()') - .pause(5000) + .pause(15000) .addFile('test_updateConfiguration.sol', { content: simpleContract }) .verifyContracts(['StorageTestUpdateConfiguration'], { wait: 5000, version: '0.6.8+commit.0bbfe453' }) }, From 5cbdb05cada0720f0c86602045ddead06c4f3b11 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 24 May 2022 14:20:46 +0530 Subject: [PATCH 04/24] timeout update --- apps/remix-ide-e2e/src/tests/compiler_api.test.ts | 2 +- apps/remix-ide-e2e/src/tests/plugin_api.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts index 2adc5a4c62..170439ea76 100644 --- a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts @@ -46,7 +46,7 @@ module.exports = { browser .addFile('test_updateConfiguration.js', { content: updateConfiguration }) .executeScript('remix.exeCurrent()') - .pause(15000) + .pause(10000) .addFile('test_updateConfiguration.sol', { content: simpleContract }) .verifyContracts(['StorageTestUpdateConfiguration'], { wait: 5000, version: '0.6.8+commit.0bbfe453' }) }, diff --git a/apps/remix-ide-e2e/src/tests/plugin_api.ts b/apps/remix-ide-e2e/src/tests/plugin_api.ts index d0cdfacf13..8409cb935d 100644 --- a/apps/remix-ide-e2e/src/tests/plugin_api.ts +++ b/apps/remix-ide-e2e/src/tests/plugin_api.ts @@ -409,7 +409,7 @@ module.exports = { .addFile('test_modal.js', { content: testModalToasterApi }) .executeScript('remix.execute(\'test_modal.js\')') .useCss() - .waitForElementVisible('*[data-id="test_id_1_ModalDialogModalBody-react"]') + .waitForElementVisible('*[data-id="test_id_1_ModalDialogModalBody-react"]', 60000) .assert.containsText('*[data-id="test_id_1_ModalDialogModalBody-react"]', 'message 1') .modalFooterOKClick('test_id_1_') // check the script runner notifications From 965ba187725d00a64b295d64090099726176b3a6 Mon Sep 17 00:00:00 2001 From: Aniket <30843294+Aniket-Engg@users.noreply.github.com> Date: Tue, 24 May 2022 14:51:05 +0530 Subject: [PATCH 05/24] Update compiler_api.test.ts --- apps/remix-ide-e2e/src/tests/compiler_api.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts index 170439ea76..2adc5a4c62 100644 --- a/apps/remix-ide-e2e/src/tests/compiler_api.test.ts +++ b/apps/remix-ide-e2e/src/tests/compiler_api.test.ts @@ -46,7 +46,7 @@ module.exports = { browser .addFile('test_updateConfiguration.js', { content: updateConfiguration }) .executeScript('remix.exeCurrent()') - .pause(10000) + .pause(15000) .addFile('test_updateConfiguration.sol', { content: simpleContract }) .verifyContracts(['StorageTestUpdateConfiguration'], { wait: 5000, version: '0.6.8+commit.0bbfe453' }) }, From b41020e800ad658d1c9bd5f8d3aa89da9c464aa6 Mon Sep 17 00:00:00 2001 From: David Disu Date: Sun, 22 May 2022 17:25:14 +0100 Subject: [PATCH 06/24] Hide backup and restore workspaces for localhost --- libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx index a32aec4b0a..9e0b0a0f04 100644 --- a/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx +++ b/libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx @@ -193,7 +193,7 @@ export function Workspace () { title='Delete'>