Skip to main content

Class: DecodeResult<T>

Class that represents decoding result.

Type parameters

Name
T

Constructors

constructor

new DecodeResult<T>(value?, error?): DecodeResult<T>

Type parameters

Name
T

Parameters

NameType
value?T
error?string

Returns

DecodeResult<T>

Defined in

packages/walletconnect-v2/src/decode.ts:31

Properties

_error

Private Optional Readonly _error: string

Defined in

packages/walletconnect-v2/src/decode.ts:29


_value

Private Optional Readonly _value: T

Defined in

packages/walletconnect-v2/src/decode.ts:27

Accessors

error

get error(): string

Gets the error occurred during the decoding procedure.

Returns

string

Defined in

packages/walletconnect-v2/src/decode.ts:63


value

get value(): T

Gets the decode value.

Returns

T

Defined in

packages/walletconnect-v2/src/decode.ts:78

Methods

isError

isError(): boolean

Returns true if the DecodeResult represents a failed decoding procedure, false otherwise.

Returns

boolean

Defined in

packages/walletconnect-v2/src/decode.ts:56


isOk

isOk(): boolean

Returns true if the DecodeResult contains a successfully decode value, false otherwise.

Returns

boolean

Defined in

packages/walletconnect-v2/src/decode.ts:71


map

map<M>(mapFunc): DecodeResult<M>

Maps the current value using the provided mapFunc. If this DecodeResult is error the mapFunc will return a new DecodeResult with the previous error.

Type parameters

Name
M

Parameters

NameTypeDescription
mapFunc(value: T) => MFunction that converts the [DecodeResult] value to the new one

Returns

DecodeResult<M>

Defined in

packages/walletconnect-v2/src/decode.ts:89


error

error(message): DecodeResult<any>

Creates a failed DecodeResult that holds the decoded error message.

Parameters

NameTypeDescription
messagestringThe error occurred during the decoding procedure.

Returns

DecodeResult<any>

Defined in

packages/walletconnect-v2/src/decode.ts:48


ok

ok<T>(value): DecodeResult<T>

Creates a successfully DecodeResult that holds the decoded value.

Type parameters

Name
T

Parameters

NameTypeDescription
valueTThe decoded value.

Returns

DecodeResult<T>

Defined in

packages/walletconnect-v2/src/decode.ts:40