diff --git a/site/op-stack/client.md b/site/op-stack/client.md index ec2fe0a2ad..960b381529 100644 --- a/site/op-stack/client.md +++ b/site/op-stack/client.md @@ -57,10 +57,26 @@ A suite of [Wallet Actions](./actions/estimateL1Gas.md) for suited for developme import { walletActionsL1 } from 'viem/op-stack' ``` +### `publicActionsL1` + +A suite of [Public Actions](./actions/getTimeToProve.md) suited for development with **Layer 1** chains. These actions provide functionalities specific to public clients operating at the Layer 1 level, enabling them to interact seamlessly with Layer 2 protocols. + +```ts +import { publicActionsL1 } from 'viem/op-stack' +``` + +### `walletActionsL2` + +A suite of [Wallet Actions](./actions/estimateL1Fee.md) suited for development with **Layer 2 (OP Stack)** chains. These actions are tailored for wallets operating on Layer 2, providing advanced features and integrations necessary for Layer 2 financial operations. + +```ts +import { walletActionsL2 } from 'viem/op-stack' +``` + ### `publicActionsL2` A suite of [Public Actions](./actions/estimateL1Gas.md) for suited for development with **Layer 2 (OP Stack)** chains. ```ts import { publicActionsL2 } from 'viem/op-stack' -``` \ No newline at end of file +``` diff --git a/src/chains/opStack/abis.ts b/src/chains/opStack/abis.ts index cb1db6bc3a..1f47cf9bea 100644 --- a/src/chains/opStack/abis.ts +++ b/src/chains/opStack/abis.ts @@ -1,3 +1,7 @@ +/** + * ABI for the OP Stack [`GasPriceOracle` contract](https://github.com/ethereum-optimism/optimism/blob/develop/packages/contracts-bedrock/src/L2/GasPriceOracle.sol). + * @see https://optimistic.etherscan.io/address/0x420000000000000000000000000000000000000f + */ export const gasPriceOracleAbi = [ { inputs: [], stateMutability: 'nonpayable', type: 'constructor' }, { diff --git a/src/chains/opStack/contracts.ts b/src/chains/opStack/contracts.ts index 7fcc217295..e29ec9c37a 100644 --- a/src/chains/opStack/contracts.ts +++ b/src/chains/opStack/contracts.ts @@ -1,5 +1,9 @@ import type { Chain } from '../../types/chain.js' +/** + * Predeploy contracts for OP Stack. + * @see https://github.com/ethereum-optimism/optimism/blob/develop/specs/predeploys.md + */ export const contracts = { gasPriceOracle: { address: '0x420000000000000000000000000000000000000F' }, l1Block: { address: '0x4200000000000000000000000000000000000015' }, diff --git a/src/chains/opStack/decorators/publicL1.ts b/src/chains/opStack/decorators/publicL1.ts index 2f87e0d7d2..4db5ff56f1 100644 --- a/src/chains/opStack/decorators/publicL1.ts +++ b/src/chains/opStack/decorators/publicL1.ts @@ -485,6 +485,21 @@ export type PublicActionsL1< ) => Promise } +/** + * A suite of Public Actions for suited for development with Layer 2 (OP Stack) chains. + * + * - Docs: https://viem.sh/op-stack/client.html + * + * @example + * import { publicActionsL1 } from 'viem/op-stack' + * import { mainnet } from 'viem/chains' + * import { buildDepositTransaction } from 'viem/wallet' + * + * export const opStackPublicClientL1 = createWalletClient({ + * chain: mainnet, + * transport: http(), + * }).extend(publicActionsL1()) + */ export function publicActionsL1() { return < TTransport extends Transport, diff --git a/src/chains/opStack/decorators/publicL2.ts b/src/chains/opStack/decorators/publicL2.ts index db4d88a830..a2ee121ea4 100644 --- a/src/chains/opStack/decorators/publicL2.ts +++ b/src/chains/opStack/decorators/publicL2.ts @@ -444,6 +444,21 @@ export type PublicActionsL2< ) => Promise } +/** + * A suite of Public Actions for suited for development with Layer 2 (OP Stack) chains. + * + * - Docs: https://viem.sh/op-stack/client.html + * + * @example + * import { publicActionsL2 } from 'viem/op-stack' + * import { optimism } from 'viem/chains' + * import { buildDepositTransaction } from 'viem/wallet' + * + * export const opStackPublicClientL1 = createWalletClient({ + * chain: optimism, + * transport: http(), + * }).extend(publicActionsL1()) + */ export function publicActionsL2() { return < TTransport extends Transport, diff --git a/src/chains/opStack/decorators/walletL1.ts b/src/chains/opStack/decorators/walletL1.ts index 3059146e65..5861f22042 100644 --- a/src/chains/opStack/decorators/walletL1.ts +++ b/src/chains/opStack/decorators/walletL1.ts @@ -138,6 +138,23 @@ export type WalletActionsL1< ) => Promise } +/** + * A suite of Wallet Actions for suited for development with Layer 2 (OP Stack) chains. + * + * - Docs: https://viem.sh/op-stack/client.html + * + * @example + * import { createPublicClient, createWalletClient, http } from 'viem' + * import { mainnet } from 'viem/chains' + * import { walletActionsL1 } from 'viem/op-stack' + * + * const walletClient = createWalletClient({ + * chain: mainnet, + * transport: http(), + * }).extend(walletActionsL1()) + * + * const hash = await walletClient.depositTransaction({...}) + */ export function walletActionsL1() { return < TTransport extends Transport, diff --git a/src/chains/opStack/decorators/walletL2.ts b/src/chains/opStack/decorators/walletL2.ts index 50edb86cd5..455bc28d83 100644 --- a/src/chains/opStack/decorators/walletL2.ts +++ b/src/chains/opStack/decorators/walletL2.ts @@ -69,6 +69,23 @@ export type WalletActionsL2< ) => Promise } +/** + * A suite of Wallet Actions for suited for development with Layer 2 (OP Stack) chains. + * + * - Docs: https://viem.sh/op-stack/client.html + * + * @example + * import { createPublicClient, createWalletClient, http } from 'viem' + * import { mainnet } from 'viem/chains' + * import { walletActionsL1 } from 'viem/op-stack' + * + * const walletClient = createWalletClient({ + * chain: mainnet, + * transport: http(), + * }).extend(walletActionsL1()) + * + * const hash = await walletClient.depositTransaction({...}) + */ export function walletActionsL2() { return < TTransport extends Transport,