Skip to content

Commit

Permalink
everything before cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
spsjvc committed Dec 28, 2023
1 parent 1f251f7 commit ec5967d
Show file tree
Hide file tree
Showing 15 changed files with 4,087 additions and 17 deletions.
39 changes: 39 additions & 0 deletions src/all.integration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { it, expect } from 'vitest';
import { createPublicClient, http, parseGwei, zeroAddress } from 'viem';

import { nitroTestnodeL1, nitroTestnodeL2 } from './chains';
import { generateChainId } from './utils';
import { prepareChainConfig } from './prepareChainConfig';
import { createRollupPrepareConfig } from './createRollupPrepareConfig';
import { createRollupPrepareTransactionRequest } from './createRollupPrepareTransactionRequest';
import { createRollupPrepareTransactionReceipt } from './createRollupPrepareTransactionReceipt';

import { getTestPrivateKeyAccount, testSetupCreateRollup } from './testHelpers';
import { createTokenBridgePrepareTransactionRequest } from './createTokenBridge';

const deployer = getTestPrivateKeyAccount();

const nitroTestnodeL1Client = createPublicClient({
chain: nitroTestnodeL1,
transport: http(),
});

const nitroTestnodeL2Client = createPublicClient({
chain: nitroTestnodeL2,
transport: http(),
});

it(`successfully deploys core contracts through rollup creator`, async () => {
const txReceipt = await testSetupCreateRollup();
const { rollup, inbox } = txReceipt.getCoreContracts();

await createTokenBridgePrepareTransactionRequest({
parentPublicClient: nitroTestnodeL1Client,
orbitPublicClient: nitroTestnodeL2Client,
params: {
rollup,
rollupOwner: deployer.address,
},
account: deployer.address,
});
});
21 changes: 21 additions & 0 deletions src/compat/publicClientToProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PublicClient } from 'viem';
import { providers } from 'ethers';

export function publicClientToProvider(publicClient: PublicClient) {
const { chain, transport } = publicClient;

console.log({ transport: transport.url });
const transportUrl = chain?.rpcUrls.default.http[0] ?? 'http://localhost:8545';

if (typeof chain === 'undefined') {
throw new Error(`[publicClientToProvider] chain is undefined`);
}

const network = {
chainId: chain.id,
name: chain.name,
ensAddress: chain.contracts?.ensRegistry?.address,
};

return new providers.StaticJsonRpcProvider(transportUrl, network);
}
22 changes: 22 additions & 0 deletions src/compat/walletClientToSigner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { WalletClient } from 'viem';
import { providers } from 'ethers';

export function walletClientToSigner(walletClient: WalletClient) {
const { account, chain, transport } = walletClient;

if (typeof account === 'undefined') {
throw new Error(`[walletClientToSigner] account is undefined`);
}

if (typeof chain === 'undefined') {
throw new Error(`[walletClientToSigner] chain is undefined`);
}

const network = {
chainId: chain.id,
name: chain.name,
ensAddress: chain.contracts?.ensRegistry?.address,
};

return new providers.Web3Provider(transport, network).getSigner(account.address);
}
Loading

0 comments on commit ec5967d

Please sign in to comment.