@pooflabs/web 0.0.61 → 0.0.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/providers/transaction-utils.d.ts +10 -0
- package/dist/{index-BcHdE9FZ.esm.js → index-AjAeq_x4.esm.js} +270 -38
- package/dist/index-AjAeq_x4.esm.js.map +1 -0
- package/dist/{index-BDbuVeBU.js → index-Ce_FPfWw.js} +271 -37
- package/dist/{index-BcHdE9FZ.esm.js.map → index-Ce_FPfWw.js.map} +1 -1
- package/dist/{index-D0CV6SvU.js → index-Cx0ON8Td.js} +2 -2
- package/dist/{index-D0CV6SvU.js.map → index-Cx0ON8Td.js.map} +1 -1
- package/dist/{index-Dphggtap.esm.js → index-Dcrdb8rn.esm.js} +2 -2
- package/dist/{index-Dphggtap.esm.js.map → index-Dcrdb8rn.esm.js.map} +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/dist/index-BDbuVeBU.js.map +0 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Connection } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* Extracts a human-readable error message from Solana transaction logs.
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractTransactionError(err: any, logMessages?: string[] | null): string;
|
|
6
|
+
/**
|
|
7
|
+
* Polls getSignatureStatuses until the transaction is confirmed, then checks for errors.
|
|
8
|
+
* Throws if the transaction failed on-chain. Returns parsed transaction info on success.
|
|
9
|
+
*/
|
|
10
|
+
export declare function confirmAndCheckTransaction(connection: Connection, signature: string): Promise<any>;
|
|
@@ -6536,10 +6536,14 @@ class WebSessionManager {
|
|
|
6536
6536
|
const newObj = JSON.parse(newSession);
|
|
6537
6537
|
return { address: newObj.address, session: newObj };
|
|
6538
6538
|
}
|
|
6539
|
+
// Refresh failed — clear stale session to prevent retry loops
|
|
6540
|
+
this.clearSession();
|
|
6539
6541
|
return null;
|
|
6540
6542
|
}
|
|
6541
6543
|
}
|
|
6542
6544
|
catch (err) {
|
|
6545
|
+
// Token decode or refresh failed — clear stale session to prevent retry loops
|
|
6546
|
+
this.clearSession();
|
|
6543
6547
|
return null;
|
|
6544
6548
|
}
|
|
6545
6549
|
return { address: sessionObj.address, session: sessionObj };
|
|
@@ -9463,15 +9467,30 @@ class ServerSessionManager {
|
|
|
9463
9467
|
constructor() {
|
|
9464
9468
|
/* Private cache (lives for the life of the process) */
|
|
9465
9469
|
this.session = null;
|
|
9470
|
+
/* Coalesce concurrent getSession() calls into a single in-flight request */
|
|
9471
|
+
this.pendingSession = null;
|
|
9466
9472
|
}
|
|
9467
9473
|
/* ---------------------------------------------- *
|
|
9468
9474
|
* GET (lazy-fetch)
|
|
9469
9475
|
* ---------------------------------------------- */
|
|
9470
9476
|
async getSession() {
|
|
9471
|
-
if (this.session
|
|
9472
|
-
this.session
|
|
9473
|
-
}
|
|
9474
|
-
|
|
9477
|
+
if (this.session !== null) {
|
|
9478
|
+
return this.session;
|
|
9479
|
+
}
|
|
9480
|
+
// If a session creation is already in-flight, reuse that promise
|
|
9481
|
+
// instead of firing a second concurrent request.
|
|
9482
|
+
if (this.pendingSession !== null) {
|
|
9483
|
+
return this.pendingSession;
|
|
9484
|
+
}
|
|
9485
|
+
this.pendingSession = createSession()
|
|
9486
|
+
.then((session) => {
|
|
9487
|
+
this.session = session;
|
|
9488
|
+
return session;
|
|
9489
|
+
})
|
|
9490
|
+
.finally(() => {
|
|
9491
|
+
this.pendingSession = null;
|
|
9492
|
+
});
|
|
9493
|
+
return this.pendingSession;
|
|
9475
9494
|
}
|
|
9476
9495
|
/* ---------------------------------------------- *
|
|
9477
9496
|
* STORE (overwrites the cached value)
|
|
@@ -9484,6 +9503,7 @@ class ServerSessionManager {
|
|
|
9484
9503
|
* ---------------------------------------------- */
|
|
9485
9504
|
clearSession() {
|
|
9486
9505
|
this.session = null;
|
|
9506
|
+
this.pendingSession = null;
|
|
9487
9507
|
}
|
|
9488
9508
|
/* ---------------------------------------------- *
|
|
9489
9509
|
* QUICK helpers
|
|
@@ -9786,6 +9806,150 @@ function hashForKey$1(value) {
|
|
|
9786
9806
|
}
|
|
9787
9807
|
return h.toString(36);
|
|
9788
9808
|
}
|
|
9809
|
+
/**
|
|
9810
|
+
* Validates that a field name is a safe identifier (alphanumeric, underscores, dots for nested paths).
|
|
9811
|
+
* Prevents prompt injection via crafted field names.
|
|
9812
|
+
*/
|
|
9813
|
+
function validateFieldName(field) {
|
|
9814
|
+
if (!/^[a-zA-Z0-9_.]+$/.test(field)) {
|
|
9815
|
+
throw new Error(`Invalid field name "${field}". Field names must only contain letters, numbers, underscores, and dots.`);
|
|
9816
|
+
}
|
|
9817
|
+
}
|
|
9818
|
+
/**
|
|
9819
|
+
* Parses a raw aggregation result (e.g. [{ count: 42 }] or [{ _id: null, total: 100 }])
|
|
9820
|
+
* into a single numeric value.
|
|
9821
|
+
*/
|
|
9822
|
+
function parseAggregateValue(result) {
|
|
9823
|
+
if (typeof result === 'number')
|
|
9824
|
+
return result;
|
|
9825
|
+
if (Array.isArray(result)) {
|
|
9826
|
+
if (result.length === 0)
|
|
9827
|
+
return 0;
|
|
9828
|
+
// Multiple elements — not a collapsed aggregate result
|
|
9829
|
+
if (result.length > 1) {
|
|
9830
|
+
throw new Error(`Unexpected aggregate result: got array with ${result.length} elements. The AI may have returned full documents instead of an aggregation.`);
|
|
9831
|
+
}
|
|
9832
|
+
const first = result[0];
|
|
9833
|
+
if (typeof first === 'number')
|
|
9834
|
+
return first;
|
|
9835
|
+
if (first && typeof first === 'object') {
|
|
9836
|
+
// $count stage returns { count: N }
|
|
9837
|
+
if (typeof first.count === 'number')
|
|
9838
|
+
return first.count;
|
|
9839
|
+
// $group stage returns { _id: null, result: N } — expect _id + one numeric field
|
|
9840
|
+
const numericEntries = Object.entries(first).filter(([key, val]) => key !== '_id' && typeof val === 'number');
|
|
9841
|
+
if (numericEntries.length === 1)
|
|
9842
|
+
return numericEntries[0][1];
|
|
9843
|
+
}
|
|
9844
|
+
// Avoid leaking document contents into error messages
|
|
9845
|
+
const shape = first && typeof first === 'object' ? `{${Object.keys(first).join(', ')}}` : String(first);
|
|
9846
|
+
throw new Error(`Unexpected aggregate result shape: ${shape}. Expected {count: N} or {_id: null, <field>: N}.`);
|
|
9847
|
+
}
|
|
9848
|
+
if (result && typeof result === 'object' && typeof result.count === 'number') {
|
|
9849
|
+
return result.count;
|
|
9850
|
+
}
|
|
9851
|
+
throw new Error(`Unexpected aggregate result type: ${typeof result}. Expected a number, array, or object with a count field.`);
|
|
9852
|
+
}
|
|
9853
|
+
/**
|
|
9854
|
+
* Count items in a collection path. Returns a numeric result.
|
|
9855
|
+
*
|
|
9856
|
+
* This uses the AI query engine with a count-specific prompt prefix,
|
|
9857
|
+
* so TaroBase will generate a $count aggregation pipeline and return
|
|
9858
|
+
* just the count rather than full documents.
|
|
9859
|
+
*
|
|
9860
|
+
* IMPORTANT: This only works for collections where the read policy is "true".
|
|
9861
|
+
* If the read policy requires per-document checks, the server will return
|
|
9862
|
+
* an error because aggregate counts cannot be performed without pulling all
|
|
9863
|
+
* documents for access control evaluation.
|
|
9864
|
+
*
|
|
9865
|
+
* @param path - Collection path (e.g., "posts", "users/abc/comments")
|
|
9866
|
+
* @param opts - Optional filter prompt and overrides
|
|
9867
|
+
* @returns AggregateResult with the count value
|
|
9868
|
+
*/
|
|
9869
|
+
async function count(path, opts = {}) {
|
|
9870
|
+
const prefix = 'Return ONLY the total count of matching documents. Use the $count stage to produce a field named "count". Do NOT return the documents themselves.';
|
|
9871
|
+
const fullPrompt = opts.prompt
|
|
9872
|
+
? `${prefix} Filter: ${opts.prompt}`
|
|
9873
|
+
: prefix;
|
|
9874
|
+
const result = await get$2(path, { prompt: fullPrompt, bypassCache: true, _overrides: opts._overrides });
|
|
9875
|
+
return { value: parseAggregateValue(result) };
|
|
9876
|
+
}
|
|
9877
|
+
/**
|
|
9878
|
+
* Run an aggregate operation on a collection path. Returns a numeric result.
|
|
9879
|
+
*
|
|
9880
|
+
* Supported operations:
|
|
9881
|
+
* - count: Total number of documents
|
|
9882
|
+
* - uniqueCount: Number of distinct values for a field
|
|
9883
|
+
* - sum: Sum of a numeric field
|
|
9884
|
+
* - avg: Average of a numeric field
|
|
9885
|
+
* - min: Minimum value of a numeric field
|
|
9886
|
+
* - max: Maximum value of a numeric field
|
|
9887
|
+
*
|
|
9888
|
+
* IMPORTANT: This only works for collections where the read policy is "true".
|
|
9889
|
+
* If the read policy requires per-document checks, the server will return
|
|
9890
|
+
* an error because aggregate operations cannot be performed without pulling
|
|
9891
|
+
* all documents for access control evaluation.
|
|
9892
|
+
*
|
|
9893
|
+
* @param path - Collection path (e.g., "posts", "users/abc/comments")
|
|
9894
|
+
* @param operation - The aggregate operation to perform
|
|
9895
|
+
* @param opts - Options including optional filter prompt and field name
|
|
9896
|
+
* @returns AggregateResult with the computed numeric value
|
|
9897
|
+
*/
|
|
9898
|
+
async function aggregate(path, operation, opts = {}) {
|
|
9899
|
+
let prefix;
|
|
9900
|
+
switch (operation) {
|
|
9901
|
+
case 'count':
|
|
9902
|
+
prefix = 'Return ONLY the total count of matching documents. Use the $count stage to produce a field named "count". Do NOT return the documents themselves.';
|
|
9903
|
+
break;
|
|
9904
|
+
case 'uniqueCount':
|
|
9905
|
+
if (!opts.field)
|
|
9906
|
+
throw new Error('aggregate "uniqueCount" requires a field option');
|
|
9907
|
+
validateFieldName(opts.field);
|
|
9908
|
+
prefix = `Return ONLY the count of unique/distinct values of the "${opts.field}" field. Use $group with _id set to "$${opts.field}" then $count to produce a field named "count". Do NOT return the documents themselves.`;
|
|
9909
|
+
break;
|
|
9910
|
+
case 'sum':
|
|
9911
|
+
if (!opts.field)
|
|
9912
|
+
throw new Error('aggregate "sum" requires a field option');
|
|
9913
|
+
validateFieldName(opts.field);
|
|
9914
|
+
prefix = `Return ONLY the sum of the "${opts.field}" field across all matching documents. Use $group with _id: null and result: { $sum: "$${opts.field}" }. Do NOT return the documents themselves.`;
|
|
9915
|
+
break;
|
|
9916
|
+
case 'avg':
|
|
9917
|
+
if (!opts.field)
|
|
9918
|
+
throw new Error('aggregate "avg" requires a field option');
|
|
9919
|
+
validateFieldName(opts.field);
|
|
9920
|
+
prefix = `Return ONLY the average of the "${opts.field}" field across all matching documents. Use $group with _id: null and result: { $avg: "$${opts.field}" }. Do NOT return the documents themselves.`;
|
|
9921
|
+
break;
|
|
9922
|
+
case 'min':
|
|
9923
|
+
if (!opts.field)
|
|
9924
|
+
throw new Error('aggregate "min" requires a field option');
|
|
9925
|
+
validateFieldName(opts.field);
|
|
9926
|
+
prefix = `Return ONLY the minimum value of the "${opts.field}" field across all matching documents. Use $group with _id: null and result: { $min: "$${opts.field}" }. Do NOT return the documents themselves.`;
|
|
9927
|
+
break;
|
|
9928
|
+
case 'max':
|
|
9929
|
+
if (!opts.field)
|
|
9930
|
+
throw new Error('aggregate "max" requires a field option');
|
|
9931
|
+
validateFieldName(opts.field);
|
|
9932
|
+
prefix = `Return ONLY the maximum value of the "${opts.field}" field across all matching documents. Use $group with _id: null and result: { $max: "$${opts.field}" }. Do NOT return the documents themselves.`;
|
|
9933
|
+
break;
|
|
9934
|
+
default:
|
|
9935
|
+
throw new Error(`Unsupported aggregate operation: ${operation}`);
|
|
9936
|
+
}
|
|
9937
|
+
const fullPrompt = opts.prompt
|
|
9938
|
+
? `${prefix} Filter: ${opts.prompt}`
|
|
9939
|
+
: prefix;
|
|
9940
|
+
const result = await get$2(path, { prompt: fullPrompt, bypassCache: true, _overrides: opts._overrides });
|
|
9941
|
+
// For uniqueCount, the AI may return $group results without the final $count
|
|
9942
|
+
// stage, producing [{_id: "val1"}, {_id: "val2"}, ...]. Verify elements look
|
|
9943
|
+
// like $group output (only _id key) before using array length as the count.
|
|
9944
|
+
if (operation === 'uniqueCount' && Array.isArray(result) && result.length > 1) {
|
|
9945
|
+
const looksLikeGroupOutput = result.every((el) => el && typeof el === 'object' && Object.keys(el).length === 1 && '_id' in el);
|
|
9946
|
+
if (looksLikeGroupOutput) {
|
|
9947
|
+
return { value: result.length };
|
|
9948
|
+
}
|
|
9949
|
+
throw new Error(`Unexpected uniqueCount result: got ${result.length} elements that don't match $group output shape.`);
|
|
9950
|
+
}
|
|
9951
|
+
return { value: parseAggregateValue(result) };
|
|
9952
|
+
}
|
|
9789
9953
|
async function get$2(path, opts = {}) {
|
|
9790
9954
|
try {
|
|
9791
9955
|
let normalizedPath = path.startsWith("/") ? path.slice(1) : path;
|
|
@@ -10252,7 +10416,7 @@ const BASE_MIN_RECONNECT_DELAY_MS = 1000;
|
|
|
10252
10416
|
const MIN_RECONNECT_DELAY_JITTER_MS = 1000;
|
|
10253
10417
|
const MAX_RECONNECT_DELAY_MS = 300000;
|
|
10254
10418
|
const RECONNECT_DELAY_GROW_FACTOR = 1.8;
|
|
10255
|
-
const MIN_BROWSER_RECONNECT_INTERVAL_MS =
|
|
10419
|
+
const MIN_BROWSER_RECONNECT_INTERVAL_MS = 5000;
|
|
10256
10420
|
const WS_CONFIG = {
|
|
10257
10421
|
// Keep retrying indefinitely so long outages recover without page refresh.
|
|
10258
10422
|
maxRetries: Infinity,
|
|
@@ -10417,6 +10581,8 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10417
10581
|
isConnected: false,
|
|
10418
10582
|
appId,
|
|
10419
10583
|
tokenRefreshTimer: null,
|
|
10584
|
+
lastMessageAt: Date.now(),
|
|
10585
|
+
keepaliveTimer: null,
|
|
10420
10586
|
};
|
|
10421
10587
|
connections.set(appId, connection);
|
|
10422
10588
|
// URL provider for reconnection with fresh tokens
|
|
@@ -10453,6 +10619,7 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10453
10619
|
ws.addEventListener('open', () => {
|
|
10454
10620
|
connection.isConnecting = false;
|
|
10455
10621
|
connection.isConnected = true;
|
|
10622
|
+
connection.lastMessageAt = Date.now();
|
|
10456
10623
|
// Schedule token refresh before expiry
|
|
10457
10624
|
(async () => {
|
|
10458
10625
|
const token = await getIdToken$1(isServer);
|
|
@@ -10460,11 +10627,28 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10460
10627
|
})();
|
|
10461
10628
|
// Re-subscribe to all existing subscriptions after reconnect
|
|
10462
10629
|
for (const sub of connection.subscriptions.values()) {
|
|
10630
|
+
sub.lastData = undefined;
|
|
10463
10631
|
sendSubscribe(connection, sub);
|
|
10464
10632
|
}
|
|
10633
|
+
// Start keepalive detection — if no messages for 90s, force reconnect
|
|
10634
|
+
if (connection.keepaliveTimer) {
|
|
10635
|
+
clearInterval(connection.keepaliveTimer);
|
|
10636
|
+
}
|
|
10637
|
+
connection.keepaliveTimer = setInterval(() => {
|
|
10638
|
+
var _a;
|
|
10639
|
+
if (Date.now() - connection.lastMessageAt > 90000) {
|
|
10640
|
+
console.warn('[WS v2] No messages received for 90s, forcing reconnect');
|
|
10641
|
+
if (connection.keepaliveTimer) {
|
|
10642
|
+
clearInterval(connection.keepaliveTimer);
|
|
10643
|
+
connection.keepaliveTimer = null;
|
|
10644
|
+
}
|
|
10645
|
+
(_a = connection.ws) === null || _a === void 0 ? void 0 : _a.reconnect();
|
|
10646
|
+
}
|
|
10647
|
+
}, 30000);
|
|
10465
10648
|
});
|
|
10466
10649
|
// Handle incoming messages
|
|
10467
10650
|
ws.addEventListener('message', (event) => {
|
|
10651
|
+
connection.lastMessageAt = Date.now();
|
|
10468
10652
|
try {
|
|
10469
10653
|
const message = JSON.parse(event.data);
|
|
10470
10654
|
handleServerMessage(connection, message);
|
|
@@ -10476,20 +10660,22 @@ async function getOrCreateConnection(appId, isServer) {
|
|
|
10476
10660
|
// Handle errors
|
|
10477
10661
|
ws.addEventListener('error', (event) => {
|
|
10478
10662
|
console.error('[WS v2] WebSocket error:', event);
|
|
10479
|
-
|
|
10480
|
-
for (const [id, pending] of connection.pendingSubscriptions) {
|
|
10663
|
+
for (const [, pending] of connection.pendingSubscriptions) {
|
|
10481
10664
|
pending.reject(new Error('WebSocket error'));
|
|
10482
|
-
connection.pendingSubscriptions.delete(id);
|
|
10483
10665
|
}
|
|
10666
|
+
connection.pendingSubscriptions.clear();
|
|
10484
10667
|
});
|
|
10485
10668
|
// Handle close
|
|
10486
10669
|
ws.addEventListener('close', () => {
|
|
10487
10670
|
connection.isConnected = false;
|
|
10488
|
-
// Clear token refresh timer
|
|
10489
10671
|
if (connection.tokenRefreshTimer) {
|
|
10490
10672
|
clearTimeout(connection.tokenRefreshTimer);
|
|
10491
10673
|
connection.tokenRefreshTimer = null;
|
|
10492
10674
|
}
|
|
10675
|
+
if (connection.keepaliveTimer) {
|
|
10676
|
+
clearInterval(connection.keepaliveTimer);
|
|
10677
|
+
connection.keepaliveTimer = null;
|
|
10678
|
+
}
|
|
10493
10679
|
});
|
|
10494
10680
|
return connection;
|
|
10495
10681
|
}
|
|
@@ -10689,9 +10875,7 @@ async function subscribeV2(path, subscriptionOptions) {
|
|
|
10689
10875
|
await subscriptionPromise;
|
|
10690
10876
|
}
|
|
10691
10877
|
catch (error) {
|
|
10692
|
-
|
|
10693
|
-
connection.subscriptions.delete(subscriptionId);
|
|
10694
|
-
throw error;
|
|
10878
|
+
console.warn('[WS v2] Subscription confirmation failed, keeping for reconnect recovery:', error);
|
|
10695
10879
|
}
|
|
10696
10880
|
}
|
|
10697
10881
|
// Return unsubscribe function
|
|
@@ -10807,8 +10991,6 @@ async function reconnectWithNewAuthV2() {
|
|
|
10807
10991
|
if (!connection.ws) {
|
|
10808
10992
|
continue;
|
|
10809
10993
|
}
|
|
10810
|
-
// Reject any pending subscriptions - they'll need to be retried after reconnect
|
|
10811
|
-
// This prevents hanging promises during auth transitions
|
|
10812
10994
|
for (const [, pending] of connection.pendingSubscriptions) {
|
|
10813
10995
|
pending.reject(new Error('Connection reconnecting due to auth change'));
|
|
10814
10996
|
}
|
|
@@ -13271,6 +13453,54 @@ function requireBuffer () {
|
|
|
13271
13453
|
|
|
13272
13454
|
var bufferExports = requireBuffer();
|
|
13273
13455
|
|
|
13456
|
+
/**
|
|
13457
|
+
* Extracts a human-readable error message from Solana transaction logs.
|
|
13458
|
+
*/
|
|
13459
|
+
function extractTransactionError(err, logMessages) {
|
|
13460
|
+
if (logMessages) {
|
|
13461
|
+
return JSON.stringify(logMessages);
|
|
13462
|
+
}
|
|
13463
|
+
if (err) {
|
|
13464
|
+
try {
|
|
13465
|
+
return JSON.stringify(err);
|
|
13466
|
+
}
|
|
13467
|
+
catch (_a) {
|
|
13468
|
+
return String(err);
|
|
13469
|
+
}
|
|
13470
|
+
}
|
|
13471
|
+
return 'Unknown transaction error';
|
|
13472
|
+
}
|
|
13473
|
+
/**
|
|
13474
|
+
* Polls getSignatureStatuses until the transaction is confirmed, then checks for errors.
|
|
13475
|
+
* Throws if the transaction failed on-chain. Returns parsed transaction info on success.
|
|
13476
|
+
*/
|
|
13477
|
+
async function confirmAndCheckTransaction(connection, signature) {
|
|
13478
|
+
var _a;
|
|
13479
|
+
const maxAttempts = 15;
|
|
13480
|
+
for (let i = 0; i < maxAttempts; i++) {
|
|
13481
|
+
const { value } = await connection.getSignatureStatuses([signature]);
|
|
13482
|
+
const status = value[0];
|
|
13483
|
+
if (status) {
|
|
13484
|
+
if (status.err) {
|
|
13485
|
+
const txInfo = await connection.getParsedTransaction(signature, {
|
|
13486
|
+
maxSupportedTransactionVersion: 0,
|
|
13487
|
+
commitment: 'confirmed'
|
|
13488
|
+
});
|
|
13489
|
+
const errorMessage = extractTransactionError(status.err, (_a = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _a === void 0 ? void 0 : _a.logMessages);
|
|
13490
|
+
throw new Error(`Transaction failed: ${errorMessage}`);
|
|
13491
|
+
}
|
|
13492
|
+
if (status.confirmationStatus === 'confirmed' || status.confirmationStatus === 'finalized') {
|
|
13493
|
+
return await connection.getParsedTransaction(signature, {
|
|
13494
|
+
maxSupportedTransactionVersion: 0,
|
|
13495
|
+
commitment: 'confirmed'
|
|
13496
|
+
});
|
|
13497
|
+
}
|
|
13498
|
+
}
|
|
13499
|
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
|
13500
|
+
}
|
|
13501
|
+
throw new Error('Transaction confirmation timeout');
|
|
13502
|
+
}
|
|
13503
|
+
|
|
13274
13504
|
const VALID_PROVIDERS = ['injected', 'google', 'apple', 'deeplink', 'phantom'];
|
|
13275
13505
|
// Dynamically import React and Phantom SDK - only when needed
|
|
13276
13506
|
let React$1;
|
|
@@ -13292,7 +13522,7 @@ async function loadDependencies() {
|
|
|
13292
13522
|
const [reactModule, reactDomModule, phantomModule] = await Promise.all([
|
|
13293
13523
|
import('react'),
|
|
13294
13524
|
import('react-dom/client'),
|
|
13295
|
-
import('./index-
|
|
13525
|
+
import('./index-Dcrdb8rn.esm.js')
|
|
13296
13526
|
]);
|
|
13297
13527
|
// Extract default export from ESM module namespace
|
|
13298
13528
|
// Dynamic import() returns { default: Module, ...exports }, not the module directly
|
|
@@ -14127,10 +14357,7 @@ class PhantomWalletProvider {
|
|
|
14127
14357
|
};
|
|
14128
14358
|
}
|
|
14129
14359
|
const signature = await this.signAndSendViaPhantom(tx);
|
|
14130
|
-
const txInfo = await connection
|
|
14131
|
-
maxSupportedTransactionVersion: 0,
|
|
14132
|
-
commitment: 'confirmed'
|
|
14133
|
-
});
|
|
14360
|
+
const txInfo = await confirmAndCheckTransaction(connection, signature);
|
|
14134
14361
|
return {
|
|
14135
14362
|
transactionSignature: signature,
|
|
14136
14363
|
blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
|
|
@@ -14316,7 +14543,9 @@ class PhantomWalletProvider {
|
|
|
14316
14543
|
const { signature } = await this.submitSignedTransactionWithBlockhash(signedTx, connection, blockhash, lastValidBlockHeight);
|
|
14317
14544
|
return signature;
|
|
14318
14545
|
}
|
|
14319
|
-
|
|
14546
|
+
const signature = await this.signAndSendViaPhantom(transaction);
|
|
14547
|
+
await confirmAndCheckTransaction(connection, signature);
|
|
14548
|
+
return signature;
|
|
14320
14549
|
}
|
|
14321
14550
|
catch (error) {
|
|
14322
14551
|
// Check if this is a connection error - if so, log out
|
|
@@ -32982,7 +33211,7 @@ class PrivyWalletProvider {
|
|
|
32982
33211
|
await this.privyMethods.logout();
|
|
32983
33212
|
}
|
|
32984
33213
|
async runTransaction(_evmTransactionData, solTransactionData, options) {
|
|
32985
|
-
var _a;
|
|
33214
|
+
var _a, _b;
|
|
32986
33215
|
await this.ensureReady({ waitForWallets: true });
|
|
32987
33216
|
let session = await WebSessionManager.getSession();
|
|
32988
33217
|
let sessionAddress = session === null || session === void 0 ? void 0 : session.address;
|
|
@@ -33064,12 +33293,12 @@ class PrivyWalletProvider {
|
|
|
33064
33293
|
};
|
|
33065
33294
|
}
|
|
33066
33295
|
// Sign and submit using shared helper
|
|
33067
|
-
const
|
|
33296
|
+
const { signature, txInfo } = await this.signAndSubmitInternal(tx, privyWallet, rpcUrl, connection);
|
|
33068
33297
|
return {
|
|
33069
|
-
transactionSignature:
|
|
33070
|
-
blockNumber: 0,
|
|
33071
|
-
gasUsed:
|
|
33072
|
-
data:
|
|
33298
|
+
transactionSignature: signature,
|
|
33299
|
+
blockNumber: (txInfo === null || txInfo === void 0 ? void 0 : txInfo.slot) || 0,
|
|
33300
|
+
gasUsed: ((_b = txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta) === null || _b === void 0 ? void 0 : _b.fee.toString()) || '0',
|
|
33301
|
+
data: txInfo === null || txInfo === void 0 ? void 0 : txInfo.meta,
|
|
33073
33302
|
};
|
|
33074
33303
|
}
|
|
33075
33304
|
catch (err) {
|
|
@@ -33215,7 +33444,8 @@ class PrivyWalletProvider {
|
|
|
33215
33444
|
// and cannot be modified after creation
|
|
33216
33445
|
}
|
|
33217
33446
|
// Use shared sign and submit logic
|
|
33218
|
-
|
|
33447
|
+
const { signature } = await this.signAndSubmitInternal(transaction, privyWallet, rpcUrl, connection);
|
|
33448
|
+
return signature;
|
|
33219
33449
|
}
|
|
33220
33450
|
// ============ Private Helpers ============
|
|
33221
33451
|
getRpcUrl(network) {
|
|
@@ -33299,15 +33529,14 @@ class PrivyWalletProvider {
|
|
|
33299
33529
|
* For Surfnet: sign with signTransactionRaw, then sendRawTransaction
|
|
33300
33530
|
* For non-Surfnet: use Privy's signAndSendTransaction (combined operation)
|
|
33301
33531
|
*/
|
|
33302
|
-
async signAndSubmitInternal(transaction, privyWallet, rpcUrl) {
|
|
33532
|
+
async signAndSubmitInternal(transaction, privyWallet, rpcUrl, connection) {
|
|
33303
33533
|
var _a;
|
|
33304
33534
|
const isSurfnet = rpcUrl === SURFNET_RPC_URL$1;
|
|
33535
|
+
let signature;
|
|
33305
33536
|
if (isSurfnet) {
|
|
33306
33537
|
// For Surfnet: sign with signTransactionRaw, then sendRawTransaction
|
|
33307
33538
|
const signedTx = await this.signTransactionRaw(transaction, privyWallet);
|
|
33308
|
-
|
|
33309
|
-
const signature = await connection.sendRawTransaction(signedTx);
|
|
33310
|
-
return signature;
|
|
33539
|
+
signature = await connection.sendRawTransaction(signedTx);
|
|
33311
33540
|
}
|
|
33312
33541
|
else {
|
|
33313
33542
|
// For non-Surfnet: use Privy's combined signAndSendTransaction
|
|
@@ -33327,13 +33556,16 @@ class PrivyWalletProvider {
|
|
|
33327
33556
|
chain: this.chainId
|
|
33328
33557
|
}));
|
|
33329
33558
|
// Handle case where signature might be bytes instead of string
|
|
33330
|
-
|
|
33331
|
-
if (
|
|
33332
|
-
|
|
33333
|
-
|
|
33559
|
+
const rawSig = result.signature;
|
|
33560
|
+
if (rawSig instanceof Uint8Array || Array.isArray(rawSig)) {
|
|
33561
|
+
signature = bs58.encode(rawSig instanceof Uint8Array ? rawSig : new Uint8Array(rawSig));
|
|
33562
|
+
}
|
|
33563
|
+
else {
|
|
33564
|
+
signature = rawSig;
|
|
33334
33565
|
}
|
|
33335
|
-
return signature;
|
|
33336
33566
|
}
|
|
33567
|
+
const txInfo = await confirmAndCheckTransaction(connection, signature);
|
|
33568
|
+
return { signature, txInfo };
|
|
33337
33569
|
}
|
|
33338
33570
|
async signMessage(message) {
|
|
33339
33571
|
var _a, _b;
|
|
@@ -34593,5 +34825,5 @@ async function getIdToken() {
|
|
|
34593
34825
|
return getIdToken$1(false);
|
|
34594
34826
|
}
|
|
34595
34827
|
|
|
34596
|
-
export {
|
|
34597
|
-
//# sourceMappingURL=index-
|
|
34828
|
+
export { useAuth as A, getIdToken as B, PrivyWalletProvider as C, DEFAULT_TEST_ADDRESS as D, buildSetDocumentsTransaction as E, clearCache as F, closeAllSubscriptions as G, convertRemainingAccounts as H, createSessionWithPrivy as I, createSessionWithSignature as J, genAuthNonce as K, genSolanaMessage as L, MockAuthProvider as M, getCachedData as N, OffchainAuthProvider as O, PhantomWalletProvider as P, reconnectWithNewAuth as Q, refreshSession as R, ServerSessionManager as S, signSessionCreateMessage as T, WebSessionManager as W, getCurrentUser as a, bufferExports as b, onAuthLoadingChanged as c, getAuthLoading as d, logout as e, getConfig as f, getDefaultExportFromCjs$1 as g, getAuthProvider as h, init as i, get$2 as j, setMany as k, login as l, setFile as m, getFiles as n, onAuthStateChanged as o, runQueryMany as p, runExpression as q, runQuery as r, set$1 as s, runExpressionMany as t, signMessage as u, signTransaction as v, signAndSubmitTransaction as w, count as x, aggregate as y, subscribe as z };
|
|
34829
|
+
//# sourceMappingURL=index-AjAeq_x4.esm.js.map
|