Skip to content

@liquality.utils

Krasimir Raykov edited this page Mar 30, 2022 · 3 revisions

Module: @liquality/utils

Table of contents

Namespaces

Functions

Functions

asyncSetImmediate

asyncSetImmediate(): Promise<unknown>

Returns

Promise<unknown>

Defined in

utils/lib/index.ts:8


compare

compare(a, b): boolean

Parameters

Name Type
a BigNumberish
b BigNumberish

Returns

boolean

Defined in

utils/lib/string.ts:3


ensure0x

ensure0x(hash): string

Appends 0x if missing from hex string

Parameters

Name Type
hash string

Returns

string

Defined in

utils/lib/hex.ts:4


ensureBuffer

ensureBuffer(message): false | Buffer

Ensure message is in buffer format.

Parameters

Name Type Description
message any any string.

Returns

false | Buffer

Buffer.

Defined in

utils/lib/crypto.ts:12


hash160

hash160(message): string

Get hash160 of message.

Parameters

Name Type Description
message string message in string or Buffer.

Returns

string

the hash160 of a string.

Defined in

utils/lib/crypto.ts:32


isHex

isHex(hex): boolean

Parameters

Name Type
hex string

Returns

boolean

Defined in

utils/lib/crypto.ts:40


padHexStart

padHexStart(hex, lengthBytes?): string

Pad a hex string with '0'

Parameters

Name Type Description
hex string The hex string to pad.
lengthBytes? number The length of the final string in bytes

Returns

string

a padded string with length greater or equal to the given length rounded up to the nearest even number.

Defined in

utils/lib/crypto.ts:55


remove0x

remove0x(hash): string

Removes 0x if it exists in hex string

Parameters

Name Type
hash string

Returns

string

Defined in

utils/lib/hex.ts:11


retry

retry<T>(method, startWaitTime?, waitBackoff?, retryNumber?): Promise<T>

Type parameters

Name
T

Parameters

Name Type Default value
method () => Promise<T> undefined
startWaitTime number 500
waitBackoff number 2
retryNumber number 5

Returns

Promise<T>

Defined in

utils/lib/index.ts:12


sha256

sha256(data): string

Parameters

Name Type
data string

Returns

string

Defined in

utils/lib/crypto.ts:36


sleep

sleep(ms): Promise<void>

Parameters

Name Type
ms number

Returns

Promise<void>

Defined in

utils/lib/index.ts:33


toStringDeep

toStringDeep<I, O>(input): O

Type parameters

Name
I
O

Parameters

Name Type
input I

Returns

O

Defined in

utils/lib/string.ts:7


validateExpiration

validateExpiration(expiration): void

Parameters

Name Type
expiration number

Returns

void

Defined in

utils/lib/swap.ts:7


validateSecret

validateSecret(secret): void

Parameters

Name Type
secret string

Returns

void

Defined in

utils/lib/swap.ts:17


validateSecretAndHash

validateSecretAndHash(secret, secretHash): void

Parameters

Name Type
secret string
secretHash string

Returns

void

Defined in

utils/lib/swap.ts:55


validateSecretHash

validateSecretHash(secretHash): void

Parameters

Name Type
secretHash string

Returns

void

Defined in

utils/lib/swap.ts:34


validateValue

validateValue(value): void

Parameters

Name Type
value BigNumberish

Returns

void

Defined in

utils/lib/swap.ts:65

Clone this wiki locally