@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.
- package/README.md +150 -3
- package/dist/auth/client.d.ts +17 -1
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +68 -0
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +57 -5
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +26 -5
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +23 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +38 -2
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +23 -2
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +238 -17
- package/dist/context.js.map +1 -1
- package/dist/domain/market/outcome.d.ts +9 -3
- package/dist/domain/market/outcome.d.ts.map +1 -1
- package/dist/domain/market/outcome.js +10 -7
- package/dist/domain/market/outcome.js.map +1 -1
- package/dist/domain/market/wire.d.ts +3 -3
- package/dist/domain/market/wire.d.ts.map +1 -1
- package/dist/domain/market/wire.js.map +1 -1
- package/dist/domain/orderbook/wire.d.ts +5 -0
- package/dist/domain/orderbook/wire.d.ts.map +1 -1
- package/dist/domain/orderbook/wire.js.map +1 -1
- package/dist/domain/position/client.d.ts +160 -4
- package/dist/domain/position/client.d.ts.map +1 -1
- package/dist/domain/position/client.js +592 -4
- package/dist/domain/position/client.js.map +1 -1
- package/dist/domain/position/index.d.ts +54 -3
- package/dist/domain/position/index.d.ts.map +1 -1
- package/dist/domain/position/index.js +1 -0
- package/dist/domain/position/index.js.map +1 -1
- package/dist/domain/position/state.d.ts +118 -0
- package/dist/domain/position/state.d.ts.map +1 -0
- package/dist/domain/position/state.js +262 -0
- package/dist/domain/position/state.js.map +1 -0
- package/dist/error.d.ts +8 -2
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js +14 -1
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/prelude.d.ts +6 -5
- package/dist/prelude.d.ts.map +1 -1
- package/dist/prelude.js +10 -1
- package/dist/prelude.js.map +1 -1
- package/dist/privy/client.d.ts +4 -0
- package/dist/privy/client.d.ts.map +1 -1
- package/dist/privy/client.js +4 -0
- package/dist/privy/client.js.map +1 -1
- package/dist/rpc.d.ts +46 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +125 -0
- package/dist/rpc.js.map +1 -1
- package/dist/shared/api_response.d.ts +7 -0
- package/dist/shared/api_response.d.ts.map +1 -1
- package/dist/shared/api_response.js +16 -0
- package/dist/shared/api_response.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/signing.d.ts +17 -0
- package/dist/shared/signing.d.ts.map +1 -1
- package/dist/shared/signing.js +27 -0
- package/dist/shared/signing.js.map +1 -1
- package/dist/shared/types.d.ts +3 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +12 -4
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +4 -0
- package/dist/ws/client.browser.d.ts.map +1 -1
- package/dist/ws/client.browser.js +13 -1
- package/dist/ws/client.browser.js.map +1 -1
- package/dist/ws/client.node.d.ts +4 -0
- package/dist/ws/client.node.d.ts.map +1 -1
- package/dist/ws/client.node.js +13 -1
- package/dist/ws/client.node.js.map +1 -1
- package/dist/ws/index.d.ts +24 -0
- package/dist/ws/index.d.ts.map +1 -1
- package/dist/ws/index.js +162 -1
- package/dist/ws/index.js.map +1 -1
- package/dist/ws/subscriptions.d.ts +12 -1
- package/dist/ws/subscriptions.d.ts.map +1 -1
- package/dist/ws/subscriptions.js +11 -0
- package/dist/ws/subscriptions.js.map +1 -1
- package/dist/ws/types.d.ts +5 -0
- package/dist/ws/types.d.ts.map +1 -1
- package/dist/ws/types.js.map +1 -1
- package/package.json +2 -1
package/dist/context.js
CHANGED
|
@@ -40,7 +40,11 @@ exports.requireSigningStrategy = requireSigningStrategy;
|
|
|
40
40
|
exports.signAndSubmitTx = signAndSubmitTx;
|
|
41
41
|
exports.signAndSubmitTxConfirmed = signAndSubmitTxConfirmed;
|
|
42
42
|
exports.signAndSubmitTxConfirmedWithSlot = signAndSubmitTxConfirmedWithSlot;
|
|
43
|
+
exports.signAndSubmitPreparedTxConfirmedWithSlot = signAndSubmitPreparedTxConfirmedWithSlot;
|
|
44
|
+
exports.signAndSubmitTxConfirmedUsingStrategy = signAndSubmitTxConfirmedUsingStrategy;
|
|
45
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
43
46
|
const error_1 = require("./error");
|
|
47
|
+
const signing_1 = require("./shared/signing");
|
|
44
48
|
const rpcFailover_1 = require("./rpcFailover");
|
|
45
49
|
function requireConnection(ctx) {
|
|
46
50
|
ctx.rpcFailoverState.maybeRecoverToPrimary();
|
|
@@ -109,6 +113,106 @@ function requireSigningStrategy(ctx) {
|
|
|
109
113
|
}
|
|
110
114
|
return ctx.signingStrategy;
|
|
111
115
|
}
|
|
116
|
+
/** Capture one signer and sponsorship assertion before transaction work can yield. */
|
|
117
|
+
function requireTransactionSigningContext(ctx) {
|
|
118
|
+
return {
|
|
119
|
+
strategy: requireSigningStrategy(ctx),
|
|
120
|
+
sponsorshipEnabled: ctx.transactionSponsorshipEnabled ?? false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reject invalid payer and sponsorship combinations before submission can yield.
|
|
125
|
+
* Unsponsored known signers must control the payer being classified; sponsored
|
|
126
|
+
* external flows may intentionally use a different payer, while native sponsorship
|
|
127
|
+
* is rejected before blockhash RPC or caller-transaction mutation.
|
|
128
|
+
*/
|
|
129
|
+
function validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled) {
|
|
130
|
+
if (!tx.feePayer) {
|
|
131
|
+
throw error_1.SdkError.validation("transaction is missing a declared fee payer");
|
|
132
|
+
}
|
|
133
|
+
if (sponsorshipEnabled) {
|
|
134
|
+
if (strategy.type === "native") {
|
|
135
|
+
throw error_1.SdkError.validation("transaction sponsorship is not supported with local-keypair signing");
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const signingAddress = (0, signing_1.signingStrategyWalletAddress)(strategy);
|
|
140
|
+
if (signingAddress && signingAddress !== tx.feePayer.toBase58()) {
|
|
141
|
+
throw error_1.SdkError.validation("signing strategy does not control transaction fee payer");
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Own the transaction message before asynchronous submission work begins.
|
|
146
|
+
* A placeholder blockhash exists only long enough to serialize an ordinary
|
|
147
|
+
* transaction that has not received its fresh blockhash yet.
|
|
148
|
+
*/
|
|
149
|
+
function snapshotTransaction(tx) {
|
|
150
|
+
if (tx.recentBlockhash || tx.nonceInfo) {
|
|
151
|
+
return web3_js_1.Transaction.from(tx.serialize({ requireAllSignatures: false, verifySignatures: false }));
|
|
152
|
+
}
|
|
153
|
+
const serializable = new web3_js_1.Transaction({
|
|
154
|
+
feePayer: tx.feePayer,
|
|
155
|
+
blockhash: "11111111111111111111111111111111",
|
|
156
|
+
lastValidBlockHeight: tx.lastValidBlockHeight ?? 0,
|
|
157
|
+
signatures: tx.signatures,
|
|
158
|
+
});
|
|
159
|
+
serializable.instructions = tx.instructions;
|
|
160
|
+
const snapshot = web3_js_1.Transaction.from(serializable.serialize({ requireAllSignatures: false, verifySignatures: false }));
|
|
161
|
+
snapshot.recentBlockhash = undefined;
|
|
162
|
+
snapshot.lastValidBlockHeight = undefined;
|
|
163
|
+
return snapshot;
|
|
164
|
+
}
|
|
165
|
+
/** Publish local signatures only when the caller still holds the submitted message. */
|
|
166
|
+
function copySignaturesIfMessageUnchanged(signed, callerTransaction) {
|
|
167
|
+
try {
|
|
168
|
+
if (!Buffer.from(signed.serializeMessage()).equals(Buffer.from(callerTransaction.serializeMessage()))) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
callerTransaction.signatures = signed.signatures.map(({ publicKey, signature }) => ({
|
|
176
|
+
publicKey,
|
|
177
|
+
signature: signature ? Buffer.from(signature) : null,
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Reject proven fee shortfalls before signing while preserving submission on unknown evidence.
|
|
182
|
+
*
|
|
183
|
+
* The transaction's prepared message supplies the exact fee and declared fee
|
|
184
|
+
* payer. Fee or balance lookup failure is deliberately best-effort; planner-owned
|
|
185
|
+
* SOL admission remains fail-closed before reaching this shared boundary. The
|
|
186
|
+
* signer and sponsorship value were captured together before RPC work.
|
|
187
|
+
*/
|
|
188
|
+
async function preflightTransactionFeeFunding(ctx, tx, strategy, sponsorshipEnabled) {
|
|
189
|
+
validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);
|
|
190
|
+
if (sponsorshipEnabled)
|
|
191
|
+
return;
|
|
192
|
+
const feePayer = tx.feePayer;
|
|
193
|
+
if (!feePayer) {
|
|
194
|
+
throw error_1.SdkError.validation("transaction is missing a declared fee payer");
|
|
195
|
+
}
|
|
196
|
+
const { Rpc } = await Promise.resolve().then(() => __importStar(require("./rpc")));
|
|
197
|
+
const rpc = new Rpc(ctx);
|
|
198
|
+
let requiredLamports;
|
|
199
|
+
try {
|
|
200
|
+
requiredLamports = await rpc.estimatePreparedTransactionFee(tx);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
let availableLamports;
|
|
206
|
+
try {
|
|
207
|
+
availableLamports = await rpc.balanceLamports(feePayer);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (availableLamports < requiredLamports) {
|
|
213
|
+
throw error_1.SdkError.insufficientSolForTransactionFees(availableLamports, requiredLamports);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
112
216
|
/**
|
|
113
217
|
* Sign and submit a transaction using the client's signing strategy.
|
|
114
218
|
*
|
|
@@ -116,9 +220,12 @@ function requireSigningStrategy(ctx) {
|
|
|
116
220
|
* accepts the transaction — inclusion is not awaited. When follow-up work
|
|
117
221
|
* depends on this transaction's on-chain effects, use
|
|
118
222
|
* {@link signAndSubmitTxConfirmed} instead.
|
|
223
|
+
* Unsponsored submission checks exact fee funding before signing when both
|
|
224
|
+
* required RPC observations are available.
|
|
119
225
|
*/
|
|
120
226
|
async function signAndSubmitTx(ctx, tx) {
|
|
121
|
-
const {
|
|
227
|
+
const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);
|
|
228
|
+
const { signature } = await signAndSubmitTxInner(ctx, tx, strategy, sponsorshipEnabled);
|
|
122
229
|
return signature;
|
|
123
230
|
}
|
|
124
231
|
/**
|
|
@@ -146,34 +253,86 @@ async function signAndSubmitTxConfirmed(ctx, tx) {
|
|
|
146
253
|
* both its signature and processing slot.
|
|
147
254
|
*/
|
|
148
255
|
async function signAndSubmitTxConfirmedWithSlot(ctx, tx) {
|
|
256
|
+
const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);
|
|
257
|
+
return signAndSubmitTxConfirmedWithSlotUsingStrategy(ctx, tx, strategy, sponsorshipEnabled);
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sign, submit once, and confirm a transaction whose message was fee-estimated.
|
|
261
|
+
*
|
|
262
|
+
* This function preserves the prepared blockhash. A wallet adapter may add
|
|
263
|
+
* signatures but may not replace any message field. Signed bytes are sent once to
|
|
264
|
+
* the active RPC because a transport failure may occur after acceptance.
|
|
265
|
+
* The unchanged message receives the same best-effort fee-funding preflight as an
|
|
266
|
+
* ordinary transaction before the signer runs. A sponsored external signer may
|
|
267
|
+
* differ from the declared fee payer. The caller-owned transaction is snapshotted
|
|
268
|
+
* before the first await so later caller mutation cannot change fee authority.
|
|
269
|
+
*/
|
|
270
|
+
async function signAndSubmitPreparedTxConfirmedWithSlot(ctx, tx) {
|
|
271
|
+
if (!tx.recentBlockhash) {
|
|
272
|
+
throw error_1.SdkError.validation("prepared transaction is missing a recent blockhash");
|
|
273
|
+
}
|
|
274
|
+
const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);
|
|
275
|
+
if (!tx.feePayer) {
|
|
276
|
+
throw error_1.SdkError.validation("prepared transaction is missing a fee payer");
|
|
277
|
+
}
|
|
278
|
+
validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);
|
|
279
|
+
if (!sponsorshipEnabled && !(0, signing_1.signingStrategyWalletAddress)(strategy)) {
|
|
280
|
+
throw error_1.SdkError.validation("signing strategy wallet identity is required");
|
|
281
|
+
}
|
|
282
|
+
const callerTransaction = tx;
|
|
283
|
+
tx = snapshotTransaction(tx);
|
|
284
|
+
await preflightTransactionFeeFunding(ctx, tx, strategy, sponsorshipEnabled);
|
|
285
|
+
const signature = await signAndSubmitPreparedTxInner(ctx, tx, strategy, callerTransaction);
|
|
286
|
+
const { Rpc } = await Promise.resolve().then(() => __importStar(require("./rpc")));
|
|
287
|
+
const status = await new Rpc(ctx).confirmSignatureStatus(signature, null);
|
|
288
|
+
return { signature, slot: status.slot };
|
|
289
|
+
}
|
|
290
|
+
/** @internal Submit with a strategy already validated for an identity-bound operation. */
|
|
291
|
+
async function signAndSubmitTxConfirmedUsingStrategy(ctx, tx, strategy) {
|
|
292
|
+
const sponsorshipEnabled = ctx.transactionSponsorshipEnabled ?? false;
|
|
293
|
+
const confirmed = await signAndSubmitTxConfirmedWithSlotUsingStrategy(ctx, tx, strategy, sponsorshipEnabled);
|
|
294
|
+
return confirmed.signature;
|
|
295
|
+
}
|
|
296
|
+
async function signAndSubmitTxConfirmedWithSlotUsingStrategy(ctx, tx, strategy, sponsorshipEnabled) {
|
|
297
|
+
const { signature, lastValidBlockHeight } = await signAndSubmitTxInner(ctx, tx, strategy, sponsorshipEnabled);
|
|
149
298
|
const { Rpc } = await Promise.resolve().then(() => __importStar(require("./rpc")));
|
|
150
|
-
const { signature, lastValidBlockHeight } = await signAndSubmitTxInner(ctx, tx);
|
|
151
299
|
const status = await new Rpc(ctx).confirmSignatureStatus(signature, lastValidBlockHeight);
|
|
152
300
|
return { signature, slot: status.slot };
|
|
153
301
|
}
|
|
154
302
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
303
|
+
* Prepare funding evidence, sign, send, and return the signature and expiry bound.
|
|
304
|
+
*
|
|
305
|
+
* The fresh blockhash feeds best-effort fee preflight before any signer runs.
|
|
306
|
+
* Submission operates on a pre-await snapshot. The fresh blockhash is copied to
|
|
307
|
+
* the caller transaction; local signatures follow only if its message still matches.
|
|
308
|
+
* `lastValidBlockHeight` is `null` when the submitted wire bytes cannot be proven
|
|
309
|
+
* to retain that blockhash because an external signer replaced it or the final
|
|
310
|
+
* bytes were never visible to the SDK.
|
|
159
311
|
*/
|
|
160
|
-
async function signAndSubmitTxInner(ctx, tx) {
|
|
312
|
+
async function signAndSubmitTxInner(ctx, tx, strategy, sponsorshipEnabled) {
|
|
313
|
+
validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);
|
|
314
|
+
const callerTransaction = tx;
|
|
315
|
+
tx = snapshotTransaction(tx);
|
|
161
316
|
const { isUserCancellation } = await Promise.resolve().then(() => __importStar(require("./shared/signing")));
|
|
162
317
|
const { SdkError } = await Promise.resolve().then(() => __importStar(require("./error")));
|
|
163
318
|
const { RetryPolicy } = await Promise.resolve().then(() => __importStar(require("./http")));
|
|
164
|
-
const strategy = requireSigningStrategy(ctx);
|
|
165
319
|
// Get blockhash with failover, at `confirmed` commitment (pinned, not the
|
|
166
320
|
// Connection's default — matching the Rust and Python SDKs).
|
|
167
321
|
const { blockhash, lastValidBlockHeight } = await connectionWithFailover(ctx, (conn) => conn.getLatestBlockhash("confirmed"));
|
|
168
322
|
tx.recentBlockhash = blockhash;
|
|
169
323
|
tx.lastValidBlockHeight = lastValidBlockHeight;
|
|
324
|
+
callerTransaction.recentBlockhash = blockhash;
|
|
325
|
+
callerTransaction.lastValidBlockHeight = lastValidBlockHeight;
|
|
326
|
+
await preflightTransactionFeeFunding(ctx, tx, strategy, sponsorshipEnabled);
|
|
170
327
|
switch (strategy.type) {
|
|
171
328
|
case "native": {
|
|
172
329
|
tx.partialSign(strategy.keypair);
|
|
330
|
+
copySignaturesIfMessageUnchanged(tx, callerTransaction);
|
|
173
331
|
const signature = await connectionWithFailover(ctx, (conn) => conn.sendRawTransaction(tx.serialize()));
|
|
174
332
|
return { signature, lastValidBlockHeight };
|
|
175
333
|
}
|
|
176
334
|
case "walletAdapter": {
|
|
335
|
+
const expectedMessage = tx.serializeMessage();
|
|
177
336
|
const txBytes = tx.serialize({ requireAllSignatures: false });
|
|
178
337
|
const signedBytes = await strategy.signer
|
|
179
338
|
.signTransaction(txBytes)
|
|
@@ -183,10 +342,11 @@ async function signAndSubmitTxInner(ctx, tx) {
|
|
|
183
342
|
throw SdkError.userCancelled();
|
|
184
343
|
throw SdkError.signing(msg);
|
|
185
344
|
});
|
|
345
|
+
const signedBlockhashIsUnchanged = await validateOrdinarySignedTransaction(signedBytes, expectedMessage, blockhash);
|
|
186
346
|
const signature = await connectionWithFailover(ctx, (conn) => conn.sendRawTransaction(signedBytes));
|
|
187
347
|
return {
|
|
188
348
|
signature,
|
|
189
|
-
lastValidBlockHeight:
|
|
349
|
+
lastValidBlockHeight: signedBlockhashIsUnchanged
|
|
190
350
|
? lastValidBlockHeight
|
|
191
351
|
: null,
|
|
192
352
|
};
|
|
@@ -204,17 +364,78 @@ async function signAndSubmitTxInner(ctx, tx) {
|
|
|
204
364
|
}
|
|
205
365
|
}
|
|
206
366
|
/**
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
367
|
+
* Sign and submit once without replacing the planner's prepared blockhash.
|
|
368
|
+
*
|
|
369
|
+
* Native signing preserves the message by construction. Wallet-adapter bytes are
|
|
370
|
+
* compared with the prepared message before submission. Privy is excluded because
|
|
371
|
+
* this SDK cannot inspect its final wire message. The native signature is published
|
|
372
|
+
* to an unchanged caller message before the one-shot send so an uncertain outcome
|
|
373
|
+
* remains reconcilable. Both admitted strategies use the active connection directly.
|
|
210
374
|
*/
|
|
211
|
-
async function
|
|
375
|
+
async function signAndSubmitPreparedTxInner(ctx, tx, strategy, callerTransaction) {
|
|
376
|
+
const { isUserCancellation } = await Promise.resolve().then(() => __importStar(require("./shared/signing")));
|
|
377
|
+
switch (strategy.type) {
|
|
378
|
+
case "native":
|
|
379
|
+
tx.partialSign(strategy.keypair);
|
|
380
|
+
copySignaturesIfMessageUnchanged(tx, callerTransaction);
|
|
381
|
+
return requireConnection(ctx).sendRawTransaction(tx.serialize());
|
|
382
|
+
case "walletAdapter": {
|
|
383
|
+
const expectedMessage = tx.serializeMessage();
|
|
384
|
+
const txBytes = tx.serialize({ requireAllSignatures: false });
|
|
385
|
+
const signedBytes = await strategy.signer
|
|
386
|
+
.signTransaction(txBytes)
|
|
387
|
+
.catch((error) => {
|
|
388
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
389
|
+
if (isUserCancellation(message))
|
|
390
|
+
throw error_1.SdkError.userCancelled();
|
|
391
|
+
throw error_1.SdkError.signing(message);
|
|
392
|
+
});
|
|
393
|
+
await assertPreparedSignedMessage(signedBytes, expectedMessage);
|
|
394
|
+
return requireConnection(ctx).sendRawTransaction(signedBytes);
|
|
395
|
+
}
|
|
396
|
+
case "privy":
|
|
397
|
+
throw error_1.SdkError.validation("prepared transaction submission cannot verify a Privy-signed message");
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Enforce the fee-preflight authority boundary after wallet-adapter signing.
|
|
402
|
+
* Signatures may change, but any account, instruction, fee payer, or blockhash
|
|
403
|
+
* change rejects the bytes before they reach RPC.
|
|
404
|
+
*/
|
|
405
|
+
async function assertPreparedSignedMessage(signedBytes, expectedMessage) {
|
|
406
|
+
const { Transaction } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
|
|
407
|
+
let signedMessage;
|
|
212
408
|
try {
|
|
213
|
-
|
|
214
|
-
return Transaction.from(signedBytes).recentBlockhash === expectedBlockhash;
|
|
409
|
+
signedMessage = Transaction.from(signedBytes).serializeMessage();
|
|
215
410
|
}
|
|
216
|
-
catch {
|
|
217
|
-
|
|
411
|
+
catch (error) {
|
|
412
|
+
throw error_1.SdkError.signing(`signed transaction is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
413
|
+
}
|
|
414
|
+
if (!Buffer.from(signedMessage).equals(Buffer.from(expectedMessage))) {
|
|
415
|
+
throw error_1.SdkError.validation("wallet changed the fee-prepared transaction message");
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/**
|
|
419
|
+
* Allow an external signer to replace only the ordinary transaction blockhash.
|
|
420
|
+
*
|
|
421
|
+
* Fee payer, accounts, and instructions are the authority used by fee preflight
|
|
422
|
+
* and must survive signing. A replacement blockhash remains allowed, but its
|
|
423
|
+
* original expiry bound is discarded.
|
|
424
|
+
*/
|
|
425
|
+
async function validateOrdinarySignedTransaction(signedBytes, expectedMessage, expectedBlockhash) {
|
|
426
|
+
const { Transaction } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
|
|
427
|
+
let signed;
|
|
428
|
+
try {
|
|
429
|
+
signed = Transaction.from(signedBytes);
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
throw error_1.SdkError.signing(`signed transaction is invalid: ${error instanceof Error ? error.message : String(error)}`);
|
|
433
|
+
}
|
|
434
|
+
const blockhashUnchanged = signed.recentBlockhash === expectedBlockhash;
|
|
435
|
+
signed.recentBlockhash = expectedBlockhash;
|
|
436
|
+
if (!Buffer.from(signed.serializeMessage()).equals(Buffer.from(expectedMessage))) {
|
|
437
|
+
throw error_1.SdkError.validation("wallet changed the transaction message beyond recent blockhash");
|
|
218
438
|
}
|
|
439
|
+
return blockhashUnchanged;
|
|
219
440
|
}
|
|
220
441
|
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,8CAYC;AAWD,wDA2CC;AAED,oDAKC;AAED,wDAOC;AAUD,0CAMC;AAkBD,4DAMC;AAWD,4EAeC;AAhLD,mCAAmC;AAInC,+CAMuB;AAkBvB,SAAgB,iBAAiB,CAAC,GAAkB;IAClD,GAAG,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;IAC7C,MAAM,IAAI,GACR,GAAG,CAAC,gBAAgB,CAAC,MAAM,KAAK,uBAAS,CAAC,OAAO;QAC/C,CAAC,CAAC,GAAG,CAAC,iBAAiB;QACvB,CAAC,CAAC,GAAG,CAAC,gBAAgB,IAAI,GAAG,CAAC,iBAAiB,CAAC;IACpD,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,gBAAQ,CAAC,UAAU,CACvB,0DAA0D,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,oBAAoB,CAC3B,GAAkB,EAClB,MAAiB;IAEjB,OAAO,MAAM,KAAK,uBAAS,CAAC,OAAO;QACjC,CAAC,CAAC,GAAG,CAAC,iBAAiB;QACvB,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC;AAC3B,CAAC;AAEM,KAAK,UAAU,sBAAsB,CAC1C,GAAkB,EAClB,SAA2C;IAE3C,GAAG,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,CAAC;IAC7C,MAAM,cAAc,GAAG,GAAG,CAAC,gBAAgB,CAAC,MAAM,CAAC;IACnD,MAAM,UAAU,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAE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AI,CAAC,WAAW,CAAC,CAAC,eAAe,KAAK,iBAAiB,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC","sourcesContent":["import type { Connection, PublicKey } from \"@solana/web3.js\";\nimport { SdkError } from \"./error\";\nimport type { LightconeHttp } from \"./http\";\nimport type { DepositSource, OrderbookRules } from \"./shared\";\nimport type { SigningStrategy } from \"./shared/signing\";\nimport {\n ActiveRpc,\n type RpcFailoverState,\n isInfrastructureError,\n sleep,\n FAST_RETRY_DELAY_MS,\n} from \"./rpcFailover\";\n\nexport interface ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly primaryConnection?: Connection;\n readonly backupConnection?: Connection;\n readonly rpcFailoverState: RpcFailoverState;\n readonly depositSource: DepositSource;\n readonly signingStrategy?: SigningStrategy;\n orderNonce?(): number | undefined;\n setOrderNonce?(nonce: number): void;\n readonly orderbookRulesCache?: Map<string, Promise<OrderbookRules>>;\n\n /** @deprecated Use primaryConnection — kept for backward compat in domain sub-clients. */\n readonly connection?: Connection;\n}\n\nexport function requireConnection(ctx: ClientContext): Connection {\n ctx.rpcFailoverState.maybeRecoverToPrimary();\n const conn =\n ctx.rpcFailoverState.active === ActiveRpc.Primary\n ? ctx.primaryConnection\n : ctx.backupConnection ?? ctx.primaryConnection;\n if (!conn) {\n throw SdkError.validation(\n \"RPC client not configured — use .rpcUrl() on the builder\"\n );\n }\n return conn;\n}\n\nfunction resolveConnectionFor(\n ctx: ClientContext,\n target: ActiveRpc\n): Connection | undefined {\n return target === ActiveRpc.Primary\n ? ctx.primaryConnection\n : ctx.backupConnection;\n}\n\nexport async function connectionWithFailover<T>(\n ctx: ClientContext,\n operation: (conn: Connection) => Promise<T>\n): Promise<T> {\n ctx.rpcFailoverState.maybeRecoverToPrimary();\n const originalActive = ctx.rpcFailoverState.active;\n const activeConn = requireConnection(ctx);\n\n // First attempt.\n try {\n return await operation(activeConn);\n } catch (firstError) {\n if (!isInfrastructureError(firstError)) throw firstError;\n }\n\n // Fast retry on same connection.\n await sleep(FAST_RETRY_DELAY_MS);\n try {\n return await operation(activeConn);\n } catch (retryError) {\n if (!isInfrastructureError(retryError)) throw retryError;\n\n // Flip and try the other connection.\n const otherTarget =\n originalActive === ActiveRpc.Primary\n ? ActiveRpc.Backup\n : ActiveRpc.Primary;\n const otherConn = resolveConnectionFor(ctx, otherTarget);\n if (otherConn) {\n try {\n const result = await operation(otherConn);\n if (otherTarget === ActiveRpc.Primary) {\n ctx.rpcFailoverState.flipToPrimary();\n } else {\n ctx.rpcFailoverState.flipToBackup();\n }\n return result;\n } catch (bothError) {\n throw bothError;\n }\n }\n throw retryError;\n }\n}\n\nexport function resolveDepositSource(\n ctx: ClientContext,\n overrideSource: DepositSource | undefined\n): DepositSource {\n return overrideSource ?? ctx.depositSource;\n}\n\nexport function requireSigningStrategy(ctx: ClientContext): SigningStrategy {\n if (!ctx.signingStrategy) {\n throw SdkError.validation(\n \"Signing strategy not configured — use .nativeSigner(), .externalSigner(), or .privyWalletId() on the builder\"\n );\n }\n return ctx.signingStrategy;\n}\n\n/**\n * Sign and submit a transaction using the client's signing strategy.\n *\n * Fetches a recent blockhash automatically. Returns as soon as the RPC\n * accepts the transaction — inclusion is not awaited. When follow-up work\n * depends on this transaction's on-chain effects, use\n * {@link signAndSubmitTxConfirmed} instead.\n */\nexport async function signAndSubmitTx(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<string> {\n const { signature } = await signAndSubmitTxInner(ctx, tx);\n return signature;\n}\n\n/**\n * Sign and submit a transaction, then wait until it reaches `confirmed`\n * commitment on-chain.\n *\n * Sequential flows should prefer this over {@link signAndSubmitTx}: a\n * transaction that depends on a prior transaction's state is only safe to\n * send once that prior transaction has confirmed. See `Rpc.confirmSignature`\n * for the terminal error taxonomy.\n *\n * Expiry (`\"TransactionExpired\"`) is only ever reported when the submitted\n * transaction provably still carries the blockhash this function fetched:\n * always true for `native`, verified against the signed bytes for\n * `walletAdapter`, and never assumed for `privy` (the backend signs and\n * submits out of the SDK's sight) — those cases end in\n * `\"ConfirmationTimeout\"` at the poll cap instead.\n */\nexport async function signAndSubmitTxConfirmed(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<string> {\n const confirmed = await signAndSubmitTxConfirmedWithSlot(ctx, tx);\n return confirmed.signature;\n}\n\nexport interface ConfirmedTransaction {\n signature: string;\n slot: number;\n}\n\n/**\n * Sign and submit a transaction, wait for confirmed commitment, and return\n * both its signature and processing slot.\n */\nexport async function signAndSubmitTxConfirmedWithSlot(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<ConfirmedTransaction> {\n const { Rpc } = await import(\"./rpc\");\n\n const { signature, lastValidBlockHeight } = await signAndSubmitTxInner(\n ctx,\n tx\n );\n const status = await new Rpc(ctx).confirmSignatureStatus(\n signature,\n lastValidBlockHeight\n );\n return { signature, slot: status.slot };\n}\n\n/**\n * Shared submit path: sign, send, and return the signature together with the\n * `lastValidBlockHeight` of the blockhash the submitted wire bytes are known\n * to carry — `null` when that cannot be proven (external signer replaced the\n * blockhash, or the bytes were never visible to the SDK).\n */\nasync function signAndSubmitTxInner(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<{ signature: string; lastValidBlockHeight: number | null }> {\n const { isUserCancellation } = await import(\"./shared/signing\");\n const { SdkError } = await import(\"./error\");\n const { RetryPolicy } = await import(\"./http\");\n\n const strategy = requireSigningStrategy(ctx);\n\n // Get blockhash with failover, at `confirmed` commitment (pinned, not the\n // Connection's default — matching the Rust and Python SDKs).\n const { blockhash, lastValidBlockHeight } = await connectionWithFailover(\n ctx,\n (conn) => conn.getLatestBlockhash(\"confirmed\")\n );\n tx.recentBlockhash = blockhash;\n tx.lastValidBlockHeight = lastValidBlockHeight;\n\n switch (strategy.type) {\n case \"native\": {\n tx.partialSign(strategy.keypair);\n const signature = await connectionWithFailover(ctx, (conn) =>\n conn.sendRawTransaction(tx.serialize())\n );\n return { signature, lastValidBlockHeight };\n }\n case \"walletAdapter\": {\n const txBytes = tx.serialize({ requireAllSignatures: false });\n const signedBytes = await strategy.signer\n .signTransaction(txBytes)\n .catch((err: unknown) => {\n const msg = err instanceof Error ? err.message : String(err);\n if (isUserCancellation(msg)) throw SdkError.userCancelled();\n throw SdkError.signing(msg);\n });\n const signature = await connectionWithFailover(ctx, (conn) =>\n conn.sendRawTransaction(signedBytes)\n );\n return {\n signature,\n lastValidBlockHeight: (await signedBlockhashUnchanged(\n signedBytes,\n blockhash\n ))\n ? lastValidBlockHeight\n : null,\n };\n }\n case \"privy\": {\n const txBytes = tx.serialize({ requireAllSignatures: false });\n const base64Tx = Buffer.from(txBytes).toString(\"base64\");\n const url = `${ctx.http.baseUrl()}/api/privy/sign_and_send_tx`;\n const result = await ctx.http.post<{ hash: string }, object>(\n url,\n { wallet_id: strategy.walletId, base64_tx: base64Tx },\n RetryPolicy.None\n );\n // The backend signs and submits server-side; the SDK never sees the\n // final wire bytes, so the blockhash it set cannot be trusted for\n // expiry detection.\n return { signature: result.hash, lastValidBlockHeight: null };\n }\n }\n}\n\n/**\n * True when the signed wire bytes still carry `expectedBlockhash`. External\n * signers may re-blockhash a transaction before signing; a bound derived\n * from the original blockhash must then not be used for expiry detection.\n */\nasync function signedBlockhashUnchanged(\n signedBytes: Uint8Array,\n expectedBlockhash: string\n): Promise<boolean> {\n try {\n const { Transaction } = await import(\"@solana/web3.js\");\n return Transaction.from(signedBytes).recentBlockhash === expectedBlockhash;\n } catch {\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,8CAYC;AAWD,wDA2CC;AAED,oDAKC;AAED,wDAOC;AAkJD,0CAOC;AAkBD,4DAMC;AAWD,4EAWC;AAaD,4FA2BC;AAGD,sFAaC;AA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CAAC;IACD,MAAM,kBAAkB,GAAG,MAAM,CAAC,eAAe,KAAK,iBAAiB,CAAC;IACxE,MAAM,CAAC,eAAe,GAAG,iBAAiB,CAAC;IAC3C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC;QACjF,MAAM,gBAAQ,CAAC,UAAU,CACvB,gEAAgE,CACjE,CAAC;IACJ,CAAC;IACD,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["import { Transaction, type Connection, type PublicKey } from \"@solana/web3.js\";\nimport { SdkError } from \"./error\";\nimport type { LightconeHttp } from \"./http\";\nimport type { AuthCredentials } from \"./auth\";\nimport type { DepositSource, OrderbookRules } from \"./shared\";\nimport {\n signingStrategyWalletAddress,\n type SigningStrategy,\n} from \"./shared/signing\";\nimport {\n ActiveRpc,\n type RpcFailoverState,\n isInfrastructureError,\n sleep,\n FAST_RETRY_DELAY_MS,\n} from \"./rpcFailover\";\n\nexport interface ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly primaryConnection?: Connection;\n readonly backupConnection?: Connection;\n readonly rpcFailoverState: RpcFailoverState;\n readonly depositSource: DepositSource;\n readonly signingStrategy?: SigningStrategy;\n /** Trusted application assertion that an external sponsor pays fees; omission is false. */\n readonly transactionSponsorshipEnabled?: boolean;\n /** Optional cached identity for auth-bound operations; callers must check expiry. */\n readonly authCredentials?: AuthCredentials;\n orderNonce?(): number | undefined;\n setOrderNonce?(nonce: number): void;\n readonly orderbookRulesCache?: Map<string, Promise<OrderbookRules>>;\n\n /** @deprecated Use primaryConnection — kept for backward compat in domain sub-clients. */\n readonly connection?: Connection;\n}\n\nexport function requireConnection(ctx: ClientContext): Connection {\n ctx.rpcFailoverState.maybeRecoverToPrimary();\n const conn =\n ctx.rpcFailoverState.active === ActiveRpc.Primary\n ? ctx.primaryConnection\n : ctx.backupConnection ?? ctx.primaryConnection;\n if (!conn) {\n throw SdkError.validation(\n \"RPC client not configured — use .rpcUrl() on the builder\"\n );\n }\n return conn;\n}\n\nfunction resolveConnectionFor(\n ctx: ClientContext,\n target: ActiveRpc\n): Connection | undefined {\n return target === ActiveRpc.Primary\n ? ctx.primaryConnection\n : ctx.backupConnection;\n}\n\nexport async function connectionWithFailover<T>(\n ctx: ClientContext,\n operation: (conn: Connection) => Promise<T>\n): Promise<T> {\n ctx.rpcFailoverState.maybeRecoverToPrimary();\n const originalActive = ctx.rpcFailoverState.active;\n const activeConn = requireConnection(ctx);\n\n // First attempt.\n try {\n return await operation(activeConn);\n } catch (firstError) {\n if (!isInfrastructureError(firstError)) throw firstError;\n }\n\n // Fast retry on same connection.\n await sleep(FAST_RETRY_DELAY_MS);\n try {\n return await operation(activeConn);\n } catch (retryError) {\n if (!isInfrastructureError(retryError)) throw retryError;\n\n // Flip and try the other connection.\n const otherTarget =\n originalActive === ActiveRpc.Primary\n ? ActiveRpc.Backup\n : ActiveRpc.Primary;\n const otherConn = resolveConnectionFor(ctx, otherTarget);\n if (otherConn) {\n try {\n const result = await operation(otherConn);\n if (otherTarget === ActiveRpc.Primary) {\n ctx.rpcFailoverState.flipToPrimary();\n } else {\n ctx.rpcFailoverState.flipToBackup();\n }\n return result;\n } catch (bothError) {\n throw bothError;\n }\n }\n throw retryError;\n }\n}\n\nexport function resolveDepositSource(\n ctx: ClientContext,\n overrideSource: DepositSource | undefined\n): DepositSource {\n return overrideSource ?? ctx.depositSource;\n}\n\nexport function requireSigningStrategy(ctx: ClientContext): SigningStrategy {\n if (!ctx.signingStrategy) {\n throw SdkError.validation(\n \"Signing strategy not configured — use .nativeSigner(), .externalSigner(), or .privyWalletId() on the builder\"\n );\n }\n return ctx.signingStrategy;\n}\n\n/** Capture one signer and sponsorship assertion before transaction work can yield. */\nfunction requireTransactionSigningContext(ctx: ClientContext): {\n strategy: SigningStrategy;\n sponsorshipEnabled: boolean;\n} {\n return {\n strategy: requireSigningStrategy(ctx),\n sponsorshipEnabled: ctx.transactionSponsorshipEnabled ?? false,\n };\n}\n\n/**\n * Reject invalid payer and sponsorship combinations before submission can yield.\n * Unsponsored known signers must control the payer being classified; sponsored\n * external flows may intentionally use a different payer, while native sponsorship\n * is rejected before blockhash RPC or caller-transaction mutation.\n */\nfunction validateTransactionFeeFundingContext(\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy,\n sponsorshipEnabled: boolean\n): void {\n if (!tx.feePayer) {\n throw SdkError.validation(\"transaction is missing a declared fee payer\");\n }\n if (sponsorshipEnabled) {\n if (strategy.type === \"native\") {\n throw SdkError.validation(\n \"transaction sponsorship is not supported with local-keypair signing\"\n );\n }\n return;\n }\n\n const signingAddress = signingStrategyWalletAddress(strategy);\n if (signingAddress && signingAddress !== tx.feePayer.toBase58()) {\n throw SdkError.validation(\n \"signing strategy does not control transaction fee payer\"\n );\n }\n}\n\n/**\n * Own the transaction message before asynchronous submission work begins.\n * A placeholder blockhash exists only long enough to serialize an ordinary\n * transaction that has not received its fresh blockhash yet.\n */\nfunction snapshotTransaction(tx: Transaction): Transaction {\n if (tx.recentBlockhash || tx.nonceInfo) {\n return Transaction.from(\n tx.serialize({ requireAllSignatures: false, verifySignatures: false })\n );\n }\n\n const serializable = new Transaction({\n feePayer: tx.feePayer,\n blockhash: \"11111111111111111111111111111111\",\n lastValidBlockHeight: tx.lastValidBlockHeight ?? 0,\n signatures: tx.signatures,\n });\n serializable.instructions = tx.instructions;\n const snapshot = Transaction.from(\n serializable.serialize({ requireAllSignatures: false, verifySignatures: false })\n );\n snapshot.recentBlockhash = undefined;\n snapshot.lastValidBlockHeight = undefined;\n return snapshot;\n}\n\n/** Publish local signatures only when the caller still holds the submitted message. */\nfunction copySignaturesIfMessageUnchanged(\n signed: Transaction,\n callerTransaction: Transaction\n): void {\n try {\n if (\n !Buffer.from(signed.serializeMessage()).equals(\n Buffer.from(callerTransaction.serializeMessage())\n )\n ) {\n return;\n }\n } catch {\n return;\n }\n callerTransaction.signatures = signed.signatures.map(({ publicKey, signature }) => ({\n publicKey,\n signature: signature ? Buffer.from(signature) : null,\n }));\n}\n\n/**\n * Reject proven fee shortfalls before signing while preserving submission on unknown evidence.\n *\n * The transaction's prepared message supplies the exact fee and declared fee\n * payer. Fee or balance lookup failure is deliberately best-effort; planner-owned\n * SOL admission remains fail-closed before reaching this shared boundary. The\n * signer and sponsorship value were captured together before RPC work.\n */\nasync function preflightTransactionFeeFunding(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy,\n sponsorshipEnabled: boolean\n): Promise<void> {\n validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);\n if (sponsorshipEnabled) return;\n const feePayer = tx.feePayer;\n if (!feePayer) {\n throw SdkError.validation(\"transaction is missing a declared fee payer\");\n }\n\n const { Rpc } = await import(\"./rpc\");\n const rpc = new Rpc(ctx);\n let requiredLamports: bigint;\n try {\n requiredLamports = await rpc.estimatePreparedTransactionFee(tx);\n } catch {\n return;\n }\n let availableLamports: bigint;\n try {\n availableLamports = await rpc.balanceLamports(feePayer);\n } catch {\n return;\n }\n if (availableLamports < requiredLamports) {\n throw SdkError.insufficientSolForTransactionFees(\n availableLamports,\n requiredLamports\n );\n }\n}\n\n/**\n * Sign and submit a transaction using the client's signing strategy.\n *\n * Fetches a recent blockhash automatically. Returns as soon as the RPC\n * accepts the transaction — inclusion is not awaited. When follow-up work\n * depends on this transaction's on-chain effects, use\n * {@link signAndSubmitTxConfirmed} instead.\n * Unsponsored submission checks exact fee funding before signing when both\n * required RPC observations are available.\n */\nexport async function signAndSubmitTx(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<string> {\n const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);\n const { signature } = await signAndSubmitTxInner(ctx, tx, strategy, sponsorshipEnabled);\n return signature;\n}\n\n/**\n * Sign and submit a transaction, then wait until it reaches `confirmed`\n * commitment on-chain.\n *\n * Sequential flows should prefer this over {@link signAndSubmitTx}: a\n * transaction that depends on a prior transaction's state is only safe to\n * send once that prior transaction has confirmed. See `Rpc.confirmSignature`\n * for the terminal error taxonomy.\n *\n * Expiry (`\"TransactionExpired\"`) is only ever reported when the submitted\n * transaction provably still carries the blockhash this function fetched:\n * always true for `native`, verified against the signed bytes for\n * `walletAdapter`, and never assumed for `privy` (the backend signs and\n * submits out of the SDK's sight) — those cases end in\n * `\"ConfirmationTimeout\"` at the poll cap instead.\n */\nexport async function signAndSubmitTxConfirmed(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<string> {\n const confirmed = await signAndSubmitTxConfirmedWithSlot(ctx, tx);\n return confirmed.signature;\n}\n\nexport interface ConfirmedTransaction {\n signature: string;\n slot: number;\n}\n\n/**\n * Sign and submit a transaction, wait for confirmed commitment, and return\n * both its signature and processing slot.\n */\nexport async function signAndSubmitTxConfirmedWithSlot(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<ConfirmedTransaction> {\n const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);\n return signAndSubmitTxConfirmedWithSlotUsingStrategy(\n ctx,\n tx,\n strategy,\n sponsorshipEnabled\n );\n}\n\n/**\n * Sign, submit once, and confirm a transaction whose message was fee-estimated.\n *\n * This function preserves the prepared blockhash. A wallet adapter may add\n * signatures but may not replace any message field. Signed bytes are sent once to\n * the active RPC because a transport failure may occur after acceptance.\n * The unchanged message receives the same best-effort fee-funding preflight as an\n * ordinary transaction before the signer runs. A sponsored external signer may\n * differ from the declared fee payer. The caller-owned transaction is snapshotted\n * before the first await so later caller mutation cannot change fee authority.\n */\nexport async function signAndSubmitPreparedTxConfirmedWithSlot(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction\n): Promise<ConfirmedTransaction> {\n if (!tx.recentBlockhash) {\n throw SdkError.validation(\"prepared transaction is missing a recent blockhash\");\n }\n const { strategy, sponsorshipEnabled } = requireTransactionSigningContext(ctx);\n if (!tx.feePayer) {\n throw SdkError.validation(\"prepared transaction is missing a fee payer\");\n }\n validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);\n if (!sponsorshipEnabled && !signingStrategyWalletAddress(strategy)) {\n throw SdkError.validation(\"signing strategy wallet identity is required\");\n }\n const callerTransaction = tx;\n tx = snapshotTransaction(tx);\n await preflightTransactionFeeFunding(ctx, tx, strategy, sponsorshipEnabled);\n const signature = await signAndSubmitPreparedTxInner(\n ctx,\n tx,\n strategy,\n callerTransaction\n );\n const { Rpc } = await import(\"./rpc\");\n const status = await new Rpc(ctx).confirmSignatureStatus(signature, null);\n return { signature, slot: status.slot };\n}\n\n/** @internal Submit with a strategy already validated for an identity-bound operation. */\nexport async function signAndSubmitTxConfirmedUsingStrategy(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy\n): Promise<string> {\n const sponsorshipEnabled = ctx.transactionSponsorshipEnabled ?? false;\n const confirmed = await signAndSubmitTxConfirmedWithSlotUsingStrategy(\n ctx,\n tx,\n strategy,\n sponsorshipEnabled\n );\n return confirmed.signature;\n}\n\nasync function signAndSubmitTxConfirmedWithSlotUsingStrategy(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy,\n sponsorshipEnabled: boolean\n): Promise<ConfirmedTransaction> {\n const { signature, lastValidBlockHeight } = await signAndSubmitTxInner(\n ctx,\n tx,\n strategy,\n sponsorshipEnabled\n );\n const { Rpc } = await import(\"./rpc\");\n const status = await new Rpc(ctx).confirmSignatureStatus(\n signature,\n lastValidBlockHeight\n );\n return { signature, slot: status.slot };\n}\n\n/**\n * Prepare funding evidence, sign, send, and return the signature and expiry bound.\n *\n * The fresh blockhash feeds best-effort fee preflight before any signer runs.\n * Submission operates on a pre-await snapshot. The fresh blockhash is copied to\n * the caller transaction; local signatures follow only if its message still matches.\n * `lastValidBlockHeight` is `null` when the submitted wire bytes cannot be proven\n * to retain that blockhash because an external signer replaced it or the final\n * bytes were never visible to the SDK.\n */\nasync function signAndSubmitTxInner(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy,\n sponsorshipEnabled: boolean\n): Promise<{ signature: string; lastValidBlockHeight: number | null }> {\n validateTransactionFeeFundingContext(tx, strategy, sponsorshipEnabled);\n const callerTransaction = tx;\n tx = snapshotTransaction(tx);\n const { isUserCancellation } = await import(\"./shared/signing\");\n const { SdkError } = await import(\"./error\");\n const { RetryPolicy } = await import(\"./http\");\n\n // Get blockhash with failover, at `confirmed` commitment (pinned, not the\n // Connection's default — matching the Rust and Python SDKs).\n const { blockhash, lastValidBlockHeight } = await connectionWithFailover(\n ctx,\n (conn) => conn.getLatestBlockhash(\"confirmed\")\n );\n tx.recentBlockhash = blockhash;\n tx.lastValidBlockHeight = lastValidBlockHeight;\n callerTransaction.recentBlockhash = blockhash;\n callerTransaction.lastValidBlockHeight = lastValidBlockHeight;\n await preflightTransactionFeeFunding(ctx, tx, strategy, sponsorshipEnabled);\n\n switch (strategy.type) {\n case \"native\": {\n tx.partialSign(strategy.keypair);\n copySignaturesIfMessageUnchanged(tx, callerTransaction);\n const signature = await connectionWithFailover(ctx, (conn) =>\n conn.sendRawTransaction(tx.serialize())\n );\n return { signature, lastValidBlockHeight };\n }\n case \"walletAdapter\": {\n const expectedMessage = tx.serializeMessage();\n const txBytes = tx.serialize({ requireAllSignatures: false });\n const signedBytes = await strategy.signer\n .signTransaction(txBytes)\n .catch((err: unknown) => {\n const msg = err instanceof Error ? err.message : String(err);\n if (isUserCancellation(msg)) throw SdkError.userCancelled();\n throw SdkError.signing(msg);\n });\n const signedBlockhashIsUnchanged = await validateOrdinarySignedTransaction(\n signedBytes,\n expectedMessage,\n blockhash\n );\n const signature = await connectionWithFailover(ctx, (conn) =>\n conn.sendRawTransaction(signedBytes)\n );\n return {\n signature,\n lastValidBlockHeight: signedBlockhashIsUnchanged\n ? lastValidBlockHeight\n : null,\n };\n }\n case \"privy\": {\n const txBytes = tx.serialize({ requireAllSignatures: false });\n const base64Tx = Buffer.from(txBytes).toString(\"base64\");\n const url = `${ctx.http.baseUrl()}/api/privy/sign_and_send_tx`;\n const result = await ctx.http.post<{ hash: string }, object>(\n url,\n { wallet_id: strategy.walletId, base64_tx: base64Tx },\n RetryPolicy.None\n );\n // The backend signs and submits server-side; the SDK never sees the\n // final wire bytes, so the blockhash it set cannot be trusted for\n // expiry detection.\n return { signature: result.hash, lastValidBlockHeight: null };\n }\n }\n}\n\n/**\n * Sign and submit once without replacing the planner's prepared blockhash.\n *\n * Native signing preserves the message by construction. Wallet-adapter bytes are\n * compared with the prepared message before submission. Privy is excluded because\n * this SDK cannot inspect its final wire message. The native signature is published\n * to an unchanged caller message before the one-shot send so an uncertain outcome\n * remains reconcilable. Both admitted strategies use the active connection directly.\n */\nasync function signAndSubmitPreparedTxInner(\n ctx: ClientContext,\n tx: import(\"@solana/web3.js\").Transaction,\n strategy: SigningStrategy,\n callerTransaction: import(\"@solana/web3.js\").Transaction\n): Promise<string> {\n const { isUserCancellation } = await import(\"./shared/signing\");\n\n switch (strategy.type) {\n case \"native\":\n tx.partialSign(strategy.keypair);\n copySignaturesIfMessageUnchanged(tx, callerTransaction);\n return requireConnection(ctx).sendRawTransaction(tx.serialize());\n case \"walletAdapter\": {\n const expectedMessage = tx.serializeMessage();\n const txBytes = tx.serialize({ requireAllSignatures: false });\n const signedBytes = await strategy.signer\n .signTransaction(txBytes)\n .catch((error: unknown) => {\n const message = error instanceof Error ? error.message : String(error);\n if (isUserCancellation(message)) throw SdkError.userCancelled();\n throw SdkError.signing(message);\n });\n await assertPreparedSignedMessage(signedBytes, expectedMessage);\n return requireConnection(ctx).sendRawTransaction(signedBytes);\n }\n case \"privy\":\n throw SdkError.validation(\n \"prepared transaction submission cannot verify a Privy-signed message\"\n );\n }\n}\n\n/**\n * Enforce the fee-preflight authority boundary after wallet-adapter signing.\n * Signatures may change, but any account, instruction, fee payer, or blockhash\n * change rejects the bytes before they reach RPC.\n */\nasync function assertPreparedSignedMessage(\n signedBytes: Uint8Array,\n expectedMessage: Uint8Array\n): Promise<void> {\n const { Transaction } = await import(\"@solana/web3.js\");\n let signedMessage: Uint8Array;\n try {\n signedMessage = Transaction.from(signedBytes).serializeMessage();\n } catch (error) {\n throw SdkError.signing(\n `signed transaction is invalid: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n if (!Buffer.from(signedMessage).equals(Buffer.from(expectedMessage))) {\n throw SdkError.validation(\n \"wallet changed the fee-prepared transaction message\"\n );\n }\n}\n\n/**\n * Allow an external signer to replace only the ordinary transaction blockhash.\n *\n * Fee payer, accounts, and instructions are the authority used by fee preflight\n * and must survive signing. A replacement blockhash remains allowed, but its\n * original expiry bound is discarded.\n */\nasync function validateOrdinarySignedTransaction(\n signedBytes: Uint8Array,\n expectedMessage: Uint8Array,\n expectedBlockhash: string\n): Promise<boolean> {\n const { Transaction } = await import(\"@solana/web3.js\");\n let signed: import(\"@solana/web3.js\").Transaction;\n try {\n signed = Transaction.from(signedBytes);\n } catch (error) {\n throw SdkError.signing(\n `signed transaction is invalid: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n const blockhashUnchanged = signed.recentBlockhash === expectedBlockhash;\n signed.recentBlockhash = expectedBlockhash;\n if (!Buffer.from(signed.serializeMessage()).equals(Buffer.from(expectedMessage))) {\n throw SdkError.validation(\n \"wallet changed the transaction message beyond recent blockhash\"\n );\n }\n return blockhashUnchanged;\n}\n"]}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import type { OutcomeResponse } from "./wire";
|
|
2
|
+
/** One market result whose artwork qualities are all populated or all absent. */
|
|
2
3
|
export interface Outcome {
|
|
3
4
|
index: number;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
/** Optional low-quality artwork, cross-filled when another quality exists. */
|
|
6
|
+
iconUrlLow?: string;
|
|
7
|
+
/** Optional medium-quality artwork, cross-filled when another quality exists. */
|
|
8
|
+
iconUrlMedium?: string;
|
|
9
|
+
/** Optional high-quality artwork, cross-filled when another quality exists. */
|
|
10
|
+
iconUrlHigh?: string;
|
|
7
11
|
name: string;
|
|
8
12
|
nameLong?: string;
|
|
9
13
|
}
|
|
14
|
+
/** Retained conversion error surface; absent outcome artwork no longer throws it. */
|
|
10
15
|
export declare class OutcomeValidationError extends Error {
|
|
11
16
|
readonly details: string[];
|
|
12
17
|
constructor(name: string, details: string[]);
|
|
13
18
|
}
|
|
19
|
+
/** Converts outcome metadata while preserving non-blank URLs and optional artwork. */
|
|
14
20
|
export declare function outcomeFromWire(source: OutcomeResponse): Outcome;
|
|
15
21
|
//# sourceMappingURL=outcome.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/domain/market/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../../../src/domain/market/outcome.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,iFAAiF;AACjF,MAAM,WAAW,OAAO;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,qFAAqF;AACrF,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;gBAEf,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;CAK5C;AAED,sFAAsF;AACtF,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAehE"}
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.OutcomeValidationError = void 0;
|
|
4
4
|
exports.outcomeFromWire = outcomeFromWire;
|
|
5
5
|
const icon_1 = require("./icon");
|
|
6
|
+
/** Retained conversion error surface; absent outcome artwork no longer throws it. */
|
|
6
7
|
class OutcomeValidationError extends Error {
|
|
7
8
|
details;
|
|
8
9
|
constructor(name, details) {
|
|
@@ -12,18 +13,20 @@ class OutcomeValidationError extends Error {
|
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
exports.OutcomeValidationError = OutcomeValidationError;
|
|
16
|
+
/** Converts outcome metadata while preserving non-blank URLs and optional artwork. */
|
|
15
17
|
function outcomeFromWire(source) {
|
|
16
|
-
const iconUrls = (0, icon_1.resolveIconUrls)(source.icon_url_low, source.icon_url_medium, source.icon_url_high);
|
|
17
|
-
if (!iconUrls) {
|
|
18
|
-
throw new OutcomeValidationError(source.name, ["Missing icon URL"]);
|
|
19
|
-
}
|
|
18
|
+
const iconUrls = (0, icon_1.resolveIconUrls)(nonBlank(source.icon_url_low), nonBlank(source.icon_url_medium), nonBlank(source.icon_url_high));
|
|
20
19
|
return {
|
|
21
20
|
index: source.index,
|
|
22
|
-
iconUrlLow: iconUrls
|
|
23
|
-
iconUrlMedium: iconUrls
|
|
24
|
-
iconUrlHigh: iconUrls
|
|
21
|
+
iconUrlLow: iconUrls?.low,
|
|
22
|
+
iconUrlMedium: iconUrls?.medium,
|
|
23
|
+
iconUrlHigh: iconUrls?.high,
|
|
25
24
|
name: source.name,
|
|
26
25
|
nameLong: source.name_long,
|
|
27
26
|
};
|
|
28
27
|
}
|
|
28
|
+
/** Treats blank outcome artwork metadata as absent without changing non-blank URLs. */
|
|
29
|
+
function nonBlank(value) {
|
|
30
|
+
return value?.trim() ? value : undefined;
|
|
31
|
+
}
|
|
29
32
|
//# sourceMappingURL=outcome.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["../../../src/domain/market/outcome.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["../../../src/domain/market/outcome.ts"],"names":[],"mappings":";;;AA4BA,0CAeC;AA3CD,iCAAyC;AAgBzC,qFAAqF;AACrF,MAAa,sBAAuB,SAAQ,KAAK;IACtC,OAAO,CAAW;IAE3B,YAAY,IAAY,EAAE,OAAiB;QACzC,KAAK,CAAC,8BAA8B,IAAI,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AARD,wDAQC;AAED,sFAAsF;AACtF,SAAgB,eAAe,CAAC,MAAuB;IACrD,MAAM,QAAQ,GAAG,IAAA,sBAAe,EAC9B,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAC7B,QAAQ,CAAC,MAAM,CAAC,eAAe,CAAC,EAChC,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAC/B,CAAC;IAEF,OAAO;QACL,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,UAAU,EAAE,QAAQ,EAAE,GAAG;QACzB,aAAa,EAAE,QAAQ,EAAE,MAAM;QAC/B,WAAW,EAAE,QAAQ,EAAE,IAAI;QAC3B,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,QAAQ,EAAE,MAAM,CAAC,SAAS;KAC3B,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,SAAS,QAAQ,CAAC,KAAgC;IAChD,OAAO,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC","sourcesContent":["import { resolveIconUrls } from \"./icon\";\nimport type { OutcomeResponse } from \"./wire\";\n\n/** One market result whose artwork qualities are all populated or all absent. */\nexport interface Outcome {\n index: number;\n /** Optional low-quality artwork, cross-filled when another quality exists. */\n iconUrlLow?: string;\n /** Optional medium-quality artwork, cross-filled when another quality exists. */\n iconUrlMedium?: string;\n /** Optional high-quality artwork, cross-filled when another quality exists. */\n iconUrlHigh?: string;\n name: string;\n nameLong?: string;\n}\n\n/** Retained conversion error surface; absent outcome artwork no longer throws it. */\nexport class OutcomeValidationError extends Error {\n readonly details: string[];\n\n constructor(name: string, details: string[]) {\n super(`Outcome validation errors (${name}): ${details.join(\"; \")}`);\n this.name = \"OutcomeValidationError\";\n this.details = details;\n }\n}\n\n/** Converts outcome metadata while preserving non-blank URLs and optional artwork. */\nexport function outcomeFromWire(source: OutcomeResponse): Outcome {\n const iconUrls = resolveIconUrls(\n nonBlank(source.icon_url_low),\n nonBlank(source.icon_url_medium),\n nonBlank(source.icon_url_high),\n );\n\n return {\n index: source.index,\n iconUrlLow: iconUrls?.low,\n iconUrlMedium: iconUrls?.medium,\n iconUrlHigh: iconUrls?.high,\n name: source.name,\n nameLong: source.name_long,\n };\n}\n\n/** Treats blank outcome artwork metadata as absent without changing non-blank URLs. */\nfunction nonBlank(value: string | undefined | null): string | undefined {\n return value?.trim() ? value : undefined;\n}\n"]}
|
|
@@ -4,9 +4,9 @@ export interface OutcomeResponse {
|
|
|
4
4
|
index: number;
|
|
5
5
|
name: string;
|
|
6
6
|
name_long?: string;
|
|
7
|
-
icon_url_low?: string;
|
|
8
|
-
icon_url_medium?: string;
|
|
9
|
-
icon_url_high?: string;
|
|
7
|
+
icon_url_low?: string | null;
|
|
8
|
+
icon_url_medium?: string | null;
|
|
9
|
+
icon_url_high?: string | null;
|
|
10
10
|
}
|
|
11
11
|
export interface ConditionalTokenResponse {
|
|
12
12
|
id: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/domain/market/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/domain/market/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAA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AAE,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/domain/market/wire.ts"],"names":[],"mappings":";;;AAkDa,QAAA,oBAAoB,GAAG;IAClC,YAAY,EAAE,eAAe;IAC7B,MAAM,EAAE,QAAQ;CACR,CAAC","sourcesContent":["import type { OrderBookId, PubkeyStr } from \"../../shared\";\nimport type { Status } from \"./index\";\n\nexport interface OutcomeResponse {\n index: number;\n name: string;\n name_long?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n}\n\nexport interface ConditionalTokenResponse {\n id: number;\n outcome_index: number;\n token_address: string;\n symbol?: string;\n uri?: string;\n outcome?: string;\n deposit_symbol?: string;\n short_symbol?: string;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n metadata_uri?: string;\n decimals?: number;\n created_at: string;\n}\n\nexport interface DepositAssetResponse {\n display_name?: string;\n token_symbol?: string;\n symbol?: string;\n deposit_asset: string;\n id: number;\n market_pubkey: string;\n vault: string;\n num_outcomes: number;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n metadata_uri?: string;\n decimals?: number;\n min_order_size?: string | null;\n conditional_mints: ConditionalTokenResponse[];\n created_at: string;\n}\n\nexport const MarketResolutionKind = {\n SingleWinner: \"single_winner\",\n Scalar: \"scalar\",\n} as const;\n\nexport type MarketResolutionKind =\n (typeof MarketResolutionKind)[keyof typeof MarketResolutionKind];\n\nexport interface MarketResolutionPayout {\n outcome_index: number;\n payout_numerator: number;\n}\n\nexport interface MarketResolutionResponse {\n kind: MarketResolutionKind;\n payout_denominator: number;\n payouts: MarketResolutionPayout[];\n single_winning_outcome: number | null;\n}\n\nexport interface MarketResponse {\n market_name?: string;\n slug?: string;\n description?: string;\n definition?: string;\n outcomes: OutcomeResponse[];\n banner_image_url_low?: string;\n banner_image_url_medium?: string;\n banner_image_url_high?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n category?: string;\n subcategory?: string;\n tags?: string[];\n featured_rank?: number;\n market_pubkey: string;\n market_id: number;\n num_outcomes?: number;\n oracle: string;\n question_id: string;\n condition_id: string;\n market_status: string;\n /**\n * Maker fee in signed basis points (negative = rebate), set per market at\n * creation and admin-updatable on chain. Optional so an older backend that\n * doesn't serialize fees yet reads as 0 instead of failing the market fetch.\n */\n maker_fee_bps?: number;\n /**\n * Taker fee in signed basis points (negative = rebate); optional for the\n * same backend-compatibility reason as `maker_fee_bps`.\n */\n taker_fee_bps?: number;\n /** Resolution deadline as a Unix timestamp in milliseconds. */\n resolution_by: number | null;\n resolution?: MarketResolutionResponse;\n created_at: string;\n activated_at?: string;\n settled_at?: string;\n deposit_assets: DepositAssetResponse[];\n orderbooks: import(\"../orderbook/wire\").OrderbookResponse[];\n}\n\nexport interface MarketsResponse {\n markets: MarketResponse[];\n next_cursor?: number;\n has_more?: boolean;\n}\n\nexport interface SingleMarketResponse {\n market: MarketResponse;\n}\n\nexport interface SearchOrderbook {\n orderbook_id: OrderBookId;\n outcome_name: string;\n outcome_name_long?: string;\n outcome_index: number;\n deposit_base_asset: PubkeyStr;\n deposit_quote_asset: PubkeyStr;\n deposit_base_symbol: string;\n deposit_quote_symbol: string;\n base_icon_url_low?: string;\n base_icon_url_medium?: string;\n base_icon_url_high?: string;\n quote_icon_url_low?: string;\n quote_icon_url_medium?: string;\n quote_icon_url_high?: string;\n conditional_base_mint: PubkeyStr;\n conditional_quote_mint: PubkeyStr;\n outcome_icon_url_low?: string;\n outcome_icon_url_medium?: string;\n outcome_icon_url_high?: string;\n conditional_base_symbol?: string;\n conditional_quote_symbol?: string;\n latest_mid_price?: string;\n}\n\nexport interface MarketSearchResult {\n slug: string;\n market_name: string;\n market_status: Status;\n category?: string;\n tags: string[];\n featured_rank: number;\n /** Resolution deadline as a Unix timestamp in milliseconds. */\n resolution_by: number | null;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n orderbooks: SearchOrderbook[];\n}\n\nexport type MarketEvent =\n | { event_type: \"settled\"; market_pubkey: string }\n | { event_type: \"created\"; market_pubkey: string }\n | { event_type: \"opened\"; market_pubkey: string }\n | { event_type: \"paused\"; market_pubkey: string }\n | { event_type: \"orderbook_created\"; market_pubkey: string; orderbook_id: string };\n\nexport interface DepositMintsResponse {\n market_pubkey: string;\n deposit_assets: DepositAssetResponse[];\n total: number;\n}\n\nexport interface GlobalDepositAssetResponse {\n id: number;\n mint: string;\n display_name?: string;\n symbol?: string;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n decimals: number | null;\n whitelist_index: number;\n active: boolean;\n}\n\nexport interface GlobalDepositAssetsListResponse {\n assets: GlobalDepositAssetResponse[];\n total: number;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../../../src/domain/market/wire.ts"],"names":[],"mappings":";;;AAkDa,QAAA,oBAAoB,GAAG;IAClC,YAAY,EAAE,eAAe;IAC7B,MAAM,EAAE,QAAQ;CACR,CAAC","sourcesContent":["import type { OrderBookId, PubkeyStr } from \"../../shared\";\nimport type { Status } from \"./index\";\n\nexport interface OutcomeResponse {\n index: number;\n name: string;\n name_long?: string;\n icon_url_low?: string | null;\n icon_url_medium?: string | null;\n icon_url_high?: string | null;\n}\n\nexport interface ConditionalTokenResponse {\n id: number;\n outcome_index: number;\n token_address: string;\n symbol?: string;\n uri?: string;\n outcome?: string;\n deposit_symbol?: string;\n short_symbol?: string;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n metadata_uri?: string;\n decimals?: number;\n created_at: string;\n}\n\nexport interface DepositAssetResponse {\n display_name?: string;\n token_symbol?: string;\n symbol?: string;\n deposit_asset: string;\n id: number;\n market_pubkey: string;\n vault: string;\n num_outcomes: number;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n metadata_uri?: string;\n decimals?: number;\n min_order_size?: string | null;\n conditional_mints: ConditionalTokenResponse[];\n created_at: string;\n}\n\nexport const MarketResolutionKind = {\n SingleWinner: \"single_winner\",\n Scalar: \"scalar\",\n} as const;\n\nexport type MarketResolutionKind =\n (typeof MarketResolutionKind)[keyof typeof MarketResolutionKind];\n\nexport interface MarketResolutionPayout {\n outcome_index: number;\n payout_numerator: number;\n}\n\nexport interface MarketResolutionResponse {\n kind: MarketResolutionKind;\n payout_denominator: number;\n payouts: MarketResolutionPayout[];\n single_winning_outcome: number | null;\n}\n\nexport interface MarketResponse {\n market_name?: string;\n slug?: string;\n description?: string;\n definition?: string;\n outcomes: OutcomeResponse[];\n banner_image_url_low?: string;\n banner_image_url_medium?: string;\n banner_image_url_high?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n category?: string;\n subcategory?: string;\n tags?: string[];\n featured_rank?: number;\n market_pubkey: string;\n market_id: number;\n num_outcomes?: number;\n oracle: string;\n question_id: string;\n condition_id: string;\n market_status: string;\n /**\n * Maker fee in signed basis points (negative = rebate), set per market at\n * creation and admin-updatable on chain. Optional so an older backend that\n * doesn't serialize fees yet reads as 0 instead of failing the market fetch.\n */\n maker_fee_bps?: number;\n /**\n * Taker fee in signed basis points (negative = rebate); optional for the\n * same backend-compatibility reason as `maker_fee_bps`.\n */\n taker_fee_bps?: number;\n /** Resolution deadline as a Unix timestamp in milliseconds. */\n resolution_by: number | null;\n resolution?: MarketResolutionResponse;\n created_at: string;\n activated_at?: string;\n settled_at?: string;\n deposit_assets: DepositAssetResponse[];\n orderbooks: import(\"../orderbook/wire\").OrderbookResponse[];\n}\n\nexport interface MarketsResponse {\n markets: MarketResponse[];\n next_cursor?: number;\n has_more?: boolean;\n}\n\nexport interface SingleMarketResponse {\n market: MarketResponse;\n}\n\nexport interface SearchOrderbook {\n orderbook_id: OrderBookId;\n outcome_name: string;\n outcome_name_long?: string;\n outcome_index: number;\n deposit_base_asset: PubkeyStr;\n deposit_quote_asset: PubkeyStr;\n deposit_base_symbol: string;\n deposit_quote_symbol: string;\n base_icon_url_low?: string;\n base_icon_url_medium?: string;\n base_icon_url_high?: string;\n quote_icon_url_low?: string;\n quote_icon_url_medium?: string;\n quote_icon_url_high?: string;\n conditional_base_mint: PubkeyStr;\n conditional_quote_mint: PubkeyStr;\n outcome_icon_url_low?: string;\n outcome_icon_url_medium?: string;\n outcome_icon_url_high?: string;\n conditional_base_symbol?: string;\n conditional_quote_symbol?: string;\n latest_mid_price?: string;\n}\n\nexport interface MarketSearchResult {\n slug: string;\n market_name: string;\n market_status: Status;\n category?: string;\n tags: string[];\n featured_rank: number;\n /** Resolution deadline as a Unix timestamp in milliseconds. */\n resolution_by: number | null;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n orderbooks: SearchOrderbook[];\n}\n\nexport type MarketEvent =\n | { event_type: \"settled\"; market_pubkey: string }\n | { event_type: \"created\"; market_pubkey: string }\n | { event_type: \"opened\"; market_pubkey: string }\n | { event_type: \"paused\"; market_pubkey: string }\n | { event_type: \"orderbook_created\"; market_pubkey: string; orderbook_id: string };\n\nexport interface DepositMintsResponse {\n market_pubkey: string;\n deposit_assets: DepositAssetResponse[];\n total: number;\n}\n\nexport interface GlobalDepositAssetResponse {\n id: number;\n mint: string;\n display_name?: string;\n symbol?: string;\n description?: string;\n icon_url_low?: string;\n icon_url_medium?: string;\n icon_url_high?: string;\n decimals: number | null;\n whitelist_index: number;\n active: boolean;\n}\n\nexport interface GlobalDepositAssetsListResponse {\n assets: GlobalDepositAssetResponse[];\n total: number;\n}\n"]}
|
|
@@ -78,6 +78,11 @@ export interface WsBookLevel {
|
|
|
78
78
|
side: Side;
|
|
79
79
|
price: string;
|
|
80
80
|
size: string;
|
|
81
|
+
/**
|
|
82
|
+
* Exact quote-token amount represented by the underlying maker orders.
|
|
83
|
+
* For grouped books this is independent of the displayed bucket price.
|
|
84
|
+
*/
|
|
85
|
+
quote_notional: string;
|
|
81
86
|
}
|
|
82
87
|
/**
|
|
83
88
|
* WS orderbook snapshot frame.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.d.ts","sourceRoot":"","sources":["../../../src/domain/orderbook/wire.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAEpF,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,6BAA6B,EAAE,MAAM,CAAC;IACtC,6BAA6B,EAAE,OAAO,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,iBAAiB,EAAE,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;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