forked from ensdomains/evmgateway
-
Notifications
You must be signed in to change notification settings - Fork 3
/
linea-ens.ts
executable file
·53 lines (47 loc) · 1.73 KB
/
linea-ens.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { Foundry } from '@adraffy/blocksmith';
import { serve } from '@resolverworks/ezccip/serve';
import { ethers } from 'ethers';
import { createProviderPair, providerURL } from '../providers.js';
import { LineaGatewayV1 } from '../../src/linea/LineaGatewayV1.js';
import { LineaRollup } from '../../src/linea/LineaRollup.js';
import { encodeShortString } from '../utils.js';
import { toPaddedHex } from '../../src/utils.js';
// backend for linea.eth / https://names.linea.build/
const config = LineaRollup.mainnetConfig;
const rollup = new LineaRollup(createProviderPair(config), config);
const gateway = new LineaGatewayV1(rollup);
const ccip = await serve(gateway, { protocol: 'raw' });
const foundry = await Foundry.launch({
fork: providerURL(config.chain1),
infoLog: false,
});
const VERIFIER = '0x2aD1A39a3b616FB11ac5DB290061A0A5C09771f3';
const SLOT = BigInt(ethers.solidityPackedKeccak256(['uint256'], [0]));
await foundry.provider.send('anvil_setStorageAt', [
VERIFIER,
toPaddedHex(SLOT),
encodeShortString(ccip.endpoint),
]);
const verifier = new ethers.Contract(
VERIFIER,
['function gatewayURLs() external view returns (string[])'],
foundry.provider
);
console.log('Hijacked:', await verifier.gatewayURLs());
await resolve('raffy.linea.eth');
// await resolve('premm.linea.eth');
// await resolve('tom.linea.eth');
await resolve('_dne123.linea.eth');
async function resolve(name: string) {
console.log();
console.log(name);
const resolver = await foundry.provider.getResolver(name);
if (!resolver) throw new Error('expected resolver');
const [address, avatar] = await Promise.all([
resolver.getAddress(),
resolver.getAvatar(),
]);
console.log({ address, avatar });
}
ccip.shutdown;
await foundry.shutdown();