template script and testing: use ethers6

pull/5188/head
yann300 2 months ago
parent e97d28073a
commit 0a2bad63fc
  1. 26
      apps/remix-ide-e2e/src/tests/terminal.test.ts
  2. 2
      libs/ghaction-helper/src/methods.ts
  3. 4
      libs/remix-ws-templates/src/script-templates/contract-deployer/basic-contract-deploy.ts
  4. 2
      libs/remix-ws-templates/src/script-templates/contract-deployer/create2-factory-deploy.ts
  5. 2
      libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/deploy_with_ethers.ts
  6. 4
      libs/remix-ws-templates/src/templates/gnosisSafeMultisig/scripts/ethers-lib.ts
  7. 2
      libs/remix-ws-templates/src/templates/ozerc1155/scripts/deploy_with_ethers.ts
  8. 4
      libs/remix-ws-templates/src/templates/ozerc1155/scripts/ethers-lib.ts
  9. 2
      libs/remix-ws-templates/src/templates/ozerc20/scripts/deploy_with_ethers.ts
  10. 4
      libs/remix-ws-templates/src/templates/ozerc20/scripts/ethers-lib.ts
  11. 2
      libs/remix-ws-templates/src/templates/ozerc721/scripts/deploy_with_ethers.ts
  12. 4
      libs/remix-ws-templates/src/templates/ozerc721/scripts/ethers-lib.ts
  13. 2
      libs/remix-ws-templates/src/templates/playground/scripts/deploy_with_ethers.ts
  14. 4
      libs/remix-ws-templates/src/templates/playground/scripts/ethers-lib.ts
  15. 2
      libs/remix-ws-templates/src/templates/remixDefault/scripts/deploy_with_ethers.ts
  16. 4
      libs/remix-ws-templates/src/templates/remixDefault/scripts/ethers-lib.ts
  17. 4
      libs/remix-ws-templates/src/templates/remixDefault/tests/storage.test.js
  18. 2
      libs/remix-ws-templates/src/templates/zeroxErc20/scripts/deploy_with_ethers.ts
  19. 4
      libs/remix-ws-templates/src/templates/zeroxErc20/scripts/ethers-lib.ts

@ -501,7 +501,7 @@ const deployWithEthersJs = `
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.BrowserProvider(web3Provider)).getSigner()
let factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
@ -510,7 +510,7 @@ const deployWithEthersJs = `
console.log('Contract Address: ', contract.address);
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
console.log('Deployment successful.')
contract.on('OwnerSet', (previousOwner, newOwner) => {
@ -531,20 +531,20 @@ describe("Storage with lib", function () {
it("test initial value", async 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()
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner()
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()
await storage.waitForDeployment()
expect((await storage.retrieve()).toNumber()).to.equal(0);
});
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()
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
await storage.deployed()
await storage.waitForDeployment()
const setValue = await storage.store(56);
await setValue.wait();
expect((await storage.retrieve()).toNumber()).to.equal(56);
@ -552,10 +552,10 @@ 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()
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner()
let Storage = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
let storage = await Storage.deploy();
await storage.deployed()
await storage.waitForDeployment()
const setValue = await storage.store(56);
await setValue.wait();
expect((await storage.retrieve()).toNumber(), 'incorrect number').to.equal(55);
@ -623,7 +623,7 @@ describe("Storage", function () {
const optionsLib = {}
const factoryLib = await ethers.getContractFactoryFromArtifact(artifactLib, optionsLib)
const lib = await factoryLib.deploy();
await lib.deployed()
await lib.waitForDeployment()
const metadata = JSON.parse(await remix.call('fileManager', 'readFile', 'contracts/artifacts/StorageWithLib.json'))
const artifact = {
@ -643,7 +643,7 @@ describe("Storage", function () {
const factory = await ethers.getContractFactoryFromArtifact(artifact, options)
const storage = await factory.deploy();
await storage.deployed()
await storage.waitForDeployment()
const storeValue = await storage.store(333);
await storeValue.wait();
expect((await storage.getFromLib()).toString()).to.equal('34');
@ -779,7 +779,7 @@ const scriptAutoExec = {
const lib = await factoryLib.deploy();
await lib.deployed()
await lib.waitForDeployment()
console.log('lib deployed', lib.address)
@ -803,7 +803,7 @@ const scriptAutoExec = {
const storage = await factory.deploy();
await storage.deployed()
await storage.waitForDeployment()
const storeValue = await storage.store(333);
@ -826,7 +826,7 @@ const scriptBlockAndTransaction = `
try {
web3.eth.getTransaction('0x0d2baaed96425861677e87dcf6961d34e2b73ad9a0929c32a05607ca94f98d17').then(console.log).catch(console.error)
web3.eth.getBlock(4757766).then(console.log).catch(console.error)
let ethersProvider = new ethers.providers.Web3Provider(web3Provider)
let ethersProvider = new ethers.BrowserProvider(web3Provider)
ethersProvider.getBlock(4757767).then(console.log).catch(console.error)
} catch (e) {
console.log(e.message)

@ -14,7 +14,7 @@ const providerConfig = {
const config = { defaultTransactionType: '0x0' }
global.remixProvider = new Provider(providerConfig)
global.remixProvider.init()
global.web3Provider = new ethers.providers.Web3Provider(global.remixProvider)
global.web3Provider = new ethers.BrowserProvider(global.remixProvider)
global.provider = global.web3Provider
global.ethereum = global.web3Provider
global.web3 = new Web3(global.web3Provider)

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -15,7 +15,7 @@ export const CREATE2_DEPLOYER_ADDRESS = '0x13b0D85CcB8bf860b6b79AF3029fCA081AE9b
export const deploy = async (contractName: string, args: Array<any>, salt: string, accountIndex?: number): Promise<string> => {
console.log(`deploying ${contractName}`)
const signer = new ethers.providers.Web3Provider(web3Provider).getSigner(accountIndex)
const signer = new ethers.BrowserProvider(web3Provider).getSigner(accountIndex)
const factory = new ethers.Contract(CREATE2_DEPLOYER_ADDRESS, contractDeployerAbi, signer)
//@ts-ignore

@ -3,7 +3,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('MultisigWallet', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -3,7 +3,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('MyToken', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -3,7 +3,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('MyToken', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -3,7 +3,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('MyToken', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -7,7 +7,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('HelloWorld', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -7,7 +7,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('Storage', [])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}

@ -7,14 +7,14 @@ describe("Storage", function () {
it("test initial value", async function () {
const Storage = await ethers.getContractFactory("Storage");
const storage = await Storage.deploy();
await storage.deployed();
await storage.waitForDeployment();
console.log("storage deployed at:" + storage.address);
expect((await storage.retrieve()).toNumber()).to.equal(0);
});
it("test updating and retrieving updated value", async function () {
const Storage = await ethers.getContractFactory("Storage");
const storage = await Storage.deploy();
await storage.deployed();
await storage.waitForDeployment();
const storage2 = await ethers.getContractAt("Storage", storage.address);
const setValue = await storage2.store(56);
await setValue.wait();

@ -3,7 +3,7 @@ import { deploy } from './ethers-lib'
(async () => {
try {
const result = await deploy('SampleERC20', ["TestToken", "TST", 18, 1000])
console.log(`address: ${result.address}`)
console.log(`address: ${await result.getAddress()}`)
} catch (e) {
console.log(e.message)
}

@ -17,13 +17,13 @@ export const deploy = async (contractName: string, args: Array<any>, accountInde
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(accountIndex)
const signer = (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)
const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
const contract = await factory.deploy(...args)
// The contract is NOT deployed yet; we must wait until it is mined
await contract.deployed()
await contract.waitForDeployment()
return contract
}
Loading…
Cancel
Save