Skip to content

Accessing bytes.buffer from createCursor() results in undefined error within react-native #4002

@xzilja

Description

@xzilja

Check existing issues

Viem Version

2.37.12

Current Behavior

When prepareUserOperation is called within react-native project an error is thrown stating

[TypeError: Cannot read property 'buffer' if undefined]

Since project has global buffer polyfill and stack trace ends at createCursor function I'm thinking there is an issue with accessing bytes.buffer (probably there will be follow up issues with accessing anything on bytes there as well).

Expected Behavior

Should not throw in react-native or documentation should mention necessary polyfills.

Steps To Reproduce

Existing polyfills of the project for refference

import 'react-native-get-random-values'

import { Buffer } from 'buffer'

global.Buffer = Buffer

Call prepare user op on bunlder

const baseSepoliaClient = createPublicClient({
  chain: baseSepolia,
  transport: http('...'),
})

const baseSepoliaBundler = createBundlerClient({
  client: baseSepoliaClient,
  transport: http('...'),
})

const userOp = await baseSepoliaBundler.prepareUserOperation({
    account,
    calls: [{
        to: '0xd...',
        value: parseEther('0.0001'),
    }],
 })

Link to Minimal Reproducible Example

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions