parent
1a67b8d6d6
commit
df523b58ca
@ -0,0 +1,5 @@ |
|||||||
|
// SPDX-License-Identifier: LGPL-3.0-only |
||||||
|
pragma solidity >=0.7.0 <0.9.0; |
||||||
|
import "https://github.com/safe-global/safe-contracts/blob/main/contracts/GnosisSafe.sol"; |
||||||
|
|
||||||
|
contract MultisigWallet is GnosisSafe {} |
@ -0,0 +1,14 @@ |
|||||||
|
export default async () => { |
||||||
|
return { |
||||||
|
// @ts-ignore
|
||||||
|
'contracts/MultisigWallet.sol': (await import('raw-loader!./contracts/MultisigWallet.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 |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
import { deploy } from './ethers-lib' |
||||||
|
|
||||||
|
(async () => { |
||||||
|
try { |
||||||
|
const result = await deploy('MultisigWallet', []) |
||||||
|
console.log(`address: ${result.address}`) |
||||||
|
} catch (e) { |
||||||
|
console.log(e.message) |
||||||
|
} |
||||||
|
})() |
@ -0,0 +1,10 @@ |
|||||||
|
import { deploy } from './web3-lib' |
||||||
|
|
||||||
|
(async () => { |
||||||
|
try { |
||||||
|
const result = await deploy('MultisigWallet', []) |
||||||
|
console.log(`address: ${result.address}`) |
||||||
|
} catch (e) { |
||||||
|
console.log(e.message) |
||||||
|
} |
||||||
|
})() |
@ -0,0 +1,29 @@ |
|||||||
|
import { ethers } from 'ethers' |
||||||
|
|
||||||
|
/** |
||||||
|
* Deploy the given contract |
||||||
|
* @param {string} contractName name of the contract to deploy |
||||||
|
* @param {Array<any>} args list of constructor' parameters |
||||||
|
* @param {Number} accountIndex account index from the exposed account |
||||||
|
* @return {Contract} deployed contract |
||||||
|
*/ |
||||||
|
export const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {
|
||||||
|
|
||||||
|
console.log(`deploying ${contractName}`) |
||||||
|
// Note that the script needs the ABI which is generated from the compilation artifact.
|
||||||
|
// Make sure contract is compiled and artifacts are generated
|
||||||
|
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path
|
||||||
|
|
||||||
|
const 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 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() |
||||||
|
return contract |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
import Web3 from 'web3' |
||||||
|
import { Contract, ContractSendMethod, Options } from 'web3-eth-contract' |
||||||
|
|
||||||
|
/** |
||||||
|
* Deploy the given contract |
||||||
|
* @param {string} contractName name of the contract to deploy |
||||||
|
* @param {Array<any>} args list of constructor' parameters |
||||||
|
* @param {string} from account used to send the transaction |
||||||
|
* @param {number} gas gas limit |
||||||
|
* @return {Options} deployed contract |
||||||
|
*/ |
||||||
|
export const deploy = async (contractName: string, args: Array<any>, from?: string, gas?: number): Promise<Options> => { |
||||||
|
|
||||||
|
const web3 = new Web3(web3Provider) |
||||||
|
console.log(`deploying ${contractName}`) |
||||||
|
// Note that the script needs the ABI which is generated from the compilation artifact.
|
||||||
|
// Make sure contract is compiled and artifacts are generated
|
||||||
|
const artifactsPath = `browser/contracts/artifacts/${contractName}.json` |
||||||
|
|
||||||
|
const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath)) |
||||||
|
|
||||||
|
const accounts = await web3.eth.getAccounts() |
||||||
|
|
||||||
|
const contract: Contract = new web3.eth.Contract(metadata.abi) |
||||||
|
|
||||||
|
const contractSend: ContractSendMethod = contract.deploy({ |
||||||
|
data: metadata.data.bytecode.object, |
||||||
|
arguments: args |
||||||
|
}) |
||||||
|
|
||||||
|
const newContractInstance = await contractSend.send({ |
||||||
|
from: from || accounts[0], |
||||||
|
gas: gas || 1500000 |
||||||
|
}) |
||||||
|
return newContractInstance.options
|
||||||
|
} |
Loading…
Reference in new issue