ethereum-optimism / ethereum-optimism/ecosystem
`.extend(walletActionsL2())` overwrites `wallet.interop` instead of extending it.
- Dominant language
- TypeScript
- Stars
- 139
- Forks
- 82
- Avg merge
- 44m
- Merged PRs (30d)
- 3
Description
**Bug Description**
`.extend(walletActionsL2())` overwrites `wallet.interop` instead of extending it, so you only get four functions instead of all the expected functions after an `.extend(publicActionsL2()).extend(walletActionsL2())`.
**Steps to Reproduce**
1. Create the directory structure.
```sh
pnpm init
pnpm install viem
pnpm install @eth-optimism/viem
```
2. Create the application as `app.mjs`:
```javascript
import {
createWalletClient,
http,
publicActions,
getContract
} from 'viem'
import { privateKeyToAccount } from 'viem/accounts'
import { interopAlpha0 } from '@eth-optimism/viem/chains'
import { walletActionsL2, publicActionsL2 } from '@eth-optimism/viem'
const privateKey = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
const account = privateKeyToAccount(privateKey)
const wallet = createWalletClient({
chain: interopAlpha0,
transport: http(),
account
}).extend(publicActions)
.extend(publicActionsL2())
.extend(walletActionsL2())
console.log("wallet.interop after .extend(publicActionsL2()) and .extend(walletActionsL2())")
console.log(wallet.interop)
const wallet2 = createWalletClient({
chain: interopAlpha0,
transport: http(),
account
}).extend(publicActions)
.extend(publicActionsL2())
console.log("wallet.interop after .extend(publicActionsL2()) only")
console.log(wallet2.interop)
```
3. Run the application.
```sh
node app.mjs
```
The output will be:
```
wallet.interop after .extend(publicActionsL2()) and .extend(walletActionsL2())
{
sendCrossDomainMessage: [Function: sendCrossDomainMessage],
relayCrossDomainMessage: [Function: relayCrossDomainMessage],
sendSuperchainERC20: [Function: sendSuperchainERC20],
sendETH: [Function: sendETH]
}
wallet.interop after .extend(publicActionsL2()) only
{
buildExecutingMessage: [Function: buildExecutingMessage],
estimateSendCrossDomainMessageGas: [Function: estimateSendCrossDomainMessageGas],
estimateRelayCrossDomainMessageGas: [Function: estimateRelayCrossDomainMessageGas],
estimateSendSuperchainERC20Gas: [Function: estimateSendSuperchainERC20Gas],
estimateSendETHGas: [Function: estimateSendETHGas],
getCrossDomainMessages: [Function: getCrossDomainMessages],
getCrossDomainMessageStatus: [Function: getCrossDomainMessageStatus],
simulateSendCrossDomainMessage: [Function: simulateSendCrossDomainMessage],
simulateRelayCrossDomainMessage: [Function: simulateRelayCrossDomainMessage],
simulateSendSuperchainERC20: [Function: simulateSendSuperchainERC20],
simulateSendETH: [Function: simulateSendETH]
}
```
**Expected behavior**
I'd.expect `.extend` to extend `wallet.interop` rather than overwrite it. If that is impossible, create `wallet.publicInterop` and `wallet.walletInterop`.
**Environment Information:**
OS: WSL and MacOS
Package version: `@eth-optimism/viem` version 0.4.7
**Configurations:**
N/A
**Logs:**
N/A
**Additional context**
N/A
---
⚠️ **Notice:** Issues that do not include the following sections will be subject to closure:
- Bug Description
- Steps to Reproduce
- Environment Information
Please ensure all required sections are filled out accurately to expedite the debugging process and improve issue resolution efficiency.
Contributor guide
Research direction
Reproduce the behavior using the provided app.mjs setup and the two .extend() chains. Trace the walletActionsL2() and publicActionsL2() entry points to see how wallet.interop is assembled; done means the combined client retains both action sets, with tests covering the reported extension order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100