Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
feat: add deployContant flag to deploy script
Browse files Browse the repository at this point in the history
Signed-off-by: Jawad Tariq <[email protected]>
  • Loading branch information
JDawg287 committed Aug 30, 2023
1 parent 0eeb6cd commit a2b673e
Showing 1 changed file with 41 additions and 13 deletions.
54 changes: 41 additions & 13 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { providers, utils, Wallet } from 'ethers'
/* eslint-disable no-case-declarations */
import { ContractFactory, providers, utils, Wallet } from 'ethers'
import fs from 'fs'

import {
Expand All @@ -8,7 +9,14 @@ import {
} from './const-addr-deployer'

const main = async function (..._args: Arg[]) {
const [providerEndpoint, contractJsonPath, salt, gasLimit, ...args] = _args
const [
providerEndpoint,
contractJsonPath,
salt,
gasLimit,
deployConstant,
...args
] = _args
const provider = new providers.JsonRpcProvider(<string>providerEndpoint)
const privateKey = process.env.PRIVATE_KEY

Expand Down Expand Up @@ -39,17 +47,37 @@ const main = async function (..._args: Arg[]) {
return
}

const address = await deployContractConstant(
wallet,
contractJson,
<string>salt,
args,
<number>gasLimit
)
.then(({ address }) => address)
.catch(console.error)

console.log(address)
switch (deployConstant) {
case 'true':
const address = await deployContractConstant(
wallet,
contractJson,
<string>salt,
args,
<number>gasLimit
)
.then(({ address }) => address)
.catch(console.error)

console.log(address)
break
case 'false':
const contractFactory = new ContractFactory(
contractJson.abi,
contractJson.bytecode,
wallet
)
const contract = await contractFactory.deploy(...args, {
gasLimit: BigInt(gasLimit),
})
await contract.deployed()
console.log(contract.address)
break
default:
console.error(
`ERROR: Please provide a valid deployConstant flag! (true|false)`
)
}
}

const args = process.argv.slice(2)
Expand Down

0 comments on commit a2b673e

Please sign in to comment.