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 c747db3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
10 changes: 5 additions & 5 deletions scripts/transfer_domains.ts
@@ -1,19 +1,19 @@
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';

export const domains = ['energyweb.iam.ewc'];
export const newOwner = '0x205801aAbf81B65B3b7C52041991994d6c2e9F9d';
export const ewcPrivateKey = Wallet.createRandom().privateKey;
export const newOwner = '';
export const ownerPrivKey = Wallet.createRandom().privateKey;

(async function () {
try {
for await (const rootDomain of domains) {
await transferDomain({
rootDomain,
signer: new Wallet(ewcPrivateKey),
signer: new Wallet(ownerPrivKey),
newOwner,
chainId: EWC_CHAIN_ID,
chainId: VOLTA_CHAIN_ID,
dryRun: true,
});
}
Expand Down
11 changes: 3 additions & 8 deletions src/utils/transfer-domains.ts
@@ -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 c747db3

Please sign in to comment.