Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Update OP Stack docs in RC CHA-69 #1612

Merged
merged 4 commits into from
Dec 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion site/op-stack/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
```
```
4 changes: 4 additions & 0 deletions src/chains/opStack/abis.ts
Original file line number Diff line number Diff line change
@@ -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' },
{
Expand Down
4 changes: 4 additions & 0 deletions src/chains/opStack/contracts.ts
Original file line number Diff line number Diff line change
@@ -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' },
Expand Down
15 changes: 15 additions & 0 deletions src/chains/opStack/decorators/publicL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,21 @@ export type PublicActionsL1<
) => Promise<WaitToProveReturnType>
}

/**
* 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,
Expand Down
15 changes: 15 additions & 0 deletions src/chains/opStack/decorators/publicL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,21 @@ export type PublicActionsL2<
) => Promise<EstimateTotalGasReturnType>
}

/**
* 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,
Expand Down
17 changes: 17 additions & 0 deletions src/chains/opStack/decorators/walletL1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,23 @@ export type WalletActionsL1<
) => Promise<ProveWithdrawalReturnType>
}

/**
* 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,
Expand Down
17 changes: 17 additions & 0 deletions src/chains/opStack/decorators/walletL2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,23 @@ export type WalletActionsL2<
) => Promise<InitiateWithdrawalReturnType>
}

/**
* 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,
Expand Down
Loading