Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
douglance committed Nov 18, 2024
1 parent f7067c2 commit fe1b33c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type PublicClient,
TransactionRequest,
} from 'viem'
import { EthBridger } from '../../lib/assetBridger/ethBridger'
import { EthBridger } from '../lib/assetBridger/ethBridger'
import { transformPublicClientToProvider } from './transformViemToEthers'

export type PrepareDepositEthParameters = {
Expand Down
42 changes: 0 additions & 42 deletions src/experimental/arbitrumDeposit/abis/inbox.ts

This file was deleted.

23 changes: 0 additions & 23 deletions src/experimental/arbitrumDeposit/abis/l1GatewayRouter.ts

This file was deleted.

56 changes: 0 additions & 56 deletions src/experimental/arbitrumDeposit/types.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { Chain, PublicClient, createPublicClient, http } from 'viem'
import { ArbitrumNetwork } from '../../lib/dataEntities/networks'
import { ArbitrumNetwork } from '../lib/dataEntities/networks'
import { arbitrumDepositActions } from './actions'

export type ArbitrumChain = Chain & ArbitrumNetwork

export type ArbitrumClients = {
parentChainPublicClient: PublicClient
childChainPublicClient: PublicClient &
ReturnType<typeof arbitrumDepositActions>
parentPublicClient: PublicClient
childPublicClient: PublicClient & ReturnType<typeof arbitrumDepositActions>
}
export type ChildChainPublicClient = PublicClient &
ReturnType<typeof arbitrumDepositActions>
Expand All @@ -25,18 +24,18 @@ export function createArbitrumClient({
parentRpcUrl,
childRpcUrl,
}: CreateArbitrumClientParams): ArbitrumClients {
const parentChainPublicClient = createPublicClient({
const parentPublicClient = createPublicClient({
chain: parentChain,
transport: http(parentRpcUrl || parentChain.rpcUrls.default.http[0]),
})

const childChainPublicClient = createPublicClient({
const childPublicClient = createPublicClient({
chain: childChain,
transport: http(childRpcUrl || childChain.rpcUrls.default.http[0]),
}).extend(arbitrumDepositActions())

return {
parentChainPublicClient,
childChainPublicClient,
parentPublicClient,
childPublicClient,
} as any as ArbitrumClients
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { createWalletClient, http, parseEther } from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { config, testSetup } from '../../scripts/testSetup'
import { localEthChain, localArbChain } from '../../src/experimental/chains'
import { createArbitrumClient } from '../../src/experimental/arbitrumDeposit/createArbitrumClient'
import { createArbitrumClient } from '../../src/experimental/createArbitrumClient'

describe('arbitrumDepositActions', function () {
before(async function () {
Expand All @@ -22,23 +22,22 @@ describe('arbitrumDepositActions', function () {
})

// Create public clients using helper
const { parentChainPublicClient, childChainPublicClient } =
createArbitrumClient({
parentChain: localEthChain,
// @ts-expect-error
childChain: localArbChain,
parentRpcUrl: config.ethUrl,
childRpcUrl: config.arbUrl,
})
const { parentPublicClient, childPublicClient } = createArbitrumClient({
parentChain: localEthChain,
// @ts-expect-error
childChain: localArbChain,
parentRpcUrl: config.ethUrl,
childRpcUrl: config.arbUrl,
})

// Get initial L2 balance
const initialBalance = await childChainPublicClient.getBalance({
const initialBalance = await childPublicClient.getBalance({
address: account.address,
})

// Prepare and send deposit transaction
// @ts-expect-error
const request = await childChainPublicClient.prepareDepositEthTransaction({
const request = await childPublicClient.prepareDepositEthTransaction({
amount: depositAmount,
account,
})
Expand All @@ -49,7 +48,7 @@ describe('arbitrumDepositActions', function () {
})

// Wait for L1 transaction
const receipt = await parentChainPublicClient.waitForTransactionReceipt({
const receipt = await parentPublicClient.waitForTransactionReceipt({
hash,
})

Expand All @@ -63,7 +62,7 @@ describe('arbitrumDepositActions', function () {
while (attempts < maxAttempts) {
await new Promise(resolve => setTimeout(resolve, 3000))

const currentBalance = await childChainPublicClient.getBalance({
const currentBalance = await childPublicClient.getBalance({
address: account.address,
})

Expand Down Expand Up @@ -93,38 +92,35 @@ describe('arbitrumDepositActions', function () {
})

// Create public clients using helper
const { parentChainPublicClient, childChainPublicClient } =
createArbitrumClient({
parentChain: localEthChain,
// @ts-expect-error
childChain: localArbChain,
parentRpcUrl: config.ethUrl,
childRpcUrl: config.arbUrl,
})
const { parentPublicClient, childPublicClient } = createArbitrumClient({
parentChain: localEthChain,
// @ts-expect-error
childChain: localArbChain,
parentRpcUrl: config.ethUrl,
childRpcUrl: config.arbUrl,
})

// Get initial destination balance
const initialBalance = await childChainPublicClient.getBalance({
const initialBalance = await childPublicClient.getBalance({
address: destinationAddress,
})

// Prepare and send deposit transaction
// @ts-expect-error
const request = await childChainPublicClient.prepareDepositEthToTransaction(
{
amount: depositAmount,
account: account.address,
destinationAddress,
parentPublicClient: parentChainPublicClient,
}
)
const request = await childPublicClient.prepareDepositEthToTransaction({
amount: depositAmount,
account: account.address,
destinationAddress,
parentPublicClient,
})

const hash = await parentWalletClient.sendTransaction({
...request,
chain: localEthChain,
})

// Wait for L1 transaction
const receipt = await parentChainPublicClient.waitForTransactionReceipt({
const receipt = await parentPublicClient.waitForTransactionReceipt({
hash,
})

Expand All @@ -138,7 +134,7 @@ describe('arbitrumDepositActions', function () {
while (attempts < maxAttempts) {
await new Promise(resolve => setTimeout(resolve, 3000))

const currentBalance = await childChainPublicClient.getBalance({
const currentBalance = await childPublicClient.getBalance({
address: destinationAddress,
})

Expand Down

0 comments on commit fe1b33c

Please sign in to comment.