@midnight-ntwrk/wallet-sdk-utilities 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ArrayOps.d.ts +1 -1
- package/dist/BlobOps.d.ts +2 -2
- package/dist/BlobOps.js +2 -2
- package/dist/EitherOps.d.ts +1 -1
- package/dist/Fluent.d.ts +1 -3
- package/dist/LedgerOps.d.ts +1 -1
- package/dist/hlist.d.ts +3 -3
- package/dist/networking/ClientServerErrors.d.ts +5 -7
- package/dist/networking/ClientServerErrors.js +3 -5
- package/dist/networking/HttpURL.d.ts +3 -7
- package/dist/networking/HttpURL.js +2 -4
- package/dist/networking/URLError.d.ts +4 -4
- package/dist/networking/URLError.js +2 -2
- package/dist/networking/WsURL.d.ts +3 -7
- package/dist/networking/WsURL.js +2 -4
- package/dist/polyFunction.d.ts +2 -2
- package/dist/testUtils.d.ts +2 -6
- package/dist/testing/compose.d.ts +4 -9
- package/dist/testing/compose.js +2 -2
- package/dist/testing/test-containers.js +1 -1
- package/dist/types.d.ts +5 -9
- package/package.json +1 -1
package/dist/ArrayOps.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NonEmptyReadonlyArray } from 'effect/Array';
|
|
1
|
+
import { type NonEmptyReadonlyArray } from 'effect/Array';
|
|
2
2
|
export declare const fold: {
|
|
3
3
|
<T>(folder: (acc: T, item: T) => T): (arr: NonEmptyReadonlyArray<T>) => T;
|
|
4
4
|
<T>(arr: NonEmptyReadonlyArray<T>, folder: (acc: T, item: T) => T): T;
|
package/dist/BlobOps.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser-compatible utility for converting a Blob to Uint8Array.
|
|
3
|
-
*
|
|
2
|
+
* Browser-compatible utility for converting a Blob to Uint8Array. Uses arrayBuffer() instead of bytes() for broader
|
|
3
|
+
* browser support.
|
|
4
4
|
*
|
|
5
5
|
* @param blob The Blob to convert to bytes
|
|
6
6
|
* @returns A Promise that resolves to a Uint8Array containing the blob's bytes
|
package/dist/BlobOps.js
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
// See the License for the specific language governing permissions and
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
/**
|
|
14
|
-
* Browser-compatible utility for converting a Blob to Uint8Array.
|
|
15
|
-
*
|
|
14
|
+
* Browser-compatible utility for converting a Blob to Uint8Array. Uses arrayBuffer() instead of bytes() for broader
|
|
15
|
+
* browser support.
|
|
16
16
|
*
|
|
17
17
|
* @param blob The Blob to convert to bytes
|
|
18
18
|
* @returns A Promise that resolves to a Uint8Array containing the blob's bytes
|
package/dist/EitherOps.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export declare const flatMapLeft: {
|
|
|
4
4
|
<R, L, L2>(either: Either.Either<R, L>, cb: (l: L) => Either.Either<R, L2>): Either.Either<R, L2>;
|
|
5
5
|
<R, L, L2>(cb: (l: L) => Either.Either<R, L2>): (either: Either.Either<R, L>) => Either.Either<R, L2>;
|
|
6
6
|
};
|
|
7
|
-
declare const LeftError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
7
|
+
declare const LeftError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
8
8
|
readonly _tag: "LeftError";
|
|
9
9
|
} & Readonly<A>;
|
|
10
10
|
export declare class LeftError<L> extends LeftError_base<{
|
package/dist/Fluent.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export declare namespace Fluent {
|
|
2
|
-
/**
|
|
3
|
-
* Exclude named methods from `T` so that they are no longer callable.
|
|
4
|
-
*/
|
|
2
|
+
/** Exclude named methods from `T` so that they are no longer callable. */
|
|
5
3
|
type ExcludeMethod<T, K extends keyof T> = Pick<T, Exclude<keyof T, K>>;
|
|
6
4
|
}
|
package/dist/LedgerOps.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Either } from 'effect';
|
|
2
|
-
declare const LedgerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
2
|
+
declare const LedgerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
3
3
|
readonly _tag: "LedgerError";
|
|
4
4
|
} & Readonly<A>;
|
|
5
5
|
export declare class LedgerError extends LedgerError_base<{
|
package/dist/hlist.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PolyFunction, WithTag } from './polyFunction.js';
|
|
1
|
+
import { type PolyFunction, type WithTag } from './polyFunction.js';
|
|
2
2
|
/**
|
|
3
|
-
* Heterogeneous list - as in - list, where elements have different types
|
|
4
|
-
*
|
|
3
|
+
* Heterogeneous list - as in - list, where elements have different types Here - more as an additional API over TS's
|
|
4
|
+
* tuple type
|
|
5
5
|
*/
|
|
6
6
|
export type Empty = [];
|
|
7
7
|
export type NonEmpty<T> = T extends Array<infer E> ? [E, ...T] : never;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
declare const ClientError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
1
|
+
declare const ClientError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
2
2
|
readonly _tag: "ClientError";
|
|
3
3
|
} & Readonly<A>;
|
|
4
4
|
/**
|
|
5
5
|
* An error representing a connection or client-side error.
|
|
6
6
|
*
|
|
7
7
|
* @remarks
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* This error typically indicates a connection issue with a target server, or when the client has submitted some data
|
|
9
|
+
* that could not be processed.
|
|
10
10
|
*/
|
|
11
11
|
export declare class ClientError extends ClientError_base<{
|
|
12
12
|
readonly message: string;
|
|
13
13
|
readonly cause?: unknown;
|
|
14
14
|
}> {
|
|
15
15
|
}
|
|
16
|
-
declare const ServerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
16
|
+
declare const ServerError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
17
17
|
readonly _tag: "ServerError";
|
|
18
18
|
} & Readonly<A>;
|
|
19
|
-
/**
|
|
20
|
-
* An error representing a server-side error.
|
|
21
|
-
*/
|
|
19
|
+
/** An error representing a server-side error. */
|
|
22
20
|
export declare class ServerError extends ServerError_base<{
|
|
23
21
|
readonly message: string;
|
|
24
22
|
}> {
|
|
@@ -15,13 +15,11 @@ import { Data } from 'effect';
|
|
|
15
15
|
* An error representing a connection or client-side error.
|
|
16
16
|
*
|
|
17
17
|
* @remarks
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* This error typically indicates a connection issue with a target server, or when the client has submitted some data
|
|
19
|
+
* that could not be processed.
|
|
20
20
|
*/
|
|
21
21
|
export class ClientError extends Data.TaggedError('ClientError') {
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* An error representing a server-side error.
|
|
25
|
-
*/
|
|
23
|
+
/** An error representing a server-side error. */
|
|
26
24
|
export class ServerError extends Data.TaggedError('ServerError') {
|
|
27
25
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Either } from 'effect';
|
|
2
2
|
import * as Brand from 'effect/Brand';
|
|
3
3
|
import { InvalidProtocolSchemeError } from './URLError.js';
|
|
4
|
-
/**
|
|
5
|
-
* A 'HTTP' URL.
|
|
6
|
-
*/
|
|
4
|
+
/** A 'HTTP' URL. */
|
|
7
5
|
export type HttpUrl = Brand.Branded<URL, 'HttpURL'>;
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a 'HTTP' URL from a source URL, ensuring that the protocol is correct.
|
|
10
|
-
*/
|
|
6
|
+
/** Constructs a 'HTTP' URL from a source URL, ensuring that the protocol is correct. */
|
|
11
7
|
export declare const HttpURL: Brand.Brand.Constructor<HttpUrl>;
|
|
12
8
|
/**
|
|
13
9
|
* Constructs a new {@link HttpURL} from a given string.
|
|
14
10
|
*
|
|
15
11
|
* @param url The URL to be made into a HTTP URL.
|
|
16
12
|
* @returns An `Either` that represents the valid HTTP URL constructed from `url`; or an
|
|
17
|
-
*
|
|
13
|
+
* {@link InvalidProtocolSchemeError}.
|
|
18
14
|
*/
|
|
19
15
|
export declare const make: (url: URL | string) => Either.Either<HttpUrl, InvalidProtocolSchemeError>;
|
|
@@ -13,16 +13,14 @@
|
|
|
13
13
|
import { Either } from 'effect';
|
|
14
14
|
import * as Brand from 'effect/Brand';
|
|
15
15
|
import { InvalidProtocolSchemeError } from './URLError.js';
|
|
16
|
-
/**
|
|
17
|
-
* Constructs a 'HTTP' URL from a source URL, ensuring that the protocol is correct.
|
|
18
|
-
*/
|
|
16
|
+
/** Constructs a 'HTTP' URL from a source URL, ensuring that the protocol is correct. */
|
|
19
17
|
export const HttpURL = Brand.refined((url) => url.protocol === 'http:' || url.protocol === 'https:', (url) => Brand.error(`Invalid protocol scheme '${url.protocol}'. Expected 'http:' or 'https:'`));
|
|
20
18
|
/**
|
|
21
19
|
* Constructs a new {@link HttpURL} from a given string.
|
|
22
20
|
*
|
|
23
21
|
* @param url The URL to be made into a HTTP URL.
|
|
24
22
|
* @returns An `Either` that represents the valid HTTP URL constructed from `url`; or an
|
|
25
|
-
*
|
|
23
|
+
* {@link InvalidProtocolSchemeError}.
|
|
26
24
|
*/
|
|
27
25
|
export const make = (url) => {
|
|
28
26
|
const targetURL = new URL(url);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
declare const InvalidProtocolSchemeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
1
|
+
declare const InvalidProtocolSchemeError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
2
2
|
readonly _tag: "InvalidProtocolSchemeError";
|
|
3
3
|
} & Readonly<A>;
|
|
4
4
|
/**
|
|
5
|
-
* A configuration error where the protocol scheme of a given server URL was unexpected (e.g., used
|
|
6
|
-
* `'
|
|
5
|
+
* A configuration error where the protocol scheme of a given server URL was unexpected (e.g., used `'ftp:'` rather than
|
|
6
|
+
* `'http:'` for a server running over HTTP).
|
|
7
7
|
*/
|
|
8
8
|
export declare class InvalidProtocolSchemeError extends InvalidProtocolSchemeError_base<{
|
|
9
9
|
/** A message describing the error. */
|
|
@@ -13,7 +13,7 @@ export declare class InvalidProtocolSchemeError extends InvalidProtocolSchemeErr
|
|
|
13
13
|
}> {
|
|
14
14
|
static readonly tag: "InvalidProtocolSchemeError";
|
|
15
15
|
}
|
|
16
|
-
declare const FailedToDeriveWebSocketUrlError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").
|
|
16
|
+
declare const FailedToDeriveWebSocketUrlError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("effect/Cause").YieldableError & {
|
|
17
17
|
readonly _tag: "FailedToDeriveWebSocketUrlError";
|
|
18
18
|
} & Readonly<A>;
|
|
19
19
|
export declare class FailedToDeriveWebSocketUrlError extends FailedToDeriveWebSocketUrlError_base<{
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
// limitations under the License.
|
|
13
13
|
import { Data } from 'effect';
|
|
14
14
|
/**
|
|
15
|
-
* A configuration error where the protocol scheme of a given server URL was unexpected (e.g., used
|
|
16
|
-
* `'
|
|
15
|
+
* A configuration error where the protocol scheme of a given server URL was unexpected (e.g., used `'ftp:'` rather than
|
|
16
|
+
* `'http:'` for a server running over HTTP).
|
|
17
17
|
*/
|
|
18
18
|
export class InvalidProtocolSchemeError extends Data.TaggedError('InvalidProtocolSchemeError') {
|
|
19
19
|
static tag = 'InvalidProtocolSchemeError';
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { Either } from 'effect';
|
|
2
2
|
import * as Brand from 'effect/Brand';
|
|
3
3
|
import { InvalidProtocolSchemeError } from './URLError.js';
|
|
4
|
-
/**
|
|
5
|
-
* A 'HTTP' URL.
|
|
6
|
-
*/
|
|
4
|
+
/** A 'HTTP' URL. */
|
|
7
5
|
export type WsURL = Brand.Branded<URL, 'WsURL'>;
|
|
8
|
-
/**
|
|
9
|
-
* Constructs a 'WS' URL from a source URL, ensuring that the protocol is correct.
|
|
10
|
-
*/
|
|
6
|
+
/** Constructs a 'WS' URL from a source URL, ensuring that the protocol is correct. */
|
|
11
7
|
export declare const WsURL: Brand.Brand.Constructor<WsURL>;
|
|
12
8
|
/**
|
|
13
9
|
* Constructs a new {@link WsURL} from a given string.
|
|
14
10
|
*
|
|
15
11
|
* @param url The URL to be made into a WebSocket URL.
|
|
16
12
|
* @returns An `Either` that represents the valid WebSocket URL constructed from `url`; or an
|
|
17
|
-
*
|
|
13
|
+
* {@link InvalidProtocolSchemeError}.
|
|
18
14
|
*/
|
|
19
15
|
export declare const make: (url: URL | string) => Either.Either<WsURL, InvalidProtocolSchemeError>;
|
package/dist/networking/WsURL.js
CHANGED
|
@@ -13,16 +13,14 @@
|
|
|
13
13
|
import { Either } from 'effect';
|
|
14
14
|
import * as Brand from 'effect/Brand';
|
|
15
15
|
import { InvalidProtocolSchemeError } from './URLError.js';
|
|
16
|
-
/**
|
|
17
|
-
* Constructs a 'WS' URL from a source URL, ensuring that the protocol is correct.
|
|
18
|
-
*/
|
|
16
|
+
/** Constructs a 'WS' URL from a source URL, ensuring that the protocol is correct. */
|
|
19
17
|
export const WsURL = Brand.refined((url) => url.protocol === 'ws:' || url.protocol === 'wss:', (url) => Brand.error(`Invalid protocol scheme '${url.protocol}'. Expected 'ws:' or 'wss:'`));
|
|
20
18
|
/**
|
|
21
19
|
* Constructs a new {@link WsURL} from a given string.
|
|
22
20
|
*
|
|
23
21
|
* @param url The URL to be made into a WebSocket URL.
|
|
24
22
|
* @returns An `Either` that represents the valid WebSocket URL constructed from `url`; or an
|
|
25
|
-
*
|
|
23
|
+
* {@link InvalidProtocolSchemeError}.
|
|
26
24
|
*/
|
|
27
25
|
export const make = (url) => {
|
|
28
26
|
const targetURL = new URL(url);
|
package/dist/polyFunction.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export type WithTag<T extends string | symbol> = {
|
|
|
4
4
|
export type TagOf<T> = T extends WithTag<infer Tag> ? Tag : never;
|
|
5
5
|
export type WithTagFrom<T> = WithTag<TagOf<T>>;
|
|
6
6
|
/**
|
|
7
|
-
* Polymorphic function - function defined for multiple types at once
|
|
8
|
-
*
|
|
7
|
+
* Polymorphic function - function defined for multiple types at once Leveraging tagging mechanics it can predictably
|
|
8
|
+
* work at runtime and be quite intuitively defined by hand
|
|
9
9
|
*/
|
|
10
10
|
export type PolyFunction<Variants extends WithTag<string | symbol>, T> = {
|
|
11
11
|
[V in Variants as TagOf<V>]: (variant: V) => T;
|
package/dist/testUtils.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A utility type that ensures that a given type is `true` or otherwise forces a compile time error.
|
|
3
|
-
*/
|
|
1
|
+
/** A utility type that ensures that a given type is `true` or otherwise forces a compile time error. */
|
|
4
2
|
export type Expect<T extends true> = T;
|
|
5
|
-
/**
|
|
6
|
-
* A utility type that exactly compares two types for equality.
|
|
7
|
-
*/
|
|
3
|
+
/** A utility type that exactly compares two types for equality. */
|
|
8
4
|
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
|
9
5
|
export type ItemType<T> = T extends ReadonlyArray<infer R> ? R : never;
|
|
@@ -10,19 +10,14 @@ export declare function getRepositoryRoot(): string;
|
|
|
10
10
|
* @returns The absolute path to the compose directory
|
|
11
11
|
*/
|
|
12
12
|
export declare function getComposeDirectory(): string;
|
|
13
|
-
/**
|
|
14
|
-
* Options for building test environment variables.
|
|
15
|
-
*/
|
|
13
|
+
/** Options for building test environment variables. */
|
|
16
14
|
export interface BuildTestEnvironmentVariablesOptions {
|
|
17
|
-
/**
|
|
18
|
-
* Additional environment variables to include.
|
|
19
|
-
* These will be merged with the variables collected from process.env.
|
|
20
|
-
*/
|
|
15
|
+
/** Additional environment variables to include. These will be merged with the variables collected from process.env. */
|
|
21
16
|
additionalVars?: Record<string, string>;
|
|
22
17
|
}
|
|
23
18
|
/**
|
|
24
|
-
* Builds and validates environment variables for test containers.
|
|
25
|
-
*
|
|
19
|
+
* Builds and validates environment variables for test containers. Throws an error if any required environment variable
|
|
20
|
+
* from envVarsToPass is missing.
|
|
26
21
|
*
|
|
27
22
|
* @param envVarsToPass - Array of environment variable names to collect from process.env
|
|
28
23
|
* @param options - Optional configuration for building environment variables
|
package/dist/testing/compose.js
CHANGED
|
@@ -32,8 +32,8 @@ export function getComposeDirectory() {
|
|
|
32
32
|
return path.join(repoRoot, 'infra', 'compose');
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Builds and validates environment variables for test containers.
|
|
36
|
-
*
|
|
35
|
+
* Builds and validates environment variables for test containers. Throws an error if any required environment variable
|
|
36
|
+
* from envVarsToPass is missing.
|
|
37
37
|
*
|
|
38
38
|
* @param envVarsToPass - Array of environment variable names to collect from process.env
|
|
39
39
|
* @param options - Optional configuration for building environment variables
|
|
@@ -28,7 +28,7 @@ export const runNodeContainer = (adjustment = identity) => {
|
|
|
28
28
|
return startContainer(adjustment(container));
|
|
29
29
|
};
|
|
30
30
|
export const runProofServerContainer = (adjustment = identity) => {
|
|
31
|
-
const container = new GenericContainer('ghcr.io/midnight-ntwrk/proof-server:8.0.
|
|
31
|
+
const container = new GenericContainer('ghcr.io/midnight-ntwrk/proof-server:8.0.3')
|
|
32
32
|
.withEnvironment({
|
|
33
33
|
RUST_BACKTRACE: 'full',
|
|
34
34
|
})
|
package/dist/types.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A utility type that checks whether type A can be assigned to type To
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* A utility type that checks whether type A can be assigned to type To It appears to be useful when exact inferred type
|
|
3
|
+
* are slightly too complex to express and we want the express a slightly simplified type rule like
|
|
4
|
+
* Expect<CanAssign<{foo: number}, object & {foo: number}>>
|
|
5
5
|
*/
|
|
6
6
|
export type CanAssign<A, To> = A extends To ? true : false;
|
|
7
|
-
/**
|
|
8
|
-
* A utility type that ensures that a given type is `true` or otherwise forces a compile time error.
|
|
9
|
-
*/
|
|
7
|
+
/** A utility type that ensures that a given type is `true` or otherwise forces a compile time error. */
|
|
10
8
|
export type Expect<T extends true> = T;
|
|
11
9
|
export type ItemType<T> = T extends ReadonlyArray<infer R> ? R : never;
|
|
12
|
-
/**
|
|
13
|
-
* A utility type that exactly compares two types for equality.
|
|
14
|
-
*/
|
|
10
|
+
/** A utility type that exactly compares two types for equality. */
|
|
15
11
|
export type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midnight-ntwrk/wallet-sdk-utilities",
|
|
3
3
|
"description": "Domain-agnostic utilities for the wallet SDK - common operations and types",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.js",
|