@parchment-trade/sdk 0.0.0-stage → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +193 -2
- package/REFERENCE.md +338 -0
- package/SECURITY.md +25 -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 +58 -4
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
/**
|
|
3
|
+
* Every approved version of each package lineage the service's transactions call, original id
|
|
4
|
+
* first. Take these from your own build (e.g. `docs/PUBLISHED-mainnet.md`) and add an upgrade's id
|
|
5
|
+
* only once you approve it. Never fill them from `GET /config`: that is the response being checked.
|
|
6
|
+
*/
|
|
7
|
+
export interface ParchmentTrustedPackages {
|
|
8
|
+
/** Core `parchment` (`exchange`, `config`, ...). */
|
|
9
|
+
core: readonly string[];
|
|
10
|
+
/** `parchment_trade` (`order`, `trade`, `oracle`, the game / mint facades, ...). */
|
|
11
|
+
trade: readonly string[];
|
|
12
|
+
/** `parchment_base` (`builder_book`, `safety`, ...). Checked against `/config` `basePackageId(s)`. */
|
|
13
|
+
base: readonly string[];
|
|
14
|
+
/** `parchment_game`. Checked against `/config` `gamePackageId(s)`; calls go through the trade facades. */
|
|
15
|
+
game: readonly string[];
|
|
16
|
+
/** `parchment_mint` (`MintCapKey` types). Checked against `/config` `mintPackageId(s)`; calls go through the trade facades. */
|
|
17
|
+
mint: readonly string[];
|
|
18
|
+
/** `parchment_oracle` (`adapter::quote`). Needed for one-step closes, liquidations and sweeps. */
|
|
19
|
+
oracle?: readonly string[];
|
|
20
|
+
/** `parchment_token` (`tokenomics::mint_on_loss`, `staking`, `parchment::install_treasury`). */
|
|
21
|
+
token?: readonly string[];
|
|
22
|
+
/** the Lazer integration (`price_feed_storage::update_price_feed`). */
|
|
23
|
+
lazerIntegration?: readonly string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `ParchmentOptions.txTrust: "unchecked"`: build without intent checks, trusting the builder API
|
|
27
|
+
* for packages and arguments (only the command shapes are checked). For tests and tooling, not wallets.
|
|
28
|
+
*/
|
|
29
|
+
export declare const UNCHECKED_TX: "unchecked";
|
|
30
|
+
/** `ParchmentOptions.txTrust` / `BatchCloseOptions.txTrust`: the trust, or the explicit opt-out. */
|
|
31
|
+
export type ParchmentTxTrustSetting = ParchmentTxTrust | typeof UNCHECKED_TX;
|
|
32
|
+
/** `ParchmentOptions.txTrust`: what builder responses are checked against. */
|
|
33
|
+
export interface ParchmentTxTrust {
|
|
34
|
+
packages: ParchmentTrustedPackages;
|
|
35
|
+
/**
|
|
36
|
+
* The service's close-only trigger delegate. `grant-close-delegate` and `grant-session-and-trigger`
|
|
37
|
+
* name none in the request (the service adds its own), so without this pin those routes are refused.
|
|
38
|
+
*/
|
|
39
|
+
triggerDelegate?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Which of `delegates` hold a trade or close-only grant on `accountId`, read from chain (the
|
|
42
|
+
* account's `delegates` and the core package's close-delegate fields), never from the Parchment
|
|
43
|
+
* API. `revoke-session-and-trigger` revokes only the grants the account holds, so with this
|
|
44
|
+
* reader a response must revoke exactly the held ones. Without it, the response must revoke
|
|
45
|
+
* every distinct named delegate, and a one-grant revoke has to use `revoke-delegate` instead.
|
|
46
|
+
*/
|
|
47
|
+
heldDelegates?: (accountId: string, delegates: readonly string[]) => Promise<readonly string[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Emergency and retired closes whose request carries no `update` take the signed update the
|
|
50
|
+
* service attaches. The chain still verifies it as a fresh Lazer signature, but which
|
|
51
|
+
* price inside that freshness window is the builder's choice. Off by default: such a request is
|
|
52
|
+
* refused under `txTrust`, so pass the `update` you fetched (bound exactly), or set this to accept
|
|
53
|
+
* the service's choice.
|
|
54
|
+
*/
|
|
55
|
+
acceptServiceOracleUpdate?: boolean;
|
|
56
|
+
}
|
|
57
|
+
/** The pure argument (base64 of BCS `vector<u8>`) a kind built for `updateBase64` passes to `quote`, or null. */
|
|
58
|
+
export declare function updateArgBase64(updateBase64: unknown): string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Why `tx` (the kind a builder returned for `route` and request `body`, with `sender`) is not the
|
|
61
|
+
* transaction built for that request, or null. Checks: every Move call targets a trusted package id
|
|
62
|
+
* and a module of that package; the route's action calls appear exactly as often as tx.rs builds
|
|
63
|
+
* them, with the request's objects, amounts, side, bounds and delegates; nothing else is called
|
|
64
|
+
* but the route's prelude. Routes with no intent here are refused.
|
|
65
|
+
*
|
|
66
|
+
* `held`: for `revoke-session-and-trigger`, the named delegates that hold a grant, read from chain
|
|
67
|
+
* ({@link ParchmentTxTrust.heldDelegates}). Without it every distinct named delegate must be revoked.
|
|
68
|
+
*/
|
|
69
|
+
export declare function txIntentViolation(route: string, tx: Transaction, body: Record<string, unknown>, sender: string, trust: ParchmentTxTrust, held?: readonly string[]): string | null;
|
|
70
|
+
/**
|
|
71
|
+
* Package ids a `/config` response names that are not in the trusted set: a config substituted
|
|
72
|
+
* with another package. Core, trade, base, game and mint ids (singular and lists) are always
|
|
73
|
+
* compared, and a lineage with no trusted ids rejects any id. `oracle`, `token` and
|
|
74
|
+
* `lazerIntegration` are compared only when trusted ids are given for them.
|
|
75
|
+
*/
|
|
76
|
+
export declare function untrustedConfigPackages(config: {
|
|
77
|
+
packageId?: string | null;
|
|
78
|
+
packageIds?: readonly string[];
|
|
79
|
+
tradePackageId?: string | null;
|
|
80
|
+
tradePackageIds?: readonly string[];
|
|
81
|
+
basePackageId?: string | null;
|
|
82
|
+
basePackageIds?: readonly string[];
|
|
83
|
+
gamePackageId?: string | null;
|
|
84
|
+
gamePackageIds?: readonly string[];
|
|
85
|
+
mintPackageId?: string | null;
|
|
86
|
+
mintPackageIds?: readonly string[];
|
|
87
|
+
oraclePackageId?: string | null;
|
|
88
|
+
tokenPackageId?: string | null;
|
|
89
|
+
lazerIntegrationPackageId?: string | null;
|
|
90
|
+
}, trusted: ParchmentTrustedPackages): string[];
|
|
91
|
+
/** `transactions/<route>` → `<route>`. */
|
|
92
|
+
export declare function txRoute(url: string): string;
|
|
93
|
+
/**
|
|
94
|
+
* With `txTrust`, a builder response must be the transaction built for its request:
|
|
95
|
+
* throws `ParchmentApiError` `intent_mismatch` otherwise. `url` is the builder path
|
|
96
|
+
* (`transactions/<route>`). Run for every client's builder responses (`Caller.fetchApiTxObject`).
|
|
97
|
+
* For `revoke-session-and-trigger` it first reads which grants are live from `trust.heldDelegates`, when set.
|
|
98
|
+
*/
|
|
99
|
+
export declare function assertTxIntent(url: string, body: Record<string, unknown>, tx: Transaction, sender: string, trust: ParchmentTxTrust): Promise<void>;
|