@depthhq/maker-sdk 0.0.0-stage → 0.1.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.
package/dist/node.d.ts ADDED
@@ -0,0 +1 @@
1
+ export { FillCursorStore } from "./fill/cursor.js";
package/dist/node.js ADDED
@@ -0,0 +1,47 @@
1
+ // src/fill/cursor.ts
2
+ import { randomBytes } from "node:crypto";
3
+ import { mkdir, readFile, rename, writeFile } from "node:fs/promises";
4
+ import { homedir } from "node:os";
5
+ import { dirname, join } from "node:path";
6
+
7
+ class FillCursorStore {
8
+ genesis;
9
+ maker;
10
+ path;
11
+ constructor(genesis, maker, directory) {
12
+ this.genesis = genesis;
13
+ this.maker = maker;
14
+ if (!/^[1-9A-HJ-NP-Za-km-z]+$/.test(genesis) || !/^[1-9A-HJ-NP-Za-km-z]+$/.test(maker))
15
+ throw new RangeError("Fill cursor identity is invalid");
16
+ this.path = join(directory ?? process.env.XDG_STATE_HOME ?? join(homedir(), ".local", "state"), "depth", "fills", `${genesis}-${maker}.json`);
17
+ }
18
+ async load() {
19
+ let contents;
20
+ try {
21
+ contents = await readFile(this.path, "utf8");
22
+ } catch (error) {
23
+ if (error.code === "ENOENT")
24
+ return;
25
+ throw error;
26
+ }
27
+ const saved = JSON.parse(contents);
28
+ if (saved.genesis !== this.genesis || saved.maker !== this.maker || typeof saved.cursor !== "string" || !saved.cursor)
29
+ throw new Error("Fill cursor file does not match this maker and network");
30
+ return saved.cursor;
31
+ }
32
+ async save(cursor) {
33
+ if (!/^[1-9A-HJ-NP-Za-km-z]+$/.test(cursor))
34
+ throw new RangeError("Fill cursor signature is invalid");
35
+ await mkdir(dirname(this.path), { recursive: true, mode: 448 });
36
+ const temporary = `${this.path}.${process.pid}.${randomBytes(8).toString("hex")}`;
37
+ await writeFile(temporary, JSON.stringify({
38
+ genesis: this.genesis,
39
+ maker: this.maker,
40
+ cursor
41
+ }), { mode: 384 });
42
+ await rename(temporary, this.path);
43
+ }
44
+ }
45
+ export {
46
+ FillCursorStore
47
+ };
@@ -0,0 +1,36 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import type { MakerClient } from "../client/client.js";
3
+ export type QuoteSnapshot = {
4
+ id: string;
5
+ status: string;
6
+ maxCapacity: bigint;
7
+ attachedOrders: number;
8
+ replacementNonce?: bigint;
9
+ };
10
+ export declare class QuoteHandle {
11
+ readonly id: PublicKey;
12
+ readonly prepareSignature: string | undefined;
13
+ private readonly client;
14
+ reserveSignature?: string;
15
+ releaseSignature?: string;
16
+ private balanceView?;
17
+ constructor(id: PublicKey, prepareSignature: string | undefined, client: MakerClient);
18
+ status(): Promise<QuoteSnapshot>;
19
+ capacity(): Promise<bigint>;
20
+ confirm(options?: {
21
+ timeoutMs?: number;
22
+ pollMs?: number;
23
+ }): Promise<{
24
+ quoteId: PublicKey;
25
+ snapshot: QuoteSnapshot;
26
+ }>;
27
+ wait(options: {
28
+ timeoutMs: number;
29
+ pollMs?: number;
30
+ }): Promise<QuoteSnapshot>;
31
+ activate(options: {
32
+ timeoutMs: number;
33
+ pollMs?: number;
34
+ }): Promise<QuoteSnapshot>;
35
+ cancel(): Promise<QuoteSnapshot>;
36
+ }
@@ -0,0 +1,22 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import type { MakerClient } from "../client/client.js";
3
+ import type { QuoteRequest } from "../client/types.js";
4
+ import type { QuoteHandle, QuoteSnapshot } from "./quote.js";
5
+ export type ReplacementSnapshot = {
6
+ prior: QuoteSnapshot;
7
+ next?: QuoteSnapshot;
8
+ nextId: PublicKey;
9
+ phase: "stopping" | "ready" | "publishing" | "active" | "failed";
10
+ };
11
+ export declare class QuoteReplacement {
12
+ readonly client: MakerClient;
13
+ readonly priorId: PublicKey;
14
+ readonly nonce: bigint;
15
+ readonly nextId: PublicKey;
16
+ constructor(client: MakerClient, priorId: PublicKey, nonce: bigint);
17
+ status(): Promise<ReplacementSnapshot>;
18
+ resume(input: QuoteRequest, options?: {
19
+ timeoutMs?: number;
20
+ pollMs?: number;
21
+ }): Promise<QuoteHandle>;
22
+ }
package/package.json CHANGED
@@ -1,6 +1,38 @@
1
1
  {
2
2
  "name": "@depthhq/maker-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "type": "module",
11
+ "main": "./dist/index.node.js",
12
+ "browser": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "browser": "./dist/index.js",
18
+ "default": "./dist/index.node.js"
19
+ },
20
+ "./node": {
21
+ "types": "./dist/node.d.ts",
22
+ "default": "./dist/node.js"
23
+ }
24
+ },
25
+ "dependencies": {
26
+ "@anchor-lang/core": "1.0.2",
27
+ "@arcium-hq/client": "0.13.2",
28
+ "@depthhq/bindings": "0.1.0",
29
+ "@depthhq/sdk": "0.1.0",
30
+ "@solana/web3.js": "1.99.0",
31
+ "buffer": "6.0.3"
32
+ },
33
+ "scripts": {
34
+ "build": "node ../../scripts/build-package.mjs maker-sdk",
35
+ "typecheck": "tsc --noEmit",
36
+ "test": "bun test"
37
+ }
6
38
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.