Skip to content

Commit

Permalink
fix: Add tokenURI param to DomainRegistered event (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
Whytecrowe authored Dec 19, 2023
2 parents 786e4c3 + 0d645ed commit b3ce424
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 15 deletions.
6 changes: 4 additions & 2 deletions contracts/registrar/IZNSRootRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ interface IZNSRootRegistrar is IDistributionConfig {
* This can be 0 as this variable is not required to perform registration process
* and can be set at a later time by the domain owner.
* @param parentHash The hash of the parent domain (0x0 for root domains)
* @param label The name as the last part of the full domain string (level) registered
* @param domainHash The hash of the domain registered
* @param tokenId The tokenId of the domain registered
* @param label The name as the last part of the full domain string (level) registered
* @param tokenURI The tokenURI of the domain registered
* @param registrant The address that called `ZNSRootRegistrar.registerRootDomain()`
* @param domainAddress The domain address of the domain registered
*/
event DomainRegistered(
bytes32 parentHash,
bytes32 indexed domainHash,
uint256 indexed tokenId,
string label,
uint256 indexed tokenId,
string tokenURI,
address indexed registrant,
address domainAddress
);
Expand Down
3 changes: 2 additions & 1 deletion contracts/registrar/ZNSRootRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ contract ZNSRootRegistrar is
emit DomainRegistered(
args.parentHash,
args.domainHash,
tokenId,
args.label,
tokenId,
args.tokenURI,
args.registrant,
args.domainAddress
);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"gas-cost": "ts-node src/utils/gas-costs.ts",
"docgen": "hardhat docgen",
"save-tag": "chmod a+x ./src/utils/git-tag/save-tag.sh && bash ./src/utils/git-tag/save-tag.sh",
"base64": "ts-node src/utils/convert-base64.ts",
"mongo:start": "docker-compose up -d",
"mongo:stop": "docker-compose stop",
"mongo:down": "docker-compose down",
Expand Down
6 changes: 2 additions & 4 deletions src/deploy/campaign/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import {
} from "../../../test/helpers";
import { ethers } from "ethers";
import { ICurvePriceConfig } from "../missions/types";
import { DEFAULT_MONGO_URI } from "../db/mongo-adapter/constants";
import { MeowMainnet } from "../missions/contracts/meow-token/mainnet-data";
import { DefenderRelaySigner } from "@openzeppelin/defender-sdk-relay-signer-client/lib/ethers";
import env from "hardhat";


const getCustomAddresses = (
Expand Down Expand Up @@ -164,7 +162,7 @@ export const validateEnv = (
throw new Error("Must provide a default royalty fraction");
}

if (!process.env.MONGO_URI) {
if (!process.env.MONGO_DB_URI) {
throw new Error(`Must provide a Mongo URI used for ${envLevel} environment!`);
}

Expand All @@ -174,7 +172,7 @@ export const validateEnv = (
if (envLevel === "prod") {
requires(process.env.MOCK_MEOW_TOKEN === "false", NO_MOCK_PROD_ERR);
requires(process.env.STAKING_TOKEN_ADDRESS === MeowMainnet.address, STAKING_TOKEN_ERR);
requires(!process.env.MONGO_URI.includes("localhost"), MONGO_URI_ERR);
requires(!process.env.MONGO_DB_URI.includes("localhost"), MONGO_URI_ERR);
}

if (process.env.VERIFY_CONTRACTS === "true") {
Expand Down
19 changes: 19 additions & 0 deletions src/utils/convert-base64.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


const toBase64 = (str : string) => btoa(str);

const fromBase64 = (str : string) => atob(str);

const [
toOrFrom,
str,
] = process.argv.slice(2);


if (toOrFrom === "to") {
console.log(toBase64(str));
} else if (toOrFrom === "from") {
console.log(fromBase64(str));
} else {
console.log("Invalid arguments");
}
4 changes: 2 additions & 2 deletions test/DeployCampaignInt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ describe("Deploy Campaign Test", () => {
process.env.MOCK_MEOW_TOKEN = "false";
process.env.STAKING_TOKEN_ADDRESS = MeowMainnet.address;
// Falls back onto the default URI which is for localhost and fails in prod
process.env.MONGO_URI = "";
process.env.MONGO_DB_URI = "";
process.env.ROYALTY_RECEIVER = "0x123";
process.env.ROYALTY_FRACTION = "100";

Expand All @@ -801,7 +801,7 @@ describe("Deploy Campaign Test", () => {

process.env.MOCK_MEOW_TOKEN = "false";
process.env.STAKING_TOKEN_ADDRESS = MeowMainnet.address;
process.env.MONGO_URI = "mongodb://localhost:27018";
process.env.MONGO_DB_URI = "mongodb://localhost:27018";
process.env.ZERO_VAULT_ADDRESS = "0x123";

try {
Expand Down
12 changes: 8 additions & 4 deletions test/ZNSRootRegistrar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,9 @@ describe("ZNSRootRegistrar", () => {
await expect(tx1).to.emit(zns.rootRegistrar, "DomainRegistered").withArgs(
ethers.ZeroHash,
lettersHash,
BigInt(lettersHash),
letters,
BigInt(lettersHash),
DEFAULT_TOKEN_URI,
deployer.address,
ethers.ZeroAddress,
);
Expand All @@ -493,8 +494,9 @@ describe("ZNSRootRegistrar", () => {
await expect(tx2).to.emit(zns.rootRegistrar, "DomainRegistered").withArgs(
ethers.ZeroHash,
alphaNumericHash,
BigInt(alphaNumericHash),
alphaNumeric,
BigInt(alphaNumericHash),
DEFAULT_TOKEN_URI,
deployer.address,
ethers.ZeroAddress,
);
Expand All @@ -513,8 +515,9 @@ describe("ZNSRootRegistrar", () => {
await expect(tx3).to.emit(zns.rootRegistrar, "DomainRegistered").withArgs(
ethers.ZeroHash,
withHyphenHash,
BigInt(withHyphenHash),
withHyphen,
BigInt(withHyphenHash),
DEFAULT_TOKEN_URI,
deployer.address,
ethers.ZeroAddress,
);
Expand Down Expand Up @@ -579,8 +582,9 @@ describe("ZNSRootRegistrar", () => {
await expect(tx).to.emit(zns.rootRegistrar, "DomainRegistered").withArgs(
ethers.ZeroHash,
hashFromTS,
BigInt(hashFromTS),
defaultDomain,
BigInt(hashFromTS),
tokenURI,
user.address,
ethers.ZeroAddress,
);
Expand Down
8 changes: 6 additions & 2 deletions test/helpers/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ export const getDomainRegisteredEvents = async ({
const filter = zns.rootRegistrar.filters.DomainRegistered(
undefined,
domainHash,
undefined,
tokenId,
undefined,
registrant
registrant,
undefined
);

return zns.rootRegistrar.queryFilter(filter, latestBlock - blockRange, latestBlock);
Expand All @@ -42,7 +44,9 @@ export const getDomainHashFromEvent = async ({
undefined,
undefined,
undefined,
user.address
undefined,
user.address,
undefined,
);

const events = await zns.rootRegistrar.queryFilter(filter, latestBlock - 2, latestBlock);
Expand Down

0 comments on commit b3ce424

Please sign in to comment.