generated from Destiner/starter-app
-
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.
- Loading branch information
Showing
7 changed files
with
1,310 additions
and
36 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
File renamed without changes.
Large diffs are not rendered by default.
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
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,31 @@ | ||
import { keccak256, type Address, type Hex } from 'viem'; | ||
|
||
import addresses from '@/data/addresses.json'; | ||
import cache from '@/data/cache.json'; | ||
import { type Chain, CHAINS, getCode as getChainCode } from '@/utils/chains'; | ||
|
||
async function run(): Promise<void> { | ||
const newCache: Record<Address, Partial<Record<Chain, string>>> = {}; | ||
for (const addressString in addresses) { | ||
const address = addressString as Address; | ||
console.log(address); | ||
newCache[address] = {}; | ||
for (const chain of CHAINS) { | ||
const addressCache = ( | ||
cache as Record<Address, Partial<Record<Chain, Hex>>> | ||
)[address]; | ||
if (addressCache && addressCache[chain]) { | ||
newCache[address as Address][chain] = addressCache[chain]; | ||
continue; | ||
} | ||
const code = await getChainCode(chain, address); | ||
if (!code) { | ||
continue; | ||
} | ||
newCache[address as Address][chain] = keccak256(code); | ||
} | ||
} | ||
console.log(JSON.stringify(cache, null, 2)); | ||
} | ||
|
||
run(); |
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