From 699d1a084853a99267baef3b48fac518a2903c74 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 18 May 2022 14:43:49 +0530 Subject: [PATCH 01/64] oz721 template added --- .../workspace/src/lib/remix-ui-workspace.tsx | 1 + libs/remix-ws-templates/src/index.ts | 3 ++- .../src/templates/ozerc20/index.ts | 4 +-- .../ozerc721/contracts/SampleERC721.sol | 14 ++++++++++ .../src/templates/ozerc721/index.ts | 16 +++++++++++ .../ozerc721/scripts/deploy_with_ethers.ts | 10 +++++++ .../ozerc721/scripts/deploy_with_web3.ts | 10 +++++++ .../src/templates/ozerc721/scripts/ethers.ts | 27 +++++++++++++++++++ .../src/templates/ozerc721/scripts/web3.ts | 24 +++++++++++++++++ .../ozerc721/tests/SampleERC721_test.sol | 18 +++++++++++++ .../src/templates/remixDefault/index.ts | 6 ++--- 11 files changed, 127 insertions(+), 6 deletions(-) create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/index.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/scripts/web3.ts create mode 100644 libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_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 70551c701f..293b6d63cc 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 bf130689f2..011ddba170 100644 --- a/libs/remix-ws-templates/src/index.ts +++ b/libs/remix-ws-templates/src/index.ts @@ -1,3 +1,4 @@ export { default as remixDefault } from './templates/remixDefault' +export { default as blank } from './templates/blank' export { default as ozerc20 } from './templates/ozerc20' -export { default as blank } from './templates/blank' \ No newline at end of file +export { default as ozerc721 } from './templates/ozerc721' diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 4e876a57d6..4a408b979f 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -3,9 +3,9 @@ export default async () => { // @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, + '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, + '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 diff --git a/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol b/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol new file mode 100644 index 0000000000..5a0d40c8e3 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/contracts/SampleERC721.sol @@ -0,0 +1,14 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; + +import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; + +/** + * @title SampleERC721 + * @dev Create a sample ERC721 standard token + */ +contract SampleERC721 is ERC721 { + + constructor(string memory tokenName, string memory tokenSymbol) ERC721(tokenName, tokenSymbol) {} +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts new file mode 100644 index 0000000000..4d27a7295a --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -0,0 +1,16 @@ +export default async () => { + return { + // @ts-ignore + 'contracts/SampleERC721.sol': (await import('raw-loader!./contracts/SampleERC721.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.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, + // @ts-ignore + 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, + // @ts-ignore + 'tests/SampleERC721_test.sol': (await import('raw-loader!./tests/SampleERC721_test.sol')).default + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts new file mode 100644 index 0000000000..16a5635ee9 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts @@ -0,0 +1,10 @@ +import { deploy } from './ethers' + +(async () => { + try { + const result = await deploy('SampleERC721', ['testNFT', 'TNFT']) + 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/ozerc721/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts new file mode 100644 index 0000000000..5fc0b3d01b --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts @@ -0,0 +1,10 @@ +import { deploy } from './web3' + +(async () => { + try { + const result = await deploy('SampleERC721', ['testToken', 'TST']) + 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/ozerc721/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts new file mode 100644 index 0000000000..04c363322a --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts @@ -0,0 +1,27 @@ + + + +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/ozerc721/scripts/web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3.ts new file mode 100644 index 0000000000..62f43b6611 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3.ts @@ -0,0 +1,24 @@ +export const deploy = async (contractName: string, args: Array, from?: string, gas?: 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 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/ozerc721/tests/SampleERC721_test.sol b/libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_test.sol new file mode 100644 index 0000000000..27a4c46826 --- /dev/null +++ b/libs/remix-ws-templates/src/templates/ozerc721/tests/SampleERC721_test.sol @@ -0,0 +1,18 @@ +// SPDX-License-Identifier: GPL-3.0 + +pragma solidity >=0.7.0 <0.9.0; +import "remix_tests.sol"; +import "../contracts/SampleERC721.sol"; + +contract SampleERC721Test { + + SampleERC721 s; + function beforeAll () public { + s = new SampleERC721("TestNFT", "TNFT"); + } + + function testTokenNameAndSymbol () public { + Assert.equal(s.name(), "TestNFT", "token name did not match"); + Assert.equal(s.symbol(), "TNFT", "token symbol did not match"); + } +} \ No newline at end of file diff --git a/libs/remix-ws-templates/src/templates/remixDefault/index.ts b/libs/remix-ws-templates/src/templates/remixDefault/index.ts index cf24859bd5..180f155113 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/index.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/index.ts @@ -7,9 +7,9 @@ export default async () => { // @ts-ignore 'contracts/3_Ballot.sol': (await import('raw-loader!./contracts/3_Ballot.sol')).default, // @ts-ignore - 'scripts/deploy_with_ethers.ts': (await import('raw-loader!./scripts/deploy_with_ethers.ts')).default, + '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, + '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 @@ -17,7 +17,7 @@ export default async () => { // @ts-ignore 'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default, // @ts-ignore - 'tests/storage.test.js': (await import('raw-loader!./tests/storage.test.js')).default, + 'tests/storage.test.js': (await import('!!raw-loader!./tests/storage.test.js')).default, // @ts-ignore 'README.txt': (await import('raw-loader!./README.txt')).default, } From b0b2cb1b859174d7e74ff35989e980f14641b9a7 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 18 May 2022 16:28:40 +0530 Subject: [PATCH 02/64] add e2e --- .../remix-ide-e2e/src/tests/workspace.test.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index e8bde35140..f9d2a0f4c0 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -104,6 +104,29 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC20_test.sol"]') }, + 'Should create ERC721 workspace with files': function (browser: NightwatchBrowser) { + browser + .click('*[data-id="workspaceCreate"]') + .waitForElementVisible('*[data-id="modalDialogCustomPromptTextCreate"]') + .waitForElementVisible('[data-id="fileSystemModalDialogModalFooter-react"] > span') + // eslint-disable-next-line dot-notation + .execute(function () { document.querySelector('*[data-id="modalDialogCustomPromptTextCreate"]')['value'] = 'workspace_erc721' }) + .click('select[id="wstemplate"]') + .click('select[id="wstemplate"] option[value=ozerc721]') + .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') + .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) + .pause(1000) + .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC721.sol"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC721_test.sol"]') + }, + // WORKSPACE TEMPLATES E2E END 'Should create two workspace and switch to the first one': function (browser: NightwatchBrowser) { From 293d59c58f83bc5ab2b940d3569bcdb5fda0729a Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 18 May 2022 17:08:53 +0530 Subject: [PATCH 03/64] check js ts file content --- apps/remix-ide-e2e/src/tests/workspace.test.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index f9d2a0f4c0..a0ade809f7 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -50,11 +50,24 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/3_Ballot.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') + .click('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`const { expect } = require("chai"); + const { ethers } = require("hardhat");`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/Ballot_test.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemREADME.txt"]') }, From c74696ceb68e729ada828c1238cf7a28ede94cf4 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Wed, 18 May 2022 17:39:09 +0530 Subject: [PATCH 04/64] content fix in e2e --- apps/remix-ide-e2e/src/tests/workspace.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index a0ade809f7..e3ab2fc562 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -64,8 +64,7 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') .click('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`const { expect } = require("chai"); - const { ethers } = require("hardhat");`) !== -1, + browser.assert.ok(content.indexOf(`const { expect } = require("chai");`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/Ballot_test.sol"]') From cbcd0b35432ce4b894769720e4f0eadcfa09f921 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 10:48:07 +0530 Subject: [PATCH 05/64] add pause --- .../remix-ide-e2e/src/tests/workspace.test.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index e3ab2fc562..622bf2016a 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -58,11 +58,30 @@ module.exports = { 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(1000) + .getEditorValue((content) => { + 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(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') .click('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') + .pause(1000) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`const { expect } = require("chai");`) !== -1, 'Incorrect content') From ebc813ee5bcb623ca91abbd114a5a00cf2aad4c6 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 10:51:25 +0530 Subject: [PATCH 06/64] js ts content check for all templates --- .../remix-ide-e2e/src/tests/workspace.test.ts | 50 +++++++++++++++++++ .../templates/ozerc20/scripts/ethers-lib.ts | 3 ++ .../src/templates/ozerc721/scripts/ethers.ts | 3 -- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 622bf2016a..842a97fba8 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -128,9 +128,34 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC20.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .pause(1000) + .getEditorValue((content) => { + 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(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC20_test.sol"]') }, @@ -151,9 +176,34 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC721.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + // check js and ts files are not transformed + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') + + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') + .pause(1000) + .getEditorValue((content) => { + 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.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') + .pause(1000) + .getEditorValue((content) => { + browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, + 'Incorrect content') + }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/SampleERC721_test.sol"]') }, 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 323eed9734..6394e65062 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,5 +1,8 @@ +<<<<<<< HEAD:libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts import { ethers } from 'ethers-lib' +======= +>>>>>>> 03bafc1b0 (js ts content check for all templates):libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers.ts 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/ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts index 04c363322a..0cb00c7e47 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts @@ -1,6 +1,3 @@ - - - export const deploy = async (contractName: string, args: Array, from?: string): Promise => { console.log(`deploying ${contractName}`) From 3ec358063b4e6642e348e9acd8288084e425f4a9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 18:28:17 +0530 Subject: [PATCH 07/64] build fix --- .../src/templates/ozerc20/scripts/ethers-lib.ts | 5 +---- .../src/templates/ozerc20/scripts/web3-lib.ts | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) 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 6394e65062..1c5f4c6548 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,8 +1,5 @@ -<<<<<<< HEAD:libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts -import { ethers } from 'ethers-lib' +import { ethers } from 'ethers' -======= ->>>>>>> 03bafc1b0 (js ts content check for all templates):libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers.ts export const deploy = async (contractName: string, args: Array, from?: string): Promise => { console.log(`deploying ${contractName}`) 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 46c31d8e53..37ff2be99b 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,4 +1,4 @@ -import Web3 from 'web3-lib' +import Web3 from 'web3' export const deploy = async (contractName: string, args: Array, from?: string, gas?: number): Promise => { From 604080473c5ce91622ab8071b6055d9fe4df79cd Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 18:52:33 +0530 Subject: [PATCH 08/64] oz721 renaminng --- libs/remix-ws-templates/src/templates/ozerc721/index.ts | 4 ++-- .../src/templates/ozerc721/scripts/deploy_with_ethers.ts | 2 +- .../src/templates/ozerc721/scripts/deploy_with_web3.ts | 2 +- .../templates/ozerc721/scripts/{ethers.ts => ethers-lib.ts} | 0 .../src/templates/ozerc721/scripts/{web3.ts => web3-lib.ts} | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename libs/remix-ws-templates/src/templates/ozerc721/scripts/{ethers.ts => ethers-lib.ts} (100%) rename libs/remix-ws-templates/src/templates/ozerc721/scripts/{web3.ts => web3-lib.ts} (100%) diff --git a/libs/remix-ws-templates/src/templates/ozerc721/index.ts b/libs/remix-ws-templates/src/templates/ozerc721/index.ts index 4d27a7295a..53b6d132e7 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/index.ts @@ -7,9 +7,9 @@ export default async () => { // @ts-ignore 'scripts/deploy_with_web3.ts': (await import('!!raw-loader!./scripts/deploy_with_web3.ts')).default, // @ts-ignore - 'scripts/ethers.ts': (await import('!!raw-loader!./scripts/ethers.ts')).default, + 'scripts/ethers-lib.ts': (await import('!!raw-loader!./scripts/ethers-lib.ts')).default, // @ts-ignore - 'scripts/web3.ts': (await import('!!raw-loader!./scripts/web3.ts')).default, + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, // @ts-ignore 'tests/SampleERC721_test.sol': (await import('raw-loader!./tests/SampleERC721_test.sol')).default } diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts index 16a5635ee9..185fd7a5fa 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts @@ -1,4 +1,4 @@ -import { deploy } from './ethers' +import { deploy } from './ethers-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts index 5fc0b3d01b..2fec0c3b28 100644 --- a/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts +++ b/libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_web3.ts @@ -1,4 +1,4 @@ -import { deploy } from './web3' +import { deploy } from './web3-lib' (async () => { try { diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers.ts rename to libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts diff --git a/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3.ts b/libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts similarity index 100% rename from libs/remix-ws-templates/src/templates/ozerc721/scripts/web3.ts rename to libs/remix-ws-templates/src/templates/ozerc721/scripts/web3-lib.ts From c8fea2ef75c337e62c957167e9713c84038e1a74 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 18:56:55 +0530 Subject: [PATCH 09/64] fix e2e --- .../remix-ide-e2e/src/tests/workspace.test.ts | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 842a97fba8..8ed8549545 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -54,14 +54,14 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .pause(1000) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') @@ -132,14 +132,14 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .pause(1000) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') @@ -180,25 +180,25 @@ module.exports = { .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_web3.ts"]') .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './web3'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './web3-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .pause(1000) .getEditorValue((content) => { - browser.assert.ok(content.indexOf(`import { deploy } from './ethers'`) !== -1, + browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) - .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') - .click('*[data-id="treeViewLitreeViewItemscripts/web3.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .pause(1000) .getEditorValue((content) => { 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.ts"]') - .click('*[data-id="treeViewLitreeViewItemscripts/ethers.ts"]') + .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') + .click('*[data-id="treeViewLitreeViewItemscripts/ethers-lib.ts"]') .pause(1000) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, From a168bea6b23afaa8dcd05cc2a22aa804f38bc4d9 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Thu, 19 May 2022 19:29:25 +0530 Subject: [PATCH 10/64] e2e fix --- .../remix-ide-e2e/src/tests/workspace.test.ts | 26 +++++++++---------- .../src/templates/ozerc20/index.ts | 4 +-- .../src/templates/remixDefault/index.ts | 4 +-- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/apps/remix-ide-e2e/src/tests/workspace.test.ts b/apps/remix-ide-e2e/src/tests/workspace.test.ts index 8ed8549545..092d939302 100644 --- a/apps/remix-ide-e2e/src/tests/workspace.test.ts +++ b/apps/remix-ide-e2e/src/tests/workspace.test.ts @@ -59,21 +59,21 @@ module.exports = { }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(1000) + .pause(2000) .getEditorValue((content) => { 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(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, 'Incorrect content') @@ -81,7 +81,7 @@ module.exports = { .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') .click('*[data-id="treeViewLitreeViewItemtests/storage.test.js"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`const { expect } = require("chai");`) !== -1, 'Incorrect content') @@ -101,7 +101,7 @@ module.exports = { .click('select[id="wstemplate"] option[value=blank]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .pause(1000) + .pause(100) .assert.elementPresent('*[data-id="treeViewUltreeViewMenu"]') .execute(function () { const fileList = document.querySelector('*[data-id="treeViewUltreeViewMenu"]') @@ -123,7 +123,7 @@ module.exports = { .click('select[id="wstemplate"] option[value=ozerc20]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .pause(1000) + .pause(100) .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC20.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') @@ -137,21 +137,21 @@ module.exports = { }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { 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(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, 'Incorrect content') @@ -171,7 +171,7 @@ module.exports = { .click('select[id="wstemplate"] option[value=ozerc721]') .waitForElementPresent('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') .execute(function () { (document.querySelector('[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok') as HTMLElement).click() }) - .pause(1000) + .pause(100) .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemcontracts/SampleERC721.sol"]') .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts"]') @@ -185,21 +185,21 @@ module.exports = { }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/deploy_with_ethers.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`import { deploy } from './ethers-lib'`) !== -1, 'Incorrect content') }) .assert.elementPresent('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') .click('*[data-id="treeViewLitreeViewItemscripts/web3-lib.ts"]') - .pause(1000) + .pause(100) .getEditorValue((content) => { 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(1000) + .pause(100) .getEditorValue((content) => { browser.assert.ok(content.indexOf(`export const deploy = async (contractName: string, args: Array, from?: string): Promise => { `) !== -1, 'Incorrect content') diff --git a/libs/remix-ws-templates/src/templates/ozerc20/index.ts b/libs/remix-ws-templates/src/templates/ozerc20/index.ts index 4a408b979f..48ffb45341 100644 --- a/libs/remix-ws-templates/src/templates/ozerc20/index.ts +++ b/libs/remix-ws-templates/src/templates/ozerc20/index.ts @@ -7,9 +7,9 @@ export default async () => { // @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, + '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, + '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 } diff --git a/libs/remix-ws-templates/src/templates/remixDefault/index.ts b/libs/remix-ws-templates/src/templates/remixDefault/index.ts index 180f155113..69bccc237d 100644 --- a/libs/remix-ws-templates/src/templates/remixDefault/index.ts +++ b/libs/remix-ws-templates/src/templates/remixDefault/index.ts @@ -11,9 +11,9 @@ export default async () => { // @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, + '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, + 'scripts/web3-lib.ts': (await import('!!raw-loader!./scripts/web3-lib.ts')).default, // @ts-ignore 'tests/Ballot_test.sol': (await import('raw-loader!./tests/Ballot_test.sol')).default, // @ts-ignore From a2cdca7595752a8aa06d713a4d3bd3aa8e35c6e1 Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 23 May 2022 14:10:27 +0530 Subject: [PATCH 11/64] 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 4ef29805044c9bb1098daa2c274fdd5e94b959ab Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Mon, 23 May 2022 18:49:25 +0530 Subject: [PATCH 12/64] 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 b8882c09f53eb657080472946f42850749688751 Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 24 May 2022 10:20:50 +0200 Subject: [PATCH 13/64] 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 a6ef958ab0f1eca5fe027dcead5533e790e0415d Mon Sep 17 00:00:00 2001 From: Aniket-Engg Date: Tue, 24 May 2022 14:20:46 +0530 Subject: [PATCH 14/64] 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 712274ee915d73deea79c88c50814ad51a8e9125 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 15/64] 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 5cd76e8f78fe1318c6c74a4d0d8046ab2a6d0028 Mon Sep 17 00:00:00 2001 From: David Disu Date: Sun, 22 May 2022 17:25:14 +0100 Subject: [PATCH 16/64] 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'>