Skip to content

Commit

Permalink
Merge branch 'main' into feat-factories-by-default
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc authored Dec 20, 2023
2 parents b9b4a30 + 9199d0d commit bd0d507
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 6 deletions.
43 changes: 41 additions & 2 deletions src/chains.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,43 @@
import { defineChain } from 'viem';
import { sepolia, arbitrumSepolia } from 'viem/chains';

export const chains = [sepolia, arbitrumSepolia];
export { sepolia, arbitrumSepolia };
const nitroTestnodeL1 = defineChain({
id: 1_337,
network: 'Nitro Testnode L1',
name: 'nitro-testnode-l1',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['http://127.0.0.1:8545'],
},
public: {
http: ['http://127.0.0.1:8545'],
},
},
testnet: true,
});

const nitroTestnodeL2 = defineChain({
id: 412_346,
network: 'Nitro Testnode L2',
name: 'nitro-testnode-l2',
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
rpcUrls: {
default: {
http: ['http://127.0.0.1:8547'],
},
public: {
http: ['http://127.0.0.1:8547'],
},
},
testnet: true,
});

export const chains = [
sepolia,
arbitrumSepolia,
nitroTestnodeL1,
nitroTestnodeL2,
] as const;

export { sepolia, arbitrumSepolia, nitroTestnodeL1, nitroTestnodeL2 };
4 changes: 2 additions & 2 deletions src/createRollupGetMaxDataSize.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { sepolia } from './chains';
import { sepolia, nitroTestnodeL1 } from './chains';
import { ParentChainId } from './types/ParentChain';

export function createRollupGetMaxDataSize(parentChainId: ParentChainId) {
// L2
if (parentChainId === sepolia.id) {
if (parentChainId === sepolia.id || parentChainId === nitroTestnodeL1.id) {
return BigInt(117_964);
}

Expand Down
7 changes: 7 additions & 0 deletions src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./chains": {
"types": "./dist/chains.d.ts",
"default": "./dist/chains.js"
},
"./contracts": {
"types": "./dist/contracts.d.ts",
"default": "./dist/contracts.js"
Expand All @@ -22,6 +26,9 @@
},
"typesVersions": {
"*": {
"chains": [
"./dist/chains.d.ts"
],
"contracts": [
"./dist/contracts.d.ts"
],
Expand Down
9 changes: 8 additions & 1 deletion src/prepareNodeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import {
import { ChainConfig } from './types/ChainConfig';
import { CoreContracts } from './types/CoreContracts';
import { ParentChainId, validParentChainId } from './types/ParentChain';
import { sepolia, arbitrumSepolia } from './chains';
import {
sepolia,
arbitrumSepolia,
nitroTestnodeL1,
nitroTestnodeL2,
} from './chains';

function sanitizePrivateKey(privateKey: string) {
return privateKey.startsWith('0x') ? privateKey.slice(2) : privateKey;
Expand All @@ -26,9 +31,11 @@ function parentChainIsArbitrum(parentChainId: ParentChainId): boolean {
// doing switch here to make sure it's exhaustive when checking against `ParentChainId`
switch (parentChainId) {
case sepolia.id:
case nitroTestnodeL1.id:
return false;

case arbitrumSepolia.id:
case nitroTestnodeL2.id:
return true;
}
}
Expand Down
24 changes: 23 additions & 1 deletion wagmi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { erc, etherscan } from '@wagmi/cli/plugins';
import dotenv from 'dotenv';

import { ParentChainId } from './src';
import { sepolia, arbitrumSepolia } from './src/chains';
import {
sepolia,
arbitrumSepolia,
nitroTestnodeL1,
nitroTestnodeL2,
} from './src/chains';

dotenv.config();

Expand All @@ -17,8 +22,12 @@ function sleep(ms: number = 3_000) {
}

const blockExplorerApiUrls: Record<ParentChainId, string> = {
// testnet
[sepolia.id]: 'https://api-sepolia.etherscan.io/api',
[arbitrumSepolia.id]: 'https://api-sepolia.arbiscan.io/api',
// local nitro-testnode / fine to omit these as we skip abi fetch
[nitroTestnodeL1.id]: '',
[nitroTestnodeL2.id]: '',
};

export async function fetchAbi(chainId: ParentChainId, address: `0x${string}`) {
Expand All @@ -40,16 +49,24 @@ const contracts: ContractConfig[] = [
name: 'RollupCreator',
version: '1.1.0',
address: {
// testnet
[sepolia.id]: '0xfbd0b034e6305788007f6e0123cc5eae701a5751',
[arbitrumSepolia.id]: '0x06E341073b2749e0Bb9912461351f716DeCDa9b0',
// local nitro-testnode (on "use-tokenbridge-creator" branch)
[nitroTestnodeL1.id]: '0x596eabe0291d4cdafac7ef53d16c92bf6922b5e0',
[nitroTestnodeL2.id]: '0x3BaF9f08bAD68869eEdEa90F2Cc546Bd80F1A651',
},
},
{
name: 'TokenBridgeCreator',
version: '1.1.2',
address: {
// testnet
[sepolia.id]: '0x7612718D3143C791B2Ff5c01a9a7D02CEf00AE9c',
[arbitrumSepolia.id]: '0xb462C69f8f638d2954c9618B03765FC1770190cF',
// local nitro-testnode (on "use-tokenbridge-creator" branch)
[nitroTestnodeL1.id]: '0x4a2ba922052ba54e29c5417bc979daaf7d5fe4f4',
[nitroTestnodeL2.id]: '0x38f35af53bf913c439eab06a367e09d6eb253492',
},
},
{
Expand All @@ -75,6 +92,11 @@ export async function assertContractAbisMatch(contract: ContractConfig) {

const abis = await Promise.all(
Object.entries(contract.address)
// don't fetch abis for testnode
.filter(([chainIdString]) => {
const chainId = Number(chainIdString);
return chainId !== nitroTestnodeL1.id && chainId !== nitroTestnodeL2.id;
})
// fetch abis for all chains
.map(([chainId, address]) =>
fetchAbi(Number(chainId) as ParentChainId, address)
Expand Down

0 comments on commit bd0d507

Please sign in to comment.