-
Notifications
You must be signed in to change notification settings - Fork 42
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
15 changed files
with
4,087 additions
and
17 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 { 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, | ||
}); | ||
}); |
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,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); | ||
} |
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,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); | ||
} |
Oops, something went wrong.