-
Notifications
You must be signed in to change notification settings - Fork 0
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
6 changed files
with
189 additions
and
228 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { NitroRollup } from '@unruggable/gateways'; | ||
import { createProviderPair, providerURL } from './providers'; | ||
import { runExample } from './example-base'; | ||
import { type ConfigItem } from './utils'; | ||
|
||
const config = NitroRollup.arb1MainnetConfig; | ||
|
||
// Make sure you've created a .env and added node provider API keys | ||
console.log(providerURL(config.chain1)); | ||
console.log(providerURL(config.chain2)); | ||
|
||
const provider = providerURL(config.chain1); | ||
const rollup = await new NitroRollup( | ||
createProviderPair(config), | ||
config | ||
); | ||
const verifierPath = `@unruggable/contracts/nitro/NitroVerifier.sol`; | ||
const verifierArgs: any[] = []; | ||
const GATEWAY_URL = 'https://arbitrum-one.gateway.unruggable.com'; | ||
//This is the address of the SlotDataContract deployed on the L2 (that we fork) | ||
const EXAMPLE_CONTRACT_ADDRESS = '0xCC344B12fcc8512cc5639CeD6556064a8907c8a1'; //Arb | ||
const configurationToSet: ConfigItem[] = [ | ||
{ | ||
getter: 'getWindow', | ||
setter: 'setWindow', | ||
value: rollup.defaultWindow, | ||
}, | ||
{ | ||
getter: 'gatewayURLs', | ||
setter: 'setGatewayURLs', | ||
value: [GATEWAY_URL], | ||
}, | ||
{ | ||
setter: 'setRollup', | ||
value: rollup.L2Rollup.target, | ||
}, | ||
]; | ||
|
||
runExample(provider, verifierPath, verifierArgs, configurationToSet, EXAMPLE_CONTRACT_ADDRESS); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import { Foundry } from '@adraffy/blocksmith'; | ||
import { namehash, toBeHex, Contract } from 'ethers'; | ||
import { type ConfigItem, type VerifierArgsType } from './utils'; | ||
import { solidityFollowSlot } from '@unruggable/gateways'; | ||
|
||
const NAME_TO_TEST = "unruggable.eth"; | ||
|
||
export const runExample = async ( | ||
chainLink: string, | ||
verifierPath: string, | ||
verifierArgs: VerifierArgsType, | ||
configurationToSet: ConfigItem[], | ||
exampleContractAddress: string | ||
) => { | ||
|
||
const foundry = await Foundry.launch({ | ||
fork: chainLink, | ||
procLog : true, | ||
infoLog : true, | ||
}); | ||
|
||
const deployerWallet = foundry.wallets.admin; | ||
|
||
const verifierArgsToUse = typeof verifierArgs === 'function' ? await verifierArgs(foundry) : verifierArgs; | ||
|
||
//Deploy verifier | ||
const verifier = await foundry.deploy({ | ||
import: verifierPath, | ||
args: verifierArgsToUse, | ||
}); | ||
|
||
//Deploy proxy | ||
const proxy = await foundry.deploy({ | ||
import: `@unruggable/lib/openzeppelin-contracts/contracts/proxy/transparent/TransparentUpgradeableProxy.sol`, | ||
args: [verifier.target, deployerWallet.address, '0x'], | ||
}); | ||
|
||
// Instantiate the proxy using the underlying verifier interface | ||
const proxyUsingInterface = new Contract( | ||
proxy.target, | ||
verifier.interface, | ||
deployerWallet | ||
); | ||
|
||
// Configure the verifier | ||
for (const config of configurationToSet) { | ||
await foundry.confirm(proxyUsingInterface[config.setter](config.value)); | ||
console.log(`Set ${config.setter} to ${config.value}`); | ||
} | ||
|
||
const ENS = '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e'; | ||
const NODE = namehash(NAME_TO_TEST); | ||
const SLOT = solidityFollowSlot(0, NODE) + 1n; | ||
|
||
const arbitrumOneResolver = await foundry.deploy({ | ||
file: 'ExampleResolver', | ||
args: [proxy.target, exampleContractAddress], | ||
}); | ||
|
||
console.log('Arbitrum One Resolver deployment:', arbitrumOneResolver.target); | ||
|
||
await foundry.provider.send('anvil_setStorageAt', [ | ||
ENS, | ||
toBeHex(SLOT, 32), | ||
toBeHex(arbitrumOneResolver.target, 32), | ||
]); | ||
const ens = new Contract( | ||
ENS, | ||
['function resolver(bytes32 node) view returns (address)'], | ||
foundry.provider | ||
); | ||
console.log('Hijacked:', await ens.resolver(NODE)); | ||
|
||
async function resolve(name: string, keys = ['avatar'], coinType = 60) { | ||
const resolver = await foundry.provider.getResolver(name); | ||
|
||
console.log("Resolver", resolver); | ||
|
||
if (!resolver) throw new Error('bug'); | ||
const [address] = await Promise.all([ | ||
resolver.getAddress(coinType) | ||
]); | ||
console.log({ | ||
name, | ||
address, | ||
}); | ||
} | ||
|
||
await resolve(NAME_TO_TEST); | ||
|
||
await foundry.shutdown(); | ||
} |
Oops, something went wrong.