From 6732f3c723e7928e43351a3eb60ed8fcb1ed0d35 Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 19 Dec 2023 12:19:56 -0800 Subject: [PATCH 1/3] add tokenURI param to DomainRegistered event --- contracts/registrar/IZNSRootRegistrar.sol | 6 ++++-- contracts/registrar/ZNSRootRegistrar.sol | 3 ++- test/ZNSRootRegistrar.test.ts | 12 ++++++++---- test/helpers/events.ts | 8 ++++++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/contracts/registrar/IZNSRootRegistrar.sol b/contracts/registrar/IZNSRootRegistrar.sol index 4672f448..365efbbf 100644 --- a/contracts/registrar/IZNSRootRegistrar.sol +++ b/contracts/registrar/IZNSRootRegistrar.sol @@ -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 ); diff --git a/contracts/registrar/ZNSRootRegistrar.sol b/contracts/registrar/ZNSRootRegistrar.sol index 2601daf8..30de690a 100644 --- a/contracts/registrar/ZNSRootRegistrar.sol +++ b/contracts/registrar/ZNSRootRegistrar.sol @@ -198,8 +198,9 @@ contract ZNSRootRegistrar is emit DomainRegistered( args.parentHash, args.domainHash, - tokenId, args.label, + tokenId, + args.tokenURI, args.registrant, args.domainAddress ); diff --git a/test/ZNSRootRegistrar.test.ts b/test/ZNSRootRegistrar.test.ts index 587bf9d4..bbb3f2c9 100644 --- a/test/ZNSRootRegistrar.test.ts +++ b/test/ZNSRootRegistrar.test.ts @@ -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, ); @@ -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, ); @@ -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, ); @@ -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, ); diff --git a/test/helpers/events.ts b/test/helpers/events.ts index 73822d17..0fb5ddff 100644 --- a/test/helpers/events.ts +++ b/test/helpers/events.ts @@ -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); @@ -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); From 1fb61278534f5e58184f6ddc2408be2830834b4d Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 19 Dec 2023 13:03:12 -0800 Subject: [PATCH 2/3] fix mongo db env var name --- src/deploy/campaign/environments.ts | 6 ++---- test/DeployCampaignInt.test.ts | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/deploy/campaign/environments.ts b/src/deploy/campaign/environments.ts index a389e48d..f8b064a9 100644 --- a/src/deploy/campaign/environments.ts +++ b/src/deploy/campaign/environments.ts @@ -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 = ( @@ -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!`); } @@ -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") { diff --git a/test/DeployCampaignInt.test.ts b/test/DeployCampaignInt.test.ts index 3944b552..d2dded9d 100644 --- a/test/DeployCampaignInt.test.ts +++ b/test/DeployCampaignInt.test.ts @@ -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"; @@ -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 { From 0d645ed50b4fa1fa2a311b7635ab136d29d1d7c2 Mon Sep 17 00:00:00 2001 From: Kirill Date: Tue, 19 Dec 2023 13:03:25 -0800 Subject: [PATCH 3/3] add base64 converter util script --- package.json | 1 + src/utils/convert-base64.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/utils/convert-base64.ts diff --git a/package.json b/package.json index 9c578710..25773c07 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/utils/convert-base64.ts b/src/utils/convert-base64.ts new file mode 100644 index 00000000..79a4a55b --- /dev/null +++ b/src/utils/convert-base64.ts @@ -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"); +}