-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Tenderly DevNets Integration (#30)
- Loading branch information
Showing
22 changed files
with
907 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,7 @@ typechain-types | |
cache | ||
artifacts | ||
|
||
# hardhat-tenderly plugin | ||
deployments | ||
|
||
*.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.18; | ||
|
||
import { ZNSRegistrar } from "../../distribution/ZNSRegistrar.sol"; | ||
import { UpgradeMock } from "../UpgradeMock.sol"; | ||
|
||
/* solhint-disable */ | ||
contract ZNSRegistrarUpgradeMock is ZNSRegistrar, UpgradeMock {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires, no-console */ | ||
import { promisify } from "util"; | ||
import { exec } from "child_process"; | ||
|
||
const execAsync = promisify(exec); | ||
|
||
const spawnCommand = "ts-node src/tenderly/spawn-devnet.ts"; | ||
const opCommandBase = "npx hardhat run"; | ||
const networkArg = "--network devnet"; | ||
const opsPath = "src/tenderly/run-all-flows.ts"; | ||
|
||
/** | ||
* Top level function to execute everything on the DevNet. | ||
* It executes 2 child processes: | ||
* 1. Spawn a DevNet through the helper and ts-node directly, | ||
* this will also set all the required env vars, so that Hardhat can correctly | ||
* work with contracts and auth in Tenderly | ||
* 2. Launch deploy and operation flow with contracts using Hardhat | ||
* | ||
* To execute this, uncomment `tenderly.setup()` line in the hardhat.config.ts | ||
* then run `yarn devnet` in the terminal. | ||
* */ | ||
const execute = async () => { | ||
// spawn DevNet on Tenderly with ts-node directly | ||
const spawnRes = await execAsync(spawnCommand); | ||
process.stdout.write(spawnRes.stdout); | ||
process.stderr.write(spawnRes.stderr); | ||
|
||
const opCommand = `${opCommandBase} ${opsPath} ${networkArg}`; | ||
|
||
// deploy all contracts, run flows using Hardhat | ||
const opRes = await execAsync(opCommand); | ||
// pass Tenderly logger through | ||
process.stdout.write(opRes.stdout); | ||
process.stderr.write(opRes.stderr); | ||
|
||
return spawnRes; | ||
}; | ||
|
||
|
||
execute() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
console.error(error); | ||
process.exit(1); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import * as hre from "hardhat"; | ||
import * as ethers from "ethers"; | ||
import { deployZNS, hashDomainLabel } from "../../test/helpers"; | ||
import { BigNumber } from "ethers"; | ||
|
||
|
||
const domainName = "wilder"; | ||
const domainHash = hashDomainLabel(domainName); | ||
const tokenId = BigNumber.from(domainHash); | ||
|
||
|
||
export const runAllFlows = async () => { | ||
const [ | ||
governor, | ||
user, | ||
] = await hre.ethers.getSigners(); | ||
|
||
const zns = await deployZNS({ | ||
deployer: governor, | ||
governorAddresses: [governor.address], | ||
adminAddresses: [governor.address], | ||
logAddresses: true, | ||
}); | ||
|
||
// get some funds for the user | ||
await zns.zeroToken.connect(user).approve(zns.treasury.address, ethers.constants.MaxUint256); | ||
await zns.zeroToken.transfer(user.address, ethers.utils.parseEther("15")); | ||
|
||
// Register Domain | ||
await zns.registrar.connect(governor).registerDomain( | ||
domainName, | ||
user.address, | ||
); | ||
|
||
// Transfer Domain | ||
await zns.domainToken.connect(governor).transferFrom(governor.address, user.address, tokenId); | ||
|
||
// Reclaim Domain | ||
await zns.registrar.connect(user).reclaimDomain(domainHash); | ||
|
||
// Revoke Domain | ||
await zns.registrar.connect(user).revokeDomain(domainHash); | ||
}; | ||
|
||
|
||
runAllFlows() | ||
.then(() => process.exit(0)) | ||
.catch(error => { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
process.exit(1); | ||
}); |
Oops, something went wrong.