Skip to content

Module: @fuel-ts/utils

Classes

Interfaces

Variables

defaultConsensusKey

Const defaultConsensusKey: "0xa449b1ffee0e2205fa924c6740cc48b3b473aa28587df6dab12abc245d1f5298"

Defined in

packages/utils/src/utils/defaultSnapshotConfigs.ts:12


defaultSnapshotConfigs

Const defaultSnapshotConfigs: SnapshotConfigs

Defined in

packages/utils/src/utils/defaultSnapshotConfigs.ts:6

Functions

arrayify

arrayify(value, name?, copy?): Uint8Array

Get a typed Uint8Array from a BytesLike object.

Parameters

NameTypeDefault valueDescription
valueBytesLikeundefinedthe BytesLike data.
name?stringundefineda display name for the error result.
copybooleantruecreate a copy of the original data (if applicable).

Returns

Uint8Array

  • a typed Uint8Array.

Defined in

packages/utils/src/utils/arrayify.ts:12


capitalizeString

capitalizeString(str): string

Parameters

NameType
strstring

Returns

string

Defined in

packages/utils/src/utils/capitalizeString.ts:1


chunkAndPadBytes

chunkAndPadBytes(bytes, chunkSize): Uint8Array[]

Function to take a byte array and split into chunks of a given size

Parameters

NameTypeDescription
bytesUint8ArrayThe byte array to chunk
chunkSizenumberThe size of each chunk

Returns

Uint8Array[]

An array of byte arrays of a specified size

Defined in

packages/utils/src/utils/chunkAndPadBytes.ts:8


concat

concat(arrays): Uint8Array

Concatenates multiple BytesLike into a single Uint8Array.

Parameters

NameTypeDescription
arraysreadonly BytesLike[]The arrays to concatenate.

Returns

Uint8Array

  • The concatenated array.

Defined in

packages/utils/src/utils/concat.ts:38


concatBytes

concatBytes(arrays): Uint8Array

Concatenates multiple Uint8Arrays into a single Uint8Array.

Parameters

NameTypeDescription
arraysreadonly Uint8Array[] | readonly number[][]The arrays to concatenate.

Returns

Uint8Array

  • The concatenated array.

Defined in

packages/utils/src/utils/concat.ts:11


dataSlice

dataSlice(data, start?, end?): string

Returns a hex string by slicing data from the start offset to the end offset.

Parameters

NameTypeDescription
dataBytesLikethe data to be sliced.
start?numberthe start offset (default: 0).
end?numberthe end offset (default: length of data).

Returns

string

  • a sliced hex string from start to end.

Defined in

packages/utils/src/utils/dataSlice.ts:15


decodeBase58

decodeBase58(value): BN

Parameters

NameType
valuestring

Returns

BN

Defined in

packages/utils/src/utils/base58.ts:51


encodeBase58

encodeBase58(_value): string

Encode value as a Base58-encoded string.

Parameters

NameType
_valueBytesLike

Returns

string

Defined in

packages/utils/src/utils/base58.ts:30


hexlify

hexlify(data): string

Returns a hex representation of the inputted bytes.

Parameters

NameType
dataBytesLike

Returns

string

Defined in

packages/utils/src/utils/hexlify.ts:10


isDefined

isDefined<T>(value): value is T

Type parameters

Name
T

Parameters

NameType
valueundefined | T

Returns

value is T

Defined in

packages/utils/src/utils/isDefined.ts:1


normalizeString

normalizeString(str): string

Converts some.string-value into SomeStringValue.

Examples: my-simple.test —— MySimpleTest myFile.ts —— MyFileTs my-abi.json —— MyAbiJson

Parameters

NameType
strstring

Returns

string

Defined in

packages/utils/src/utils/normalizeString.ts:11


sleep

sleep(time): Promise<unknown>

Parameters

NameType
timenumber

Returns

Promise<unknown>

Defined in

packages/utils/src/utils/sleep.ts:1


toUtf8Bytes

toUtf8Bytes(stri, form?): Uint8Array

Returns the UTF-8 byte representation of str.

If form is disabled, the string is not normalized.

Parameters

NameTypeDefault valueDescription
stristringundefinedthe string to convert to UTF-8 bytes.
formbooleantruewhether to normalize the string.

Returns

Uint8Array

  • the UTF-8 byte representation of str.

Defined in

packages/utils/src/utils/toUtf8Bytes.ts:11


toUtf8String

toUtf8String(bytes): string

Returns the string represented by the UTF-8 data bytes.

Parameters

NameTypeDescription
bytesBytesLikethe UTF-8 data bytes

Returns

string

the string represented by the UTF-8 data bytes

Defined in

packages/utils/src/utils/toUtf8String.ts:179