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

Cannot read properties of undefined (reading 'length') for "buildProveWithdrawal" function #3122

Closed
1 task done
qiushui777 opened this issue Dec 13, 2024 · 2 comments
Closed
1 task done
Labels
needs reproduction Misc: Needs Reproduction

Comments

@qiushui777
Copy link

Check existing issues

Viem Version

2.21

Current Behavior

hi, I am trying to build prove withdraw for optim -> eth bridge tx. here is my code

const { createPublicClient, createWalletClient, custom, http  } = require('viem') 



const { privateKeyToAccount } =  require('viem/accounts')
const { mainnet, optimism } = require('viem/chains')
const { publicActionsL1, publicActionsL2, walletActionsL1, getWithdrawals  } = require('viem/op-stack')


...

const publicClientL1 = createPublicClient({
    chain: mainnet,
    transport: http(gethrpc)
  }).extend(publicActionsL1())



const walletClientL1 = createWalletClient({
    chain: mainnet,
    transport: http(gethrpc)
  }).extend(walletActionsL1())

  
  
const publicClientL2 = createPublicClient({
    chain: optimism,
    transport: http(optimrpc)
  }).extend(publicActionsL2())


const account = privateKeyToAccount("0x" + walletPrivateKey)


const args = process.argv.slice(1)

txhash = args[1]





// console.log(txhash)
const execute = async (txhash) => {

    const receipt = await publicClientL2.getTransactionReceipt({
        hash: txhash,
      })
    
    // console.log(receipt)

    const withdrawal = getWithdrawals(receipt)
    // console.log(withdrawal)
    
    const output = await publicClientL1.getL2Output({
        l2BlockNumber: receipt.blockNumber,
        targetChain: optimism,
      })

    // console.log(output)
    
    const args = await publicClientL2.buildProveWithdrawal({
        account ,
        output,
        withdrawal,
      })
       
    console.log(args)

}


execute(txhash).then((returndata) => {

    console.log(returndata);

  }

    
).catch(err => {
    console.error("err", err);
  }).finally(_ => {
    process.exit(0);
})


and it gives me this error

err TypeError: Cannot read properties of undefined (reading 'length')
    at size (/root/node_modules/viem/_cjs/utils/data/size.js:8:18)
    at encodeBytes (/root/node_modules/viem/_cjs/utils/abi/encodeAbiParameters.js:140:42)
    at prepareParam (/root/node_modules/viem/_cjs/utils/abi/encodeAbiParameters.js:64:16)
    at prepareParams (/root/node_modules/viem/_cjs/utils/abi/encodeAbiParameters.js:34:29)
    at encodeAbiParameters (/root/node_modules/viem/_cjs/utils/abi/encodeAbiParameters.js:22:28)
    at getWithdrawalHashStorageSlot (/root/node_modules/viem/_cjs/op-stack/utils/getWithdrawalHashStorageSlot.js:7:67)
    at buildProveWithdrawal (/root/node_modules/viem/_cjs/op-stack/actions/buildProveWithdrawal.js:17:85)
    at Object.buildProveWithdrawal (/root/node_modules/viem/_cjs/op-stack/decorators/publicL2.js:20:96)

Any idea why? I think I follow the exact same code in the doc.

Expected Behavior

No response

Steps To Reproduce

No response

Link to Minimal Reproducible Example

No response

Anything else?

No response

@jxom jxom added the needs reproduction Misc: Needs Reproduction label Dec 13, 2024
Copy link
Contributor

Hello @qiushui777.

Please provide a minimal reproduction using StackBlitz, TypeScript Playground (for type issues), or a separate minimal GitHub repository.

Minimal reproductions are required as they save us a lot of time reproducing your config/environment and issue, and allow us to help you faster.

Once a minimal reproduction is added, a team member will confirm it works, then re-open the issue.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 13, 2024
Copy link
Contributor

This issue has been locked since it has been closed for more than 14 days.

If you found a concrete bug or regression related to it, please open a new bug report with a reproduction against the latest Viem version. If you have any questions or comments you can create a new discussion thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs reproduction Misc: Needs Reproduction
Projects
None yet
Development

No branches or pull requests

2 participants