@parchment-trade/sdk 0.0.0-stage → 1.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.
- package/LICENSE +202 -0
- package/README.md +192 -2
- package/REFERENCE.md +338 -0
- package/SECURITY.md +23 -0
- package/dist/general/providers/index.d.ts +2 -0
- package/dist/general/providers/index.js +2 -0
- package/dist/general/providers/parchment.d.ts +1 -0
- package/dist/general/providers/parchment.js +1 -0
- package/dist/general/providers/parchmentSdk.d.ts +23 -0
- package/dist/general/providers/parchmentSdk.js +11 -0
- package/dist/general/types/configTypes.d.ts +62 -0
- package/dist/general/types/configTypes.js +1 -0
- package/dist/general/types/index.d.ts +1 -0
- package/dist/general/types/index.js +1 -0
- package/dist/general/utils/address.d.ts +49 -0
- package/dist/general/utils/address.js +110 -0
- package/dist/general/utils/caller.d.ts +58 -0
- package/dist/general/utils/caller.js +182 -0
- package/dist/general/utils/errors.d.ts +16 -0
- package/dist/general/utils/errors.js +26 -0
- package/dist/general/utils/index.d.ts +4 -0
- package/dist/general/utils/index.js +4 -0
- package/dist/general/utils/jsBigInt.d.ts +26 -0
- package/dist/general/utils/jsBigInt.js +74 -0
- package/dist/general/utils/txShape.d.ts +8 -0
- package/dist/general/utils/txShape.js +39 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/packages/index.d.ts +11 -0
- package/dist/packages/index.js +5 -0
- package/dist/packages/parchment/abortCodes.d.ts +196 -0
- package/dist/packages/parchment/abortCodes.js +522 -0
- package/dist/packages/parchment/batchClose.d.ts +268 -0
- package/dist/packages/parchment/batchClose.js +524 -0
- package/dist/packages/parchment/eventGuard.d.ts +106 -0
- package/dist/packages/parchment/eventGuard.js +119 -0
- package/dist/packages/parchment/gameCounterEvents.d.ts +59 -0
- package/dist/packages/parchment/gameCounterEvents.js +56 -0
- package/dist/packages/parchment/index.d.ts +52 -0
- package/dist/packages/parchment/index.js +30 -0
- package/dist/packages/parchment/liquidationCredit.d.ts +28 -0
- package/dist/packages/parchment/liquidationCredit.js +25 -0
- package/dist/packages/parchment/lockedMintEvents.d.ts +42 -0
- package/dist/packages/parchment/lockedMintEvents.js +46 -0
- package/dist/packages/parchment/monitoring.d.ts +369 -0
- package/dist/packages/parchment/monitoring.js +259 -0
- package/dist/packages/parchment/notes.d.ts +6 -0
- package/dist/packages/parchment/notes.js +1 -0
- package/dist/packages/parchment/onboarding.d.ts +50 -0
- package/dist/packages/parchment/onboarding.js +48 -0
- package/dist/packages/parchment/orderEffects.d.ts +207 -0
- package/dist/packages/parchment/orderEffects.js +268 -0
- package/dist/packages/parchment/orderParams.d.ts +72 -0
- package/dist/packages/parchment/orderParams.js +71 -0
- package/dist/packages/parchment/packageIds.d.ts +53 -0
- package/dist/packages/parchment/packageIds.js +149 -0
- package/dist/packages/parchment/parchment.d.ts +442 -0
- package/dist/packages/parchment/parchment.js +975 -0
- package/dist/packages/parchment/parchmentAccount.d.ts +189 -0
- package/dist/packages/parchment/parchmentAccount.js +273 -0
- package/dist/packages/parchment/parchmentMarket.d.ts +58 -0
- package/dist/packages/parchment/parchmentMarket.js +86 -0
- package/dist/packages/parchment/parchmentTypes.d.ts +2031 -0
- package/dist/packages/parchment/parchmentTypes.js +65 -0
- package/dist/packages/parchment/publicInts.d.ts +45 -0
- package/dist/packages/parchment/publicInts.js +383 -0
- package/dist/packages/parchment/reconcileEvents.d.ts +24 -0
- package/dist/packages/parchment/reconcileEvents.js +30 -0
- package/dist/packages/parchment/retainedFee.d.ts +43 -0
- package/dist/packages/parchment/retainedFee.js +68 -0
- package/dist/packages/parchment/sessionClose.d.ts +68 -0
- package/dist/packages/parchment/sessionClose.js +50 -0
- package/dist/packages/parchment/sessionKey.d.ts +78 -0
- package/dist/packages/parchment/sessionKey.js +154 -0
- package/dist/packages/parchment/slippage.d.ts +23 -0
- package/dist/packages/parchment/slippage.js +27 -0
- package/dist/packages/parchment/sponsor.d.ts +39 -0
- package/dist/packages/parchment/sponsor.js +48 -0
- package/dist/packages/parchment/stakingCalls.d.ts +33 -0
- package/dist/packages/parchment/stakingCalls.js +21 -0
- package/dist/packages/parchment/stakingEvents.d.ts +53 -0
- package/dist/packages/parchment/stakingEvents.js +71 -0
- package/dist/packages/parchment/triggerCalls.d.ts +46 -0
- package/dist/packages/parchment/triggerCalls.js +36 -0
- package/dist/packages/parchment/triggerEvents.d.ts +22 -0
- package/dist/packages/parchment/triggerEvents.js +33 -0
- package/dist/packages/parchment/triggers.d.ts +113 -0
- package/dist/packages/parchment/triggers.js +183 -0
- package/dist/packages/parchment/txBodies.d.ts +111 -0
- package/dist/packages/parchment/txBodies.js +683 -0
- package/dist/packages/parchment/txIntent.d.ts +99 -0
- package/dist/packages/parchment/txIntent.js +611 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -0
- package/package.json +55 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** `0x` plus 64 lowercase hex characters; else `bad_request`, the service's and the legacy API's code. */
|
|
2
|
+
export declare function normalizeAddress(value: string): string;
|
|
3
|
+
/**
|
|
4
|
+
* A caller's base-unit integer (digits or a bigint) as its decimal text; bodies send it as the API's
|
|
5
|
+
* `"123n"` literal (`toJsBigInt`). A malformed value throws `code` (transaction bodies pass the service's
|
|
6
|
+
* `bad_amount` / `bad_price_bound`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function baseUnit(value: string | bigint, field: string, code?: string): string;
|
|
9
|
+
export declare const U64_MAX: bigint;
|
|
10
|
+
/**
|
|
11
|
+
* {@link baseUnit} that also fits a Move u64, else `overflowCode` with no request; a malformed value
|
|
12
|
+
* throws the same code. Transaction bodies pass the service's `u64_of` code `bad_amount`;
|
|
13
|
+
* previews keep `invalid_amount`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function u64Unit(value: string | bigint, field: string, overflowCode?: string): string;
|
|
16
|
+
/** {@link baseUnit} that fits a Move u128 (price bounds); malformed or overflow is the service's `price_bound_of` code `bad_price_bound`. */
|
|
17
|
+
export declare function u128Unit(value: string | bigint, field: string): string;
|
|
18
|
+
export declare function signedUpdateBase64(update: string | Uint8Array): string;
|
|
19
|
+
export declare function coinDigest(value: string): string;
|
|
20
|
+
export declare function compact(body: Record<string, unknown>): Record<string, unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Decimal id cursor (positions, claims, leaderboard offset); null or blank is omitted, like the legacy API's `numeric_cursor`.
|
|
23
|
+
* `max` is the largest value the service parses for this cursor (leaderboard offset: u64); a
|
|
24
|
+
* larger one is a local error with no request: `code` (default `bad_request`; the leaderboard uses the service's `bad_cursor`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function idCursor(value: string | number | bigint | null | undefined, field: string, max?: bigint, code?: string): string | undefined;
|
|
27
|
+
export declare const I64_MAX: bigint;
|
|
28
|
+
/**
|
|
29
|
+
* Millisecond query bound the service parses as i64 (price history `fromMs`/`toMs`, the service's `opt_i64`, which is
|
|
30
|
+
* Rust's `str::parse::<i64>`): an optional `+`/`-` sign and ASCII digits within i64. Anything else
|
|
31
|
+
* (blank, padded, decimal, hex, out of range) is a local `bad_request`, the service's code (a
|
|
32
|
+
* non-digit was `invalid_amount`). A negative or `+`-signed value parses at the service, so it is sent unchanged.
|
|
33
|
+
*/
|
|
34
|
+
/**
|
|
35
|
+
* History `cursor`: the service's `opt_i64` (`str::parse::<i64>`), so a negative or `+`-signed value is sent
|
|
36
|
+
* unchanged and anything else (padded, decimal, hex, out of i64 range) is a local `bad_request`. Null or
|
|
37
|
+
* a blank string is omitted (the SDK never sends an empty cursor). Formerly `idCursor` (digits only, trimmed).
|
|
38
|
+
*/
|
|
39
|
+
export declare function historyCursor(value: string | number | bigint | null | undefined): string | undefined;
|
|
40
|
+
export declare function i64Ms(value: string | bigint, field: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Page-size query value. The service answers a malformed `limit` (non-numeric, negative, zero,
|
|
43
|
+
* decimal, hex; a fractional or unsafe number too) with 400 `bad_request`, so that is thrown here with
|
|
44
|
+
* no request (was `invalid_amount`). Any all-digit value above zero is sent and the service
|
|
45
|
+
* clamps it to its `max-page-limit` (default 200), u64 overflow included; a blank string is omitted.
|
|
46
|
+
*/
|
|
47
|
+
export declare function limitParam(value: string | number | bigint | undefined): string | undefined;
|
|
48
|
+
/** A `GET accounts/{owner}/equity` range: exactly `24h`, `7d`, `30d` or `all`, else `bad_request`. */
|
|
49
|
+
export declare function equityRange(value: unknown): "24h" | "7d" | "30d" | "all";
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { toBase64 } from "@mysten/sui/utils";
|
|
2
|
+
import { ParchmentApiError } from "./errors.js";
|
|
3
|
+
export function normalizeAddress(value) {
|
|
4
|
+
const hex = value.trim().toLowerCase().replace(/^0x/, "");
|
|
5
|
+
if (!/^[0-9a-f]{1,64}$/.test(hex)) {
|
|
6
|
+
throw new ParchmentApiError(0, "bad_request", `not an address: ${value}`);
|
|
7
|
+
}
|
|
8
|
+
return `0x${hex.padStart(64, "0")}`;
|
|
9
|
+
}
|
|
10
|
+
export function baseUnit(value, field, code = "invalid_amount") {
|
|
11
|
+
const text = typeof value === "bigint" ? value.toString() : typeof value === "string" ? value.trim() : "";
|
|
12
|
+
if (text.length === 0 || text.length > 78 || !/^[0-9]+$/.test(text)) {
|
|
13
|
+
throw new ParchmentApiError(0, code, `${field} must be a base-unit integer`);
|
|
14
|
+
}
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
17
|
+
export const U64_MAX = (1n << 64n) - 1n;
|
|
18
|
+
const U128_MAX = (1n << 128n) - 1n;
|
|
19
|
+
export function u64Unit(value, field, overflowCode = "invalid_amount") {
|
|
20
|
+
const text = baseUnit(value, field, overflowCode);
|
|
21
|
+
if (BigInt(text) > U64_MAX) {
|
|
22
|
+
throw new ParchmentApiError(0, overflowCode, `${field} must fit in a u64`);
|
|
23
|
+
}
|
|
24
|
+
return text;
|
|
25
|
+
}
|
|
26
|
+
export function u128Unit(value, field) {
|
|
27
|
+
const text = baseUnit(value, field, "bad_price_bound");
|
|
28
|
+
if (BigInt(text) > U128_MAX) {
|
|
29
|
+
throw new ParchmentApiError(0, "bad_price_bound", `${field} must fit in a u128`);
|
|
30
|
+
}
|
|
31
|
+
return text;
|
|
32
|
+
}
|
|
33
|
+
export function signedUpdateBase64(update) {
|
|
34
|
+
if (typeof update !== "string") {
|
|
35
|
+
if (update.byteLength === 0) {
|
|
36
|
+
throw new ParchmentApiError(0, "update_required", "signed Lazer update is empty");
|
|
37
|
+
}
|
|
38
|
+
return toBase64(update);
|
|
39
|
+
}
|
|
40
|
+
const standard = update.replace(/\s/g, "").replace(/-/g, "+").replace(/_/g, "/");
|
|
41
|
+
if (standard.length === 0 || !/^[A-Za-z0-9+/]+={0,2}$/.test(standard)) {
|
|
42
|
+
throw new ParchmentApiError(0, "update_required", "signed Lazer update must be base64");
|
|
43
|
+
}
|
|
44
|
+
if (Math.floor((standard.replace(/=+$/, "").length * 6) / 8) === 0) {
|
|
45
|
+
throw new ParchmentApiError(0, "update_required", "signed Lazer update is empty");
|
|
46
|
+
}
|
|
47
|
+
return standard;
|
|
48
|
+
}
|
|
49
|
+
export function coinDigest(value) {
|
|
50
|
+
if (value.length === 0 || value.length > 128 || !/^[0-9A-Za-z]+$/.test(value)) {
|
|
51
|
+
throw new ParchmentApiError(0, "bad_request", "coin.digest must be a base58 digest");
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
export function compact(body) {
|
|
56
|
+
const out = {};
|
|
57
|
+
for (const [key, value] of Object.entries(body)) {
|
|
58
|
+
if (value !== undefined)
|
|
59
|
+
out[key] = value;
|
|
60
|
+
}
|
|
61
|
+
return out;
|
|
62
|
+
}
|
|
63
|
+
export function idCursor(value, field, max, code = "bad_request") {
|
|
64
|
+
if (value === undefined || value === null || (typeof value === "string" && value.trim() === ""))
|
|
65
|
+
return undefined;
|
|
66
|
+
const cursor = typeof value === "string" ? value.trim()
|
|
67
|
+
: typeof value === "bigint" || (typeof value === "number" && Number.isSafeInteger(value)) ? value.toString() : "";
|
|
68
|
+
if (!/^[0-9]{1,40}$/.test(cursor))
|
|
69
|
+
throw new ParchmentApiError(0, code, `${field} must be a decimal id`);
|
|
70
|
+
if (max !== undefined && BigInt(cursor) > max)
|
|
71
|
+
throw new ParchmentApiError(0, code, `${field} must be <= ${max}`);
|
|
72
|
+
return cursor;
|
|
73
|
+
}
|
|
74
|
+
export const I64_MAX = (1n << 63n) - 1n;
|
|
75
|
+
export function historyCursor(value) {
|
|
76
|
+
if (value === undefined || value === null || (typeof value === "string" && value.trim() === ""))
|
|
77
|
+
return undefined;
|
|
78
|
+
if (typeof value === "number" && !Number.isSafeInteger(value)) {
|
|
79
|
+
throw new ParchmentApiError(0, "bad_request", "cursor is not an integer");
|
|
80
|
+
}
|
|
81
|
+
return i64Ms(typeof value === "number" ? BigInt(value) : value, "cursor");
|
|
82
|
+
}
|
|
83
|
+
export function i64Ms(value, field) {
|
|
84
|
+
const bad = () => new ParchmentApiError(0, "bad_request", `${field} is not an integer`);
|
|
85
|
+
const text = typeof value === "bigint" ? value.toString() : value;
|
|
86
|
+
if (typeof text !== "string" || !/^[+-]?[0-9]+$/.test(text))
|
|
87
|
+
throw bad();
|
|
88
|
+
const n = BigInt(text);
|
|
89
|
+
if (n > I64_MAX || n < -I64_MAX - 1n)
|
|
90
|
+
throw bad();
|
|
91
|
+
return text;
|
|
92
|
+
}
|
|
93
|
+
export function limitParam(value) {
|
|
94
|
+
if (value === undefined)
|
|
95
|
+
return undefined;
|
|
96
|
+
const bad = () => new ParchmentApiError(0, "bad_request", "limit must be a positive integer");
|
|
97
|
+
if (typeof value === "number" && !Number.isSafeInteger(value))
|
|
98
|
+
throw bad();
|
|
99
|
+
const text = (typeof value === "string" ? value : value.toString()).trim();
|
|
100
|
+
if (text === "")
|
|
101
|
+
return undefined;
|
|
102
|
+
if (!/^[0-9]+$/.test(text) || BigInt(text) === 0n)
|
|
103
|
+
throw bad();
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
106
|
+
export function equityRange(value) {
|
|
107
|
+
if (value === "24h" || value === "7d" || value === "30d" || value === "all")
|
|
108
|
+
return value;
|
|
109
|
+
throw new ParchmentApiError(0, "bad_request", "range must be 24h, 7d, 30d, or all");
|
|
110
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { ParchmentBuiltTx } from "../../packages/parchment/parchmentTypes.js";
|
|
2
|
+
import type { CallerConfig } from "../types/configTypes.js";
|
|
3
|
+
import { type IntPaths } from "./jsBigInt.js";
|
|
4
|
+
/**
|
|
5
|
+
* Shared HTTP transport for Parchment API clients.
|
|
6
|
+
*
|
|
7
|
+
* A missing body is a GET. A body is a POST of JSON. Every integer in that JSON,
|
|
8
|
+
* request and response, is a `"123n"` literal (bigint-serde `js_bigint`); a read names
|
|
9
|
+
* where its response has integers ({@link IntPaths}) and gets them as bigints.
|
|
10
|
+
* Successful responses use a `data` field, which this caller returns. Transaction builders return kind bytes in
|
|
11
|
+
* `txBytesBase64`; {@link fetchApiTxObject} turns those into a `Transaction`
|
|
12
|
+
* and sets the sender.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Caller {
|
|
15
|
+
readonly config: CallerConfig;
|
|
16
|
+
protected readonly apiBaseUrl: string | undefined;
|
|
17
|
+
protected readonly apiEndpoint: string;
|
|
18
|
+
private readonly apiUrlPrefix;
|
|
19
|
+
/**
|
|
20
|
+
* @param config - API origin and optional path segment.
|
|
21
|
+
* @param apiUrlPrefix - Package path inserted after the API segment. Parchment uses `"parchment"`.
|
|
22
|
+
*/
|
|
23
|
+
constructor(config?: CallerConfig, apiUrlPrefix?: string);
|
|
24
|
+
protected urlForApiCall(url: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Sends a request and returns the `data` payload, its integers decoded to bigints.
|
|
27
|
+
*
|
|
28
|
+
* @param url - Path relative to `/api/parchment`, unless `apiEndpoint` was changed.
|
|
29
|
+
* @param ints - Where `data` has integers; a malformed one is `bad_body`.
|
|
30
|
+
* @param body - JSON body. Omit it for a GET.
|
|
31
|
+
* @param signal - Optional cancellation signal.
|
|
32
|
+
*/
|
|
33
|
+
protected fetchApi<Output, BodyType = undefined>(url: string, ints: IntPaths, body?: BodyType, signal?: AbortSignal): Promise<Output>;
|
|
34
|
+
/** `fetchApi` for a `{ [key]: value }` payload: a null or missing value is `bad_body`, not a TypeError. */
|
|
35
|
+
protected fetchApiField<Output, Key extends string>(url: string, key: Key, ints: IntPaths, signal?: AbortSignal): Promise<Output>;
|
|
36
|
+
/**
|
|
37
|
+
* Posts a transaction builder and returns the parsed kind with its sender set. The API is trusted
|
|
38
|
+
* for what it builds; with `config.txTrust` set to pinned packages (opt-in strict mode) the kind is
|
|
39
|
+
* also checked against the request (`intent_mismatch`). The bytes do not include gas. A kind with a command the service never builds (a framework call
|
|
40
|
+
* other than `coin::zero`, a transfer to anyone but the sender, a split of the gas coin, a merge,
|
|
41
|
+
* a vector, a publish or an upgrade) is `bad_tx`.
|
|
42
|
+
*/
|
|
43
|
+
protected fetchApiTxObject(url: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<ParchmentBuiltTx>;
|
|
44
|
+
/**
|
|
45
|
+
* Appends `staking::sync_locked` for `owner` to a built release / exit (the `syncLocked` option).
|
|
46
|
+
* The API does not build it; the pool, exchange, token package and collateral type come from
|
|
47
|
+
* `/config`. `txBytesBase64` stays the API's kind, without the appended call. Under strict
|
|
48
|
+
* `txTrust` the token package must be pinned and `/config` must name a pinned one.
|
|
49
|
+
*/
|
|
50
|
+
protected appendSyncLocked(built: ParchmentBuiltTx, owner: string, signal?: AbortSignal): Promise<ParchmentBuiltTx>;
|
|
51
|
+
private fetchImpl;
|
|
52
|
+
private readData;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Validates the opt-in request timeout. `undefined` means no timeout (the default). Node fires a
|
|
56
|
+
* delay above 2^31-1 ms after 1 ms, so a larger value is clamped (about 24.8 days).
|
|
57
|
+
*/
|
|
58
|
+
export declare function requestTimeoutMs(timeoutMs: number | undefined): number | undefined;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { normalizeSuiAddress } from "@mysten/sui/utils";
|
|
3
|
+
import { PUBLIC_INTS } from "../../packages/parchment/publicInts.js";
|
|
4
|
+
import { addSyncLockedCall } from "../../packages/parchment/stakingCalls.js";
|
|
5
|
+
import { ParchmentApiError, retryAfterMs } from "./errors.js";
|
|
6
|
+
import { decodeJsBigInts } from "./jsBigInt.js";
|
|
7
|
+
import { serviceTxViolation } from "./txShape.js";
|
|
8
|
+
import { UNCHECKED_TX, assertTxIntent, txRoute, untrustedConfigPackages } from "../../packages/parchment/txIntent.js";
|
|
9
|
+
export class Caller {
|
|
10
|
+
config;
|
|
11
|
+
apiBaseUrl;
|
|
12
|
+
apiEndpoint;
|
|
13
|
+
apiUrlPrefix;
|
|
14
|
+
constructor(config = {}, apiUrlPrefix = "") {
|
|
15
|
+
this.config = config;
|
|
16
|
+
this.apiUrlPrefix = apiUrlPrefix;
|
|
17
|
+
this.apiBaseUrl = config.baseUrl?.trim().replace(/\/+$/, "") || undefined;
|
|
18
|
+
this.apiEndpoint = config.apiEndpoint?.replace(/^\/+|\/+$/g, "") || "api";
|
|
19
|
+
}
|
|
20
|
+
urlForApiCall(url) {
|
|
21
|
+
if (!this.apiBaseUrl) {
|
|
22
|
+
throw new ParchmentApiError(0, "base_url_required", "baseUrl is required");
|
|
23
|
+
}
|
|
24
|
+
const queryAt = url.indexOf("?");
|
|
25
|
+
const pathPart = queryAt === -1 ? url : url.slice(0, queryAt);
|
|
26
|
+
const query = queryAt === -1 ? "" : url.slice(queryAt);
|
|
27
|
+
const path = [this.apiEndpoint, this.apiUrlPrefix, pathPart]
|
|
28
|
+
.map((segment) => segment.replace(/^\/+|\/+$/g, ""))
|
|
29
|
+
.filter(Boolean)
|
|
30
|
+
.join("/");
|
|
31
|
+
return `${this.apiBaseUrl}/${path}${query}`;
|
|
32
|
+
}
|
|
33
|
+
async fetchApi(url, ints, body, signal) {
|
|
34
|
+
const hasBody = body !== undefined;
|
|
35
|
+
const fullUrl = this.urlForApiCall(url);
|
|
36
|
+
const timeoutMs = requestTimeoutMs(this.config.timeoutMs);
|
|
37
|
+
const callerSignals = [this.config.signal, signal].filter((s) => s != null);
|
|
38
|
+
for (const s of callerSignals)
|
|
39
|
+
s.throwIfAborted();
|
|
40
|
+
const timeout = timeoutMs === undefined ? undefined : new AbortController();
|
|
41
|
+
const timer = timeout && setTimeout(() => timeout.abort(), timeoutMs);
|
|
42
|
+
const signals = timeout ? [...callerSignals, timeout.signal] : callerSignals;
|
|
43
|
+
const stop = signals.length === 0 ? undefined : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
44
|
+
const timedOut = () => new ParchmentApiError(0, "timeout", `request timed out after ${timeoutMs} ms`);
|
|
45
|
+
try {
|
|
46
|
+
let response;
|
|
47
|
+
try {
|
|
48
|
+
response = await this.fetchImpl()(fullUrl, {
|
|
49
|
+
method: hasBody ? "POST" : "GET",
|
|
50
|
+
headers: hasBody
|
|
51
|
+
? { "content-type": "application/json", accept: "application/json" }
|
|
52
|
+
: { accept: "application/json" },
|
|
53
|
+
body: hasBody ? JSON.stringify(body) : undefined,
|
|
54
|
+
signal: stop,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof ParchmentApiError)
|
|
59
|
+
throw error;
|
|
60
|
+
for (const s of callerSignals)
|
|
61
|
+
s.throwIfAborted();
|
|
62
|
+
if (timeout?.signal.aborted)
|
|
63
|
+
throw timedOut();
|
|
64
|
+
const message = error instanceof Error ? error.message : "request failed";
|
|
65
|
+
throw new ParchmentApiError(0, "network", message);
|
|
66
|
+
}
|
|
67
|
+
return decodeJsBigInts(await this.readData(response, callerSignals, timeout?.signal, timedOut), ints);
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
if (timer !== undefined)
|
|
71
|
+
clearTimeout(timer);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async fetchApiField(url, key, ints, signal) {
|
|
75
|
+
const data = await this.fetchApi(url, ints, undefined, signal);
|
|
76
|
+
const value = data?.[key];
|
|
77
|
+
if (value === null || value === undefined) {
|
|
78
|
+
throw new ParchmentApiError(0, "bad_body", `response has no ${key}`);
|
|
79
|
+
}
|
|
80
|
+
return value;
|
|
81
|
+
}
|
|
82
|
+
async fetchApiTxObject(url, body, signal) {
|
|
83
|
+
if (typeof body.sender !== "string") {
|
|
84
|
+
throw new ParchmentApiError(0, "bad_request", "walletAddress is required");
|
|
85
|
+
}
|
|
86
|
+
const sender = body.sender;
|
|
87
|
+
const trust = this.config.txTrust ?? UNCHECKED_TX;
|
|
88
|
+
if (trust !== UNCHECKED_TX && (typeof trust !== "object" || trust === null || typeof trust.packages !== "object" || trust.packages === null)) {
|
|
89
|
+
throw new ParchmentApiError(0, "bad_request", 'txTrust is "unchecked" or { packages }');
|
|
90
|
+
}
|
|
91
|
+
const data = await this.fetchApi(url, [], body, signal);
|
|
92
|
+
if (!data || typeof data.txBytesBase64 !== "string" || data.txBytesBase64.length === 0) {
|
|
93
|
+
throw new ParchmentApiError(0, "bad_tx", "transaction response has no txBytesBase64");
|
|
94
|
+
}
|
|
95
|
+
let tx;
|
|
96
|
+
try {
|
|
97
|
+
tx = Transaction.fromKind(data.txBytesBase64);
|
|
98
|
+
}
|
|
99
|
+
catch (error) {
|
|
100
|
+
const message = error instanceof Error ? error.message : "could not read transaction kind";
|
|
101
|
+
throw new ParchmentApiError(0, "bad_tx", message);
|
|
102
|
+
}
|
|
103
|
+
const violation = serviceTxViolation(tx, sender);
|
|
104
|
+
if (violation !== null)
|
|
105
|
+
throw new ParchmentApiError(0, "bad_tx", `transaction has a ${violation}`);
|
|
106
|
+
if (trust !== UNCHECKED_TX)
|
|
107
|
+
await assertTxIntent(url, body, tx, sender, trust);
|
|
108
|
+
tx.setSender(sender);
|
|
109
|
+
return {
|
|
110
|
+
request: { route: txRoute(url), body },
|
|
111
|
+
tx,
|
|
112
|
+
commands: data.commands ?? [],
|
|
113
|
+
note: data.note ?? null,
|
|
114
|
+
txBytesBase64: data.txBytesBase64,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async appendSyncLocked(built, owner, signal) {
|
|
118
|
+
const config = await this.fetchApi("config", PUBLIC_INTS.config, undefined, signal);
|
|
119
|
+
const trust = this.config.txTrust;
|
|
120
|
+
if (trust && trust !== UNCHECKED_TX) {
|
|
121
|
+
if (!trust.packages.token?.length) {
|
|
122
|
+
throw new ParchmentApiError(0, "untrusted_package", "syncLocked under txTrust needs txTrust.packages.token");
|
|
123
|
+
}
|
|
124
|
+
const untrusted = untrustedConfigPackages(config, trust.packages);
|
|
125
|
+
if (untrusted.length > 0)
|
|
126
|
+
throw new ParchmentApiError(0, "untrusted_package", `config names package ids outside txTrust: ${untrusted.join(", ")}`);
|
|
127
|
+
}
|
|
128
|
+
const { tokenPackageId, stakingPoolId, exchangeId, usdcType } = config;
|
|
129
|
+
if (!tokenPackageId || !stakingPoolId || !exchangeId || !usdcType) {
|
|
130
|
+
throw new ParchmentApiError(0, "sync_locked_unavailable", "config has no token package, staking pool or exchange for sync_locked");
|
|
131
|
+
}
|
|
132
|
+
addSyncLockedCall(built.tx, { packageId: tokenPackageId, coinType: usdcType, pool: stakingPoolId, exchange: exchangeId, owner: normalizeSuiAddress(owner) });
|
|
133
|
+
return built;
|
|
134
|
+
}
|
|
135
|
+
fetchImpl() {
|
|
136
|
+
return this.config.fetch ?? globalThis.fetch;
|
|
137
|
+
}
|
|
138
|
+
async readData(response, callerSignals, timeoutSignal, timedOut) {
|
|
139
|
+
let text;
|
|
140
|
+
try {
|
|
141
|
+
text = await response.text();
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
for (const s of callerSignals)
|
|
145
|
+
s.throwIfAborted();
|
|
146
|
+
if (timeoutSignal?.aborted)
|
|
147
|
+
throw timedOut();
|
|
148
|
+
const message = error instanceof Error ? error.message : "response body could not be read";
|
|
149
|
+
throw new ParchmentApiError(response.status, "network", message);
|
|
150
|
+
}
|
|
151
|
+
const retryAfter = response.ok ? undefined : retryAfterMs(response.headers?.get?.("retry-after"));
|
|
152
|
+
let parsed;
|
|
153
|
+
try {
|
|
154
|
+
parsed = text ? JSON.parse(text) : null;
|
|
155
|
+
}
|
|
156
|
+
catch {
|
|
157
|
+
throw new ParchmentApiError(response.status, "bad_body", "response was not JSON", retryAfter);
|
|
158
|
+
}
|
|
159
|
+
if (!parsed || typeof parsed !== "object") {
|
|
160
|
+
throw new ParchmentApiError(response.status, "bad_body", "response was empty", retryAfter);
|
|
161
|
+
}
|
|
162
|
+
const record = parsed;
|
|
163
|
+
if (record.error) {
|
|
164
|
+
throw new ParchmentApiError(response.status, record.error.code ?? "bad_request", record.error.message ?? "request failed", retryAfter);
|
|
165
|
+
}
|
|
166
|
+
if (!response.ok) {
|
|
167
|
+
throw new ParchmentApiError(response.status, "bad_request", `HTTP ${response.status}`, retryAfter);
|
|
168
|
+
}
|
|
169
|
+
if (!("data" in record)) {
|
|
170
|
+
throw new ParchmentApiError(response.status, "bad_body", "response has no data");
|
|
171
|
+
}
|
|
172
|
+
return record.data;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
export function requestTimeoutMs(timeoutMs) {
|
|
176
|
+
if (timeoutMs === undefined)
|
|
177
|
+
return undefined;
|
|
178
|
+
if (typeof timeoutMs !== "number" || !(timeoutMs > 0)) {
|
|
179
|
+
throw new ParchmentApiError(0, "bad_request", "timeoutMs must be a positive number of milliseconds");
|
|
180
|
+
}
|
|
181
|
+
return Math.min(timeoutMs, 2_147_483_647);
|
|
182
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Failure from a Parchment API call or from a request the SDK refused locally. */
|
|
2
|
+
export declare class ParchmentApiError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
readonly code: string;
|
|
5
|
+
/**
|
|
6
|
+
* The response's `Retry-After` in milliseconds (delta-seconds or an HTTP date, floored at 0), when an
|
|
7
|
+
* error response carried a valid one: 429 from the limiter, and 503/504 passed through by the legacy API.
|
|
8
|
+
*/
|
|
9
|
+
readonly retryAfterMs?: number;
|
|
10
|
+
constructor(status: number, code: string, message: string, retryAfterMs?: number);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* `Retry-After` as milliseconds: delta-seconds or an IMF-fixdate HTTP date (floored at 0); anything else
|
|
14
|
+
* (e.g. "1.5", "-1", "2026-13", which `Date.parse` would accept leniently) is undefined, per RFC 9110.
|
|
15
|
+
*/
|
|
16
|
+
export declare function retryAfterMs(header: string | null | undefined): number | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export class ParchmentApiError extends Error {
|
|
2
|
+
status;
|
|
3
|
+
code;
|
|
4
|
+
retryAfterMs;
|
|
5
|
+
constructor(status, code, message, retryAfterMs) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = "ParchmentApiError";
|
|
8
|
+
this.status = status;
|
|
9
|
+
this.code = code;
|
|
10
|
+
if (retryAfterMs !== undefined)
|
|
11
|
+
this.retryAfterMs = retryAfterMs;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function retryAfterMs(header) {
|
|
15
|
+
const value = header?.trim();
|
|
16
|
+
if (!value)
|
|
17
|
+
return undefined;
|
|
18
|
+
if (/^[0-9]+$/.test(value)) {
|
|
19
|
+
const seconds = Number(value);
|
|
20
|
+
return Number.isSafeInteger(seconds * 1000) ? seconds * 1000 : undefined;
|
|
21
|
+
}
|
|
22
|
+
if (!/^[A-Z][a-z]{2}, [0-9]{2} [A-Z][a-z]{2} [0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2} GMT$/.test(value))
|
|
23
|
+
return undefined;
|
|
24
|
+
const at = Date.parse(value);
|
|
25
|
+
return Number.isNaN(at) ? undefined : Math.max(0, at - Date.now());
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Rust width of an integer field: `u`/`i` plus bits, or the bare `u` (unsigned, any width) /
|
|
3
|
+
* `i` (signed, any width). Paths without a tag are unsigned (`u`).
|
|
4
|
+
*/
|
|
5
|
+
export type IntKind = "u" | "i" | "u8" | "u16" | "u32" | "u64" | "u128" | "i64" | "i128";
|
|
6
|
+
/**
|
|
7
|
+
* A public-API integer literal (`"123n"`) as a bigint; anything else, or a value outside `kind`
|
|
8
|
+
* (default signed, any width), is `bad_body` naming `field`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseJsBigInt(value: unknown, field: string, kind?: IntKind): bigint;
|
|
11
|
+
/** A bigint as the public API's integer literal (`123n` -> `"123n"`). */
|
|
12
|
+
export declare function toJsBigInt(value: bigint): string;
|
|
13
|
+
/**
|
|
14
|
+
* Where a response carries integers, by JSON path: `a.b` (object field), `a[]` (array items),
|
|
15
|
+
* `a.*` (map values), `[]` alone for a top-level array, optionally tagged with the field's Rust
|
|
16
|
+
* width after a colon (`ageMs:i64`, `id:u64`; {@link IntKind}). Untagged paths are unsigned of any
|
|
17
|
+
* width, so a negative there is `bad_body`. A path whose value is absent or null is left as is
|
|
18
|
+
* (the type says whether that is allowed).
|
|
19
|
+
*/
|
|
20
|
+
export type IntPaths = readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* Decodes, in place, every integer at `paths` from its `"123n"` literal to a bigint; a value
|
|
23
|
+
* there that is not one, or is out of its tagged range, is `bad_body` naming its path.
|
|
24
|
+
* Everything else is left untouched.
|
|
25
|
+
*/
|
|
26
|
+
export declare function decodeJsBigInts<T>(value: unknown, paths: IntPaths): T;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ParchmentApiError } from "./errors.js";
|
|
2
|
+
const JS_BIGINT = /^(?:0|-?[1-9][0-9]*)n$/;
|
|
3
|
+
const INT_KINDS = new Set(["u", "i", "u8", "u16", "u32", "u64", "u128", "i64", "i128"]);
|
|
4
|
+
function inRange(n, kind) {
|
|
5
|
+
const signed = kind.startsWith("i");
|
|
6
|
+
if (!signed && n < 0n)
|
|
7
|
+
return false;
|
|
8
|
+
const bits = kind.length > 1 ? BigInt(kind.slice(1)) : null;
|
|
9
|
+
if (bits === null)
|
|
10
|
+
return true;
|
|
11
|
+
return signed ? n >= -(1n << (bits - 1n)) && n < 1n << (bits - 1n) : n < 1n << bits;
|
|
12
|
+
}
|
|
13
|
+
export function parseJsBigInt(value, field, kind = "i") {
|
|
14
|
+
if (typeof value !== "string" || !JS_BIGINT.test(value)) {
|
|
15
|
+
throw new ParchmentApiError(0, "bad_body", `${field} must be an integer literal like "123n"`);
|
|
16
|
+
}
|
|
17
|
+
const n = BigInt(value.slice(0, -1));
|
|
18
|
+
if (!inRange(n, kind)) {
|
|
19
|
+
throw new ParchmentApiError(0, "bad_body", `${field} is out of range for ${kind === "u" ? "an unsigned integer" : kind}`);
|
|
20
|
+
}
|
|
21
|
+
return n;
|
|
22
|
+
}
|
|
23
|
+
export function toJsBigInt(value) {
|
|
24
|
+
return `${value}n`;
|
|
25
|
+
}
|
|
26
|
+
function splitTag(path) {
|
|
27
|
+
const at = path.lastIndexOf(":");
|
|
28
|
+
if (at < 0)
|
|
29
|
+
return [path, "u"];
|
|
30
|
+
const tag = path.slice(at + 1);
|
|
31
|
+
if (!INT_KINDS.has(tag))
|
|
32
|
+
throw new Error(`unknown integer tag ${tag} in ${path}`);
|
|
33
|
+
return [path.slice(0, at), tag];
|
|
34
|
+
}
|
|
35
|
+
export function decodeJsBigInts(value, paths) {
|
|
36
|
+
for (const tagged of paths) {
|
|
37
|
+
const [path, kind] = splitTag(tagged);
|
|
38
|
+
decodeAt(value, path.split(/\.|(?=\[\])/), path, kind);
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
function decodeAt(node, steps, path, kind) {
|
|
43
|
+
const [step, ...rest] = steps;
|
|
44
|
+
if (node === null || node === undefined || step === undefined)
|
|
45
|
+
return;
|
|
46
|
+
if (step === "[]") {
|
|
47
|
+
if (!Array.isArray(node))
|
|
48
|
+
throw new ParchmentApiError(0, "bad_body", `${path}: expected a list`);
|
|
49
|
+
if (rest.length === 0) {
|
|
50
|
+
node.forEach((item, i) => {
|
|
51
|
+
node[i] = parseJsBigInt(item, path, kind);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
for (const item of node)
|
|
56
|
+
decodeAt(item, rest, path, kind);
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (typeof node !== "object" || Array.isArray(node)) {
|
|
61
|
+
throw new ParchmentApiError(0, "bad_body", `${path}: expected an object`);
|
|
62
|
+
}
|
|
63
|
+
const record = node;
|
|
64
|
+
const keys = step === "*" ? Object.keys(record) : [step];
|
|
65
|
+
for (const key of keys) {
|
|
66
|
+
const child = record[key];
|
|
67
|
+
if (child === null || child === undefined)
|
|
68
|
+
continue;
|
|
69
|
+
if (rest.length === 0)
|
|
70
|
+
record[key] = parseJsBigInt(child, path, kind);
|
|
71
|
+
else
|
|
72
|
+
decodeAt(child, rest, path, kind);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
/**
|
|
3
|
+
* Why a service-built transaction kind is not one the service builds, or null. The service only makes
|
|
4
|
+
* Move calls (outside the framework, except `0x2::coin::zero`), `TransferObjects` to the sender and a
|
|
5
|
+
* `SplitCoins` of an owned coin input (the builder creation fee); never a split of the gas coin, a merge, a
|
|
6
|
+
* vector, a publish or an upgrade.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serviceTxViolation(tx: Transaction, sender: string): string | null;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { fromBase64, normalizeSuiAddress, toHex } from "@mysten/sui/utils";
|
|
2
|
+
const FRAMEWORK_PACKAGES = new Set(["0x1", "0x2", "0x3"].map((id) => normalizeSuiAddress(id)));
|
|
3
|
+
const FRAMEWORK_CALLS = new Set(["coin::zero"]);
|
|
4
|
+
function pureAddress(data, arg) {
|
|
5
|
+
if (arg?.$kind !== "Input" || typeof arg.Input !== "number")
|
|
6
|
+
return null;
|
|
7
|
+
const input = data.inputs[arg.Input];
|
|
8
|
+
if (input?.$kind !== "Pure" || !input.Pure)
|
|
9
|
+
return null;
|
|
10
|
+
const bytes = fromBase64(input.Pure.bytes);
|
|
11
|
+
return bytes.length === 32 ? normalizeSuiAddress(toHex(bytes)) : null;
|
|
12
|
+
}
|
|
13
|
+
export function serviceTxViolation(tx, sender) {
|
|
14
|
+
const data = tx.getData();
|
|
15
|
+
const me = normalizeSuiAddress(sender);
|
|
16
|
+
for (const command of data.commands) {
|
|
17
|
+
switch (command.$kind) {
|
|
18
|
+
case "MoveCall": {
|
|
19
|
+
const { package: pkg, module, function: fn } = command.MoveCall;
|
|
20
|
+
if (FRAMEWORK_PACKAGES.has(normalizeSuiAddress(pkg)) && !FRAMEWORK_CALLS.has(`${module}::${fn}`))
|
|
21
|
+
return `call to ${pkg}::${module}::${fn}`;
|
|
22
|
+
break;
|
|
23
|
+
}
|
|
24
|
+
case "TransferObjects": {
|
|
25
|
+
const to = pureAddress(data, command.TransferObjects.address);
|
|
26
|
+
if (to !== me)
|
|
27
|
+
return `transfer to ${to ?? "a computed address"}`;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
case "SplitCoins":
|
|
31
|
+
if (command.SplitCoins.coin?.$kind !== "Input")
|
|
32
|
+
return "split of the gas coin";
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
return `${command.$kind} command`;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return null;
|
|
39
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { EMERGENCY_CLOSE_DISABLED_MS, MARKET_STATUS_ACTIVE, MARKET_STATUS_REDUCE_ONLY, MARKET_STATUS_RETIRED, ORDER_PARAMS_V1_BCS, ORDER_TX_NOTE, PUBLIC_INTS, bindTradingReferrerTxBody, transferAccountTxBody, cancelOrderTxBody, claimPendingMintTxBody, claimQuestTxBody, claimTxBody, exitEarlyBoundedTxBody, exitEarlyTxBody, releaseUnlockedTxBody, closePreviewBody, closeRetiredTxBody, depositTxBody, gameTxBody, openCratesTxBody, installTreasuryTxBody, lpHarvestTxBody, openAccountTxBody, registerBuilderTxBody, setBuilderPayoutTxBody, createBuilderTxBody, setBuilderFeeTxBody, builderOwnerTxBody, transferBuilderTxBody, approveBuilderTxBody, revokeBuilderApprovalTxBody, BUILDER_FEE_HARD_BPS, MAX_BUILDER_CREATE_FEE, setBuilderCreateFeeTxBody, stakeTxBody, sweepSurplusTxBody, unstakeTxBody, withdrawTxBody, decodeOrderParams, closeRetiredAsDelegateTxBody, emergencyCloseAsDelegateTxBody, grantDelegateTxBody, grantCloseDelegateTxBody, grantSessionAndTriggerTxBody, revokeSessionAndTriggerTxBody, revokeDelegateTxBody, NEAR_LIQ_DISTANCE_FRACTION, TRIGGER_PROOF_TTL_MS, TRIGGER_PROOF_VERSION, newTriggerIntentId, signTriggerProof, stopAgainstLiquidation, triggerBindBody, triggerPrepareBody, triggerProofMessage, triggerRequestBody, emergencyCloseDisabled, emergencyCloseTxBody, expireOrderTxBody, hasPendingOrderSlot, isEmergencyAfterDisabled, openPreviewBody, orderParamsFromJson, orderRefTxBody, requestCloseAsDelegateTxBody, requestCloseTxBody, requestOpenAsDelegateTxBody, requestOpenTxBody, assertDelegateLiveThroughFill, DELEGATE_FILL_MARGIN_MS, ORDER_ABORT_MESSAGES, ORDER_ABORT_NAMES, ORACLE_RESERVED_ABORT_CODES, ORDER_RESERVED_ABORT_CODES, TRADE_RESERVED_ABORT_CODES, MIN_CANCEL_DELAY_MS, ORDER_FINALIZED_EVENT_BCS, ORDER_OUTCOMES, ORDER_REFUND_SESSION_MESSAGE, ORDER_REQUESTED_EVENT_BCS, PARCHMENT_CANDLES_BATCH_MAX_MARKETS, PARCHMENT_SPONSORED_ACTIONS, PARCHMENT_TRADE_MODULES, ParchmentAccount, ParchmentMarket, TX_ACTIONS, TRADE_ABORT_MESSAGES, TRADE_ABORT_NAMES, FEE_MINT_ABORT_MESSAGES, FEE_MINT_ABORT_NAMES, MARKET_ABORT_MESSAGES, MARKET_ABORT_NAMES, ACCESS_ABORT_NAMES, ACCOUNT_ABORT_NAMES, CONFIG_ABORT_NAMES, BUILDER_ABORT_NAMES, REFERRAL_ABORT_NAMES, STAKING_ABORT_NAMES, DECLARED_NOT_RAISED_ABORT_CODES, EXCHANGE_ABORT_NAMES, HOLDER_BOOK_ABORT_NAMES, ACCOUNT_TRANSFER_ABORT_NAMES, ABORT_MODULE_PATHS, ABORT_NAME_MAPS, AUTHORITY_ABORT_NAMES, FEES_ABORT_NAMES, GAME_ABORT_MESSAGES, GAME_ABORT_NAMES, KEEPER_ABORT_NAMES, EVENT_GUARD_ABORT_NAMES, LIQ_BOOK_ABORT_NAMES, LP_ABORT_NAMES, ORACLE_ABORT_NAMES, ORACLE_ADAPTER_ABORT_NAMES, POSITION_ABORT_NAMES, TIMELOCK_ABORT_NAMES, LOCKED_MINT_ABORT_NAMES, MINT_CAP_ABORT_NAMES, UNCOVERED_MODULES, LOCKED_LEDGER_STATUSES, RETAINED_FEE_CURVE_DEFAULTS, RETAINED_FEE_CURVE_MAX_COV_BPS, addSetRetainedFeeCurveCall, lpRetainedFeeCurve, retainedFeeCurve, retainedStakerShareBps, abortMessage, abortName, boundFromSlippage, decodeAbortCode, decodeOrderFinalizedEvent, finalizedOrdersFromTx, orderOutcome, decodeOrderRequestedEvent, isParchmentTradeModule, marketIsActive, marketIsDelisted, marketIsRetired, marketMinHoldMs, marketNextSessionOpenMs, marketSessionEndsAtMs, liquidationPaused, requestsPausedMessage, orderAbortMessage, orderAbortName, effectiveCancelAfterMs, orderExpiresAfterMs, parchmentBaseTypePackageId, parchmentCallPackageId, parchmentCoreTypePackageId, parchmentGameTypePackageId, parchmentMintTypePackageId, parchmentTradeTypePackageId, requireSplitPackageIds, requestedOrderIdFromTx, requestedOrdersFromTx, SPONSOR_IN_FLIGHT_LIMIT, SPONSOR_NOT_DELEGATE, isSessionKeyRevoked, shouldPayOwnGas, sponsorBody, SESSION_KEY_EXPIRY_MARGIN_MS, SESSION_KEY_TTL_MS, MAX_SPONSOR_PROOF_LIFETIME_MS, SPONSOR_PROOF_LIFETIME_MS, assertSessionTradeKind, createSessionKey, isSponsoredCopyOf, liveSessionDelegate, sessionKeyExpiryMs, sessionKeyFromSecret, sessionKeySecret, signSessionSponsoredTx, signSponsorProof, sponsorProofMessage, tradeAbortMessage, FORCE_CLOSE_SESSION_MAX_IDS, BatchCloseError, CLOSE_BATCH_BUDGET, SPONSOR_BATCH_BUDGET, SUI_TX_LIMITS, batchCloseTx, closeBatchTopUps, closeBatchUsage, fitCloseBatch, legIsRequest, planCloseBatches, splitCloseBatches, txIntentViolation, untrustedConfigPackages, UNCHECKED_TX, GAME_REGISTRY_MAXIMA, gameEventLimitsFromDefinitions, playerProgressionEvents, addArmSessionCloseAdminCall, addArmSessionCloseCall, addSessionRefundCall, addForceCloseSessionCall, addMintPendingForCalls, buildMintPendingForTx, addOneSignatureOnboardingCalls, deriveAccountId, MONITORING_MAX_DAYS, monitoringPath, monitoringView, statsActivityPath, statsActivityView, STAKING_HISTORY_WINDOWS, stakingHistoryPath, stakingHistoryView, parseLivePrice, parseTrade, } from "./parchment/index.js";
|
|
2
|
+
export type { ParchmentDelegateLiveness, BatchCloseClient, BatchCloseLeg, BatchCloseOptions, CloseBatchPlanLeg, CloseBatchUsage, GameEventLimits, ParchmentTrustedPackages, ParchmentTxTrust, ParchmentTxTrustSetting, ArmSessionCloseAdminCall, ArmSessionCloseCall, ForceCloseSessionCall, SessionRefundCall, AccountIdInput, OneSignatureOnboardingCalls, ParchmentSessionKey, ParchmentSponsorProof, StopPlacement, TriggerBindInput, TriggerIntentTarget, TriggerKind, TriggerProof, TriggerProofInput, TriggerSigner, TriggerTarget, ParchmentRetainedFeeCurve, SetRetainedFeeCurveCall, OrderParamsV1, FinalizedOrderRef, OrderFinalizedEventV1, OrderRequestedEventV1, ParchmentExecutedEventLike, ParchmentExecutedTxLike, ParchmentPackageScope, ParchmentTradeModule, RequestedOrderRef, SlippageAction, SlippageSide, ParchmentMonitoring, ParchmentMintCapStats, ParchmentMintEpoch, ParchmentMintDay, ParchmentQueueStats, ParchmentQueueDay, ParchmentMarketExposure, ParchmentSideExposure, ParchmentExposureDay, ParchmentFeeStats, ParchmentFeeFlows, ParchmentFeeDay, ParchmentMarketFillLag, ParchmentFillLags, ParchmentFillLagDay, ParchmentLagStats, ParchmentGapStats, ParchmentShortHoldStats, ParchmentShortHolds, ParchmentShortHoldDay, ParchmentMarketShortHolds, ParchmentStatsActivity, ParchmentMarketActivity, ParchmentMarketFlow, ParchmentMarketFlowDay, ParchmentCollateralFlow, ParchmentCollateralFlowDay, ParchmentStakingHistory, ParchmentStakingHistoryDays, ParchmentStakingHistoryPoint, ParchmentStakingDay, } from "./parchment/index.js";
|
|
3
|
+
export { EVENT_CLOSE_ARMED_EVENT_BCS, EVENT_GUARD_MAX_WINDOW_MS, EVENT_LEVERAGE_CAP_UPDATED_EVENT_BCS, EVENT_PAUSE_UPDATED_EVENT_BCS, EVENT_REASON, addArmEventCloseCall, addClearEventLeverageCapCall, addClearEventPauseCall, addEventGuardAdminClearCall, addSetEventLeverageCapCall, addSetEventPauseCall, decodeEventCloseArmedEvent, decodeEventLeverageCapUpdatedEvent, decodeEventPauseUpdatedEvent, eventGuardEventType, } from "./parchment/index.js";
|
|
4
|
+
export type { ArmEventCloseCall, EventCloseArmedEvent, EventGuardAdminClearCall, EventKeeperCall, EventLeverageCapUpdatedEvent, EventPauseUpdatedEvent, EventReason, SetEventLeverageCapCall, SetEventPauseCall, } from "./parchment/index.js";
|
|
5
|
+
export { TRIGGER_LEVELS_COMMITTED_BCS, TRIGGER_LEVELS_SET_EVENT_BCS, decodeTriggerLevelsCommitted, decodeTriggerLevelsSetEvent } from "./parchment/index.js";
|
|
6
|
+
export type { TriggerLevelsCommitted, TriggerLevelsSetEvent } from "./parchment/index.js";
|
|
7
|
+
export { addRequestOpenWithTriggersCall, addRequestOpenWithTriggersAsDelegateCall, addSetTriggerLevelsCall, addSetTriggerLevelsAsDelegateCall } from "./parchment/index.js";
|
|
8
|
+
export type { MintPendingForCalls } from "./parchment/index.js";
|
|
9
|
+
export type { TriggerOpenCall, TriggerOpenWithCapCall, TriggerEditCall, TriggerEditWithCapCall, TriggerEditAsDelegateCall } from "./parchment/index.js";
|
|
10
|
+
export { LOCKED_WEIGHT_SYNCED_EVENT_BCS, LOCKED_YIELD_CLAIMED_EVENT_BCS, LOCKED_YIELD_FORFEITED_EVENT_BCS, LOCKED_WEIGHT_BPS_UPDATED_EVENT_BCS, decodeLockedWeightSyncedEvent, decodeLockedYieldClaimedEvent, decodeLockedYieldForfeitedEvent, decodeLockedWeightBpsUpdatedEvent, addSyncLockedCall, addSyncLockedCalls, addForfeitLockedYieldCall, } from "./parchment/index.js";
|
|
11
|
+
export type { LockedWeightSyncedEventV1, LockedYieldClaimedEventV1, LockedYieldForfeitedEventV1, LockedWeightBpsUpdatedEventV1, SyncLockedCall, } from "./parchment/index.js";
|