@lightconexyz/lightcone-sdk 0.8.1 → 0.8.2

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 (95) hide show
  1. package/README.md +150 -3
  2. package/dist/auth/client.d.ts +17 -1
  3. package/dist/auth/client.d.ts.map +1 -1
  4. package/dist/auth/client.js +68 -0
  5. package/dist/auth/client.js.map +1 -1
  6. package/dist/auth/index.d.ts +57 -5
  7. package/dist/auth/index.d.ts.map +1 -1
  8. package/dist/auth/index.js +26 -5
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/client.d.ts +23 -1
  11. package/dist/client.d.ts.map +1 -1
  12. package/dist/client.js +38 -2
  13. package/dist/client.js.map +1 -1
  14. package/dist/context.d.ts +23 -2
  15. package/dist/context.d.ts.map +1 -1
  16. package/dist/context.js +238 -17
  17. package/dist/context.js.map +1 -1
  18. package/dist/domain/market/outcome.d.ts +9 -3
  19. package/dist/domain/market/outcome.d.ts.map +1 -1
  20. package/dist/domain/market/outcome.js +10 -7
  21. package/dist/domain/market/outcome.js.map +1 -1
  22. package/dist/domain/market/wire.d.ts +3 -3
  23. package/dist/domain/market/wire.d.ts.map +1 -1
  24. package/dist/domain/market/wire.js.map +1 -1
  25. package/dist/domain/orderbook/wire.d.ts +5 -0
  26. package/dist/domain/orderbook/wire.d.ts.map +1 -1
  27. package/dist/domain/orderbook/wire.js.map +1 -1
  28. package/dist/domain/position/client.d.ts +160 -4
  29. package/dist/domain/position/client.d.ts.map +1 -1
  30. package/dist/domain/position/client.js +592 -4
  31. package/dist/domain/position/client.js.map +1 -1
  32. package/dist/domain/position/index.d.ts +54 -3
  33. package/dist/domain/position/index.d.ts.map +1 -1
  34. package/dist/domain/position/index.js +1 -0
  35. package/dist/domain/position/index.js.map +1 -1
  36. package/dist/domain/position/state.d.ts +118 -0
  37. package/dist/domain/position/state.d.ts.map +1 -0
  38. package/dist/domain/position/state.js +262 -0
  39. package/dist/domain/position/state.js.map +1 -0
  40. package/dist/error.d.ts +8 -2
  41. package/dist/error.d.ts.map +1 -1
  42. package/dist/error.js +14 -1
  43. package/dist/error.js.map +1 -1
  44. package/dist/index.d.ts +4 -3
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +3 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/prelude.d.ts +6 -5
  49. package/dist/prelude.d.ts.map +1 -1
  50. package/dist/prelude.js +10 -1
  51. package/dist/prelude.js.map +1 -1
  52. package/dist/privy/client.d.ts +4 -0
  53. package/dist/privy/client.d.ts.map +1 -1
  54. package/dist/privy/client.js +4 -0
  55. package/dist/privy/client.js.map +1 -1
  56. package/dist/rpc.d.ts +46 -1
  57. package/dist/rpc.d.ts.map +1 -1
  58. package/dist/rpc.js +125 -0
  59. package/dist/rpc.js.map +1 -1
  60. package/dist/shared/api_response.d.ts +7 -0
  61. package/dist/shared/api_response.d.ts.map +1 -1
  62. package/dist/shared/api_response.js +16 -0
  63. package/dist/shared/api_response.js.map +1 -1
  64. package/dist/shared/index.d.ts +1 -1
  65. package/dist/shared/index.d.ts.map +1 -1
  66. package/dist/shared/index.js +2 -1
  67. package/dist/shared/index.js.map +1 -1
  68. package/dist/shared/signing.d.ts +17 -0
  69. package/dist/shared/signing.d.ts.map +1 -1
  70. package/dist/shared/signing.js +27 -0
  71. package/dist/shared/signing.js.map +1 -1
  72. package/dist/shared/types.d.ts +3 -1
  73. package/dist/shared/types.d.ts.map +1 -1
  74. package/dist/shared/types.js +12 -4
  75. package/dist/shared/types.js.map +1 -1
  76. package/dist/ws/client.browser.d.ts +4 -0
  77. package/dist/ws/client.browser.d.ts.map +1 -1
  78. package/dist/ws/client.browser.js +13 -1
  79. package/dist/ws/client.browser.js.map +1 -1
  80. package/dist/ws/client.node.d.ts +4 -0
  81. package/dist/ws/client.node.d.ts.map +1 -1
  82. package/dist/ws/client.node.js +13 -1
  83. package/dist/ws/client.node.js.map +1 -1
  84. package/dist/ws/index.d.ts +24 -0
  85. package/dist/ws/index.d.ts.map +1 -1
  86. package/dist/ws/index.js +162 -1
  87. package/dist/ws/index.js.map +1 -1
  88. package/dist/ws/subscriptions.d.ts +12 -1
  89. package/dist/ws/subscriptions.d.ts.map +1 -1
  90. package/dist/ws/subscriptions.js +11 -0
  91. package/dist/ws/subscriptions.js.map +1 -1
  92. package/dist/ws/types.d.ts +5 -0
  93. package/dist/ws/types.d.ts.map +1 -1
  94. package/dist/ws/types.js.map +1 -1
  95. package/package.json +2 -1
@@ -0,0 +1,262 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WalletDepositBalancesState = exports.SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS = exports.SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS = exports.WRAPPED_SOL_MINT = void 0;
7
+ exports.solBalanceAvailability = solBalanceAvailability;
8
+ exports.unwrapAllSolBalanceAvailability = unwrapAllSolBalanceAvailability;
9
+ const decimal_js_1 = __importDefault(require("decimal.js"));
10
+ const error_1 = require("../../error");
11
+ const shared_1 = require("../../shared");
12
+ /**
13
+ * Canonical WSOL mint under Solana's legacy SPL Token Program (“Tokenkeg”).
14
+ * ATA derivation stays pinned to Tokenkeg rather than Token-2022 so state and
15
+ * transaction planning address the protocol's one canonical account.
16
+ */
17
+ exports.WRAPPED_SOL_MINT = "So11111111111111111111111111111111111111112";
18
+ /** Unsponsored native reserve floor, in lamports, when canonical ATA creation is required. */
19
+ exports.SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS = 3500000n;
20
+ /** Unsponsored native reserve floor, in lamports, when canonical WSOL already exists. */
21
+ exports.SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS = 1000000n;
22
+ /** Maximum exact non-negative lamport value representable by Solana's u64 fields. */
23
+ const MAX_SOLANA_LAMPORTS = 0xffffffffffffffffn;
24
+ /** Derive fail-closed availability and type an insufficient native reserve as fee funding. */
25
+ function solBalanceAvailability(components, costs) {
26
+ for (const [label, value] of [
27
+ ["native SOL", components.nativeLamports],
28
+ ["canonical WSOL", components.canonicalWsolLamports],
29
+ ]) {
30
+ if (typeof value !== "bigint" || value < 0n || value > MAX_SOLANA_LAMPORTS) {
31
+ throw error_1.SdkError.validation(`${label} must fit the non-negative u64 lamport range`);
32
+ }
33
+ }
34
+ for (const [label, value] of [
35
+ ["transaction fee", costs.feeLamports],
36
+ ["upfront rent", costs.upfrontRentLamports],
37
+ ]) {
38
+ if (typeof value !== "bigint" || value < 0n || value > MAX_SOLANA_LAMPORTS) {
39
+ throw error_1.SdkError.validation(`${label} must fit the non-negative u64 lamport range`);
40
+ }
41
+ }
42
+ const displayedLamports = components.nativeLamports + components.canonicalWsolLamports;
43
+ if (displayedLamports > MAX_SOLANA_LAMPORTS) {
44
+ throw error_1.SdkError.validation("displayed SOL exceeds the transaction u64 range");
45
+ }
46
+ const liveCosts = costs.feeLamports + costs.upfrontRentLamports;
47
+ if (liveCosts > MAX_SOLANA_LAMPORTS) {
48
+ throw error_1.SdkError.validation("combined transaction costs must fit u64 lamports");
49
+ }
50
+ const floor = costs.createsCanonicalWsolAccount
51
+ ? exports.SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS
52
+ : exports.SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS;
53
+ const reserveLamports = costs.sponsored
54
+ ? 0n
55
+ : liveCosts > floor
56
+ ? liveCosts
57
+ : floor;
58
+ if (components.nativeLamports < reserveLamports) {
59
+ throw error_1.SdkError.insufficientSolForTransactionFees(components.nativeLamports, reserveLamports);
60
+ }
61
+ return {
62
+ components,
63
+ displayedLamports,
64
+ reserveLamports,
65
+ spendableLamports: displayedLamports - reserveLamports,
66
+ };
67
+ }
68
+ /**
69
+ * Return unwrap-all availability with the live fee as its entire reserve.
70
+ *
71
+ * This function rejects costs that include sponsorship, account creation, or
72
+ * upfront rent. It rejects malformed or out-of-range components and costs. It
73
+ * rejects a displayed-balance sum outside Solana's unsigned 64-bit range. Native
74
+ * SOL must fund the fee without relying on lamports that a later `CloseAccount`
75
+ * instruction may transfer. The ordinary persistent-account floor does not apply
76
+ * because unwrap-all removes that account. An insufficient native fee balance
77
+ * returns the typed transaction-fee error.
78
+ */
79
+ function unwrapAllSolBalanceAvailability(components, costs) {
80
+ for (const [label, value] of [
81
+ ["native SOL", components.nativeLamports],
82
+ ["canonical WSOL", components.canonicalWsolLamports],
83
+ ]) {
84
+ if (typeof value !== "bigint" || value < 0n || value > MAX_SOLANA_LAMPORTS) {
85
+ throw error_1.SdkError.validation(`${label} must fit the non-negative u64 lamport range`);
86
+ }
87
+ }
88
+ for (const [label, value] of [
89
+ ["transaction fee", costs.feeLamports],
90
+ ["upfront rent", costs.upfrontRentLamports],
91
+ ]) {
92
+ if (typeof value !== "bigint" || value < 0n || value > MAX_SOLANA_LAMPORTS) {
93
+ throw error_1.SdkError.validation(`${label} must fit the non-negative u64 lamport range`);
94
+ }
95
+ }
96
+ if (costs.upfrontRentLamports !== 0n ||
97
+ costs.createsCanonicalWsolAccount ||
98
+ costs.sponsored) {
99
+ throw error_1.SdkError.validation("unwrap-all costs must be unsponsored with no upfront rent or account creation");
100
+ }
101
+ const displayedLamports = components.nativeLamports + components.canonicalWsolLamports;
102
+ if (displayedLamports > MAX_SOLANA_LAMPORTS) {
103
+ throw error_1.SdkError.validation("displayed SOL exceeds the transaction u64 range");
104
+ }
105
+ if (components.nativeLamports < costs.feeLamports) {
106
+ throw error_1.SdkError.insufficientSolForTransactionFees(components.nativeLamports, costs.feeLamports);
107
+ }
108
+ return {
109
+ components,
110
+ displayedLamports,
111
+ reserveLamports: costs.feeLamports,
112
+ spendableLamports: displayedLamports - costs.feeLamports,
113
+ };
114
+ }
115
+ /**
116
+ * Mutable application-owned wallet balance state.
117
+ *
118
+ * The default instance is uninitialized. A complete REST or WebSocket snapshot
119
+ * establishes its wallet baseline; later component events must match that wallet
120
+ * and carry absolute values. Native SOL never enters the sparse SPL mint map, and
121
+ * complete cross-component snapshots may replace `contextSlot` with a lower slot.
122
+ * Map containers are copied, but mutable balance objects are retained by reference;
123
+ * treat payload entries as immutable after applying them.
124
+ */
125
+ class WalletDepositBalancesState {
126
+ /** Wallet owning the current baseline, or `undefined` before initialization. */
127
+ walletAddress;
128
+ /** Slot of the last accepted event, not a globally monotonic stream version. */
129
+ contextSlot;
130
+ /** Sparse mint-keyed SPL balances; explicit zero updates remove their mint. */
131
+ balances = new Map();
132
+ /** Exact nine-decimal native SOL, separate from `balances`. */
133
+ nativeSolBalance;
134
+ /**
135
+ * Initialize or wholesale-replace state from a complete REST snapshot.
136
+ * The caller supplies the wallet omitted by REST; prior slots are not compared.
137
+ * Unlike WebSocket parsing, this TypeScript REST boundary performs no runtime
138
+ * shape validation. Malformed exact values fail when a derived method scales them.
139
+ */
140
+ applyRestSnapshot(walletAddress, snapshot) {
141
+ this.replace(walletAddress, snapshot.context_slot, snapshot.balances, snapshot.native_sol_balance);
142
+ return { kind: "applied" };
143
+ }
144
+ /**
145
+ * Apply the wallet event state machine.
146
+ *
147
+ * Complete snapshots always replace state. Matching component events replace
148
+ * one absolute value, zero SPL removes its mint, and status, pre-initialization,
149
+ * or wrong-wallet events return `ignored` without mutation.
150
+ */
151
+ applyEvent(event) {
152
+ switch (event.event_type) {
153
+ case "wallet_deposit_balance_snapshot":
154
+ // Complete snapshots are authoritative even when their lower
155
+ // cross-component slot trails a previously observed update.
156
+ this.replace(event.wallet_address, event.context_slot, event.balances, event.native_sol_balance);
157
+ return { kind: "applied" };
158
+ case "wallet_deposit_balance_update":
159
+ if (!this.matchesInitializedWallet(event.wallet_address)) {
160
+ return { kind: "ignored" };
161
+ }
162
+ let isZero;
163
+ try {
164
+ isZero = isZeroTokenAmount(event.balance.idle);
165
+ }
166
+ catch {
167
+ return { kind: "rejected" };
168
+ }
169
+ if (isZero) {
170
+ this.balances.delete(event.balance.mint);
171
+ }
172
+ else {
173
+ this.balances.set(event.balance.mint, event.balance);
174
+ }
175
+ this.contextSlot = event.context_slot;
176
+ return { kind: "applied" };
177
+ case "wallet_native_sol_balance_update":
178
+ if (!this.matchesInitializedWallet(event.wallet_address)) {
179
+ return { kind: "ignored" };
180
+ }
181
+ this.nativeSolBalance = event.native_sol_balance;
182
+ this.contextSlot = event.context_slot;
183
+ return { kind: "applied" };
184
+ case "wallet_deposit_balance_status":
185
+ return { kind: "ignored" };
186
+ }
187
+ }
188
+ /**
189
+ * Return exact native SOL plus canonical WSOL with nine fractional digits.
190
+ * Uses arbitrary-width integer arithmetic and never merges the stored assets.
191
+ */
192
+ combinedSolBalance() {
193
+ const native = this.nativeSolLamports();
194
+ const wrapped = this.balances.get(exports.WRAPPED_SOL_MINT);
195
+ const wrappedLamports = wrapped
196
+ ? (0, shared_1.exactScaledInteger)(wrapped.idle, 9)
197
+ : 0n;
198
+ return formatLamports(native + wrappedLamports);
199
+ }
200
+ /** Return exact native and canonical WSOL components for transaction planning. */
201
+ solComponents() {
202
+ let nativeLamports;
203
+ let canonicalWsolLamports;
204
+ try {
205
+ nativeLamports = this.nativeSolLamports();
206
+ canonicalWsolLamports = this.canonicalWsolLamports();
207
+ }
208
+ catch (error) {
209
+ throw error_1.SdkError.validation(`invalid SOL balance component: ${error instanceof Error ? error.message : String(error)}`);
210
+ }
211
+ if (nativeLamports > MAX_SOLANA_LAMPORTS ||
212
+ canonicalWsolLamports > MAX_SOLANA_LAMPORTS) {
213
+ throw error_1.SdkError.validation("SOL component exceeds the transaction u64 range");
214
+ }
215
+ return { nativeLamports, canonicalWsolLamports };
216
+ }
217
+ /** Scale cached native SOL exactly to lamports; requires initialized state. */
218
+ nativeSolLamports() {
219
+ if (this.nativeSolBalance === undefined) {
220
+ throw new Error("wallet balance state is not initialized");
221
+ }
222
+ return (0, shared_1.exactScaledInteger)(this.nativeSolBalance, 9);
223
+ }
224
+ /** Scale the canonical WSOL idle balance exactly to lamports. */
225
+ canonicalWsolLamports() {
226
+ const wrapped = this.balances.get(exports.WRAPPED_SOL_MINT);
227
+ return wrapped ? (0, shared_1.exactScaledInteger)(wrapped.idle, 9) : 0n;
228
+ }
229
+ matchesInitializedWallet(walletAddress) {
230
+ return (this.walletAddress === walletAddress &&
231
+ this.contextSlot !== undefined &&
232
+ this.nativeSolBalance !== undefined);
233
+ }
234
+ replace(walletAddress, contextSlot, balances, nativeSolBalance) {
235
+ // Own the map lifecycle while retaining payload objects by reference. Callers
236
+ // must treat balance records as immutable after handing them to state.
237
+ this.walletAddress = walletAddress;
238
+ this.contextSlot = contextSlot;
239
+ this.balances.clear();
240
+ for (const balance of Object.values(balances)) {
241
+ this.balances.set(balance.mint, balance);
242
+ }
243
+ this.nativeSolBalance = nativeSolBalance;
244
+ }
245
+ }
246
+ exports.WalletDepositBalancesState = WalletDepositBalancesState;
247
+ function formatLamports(value) {
248
+ // Integer division restores fixed-scale SOL text without floating-point loss.
249
+ const scale = 1000000000n;
250
+ const whole = value / scale;
251
+ const fraction = (value % scale).toString().padStart(9, "0");
252
+ return `${whole}.${fraction}`;
253
+ }
254
+ /** Detect explicit zero without imposing SOL's nine-decimal scale on SPL tokens. */
255
+ function isZeroTokenAmount(value) {
256
+ const amount = new decimal_js_1.default(value);
257
+ if (!amount.isFinite() || amount.isNegative()) {
258
+ throw new Error(`invalid deposit-token balance: ${value}`);
259
+ }
260
+ return amount.isZero();
261
+ }
262
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../../src/domain/position/state.ts"],"names":[],"mappings":";;;;;;AAgEA,wDAiDC;AAaD,0EA8CC;AA5KD,4DAAiC;AACjC,uCAAuC;AACvC,yCAAkD;AAQlD;;;;GAIG;AACU,QAAA,gBAAgB,GAC3B,6CAA0D,CAAC;AAE7D,8FAA8F;AACjF,QAAA,0CAA0C,GAAG,QAAU,CAAC;AACrE,yFAAyF;AAC5E,QAAA,0CAA0C,GAA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E;IAC9E,MAAM,KAAK,GAAG,WAAc,CAAC;IAC7B,MAAM,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAC5B,MAAM,QAAQ,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7D,OAAO,GAAG,KAAK,IAAI,QAAQ,EAAE,CAAC;AAChC,CAAC;AAED,oFAAoF;AACpF,SAAS,iBAAiB,CAAC,KAAa;IACtC,MAAM,MAAM,GAAG,IAAI,oBAAO,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,MAAM,CAAC,UAAU,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,EAAE,CAAC;AACzB,CAAC","sourcesContent":["import Decimal from \"decimal.js\";\nimport { SdkError } from \"../../error\";\nimport { exactScaledInteger } from \"../../shared\";\nimport type { PubkeyStr } from \"../../shared\";\nimport type {\n DepositTokenBalance,\n DepositTokenBalancesSnapshot,\n WalletDepositBalancesEvent,\n} from \"./index\";\n\n/**\n * Canonical WSOL mint under Solana's legacy SPL Token Program (“Tokenkeg”).\n * ATA derivation stays pinned to Tokenkeg rather than Token-2022 so state and\n * transaction planning address the protocol's one canonical account.\n */\nexport const WRAPPED_SOL_MINT =\n \"So11111111111111111111111111111111111111112\" as PubkeyStr;\n\n/** Unsponsored native reserve floor, in lamports, when canonical ATA creation is required. */\nexport const SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS = 3_500_000n;\n/** Unsponsored native reserve floor, in lamports, when canonical WSOL already exists. */\nexport const SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS = 1_000_000n;\n/** Maximum exact non-negative lamport value representable by Solana's u64 fields. */\nconst MAX_SOLANA_LAMPORTS = 0xffff_ffff_ffff_ffffn;\n\n/** Exact components behind the single displayed SOL asset. */\nexport interface SolBalanceComponents {\n /** Lamports held by the Trading Wallet system account. */\n nativeLamports: bigint;\n /** Token amount in the Trading Wallet's persistent canonical WSOL ATA. */\n canonicalWsolLamports: bigint;\n}\n\n/**\n * Stores live chain costs used to derive transaction funding requirements.\n *\n * {@link solBalanceAvailability} applies ordinary safety floors.\n * {@link unwrapAllSolBalanceAvailability} rejects account creation, upfront rent,\n * and sponsorship, then uses only `feeLamports` as the unwrap-all reserve.\n */\nexport interface SolActionCosts {\n /** Live `getFeeForMessage` result, in lamports. */\n feeLamports: bigint;\n /** Rent funded up front, even when a temporary account refunds it later. */\n upfrontRentLamports: bigint;\n /** Whether this transaction must create the persistent canonical WSOL ATA. */\n createsCanonicalWsolAccount: boolean;\n /** Exact public sponsorship capability supplied by the caller. */\n sponsored: boolean;\n}\n\n/** Action-specific displayed, reserved, and spendable SOL values. */\nexport interface SolBalanceAvailability {\n /** Separately authoritative native and canonical WSOL balances. */\n components: SolBalanceComponents;\n /** Sum of both components in lamports, before reserve. */\n displayedLamports: bigint;\n /** Native lamports withheld for live costs and any action-specific safety floor. */\n reserveLamports: bigint;\n /** Displayed lamports available to this action after reserve. */\n spendableLamports: bigint;\n}\n\n/** Derive fail-closed availability and type an insufficient native reserve as fee funding. */\nexport function solBalanceAvailability(\n components: SolBalanceComponents,\n costs: SolActionCosts\n): SolBalanceAvailability {\n for (const [label, value] of [\n [\"native SOL\", components.nativeLamports],\n [\"canonical WSOL\", components.canonicalWsolLamports],\n ] as const) {\n if (typeof value !== \"bigint\" || value < 0n || value > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(`${label} must fit the non-negative u64 lamport range`);\n }\n }\n for (const [label, value] of [\n [\"transaction fee\", costs.feeLamports],\n [\"upfront rent\", costs.upfrontRentLamports],\n ] as const) {\n if (typeof value !== \"bigint\" || value < 0n || value > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(`${label} must fit the non-negative u64 lamport range`);\n }\n }\n const displayedLamports =\n components.nativeLamports + components.canonicalWsolLamports;\n if (displayedLamports > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(\"displayed SOL exceeds the transaction u64 range\");\n }\n const liveCosts = costs.feeLamports + costs.upfrontRentLamports;\n if (liveCosts > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(\"combined transaction costs must fit u64 lamports\");\n }\n const floor = costs.createsCanonicalWsolAccount\n ? SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS\n : SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS;\n const reserveLamports = costs.sponsored\n ? 0n\n : liveCosts > floor\n ? liveCosts\n : floor;\n if (components.nativeLamports < reserveLamports) {\n throw SdkError.insufficientSolForTransactionFees(\n components.nativeLamports,\n reserveLamports\n );\n }\n return {\n components,\n displayedLamports,\n reserveLamports,\n spendableLamports: displayedLamports - reserveLamports,\n };\n}\n\n/**\n * Return unwrap-all availability with the live fee as its entire reserve.\n *\n * This function rejects costs that include sponsorship, account creation, or\n * upfront rent. It rejects malformed or out-of-range components and costs. It\n * rejects a displayed-balance sum outside Solana's unsigned 64-bit range. Native\n * SOL must fund the fee without relying on lamports that a later `CloseAccount`\n * instruction may transfer. The ordinary persistent-account floor does not apply\n * because unwrap-all removes that account. An insufficient native fee balance\n * returns the typed transaction-fee error.\n */\nexport function unwrapAllSolBalanceAvailability(\n components: SolBalanceComponents,\n costs: SolActionCosts\n): SolBalanceAvailability {\n for (const [label, value] of [\n [\"native SOL\", components.nativeLamports],\n [\"canonical WSOL\", components.canonicalWsolLamports],\n ] as const) {\n if (typeof value !== \"bigint\" || value < 0n || value > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(`${label} must fit the non-negative u64 lamport range`);\n }\n }\n for (const [label, value] of [\n [\"transaction fee\", costs.feeLamports],\n [\"upfront rent\", costs.upfrontRentLamports],\n ] as const) {\n if (typeof value !== \"bigint\" || value < 0n || value > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(`${label} must fit the non-negative u64 lamport range`);\n }\n }\n if (\n costs.upfrontRentLamports !== 0n ||\n costs.createsCanonicalWsolAccount ||\n costs.sponsored\n ) {\n throw SdkError.validation(\n \"unwrap-all costs must be unsponsored with no upfront rent or account creation\"\n );\n }\n const displayedLamports =\n components.nativeLamports + components.canonicalWsolLamports;\n if (displayedLamports > MAX_SOLANA_LAMPORTS) {\n throw SdkError.validation(\"displayed SOL exceeds the transaction u64 range\");\n }\n if (components.nativeLamports < costs.feeLamports) {\n throw SdkError.insufficientSolForTransactionFees(\n components.nativeLamports,\n costs.feeLamports\n );\n }\n return {\n components,\n displayedLamports,\n reserveLamports: costs.feeLamports,\n spendableLamports: displayedLamports - costs.feeLamports,\n };\n}\n\n/** Whether an event was accepted by, or rejected by, its lifecycle guard. */\nexport type WalletDepositBalancesApplyResult =\n | { kind: \"applied\" }\n | { kind: \"ignored\" }\n | { kind: \"rejected\" };\n\n/**\n * Mutable application-owned wallet balance state.\n *\n * The default instance is uninitialized. A complete REST or WebSocket snapshot\n * establishes its wallet baseline; later component events must match that wallet\n * and carry absolute values. Native SOL never enters the sparse SPL mint map, and\n * complete cross-component snapshots may replace `contextSlot` with a lower slot.\n * Map containers are copied, but mutable balance objects are retained by reference;\n * treat payload entries as immutable after applying them.\n */\nexport class WalletDepositBalancesState {\n /** Wallet owning the current baseline, or `undefined` before initialization. */\n walletAddress: PubkeyStr | undefined;\n /** Slot of the last accepted event, not a globally monotonic stream version. */\n contextSlot: number | undefined;\n /** Sparse mint-keyed SPL balances; explicit zero updates remove their mint. */\n readonly balances = new Map<PubkeyStr, DepositTokenBalance>();\n /** Exact nine-decimal native SOL, separate from `balances`. */\n nativeSolBalance: string | undefined;\n\n /**\n * Initialize or wholesale-replace state from a complete REST snapshot.\n * The caller supplies the wallet omitted by REST; prior slots are not compared.\n * Unlike WebSocket parsing, this TypeScript REST boundary performs no runtime\n * shape validation. Malformed exact values fail when a derived method scales them.\n */\n applyRestSnapshot(\n walletAddress: PubkeyStr,\n snapshot: DepositTokenBalancesSnapshot\n ): WalletDepositBalancesApplyResult {\n this.replace(\n walletAddress,\n snapshot.context_slot,\n snapshot.balances,\n snapshot.native_sol_balance\n );\n return { kind: \"applied\" };\n }\n\n /**\n * Apply the wallet event state machine.\n *\n * Complete snapshots always replace state. Matching component events replace\n * one absolute value, zero SPL removes its mint, and status, pre-initialization,\n * or wrong-wallet events return `ignored` without mutation.\n */\n applyEvent(event: WalletDepositBalancesEvent): WalletDepositBalancesApplyResult {\n switch (event.event_type) {\n case \"wallet_deposit_balance_snapshot\":\n // Complete snapshots are authoritative even when their lower\n // cross-component slot trails a previously observed update.\n this.replace(\n event.wallet_address,\n event.context_slot,\n event.balances,\n event.native_sol_balance\n );\n return { kind: \"applied\" };\n case \"wallet_deposit_balance_update\":\n if (!this.matchesInitializedWallet(event.wallet_address)) {\n return { kind: \"ignored\" };\n }\n let isZero: boolean;\n try {\n isZero = isZeroTokenAmount(event.balance.idle);\n } catch {\n return { kind: \"rejected\" };\n }\n if (isZero) {\n this.balances.delete(event.balance.mint);\n } else {\n this.balances.set(event.balance.mint, event.balance);\n }\n this.contextSlot = event.context_slot;\n return { kind: \"applied\" };\n case \"wallet_native_sol_balance_update\":\n if (!this.matchesInitializedWallet(event.wallet_address)) {\n return { kind: \"ignored\" };\n }\n this.nativeSolBalance = event.native_sol_balance;\n this.contextSlot = event.context_slot;\n return { kind: \"applied\" };\n case \"wallet_deposit_balance_status\":\n return { kind: \"ignored\" };\n }\n }\n\n /**\n * Return exact native SOL plus canonical WSOL with nine fractional digits.\n * Uses arbitrary-width integer arithmetic and never merges the stored assets.\n */\n combinedSolBalance(): string {\n const native = this.nativeSolLamports();\n const wrapped = this.balances.get(WRAPPED_SOL_MINT);\n const wrappedLamports = wrapped\n ? exactScaledInteger(wrapped.idle, 9)\n : 0n;\n return formatLamports(native + wrappedLamports);\n }\n\n /** Return exact native and canonical WSOL components for transaction planning. */\n solComponents(): SolBalanceComponents {\n let nativeLamports: bigint;\n let canonicalWsolLamports: bigint;\n try {\n nativeLamports = this.nativeSolLamports();\n canonicalWsolLamports = this.canonicalWsolLamports();\n } catch (error) {\n throw SdkError.validation(\n `invalid SOL balance component: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n if (\n nativeLamports > MAX_SOLANA_LAMPORTS ||\n canonicalWsolLamports > MAX_SOLANA_LAMPORTS\n ) {\n throw SdkError.validation(\"SOL component exceeds the transaction u64 range\");\n }\n return { nativeLamports, canonicalWsolLamports };\n }\n\n /** Scale cached native SOL exactly to lamports; requires initialized state. */\n nativeSolLamports(): bigint {\n if (this.nativeSolBalance === undefined) {\n throw new Error(\"wallet balance state is not initialized\");\n }\n return exactScaledInteger(this.nativeSolBalance, 9);\n }\n\n /** Scale the canonical WSOL idle balance exactly to lamports. */\n canonicalWsolLamports(): bigint {\n const wrapped = this.balances.get(WRAPPED_SOL_MINT);\n return wrapped ? exactScaledInteger(wrapped.idle, 9) : 0n;\n }\n\n private matchesInitializedWallet(walletAddress: PubkeyStr): boolean {\n return (\n this.walletAddress === walletAddress &&\n this.contextSlot !== undefined &&\n this.nativeSolBalance !== undefined\n );\n }\n\n private replace(\n walletAddress: PubkeyStr,\n contextSlot: number,\n balances: Record<PubkeyStr, DepositTokenBalance>,\n nativeSolBalance: string\n ): void {\n // Own the map lifecycle while retaining payload objects by reference. Callers\n // must treat balance records as immutable after handing them to state.\n this.walletAddress = walletAddress;\n this.contextSlot = contextSlot;\n this.balances.clear();\n for (const balance of Object.values(balances)) {\n this.balances.set(balance.mint, balance);\n }\n this.nativeSolBalance = nativeSolBalance;\n }\n}\n\nfunction formatLamports(value: bigint): string {\n // Integer division restores fixed-scale SOL text without floating-point loss.\n const scale = 1_000_000_000n;\n const whole = value / scale;\n const fraction = (value % scale).toString().padStart(9, \"0\");\n return `${whole}.${fraction}`;\n}\n\n/** Detect explicit zero without imposing SOL's nine-decimal scale on SPL tokens. */\nfunction isZeroTokenAmount(value: string): boolean {\n const amount = new Decimal(value);\n if (!amount.isFinite() || amount.isNegative()) {\n throw new Error(`invalid deposit-token balance: ${value}`);\n }\n return amount.isZero();\n}\n"]}
package/dist/error.d.ts CHANGED
@@ -43,16 +43,22 @@ export declare class AuthError extends Error {
43
43
  readonly variant: AuthErrorVariant;
44
44
  constructor(variant: AuthErrorVariant, message: string);
45
45
  }
46
- export type SdkErrorVariant = "Http" | "Ws" | "Auth" | "Validation" | "Serde" | "MissingMarketContext" | "Signing" | "UserCancelled" | "TransactionFailed" | "TransactionExpired" | "ConfirmationTimeout" | "ApiRejected" | "Program" | "Other";
46
+ export type SdkErrorVariant = "Http" | "Ws" | "Auth" | "Validation" | "InsufficientSolForTransactionFees" | "Serde" | "MissingMarketContext" | "Signing" | "UserCancelled" | "TransactionFailed" | "TransactionExpired" | "ConfirmationTimeout" | "ApiRejected" | "Program" | "Other";
47
47
  export declare class SdkError extends Error {
48
48
  readonly variant: SdkErrorVariant;
49
49
  readonly causeError?: Error;
50
50
  readonly apiRejectedDetails?: ApiRejectedDetails;
51
51
  /** Transaction signature, set on the transaction-confirmation variants. */
52
52
  readonly signature?: string;
53
- constructor(variant: SdkErrorVariant, message: string, causeError?: Error, apiRejectedDetails?: ApiRejectedDetails, signature?: string);
53
+ /** Confirmed Native SOL Balance in the declared fee payer, in lamports. */
54
+ readonly availableLamports?: bigint;
55
+ /** Exact transaction fee or planner-owned reserve required, in lamports. */
56
+ readonly requiredLamports?: bigint;
57
+ constructor(variant: SdkErrorVariant, message: string, causeError?: Error, apiRejectedDetails?: ApiRejectedDetails, signature?: string, availableLamports?: bigint, requiredLamports?: bigint);
54
58
  static from(error: unknown): SdkError;
55
59
  static validation(message: string): SdkError;
60
+ /** Return the typed contract for a proven transaction-fee funding shortfall. */
61
+ static insufficientSolForTransactionFees(availableLamports: bigint, requiredLamports: bigint): SdkError;
56
62
  static serde(message: string): SdkError;
57
63
  static missingMarketContext(message: string): SdkError;
58
64
  static signing(message: string): SdkError;
@@ -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AO,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ;IAIzC,MAAM,CAAC,aAAa,IAAI,QAAQ;IAIhC,MAAM,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,QAAQ;IAUpE,MAAM,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ;IAUtD,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,QAAQ;IAUvD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,QAAQ;CAG1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAatD"}
package/dist/error.js CHANGED
@@ -105,13 +105,19 @@ class SdkError extends Error {
105
105
  apiRejectedDetails;
106
106
  /** Transaction signature, set on the transaction-confirmation variants. */
107
107
  signature;
108
- constructor(variant, message, causeError, apiRejectedDetails, signature) {
108
+ /** Confirmed Native SOL Balance in the declared fee payer, in lamports. */
109
+ availableLamports;
110
+ /** Exact transaction fee or planner-owned reserve required, in lamports. */
111
+ requiredLamports;
112
+ constructor(variant, message, causeError, apiRejectedDetails, signature, availableLamports, requiredLamports) {
109
113
  super(message);
110
114
  this.name = "SdkError";
111
115
  this.variant = variant;
112
116
  this.causeError = causeError;
113
117
  this.apiRejectedDetails = apiRejectedDetails;
114
118
  this.signature = signature;
119
+ this.availableLamports = availableLamports;
120
+ this.requiredLamports = requiredLamports;
115
121
  }
116
122
  static from(error) {
117
123
  if (error instanceof SdkError) {
@@ -148,6 +154,13 @@ class SdkError extends Error {
148
154
  static validation(message) {
149
155
  return new SdkError("Validation", message);
150
156
  }
157
+ /** Return the typed contract for a proven transaction-fee funding shortfall. */
158
+ static insufficientSolForTransactionFees(availableLamports, requiredLamports) {
159
+ if (availableLamports < 0n || requiredLamports < 0n) {
160
+ return SdkError.validation("transaction fee funding values must be non-negative lamports");
161
+ }
162
+ return new SdkError("InsufficientSolForTransactionFees", "Insufficient SOL for transaction fees. Deposit SOL to your wallet and try again.", undefined, undefined, undefined, availableLamports, requiredLamports);
163
+ }
151
164
  static serde(message) {
152
165
  return new SdkError("Serde", message);
153
166
  }
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAoRA,wCAaC;AAjSD,wDAA2D;AAY3D,MAAa,SAAU,SAAQ,KAAK;IACzB,OAAO,CAAmB;IAC1B,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,YAAY,CAAU;IACtB,QAAQ,CAAU;IAE3B,YAAY,MAOX;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAAe;QAC5B,OAAO,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,mBAAmB,OAAO,EAAE,EAAE,CAAC,CAAC;IACtF,CAAC;IAED,MAAM,CAAC,OAAO;QACZ,OAAO,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;IACnE,CAAC;IAED,MAAM,CAAC,YAAY;QACjB,OAAO,IAAI,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;IAC1F,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E,CAAC;QAC9B,IAAI,KAAK,CAAC,OAAO,KAAK,aAAa,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC,kBAAkB,EAAE,UAAU,KAAK,GAAG,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,UAAU,YAAY,SAAS,EAAE,CAAC;YACtE,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,KAAK,cAAc,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { ApiRejectedDetails } from \"./shared/api_response\";\n\nexport type HttpErrorVariant =\n | \"Request\"\n | \"ServerError\"\n | \"RateLimited\"\n | \"Unauthorized\"\n | \"NotFound\"\n | \"BadRequest\"\n | \"Timeout\"\n | \"MaxRetriesExceeded\";\n\nexport class HttpError extends Error {\n readonly variant: HttpErrorVariant;\n readonly status?: number;\n readonly body?: string;\n readonly retryAfterMs?: number;\n readonly attempts?: number;\n\n constructor(params: {\n variant: HttpErrorVariant;\n message: string;\n status?: number;\n body?: string;\n retryAfterMs?: number;\n attempts?: number;\n }) {\n super(params.message);\n this.name = \"HttpError\";\n this.variant = params.variant;\n this.status = params.status;\n this.body = params.body;\n this.retryAfterMs = params.retryAfterMs;\n this.attempts = params.attempts;\n }\n\n static request(message: string): HttpError {\n return new HttpError({ variant: \"Request\", message: `Request failed: ${message}` });\n }\n\n static timeout(): HttpError {\n return new HttpError({ variant: \"Timeout\", message: \"Timeout\" });\n }\n\n static unauthorized(): HttpError {\n return new HttpError({ variant: \"Unauthorized\", message: \"Unauthorized\", status: 401 });\n }\n\n static notFound(body: string): HttpError {\n return new HttpError({\n variant: \"NotFound\",\n message: `Not found: ${body || \"resource\"}`,\n status: 404,\n body,\n });\n }\n\n static badRequest(body: string): HttpError {\n return new HttpError({\n variant: \"BadRequest\",\n message: `Bad request: ${body || \"invalid request\"}`,\n status: 400,\n body,\n });\n }\n\n static rateLimited(retryAfterMs?: number): HttpError {\n return new HttpError({\n variant: \"RateLimited\",\n message:\n retryAfterMs !== undefined\n ? `Rate limited (retry after ${retryAfterMs}ms)`\n : \"Rate limited\",\n status: 429,\n retryAfterMs,\n });\n }\n\n static serverError(status: number, body: string): HttpError {\n return new HttpError({\n variant: \"ServerError\",\n message: `Server error ${status}: ${body}`,\n status,\n body,\n });\n }\n\n /**\n * NOT produced by the SDK's HTTP retry loop. On retry exhaustion the FINAL\n * attempt's error propagates unchanged — structured rejection details,\n * status classification (isUnauthorized etc.), and request id intact —\n * because flattening it into this wrapper's message string would destroy\n * everything callers switch on (see the retry-exhaustion tests). The\n * factory stays public for consumers that build their own retry loops on\n * the raw/no-restore primitives and want a conventional exhaustion error.\n */\n static maxRetriesExceeded(attempts: number, lastError: string): HttpError {\n return new HttpError({\n variant: \"MaxRetriesExceeded\",\n message: `Max retries exceeded after ${attempts} attempts: ${lastError}`,\n attempts,\n });\n }\n}\n\nexport type WsErrorVariant =\n | \"NotConnected\"\n | \"ConnectionFailed\"\n | \"SendFailed\"\n | \"DeserializationError\"\n | \"ProtocolError\"\n | \"Closed\";\n\nexport class WsError extends Error {\n readonly variant: WsErrorVariant;\n readonly code?: number;\n\n constructor(variant: WsErrorVariant, message: string, code?: number) {\n super(message);\n this.name = \"WsError\";\n this.variant = variant;\n this.code = code;\n }\n}\n\nexport type AuthErrorVariant =\n | \"NotAuthenticated\"\n | \"LoginFailed\"\n | \"SignatureVerificationFailed\"\n | \"TokenExpired\";\n\nexport class AuthError extends Error {\n readonly variant: AuthErrorVariant;\n\n constructor(variant: AuthErrorVariant, message: string) {\n super(message);\n this.name = \"AuthError\";\n this.variant = variant;\n }\n}\n\nexport type SdkErrorVariant =\n | \"Http\"\n | \"Ws\"\n | \"Auth\"\n | \"Validation\"\n | \"Serde\"\n | \"MissingMarketContext\"\n | \"Signing\"\n | \"UserCancelled\"\n | \"TransactionFailed\"\n | \"TransactionExpired\"\n | \"ConfirmationTimeout\"\n | \"ApiRejected\"\n | \"Program\"\n | \"Other\";\n\nexport class SdkError extends Error {\n readonly variant: SdkErrorVariant;\n readonly causeError?: Error;\n readonly apiRejectedDetails?: ApiRejectedDetails;\n /** Transaction signature, set on the transaction-confirmation variants. */\n readonly signature?: string;\n\n constructor(\n variant: SdkErrorVariant,\n message: string,\n causeError?: Error,\n apiRejectedDetails?: ApiRejectedDetails,\n signature?: string\n ) {\n super(message);\n this.name = \"SdkError\";\n this.variant = variant;\n this.causeError = causeError;\n this.apiRejectedDetails = apiRejectedDetails;\n this.signature = signature;\n }\n\n static from(error: unknown): SdkError {\n if (error instanceof SdkError) {\n return error;\n }\n if (error instanceof ApiRejectedDetails) {\n return SdkError.apiRejected(error);\n }\n if (error instanceof HttpError) {\n return new SdkError(\"Http\", error.message, error);\n }\n if (error instanceof WsError) {\n return new SdkError(\"Ws\", error.message, error);\n }\n if (error instanceof AuthError) {\n return new SdkError(\"Auth\", error.message, error);\n }\n if (error instanceof SyntaxError) {\n return new SdkError(\"Serde\", error.message, error);\n }\n // ProgramSdkError is imported lazily to avoid circular deps;\n // duck-type check on .name instead.\n if (error instanceof Error && error.name === \"ProgramSdkError\") {\n return new SdkError(\"Program\", error.message, error);\n }\n if (error instanceof Error) {\n return new SdkError(\"Other\", error.message, error);\n }\n if (typeof error === \"object\" && error !== null) {\n return new SdkError(\"Other\", JSON.stringify(error));\n }\n return new SdkError(\"Other\", String(error));\n }\n\n static validation(message: string): SdkError {\n return new SdkError(\"Validation\", message);\n }\n\n static serde(message: string): SdkError {\n return new SdkError(\"Serde\", message);\n }\n\n static missingMarketContext(message: string): SdkError {\n return new SdkError(\"MissingMarketContext\", message);\n }\n\n static signing(message: string): SdkError {\n return new SdkError(\"Signing\", message);\n }\n\n static userCancelled(): SdkError {\n return new SdkError(\"UserCancelled\", \"User cancelled signing\");\n }\n\n static transactionFailed(signature: string, error: string): SdkError {\n return new SdkError(\n \"TransactionFailed\",\n `Transaction ${signature} failed on-chain: ${error}`,\n undefined,\n undefined,\n signature\n );\n }\n\n static transactionExpired(signature: string): SdkError {\n return new SdkError(\n \"TransactionExpired\",\n `Transaction ${signature} expired before confirmation — it was never processed and is safe to resubmit`,\n undefined,\n undefined,\n signature\n );\n }\n\n static confirmationTimeout(signature: string): SdkError {\n return new SdkError(\n \"ConfirmationTimeout\",\n `Timed out confirming transaction ${signature} — status unknown; check the signature on-chain before resubmitting`,\n undefined,\n undefined,\n signature\n );\n }\n\n static apiRejected(details: ApiRejectedDetails): SdkError {\n return new SdkError(\"ApiRejected\", details.toString(), undefined, details);\n }\n}\n\n/**\n * True when the backend rejected a request as unauthenticated (HTTP 401) —\n * either a bare 401 (`HttpError` with variant `Unauthorized`) or a 401 that\n * carried a structured rejection envelope (`SdkError` `ApiRejected` with an\n * `httpStatus` of 401). Lets callers decide whether refreshing credentials\n * and retrying makes sense without matching on backend error strings.\n * Accepts `unknown` because the transport surfaces both `HttpError` and\n * `SdkError` to callers.\n */\nexport function isUnauthorized(error: unknown): boolean {\n if (error instanceof HttpError) {\n return error.variant === \"Unauthorized\";\n }\n if (error instanceof SdkError) {\n if (error.variant === \"ApiRejected\") {\n return error.apiRejectedDetails?.httpStatus === 401;\n }\n if (error.variant === \"Http\" && error.causeError instanceof HttpError) {\n return error.causeError.variant === \"Unauthorized\";\n }\n }\n return false;\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAkTA,wCAaC;AA/TD,wDAA2D;AAY3D,MAAa,SAAU,SAAQ,KAAK;IACzB,OAAO,CAAmB;IAC1B,MAAM,CAAU;IAChB,IAAI,CAAU;IACd,YAAY,CAAU;IACtB,QAAQ,CAAU;IAE3B,YAAY,MAOX;QACC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAA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AAa,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC,kBAAkB,EAAE,UAAU,KAAK,GAAG,CAAC;QACtD,CAAC;QACD,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,UAAU,YAAY,SAAS,EAAE,CAAC;YACtE,OAAO,KAAK,CAAC,UAAU,CAAC,OAAO,KAAK,cAAc,CAAC;QACrD,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { ApiRejectedDetails } from \"./shared/api_response\";\n\nexport type HttpErrorVariant =\n | \"Request\"\n | \"ServerError\"\n | \"RateLimited\"\n | \"Unauthorized\"\n | \"NotFound\"\n | \"BadRequest\"\n | \"Timeout\"\n | \"MaxRetriesExceeded\";\n\nexport class HttpError extends Error {\n readonly variant: HttpErrorVariant;\n readonly status?: number;\n readonly body?: string;\n readonly retryAfterMs?: number;\n readonly attempts?: number;\n\n constructor(params: {\n variant: HttpErrorVariant;\n message: string;\n status?: number;\n body?: string;\n retryAfterMs?: number;\n attempts?: number;\n }) {\n super(params.message);\n this.name = \"HttpError\";\n this.variant = params.variant;\n this.status = params.status;\n this.body = params.body;\n this.retryAfterMs = params.retryAfterMs;\n this.attempts = params.attempts;\n }\n\n static request(message: string): HttpError {\n return new HttpError({ variant: \"Request\", message: `Request failed: ${message}` });\n }\n\n static timeout(): HttpError {\n return new HttpError({ variant: \"Timeout\", message: \"Timeout\" });\n }\n\n static unauthorized(): HttpError {\n return new HttpError({ variant: \"Unauthorized\", message: \"Unauthorized\", status: 401 });\n }\n\n static notFound(body: string): HttpError {\n return new HttpError({\n variant: \"NotFound\",\n message: `Not found: ${body || \"resource\"}`,\n status: 404,\n body,\n });\n }\n\n static badRequest(body: string): HttpError {\n return new HttpError({\n variant: \"BadRequest\",\n message: `Bad request: ${body || \"invalid request\"}`,\n status: 400,\n body,\n });\n }\n\n static rateLimited(retryAfterMs?: number): HttpError {\n return new HttpError({\n variant: \"RateLimited\",\n message:\n retryAfterMs !== undefined\n ? `Rate limited (retry after ${retryAfterMs}ms)`\n : \"Rate limited\",\n status: 429,\n retryAfterMs,\n });\n }\n\n static serverError(status: number, body: string): HttpError {\n return new HttpError({\n variant: \"ServerError\",\n message: `Server error ${status}: ${body}`,\n status,\n body,\n });\n }\n\n /**\n * NOT produced by the SDK's HTTP retry loop. On retry exhaustion the FINAL\n * attempt's error propagates unchanged — structured rejection details,\n * status classification (isUnauthorized etc.), and request id intact —\n * because flattening it into this wrapper's message string would destroy\n * everything callers switch on (see the retry-exhaustion tests). The\n * factory stays public for consumers that build their own retry loops on\n * the raw/no-restore primitives and want a conventional exhaustion error.\n */\n static maxRetriesExceeded(attempts: number, lastError: string): HttpError {\n return new HttpError({\n variant: \"MaxRetriesExceeded\",\n message: `Max retries exceeded after ${attempts} attempts: ${lastError}`,\n attempts,\n });\n }\n}\n\nexport type WsErrorVariant =\n | \"NotConnected\"\n | \"ConnectionFailed\"\n | \"SendFailed\"\n | \"DeserializationError\"\n | \"ProtocolError\"\n | \"Closed\";\n\nexport class WsError extends Error {\n readonly variant: WsErrorVariant;\n readonly code?: number;\n\n constructor(variant: WsErrorVariant, message: string, code?: number) {\n super(message);\n this.name = \"WsError\";\n this.variant = variant;\n this.code = code;\n }\n}\n\nexport type AuthErrorVariant =\n | \"NotAuthenticated\"\n | \"LoginFailed\"\n | \"SignatureVerificationFailed\"\n | \"TokenExpired\";\n\nexport class AuthError extends Error {\n readonly variant: AuthErrorVariant;\n\n constructor(variant: AuthErrorVariant, message: string) {\n super(message);\n this.name = \"AuthError\";\n this.variant = variant;\n }\n}\n\nexport type SdkErrorVariant =\n | \"Http\"\n | \"Ws\"\n | \"Auth\"\n | \"Validation\"\n | \"InsufficientSolForTransactionFees\"\n | \"Serde\"\n | \"MissingMarketContext\"\n | \"Signing\"\n | \"UserCancelled\"\n | \"TransactionFailed\"\n | \"TransactionExpired\"\n | \"ConfirmationTimeout\"\n | \"ApiRejected\"\n | \"Program\"\n | \"Other\";\n\nexport class SdkError extends Error {\n readonly variant: SdkErrorVariant;\n readonly causeError?: Error;\n readonly apiRejectedDetails?: ApiRejectedDetails;\n /** Transaction signature, set on the transaction-confirmation variants. */\n readonly signature?: string;\n /** Confirmed Native SOL Balance in the declared fee payer, in lamports. */\n readonly availableLamports?: bigint;\n /** Exact transaction fee or planner-owned reserve required, in lamports. */\n readonly requiredLamports?: bigint;\n\n constructor(\n variant: SdkErrorVariant,\n message: string,\n causeError?: Error,\n apiRejectedDetails?: ApiRejectedDetails,\n signature?: string,\n availableLamports?: bigint,\n requiredLamports?: bigint\n ) {\n super(message);\n this.name = \"SdkError\";\n this.variant = variant;\n this.causeError = causeError;\n this.apiRejectedDetails = apiRejectedDetails;\n this.signature = signature;\n this.availableLamports = availableLamports;\n this.requiredLamports = requiredLamports;\n }\n\n static from(error: unknown): SdkError {\n if (error instanceof SdkError) {\n return error;\n }\n if (error instanceof ApiRejectedDetails) {\n return SdkError.apiRejected(error);\n }\n if (error instanceof HttpError) {\n return new SdkError(\"Http\", error.message, error);\n }\n if (error instanceof WsError) {\n return new SdkError(\"Ws\", error.message, error);\n }\n if (error instanceof AuthError) {\n return new SdkError(\"Auth\", error.message, error);\n }\n if (error instanceof SyntaxError) {\n return new SdkError(\"Serde\", error.message, error);\n }\n // ProgramSdkError is imported lazily to avoid circular deps;\n // duck-type check on .name instead.\n if (error instanceof Error && error.name === \"ProgramSdkError\") {\n return new SdkError(\"Program\", error.message, error);\n }\n if (error instanceof Error) {\n return new SdkError(\"Other\", error.message, error);\n }\n if (typeof error === \"object\" && error !== null) {\n return new SdkError(\"Other\", JSON.stringify(error));\n }\n return new SdkError(\"Other\", String(error));\n }\n\n static validation(message: string): SdkError {\n return new SdkError(\"Validation\", message);\n }\n\n /** Return the typed contract for a proven transaction-fee funding shortfall. */\n static insufficientSolForTransactionFees(\n availableLamports: bigint,\n requiredLamports: bigint\n ): SdkError {\n if (availableLamports < 0n || requiredLamports < 0n) {\n return SdkError.validation(\n \"transaction fee funding values must be non-negative lamports\"\n );\n }\n return new SdkError(\n \"InsufficientSolForTransactionFees\",\n \"Insufficient SOL for transaction fees. Deposit SOL to your wallet and try again.\",\n undefined,\n undefined,\n undefined,\n availableLamports,\n requiredLamports\n );\n }\n\n static serde(message: string): SdkError {\n return new SdkError(\"Serde\", message);\n }\n\n static missingMarketContext(message: string): SdkError {\n return new SdkError(\"MissingMarketContext\", message);\n }\n\n static signing(message: string): SdkError {\n return new SdkError(\"Signing\", message);\n }\n\n static userCancelled(): SdkError {\n return new SdkError(\"UserCancelled\", \"User cancelled signing\");\n }\n\n static transactionFailed(signature: string, error: string): SdkError {\n return new SdkError(\n \"TransactionFailed\",\n `Transaction ${signature} failed on-chain: ${error}`,\n undefined,\n undefined,\n signature\n );\n }\n\n static transactionExpired(signature: string): SdkError {\n return new SdkError(\n \"TransactionExpired\",\n `Transaction ${signature} expired before confirmation — it was never processed and is safe to resubmit`,\n undefined,\n undefined,\n signature\n );\n }\n\n static confirmationTimeout(signature: string): SdkError {\n return new SdkError(\n \"ConfirmationTimeout\",\n `Timed out confirming transaction ${signature} — status unknown; check the signature on-chain before resubmitting`,\n undefined,\n undefined,\n signature\n );\n }\n\n static apiRejected(details: ApiRejectedDetails): SdkError {\n return new SdkError(\"ApiRejected\", details.toString(), undefined, details);\n }\n}\n\n/**\n * True when the backend rejected a request as unauthenticated (HTTP 401) —\n * either a bare 401 (`HttpError` with variant `Unauthorized`) or a 401 that\n * carried a structured rejection envelope (`SdkError` `ApiRejected` with an\n * `httpStatus` of 401). Lets callers decide whether refreshing credentials\n * and retrying makes sense without matching on backend error strings.\n * Accepts `unknown` because the transport surfaces both `HttpError` and\n * `SdkError` to callers.\n */\nexport function isUnauthorized(error: unknown): boolean {\n if (error instanceof HttpError) {\n return error.variant === \"Unauthorized\";\n }\n if (error instanceof SdkError) {\n if (error.variant === \"ApiRejected\") {\n return error.apiRejectedDetails?.httpStatus === 401;\n }\n if (error.variant === \"Http\" && error.causeError instanceof HttpError) {\n return error.causeError.variant === \"Unauthorized\";\n }\n }\n return false;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -13,10 +13,11 @@ export * as http from "./http";
13
13
  export * as ws from "./ws";
14
14
  export { LightconeClient, LightconeClientBuilder } from "./client";
15
15
  export { Rpc } from "./rpc";
16
+ export type { CanonicalWsolAccountInfo } from "./rpc";
16
17
  export type { ClientContext, ConfirmedTransaction } from "./context";
17
- export { requireConnection, requireSigningStrategy, resolveDepositSource, signAndSubmitTx, signAndSubmitTxConfirmed, signAndSubmitTxConfirmedWithSlot, } from "./context";
18
- export type { AuthCredentials, AuthMethod, ChainType, GoogleAccountData, PrivyEmbeddedWallet, SessionResponse, User, UserIdentity, UserPrivyData, XAccountData, } from "./auth";
19
- export { avatarUrl, displayName, identityText, tradingWallet, userPrivy, userXAccount, walletDisplayName, } from "./auth";
18
+ export { requireConnection, requireSigningStrategy, resolveDepositSource, signAndSubmitTx, signAndSubmitTxConfirmed, signAndSubmitTxConfirmedWithSlot, signAndSubmitPreparedTxConfirmedWithSlot, } from "./context";
19
+ export type { AuthCredentials, AuthMethod, ChainType, EmailAccountData, GoogleAccountData, LinkedIdentity, LinkedIdentitySelector, LinkedIdentityType, MaxSlippagePreferenceBody, PrivyEmbeddedWallet, RegisterPrivyConflict, RegisterPrivyRequest, SessionResponse, User, UserIdentity, UserPrivyData, XAccountData, } from "./auth";
20
+ export { avatarUrl, classifyRegisterPrivyConflict, displayName, identityText, tradingWallet, userPrivy, userXAccount, walletDisplayName, } from "./auth";
20
21
  export type { FavoriteMarkets, FavoriteMarketUpdate, GlobalDepositAssetsResult, MarketsClient, MarketsResult, MetricsClient, OrdersClient, OrderbooksClient, PositionsClient, PriceHistorySubClient, ReferralsClient, TradesClient, } from "./prelude";
21
22
  export * from "./prelude";
22
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;A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AAe,EACf,qBAAqB,EACrB,eAAe,EACf,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,cAAc,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -39,7 +39,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
39
39
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
40
40
  };
41
41
  Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.walletDisplayName = exports.userXAccount = exports.userPrivy = exports.tradingWallet = exports.identityText = exports.displayName = exports.avatarUrl = exports.signAndSubmitTxConfirmedWithSlot = exports.signAndSubmitTxConfirmed = exports.signAndSubmitTx = exports.resolveDepositSource = exports.requireSigningStrategy = exports.requireConnection = exports.Rpc = exports.LightconeClientBuilder = exports.LightconeClient = exports.ws = exports.http = exports.privy = exports.auth = exports.program = exports.domain = exports.shared = void 0;
42
+ exports.walletDisplayName = exports.userXAccount = exports.userPrivy = exports.tradingWallet = exports.identityText = exports.displayName = exports.classifyRegisterPrivyConflict = exports.avatarUrl = exports.signAndSubmitPreparedTxConfirmedWithSlot = exports.signAndSubmitTxConfirmedWithSlot = exports.signAndSubmitTxConfirmed = exports.signAndSubmitTx = exports.resolveDepositSource = exports.requireSigningStrategy = exports.requireConnection = exports.Rpc = exports.LightconeClientBuilder = exports.LightconeClient = exports.ws = exports.http = exports.privy = exports.auth = exports.program = exports.domain = exports.shared = void 0;
43
43
  // Layer 1: Core
44
44
  exports.shared = __importStar(require("./shared"));
45
45
  exports.domain = __importStar(require("./domain"));
@@ -67,8 +67,10 @@ Object.defineProperty(exports, "resolveDepositSource", { enumerable: true, get:
67
67
  Object.defineProperty(exports, "signAndSubmitTx", { enumerable: true, get: function () { return context_1.signAndSubmitTx; } });
68
68
  Object.defineProperty(exports, "signAndSubmitTxConfirmed", { enumerable: true, get: function () { return context_1.signAndSubmitTxConfirmed; } });
69
69
  Object.defineProperty(exports, "signAndSubmitTxConfirmedWithSlot", { enumerable: true, get: function () { return context_1.signAndSubmitTxConfirmedWithSlot; } });
70
+ Object.defineProperty(exports, "signAndSubmitPreparedTxConfirmedWithSlot", { enumerable: true, get: function () { return context_1.signAndSubmitPreparedTxConfirmedWithSlot; } });
70
71
  var auth_1 = require("./auth");
71
72
  Object.defineProperty(exports, "avatarUrl", { enumerable: true, get: function () { return auth_1.avatarUrl; } });
73
+ Object.defineProperty(exports, "classifyRegisterPrivyConflict", { enumerable: true, get: function () { return auth_1.classifyRegisterPrivyConflict; } });
72
74
  Object.defineProperty(exports, "displayName", { enumerable: true, get: function () { return auth_1.displayName; } });
73
75
  Object.defineProperty(exports, "identityText", { enumerable: true, get: function () { return auth_1.identityText; } });
74
76
  Object.defineProperty(exports, "tradingWallet", { enumerable: true, get: function () { return auth_1.tradingWallet; } });
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gBAAgB;AAChB,mDAAmC;AACnC,mDAAmC;AACnC,qDAAqC;AACrC,0CAAwB;AACxB,wCAAsB;AACtB,4CAA0B;AAE1B,wBAAwB;AACxB,+CAA+B;AAC/B,iDAAiC;AAEjC,gBAAgB;AAChB,+CAA+B;AAE/B,qBAAqB;AACrB,2CAA2B;AAE3B,6BAA6B;AAC7B,mCAAmE;AAA1D,yGAAA,eAAe,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAChD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AAEZ,qCAOmB;AANjB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,+GAAA,oBAAoB,OAAA;AACpB,0GAAA,eAAe,OAAA;AACf,mHAAA,wBAAwB,OAAA;AACxB,2HAAA,gCAAgC,OAAA;AAgBlC,+BAQgB;AAPd,iGAAA,SAAS,OAAA;AACT,mGAAA,WAAW,OAAA;AACX,oGAAA,YAAY,OAAA;AACZ,qGAAA,aAAa,OAAA;AACb,iGAAA,SAAS,OAAA;AACT,oGAAA,YAAY,OAAA;AACZ,yGAAA,iBAAiB,OAAA;AAkBnB,4CAA0B","sourcesContent":["/**\n * Lightcone SDK v2 - TypeScript implementation mirroring Rust SDK v2 layers.\n */\n\n// Layer 1: Core\nexport * as shared from \"./shared\";\nexport * as domain from \"./domain\";\nexport * as program from \"./program\";\nexport * from \"./error\";\nexport * from \"./env\";\nexport * from \"./network\";\n\n// Layer 2: Auth + Privy\nexport * as auth from \"./auth\";\nexport * as privy from \"./privy\";\n\n// Layer 3: HTTP\nexport * as http from \"./http\";\n\n// Layer 4: WebSocket\nexport * as ws from \"./ws\";\n\n// Layer 5: High-level client\nexport { LightconeClient, LightconeClientBuilder } from \"./client\";\nexport { Rpc } from \"./rpc\";\nexport type { ClientContext, ConfirmedTransaction } from \"./context\";\nexport {\n requireConnection,\n requireSigningStrategy,\n resolveDepositSource,\n signAndSubmitTx,\n signAndSubmitTxConfirmed,\n signAndSubmitTxConfirmedWithSlot,\n} from \"./context\";\n\n// Convenience top-level type exports\nexport type {\n AuthCredentials,\n AuthMethod,\n ChainType,\n GoogleAccountData,\n PrivyEmbeddedWallet,\n SessionResponse,\n User,\n UserIdentity,\n UserPrivyData,\n XAccountData,\n} from \"./auth\";\nexport {\n avatarUrl,\n displayName,\n identityText,\n tradingWallet,\n userPrivy,\n userXAccount,\n walletDisplayName,\n} from \"./auth\";\n\nexport type {\n FavoriteMarkets,\n FavoriteMarketUpdate,\n GlobalDepositAssetsResult,\n MarketsClient,\n MarketsResult,\n MetricsClient,\n OrdersClient,\n OrderbooksClient,\n PositionsClient,\n PriceHistorySubClient,\n ReferralsClient,\n TradesClient,\n} from \"./prelude\";\n\nexport * from \"./prelude\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,gBAAgB;AAChB,mDAAmC;AACnC,mDAAmC;AACnC,qDAAqC;AACrC,0CAAwB;AACxB,wCAAsB;AACtB,4CAA0B;AAE1B,wBAAwB;AACxB,+CAA+B;AAC/B,iDAAiC;AAEjC,gBAAgB;AAChB,+CAA+B;AAE/B,qBAAqB;AACrB,2CAA2B;AAE3B,6BAA6B;AAC7B,mCAAmE;AAA1D,yGAAA,eAAe,OAAA;AAAE,gHAAA,sBAAsB,OAAA;AAChD,6BAA4B;AAAnB,0FAAA,GAAG,OAAA;AAGZ,qCAQmB;AAPjB,4GAAA,iBAAiB,OAAA;AACjB,iHAAA,sBAAsB,OAAA;AACtB,+GAAA,oBAAoB,OAAA;AACpB,0GAAA,eAAe,OAAA;AACf,mHAAA,wBAAwB,OAAA;AACxB,2HAAA,gCAAgC,OAAA;AAChC,mIAAA,wCAAwC,OAAA;AAuB1C,+BASgB;AARd,iGAAA,SAAS,OAAA;AACT,qHAAA,6BAA6B,OAAA;AAC7B,mGAAA,WAAW,OAAA;AACX,oGAAA,YAAY,OAAA;AACZ,qGAAA,aAAa,OAAA;AACb,iGAAA,SAAS,OAAA;AACT,oGAAA,YAAY,OAAA;AACZ,yGAAA,iBAAiB,OAAA;AAkBnB,4CAA0B","sourcesContent":["/**\n * Lightcone SDK v2 - TypeScript implementation mirroring Rust SDK v2 layers.\n */\n\n// Layer 1: Core\nexport * as shared from \"./shared\";\nexport * as domain from \"./domain\";\nexport * as program from \"./program\";\nexport * from \"./error\";\nexport * from \"./env\";\nexport * from \"./network\";\n\n// Layer 2: Auth + Privy\nexport * as auth from \"./auth\";\nexport * as privy from \"./privy\";\n\n// Layer 3: HTTP\nexport * as http from \"./http\";\n\n// Layer 4: WebSocket\nexport * as ws from \"./ws\";\n\n// Layer 5: High-level client\nexport { LightconeClient, LightconeClientBuilder } from \"./client\";\nexport { Rpc } from \"./rpc\";\nexport type { CanonicalWsolAccountInfo } from \"./rpc\";\nexport type { ClientContext, ConfirmedTransaction } from \"./context\";\nexport {\n requireConnection,\n requireSigningStrategy,\n resolveDepositSource,\n signAndSubmitTx,\n signAndSubmitTxConfirmed,\n signAndSubmitTxConfirmedWithSlot,\n signAndSubmitPreparedTxConfirmedWithSlot,\n} from \"./context\";\n\n// Convenience top-level type exports\nexport type {\n AuthCredentials,\n AuthMethod,\n ChainType,\n EmailAccountData,\n GoogleAccountData,\n LinkedIdentity,\n LinkedIdentitySelector,\n LinkedIdentityType,\n MaxSlippagePreferenceBody,\n PrivyEmbeddedWallet,\n RegisterPrivyConflict,\n RegisterPrivyRequest,\n SessionResponse,\n User,\n UserIdentity,\n UserPrivyData,\n XAccountData,\n} from \"./auth\";\nexport {\n avatarUrl,\n classifyRegisterPrivyConflict,\n displayName,\n identityText,\n tradingWallet,\n userPrivy,\n userXAccount,\n walletDisplayName,\n} from \"./auth\";\n\nexport type {\n FavoriteMarkets,\n FavoriteMarketUpdate,\n GlobalDepositAssetsResult,\n MarketsClient,\n MarketsResult,\n MetricsClient,\n OrdersClient,\n OrderbooksClient,\n PositionsClient,\n PriceHistorySubClient,\n ReferralsClient,\n TradesClient,\n} from \"./prelude\";\n\nexport * from \"./prelude\";\n"]}
package/dist/prelude.d.ts CHANGED
@@ -3,6 +3,7 @@ export { SdkError } from "./error";
3
3
  export { LightconeEnv, apiUrl, wsUrl, rpcUrl, programId } from "./env";
4
4
  export { LightconeClient, LightconeClientBuilder, } from "./client";
5
5
  export { Rpc } from "./rpc";
6
+ export type { CanonicalWsolAccountInfo } from "./rpc";
6
7
  export type { ClientContext } from "./context";
7
8
  export { Auth } from "./auth";
8
9
  export { Markets } from "./domain/market";
@@ -27,17 +28,17 @@ export { OrderbookState } from "./domain/orderbook/state";
27
28
  export type { OrderbookApplyResult, OrderbookRefreshReason, } from "./domain/orderbook/state";
28
29
  export type { CancelAllBody, CancelAllSuccess, CancelBody, CancelSuccess, ConditionalBalance, FillInfo, GlobalDepositUpdate, NonceUpdate, LimitOrder, OrderEvent, OrderStatus, OrderType, SubmitOrderResponse, SubmitOrderStatus, UserBalanceUpdate, UserDepositAssetBalance, UserMarketBalance, UserOutcomeBalance, UserSnapshotOrder, UserOrdersResponse, UserUpdate, } from "./domain/order";
29
30
  export type { UserOpenLimitOrders } from "./domain/order/state";
30
- export type { Portfolio, Position, PositionOutcome, WalletHolding, TokenBalance, TokenBalanceComputedBase, TokenBalanceTokenType, DepositAssetMetadata, DepositTokenBalance, DepositTokenBalancesSnapshot, } from "./domain/position";
31
- export { DepositBuilder, WithdrawBuilder, RedeemWinningsBuilder, WithdrawFromPositionBuilder, InitPositionTokensBuilder, ExtendPositionTokensBuilder, DepositToGlobalBuilder, WithdrawFromGlobalBuilder, GlobalToMarketDepositBuilder, } from "./domain/position";
31
+ export type { Portfolio, Position, PositionOutcome, WalletHolding, TokenBalance, TokenBalanceComputedBase, TokenBalanceTokenType, DepositAssetMetadata, DepositTokenBalance, DepositTokenBalancesSnapshot, WalletDepositBalanceSnapshot, WalletDepositBalanceStatus, WalletDepositBalanceStatusEvent, WalletDepositBalancesApplyResult, WalletDepositBalancesEvent, WalletDepositBalanceUpdate, WalletNativeSolBalanceUpdate, SolActionCosts, SolActionKind, SolActionPlan, SolBalanceAvailability, SolBalanceComponents, SolComponentDelta, } from "./domain/position";
32
+ export { DepositBuilder, WithdrawBuilder, RedeemWinningsBuilder, WithdrawFromPositionBuilder, InitPositionTokensBuilder, ExtendPositionTokensBuilder, DepositToGlobalBuilder, WithdrawFromGlobalBuilder, GlobalToMarketDepositBuilder, WalletDepositBalancesState, WRAPPED_SOL_MINT, nativeWithdrawSeed, solBalanceAvailability, unwrapAllSolBalanceAvailability, SOL_RESERVE_WITH_ACCOUNT_CREATION_LAMPORTS, SOL_RESERVE_WITH_EXISTING_ACCOUNT_LAMPORTS, } from "./domain/position";
32
33
  export type { Trade, WsTrade } from "./domain/trade";
33
34
  export { TradeHistory } from "./domain/trade/state";
34
35
  export type { DepositPrice, DepositPriceCandleUpdate, DepositPriceHistoryQuery, DepositPriceKey, DepositPriceSnapshot, DepositPriceTick, DepositTokenCandle, DepositTokenPriceHistoryResponse, DepositAssetPriceEvent, DepositAssetPriceSnapshot, DepositAssetPriceTick, DepositAssetPricesSnapshotResponse, LineData, MidpointPriceCandle, OhlcvPriceCandle, OrderbookPriceHistoryQuery, OrderbookPriceHistoryResponse, PriceCandle, PriceHistory, PriceHistoryRestResponse, PriceHistorySnapshot, PriceHistoryUpdate, } from "./domain/price_history";
35
36
  export { DepositPriceState, PriceHistoryState } from "./domain/price_history";
36
- export type { AuthCredentials, AuthMethod, ChainType, GoogleAccountData, PrivyEmbeddedWallet, SessionResponse, User, UserIdentity, UserPrivyData, XAccountData, } from "./auth";
37
- export { avatarUrl, displayName, identityText, tradingWallet, userPrivy, userXAccount } from "./auth";
37
+ export type { AuthCredentials, AuthMethod, ChainType, EmailAccountData, GoogleAccountData, LinkedIdentity, LinkedIdentitySelector, LinkedIdentityType, MaxSlippagePreferenceBody, PrivyEmbeddedWallet, RegisterPrivyConflict, RegisterPrivyRequest, SessionResponse, User, UserIdentity, UserPrivyData, XAccountData, } from "./auth";
38
+ export { avatarUrl, classifyRegisterPrivyConflict, displayName, identityText, tradingWallet, userPrivy, userXAccount, } from "./auth";
38
39
  export { LimitOrderEnvelope, type OrderEnvelope, type OrderPayload, } from "./program";
39
40
  export type { ExportWalletRequest, ExportWalletResponse, PrivyOrderEnvelope, SignAndSendOrderRequest, SignAndSendTxRequest, SignAndSendTxResponse, } from "./privy";
40
- export { isUserCancellation, type ExternalSigner, type SigningStrategy, } from "./shared/signing";
41
+ export { isUserCancellation, requireNativeSigningStrategy, type ExternalSigner, type NativeSigningStrategy, type SigningStrategy, } from "./shared/signing";
41
42
  export { MergeBuilder, } from "./domain/position";
42
43
  export type { Notification, NotificationKind, MarketResolvedData, OrderFilledData, MarketData, } from "./domain/notification";
43
44
  export type { RedeemResult, ReferralCodeInfo, ReferralStatus, } from "./domain/referral";
@@ -1 +1 @@
1
- {"version":3,"file":"prelude.d.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