Skip to content

Commit

Permalink
docs: update OP Stack docs in RC CHA-69 (#1612)
Browse files Browse the repository at this point in the history
* feat: Add more docs to op

* Update site/op-stack/client.md

* Update site/op-stack/client.md

* Apply suggestions from code review

Co-authored-by: jxom  <jakemoxey@gmail.com>

---------

Co-authored-by: Will Cory <willcory@Wills-MacBook-Pro.local>
Co-authored-by: jxom <jakemoxey@gmail.com>
  • Loading branch information
3 people committed Dec 25, 2023
1 parent a31d4e9 commit efe781b
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 1 deletion.
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

0 comments on commit efe781b

Please sign in to comment.