@proof-labs/trading-sdk 4.0.0

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 (59) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +391 -0
  3. package/dist/client.d.ts +640 -0
  4. package/dist/client.d.ts.map +1 -0
  5. package/dist/client.js +1730 -0
  6. package/dist/client.js.map +1 -0
  7. package/dist/codec-adapter.d.ts +33 -0
  8. package/dist/codec-adapter.d.ts.map +1 -0
  9. package/dist/codec-adapter.js +419 -0
  10. package/dist/codec-adapter.js.map +1 -0
  11. package/dist/codec.d.ts +137 -0
  12. package/dist/codec.d.ts.map +1 -0
  13. package/dist/codec.js +229 -0
  14. package/dist/codec.js.map +1 -0
  15. package/dist/crypto.d.ts +78 -0
  16. package/dist/crypto.d.ts.map +1 -0
  17. package/dist/crypto.js +145 -0
  18. package/dist/crypto.js.map +1 -0
  19. package/dist/errors.d.ts +122 -0
  20. package/dist/errors.d.ts.map +1 -0
  21. package/dist/errors.js +397 -0
  22. package/dist/errors.js.map +1 -0
  23. package/dist/governance-query.d.ts +47 -0
  24. package/dist/governance-query.d.ts.map +1 -0
  25. package/dist/governance-query.js +525 -0
  26. package/dist/governance-query.js.map +1 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +22 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/testing.d.ts +25 -0
  32. package/dist/testing.d.ts.map +1 -0
  33. package/dist/testing.js +22 -0
  34. package/dist/testing.js.map +1 -0
  35. package/dist/trigger-history.d.ts +9 -0
  36. package/dist/trigger-history.d.ts.map +1 -0
  37. package/dist/trigger-history.js +442 -0
  38. package/dist/trigger-history.js.map +1 -0
  39. package/dist/triggers.d.ts +15 -0
  40. package/dist/triggers.d.ts.map +1 -0
  41. package/dist/triggers.js +399 -0
  42. package/dist/triggers.js.map +1 -0
  43. package/dist/tx-result.d.ts +53 -0
  44. package/dist/tx-result.d.ts.map +1 -0
  45. package/dist/tx-result.js +58 -0
  46. package/dist/tx-result.js.map +1 -0
  47. package/dist/types.d.ts +2085 -0
  48. package/dist/types.d.ts.map +1 -0
  49. package/dist/types.js +121 -0
  50. package/dist/types.js.map +1 -0
  51. package/dist/wasm/proof_trading_sdk_wasm.d.ts +98 -0
  52. package/dist/wasm/proof_trading_sdk_wasm.js +698 -0
  53. package/dist/wasm/proof_trading_sdk_wasm_bg.wasm +0 -0
  54. package/dist/wasm/proof_trading_sdk_wasm_bg.wasm.d.ts +19 -0
  55. package/dist/wasm-loader.d.ts +42 -0
  56. package/dist/wasm-loader.d.ts.map +1 -0
  57. package/dist/wasm-loader.js +95 -0
  58. package/dist/wasm-loader.js.map +1 -0
  59. package/package.json +72 -0
@@ -0,0 +1,19 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export const memory: WebAssembly.Memory;
4
+ export const admin_proposal_content_hash: (a: number, b: number, c: bigint, d: bigint, e: number, f: number, g: number, h: bigint, i: bigint, j: bigint, k: any) => [number, number, number, number];
5
+ export const chain_id_from_string: (a: number, b: number) => [number, number];
6
+ export const decode_payload: (a: number, b: number, c: number) => [number, number, number];
7
+ export const encode_payload: (a: number, b: any) => [number, number, number, number];
8
+ export const encode_signed_tx: (a: number, b: number, c: number, d: bigint, e: number, f: number, g: number, h: number) => [number, number, number, number];
9
+ export const pubkey_to_owner: (a: number, b: number) => [number, number, number, number];
10
+ export const sign_and_encode: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number) => [number, number, number, number];
11
+ export const signing_message: (a: number, b: number, c: number, d: bigint, e: number, f: number) => [number, number, number, number];
12
+ export const __wbindgen_malloc: (a: number, b: number) => number;
13
+ export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
14
+ export const __wbindgen_exn_store: (a: number) => void;
15
+ export const __externref_table_alloc: () => number;
16
+ export const __wbindgen_externrefs: WebAssembly.Table;
17
+ export const __externref_table_dealloc: (a: number) => void;
18
+ export const __wbindgen_free: (a: number, b: number, c: number) => void;
19
+ export const __wbindgen_start: () => void;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Lazy loader for the WASM core (`crates/proof-trading-sdk-wasm`, built into
3
+ * `src/wasm/` by `npm run build:wasm`).
4
+ *
5
+ * WASM instantiation is asynchronous — browsers disallow synchronous compile of
6
+ * a module this size on the main thread (see ADR 0001). Call `await ready()`
7
+ * once before any codec/signing call that routes through WASM; after it
8
+ * resolves, `getWasm()` returns the initialized exports synchronously.
9
+ *
10
+ * The generated module and binary use literal relative references on purpose:
11
+ * package consumers such as Vite must be able to discover, copy, and rewrite
12
+ * both assets into their own build. `npm run build:wasm` runs before TypeScript,
13
+ * so those generated files exist whenever this source is compiled.
14
+ */
15
+ /** The subset of the generated WASM bindings the SDK uses. */
16
+ export interface WasmCore {
17
+ /** wasm-bindgen init — accepts the `.wasm` bytes (Node) or fetches by URL
18
+ * (browser), passed as `{ module_or_path }` (the single-object form current
19
+ * wasm-bindgen requires; the bare positional argument is deprecated). */
20
+ default: (options?: {
21
+ module_or_path?: BufferSource | URL;
22
+ }) => Promise<unknown>;
23
+ encode_payload(actionType: number, fields: unknown): Uint8Array;
24
+ decode_payload(actionType: number, payload: Uint8Array): unknown;
25
+ signing_message(chainId: Uint8Array, actionType: number, seq: bigint, payload: Uint8Array): Uint8Array;
26
+ encode_signed_tx(actionType: number, payload: Uint8Array, seq: bigint, pubkey: Uint8Array, signature: Uint8Array): Uint8Array;
27
+ sign_and_encode(chainId: Uint8Array, actionType: number, payload: Uint8Array, seq: bigint, secretKey: Uint8Array): Uint8Array;
28
+ pubkey_to_owner(pubkey: Uint8Array): Uint8Array;
29
+ chain_id_from_string(chainId: string): Uint8Array;
30
+ admin_proposal_content_hash(chainId: Uint8Array, proposalId: bigint, registryVersion: bigint, threshold: number, proposer: Uint8Array, createdHeight: bigint, createdMs: bigint, expiryMs: bigint, action: unknown): Uint8Array;
31
+ }
32
+ /**
33
+ * Initialize the WASM core (idempotent). Resolves once the module is ready;
34
+ * concurrent callers share a single instantiation.
35
+ */
36
+ export declare function ready(): Promise<void>;
37
+ /**
38
+ * The initialized WASM exports. Throws if `ready()` has not completed — this
39
+ * keeps the codec entry points synchronous while making the async init explicit.
40
+ */
41
+ export declare function getWasm(): WasmCore;
42
+ //# sourceMappingURL=wasm-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wasm-loader.d.ts","sourceRoot":"","sources":["../src/wasm-loader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,QAAQ;IACvB;;8EAE0E;IAC1E,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE;QAClB,cAAc,CAAC,EAAE,YAAY,GAAG,GAAG,CAAC;KACrC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACvB,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,GAAG,UAAU,CAAC;IAChE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;IACjE,eAAe,CACb,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,EAClB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,UAAU,GAClB,UAAU,CAAC;IACd,gBAAgB,CACd,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,UAAU,EAClB,SAAS,EAAE,UAAU,GACpB,UAAU,CAAC;IACd,eAAe,CACb,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,UAAU,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,UAAU,GACpB,UAAU,CAAC;IACd,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAAC;IAChD,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,UAAU,CAAC;IAClD,2BAA2B,CACzB,OAAO,EAAE,UAAU,EACnB,UAAU,EAAE,MAAM,EAClB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,UAAU,EACpB,aAAa,EAAE,MAAM,EACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,GACd,UAAU,CAAC;CACf;AA+CD;;;GAGG;AACH,wBAAsB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAgB3C;AAyBD;;;GAGG;AACH,wBAAgB,OAAO,IAAI,QAAQ,CAOlC"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Lazy loader for the WASM core (`crates/proof-trading-sdk-wasm`, built into
3
+ * `src/wasm/` by `npm run build:wasm`).
4
+ *
5
+ * WASM instantiation is asynchronous — browsers disallow synchronous compile of
6
+ * a module this size on the main thread (see ADR 0001). Call `await ready()`
7
+ * once before any codec/signing call that routes through WASM; after it
8
+ * resolves, `getWasm()` returns the initialized exports synchronously.
9
+ *
10
+ * The generated module and binary use literal relative references on purpose:
11
+ * package consumers such as Vite must be able to discover, copy, and rewrite
12
+ * both assets into their own build. `npm run build:wasm` runs before TypeScript,
13
+ * so those generated files exist whenever this source is compiled.
14
+ */
15
+ let cached = null;
16
+ let initPromise = null;
17
+ function isNode() {
18
+ // Read `process` off globalThis so this compiles without `@types/node`
19
+ // (the SDK is browser-first and does not depend on Node typings).
20
+ const g = globalThis;
21
+ return typeof g.process?.versions?.node === "string";
22
+ }
23
+ /**
24
+ * Resolve Node built-ins without placing a statically discoverable `node:*`
25
+ * import in the browser dependency graph. Next/Webpack follows ordinary
26
+ * dynamic-import specifiers even when their branch is runtime-only. Node 22+
27
+ * uses `process.getBuiltinModule`; Node 20 uses a deliberately hidden native
28
+ * dynamic import so existing integration runners remain supported.
29
+ */
30
+ async function nodeBuiltin(name) {
31
+ const process = globalThis.process;
32
+ if (process?.getBuiltinModule) {
33
+ return process.getBuiltinModule(name);
34
+ }
35
+ // `Function` keeps the `node:` specifier out of Webpack's module graph. It
36
+ // runs only in the Node branch; browsers never evaluate it. Do not replace
37
+ // this with `import("node:fs")` without rerunning the Next/Webpack consumer
38
+ // smoke test.
39
+ const nativeImport = Function("specifier", "return import(specifier)");
40
+ return (await nativeImport(`node:${name}`));
41
+ }
42
+ /**
43
+ * Initialize the WASM core (idempotent). Resolves once the module is ready;
44
+ * concurrent callers share a single instantiation.
45
+ */
46
+ export async function ready() {
47
+ if (cached)
48
+ return;
49
+ if (!initPromise) {
50
+ initPromise = instantiate();
51
+ }
52
+ const attempt = initPromise;
53
+ try {
54
+ await attempt;
55
+ }
56
+ catch (e) {
57
+ // A failed init (e.g. a transient fetch error for the .wasm binary in a
58
+ // browser) must not stay cached, or every later call replays the same
59
+ // rejection until page reload. Clear it so the next `ready()` retries —
60
+ // unless a newer attempt is already in flight.
61
+ if (initPromise === attempt)
62
+ initPromise = null;
63
+ throw e;
64
+ }
65
+ }
66
+ async function instantiate() {
67
+ // Keep this import literal: Vite/Rollup must see the generated module in
68
+ // a consuming application's dependency graph.
69
+ const mod = (await import("./wasm/proof_trading_sdk_wasm.js"));
70
+ // Likewise, a literal URL lets the consumer's bundler emit the binary as
71
+ // a hashed asset rather than leaving a broken node_modules-relative URL.
72
+ const wasmUrl = new URL("./wasm/proof_trading_sdk_wasm_bg.wasm", import.meta.url);
73
+ if (isNode()) {
74
+ const fs = await nodeBuiltin("fs");
75
+ const url = await nodeBuiltin("url");
76
+ const path = url.fileURLToPath(wasmUrl);
77
+ await mod.default({ module_or_path: fs.readFileSync(path) });
78
+ }
79
+ else {
80
+ await mod.default({ module_or_path: wasmUrl });
81
+ }
82
+ cached = mod;
83
+ return mod;
84
+ }
85
+ /**
86
+ * The initialized WASM exports. Throws if `ready()` has not completed — this
87
+ * keeps the codec entry points synchronous while making the async init explicit.
88
+ */
89
+ export function getWasm() {
90
+ if (!cached) {
91
+ throw new Error("WASM core not initialized — call `await ready()` before encoding/signing");
92
+ }
93
+ return cached;
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,CAAC;QAChD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,yEAAyE;IACzE,8CAA8C;IAC9C,MAAM,GAAG,GACP,CAAC,MAAM,MAAM,CAAC,kCAAkC,CAAC,CAAwB,CAAC;IAC5E,yEAAyE;IACzE,yEAAyE;IACzE,MAAM,OAAO,GAAG,IAAI,GAAG,CACrB,uCAAuC,EACvC,MAAM,CAAC,IAAI,CAAC,GAAG,CAChB,CAAC;IACF,IAAI,MAAM,EAAE,EAAE,CAAC;QACb,MAAM,EAAE,GAAG,MAAM,WAAW,CAAS,IAAI,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,MAAM,WAAW,CAAU,KAAK,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACxC,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,OAAO,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,CAAC,CAAC;IACjD,CAAC;IACD,MAAM,GAAG,GAAG,CAAC;IACb,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO;IACrB,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CACb,0EAA0E,CAC3E,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@proof-labs/trading-sdk",
3
+ "version": "4.0.0",
4
+ "description": "TypeScript SDK for Proof Exchange — signing, encoding, querying, and submitting actions.",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Proof-labs/trading-sdk.git"
9
+ },
10
+ "homepage": "https://github.com/Proof-labs/trading-sdk#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/Proof-labs/trading-sdk/issues"
13
+ },
14
+ "keywords": [
15
+ "proof",
16
+ "exchange",
17
+ "trading",
18
+ "sdk",
19
+ "ed25519",
20
+ "messagepack"
21
+ ],
22
+ "type": "module",
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "main": "dist/index.js",
27
+ "types": "dist/index.d.ts",
28
+ "files": [
29
+ "dist",
30
+ "LICENSE",
31
+ "README.md"
32
+ ],
33
+ "publishConfig": {
34
+ "access": "public"
35
+ },
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js",
40
+ "default": "./dist/index.js"
41
+ },
42
+ "./testing": {
43
+ "types": "./dist/testing.d.ts",
44
+ "import": "./dist/testing.js",
45
+ "default": "./dist/testing.js"
46
+ }
47
+ },
48
+ "scripts": {
49
+ "build": "npm run build:wasm && tsc && npm run copy:wasm",
50
+ "build:wasm": "cargo build -p proof-trading-sdk-wasm --target wasm32-unknown-unknown --release && wasm-bindgen --target web --out-dir src/wasm target/wasm32-unknown-unknown/release/proof_trading_sdk_wasm.wasm",
51
+ "copy:wasm": "node -e \"require('node:fs').cpSync('src/wasm','dist/wasm',{recursive:true})\"",
52
+ "prepare": "npm run build",
53
+ "prepublishOnly": "npm run build",
54
+ "pretest": "npm run build:wasm",
55
+ "test": "vitest run",
56
+ "smoke:browser:prepare": "node scripts/prepare-browser-smoke.mjs .browser-smoke",
57
+ "smoke:browser": "node scripts/browser-smoke.mjs .browser-smoke",
58
+ "example": "npx tsx examples/connect-and-trade.ts"
59
+ },
60
+ "dependencies": {
61
+ "@msgpack/msgpack": "^3.0.0-beta.3",
62
+ "@noble/ed25519": "^3.1.0",
63
+ "@noble/hashes": "^2.2.0"
64
+ },
65
+ "devDependencies": {
66
+ "playwright": "1.61.1",
67
+ "prettier": "^3.9.4",
68
+ "typescript": "^6.0.0",
69
+ "vite": "8.1.5",
70
+ "vitest": "^4.1.0"
71
+ }
72
+ }