Skip to content

bare-crypto HMAC TypeError when fetching TRON gas-free address #10

@shaksi

Description

@shaksi

Before submitting a new issue

  • I tested using the latest version of the library, as the bug might be already fixed.
  • I tested using a supported version of react native.
  • I checked for possible duplicate issues, with possible answers.

Bug summary

When calling WDKService.getAssetAddress(NetworkType.TRON, 0) to get the TRON gas-free address, the worklet throws a TypeError in the bare-crypto HMAC implementation.

Error

TypeError: Cannot read properties of undefined (reading 'buffer')
at new CryptoHmac (file:///wdk.manager.worklet.bundle/node_modules/bare-crypto/lib/hmac.js:15:11)
at createHmac (file:///wdk.manager.worklet.bundle/node_modules/bare-crypto/index.js:21:10)
at WalletAccountTronGasfree._sendRequestToGasfreeProvider (file:///wdk.manager.worklet.bundle/node_modules/@wdk/wallet-tron-gasfree/src/wallet-account-read-only-tron-gasfree.js:174:23)
at WalletAccountTronGasfree._getGasfreeAccount (file:///wdk.manager.worklet.bundle/node_modules/@wdk/wallet-tron-gasfree/src/wallet-account-read-only-tron-gasfree.js:150:35)
at WalletAccountTronGasfree.getAddress (file:///wdk.manager.worklet.bundle/node_modules/@wdk/wallet-tron-gasfree/src/wallet-account-read-only-tron-gasfree.js:70:43)
at WdkManager.getAbstractedAddress (file:///wdk.manager.worklet.bundle/node_modules/@tetherto/pear-wrk-wdk/src/wdk-core/wdk-manager.js:299:26)

Expected Behavior

Should return the TRON gas-free address object with { address: "T..." }

Actual Behavior

Throws TypeError: Cannot read properties of undefined (reading 'buffer') at bare-crypto/lib/hmac.js:15

Additional Context

  • Bitcoin addresses work fine via addresses[NetworkType.SEGWIT] - this code path doesn't use HMAC
  • The bug is in the pre-built worklet bundle (wdk.manager.worklet.bundle), not in user-land code
  • Attempted upgrading @tetherto/pear-wrk-wdk to beta.5 but install fails due to missing http2 module during gen:mobile-bundle postinstall script

Library version

1.0.0-beta.3

Environment info

- @tetherto/wdk-react-native-provider: 1.0.0-beta.3
  - @tetherto/pear-wrk-wdk: 1.0.0-beta.4
  - react-native-bare-kit: 0.10.9
  - React Native: 0.76.9
  - Expo SDK: 52
  - Platform: iOS Simulator (arm64)
  - Node: 22.x

Steps to reproduce

  1. Initialize WalletProvider with TronChainConfig including gas-free settings
  2. Create or unlock a wallet
  3. Call WDKService.getAssetAddress(NetworkType.TRON, 0)

Reproducible example repository

http://

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions