@symbiome-forge/cow-sdk-wasm 0.1.0-alpha.5 → 0.1.0-alpha.6

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.
Files changed (94) hide show
  1. package/README.md +41 -15
  2. package/dist/default/edge.d.ts +111 -0
  3. package/dist/default/{index.mjs → edge.mjs} +20 -1
  4. package/dist/default/index.cjs +20 -0
  5. package/dist/default/index.d.ts +14 -0
  6. package/dist/default/module.d.ts +111 -0
  7. package/dist/default/module.mjs +323 -0
  8. package/dist/default/raw/{trading-web.d.ts → default-module.d.ts} +8 -3
  9. package/dist/default/raw/{trading-web.js → default-module.js} +4 -2
  10. package/dist/{orderbook/raw/trading-web.d.ts → default/raw/default-web.d.ts} +4 -2
  11. package/dist/{orderbook/raw/trading-web.js → default/raw/default-web.js} +3 -1
  12. package/dist/default/raw/default.cjs +3 -1
  13. package/dist/default/raw/default.d.ts +4 -0
  14. package/dist/default/raw/default.js +1 -0
  15. package/dist/orderbook/edge.d.ts +73 -0
  16. package/dist/orderbook/{index.mjs → edge.mjs} +20 -1
  17. package/dist/orderbook/index.cjs +20 -0
  18. package/dist/orderbook/index.d.ts +14 -0
  19. package/dist/orderbook/module.d.ts +73 -0
  20. package/dist/orderbook/module.mjs +164 -0
  21. package/dist/orderbook/raw/orderbook-module.d.ts +27 -0
  22. package/dist/orderbook/raw/orderbook-module.js +23 -0
  23. package/dist/orderbook/raw/orderbook-web.d.ts +24 -0
  24. package/dist/orderbook/raw/orderbook-web.js +23 -0
  25. package/dist/orderbook/raw/orderbook.cjs +3 -1
  26. package/dist/orderbook/raw/orderbook.d.ts +4 -0
  27. package/dist/orderbook/raw/orderbook.js +1 -0
  28. package/dist/raw/default-bundler/cow_sdk_wasm_bg.js +20 -20
  29. package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm +0 -0
  30. package/dist/raw/default-bundler/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  31. package/dist/raw/default-module/cow_sdk_wasm.d.ts +3113 -0
  32. package/dist/raw/default-module/cow_sdk_wasm.js +2392 -0
  33. package/dist/raw/default-module/cow_sdk_wasm_bg.wasm.d.ts +78 -0
  34. package/dist/raw/default-nodejs/cow_sdk_wasm.cjs +20 -20
  35. package/dist/raw/default-nodejs/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  36. package/dist/raw/default-web/cow_sdk_wasm.d.ts +3216 -0
  37. package/dist/raw/default-web/cow_sdk_wasm.js +2489 -0
  38. package/dist/raw/default-web/cow_sdk_wasm_bg.wasm.d.ts +78 -0
  39. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.js +20 -20
  40. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm +0 -0
  41. package/dist/raw/orderbook-bundler/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  42. package/dist/raw/orderbook-module/cow_sdk_wasm.d.ts +2037 -0
  43. package/dist/raw/orderbook-module/cow_sdk_wasm.js +1692 -0
  44. package/dist/raw/orderbook-module/cow_sdk_wasm_bg.wasm.d.ts +52 -0
  45. package/dist/raw/orderbook-nodejs/cow_sdk_wasm.cjs +20 -20
  46. package/dist/raw/orderbook-nodejs/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  47. package/dist/raw/orderbook-web/cow_sdk_wasm.d.ts +2114 -0
  48. package/dist/raw/orderbook-web/cow_sdk_wasm.js +1789 -0
  49. package/dist/raw/orderbook-web/cow_sdk_wasm_bg.wasm.d.ts +52 -0
  50. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.js +10 -10
  51. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm +0 -0
  52. package/dist/raw/signing-bundler/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  53. package/dist/raw/signing-module/cow_sdk_wasm.d.ts +774 -0
  54. package/dist/raw/signing-module/cow_sdk_wasm.js +1062 -0
  55. package/dist/raw/signing-module/cow_sdk_wasm_bg.wasm.d.ts +27 -0
  56. package/dist/raw/signing-nodejs/cow_sdk_wasm.cjs +10 -10
  57. package/dist/raw/signing-nodejs/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  58. package/dist/raw/signing-web/cow_sdk_wasm.d.ts +826 -0
  59. package/dist/raw/signing-web/cow_sdk_wasm.js +1159 -0
  60. package/dist/raw/signing-web/cow_sdk_wasm_bg.wasm.d.ts +27 -0
  61. package/dist/raw/trading-bundler/cow_sdk_wasm_bg.js +20 -20
  62. package/dist/raw/trading-bundler/cow_sdk_wasm_bg.wasm +0 -0
  63. package/dist/raw/trading-bundler/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  64. package/dist/raw/trading-module/cow_sdk_wasm.d.ts +2977 -0
  65. package/dist/raw/trading-module/cow_sdk_wasm.js +2178 -0
  66. package/dist/raw/trading-module/cow_sdk_wasm_bg.wasm.d.ts +68 -0
  67. package/dist/raw/trading-nodejs/cow_sdk_wasm.cjs +20 -20
  68. package/dist/raw/trading-nodejs/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  69. package/dist/raw/trading-web/cow_sdk_wasm.d.ts +3 -3
  70. package/dist/raw/trading-web/cow_sdk_wasm.js +21 -21
  71. package/dist/raw/trading-web/cow_sdk_wasm_bg.wasm.d.ts +3 -3
  72. package/dist/signing/edge.d.ts +37 -0
  73. package/dist/signing/{index.mjs → edge.mjs} +20 -1
  74. package/dist/signing/index.cjs +20 -0
  75. package/dist/signing/index.d.ts +14 -0
  76. package/dist/signing/module.d.ts +37 -0
  77. package/dist/signing/module.mjs +63 -0
  78. package/dist/signing/raw/signing-module.d.ts +21 -0
  79. package/dist/signing/raw/signing-module.js +17 -0
  80. package/dist/signing/raw/signing-web.d.ts +18 -0
  81. package/dist/signing/raw/signing-web.js +17 -0
  82. package/dist/signing/raw/signing.cjs +3 -1
  83. package/dist/signing/raw/signing.d.ts +4 -0
  84. package/dist/signing/raw/signing.js +1 -0
  85. package/dist/trading/module.d.ts +92 -0
  86. package/dist/trading/{index.mjs → module.mjs} +1 -1
  87. package/dist/{signing/raw/trading-web.d.ts → trading/raw/trading-module.d.ts} +6 -3
  88. package/dist/{signing/raw/trading-web.js → trading/raw/trading-module.js} +2 -2
  89. package/dist/trading/raw/trading.cjs +0 -6
  90. package/dist/trading/raw/trading.js +0 -6
  91. package/package.json +116 -18
  92. package/dist/default/raw/trading-web.cjs +0 -65
  93. package/dist/orderbook/raw/trading-web.cjs +0 -65
  94. package/dist/signing/raw/trading-web.cjs +0 -65
package/README.md CHANGED
@@ -37,19 +37,37 @@ flavor-specific imports — with no bundled wallet library.
37
37
 
38
38
  ## Pick your import
39
39
 
40
+ Pick the **flavor** (feature set) by its base subpath. Every flavor ships the same
41
+ runtime entries over one shared wasm binary, so pick the **runtime** by the suffix:
42
+
40
43
  | Import | Surface | Use when |
41
44
  | --- | --- | --- |
42
- | `@symbiome-forge/cow-sdk-wasm/trading` | Full order lifecycle: quote, sign, post, cancel, app-data | A browser dapp, a Node backend, or an edge runtime running order flow — one feature set serves all three; pick the runtime by import |
43
- | `@symbiome-forge/cow-sdk-wasm/trading/edge` | The `trading` flavor's web-target build, with explicit wasm init | Cloudflare Workers, Deno, or Vercel Edge; pair with `…/trading/edge/wasm` for the module asset |
45
+ | `@symbiome-forge/cow-sdk-wasm/trading` | Full order lifecycle: quote, sign, post, cancel, app-data | A browser dapp, a Node backend, or an edge runtime running order flow — one feature set serves all three; pick the runtime by suffix |
44
46
  | `@symbiome-forge/cow-sdk-wasm/orderbook` | Orderbook reads, cancellation, and signing — no trading or app-data | A read-focused dapp that does not post orders |
45
47
  | `@symbiome-forge/cow-sdk-wasm/signing` | Signing, UID, EIP-1271, deployment, and version helpers — the smallest flavor | A signer service or HSM-facing adapter |
46
48
  | `@symbiome-forge/cow-sdk-wasm` | Everything above plus subgraph analytics and IPFS app-data | General use that needs subgraph or IPFS |
47
49
 
48
- The `trading` flavor resolves the right target automatically through standard
49
- conditional exports — `node` and `browser` for bundlers and Node, and `workerd` /
50
- `deno` / `edge-light` / `bun` for edge with `./trading/edge` as the explicit
51
- Workers entry. Public imports go through these subpaths; do not import from
52
- `dist/raw` or generated wasm-pack directories.
50
+ Each flavor exposes three runtime entries that share one wasm binary:
51
+
52
+ - the **base** import (above) auto-selects the build through standard conditional
53
+ exports: `node` loads the Node (CommonJS) build; `browser`, `import`, and the edge
54
+ conditions (`workerd` / `worker` / `deno` / `edge-light` / `bun`) load the
55
+ explicit-init **web** build, which instantiates its wasm through
56
+ `new URL(import.meta.url)` and so works across every bundler and with no bundler at
57
+ all — call `await initialize()` once before the first call;
58
+ - **`…/edge`** is the explicit web entry for Cloudflare Workers, Deno, and Vercel
59
+ Edge — pair it with **`…/edge/wasm`** for the precompiled module and call
60
+ `await initialize(wasmModule)`;
61
+ - **`…/module`** is the standards-track source-phase build (`import source` / Wasm
62
+ ESM Integration): it auto-initializes with no `initialize()` call, runs today on
63
+ Node 24, Deno, and esbuild, and is the forward path for browser bundlers as they
64
+ adopt source-phase.
65
+
66
+ So the focused flavors' entries are `…/trading/edge`, `…/trading/module`,
67
+ `…/orderbook/edge`, `…/signing/module`, and so on; the root (everything) flavor's are
68
+ `@symbiome-forge/cow-sdk-wasm/edge` and `@symbiome-forge/cow-sdk-wasm/module`. Public
69
+ imports go through these subpaths; do not import from `dist/raw` or generated
70
+ wasm-pack directories.
53
71
 
54
72
  Building a **native Rust** service, or a Rust app you compile to wasm yourself?
55
73
  Use [`cow-sdk`](https://crates.io/crates/cow-sdk) — this package is for
@@ -63,10 +81,15 @@ preview and signature. The wallet signs a typed-data envelope the SDK hands it;
63
81
  no key reaches the package.
64
82
 
65
83
  ```ts
66
- import { TradingClient } from "@symbiome-forge/cow-sdk-wasm/trading";
84
+ import { initialize, TradingClient } from "@symbiome-forge/cow-sdk-wasm/trading";
67
85
  import { createWalletClient, custom } from "viem";
68
86
  import { mainnet } from "viem/chains";
69
87
 
88
+ // Instantiate the wasm module once before any call. The bundled module is resolved
89
+ // from the package via `new URL(import.meta.url)`, so this works in every bundler
90
+ // and with no bundler at all — no bundler wasm plugin required.
91
+ await initialize();
92
+
70
93
  const [owner] = await window.ethereum.request({ method: "eth_requestAccounts" });
71
94
  const wallet = createWalletClient({ chain: mainnet, transport: custom(window.ethereum) });
72
95
 
@@ -210,13 +233,16 @@ current alpha build (gzip is the compressed-transfer figure):
210
233
  | signing | 0.31 MiB | 120 KiB | 142 KiB | 0.9 MiB raw / 300 KiB brotli |
211
234
  | orderbook | 1.02 MiB | 341 KiB | 447 KiB | 1.5 MiB raw / 500 KiB brotli |
212
235
  | trading | 1.54 MiB | 490 KiB | 659 KiB | 3.2 MiB raw / 850 KiB brotli |
213
- | default | 1.63 MiB | 513 KiB | 692 KiB | 3.3 MiB raw / 900 KiB brotli |
214
-
215
- The `trading` flavor emits one wasm binary across its bundler, Node, and web
216
- targets; its web-target gzip size is within the current Cloudflare Workers Free
217
- compressed-size limit, enforced as a byte budget on every build. End-to-end
218
- Workers support also depends on `wrangler deploy --dry-run` verification and a
219
- Worker startup-time gate, tracked separately.
236
+ | default | 1.63 MiB | 513 KiB | 691 KiB | 3.3 MiB raw / 900 KiB brotli |
237
+
238
+ Each flavor emits one wasm binary shared across its bundler, Node, web, and
239
+ source-phase module targets the web glue's default URL, the module glue's
240
+ `import source`, and the raw Worker module subpath all reuse the one bundler copy,
241
+ so a flavor's gzip figure above is its size on every runtime. Each flavor's gzip
242
+ size is enforced as a per-build byte budget within the current Cloudflare Workers
243
+ Free compressed-size limit. End-to-end Workers support also depends on
244
+ `wrangler deploy --dry-run` verification and a Worker startup-time gate, tracked
245
+ separately.
220
246
 
221
247
  ## Not in this package
222
248
 
@@ -0,0 +1,111 @@
1
+ /// <reference lib="esnext.disposable" />
2
+ import * as raw from "./raw/default.js";
3
+ import type { WasmEnvelope } from "./envelope.js";
4
+ import type { CommonClientConfig, IpfsClientConfig, SdkClientOptions, SigningOptions, SubgraphClientConfig, TradingClientConfig } from "./options.js";
5
+ import type { ContractReadCallback, CustomEip1271Callback, DigestSignerCallback, Eip1193RequestCallback, TypedDataSignerCallback } from "./callbacks.js";
6
+ export interface OrderBookClientConfig extends CommonClientConfig {
7
+ }
8
+ /**
9
+ * Initialize the wasm module, idempotently, once per module instance.
10
+ *
11
+ * On the `web` build — Cloudflare Workers, Deno, Vercel Edge, and no-bundler
12
+ * browsers — the host owns module instantiation, so it must call this once with
13
+ * the compiled module (Workers pass the `CompiledWasm` binding) or its URL/bytes
14
+ * (Deno and browsers). On the `bundler` and `nodejs` builds the host
15
+ * bundler/runtime instantiates the module on import, so this resolves
16
+ * immediately and the argument is ignored — calling it is optional and harmless,
17
+ * which keeps one call shape working across every target.
18
+ */
19
+ export declare function initialize(module?: WebAssembly.Module | raw.InitInput): Promise<void>;
20
+ export default initialize;
21
+ export type { InitInput } from "./raw/default.js";
22
+ export declare class IpfsClient {
23
+ #private;
24
+ constructor(config: IpfsClientConfig);
25
+ fetchAppDataFromCid(cid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataDocDto>>;
26
+ fetchAppDataFromHex(appDataHex: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataDocDto>>;
27
+ dispose(): void;
28
+ [Symbol.dispose](): void;
29
+ }
30
+ export declare class OrderBookClient {
31
+ #private;
32
+ constructor(config: OrderBookClientConfig);
33
+ cancelOrders(signed: raw.SignedCancellationsInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<{
34
+ cancelled: true;
35
+ }>>;
36
+ getNativePrice(token: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.NativePriceResponseDto>>;
37
+ getOrder(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto>>;
38
+ getOrders(owner: string, pagination?: raw.PaginationOptions | null, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto[]>>;
39
+ getOrderMultiEnv(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto>>;
40
+ getTxOrders(txHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto[]>>;
41
+ getVersion(options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
42
+ getOrderLink(orderUid: string): WasmEnvelope<string>;
43
+ getQuote(request: raw.OrderQuoteRequestInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderQuoteResponseDto>>;
44
+ getTrades(query: raw.TradesQueryInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TradeDto[]>>;
45
+ getOrderCompetitionStatus(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.CompetitionOrderStatusDto>>;
46
+ getTotalSurplus(owner: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TotalSurplusDto>>;
47
+ getSolverCompetition(auctionId: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.SolverCompetitionResponseDto>>;
48
+ getSolverCompetitionByTxHash(txHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.SolverCompetitionResponseDto>>;
49
+ getAppData(appDataHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataObjectDto>>;
50
+ uploadAppData(appDataHash: string, fullAppData: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<{
51
+ uploaded: true;
52
+ }>>;
53
+ sendOrder(signed: raw.SignedOrderDto, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
54
+ sendOrderCreation(input: raw.OrderCreationInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
55
+ dispose(): void;
56
+ [Symbol.dispose](): void;
57
+ }
58
+ export declare class SubgraphClient {
59
+ #private;
60
+ constructor(config: SubgraphClientConfig);
61
+ getLastDaysVolume(days: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
62
+ getLastHoursVolume(hours: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
63
+ getTotals(options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
64
+ runQuery(request: raw.SubgraphQueryInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
65
+ dispose(): void;
66
+ [Symbol.dispose](): void;
67
+ }
68
+ export declare class TradingClient {
69
+ #private;
70
+ constructor(config: TradingClientConfig);
71
+ buildSellNativeCurrencyTx(order: raw.OrderInput, quoteId: number, from: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.BuiltSellNativeCurrencyTxDto>>;
72
+ buildSellNativeCurrencyTxFromQuote(quoteResults: raw.QuoteResultsDto, from: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.BuiltSellNativeCurrencyTxDto>>;
73
+ getCowProtocolAllowance(params: raw.AllowanceParametersInput, readContractCallback: ContractReadCallback, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
74
+ buildApprovalTx(params: raw.ApprovalParametersInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TransactionRequestDto>>;
75
+ getQuote(params: raw.SwapParametersInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.QuoteResultsDto>>;
76
+ postLimitOrder(params: raw.LimitTradeParametersInput, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
77
+ postSwapOrder(params: raw.SwapParametersInput, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
78
+ postSwapOrderFromQuote(quoteResults: raw.QuoteResultsDto, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
79
+ postSwapOrderWithEip1271(params: raw.SwapParametersInput, owner: string, customCallback: CustomEip1271Callback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
80
+ dispose(): void;
81
+ [Symbol.dispose](): void;
82
+ }
83
+ export declare function appDataDoc(doc: raw.AppDataDocInput): WasmEnvelope<raw.AppDataDocDto>;
84
+ export declare function appDataHexToCid(appDataHex: string): WasmEnvelope<string>;
85
+ export declare function appDataInfo(doc: raw.AppDataDocInput): WasmEnvelope<raw.AppDataInfoDto>;
86
+ export declare function buildCancelOrderTx(params: raw.OrderTraderParametersInput): WasmEnvelope<raw.TransactionRequestDto>;
87
+ export declare function buildPresignTx(params: raw.OrderTraderParametersInput): WasmEnvelope<raw.TransactionRequestDto>;
88
+ export declare function cidToAppDataHex(cid: string): WasmEnvelope<string>;
89
+ export declare function computeOrderUid(input: raw.OrderInput, chainId: number, owner: string): WasmEnvelope<raw.GeneratedOrderUidDto>;
90
+ export declare function decodeEthFlowLog(log: raw.EventLogInput): WasmEnvelope<raw.EthFlowEventDto>;
91
+ export declare function decodeSettlementLog(log: raw.EventLogInput): WasmEnvelope<raw.SettlementEventDto>;
92
+ export declare function deploymentAddresses(chainId: number, env?: string | null): WasmEnvelope<raw.DeploymentAddressesDto>;
93
+ export declare function domainSeparator(chainId: number): string;
94
+ export declare function eip1271SignaturePayload(input: raw.OrderInput, ecdsaSignature: string): WasmEnvelope<string>;
95
+ export declare function orderTypedData(input: raw.OrderInput, chainId: number): WasmEnvelope<raw.TypedDataEnvelopeDto>;
96
+ export declare function signCancellationEthSignDigest(orderUids: string[], chainId: number, digestSigner: DigestSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
97
+ export declare function signCancellationWithEip1193(orderUids: string[], chainId: number, owner: string, requestCallback: Eip1193RequestCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
98
+ export declare function signCancellationWithTypedDataSigner(orderUids: string[], chainId: number, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
99
+ export declare function signOrderEthSignDigest(input: raw.OrderInput, chainId: number, owner: string, digestSigner: DigestSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
100
+ export declare function signOrderWithCustomEip1271(input: raw.OrderInput, chainId: number, owner: string, customCallback: CustomEip1271Callback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
101
+ export declare function signOrderWithEip1193(input: raw.OrderInput, chainId: number, owner: string, requestCallback: Eip1193RequestCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
102
+ export declare function signOrderWithEip1271(input: raw.OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
103
+ export declare function signOrderWithTypedDataSigner(input: raw.OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
104
+ export declare function supportedChainIds(): Uint32Array;
105
+ export declare function validateAppDataDoc(doc: raw.AppDataDocInput): WasmEnvelope<raw.ValidationResultDto>;
106
+ export declare function wasmVersion(): string;
107
+ export type { AllowanceParametersInput, AmountsDto, AppDataDocDto, AppDataDocInput, AppDataInfoDto, AppDataObjectDto, ApprovalParametersInput, BuiltSellNativeCurrencyTxDto, CompetitionAuctionDto, CompetitionOrderStatusDto, CompetitionOrderStatusKindDto, ContractCallDto, CostsDto, CowEip1271SignRequest, CowEnvDto, DeploymentAddressesDto, Eip1193Request, EthFlowEventDto, EthflowDataDto, EventLogInput, ExecutedAmountsDto, ExecutedProtocolFeeDto, FeeComponentDto, GeneratedOrderUidDto, InteractionDataDto, LimitTradeParametersInput, NativePriceResponseDto, NetworkFeeDto, OnchainOrderDataDto, OrderClassDto, OrderCreationInput, OrderDataDto, OrderDto, OrderInput, OrderInteractionsDto, OrderKindDto, OrderPostingResultDto, OrderQuoteRequestInput, OrderQuoteResponseDto, OrderStatusDto, OrderTraderParametersInput, OrderBookRuntimeBindingDto, PaginationOptions, PartnerFeeDto, PartnerFeeInput, PartnerFeePolicyDto, PartnerFeePolicyInput, QuoteAmountsAndCostsDto, QuoteDataDto, QuoteResultsDto, SettlementEventDto, SignedCancellationsInput, SignedOrderDto, SigningSchemeDto, SolverCompetitionOrderDto, SolverCompetitionResponseDto, SolverExecutionDto, SolverSettlementDto, StoredOrderQuoteDto, SubgraphQueryInput, SwapParametersInput, TokenBalanceDto, TotalSurplusDto, TradeDto, TradeParametersDto, TradesQueryInput, TradingAppDataInfoDto, TransactionRequestDto, TypedDataDomainDto, TypedDataEnvelopeDto, TypedDataFieldDto, ValidationResultDto } from "./raw/default.js";
108
+ export type { ContractReadCallback, CowEip1271SignCallback, CowEnv, CustomEip1271Callback, DigestSignerCallback, Eip1193RequestCallback, TypedDataSignerCallback } from "./callbacks.js";
109
+ export type { OrderBookRejectionCategory, CowError } from "./errors.js";
110
+ export type { SchemaVersion, WasmEnvelope } from "./envelope.js";
111
+ export type { CowFetchCallback, CowFetchRequest, CowFetchResponse, HttpTransportConfig, IpfsClientConfig, JitterStrategyConfig, LimiterScopeConfig, RequestRateLimiterConfig, RetryPolicyConfig, SdkClientOptions, SigningOptions, SubgraphClientConfig, TradingClientConfig, TransportPolicyConfig, WalletConfig } from "./options.js";
@@ -1,5 +1,24 @@
1
- import * as raw from "./raw/default.js";
1
+ import * as raw from "./raw/default-web.js";
2
2
  import { assertActive, callAsync, callSync, defaultsFrom, disposeRaw, mergeOptions, mergeSigningOptions, translateClientConfig } from "./internal.js";
3
+ let initialized;
4
+ /**
5
+ * Initialize the wasm module, idempotently, once per module instance.
6
+ *
7
+ * On the `web` build — Cloudflare Workers, Deno, Vercel Edge, and no-bundler
8
+ * browsers — the host owns module instantiation, so it must call this once with
9
+ * the compiled module (Workers pass the `CompiledWasm` binding) or its URL/bytes
10
+ * (Deno and browsers). On the `bundler` and `nodejs` builds the host
11
+ * bundler/runtime instantiates the module on import, so this resolves
12
+ * immediately and the argument is ignored — calling it is optional and harmless,
13
+ * which keeps one call shape working across every target.
14
+ */
15
+ export async function initialize(module) {
16
+ if (!initialized) {
17
+ initialized = raw.initializeRaw({ module_or_path: module }).then(() => undefined);
18
+ }
19
+ await initialized;
20
+ }
21
+ export default initialize;
3
22
  export class IpfsClient {
4
23
  #inner;
5
24
  #defaults;
@@ -34,6 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.TradingClient = exports.SubgraphClient = exports.OrderBookClient = exports.IpfsClient = void 0;
37
+ exports.initialize = initialize;
37
38
  exports.appDataDoc = appDataDoc;
38
39
  exports.appDataHexToCid = appDataHexToCid;
39
40
  exports.appDataInfo = appDataInfo;
@@ -60,6 +61,25 @@ exports.validateAppDataDoc = validateAppDataDoc;
60
61
  exports.wasmVersion = wasmVersion;
61
62
  const raw = __importStar(require("./raw/default.cjs"));
62
63
  const internal_js_1 = require("./internal.cjs");
64
+ let initialized;
65
+ /**
66
+ * Initialize the wasm module, idempotently, once per module instance.
67
+ *
68
+ * On the `web` build — Cloudflare Workers, Deno, Vercel Edge, and no-bundler
69
+ * browsers — the host owns module instantiation, so it must call this once with
70
+ * the compiled module (Workers pass the `CompiledWasm` binding) or its URL/bytes
71
+ * (Deno and browsers). On the `bundler` and `nodejs` builds the host
72
+ * bundler/runtime instantiates the module on import, so this resolves
73
+ * immediately and the argument is ignored — calling it is optional and harmless,
74
+ * which keeps one call shape working across every target.
75
+ */
76
+ async function initialize(module) {
77
+ if (!initialized) {
78
+ initialized = raw.initializeRaw({ module_or_path: module }).then(() => undefined);
79
+ }
80
+ await initialized;
81
+ }
82
+ exports.default = initialize;
63
83
  class IpfsClient {
64
84
  #inner;
65
85
  #defaults;
@@ -5,6 +5,20 @@ import type { CommonClientConfig, IpfsClientConfig, SdkClientOptions, SigningOpt
5
5
  import type { ContractReadCallback, CustomEip1271Callback, DigestSignerCallback, Eip1193RequestCallback, TypedDataSignerCallback } from "./callbacks.js";
6
6
  export interface OrderBookClientConfig extends CommonClientConfig {
7
7
  }
8
+ /**
9
+ * Initialize the wasm module, idempotently, once per module instance.
10
+ *
11
+ * On the `web` build — Cloudflare Workers, Deno, Vercel Edge, and no-bundler
12
+ * browsers — the host owns module instantiation, so it must call this once with
13
+ * the compiled module (Workers pass the `CompiledWasm` binding) or its URL/bytes
14
+ * (Deno and browsers). On the `bundler` and `nodejs` builds the host
15
+ * bundler/runtime instantiates the module on import, so this resolves
16
+ * immediately and the argument is ignored — calling it is optional and harmless,
17
+ * which keeps one call shape working across every target.
18
+ */
19
+ export declare function initialize(module?: WebAssembly.Module | raw.InitInput): Promise<void>;
20
+ export default initialize;
21
+ export type { InitInput } from "./raw/default.js";
8
22
  export declare class IpfsClient {
9
23
  #private;
10
24
  constructor(config: IpfsClientConfig);
@@ -0,0 +1,111 @@
1
+ /// <reference lib="esnext.disposable" />
2
+ import * as raw from "./raw/default.js";
3
+ import type { WasmEnvelope } from "./envelope.js";
4
+ import type { CommonClientConfig, IpfsClientConfig, SdkClientOptions, SigningOptions, SubgraphClientConfig, TradingClientConfig } from "./options.js";
5
+ import type { ContractReadCallback, CustomEip1271Callback, DigestSignerCallback, Eip1193RequestCallback, TypedDataSignerCallback } from "./callbacks.js";
6
+ export interface OrderBookClientConfig extends CommonClientConfig {
7
+ }
8
+ /**
9
+ * Initialize the wasm module, idempotently, once per module instance.
10
+ *
11
+ * On the `web` build — Cloudflare Workers, Deno, Vercel Edge, and no-bundler
12
+ * browsers — the host owns module instantiation, so it must call this once with
13
+ * the compiled module (Workers pass the `CompiledWasm` binding) or its URL/bytes
14
+ * (Deno and browsers). On the `bundler` and `nodejs` builds the host
15
+ * bundler/runtime instantiates the module on import, so this resolves
16
+ * immediately and the argument is ignored — calling it is optional and harmless,
17
+ * which keeps one call shape working across every target.
18
+ */
19
+ export declare function initialize(module?: WebAssembly.Module | raw.InitInput): Promise<void>;
20
+ export default initialize;
21
+ export type { InitInput } from "./raw/default.js";
22
+ export declare class IpfsClient {
23
+ #private;
24
+ constructor(config: IpfsClientConfig);
25
+ fetchAppDataFromCid(cid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataDocDto>>;
26
+ fetchAppDataFromHex(appDataHex: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataDocDto>>;
27
+ dispose(): void;
28
+ [Symbol.dispose](): void;
29
+ }
30
+ export declare class OrderBookClient {
31
+ #private;
32
+ constructor(config: OrderBookClientConfig);
33
+ cancelOrders(signed: raw.SignedCancellationsInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<{
34
+ cancelled: true;
35
+ }>>;
36
+ getNativePrice(token: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.NativePriceResponseDto>>;
37
+ getOrder(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto>>;
38
+ getOrders(owner: string, pagination?: raw.PaginationOptions | null, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto[]>>;
39
+ getOrderMultiEnv(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto>>;
40
+ getTxOrders(txHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderDto[]>>;
41
+ getVersion(options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
42
+ getOrderLink(orderUid: string): WasmEnvelope<string>;
43
+ getQuote(request: raw.OrderQuoteRequestInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.OrderQuoteResponseDto>>;
44
+ getTrades(query: raw.TradesQueryInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TradeDto[]>>;
45
+ getOrderCompetitionStatus(orderUid: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.CompetitionOrderStatusDto>>;
46
+ getTotalSurplus(owner: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TotalSurplusDto>>;
47
+ getSolverCompetition(auctionId: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.SolverCompetitionResponseDto>>;
48
+ getSolverCompetitionByTxHash(txHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.SolverCompetitionResponseDto>>;
49
+ getAppData(appDataHash: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.AppDataObjectDto>>;
50
+ uploadAppData(appDataHash: string, fullAppData: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<{
51
+ uploaded: true;
52
+ }>>;
53
+ sendOrder(signed: raw.SignedOrderDto, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
54
+ sendOrderCreation(input: raw.OrderCreationInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
55
+ dispose(): void;
56
+ [Symbol.dispose](): void;
57
+ }
58
+ export declare class SubgraphClient {
59
+ #private;
60
+ constructor(config: SubgraphClientConfig);
61
+ getLastDaysVolume(days: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
62
+ getLastHoursVolume(hours: number, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
63
+ getTotals(options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
64
+ runQuery(request: raw.SubgraphQueryInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<unknown>>;
65
+ dispose(): void;
66
+ [Symbol.dispose](): void;
67
+ }
68
+ export declare class TradingClient {
69
+ #private;
70
+ constructor(config: TradingClientConfig);
71
+ buildSellNativeCurrencyTx(order: raw.OrderInput, quoteId: number, from: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.BuiltSellNativeCurrencyTxDto>>;
72
+ buildSellNativeCurrencyTxFromQuote(quoteResults: raw.QuoteResultsDto, from: string, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.BuiltSellNativeCurrencyTxDto>>;
73
+ getCowProtocolAllowance(params: raw.AllowanceParametersInput, readContractCallback: ContractReadCallback, options?: SdkClientOptions | null): Promise<WasmEnvelope<string>>;
74
+ buildApprovalTx(params: raw.ApprovalParametersInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.TransactionRequestDto>>;
75
+ getQuote(params: raw.SwapParametersInput, options?: SdkClientOptions | null): Promise<WasmEnvelope<raw.QuoteResultsDto>>;
76
+ postLimitOrder(params: raw.LimitTradeParametersInput, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
77
+ postSwapOrder(params: raw.SwapParametersInput, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
78
+ postSwapOrderFromQuote(quoteResults: raw.QuoteResultsDto, owner: string, signerCallback: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
79
+ postSwapOrderWithEip1271(params: raw.SwapParametersInput, owner: string, customCallback: CustomEip1271Callback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.OrderPostingResultDto>>;
80
+ dispose(): void;
81
+ [Symbol.dispose](): void;
82
+ }
83
+ export declare function appDataDoc(doc: raw.AppDataDocInput): WasmEnvelope<raw.AppDataDocDto>;
84
+ export declare function appDataHexToCid(appDataHex: string): WasmEnvelope<string>;
85
+ export declare function appDataInfo(doc: raw.AppDataDocInput): WasmEnvelope<raw.AppDataInfoDto>;
86
+ export declare function buildCancelOrderTx(params: raw.OrderTraderParametersInput): WasmEnvelope<raw.TransactionRequestDto>;
87
+ export declare function buildPresignTx(params: raw.OrderTraderParametersInput): WasmEnvelope<raw.TransactionRequestDto>;
88
+ export declare function cidToAppDataHex(cid: string): WasmEnvelope<string>;
89
+ export declare function computeOrderUid(input: raw.OrderInput, chainId: number, owner: string): WasmEnvelope<raw.GeneratedOrderUidDto>;
90
+ export declare function decodeEthFlowLog(log: raw.EventLogInput): WasmEnvelope<raw.EthFlowEventDto>;
91
+ export declare function decodeSettlementLog(log: raw.EventLogInput): WasmEnvelope<raw.SettlementEventDto>;
92
+ export declare function deploymentAddresses(chainId: number, env?: string | null): WasmEnvelope<raw.DeploymentAddressesDto>;
93
+ export declare function domainSeparator(chainId: number): string;
94
+ export declare function eip1271SignaturePayload(input: raw.OrderInput, ecdsaSignature: string): WasmEnvelope<string>;
95
+ export declare function orderTypedData(input: raw.OrderInput, chainId: number): WasmEnvelope<raw.TypedDataEnvelopeDto>;
96
+ export declare function signCancellationEthSignDigest(orderUids: string[], chainId: number, digestSigner: DigestSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
97
+ export declare function signCancellationWithEip1193(orderUids: string[], chainId: number, owner: string, requestCallback: Eip1193RequestCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
98
+ export declare function signCancellationWithTypedDataSigner(orderUids: string[], chainId: number, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedCancellationsInput>>;
99
+ export declare function signOrderEthSignDigest(input: raw.OrderInput, chainId: number, owner: string, digestSigner: DigestSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
100
+ export declare function signOrderWithCustomEip1271(input: raw.OrderInput, chainId: number, owner: string, customCallback: CustomEip1271Callback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
101
+ export declare function signOrderWithEip1193(input: raw.OrderInput, chainId: number, owner: string, requestCallback: Eip1193RequestCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
102
+ export declare function signOrderWithEip1271(input: raw.OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
103
+ export declare function signOrderWithTypedDataSigner(input: raw.OrderInput, chainId: number, owner: string, typedDataSigner: TypedDataSignerCallback, options?: SigningOptions | null): Promise<WasmEnvelope<raw.SignedOrderDto>>;
104
+ export declare function supportedChainIds(): Uint32Array;
105
+ export declare function validateAppDataDoc(doc: raw.AppDataDocInput): WasmEnvelope<raw.ValidationResultDto>;
106
+ export declare function wasmVersion(): string;
107
+ export type { AllowanceParametersInput, AmountsDto, AppDataDocDto, AppDataDocInput, AppDataInfoDto, AppDataObjectDto, ApprovalParametersInput, BuiltSellNativeCurrencyTxDto, CompetitionAuctionDto, CompetitionOrderStatusDto, CompetitionOrderStatusKindDto, ContractCallDto, CostsDto, CowEip1271SignRequest, CowEnvDto, DeploymentAddressesDto, Eip1193Request, EthFlowEventDto, EthflowDataDto, EventLogInput, ExecutedAmountsDto, ExecutedProtocolFeeDto, FeeComponentDto, GeneratedOrderUidDto, InteractionDataDto, LimitTradeParametersInput, NativePriceResponseDto, NetworkFeeDto, OnchainOrderDataDto, OrderClassDto, OrderCreationInput, OrderDataDto, OrderDto, OrderInput, OrderInteractionsDto, OrderKindDto, OrderPostingResultDto, OrderQuoteRequestInput, OrderQuoteResponseDto, OrderStatusDto, OrderTraderParametersInput, OrderBookRuntimeBindingDto, PaginationOptions, PartnerFeeDto, PartnerFeeInput, PartnerFeePolicyDto, PartnerFeePolicyInput, QuoteAmountsAndCostsDto, QuoteDataDto, QuoteResultsDto, SettlementEventDto, SignedCancellationsInput, SignedOrderDto, SigningSchemeDto, SolverCompetitionOrderDto, SolverCompetitionResponseDto, SolverExecutionDto, SolverSettlementDto, StoredOrderQuoteDto, SubgraphQueryInput, SwapParametersInput, TokenBalanceDto, TotalSurplusDto, TradeDto, TradeParametersDto, TradesQueryInput, TradingAppDataInfoDto, TransactionRequestDto, TypedDataDomainDto, TypedDataEnvelopeDto, TypedDataFieldDto, ValidationResultDto } from "./raw/default.js";
108
+ export type { ContractReadCallback, CowEip1271SignCallback, CowEnv, CustomEip1271Callback, DigestSignerCallback, Eip1193RequestCallback, TypedDataSignerCallback } from "./callbacks.js";
109
+ export type { OrderBookRejectionCategory, CowError } from "./errors.js";
110
+ export type { SchemaVersion, WasmEnvelope } from "./envelope.js";
111
+ export type { CowFetchCallback, CowFetchRequest, CowFetchResponse, HttpTransportConfig, IpfsClientConfig, JitterStrategyConfig, LimiterScopeConfig, RequestRateLimiterConfig, RetryPolicyConfig, SdkClientOptions, SigningOptions, SubgraphClientConfig, TradingClientConfig, TransportPolicyConfig, WalletConfig } from "./options.js";