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