hardhat/config#types TypeScript Examples
The following examples show how to use
hardhat/config#types.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: deploy.ts From eth with GNU General Public License v3.0 | 6 votes |
task('deploy', 'deploy all contracts')
.addOptionalParam('whitelist', 'override the whitelist', undefined, types.boolean)
.addOptionalParam('fund', 'amount of eth to fund whitelist contract for fund', 0.5, types.float)
.addOptionalParam(
'subgraph',
'bring up subgraph with name (requires docker)',
undefined,
types.string
)
.setAction(deploy);
Example #2
Source File: hardhat.config.ts From hoprnet with GNU General Public License v3.0 | 6 votes |
task<FaucetCLIOPts>('faucet', 'Faucets a local development HOPR node account with ETH and HOPR tokens', faucet)
.addOptionalParam<string>('address', 'HoprToken address', undefined, types.string)
.addOptionalParam<string>('amount', 'Amount of HOPR to fund', DEFAULT_FUND_AMOUNT, types.string)
.addFlag('useLocalIdentities', `Fund all identities stored in identity directory`)
.addOptionalParam<string>(
'password',
`Password to decrypt identities stored in identity directory`,
undefined,
types.string
)
.addOptionalParam<string>(
'identityDirectory',
`Overwrite default identity directory, default ['/tmp']`,
DEFAULT_IDENTITY_DIRECTORY,
types.string
)
.addOptionalParam<string>('identityPrefix', `only use identity files with prefix`, undefined, types.string)
Example #3
Source File: hardhat.config.ts From hoprnet with GNU General Public License v3.0 | 6 votes |
subtask('flat:get-dependency-graph')
.addOptionalParam('files', undefined, undefined, types.any)
.setAction(async ({ files }, { run }) => {
const sourcePaths =
files === undefined ? await run('compile:solidity:get-source-paths') : files.map((f: string) => realpathSync(f))
const sourceNames = await run('compile:solidity:get-source-names', {
sourcePaths
})
const dependencyGraph = await run('compile:solidity:get-dependency-graph', { sourceNames })
return dependencyGraph
})
Example #4
Source File: hardhat.config.ts From hoprnet with GNU General Public License v3.0 | 6 votes |
task('flat', 'Flattens and prints contracts and their dependencies')
.addOptionalVariadicPositionalParam('files', 'The files to flatten', undefined, types.inputFile)
.addOptionalParam('output', 'Specify the output file', undefined, types.string)
.setAction(async ({ files, output }, { run }) => {
console.log(
await run('flat:get-flattened-sources', {
files,
output
})
)
})
Example #5
Source File: create-proposal.ts From nouns-monorepo with GNU General Public License v3.0 | 6 votes |
task('create-proposal', 'Create a governance proposal')
.addOptionalParam(
'nounsDaoProxy',
'The `NounsDAOProxy` contract address',
'0x610178dA211FEF7D417bC0e6FeD39F05609AD788',
types.string,
)
.setAction(async ({ nounsDaoProxy }, { ethers }) => {
const nounsDaoFactory = await ethers.getContractFactory('NounsDAOLogicV1');
const nounsDao = nounsDaoFactory.attach(nounsDaoProxy);
const [deployer] = await ethers.getSigners();
const oneETH = utils.parseEther('1');
const receipt = await (
await nounsDao.propose(
[deployer.address],
[oneETH],
[''],
['0x'],
'# Test Proposal\n## This is a **test**.',
)
).wait();
if (!receipt.events?.length) {
throw new Error('Failed to create proposal');
}
console.log('Proposal created');
});
Example #6
Source File: mint-noun.ts From nouns-monorepo with GNU General Public License v3.0 | 6 votes |
task('mint-noun', 'Mints a Noun')
.addOptionalParam(
'nounsToken',
'The `NounsToken` contract address',
'0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9',
types.string,
)
.setAction(async ({ nounsToken }, { ethers }) => {
const nftFactory = await ethers.getContractFactory('NounsToken');
const nftContract = nftFactory.attach(nounsToken);
const receipt = await (await nftContract.mint()).wait();
const nounCreated = receipt.events?.[1];
const { tokenId } = nounCreated?.args as Result;
console.log(`Noun minted with ID: ${tokenId.toString()}.`);
});
Example #7
Source File: creation.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("create", "Create a Safe")
.addFlag("l2", "Should use version of the Safe contract that is more event heave")
.addFlag("buildOnly", "Indicate whether this transaction should only be logged and not submitted on-chain")
.addParam("signers", "Comma separated list of signer addresses (dafault is the address of linked account)", "", types.string, true)
.addParam("threshold", "Threshold that should be used", 1, types.int, true)
.addParam("fallback", "Fallback handler address", AddressZero, types.string, true)
.addParam("nonce", "Nonce used with factory", new Date().getTime(), types.int, true)
.addParam("singleton", "Set to overwrite which singleton address to use", "", types.string, true)
.addParam("factory", "Set to overwrite which factory address to use", "", types.string, true)
.setAction(async (taskArgs, hre) => {
const singleton = taskArgs.l2 ? await safeL2Singleton(hre, taskArgs.singleton) : await safeSingleton(hre, taskArgs.singleton)
const factory = await proxyFactory(hre, taskArgs.factory)
const signers: string[] = taskArgs.signers ? parseSigners(taskArgs.signers) : [(await hre.getNamedAccounts()).deployer]
const fallbackHandler = getAddress(taskArgs.fallback)
const setupData = singleton.interface.encodeFunctionData(
"setup",
[signers, taskArgs.threshold, AddressZero, "0x", fallbackHandler, AddressZero, 0, AddressZero]
)
const predictedAddress = await calculateProxyAddress(factory, singleton.address, setupData, taskArgs.nonce)
console.log(`Deploy Safe to ${predictedAddress}`)
console.log(`Singleton: ${singleton.address}`)
console.log(`Setup data: ${setupData}`)
console.log(`Nonce: ${taskArgs.nonce}`)
console.log(`To (factory): ${factory.address}`)
console.log(`Data: ${factory.interface.encodeFunctionData("createProxyWithNonce", [singleton.address, setupData, taskArgs.nonce])}`)
if (!taskArgs.buildOnly)
await factory.createProxyWithNonce(singleton.address, setupData, taskArgs.nonce).then((tx: any) => tx.wait())
// TODO verify deployment
});
Example #8
Source File: wallet.ts From eth with GNU General Public License v3.0 | 6 votes |
task('wallet:send', 'send the native currency of this chain (ETH on mainnet, xDAI on xDAI chain)')
.addParam('from', 'sender address', undefined, types.string)
.addParam('to', 'receiver address', undefined, types.string)
.addParam('value', 'value to send (in units of ETH/xDAI)', undefined, types.float)
.addParam(
'dry',
"dry run only (doesn't carry out transaction, just verifies that it's valid). default: true",
true,
types.boolean
)
.addParam('gaspricegwei', 'gas price in gwei', 1, types.float)
.addParam('confirmations', 'confirmations to wait', 1, types.int)
.setAction(sendValue);
Example #9
Source File: verify-etherscan.ts From nouns-monorepo with GNU General Public License v3.0 | 6 votes |
task('verify-etherscan', 'Verify the Solidity contracts on Etherscan')
.addParam('contracts', 'Contract objects from the deployment', undefined, types.json)
.setAction(async ({ contracts }: { contracts: Record<ContractName, VerifyArgs> }, hre) => {
for (const [name, contract] of Object.entries(contracts)) {
console.log(`verifying ${name}...`);
try {
const code = await contract.instance?.provider.getCode(contract.address);
if (code === '0x') {
console.log(`${name} contract deployment has not completed. waiting to verify...`);
await contract.instance?.deployed();
}
await hre.run('verify:verify', {
...contract,
contract: nameToFullyQualifiedName[name],
});
} catch ({ message }) {
if ((message as string).includes('Reason: Already Verified')) {
continue;
}
console.error(message);
}
}
});
Example #10
Source File: cpp-address.ts From trident with GNU General Public License v3.0 | 6 votes |
task("cpp-address", "Constant Product Pool deploy")
.addOptionalParam("tokenA", "Token A", WNATIVE_ADDRESS[ChainId.MATIC], types.string)
.addOptionalParam("tokenB", "Token B", USDC_ADDRESS[ChainId.MATIC], types.string)
.addOptionalParam("fee", "Fee tier", 30, types.int)
.addOptionalParam("twap", "Twap enabled", true, types.boolean)
.setAction(async ({ tokenA, tokenB, fee, twap }, { ethers }): Promise<string> => {
const master = (await ethers.getContract("MasterDeployer")).address;
const factory = (await ethers.getContract("ConstantProductPoolFactory")).address;
const deployData = ethers.utils.defaultAbiCoder.encode(
["address", "address", "uint256", "bool"],
[...[tokenA, tokenB].sort(), fee, twap]
);
const salt = ethers.utils.keccak256(deployData);
// const constructorParams = ethers.utils.defaultAbiCoder
// .encode(["bytes", "address"], [deployData, master])
// .substring(2);
const Pool = await ethers.getContractFactory("ConstantProductPool");
const initCodeHash = ethers.utils.keccak256(Pool.bytecode);
const address = ethers.utils.getCreate2Address(factory, salt, initCodeHash);
console.log(address, [...[tokenA, tokenB].sort(), fee, twap]);
return address;
});
Example #11
Source File: debug.ts From eth with GNU General Public License v3.0 | 6 votes |
// yarn workspace eth hardhat:dev debug:giveOneOfEachArtifact "0x5bcf0ac4c057dcaf9b23e4dd7cb7b035a71dd0dc" 10
task(
'debug:giveOneOfEachArtifact',
'gives the player one of each type of artifact, one of each rarity'
)
.addPositionalParam(
'playerAddress',
'the address of the player to give the artifacts',
undefined,
types.string
)
.addPositionalParam('biome', 'the biome of the artifacts to give', 1, types.int)
.setAction(giveOneOfEachArtifact);
Example #12
Source File: debug.ts From eth with GNU General Public License v3.0 | 6 votes |
// yarn workspace eth hardhat:dev debug:giveArtifact "0x27fd6eec1e1f3ce4a53b40d5813119d868f7b4e3" PhotoidCannon 5
task('debug:giveArtifact', 'gives the player some amount of a particular type of artifact')
.addPositionalParam(
'playerAddress',
'the address of the player to give the artifacts',
undefined,
types.string
)
.addPositionalParam(
'artifactType',
'one of: [Monolith, Colossus, Spaceship, Pyramid, Wormhole, ' +
'PlanetaryShield, PhotoidCannon, BloomFilter, BlackDomain]',
undefined,
types.string
)
.addPositionalParam('amount', 'the amount of this artifact to give', 1, types.int)
.addPositionalParam('rarity', 'the rarity of the artifact to give', 1, types.int)
.addPositionalParam('biome', 'the biome of the artifact to give', 1, types.int)
.addPositionalParam(
'discoveredOn',
'the planet ID (decimal string) this was discovered on',
'0',
types.string
)
.setAction(giveArtifact);
Example #13
Source File: information.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("info", "Displays information about a Safe")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.setAction(async (taskArgs, hre) => {
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Checking Safe at ${safeAddress}`)
console.log(`Singleton: ${await getSingletonAddress(hre, safeAddress)}`)
console.log(`Version: ${await safe.VERSION()}`)
console.log(`Owners: ${await safe.getOwners()}`)
console.log(`Threshold: ${await safe.getThreshold()}`)
console.log(`Nonce: ${await safe.nonce()}`)
console.log(`Fallback Handler: ${await getFallbackHandlerAddress(hre, safeAddress)}`)
console.log(`Modules: ${await getModules(hre, safe)}`)
});
Example #14
Source File: cpp-verify.ts From trident with GNU General Public License v3.0 | 6 votes |
task("cpp-verify", "Constant Product Pool verify")
.addOptionalParam(
"tokenA",
"Token A",
WETH9_ADDRESS[ChainId.OPTIMISM], // kovan weth
types.string
)
.addOptionalParam(
"tokenB",
"Token B",
DAI_ADDRESS[ChainId.OPTIMISM], // kovan dai
types.string
)
.addOptionalParam("fee", "Fee tier", 30, types.int)
.addOptionalParam("twap", "Twap enabled", false, types.boolean)
.setAction(async function ({ tokenA, tokenB, fee, twap }, { ethers, run }) {
console.log(`Verify cpp tokenA: ${tokenA} tokenB: ${tokenB} fee: ${fee} twap: ${twap}`);
const masterDeployer = await ethers.getContract<MasterDeployer>("MasterDeployer");
const address = await run("cpp-address", { tokenA, tokenB, fee, twap });
console.log(`Verify cpp ${address}`);
const deployData = ethers.utils.defaultAbiCoder.encode(
["address", "address", "uint256", "bool"],
[...[tokenA, tokenB].sort(), fee, twap]
);
await run("verify:verify", {
address,
constructorArguments: [],
});
});
Example #15
Source File: proposing.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("propose", "Create a Safe tx proposal json file")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addParam("to", "Address of the target", undefined, types.string)
.addParam("value", "Value in ETH", "0", types.string, true)
.addParam("data", "Data as hex string", "0x", types.string, true)
.addFlag("delegatecall", "Indicator if tx should be executed as a delegatecall")
.addFlag("onChainHash", "Get hash from chain (required for pre-1.3.0 version)")
.setAction(async (taskArgs, hre) => {
console.log(`Running on ${hre.network.name}`)
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress}`)
const nonce = await safe.nonce()
if (!isHexString(taskArgs.data)) throw Error(`Invalid hex string provided for data: ${taskArgs.data}`)
const tx = buildSafeTransaction({ to: taskArgs.to, value: parseEther(taskArgs.value).toString(), data: taskArgs.data, nonce: nonce.toString(), operation: taskArgs.delegatecall ? 1 : 0 })
const chainId = (await safe.provider.getNetwork()).chainId
const safeTxHash = await calcSafeTxHash(safe, tx, chainId, taskArgs.onChainHash)
const proposal: SafeTxProposal = {
safe: safeAddress,
chainId,
safeTxHash,
tx
}
await writeToCliCache(proposalFile(safeTxHash), proposal)
console.log(`Safe transaction hash: ${safeTxHash}`)
});
Example #16
Source File: proposing.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("propose-multi", "Create a Safe tx proposal json file")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addPositionalParam("txs", "Json file with transactions", undefined, types.inputFile)
.addParam("multiSend", "Set to overwrite which multiSend address to use", "", types.string, true)
.addParam("nonce", "Set nonce to use (will default to on-chain nonce)", "", types.string, true)
.addParam("export", "If specified instead of executing the data will be exported as a json file for the transaction builder", undefined, types.string)
.addParam("name", "Name to be used for the transaction builder json", undefined, types.string, true)
.addFlag("onChainHash", "Get hash from chain (required for pre-1.3.0 version)")
.setAction(async (taskArgs, hre) => {
console.log(`Running on ${hre.network.name}`)
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress}`)
const nonce = taskArgs.nonce || await safe.nonce()
const txs = await loadMetaTransactions(taskArgs.txs)
const chainId = (await safe.provider.getNetwork()).chainId
if (taskArgs.export) {
await writeTxBuilderJson(taskArgs.export, chainId.toString(), txs, taskArgs.name || "Custom Transactions")
return
}
const tx = await parseMultiSendJsonFile(hre, txs, BigNumber.from(nonce).toNumber(), taskArgs.multiSend)
console.log("Safe transaction", tx)
const safeTxHash = await calcSafeTxHash(safe, tx, chainId, taskArgs.onChainHash)
const proposal: SafeTxProposal = {
safe: safeAddress,
chainId,
safeTxHash,
tx
}
await writeToCliCache(proposalFile(safeTxHash), proposal)
console.log("Safe transaction hash:", safeTxHash)
return safeTxHash
});
Example #17
Source File: proposing.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("show-proposal", "Shows details for a Safe transaction")
.addPositionalParam("hash", "Hash of Safe transaction to display", undefined, types.string)
.setAction(async (taskArgs, hre) => {
const proposal: SafeTxProposal = await readFromCliCache(proposalFile(taskArgs.hash))
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress}@${proposal.chainId}`)
const nonce = await safe.nonce()
if (BigNumber.from(proposal.tx.nonce).lt(nonce)) {
console.log(`!Nonce has already been used!`)
}
console.log("Details")
console.log(proposal.tx)
});
Example #18
Source File: signing.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("sign-tx", "Signs a Safe transaction")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addParam("to", "Address of the target", undefined, types.string)
.addParam("value", "Value in ETH", "0", types.string, true)
.addParam("data", "Data as hex string", "0x", types.string, true)
.addParam("signerIndex", "Index of the signer to use", 0, types.int, true)
.addFlag("delegatecall", "Indicator if tx should be executed as a delegatecall")
.setAction(async (taskArgs, hre) => {
console.log(`Running on ${hre.network.name}`)
const signers = await hre.ethers.getSigners()
const signer = signers[taskArgs.signerIndex]
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress} with ${signer.address}`)
const nonce = await safe.nonce()
if (!isHexString(taskArgs.data)) throw Error(`Invalid hex string provided for data: ${taskArgs.data}`)
const tx = buildSafeTransaction({ to: taskArgs.to, value: parseEther(taskArgs.value), data: taskArgs.data, nonce, operation: taskArgs.delegatecall ? 1 : 0 })
const signature = await safeSignMessage(signer, safe, tx)
console.log(`Signature: ${signature.data}`)
});
Example #19
Source File: signing.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("sign-proposal", "Signs a Safe transaction")
.addPositionalParam("hash", "Hash of Safe transaction to display", undefined, types.string)
.addParam("signerIndex", "Index of the signer to use", 0, types.int, true)
.setAction(async (taskArgs, hre) => {
const proposal: SafeTxProposal = await readFromCliCache(proposalFile(taskArgs.hash))
const signers = await hre.ethers.getSigners()
const signer = signers[taskArgs.signerIndex]
const safe = await safeSingleton(hre, proposal.safe)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress} with ${signer.address}`)
const owners: string[] = await safe.getOwners()
if (owners.indexOf(signer.address) < 0) {
throw Error(`Signer is not an owner of the Safe. Owners: ${owners}`)
}
const signature = await signHash(signer, taskArgs.hash)
await updateSignatureFile(taskArgs.hash, signature)
console.log(`Signature: ${signature.data}`)
});
Example #20
Source File: simple.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("submit-multi", "Executes a Safe transaction from a file")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addPositionalParam("txs", "Json file with transactions", undefined, types.inputFile)
.addFlag("onChainHash", "Get hash from chain (required for pre-1.3.0 version)")
.addParam("multiSend", "Set to overwrite which multiSend address to use", "", types.string, true)
.addParam("signerIndex", "Index of the signer to use", 0, types.int, true)
.addParam("signatures", "Comma seperated list of signatures", undefined, types.string, true)
.addParam("gasPrice", "Gas price to be used", undefined, types.int, true)
.addParam("gasLimit", "Gas limit to be used", undefined, types.int, true)
.addFlag("buildOnly", "Flag to only output the final transaction")
.setAction(async (taskArgs, hre) => {
const safeTxHash = await hre.run("propose-multi", {
address: taskArgs.address,
txs: taskArgs.txs,
onChainHash: taskArgs.onChainHash,
multiSend: taskArgs.multiSend
})
await hre.run("submit-proposal", {
hash: safeTxHash,
onChainHash: taskArgs.onChainHash,
signerIndex: taskArgs.signerIndex,
signatures: taskArgs.signatures,
gasLimit: taskArgs.gasLimit,
buildOnly: taskArgs.buildOnly,
})
});
Example #21
Source File: submitting.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("submit-tx", "Executes a Safe transaction")
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addParam("to", "Address of the target", undefined, types.string)
.addParam("value", "Value in ETH", "0", types.string, true)
.addParam("data", "Data as hex string", "0x", types.string, true)
.addParam("signatures", "Comma seperated list of signatures", undefined, types.string, true)
.addParam("gasPrice", "Gas price to be used", undefined, types.int, true)
.addParam("gasLimit", "Gas limit to be used", undefined, types.int, true)
.addFlag("delegatecall", "Indicator if tx should be executed as a delegatecall")
.setAction(async (taskArgs, hre) => {
console.log(`Running on ${hre.network.name}`)
const [signer] = await hre.ethers.getSigners()
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress} with ${signer.address}`)
const nonce = await safe.nonce()
if (!isHexString(taskArgs.data)) throw Error(`Invalid hex string provided for data: ${taskArgs.data}`)
const tx = buildSafeTransaction({
to: taskArgs.to,
value: parseEther(taskArgs.value),
data: taskArgs.data,
nonce,
operation: taskArgs.delegatecall ? 1 : 0
})
const signatures = await prepareSignatures(safe, tx, taskArgs.signatures, signer)
const populatedTx: PopulatedTransaction = await populateExecuteTx(safe, tx, signatures, { gasLimit: taskArgs.gasLimit, gasPrice: taskArgs.gasPrice })
const receipt = await signer.sendTransaction(populatedTx).then(tx => tx.wait())
console.log(receipt.transactionHash)
});
Example #22
Source File: submitting.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("submit-proposal", "Executes a Safe transaction")
.addPositionalParam("hash", "Hash of Safe transaction to display", undefined, types.string)
.addParam("signerIndex", "Index of the signer to use", 0, types.int, true)
.addParam("signatures", "Comma seperated list of signatures", undefined, types.string, true)
.addParam("gasPrice", "Gas price to be used", undefined, types.int, true)
.addParam("gasLimit", "Gas limit to be used", undefined, types.int, true)
.addFlag("buildOnly", "Flag to only output the final transaction")
.setAction(async (taskArgs, hre) => {
console.log(`Running on ${hre.network.name}`)
const proposal: SafeTxProposal = await readFromCliCache(proposalFile(taskArgs.hash))
const signers = await hre.ethers.getSigners()
const signer = signers[taskArgs.signerIndex]
const safe = await safeSingleton(hre, proposal.safe)
const safeAddress = await safe.resolvedAddress
console.log(`Using Safe at ${safeAddress} with ${signer.address}`)
const currentNonce = await safe.nonce()
if (!BigNumber.from(proposal.tx.nonce).eq(currentNonce)) {
throw Error("Proposal does not have correct nonce!")
}
const signatureStrings: Record<string, string> = await loadSignatures(taskArgs.hash)
const signatureArray = Object.values(signatureStrings)
if (taskArgs.signatures) {
signatureArray.push(taskArgs.signatures)
}
const signatures = await prepareSignatures(safe, proposal.tx, signatureArray.join(","), signer, taskArgs.hash)
const populatedTx: PopulatedTransaction = await populateExecuteTx(safe, proposal.tx, signatures, { gasLimit: taskArgs.gasLimit, gasPrice: taskArgs.gasPrice })
if (taskArgs.buildOnly) {
console.log("Ethereum transaction:", populatedTx)
return
}
const receipt = await signer.sendTransaction(populatedTx).then(tx => tx.wait())
console.log("Ethereum transaction hash:", receipt.transactionHash)
return receipt.transactionHash
});
Example #23
Source File: index.ts From safe-tasks with GNU Lesser General Public License v3.0 | 6 votes |
task("history", `WIP: Displays the transaction history of a Safe based on events (ordered newest first).
Only outgoing transactions made with a Safe >=1.1.0 will be displayed.`)
.addPositionalParam("address", "Address or ENS name of the Safe to check", undefined, types.string)
.addParam("start", "Start index of the tx to load", 0, types.int, true)
.setAction(async (taskArgs, hre) => {
const safe = await safeSingleton(hre, taskArgs.address)
const safeAddress = await safe.resolvedAddress
console.log(`Checking Safe at ${safeAddress}`)
console.log(await loadHistoryTxs(hre.ethers.provider, safeAddress, taskArgs.start))
});
Example #24
Source File: cpp-stable-pools.ts From trident with GNU General Public License v3.0 | 6 votes |
task("cpp-stable-pools", "Generate stable pool addresses")
.addOptionalParam("fee", "Fee tier", 30, types.int)
.addOptionalParam("twap", "Twap enabled", true, types.boolean)
.setAction(async function ({ fee, twap }, { ethers, run, getChainId }) {
const chainId = await getChainId();
const wnative = WNATIVE_ADDRESS[chainId];
const usdc = USDC_ADDRESS[chainId];
const dai = DAI_ADDRESS[chainId];
const usdt = USDT_ADDRESS[chainId];
for (const [tokenA, tokenB] of [
[wnative, usdc],
[wnative, usdt],
[wnative, dai],
]) {
console.log(`Genrating pool for tokenA: ${tokenA} and ${tokenB}`);
const address = await run("cpp-address", { tokenA, tokenB, fee, twap });
console.log(`Genrated address ${address} pool with tokenA: ${tokenA} and ${tokenB}`);
}
});
Example #25
Source File: update-configs.ts From nouns-monorepo with GNU General Public License v3.0 | 5 votes |
task('update-configs', 'Write the deployed addresses to the SDK and subgraph configs')
.addParam('contracts', 'Contract objects from the deployment', undefined, types.json)
.setAction(
async ({ contracts }: { contracts: Record<ContractName, DeployedContract> }, { ethers }) => {
const { name: network, chainId } = await ethers.provider.getNetwork();
// Update SDK addresses
const sdkPath = join(__dirname, '../../nouns-sdk');
const addressesPath = join(sdkPath, 'src/contract/addresses.json');
const addresses = JSON.parse(readFileSync(addressesPath, 'utf8'));
addresses[chainId] = {
nounsToken: contracts.NounsToken.address,
nounsSeeder: contracts.NounsSeeder.address,
nounsDescriptor: contracts.NounsDescriptor.address,
nftDescriptor: contracts.NFTDescriptor.address,
nounsAuctionHouse: contracts.NounsAuctionHouse.address,
nounsAuctionHouseProxy: contracts.NounsAuctionHouseProxy.address,
nounsAuctionHouseProxyAdmin: contracts.NounsAuctionHouseProxyAdmin.address,
nounsDaoExecutor: contracts.NounsDAOExecutor.address,
nounsDAOProxy: contracts.NounsDAOProxy.address,
nounsDAOLogicV1: contracts.NounsDAOLogicV1.address,
};
writeFileSync(addressesPath, JSON.stringify(addresses, null, 2));
try {
execSync('yarn build', {
cwd: sdkPath,
});
} catch {
console.log('Failed to re-build `@nouns/sdk`. Please rebuild manually.');
}
console.log('Addresses written to the Nouns SDK.');
// Generate subgraph config
const configName = `${network}-fork`;
const subgraphConfigPath = join(__dirname, `../../nouns-subgraph/config/${configName}.json`);
const subgraphConfig = {
network,
nounsToken: {
address: contracts.NounsToken.address,
startBlock: contracts.NounsToken.instance.deployTransaction.blockNumber,
},
nounsAuctionHouse: {
address: contracts.NounsAuctionHouseProxy.address,
startBlock: contracts.NounsAuctionHouseProxy.instance.deployTransaction.blockNumber,
},
nounsDAO: {
address: contracts.NounsDAOProxy.address,
startBlock: contracts.NounsDAOProxy.instance.deployTransaction.blockNumber,
},
};
writeFileSync(subgraphConfigPath, JSON.stringify(subgraphConfig, null, 2));
console.log('Subgraph config has been generated.');
},
);
Example #26
Source File: index.ts From hardhat-circom with GNU General Public License v3.0 | 5 votes |
task(TASK_CIRCOM, "compile circom circuits and template Verifier")
.addFlag("deterministic", "enable deterministic builds for groth16 protocol circuits (except for .wasm)")
.addFlag("debug", "output intermediate files to artifacts directory, generally for debug")
.addOptionalParam("circuit", "limit your circom task to a single circuit name", undefined, types.string)
.setAction(circomCompile);
Example #27
Source File: populate-descriptor.ts From nouns-monorepo with GNU General Public License v3.0 | 5 votes |
task('populate-descriptor', 'Populates the descriptor with color palettes and Noun parts')
.addOptionalParam(
'nftDescriptor',
'The `NFTDescriptor` contract address',
'0x5FbDB2315678afecb367f032d93F642f64180aa3',
types.string,
)
.addOptionalParam(
'nounsDescriptor',
'The `NounsDescriptor` contract address',
'0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512',
types.string,
)
.setAction(async ({ nftDescriptor, nounsDescriptor }, { ethers }) => {
const descriptorFactory = await ethers.getContractFactory('NounsDescriptor', {
libraries: {
NFTDescriptor: nftDescriptor,
},
});
const descriptorContract = descriptorFactory.attach(nounsDescriptor);
const { bgcolors, palette, images } = ImageData;
const { bodies, accessories, heads, glasses } = images;
// Chunk head and accessory population due to high gas usage
await descriptorContract.addManyBackgrounds(bgcolors);
await descriptorContract.addManyColorsToPalette(0, palette);
await descriptorContract.addManyBodies(bodies.map(({ data }) => data));
const accessoryChunk = chunkArray(accessories, 10);
for (const chunk of accessoryChunk) {
await descriptorContract.addManyAccessories(chunk.map(({ data }) => data));
}
const headChunk = chunkArray(heads, 10);
for (const chunk of headChunk) {
await descriptorContract.addManyHeads(chunk.map(({ data }) => data));
}
await descriptorContract.addManyGlasses(glasses.map(({ data }) => data));
console.log('Descriptor populated with palettes and parts.');
});
Example #28
Source File: index.ts From hardhat-circom with GNU General Public License v3.0 | 5 votes |
subtask(TASK_CIRCOM_TEMPLATE, "template Verifier with zkeys")
.addParam("zkeys", "array of zkey fastfiles (can be passed directly to SnarkJS)", undefined, types.any)
.setAction(circomTemplate);
Example #29
Source File: cpp-deploy.ts From trident with GNU General Public License v3.0 | 5 votes |
task("cpp-deploy", "Constant Product Pool deploy")
.addOptionalParam(
"tokenA",
"Token A",
WNATIVE_ADDRESS[ChainId.MATIC], // kovan weth
types.string
)
.addOptionalParam(
"tokenB",
"Token B",
USDC_ADDRESS[ChainId.MATIC], // kovan dai
types.string
)
.addOptionalParam("fee", "Fee tier", 30, types.int)
.addOptionalParam("twap", "Twap enabled", true, types.boolean)
.addOptionalParam("verify", "Verify", true, types.boolean)
.setAction(async function ({ tokenA, tokenB, fee, twap, verify }, { ethers, run }) {
const masterDeployer = await ethers.getContract<MasterDeployer>("MasterDeployer");
const constantProductPoolFactory = await ethers.getContract<ConstantProductPoolFactory>(
"ConstantProductPoolFactory"
);
const deployData = ethers.utils.defaultAbiCoder.encode(
["address", "address", "uint256", "bool"],
[...[tokenA, tokenB].sort(), fee, twap]
);
console.log([...[tokenA, tokenB].sort(), fee, twap], {
factory: constantProductPoolFactory.address,
deployData,
});
// console.log("1", [...[tokenA, tokenB].sort(), fee, twap]);
// const contractTransaction = await masterDeployer.deployPool(constantProductPoolFactory.address, deployData);
// console.log("2");
// if (!verify) return;
// const contractReceipt = await contractTransaction.wait(5);
// const { events } = contractReceipt;
// await run("verify:verify", {
// address: events?.[0].args?.pool,
// constructorArguments: [deployData, masterDeployer.address],
// });
});