Skip to main content

util

convertRecoveryToV()โ€‹

convertRecoveryToV(recovery: number, txData: any): Buffer | BN

Convert a recovery parameter (0/1) to the proper v value format based on transaction type. Consolidates the v parameter conversion logic used across ethereum.ts and util.ts.

Parametersโ€‹

ParameterTypeDescription
recoverynumberRecovery parameter (0 or 1)
txDataanyTransaction data containing chainId, useEIP155, and type

Returnsโ€‹

Buffer | BN

The properly formatted v value as Buffer or BN

Sourceโ€‹

src/util.ts:878


fetchCalldataDecoder()โ€‹

fetchCalldataDecoder(_data: string | Uint8Array, to: string, _chainId: string | number, recurse: boolean): Promise<{"abi": any;"def": Buffer; }>

Fetches calldata from a remote scanner based on the transaction's chainId

Parametersโ€‹

ParameterTypeDefault value
_datastring | Uint8Arrayundefined
tostringundefined
_chainIdstring | numberundefined
recursebooleantrue

Returnsโ€‹

Promise<{"abi": any;"def": Buffer; }>

MemberTypeValue
abiany-
defBuffer...

Sourceโ€‹

src/util.ts:628


generateAppSecret()โ€‹

generateAppSecret(deviceId: string | Buffer, password: string | Buffer, appName: string | Buffer): Buffer

Generates an application secret for use in maintaining connection to device.

Parametersโ€‹

ParameterTypeDescription
deviceIdstring | BufferThe device ID of the device you want to generate a token for.
passwordstring | BufferThe password entered when connecting to the device.
appNamestring | BufferThe name of the application.

Returnsโ€‹

Buffer

an application secret as a Buffer

Sourceโ€‹

src/util.ts:705


getV()โ€‹

getV(tx: any, resp: any): BN

Get the v component of signature using viem parsing.

Parametersโ€‹

ParameterTypeDescription
txanySerialized transaction (Buffer or hex string)
respanyLattice response with sig and pubkey

Returnsโ€‹

BN

BN object containing the v param

Sourceโ€‹

src/util.ts:732


getYParity()โ€‹

getYParity(messageHash: any, signature?: any, publicKey?: string | Buffer | Uint8Array): number

Get the y-parity value for a signature by recovering the public key.

Usage:

  • Simple: getYParity(messageHash, signature, publicKey)
  • Object: getYParity({ messageHash, signature, publicKey })
  • Legacy: getYParity(tx, response)

Parametersโ€‹

ParameterTypeDescription
messageHashanyThe 32-byte message hash (or tx object for legacy)
signature?anyObject with r and s values
publicKey?string | Buffer | Uint8ArrayExpected public key

Returnsโ€‹

number

0 or 1 for the y-parity value

Sourceโ€‹

src/util.ts:921


selectDefFrom4byteABI()โ€‹

selectDefFrom4byteABI(abiData: any[], selector: string): any

Takes a list of ABI data objects and a selector, and returns the earliest ABI data object that matches the selector.

Parametersโ€‹

ParameterType
abiDataany[]
selectorstring

Returnsโ€‹

any

Sourceโ€‹

src/util.ts:392