+1








01fd5237f5
Signed-off-by: Joaquim Verges <[email protected]> Signed-off-by: jxom <[email protected]> Signed-off-by: greg <[email protected]> Signed-off-by: Jonas Daniels <[email protected]> Co-authored-by: GitHub Action <[email protected]> Co-authored-by: Manan Tank <[email protected]> Co-authored-by: Joaquim Verges <[email protected]> Co-authored-by: jxom <[email protected]> Co-authored-by: Nacho Iacovino <[email protected]> Co-authored-by: greg <[email protected]> Co-authored-by: Winston Yeo <[email protected]> Co-authored-by: iketw <[email protected]> Co-authored-by: Winston Yeo <[email protected]> Co-authored-by: Isaac Dubuque <[email protected]>
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { sha256 } from "@noble/hashes/sha256";
|
|
import { startProxy } from "@viem/anvil";
|
|
import { FORK_BLOCK_NUMBER, OPTIMISM_FORK_BLOCK_NUMBER } from "./src/chains.js";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
require("dotenv-mono").load();
|
|
|
|
const SECRET_KEY = process.env.TW_SECRET_KEY as string;
|
|
|
|
const clientId = SECRET_KEY
|
|
? // eslint-disable-next-line no-restricted-globals
|
|
Buffer.from(sha256(SECRET_KEY)).toString("hex").slice(0, 32)
|
|
: "";
|
|
|
|
export default async function globalSetup() {
|
|
const shutdownMainnet = await startProxy({
|
|
port: 8645,
|
|
options: {
|
|
chainId: 1,
|
|
forkUrl: `https://1.rpc.thirdweb.com/${clientId}`,
|
|
forkHeader: { "x-secret-key": SECRET_KEY },
|
|
forkChainId: 1,
|
|
forkBlockNumber: FORK_BLOCK_NUMBER,
|
|
noMining: true,
|
|
startTimeout: 20000,
|
|
},
|
|
});
|
|
|
|
const shutdownOptimism = await startProxy({
|
|
port: 8646,
|
|
options: {
|
|
chainId: 10,
|
|
forkUrl: `https://10.rpc.thirdweb.com/${clientId}`,
|
|
forkHeader: { "x-secret-key": SECRET_KEY },
|
|
forkChainId: 10,
|
|
forkBlockNumber: OPTIMISM_FORK_BLOCK_NUMBER,
|
|
noMining: true,
|
|
startTimeout: 20000,
|
|
},
|
|
});
|
|
|
|
const shutdownAnvil = await startProxy({
|
|
port: 8647,
|
|
});
|
|
|
|
return () => {
|
|
shutdownMainnet();
|
|
shutdownOptimism();
|
|
shutdownAnvil();
|
|
};
|
|
}
|