@symbiome-forge/cow-sdk-wasm 0.1.0-alpha.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/LICENSE +674 -0
- package/README.md +278 -0
- package/dist/cloudflare/callbacks.cjs +2 -0
- package/dist/cloudflare/callbacks.d.ts +55 -0
- package/dist/cloudflare/callbacks.js +1 -0
- package/dist/cloudflare/envelope.cjs +2 -0
- package/dist/cloudflare/envelope.d.ts +5 -0
- package/dist/cloudflare/envelope.js +1 -0
- package/dist/cloudflare/errors.cjs +150 -0
- package/dist/cloudflare/errors.d.ts +82 -0
- package/dist/cloudflare/errors.js +145 -0
- package/dist/cloudflare/index.cjs +286 -0
- package/dist/cloudflare/index.d.ts +78 -0
- package/dist/cloudflare/index.js +1 -0
- package/dist/cloudflare/index.mjs +223 -0
- package/dist/cloudflare/internal.cjs +127 -0
- package/dist/cloudflare/internal.d.ts +40 -0
- package/dist/cloudflare/internal.js +115 -0
- package/dist/cloudflare/options.cjs +2 -0
- package/dist/cloudflare/options.d.ts +70 -0
- package/dist/cloudflare/options.js +1 -0
- package/dist/cloudflare/raw/cloudflare.cjs +65 -0
- package/dist/cloudflare/raw/cloudflare.d.ts +30 -0
- package/dist/cloudflare/raw/cloudflare.js +29 -0
- package/dist/default/callbacks.cjs +2 -0
- package/dist/default/callbacks.d.ts +55 -0
- package/dist/default/callbacks.js +1 -0
- package/dist/default/envelope.cjs +2 -0
- package/dist/default/envelope.d.ts +5 -0
- package/dist/default/envelope.js +1 -0
- package/dist/default/errors.cjs +150 -0
- package/dist/default/errors.d.ts +82 -0
- package/dist/default/errors.js +145 -0
- package/dist/default/index.cjs +359 -0
- package/dist/default/index.d.ts +94 -0
- package/dist/default/index.js +1 -0
- package/dist/default/index.mjs +295 -0
- package/dist/default/internal.cjs +127 -0
- package/dist/default/internal.d.ts +40 -0
- package/dist/default/internal.js +115 -0
- package/dist/default/options.cjs +2 -0
- package/dist/default/options.d.ts +70 -0
- package/dist/default/options.js +1 -0
- package/dist/default/raw/default.cjs +66 -0
- package/dist/default/raw/default.d.ts +31 -0
- package/dist/default/raw/default.js +30 -0
- package/dist/orderbook/callbacks.cjs +2 -0
- package/dist/orderbook/callbacks.d.ts +55 -0
- package/dist/orderbook/callbacks.js +1 -0
- package/dist/orderbook/envelope.cjs +2 -0
- package/dist/orderbook/envelope.d.ts +5 -0
- package/dist/orderbook/envelope.js +1 -0
- package/dist/orderbook/errors.cjs +150 -0
- package/dist/orderbook/errors.d.ts +82 -0
- package/dist/orderbook/errors.js +145 -0
- package/dist/orderbook/index.cjs +195 -0
- package/dist/orderbook/index.d.ts +57 -0
- package/dist/orderbook/index.js +1 -0
- package/dist/orderbook/index.mjs +139 -0
- package/dist/orderbook/internal.cjs +127 -0
- package/dist/orderbook/internal.d.ts +40 -0
- package/dist/orderbook/internal.js +115 -0
- package/dist/orderbook/options.cjs +2 -0
- package/dist/orderbook/options.d.ts +70 -0
- package/dist/orderbook/options.js +1 -0
- package/dist/orderbook/raw/orderbook.cjs +58 -0
- package/dist/orderbook/raw/orderbook.d.ts +23 -0
- package/dist/orderbook/raw/orderbook.js +22 -0
- package/dist/raw/cloudflare-web/cow_sdk_wasm.d.ts +2870 -0
- package/dist/raw/cloudflare-web/cow_sdk_wasm.js +2183 -0
- package/dist/raw/cloudflare-web/cow_sdk_wasm_bg.wasm +0 -0
- package/dist/raw/cloudflare-web/cow_sdk_wasm_bg.wasm.d.ts +65 -0
- package/dist/raw/default-bundler/cow_sdk_wasm.d.ts +2916 -0
- package/dist/raw/default-bundler/cow_sdk_wasm.js +9 -0
- package/dist/raw/default-bundler/cow_sdk_wasm_bg.js +2297 -0
- package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm +0 -0
- package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm.d.ts +75 -0
- package/dist/raw/default-nodejs/cow_sdk_wasm.cjs +2330 -0
- package/dist/raw/default-nodejs/cow_sdk_wasm.d.ts +2916 -0
- package/dist/raw/default-nodejs/cow_sdk_wasm_bg.wasm.d.ts +75 -0
- package/dist/raw/orderbook-bundler/cow_sdk_wasm.d.ts +1876 -0
- package/dist/raw/orderbook-bundler/cow_sdk_wasm.js +9 -0
- package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.js +1636 -0
- package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm +0 -0
- package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm.d.ts +50 -0
- package/dist/raw/orderbook-nodejs/cow_sdk_wasm.cjs +1661 -0
- package/dist/raw/orderbook-nodejs/cow_sdk_wasm.d.ts +1876 -0
- package/dist/raw/orderbook-nodejs/cow_sdk_wasm_bg.wasm.d.ts +50 -0
- package/dist/raw/signing-bundler/cow_sdk_wasm.d.ts +774 -0
- package/dist/raw/signing-bundler/cow_sdk_wasm.js +9 -0
- package/dist/raw/signing-bundler/cow_sdk_wasm_bg.js +1059 -0
- package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm +0 -0
- package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm.d.ts +27 -0
- package/dist/raw/signing-nodejs/cow_sdk_wasm.cjs +1078 -0
- package/dist/raw/signing-nodejs/cow_sdk_wasm.d.ts +774 -0
- package/dist/raw/signing-nodejs/cow_sdk_wasm_bg.wasm.d.ts +27 -0
- package/dist/signing/callbacks.cjs +2 -0
- package/dist/signing/callbacks.d.ts +55 -0
- package/dist/signing/callbacks.js +1 -0
- package/dist/signing/envelope.cjs +2 -0
- package/dist/signing/envelope.d.ts +5 -0
- package/dist/signing/envelope.js +1 -0
- package/dist/signing/errors.cjs +150 -0
- package/dist/signing/errors.d.ts +82 -0
- package/dist/signing/errors.js +145 -0
- package/dist/signing/index.cjs +93 -0
- package/dist/signing/index.d.ts +23 -0
- package/dist/signing/index.js +1 -0
- package/dist/signing/index.mjs +44 -0
- package/dist/signing/internal.cjs +127 -0
- package/dist/signing/internal.d.ts +40 -0
- package/dist/signing/internal.js +115 -0
- package/dist/signing/options.cjs +2 -0
- package/dist/signing/options.d.ts +70 -0
- package/dist/signing/options.js +1 -0
- package/dist/signing/raw/signing.cjs +52 -0
- package/dist/signing/raw/signing.d.ts +17 -0
- package/dist/signing/raw/signing.js +16 -0
- package/package.json +112 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.translateHttpTransport = translateHttpTransport;
|
|
4
|
+
exports.translateClientConfig = translateClientConfig;
|
|
5
|
+
exports.mergeOptions = mergeOptions;
|
|
6
|
+
exports.mergeSigningOptions = mergeSigningOptions;
|
|
7
|
+
exports.assertActive = assertActive;
|
|
8
|
+
exports.disposeRaw = disposeRaw;
|
|
9
|
+
exports.normalizeThrown = normalizeThrown;
|
|
10
|
+
exports.callAsync = callAsync;
|
|
11
|
+
exports.callSync = callSync;
|
|
12
|
+
exports.defaultsFrom = defaultsFrom;
|
|
13
|
+
const errors_js_1 = require("./errors.cjs");
|
|
14
|
+
function translateHttpTransport(transport) {
|
|
15
|
+
if (transport?.kind === "callback") {
|
|
16
|
+
return transport;
|
|
17
|
+
}
|
|
18
|
+
// An omitted transport (or `{ kind: "fetch" }` without an explicit fetch)
|
|
19
|
+
// defaults to the runtime's global `fetch`, matching the Rust builders'
|
|
20
|
+
// zero-config default.
|
|
21
|
+
const fetchFn = transport?.fetch ?? globalThis.fetch;
|
|
22
|
+
if (typeof fetchFn !== "function") {
|
|
23
|
+
throw (0, errors_js_1.invalidInput)("transport.fetch", "globalThis.fetch is unavailable; pass an explicit fetch function");
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
kind: "callback",
|
|
27
|
+
callback: adaptFetchToCallback(fetchFn)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function translateClientConfig(config) {
|
|
31
|
+
const { signal: _signal, transport, ...rest } = config;
|
|
32
|
+
return {
|
|
33
|
+
...rest,
|
|
34
|
+
transport: translateHttpTransport(transport)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function mergeOptions(defaults, options) {
|
|
38
|
+
const signal = options?.signal ?? defaults.signal;
|
|
39
|
+
if (signal?.aborted) {
|
|
40
|
+
throw (0, errors_js_1.cancelledError)();
|
|
41
|
+
}
|
|
42
|
+
const timeoutMs = options?.timeoutMs ?? defaults.timeoutMs ?? undefined;
|
|
43
|
+
if (signal || timeoutMs !== undefined) {
|
|
44
|
+
const merged = {};
|
|
45
|
+
if (signal) {
|
|
46
|
+
merged.signal = signal;
|
|
47
|
+
}
|
|
48
|
+
if (timeoutMs !== undefined && timeoutMs !== null) {
|
|
49
|
+
merged.timeoutMs = timeoutMs;
|
|
50
|
+
}
|
|
51
|
+
return merged;
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Applies the client-level `signal`/`timeoutMs` defaults to a signing call
|
|
57
|
+
* while preserving the per-call `walletConfig`, and performs the same
|
|
58
|
+
* already-aborted short-circuit as {@link mergeOptions}. Signing methods take
|
|
59
|
+
* {@link SigningOptions} (a superset of {@link SdkClientOptions}), so the
|
|
60
|
+
* shared default propagation must not drop the wallet timeout.
|
|
61
|
+
*/
|
|
62
|
+
function mergeSigningOptions(defaults, options) {
|
|
63
|
+
const merged = mergeOptions(defaults, options);
|
|
64
|
+
const walletConfig = options?.walletConfig;
|
|
65
|
+
if (walletConfig === undefined) {
|
|
66
|
+
return merged;
|
|
67
|
+
}
|
|
68
|
+
return { ...merged, walletConfig };
|
|
69
|
+
}
|
|
70
|
+
function assertActive(disposed) {
|
|
71
|
+
if (disposed) {
|
|
72
|
+
throw (0, errors_js_1.invalidInput)("client", "client has been disposed");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
function disposeRaw(raw) {
|
|
76
|
+
raw?.free?.();
|
|
77
|
+
}
|
|
78
|
+
function normalizeThrown(error) {
|
|
79
|
+
return (0, errors_js_1.normalizeError)(error);
|
|
80
|
+
}
|
|
81
|
+
async function callAsync(operation) {
|
|
82
|
+
try {
|
|
83
|
+
return await operation();
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw (0, errors_js_1.normalizeError)(error);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function callSync(operation) {
|
|
90
|
+
try {
|
|
91
|
+
return operation();
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
throw (0, errors_js_1.normalizeError)(error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
function defaultsFrom(config) {
|
|
98
|
+
return {
|
|
99
|
+
signal: config.signal,
|
|
100
|
+
timeoutMs: config.timeoutMs
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
function adaptFetchToCallback(fetchFn) {
|
|
104
|
+
return async (request) => {
|
|
105
|
+
const init = {
|
|
106
|
+
method: request.method,
|
|
107
|
+
headers: request.headers
|
|
108
|
+
};
|
|
109
|
+
if (request.signal) {
|
|
110
|
+
init.signal = request.signal;
|
|
111
|
+
}
|
|
112
|
+
if (request.body !== undefined) {
|
|
113
|
+
init.body = request.body;
|
|
114
|
+
}
|
|
115
|
+
const response = await fetchFn(request.url, init);
|
|
116
|
+
const headers = {};
|
|
117
|
+
response.headers.forEach((value, key) => {
|
|
118
|
+
headers[key] = value;
|
|
119
|
+
});
|
|
120
|
+
return {
|
|
121
|
+
status: response.status,
|
|
122
|
+
statusText: response.statusText,
|
|
123
|
+
headers,
|
|
124
|
+
body: await response.text()
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type CowError } from "./errors.js";
|
|
2
|
+
import type { CowFetchCallback } from "./callbacks.js";
|
|
3
|
+
import type { CommonClientConfig, HttpTransportConfig, SdkClientOptions, SigningOptions } from "./options.js";
|
|
4
|
+
export interface ClientDefaults {
|
|
5
|
+
signal: AbortSignal | undefined;
|
|
6
|
+
timeoutMs: number | null | undefined;
|
|
7
|
+
}
|
|
8
|
+
export type DisposableRawClient = {
|
|
9
|
+
free?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function translateHttpTransport(transport?: HttpTransportConfig): {
|
|
12
|
+
kind: "callback";
|
|
13
|
+
callback: CowFetchCallback;
|
|
14
|
+
};
|
|
15
|
+
export declare function translateClientConfig<T extends {
|
|
16
|
+
transport?: HttpTransportConfig;
|
|
17
|
+
}>(config: T): Omit<T, "signal" | "transport"> & {
|
|
18
|
+
transport: {
|
|
19
|
+
kind: "callback";
|
|
20
|
+
callback: CowFetchCallback;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare function mergeOptions(defaults: ClientDefaults, options?: SdkClientOptions | null): SdkClientOptions | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Applies the client-level `signal`/`timeoutMs` defaults to a signing call
|
|
26
|
+
* while preserving the per-call `walletConfig`, and performs the same
|
|
27
|
+
* already-aborted short-circuit as {@link mergeOptions}. Signing methods take
|
|
28
|
+
* {@link SigningOptions} (a superset of {@link SdkClientOptions}), so the
|
|
29
|
+
* shared default propagation must not drop the wallet timeout.
|
|
30
|
+
*/
|
|
31
|
+
export declare function mergeSigningOptions(defaults: ClientDefaults, options?: SigningOptions | null): SigningOptions | undefined;
|
|
32
|
+
export declare function assertActive(disposed: boolean): void;
|
|
33
|
+
export declare function disposeRaw(raw: DisposableRawClient | undefined): void;
|
|
34
|
+
export declare function normalizeThrown(error: unknown): CowError;
|
|
35
|
+
export declare function callAsync<T>(operation: () => Promise<T>): Promise<T>;
|
|
36
|
+
export declare function callSync<T>(operation: () => T): T;
|
|
37
|
+
export declare function defaultsFrom(config: CommonClientConfig | {
|
|
38
|
+
signal?: AbortSignal;
|
|
39
|
+
timeoutMs?: number | null;
|
|
40
|
+
}): ClientDefaults;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { cancelledError, invalidInput, normalizeError } from "./errors.js";
|
|
2
|
+
export function translateHttpTransport(transport) {
|
|
3
|
+
if (transport?.kind === "callback") {
|
|
4
|
+
return transport;
|
|
5
|
+
}
|
|
6
|
+
// An omitted transport (or `{ kind: "fetch" }` without an explicit fetch)
|
|
7
|
+
// defaults to the runtime's global `fetch`, matching the Rust builders'
|
|
8
|
+
// zero-config default.
|
|
9
|
+
const fetchFn = transport?.fetch ?? globalThis.fetch;
|
|
10
|
+
if (typeof fetchFn !== "function") {
|
|
11
|
+
throw invalidInput("transport.fetch", "globalThis.fetch is unavailable; pass an explicit fetch function");
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
kind: "callback",
|
|
15
|
+
callback: adaptFetchToCallback(fetchFn)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function translateClientConfig(config) {
|
|
19
|
+
const { signal: _signal, transport, ...rest } = config;
|
|
20
|
+
return {
|
|
21
|
+
...rest,
|
|
22
|
+
transport: translateHttpTransport(transport)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function mergeOptions(defaults, options) {
|
|
26
|
+
const signal = options?.signal ?? defaults.signal;
|
|
27
|
+
if (signal?.aborted) {
|
|
28
|
+
throw cancelledError();
|
|
29
|
+
}
|
|
30
|
+
const timeoutMs = options?.timeoutMs ?? defaults.timeoutMs ?? undefined;
|
|
31
|
+
if (signal || timeoutMs !== undefined) {
|
|
32
|
+
const merged = {};
|
|
33
|
+
if (signal) {
|
|
34
|
+
merged.signal = signal;
|
|
35
|
+
}
|
|
36
|
+
if (timeoutMs !== undefined && timeoutMs !== null) {
|
|
37
|
+
merged.timeoutMs = timeoutMs;
|
|
38
|
+
}
|
|
39
|
+
return merged;
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Applies the client-level `signal`/`timeoutMs` defaults to a signing call
|
|
45
|
+
* while preserving the per-call `walletConfig`, and performs the same
|
|
46
|
+
* already-aborted short-circuit as {@link mergeOptions}. Signing methods take
|
|
47
|
+
* {@link SigningOptions} (a superset of {@link SdkClientOptions}), so the
|
|
48
|
+
* shared default propagation must not drop the wallet timeout.
|
|
49
|
+
*/
|
|
50
|
+
export function mergeSigningOptions(defaults, options) {
|
|
51
|
+
const merged = mergeOptions(defaults, options);
|
|
52
|
+
const walletConfig = options?.walletConfig;
|
|
53
|
+
if (walletConfig === undefined) {
|
|
54
|
+
return merged;
|
|
55
|
+
}
|
|
56
|
+
return { ...merged, walletConfig };
|
|
57
|
+
}
|
|
58
|
+
export function assertActive(disposed) {
|
|
59
|
+
if (disposed) {
|
|
60
|
+
throw invalidInput("client", "client has been disposed");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export function disposeRaw(raw) {
|
|
64
|
+
raw?.free?.();
|
|
65
|
+
}
|
|
66
|
+
export function normalizeThrown(error) {
|
|
67
|
+
return normalizeError(error);
|
|
68
|
+
}
|
|
69
|
+
export async function callAsync(operation) {
|
|
70
|
+
try {
|
|
71
|
+
return await operation();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
throw normalizeError(error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function callSync(operation) {
|
|
78
|
+
try {
|
|
79
|
+
return operation();
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
throw normalizeError(error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
export function defaultsFrom(config) {
|
|
86
|
+
return {
|
|
87
|
+
signal: config.signal,
|
|
88
|
+
timeoutMs: config.timeoutMs
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function adaptFetchToCallback(fetchFn) {
|
|
92
|
+
return async (request) => {
|
|
93
|
+
const init = {
|
|
94
|
+
method: request.method,
|
|
95
|
+
headers: request.headers
|
|
96
|
+
};
|
|
97
|
+
if (request.signal) {
|
|
98
|
+
init.signal = request.signal;
|
|
99
|
+
}
|
|
100
|
+
if (request.body !== undefined) {
|
|
101
|
+
init.body = request.body;
|
|
102
|
+
}
|
|
103
|
+
const response = await fetchFn(request.url, init);
|
|
104
|
+
const headers = {};
|
|
105
|
+
response.headers.forEach((value, key) => {
|
|
106
|
+
headers[key] = value;
|
|
107
|
+
});
|
|
108
|
+
return {
|
|
109
|
+
status: response.status,
|
|
110
|
+
statusText: response.statusText,
|
|
111
|
+
headers,
|
|
112
|
+
body: await response.text()
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { CowEnv, CowFetchCallback, CowFetchRequest, CowFetchResponse } from "./callbacks.js";
|
|
2
|
+
export interface SdkClientOptions {
|
|
3
|
+
timeoutMs?: number;
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}
|
|
6
|
+
export interface WalletConfig {
|
|
7
|
+
timeoutMs?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface SigningOptions extends SdkClientOptions {
|
|
10
|
+
walletConfig?: WalletConfig;
|
|
11
|
+
}
|
|
12
|
+
export type HttpTransportConfig = {
|
|
13
|
+
kind: "fetch";
|
|
14
|
+
fetch?: typeof globalThis.fetch;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "callback";
|
|
17
|
+
callback: CowFetchCallback;
|
|
18
|
+
};
|
|
19
|
+
export type JitterStrategyConfig = "none" | "full" | "equal" | "decorrelated";
|
|
20
|
+
export type LimiterScopeConfig = "global" | "perHost";
|
|
21
|
+
export interface RetryPolicyConfig {
|
|
22
|
+
/** Maximum attempts, including the initial request. */
|
|
23
|
+
maxAttempts?: number;
|
|
24
|
+
/** Base exponential-backoff delay in milliseconds. */
|
|
25
|
+
baseDelayMs?: number;
|
|
26
|
+
/** Maximum exponential-backoff delay in milliseconds. */
|
|
27
|
+
maxDelayMs?: number;
|
|
28
|
+
}
|
|
29
|
+
export interface RequestRateLimiterConfig {
|
|
30
|
+
/** Request tokens granted per interval. Zero disables limiting. */
|
|
31
|
+
tokensPerInterval?: number;
|
|
32
|
+
/** Limiter interval in milliseconds. */
|
|
33
|
+
intervalMs?: number;
|
|
34
|
+
/** Bucket scope. */
|
|
35
|
+
scope?: LimiterScopeConfig;
|
|
36
|
+
}
|
|
37
|
+
export interface TransportPolicyConfig {
|
|
38
|
+
retryPolicy?: RetryPolicyConfig;
|
|
39
|
+
requestRateLimiter?: RequestRateLimiterConfig;
|
|
40
|
+
jitterStrategy?: JitterStrategyConfig;
|
|
41
|
+
userAgent?: string;
|
|
42
|
+
}
|
|
43
|
+
export interface CommonClientConfig {
|
|
44
|
+
chainId: number;
|
|
45
|
+
env?: CowEnv | string | null;
|
|
46
|
+
apiKey?: string | null;
|
|
47
|
+
transport?: HttpTransportConfig;
|
|
48
|
+
transportPolicy?: TransportPolicyConfig | null;
|
|
49
|
+
timeoutMs?: number | null;
|
|
50
|
+
signal?: AbortSignal;
|
|
51
|
+
}
|
|
52
|
+
export interface IpfsClientConfig {
|
|
53
|
+
ipfsUri?: string | null;
|
|
54
|
+
transport?: HttpTransportConfig;
|
|
55
|
+
transportPolicy?: TransportPolicyConfig | null;
|
|
56
|
+
timeoutMs?: number | null;
|
|
57
|
+
signal?: AbortSignal;
|
|
58
|
+
}
|
|
59
|
+
export interface SubgraphClientConfig {
|
|
60
|
+
chainId: number;
|
|
61
|
+
apiKey: string;
|
|
62
|
+
transport?: HttpTransportConfig;
|
|
63
|
+
transportPolicy?: TransportPolicyConfig | null;
|
|
64
|
+
timeoutMs?: number | null;
|
|
65
|
+
signal?: AbortSignal;
|
|
66
|
+
}
|
|
67
|
+
export interface TradingClientConfig extends CommonClientConfig {
|
|
68
|
+
appCode: string;
|
|
69
|
+
}
|
|
70
|
+
export type { CowFetchCallback, CowFetchRequest, CowFetchResponse };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.wasmVersion = exports.supportedChainIds = exports.signOrderWithTypedDataSigner = exports.signOrderWithEip1271 = exports.signOrderWithEip1193 = exports.signOrderWithCustomEip1271 = exports.signOrderEthSignDigest = exports.orderTypedData = exports.eip1271SignaturePayload = exports.domainSeparator = exports.deploymentAddresses = exports.decodeSettlementLog = exports.decodeEthFlowLog = exports.computeOrderUid = exports.__cow_sdk_wasm_init = void 0;
|
|
37
|
+
const wasm = __importStar(require("../../raw/signing-nodejs/cow_sdk_wasm.cjs"));
|
|
38
|
+
exports.__cow_sdk_wasm_init = wasm.__cow_sdk_wasm_init;
|
|
39
|
+
exports.computeOrderUid = wasm.computeOrderUid;
|
|
40
|
+
exports.decodeEthFlowLog = wasm.decodeEthFlowLog;
|
|
41
|
+
exports.decodeSettlementLog = wasm.decodeSettlementLog;
|
|
42
|
+
exports.deploymentAddresses = wasm.deploymentAddresses;
|
|
43
|
+
exports.domainSeparator = wasm.domainSeparator;
|
|
44
|
+
exports.eip1271SignaturePayload = wasm.eip1271SignaturePayload;
|
|
45
|
+
exports.orderTypedData = wasm.orderTypedData;
|
|
46
|
+
exports.signOrderEthSignDigest = wasm.signOrderEthSignDigest;
|
|
47
|
+
exports.signOrderWithCustomEip1271 = wasm.signOrderWithCustomEip1271;
|
|
48
|
+
exports.signOrderWithEip1193 = wasm.signOrderWithEip1193;
|
|
49
|
+
exports.signOrderWithEip1271 = wasm.signOrderWithEip1271;
|
|
50
|
+
exports.signOrderWithTypedDataSigner = wasm.signOrderWithTypedDataSigner;
|
|
51
|
+
exports.supportedChainIds = wasm.supportedChainIds;
|
|
52
|
+
exports.wasmVersion = wasm.wasmVersion;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as wasm from "../../raw/signing-bundler/cow_sdk_wasm.js";
|
|
2
|
+
export type * from "../../raw/signing-bundler/cow_sdk_wasm.js";
|
|
3
|
+
export declare const __cow_sdk_wasm_init: typeof wasm.__cow_sdk_wasm_init;
|
|
4
|
+
export declare const computeOrderUid: typeof wasm.computeOrderUid;
|
|
5
|
+
export declare const decodeEthFlowLog: typeof wasm.decodeEthFlowLog;
|
|
6
|
+
export declare const decodeSettlementLog: typeof wasm.decodeSettlementLog;
|
|
7
|
+
export declare const deploymentAddresses: typeof wasm.deploymentAddresses;
|
|
8
|
+
export declare const domainSeparator: typeof wasm.domainSeparator;
|
|
9
|
+
export declare const eip1271SignaturePayload: typeof wasm.eip1271SignaturePayload;
|
|
10
|
+
export declare const orderTypedData: typeof wasm.orderTypedData;
|
|
11
|
+
export declare const signOrderEthSignDigest: typeof wasm.signOrderEthSignDigest;
|
|
12
|
+
export declare const signOrderWithCustomEip1271: typeof wasm.signOrderWithCustomEip1271;
|
|
13
|
+
export declare const signOrderWithEip1193: typeof wasm.signOrderWithEip1193;
|
|
14
|
+
export declare const signOrderWithEip1271: typeof wasm.signOrderWithEip1271;
|
|
15
|
+
export declare const signOrderWithTypedDataSigner: typeof wasm.signOrderWithTypedDataSigner;
|
|
16
|
+
export declare const supportedChainIds: typeof wasm.supportedChainIds;
|
|
17
|
+
export declare const wasmVersion: typeof wasm.wasmVersion;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as wasm from "../../raw/signing-bundler/cow_sdk_wasm.js";
|
|
2
|
+
export const __cow_sdk_wasm_init = wasm.__cow_sdk_wasm_init;
|
|
3
|
+
export const computeOrderUid = wasm.computeOrderUid;
|
|
4
|
+
export const decodeEthFlowLog = wasm.decodeEthFlowLog;
|
|
5
|
+
export const decodeSettlementLog = wasm.decodeSettlementLog;
|
|
6
|
+
export const deploymentAddresses = wasm.deploymentAddresses;
|
|
7
|
+
export const domainSeparator = wasm.domainSeparator;
|
|
8
|
+
export const eip1271SignaturePayload = wasm.eip1271SignaturePayload;
|
|
9
|
+
export const orderTypedData = wasm.orderTypedData;
|
|
10
|
+
export const signOrderEthSignDigest = wasm.signOrderEthSignDigest;
|
|
11
|
+
export const signOrderWithCustomEip1271 = wasm.signOrderWithCustomEip1271;
|
|
12
|
+
export const signOrderWithEip1193 = wasm.signOrderWithEip1193;
|
|
13
|
+
export const signOrderWithEip1271 = wasm.signOrderWithEip1271;
|
|
14
|
+
export const signOrderWithTypedDataSigner = wasm.signOrderWithTypedDataSigner;
|
|
15
|
+
export const supportedChainIds = wasm.supportedChainIds;
|
|
16
|
+
export const wasmVersion = wasm.wasmVersion;
|
package/package.json
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@symbiome-forge/cow-sdk-wasm",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "TypeScript/WebAssembly SDK for CoW Protocol — typed orderbook, trading, signing (EIP-712/1271/1193), and app-data, compiled from the Rust SDK.",
|
|
5
|
+
"license": "GPL-3.0-or-later",
|
|
6
|
+
"homepage": "https://github.com/0xSymbiome/cow-rs",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/0xSymbiome/cow-rs.git",
|
|
10
|
+
"directory": "crates/wasm/npm"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"cow-protocol",
|
|
14
|
+
"cowswap",
|
|
15
|
+
"sdk",
|
|
16
|
+
"ethereum",
|
|
17
|
+
"defi",
|
|
18
|
+
"orderbook",
|
|
19
|
+
"trading",
|
|
20
|
+
"wasm",
|
|
21
|
+
"webassembly",
|
|
22
|
+
"wasm-bindgen",
|
|
23
|
+
"typescript",
|
|
24
|
+
"eip-712",
|
|
25
|
+
"eip-1271",
|
|
26
|
+
"eip-1193",
|
|
27
|
+
"app-data"
|
|
28
|
+
],
|
|
29
|
+
"packageManager": "pnpm@11.7.0",
|
|
30
|
+
"type": "module",
|
|
31
|
+
"main": "./dist/default/index.cjs",
|
|
32
|
+
"module": "./dist/default/index.mjs",
|
|
33
|
+
"types": "./dist/default/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"types": "./dist/default/index.d.ts",
|
|
37
|
+
"node": {
|
|
38
|
+
"types": "./dist/default/index.d.ts",
|
|
39
|
+
"require": "./dist/default/index.cjs",
|
|
40
|
+
"default": "./dist/default/index.cjs"
|
|
41
|
+
},
|
|
42
|
+
"browser": {
|
|
43
|
+
"types": "./dist/default/index.d.ts",
|
|
44
|
+
"import": "./dist/default/index.mjs"
|
|
45
|
+
},
|
|
46
|
+
"import": "./dist/default/index.mjs",
|
|
47
|
+
"default": "./dist/default/index.mjs"
|
|
48
|
+
},
|
|
49
|
+
"./orderbook": {
|
|
50
|
+
"types": "./dist/orderbook/index.d.ts",
|
|
51
|
+
"node": {
|
|
52
|
+
"types": "./dist/orderbook/index.d.ts",
|
|
53
|
+
"require": "./dist/orderbook/index.cjs",
|
|
54
|
+
"default": "./dist/orderbook/index.cjs"
|
|
55
|
+
},
|
|
56
|
+
"browser": {
|
|
57
|
+
"types": "./dist/orderbook/index.d.ts",
|
|
58
|
+
"import": "./dist/orderbook/index.mjs"
|
|
59
|
+
},
|
|
60
|
+
"import": "./dist/orderbook/index.mjs",
|
|
61
|
+
"default": "./dist/orderbook/index.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./signing": {
|
|
64
|
+
"types": "./dist/signing/index.d.ts",
|
|
65
|
+
"node": {
|
|
66
|
+
"types": "./dist/signing/index.d.ts",
|
|
67
|
+
"require": "./dist/signing/index.cjs",
|
|
68
|
+
"default": "./dist/signing/index.cjs"
|
|
69
|
+
},
|
|
70
|
+
"browser": {
|
|
71
|
+
"types": "./dist/signing/index.d.ts",
|
|
72
|
+
"import": "./dist/signing/index.mjs"
|
|
73
|
+
},
|
|
74
|
+
"import": "./dist/signing/index.mjs",
|
|
75
|
+
"default": "./dist/signing/index.mjs"
|
|
76
|
+
},
|
|
77
|
+
"./cloudflare": {
|
|
78
|
+
"types": "./dist/cloudflare/index.d.ts",
|
|
79
|
+
"browser": {
|
|
80
|
+
"types": "./dist/cloudflare/index.d.ts",
|
|
81
|
+
"import": "./dist/cloudflare/index.mjs"
|
|
82
|
+
},
|
|
83
|
+
"import": "./dist/cloudflare/index.mjs",
|
|
84
|
+
"default": "./dist/cloudflare/index.mjs"
|
|
85
|
+
},
|
|
86
|
+
"./cloudflare/wasm": "./dist/raw/cloudflare-web/cow_sdk_wasm_bg.wasm"
|
|
87
|
+
},
|
|
88
|
+
"files": [
|
|
89
|
+
"dist/",
|
|
90
|
+
"README.md",
|
|
91
|
+
"LICENSE"
|
|
92
|
+
],
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "bash scripts/build.sh",
|
|
95
|
+
"compile:facade": "bash scripts/compile-facade.sh",
|
|
96
|
+
"test": "vitest run --config vitest.config.ts",
|
|
97
|
+
"typecheck": "tsc --project tsconfig.facade.json --noEmit",
|
|
98
|
+
"prepublishOnly": "node scripts/render-package-json.mjs && bash scripts/prepublish-guard.sh"
|
|
99
|
+
},
|
|
100
|
+
"devDependencies": {
|
|
101
|
+
"@types/node": "25.6.2",
|
|
102
|
+
"typescript": "6.0.3",
|
|
103
|
+
"vitest": "4.1.5"
|
|
104
|
+
},
|
|
105
|
+
"engines": {
|
|
106
|
+
"node": ">=22.0.0"
|
|
107
|
+
},
|
|
108
|
+
"publishConfig": {
|
|
109
|
+
"access": "public"
|
|
110
|
+
},
|
|
111
|
+
"sideEffects": false
|
|
112
|
+
}
|