Skip to content

Utils.ts

This module contains generic utilities.

Added in v2.0.0

Signature

export declare class CryptoError

Added in v2.0.0

Source: src/Utils.ts:22

Signature

export declare const TaggedStruct: <Tag extends SchemaAST.LiteralValue, Fields extends Schema.Struct.Fields>(
tag: Tag,
fields: Fields
) => Schema.Struct<
{ _tag: Schema.PropertySignature<":", Exclude<Tag, undefined>, never, "?:", Tag | undefined, true, never> } & Fields
>

Source: src/Utils.ts:178

Added in v2.0.0

Ensure input is hex encoded (e.g. 0x${string}), otherwise encode as hex.

Signature

export declare const ensureHex: <T extends string>(s: T) => `0x${string}`

Source: src/Utils.ts:71

Added in v2.0.0

Signature

export declare function extractErrorDetails<T extends Error>(
error: T,
withOwnProperties: boolean | undefined = true
): {
[K in keyof T]: T[K]
} & {
message: string
name: string
stack?: string
cause?: unknown
}

Source: src/Utils.ts:92

Added in v2.0.0

Signature

export declare const formatBigDecimal: (n: BigDecimal.BigDecimal) => string

Source: src/Utils.ts:200

Added in v2.0.0

Signature

export declare const generateSalt: (rpcType: RpcType) => Effect.Effect<`0x${string}`, CryptoError, never>

Source: src/Utils.ts:30

Added in v2.0.0

Determine timeout timestamp for a fungible asset order.

Signature

export declare function getTimeoutInNanoseconds24HoursFromNow(): bigint

Source: src/Utils.ts:81

Added in v2.0.0

Signature

export declare const matchOptionBool: {
<A, B, C>(options: {
readonly onNone: LazyArg<A>
readonly onSomeTrue: (a: true) => B
readonly onSomeFalse: (a: false) => C
}): (self: O.Option<boolean>) => Unify<A | Unify<B | C>>
<A, B, C>(
self: O.Option<boolean>,
options: { readonly onNone: LazyArg<A>; readonly onSomeTrue: (a: true) => B; readonly onSomeFalse: (a: false) => C }
): Unify<A | Unify<B | C>>
}

Source: src/Utils.ts:141

Added in v2.0.0

Convert a BigDecimal to raw amount (smallest atomic units) for a given decimal precision

Signature

export declare const toRawAmount: (bd: BigDecimal.BigDecimal, decimals?: number) => bigint

Source: src/Utils.ts:233

Added in v2.0.0

Signature

export declare const verifySalt: (hex: `0x${string}`) => Effect.Effect<boolean>

Source: src/Utils.ts:55

Added in v2.0.0