Skip to content

Commit

Permalink
refactor: transfer domain dry run logs
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jun 30, 2023
1 parent 24e36c9 commit 1142c8a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 2 additions & 2 deletions scripts/transfer_domains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EWC_CHAIN_ID } from '@energyweb/credential-governance';
import { VOLTA_CHAIN_ID } from '@energyweb/credential-governance';
import { Wallet } from 'ethers';
import { transferDomain } from '../src/utils/transfer-domains';

Expand All @@ -13,7 +13,7 @@ export const ewcPrivateKey = Wallet.createRandom().privateKey;
rootDomain,
signer: new Wallet(ewcPrivateKey),
newOwner,
chainId: EWC_CHAIN_ID,
chainId: VOLTA_CHAIN_ID,
dryRun: true,
});
}
Expand Down
11 changes: 3 additions & 8 deletions src/utils/transfer-domains.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import { ChainId } from '..';
// import {
// DomainHierarchy,
// DomainReader,
// DomainTransactionFactoryV2,
// ResolverContractType,
// } from './domains-build.js';
import { Wallet } from 'ethers';
import { namehash, labelhash } from './ens-hash';
import { getLogger } from '../config/logger.config';
Expand Down Expand Up @@ -36,7 +30,6 @@ export const transferDomain = async ({
);
const transferred: Record<string, unknown>[] = [];
const transfer = async (domain: string) => {
logger.info(`Transferring ${domain}`);
const domainHash = namehash(domain);

let def;
Expand Down Expand Up @@ -65,11 +58,12 @@ export const transferDomain = async ({
subnodes.push(`orgs.${domain}`);
}
}
logger.info(`Subnodes of ${domain} are ${subnodes}`);
logger.info(`Subnodes of ${domain} are ${subnodes ?? 'not set'}`);
for await (const nodeName of subnodes) {
console.group();
const label = nodeName.split('.')[0];
const labelHash = labelhash(label);
console.log(`${dryRun ? 'Would transfer' : 'Transferring'} ${nodeName}`);
if (!dryRun) {
await (
await ensRegistry.setSubnodeOwner(
Expand All @@ -82,6 +76,7 @@ export const transferDomain = async ({
await transfer(nodeName);
console.groupEnd();
}
console.log(`${dryRun ? 'Would transfer' : 'Transferring'} ${domain}`);
if (!dryRun) {
await (await ensRegistry.setOwner(domainHash, newOwner)).wait();
}
Expand Down

0 comments on commit 1142c8a

Please sign in to comment.