@unicitylabs/sphere-sdk 0.3.7 → 0.3.8
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/core/index.cjs +97 -2589
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +11 -222
- package/dist/core/index.d.ts +11 -222
- package/dist/core/index.js +93 -2585
- package/dist/core/index.js.map +1 -1
- package/dist/impl/browser/index.cjs +233 -195
- package/dist/impl/browser/index.cjs.map +1 -1
- package/dist/impl/browser/index.js +234 -198
- package/dist/impl/browser/index.js.map +1 -1
- package/dist/impl/browser/ipfs.cjs +6 -1
- package/dist/impl/browser/ipfs.cjs.map +1 -1
- package/dist/impl/browser/ipfs.js +6 -1
- package/dist/impl/browser/ipfs.js.map +1 -1
- package/dist/impl/nodejs/index.cjs +205 -142
- package/dist/impl/nodejs/index.cjs.map +1 -1
- package/dist/impl/nodejs/index.d.cts +2 -70
- package/dist/impl/nodejs/index.d.ts +2 -70
- package/dist/impl/nodejs/index.js +206 -145
- package/dist/impl/nodejs/index.js.map +1 -1
- package/dist/index.cjs +239 -2600
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +60 -226
- package/dist/index.d.ts +60 -226
- package/dist/index.js +235 -2593
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1162,7 +1162,7 @@ interface TrackedAddress extends TrackedAddressEntry {
|
|
|
1162
1162
|
/** Primary nametag (from nametag cache, without @ prefix) */
|
|
1163
1163
|
readonly nametag?: string;
|
|
1164
1164
|
}
|
|
1165
|
-
type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:
|
|
1165
|
+
type SphereEventType = 'transfer:incoming' | 'transfer:confirmed' | 'transfer:failed' | 'payment_request:incoming' | 'payment_request:accepted' | 'payment_request:rejected' | 'payment_request:paid' | 'payment_request:response' | 'message:dm' | 'message:broadcast' | 'sync:started' | 'sync:completed' | 'sync:provider' | 'sync:error' | 'connection:changed' | 'nametag:registered' | 'nametag:recovered' | 'identity:changed' | 'address:activated' | 'address:hidden' | 'address:unhidden' | 'sync:remote-update' | 'groupchat:message' | 'groupchat:joined' | 'groupchat:left' | 'groupchat:kicked' | 'groupchat:group_deleted' | 'groupchat:updated' | 'groupchat:connection';
|
|
1166
1166
|
interface SphereEventMap {
|
|
1167
1167
|
'transfer:incoming': IncomingTransfer;
|
|
1168
1168
|
'transfer:confirmed': TransferResult;
|
|
@@ -1173,15 +1173,6 @@ interface SphereEventMap {
|
|
|
1173
1173
|
'payment_request:paid': IncomingPaymentRequest$1;
|
|
1174
1174
|
'payment_request:response': PaymentRequestResponse;
|
|
1175
1175
|
'message:dm': DirectMessage;
|
|
1176
|
-
'message:read': {
|
|
1177
|
-
messageIds: string[];
|
|
1178
|
-
peerPubkey: string;
|
|
1179
|
-
};
|
|
1180
|
-
'message:typing': {
|
|
1181
|
-
senderPubkey: string;
|
|
1182
|
-
senderNametag?: string;
|
|
1183
|
-
timestamp: number;
|
|
1184
|
-
};
|
|
1185
1176
|
'message:broadcast': BroadcastMessage;
|
|
1186
1177
|
'sync:started': {
|
|
1187
1178
|
source: string;
|
|
@@ -1551,27 +1542,6 @@ interface TransportProvider extends BaseProvider {
|
|
|
1551
1542
|
* @returns Unsubscribe function
|
|
1552
1543
|
*/
|
|
1553
1544
|
onPaymentRequestResponse?(handler: PaymentRequestResponseHandler): () => void;
|
|
1554
|
-
/**
|
|
1555
|
-
* Send a read receipt for a message
|
|
1556
|
-
* @param recipientTransportPubkey - Transport pubkey of the message sender
|
|
1557
|
-
* @param messageEventId - Event ID of the message being acknowledged
|
|
1558
|
-
*/
|
|
1559
|
-
sendReadReceipt?(recipientTransportPubkey: string, messageEventId: string): Promise<void>;
|
|
1560
|
-
/**
|
|
1561
|
-
* Subscribe to incoming read receipts
|
|
1562
|
-
* @returns Unsubscribe function
|
|
1563
|
-
*/
|
|
1564
|
-
onReadReceipt?(handler: ReadReceiptHandler): () => void;
|
|
1565
|
-
/**
|
|
1566
|
-
* Send typing indicator to a recipient
|
|
1567
|
-
* @param recipientTransportPubkey - Transport pubkey of the conversation partner
|
|
1568
|
-
*/
|
|
1569
|
-
sendTypingIndicator?(recipientTransportPubkey: string): Promise<void>;
|
|
1570
|
-
/**
|
|
1571
|
-
* Subscribe to incoming typing indicators
|
|
1572
|
-
* @returns Unsubscribe function
|
|
1573
|
-
*/
|
|
1574
|
-
onTypingIndicator?(handler: TypingIndicatorHandler): () => void;
|
|
1575
1545
|
/**
|
|
1576
1546
|
* Get list of configured relay URLs
|
|
1577
1547
|
*/
|
|
@@ -1661,10 +1631,6 @@ interface IncomingMessage {
|
|
|
1661
1631
|
content: string;
|
|
1662
1632
|
timestamp: number;
|
|
1663
1633
|
encrypted: boolean;
|
|
1664
|
-
/** Set when this is a self-wrap replay (sent message recovered from relay) */
|
|
1665
|
-
isSelfWrap?: boolean;
|
|
1666
|
-
/** Recipient pubkey — only present on self-wrap replays */
|
|
1667
|
-
recipientTransportPubkey?: string;
|
|
1668
1634
|
}
|
|
1669
1635
|
type MessageHandler = (message: IncomingMessage) => void;
|
|
1670
1636
|
interface TokenTransferPayload {
|
|
@@ -1786,24 +1752,6 @@ interface PeerInfo {
|
|
|
1786
1752
|
/** Event timestamp */
|
|
1787
1753
|
timestamp: number;
|
|
1788
1754
|
}
|
|
1789
|
-
interface IncomingReadReceipt {
|
|
1790
|
-
/** Transport-specific pubkey of the sender who read the message */
|
|
1791
|
-
senderTransportPubkey: string;
|
|
1792
|
-
/** Event ID of the message that was read */
|
|
1793
|
-
messageEventId: string;
|
|
1794
|
-
/** Timestamp */
|
|
1795
|
-
timestamp: number;
|
|
1796
|
-
}
|
|
1797
|
-
type ReadReceiptHandler = (receipt: IncomingReadReceipt) => void;
|
|
1798
|
-
interface IncomingTypingIndicator {
|
|
1799
|
-
/** Transport-specific pubkey of the sender who is typing */
|
|
1800
|
-
senderTransportPubkey: string;
|
|
1801
|
-
/** Sender's nametag (if known) */
|
|
1802
|
-
senderNametag?: string;
|
|
1803
|
-
/** Timestamp */
|
|
1804
|
-
timestamp: number;
|
|
1805
|
-
}
|
|
1806
|
-
type TypingIndicatorHandler = (indicator: IncomingTypingIndicator) => void;
|
|
1807
1755
|
|
|
1808
1756
|
/**
|
|
1809
1757
|
* L1 Payments Sub-Module
|
|
@@ -2272,6 +2220,7 @@ type AggregatorEventCallback = OracleEventCallback;
|
|
|
2272
2220
|
* Platform-independent abstraction for fetching token market prices.
|
|
2273
2221
|
* Does not extend BaseProvider — stateless HTTP client with internal caching.
|
|
2274
2222
|
*/
|
|
2223
|
+
|
|
2275
2224
|
/**
|
|
2276
2225
|
* Supported price provider platforms
|
|
2277
2226
|
*/
|
|
@@ -2307,6 +2256,8 @@ interface PriceProviderConfig {
|
|
|
2307
2256
|
timeout?: number;
|
|
2308
2257
|
/** Enable debug logging */
|
|
2309
2258
|
debug?: boolean;
|
|
2259
|
+
/** StorageProvider for persistent caching across page reloads (optional) */
|
|
2260
|
+
storage?: StorageProvider;
|
|
2310
2261
|
}
|
|
2311
2262
|
/**
|
|
2312
2263
|
* Price data provider
|
|
@@ -2333,7 +2284,7 @@ interface PriceProvider {
|
|
|
2333
2284
|
/**
|
|
2334
2285
|
* Get price for a single token
|
|
2335
2286
|
* @param tokenName - Token name (e.g., 'bitcoin')
|
|
2336
|
-
* @returns Token price or null
|
|
2287
|
+
* @returns Token price (zero-price entry for tokens not listed on the platform), or null on network error with no cache
|
|
2337
2288
|
*/
|
|
2338
2289
|
getPrice(tokenName: string): Promise<TokenPrice | null>;
|
|
2339
2290
|
/**
|
|
@@ -2347,6 +2298,7 @@ interface PriceProvider {
|
|
|
2347
2298
|
*
|
|
2348
2299
|
* Fetches token prices from CoinGecko API with internal caching.
|
|
2349
2300
|
* Supports both free and pro API tiers.
|
|
2301
|
+
* Optionally persists cache to StorageProvider for survival across page reloads.
|
|
2350
2302
|
*/
|
|
2351
2303
|
|
|
2352
2304
|
/**
|
|
@@ -2360,6 +2312,9 @@ interface PriceProvider {
|
|
|
2360
2312
|
* // Pro tier
|
|
2361
2313
|
* const provider = new CoinGeckoPriceProvider({ apiKey: 'CG-xxx' });
|
|
2362
2314
|
*
|
|
2315
|
+
* // With persistent cache (survives page reloads)
|
|
2316
|
+
* const provider = new CoinGeckoPriceProvider({ storage: myStorageProvider });
|
|
2317
|
+
*
|
|
2363
2318
|
* const prices = await provider.getPrices(['bitcoin', 'ethereum']);
|
|
2364
2319
|
* console.log(prices.get('bitcoin')?.priceUsd);
|
|
2365
2320
|
* ```
|
|
@@ -2372,8 +2327,33 @@ declare class CoinGeckoPriceProvider implements PriceProvider {
|
|
|
2372
2327
|
private readonly timeout;
|
|
2373
2328
|
private readonly debug;
|
|
2374
2329
|
private readonly baseUrl;
|
|
2330
|
+
private readonly storage;
|
|
2331
|
+
/** In-flight fetch promise for deduplication of concurrent getPrices() calls */
|
|
2332
|
+
private fetchPromise;
|
|
2333
|
+
/** Token names being fetched in the current in-flight request */
|
|
2334
|
+
private fetchNames;
|
|
2335
|
+
/** Whether persistent cache has been loaded into memory */
|
|
2336
|
+
private persistentCacheLoaded;
|
|
2337
|
+
/** Promise for loading persistent cache (deduplication) */
|
|
2338
|
+
private loadCachePromise;
|
|
2375
2339
|
constructor(config?: Omit<PriceProviderConfig, 'platform'>);
|
|
2376
2340
|
getPrices(tokenNames: string[]): Promise<Map<string, TokenPrice>>;
|
|
2341
|
+
private doFetch;
|
|
2342
|
+
/**
|
|
2343
|
+
* Load cached prices from StorageProvider into in-memory cache.
|
|
2344
|
+
* Only loads entries that are still within cacheTtlMs.
|
|
2345
|
+
*/
|
|
2346
|
+
private loadFromStorage;
|
|
2347
|
+
private doLoadFromStorage;
|
|
2348
|
+
/**
|
|
2349
|
+
* Save current prices to StorageProvider (fire-and-forget).
|
|
2350
|
+
*/
|
|
2351
|
+
private saveToStorage;
|
|
2352
|
+
/**
|
|
2353
|
+
* On 429 rate-limit, extend stale cache entries so subsequent calls
|
|
2354
|
+
* don't immediately retry and hammer the API.
|
|
2355
|
+
*/
|
|
2356
|
+
private extendCacheOnRateLimit;
|
|
2377
2357
|
getPrice(tokenName: string): Promise<TokenPrice | null>;
|
|
2378
2358
|
clearCache(): void;
|
|
2379
2359
|
}
|
|
@@ -3222,10 +3202,6 @@ declare class CommunicationsModule {
|
|
|
3222
3202
|
* Get unread count
|
|
3223
3203
|
*/
|
|
3224
3204
|
getUnreadCount(peerPubkey?: string): number;
|
|
3225
|
-
/**
|
|
3226
|
-
* Send typing indicator to a peer
|
|
3227
|
-
*/
|
|
3228
|
-
sendTypingIndicator(peerPubkey: string): Promise<void>;
|
|
3229
3205
|
/**
|
|
3230
3206
|
* Subscribe to incoming DMs
|
|
3231
3207
|
*/
|
|
@@ -3376,155 +3352,6 @@ declare class GroupChatModule {
|
|
|
3376
3352
|
}
|
|
3377
3353
|
declare function createGroupChatModule(config?: GroupChatModuleConfig): GroupChatModule;
|
|
3378
3354
|
|
|
3379
|
-
/**
|
|
3380
|
-
* Market Module Types
|
|
3381
|
-
* Intent bulletin board for posting and discovering intents,
|
|
3382
|
-
* plus real-time feed subscription.
|
|
3383
|
-
*/
|
|
3384
|
-
type IntentType = 'buy' | 'sell' | 'service' | 'announcement' | 'other' | (string & {});
|
|
3385
|
-
type IntentStatus = 'active' | 'closed' | 'expired';
|
|
3386
|
-
interface MarketModuleConfig {
|
|
3387
|
-
/** Market API base URL (default: https://market-api.unicity.network) */
|
|
3388
|
-
apiUrl?: string;
|
|
3389
|
-
/** Request timeout in ms (default: 30000) */
|
|
3390
|
-
timeout?: number;
|
|
3391
|
-
}
|
|
3392
|
-
interface MarketModuleDependencies {
|
|
3393
|
-
identity: FullIdentity;
|
|
3394
|
-
emitEvent: <T extends SphereEventType>(type: T, data: SphereEventMap[T]) => void;
|
|
3395
|
-
}
|
|
3396
|
-
interface PostIntentRequest {
|
|
3397
|
-
description: string;
|
|
3398
|
-
intentType: IntentType;
|
|
3399
|
-
category?: string;
|
|
3400
|
-
price?: number;
|
|
3401
|
-
currency?: string;
|
|
3402
|
-
location?: string;
|
|
3403
|
-
contactHandle?: string;
|
|
3404
|
-
expiresInDays?: number;
|
|
3405
|
-
}
|
|
3406
|
-
interface PostIntentResult {
|
|
3407
|
-
intentId: string;
|
|
3408
|
-
message: string;
|
|
3409
|
-
expiresAt: string;
|
|
3410
|
-
}
|
|
3411
|
-
interface MarketIntent {
|
|
3412
|
-
id: string;
|
|
3413
|
-
intentType: IntentType;
|
|
3414
|
-
category?: string;
|
|
3415
|
-
price?: string;
|
|
3416
|
-
currency: string;
|
|
3417
|
-
location?: string;
|
|
3418
|
-
status: IntentStatus;
|
|
3419
|
-
createdAt: string;
|
|
3420
|
-
expiresAt: string;
|
|
3421
|
-
}
|
|
3422
|
-
interface SearchIntentResult {
|
|
3423
|
-
id: string;
|
|
3424
|
-
score: number;
|
|
3425
|
-
agentNametag?: string;
|
|
3426
|
-
agentPublicKey: string;
|
|
3427
|
-
description: string;
|
|
3428
|
-
intentType: IntentType;
|
|
3429
|
-
category?: string;
|
|
3430
|
-
price?: number;
|
|
3431
|
-
currency: string;
|
|
3432
|
-
location?: string;
|
|
3433
|
-
contactMethod: string;
|
|
3434
|
-
contactHandle?: string;
|
|
3435
|
-
createdAt: string;
|
|
3436
|
-
expiresAt: string;
|
|
3437
|
-
}
|
|
3438
|
-
interface SearchFilters {
|
|
3439
|
-
intentType?: IntentType;
|
|
3440
|
-
category?: string;
|
|
3441
|
-
minPrice?: number;
|
|
3442
|
-
maxPrice?: number;
|
|
3443
|
-
location?: string;
|
|
3444
|
-
/** Minimum similarity score (0–1). Results below this threshold are excluded (client-side). */
|
|
3445
|
-
minScore?: number;
|
|
3446
|
-
}
|
|
3447
|
-
interface SearchOptions {
|
|
3448
|
-
filters?: SearchFilters;
|
|
3449
|
-
limit?: number;
|
|
3450
|
-
}
|
|
3451
|
-
interface SearchResult {
|
|
3452
|
-
intents: SearchIntentResult[];
|
|
3453
|
-
count: number;
|
|
3454
|
-
}
|
|
3455
|
-
/** A listing broadcast on the live feed */
|
|
3456
|
-
interface FeedListing {
|
|
3457
|
-
id: string;
|
|
3458
|
-
title: string;
|
|
3459
|
-
descriptionPreview: string;
|
|
3460
|
-
agentName: string;
|
|
3461
|
-
agentId: number;
|
|
3462
|
-
type: IntentType;
|
|
3463
|
-
createdAt: string;
|
|
3464
|
-
}
|
|
3465
|
-
/** WebSocket message: initial batch of recent listings */
|
|
3466
|
-
interface FeedInitialMessage {
|
|
3467
|
-
type: 'initial';
|
|
3468
|
-
listings: FeedListing[];
|
|
3469
|
-
}
|
|
3470
|
-
/** WebSocket message: single new listing */
|
|
3471
|
-
interface FeedNewMessage {
|
|
3472
|
-
type: 'new';
|
|
3473
|
-
listing: FeedListing;
|
|
3474
|
-
}
|
|
3475
|
-
type FeedMessage = FeedInitialMessage | FeedNewMessage;
|
|
3476
|
-
/** Callback for live feed events */
|
|
3477
|
-
type FeedListener = (message: FeedMessage) => void;
|
|
3478
|
-
|
|
3479
|
-
/**
|
|
3480
|
-
* Market Module
|
|
3481
|
-
*
|
|
3482
|
-
* Intent bulletin board — post and discover intents (buy, sell,
|
|
3483
|
-
* service, announcement, other) with secp256k1-signed requests
|
|
3484
|
-
* tied to the wallet identity. Includes real-time feed via WebSocket.
|
|
3485
|
-
*/
|
|
3486
|
-
|
|
3487
|
-
declare class MarketModule {
|
|
3488
|
-
private readonly apiUrl;
|
|
3489
|
-
private readonly timeout;
|
|
3490
|
-
private identity;
|
|
3491
|
-
private registered;
|
|
3492
|
-
constructor(config?: MarketModuleConfig);
|
|
3493
|
-
/** Called by Sphere after construction */
|
|
3494
|
-
initialize(deps: MarketModuleDependencies): void;
|
|
3495
|
-
/** No-op — stateless module */
|
|
3496
|
-
load(): Promise<void>;
|
|
3497
|
-
/** No-op — stateless module */
|
|
3498
|
-
destroy(): void;
|
|
3499
|
-
/** Post a new intent (agent is auto-registered on first post) */
|
|
3500
|
-
postIntent(intent: PostIntentRequest): Promise<PostIntentResult>;
|
|
3501
|
-
/** Semantic search for intents (public — no auth required) */
|
|
3502
|
-
search(query: string, opts?: SearchOptions): Promise<SearchResult>;
|
|
3503
|
-
/** List own intents (authenticated) */
|
|
3504
|
-
getMyIntents(): Promise<MarketIntent[]>;
|
|
3505
|
-
/** Close (delete) an intent */
|
|
3506
|
-
closeIntent(intentId: string): Promise<void>;
|
|
3507
|
-
/** Fetch the most recent listings via REST (public — no auth required) */
|
|
3508
|
-
getRecentListings(): Promise<FeedListing[]>;
|
|
3509
|
-
/**
|
|
3510
|
-
* Subscribe to the live listing feed via WebSocket.
|
|
3511
|
-
* Returns an unsubscribe function that closes the connection.
|
|
3512
|
-
*
|
|
3513
|
-
* Requires a WebSocket implementation — works natively in browsers
|
|
3514
|
-
* and in Node.js 21+ (or with the `ws` package).
|
|
3515
|
-
*/
|
|
3516
|
-
subscribeFeed(listener: FeedListener): () => void;
|
|
3517
|
-
private ensureIdentity;
|
|
3518
|
-
/** Register the agent's public key with the server (idempotent) */
|
|
3519
|
-
private ensureRegistered;
|
|
3520
|
-
private parseResponse;
|
|
3521
|
-
private apiPost;
|
|
3522
|
-
private apiGet;
|
|
3523
|
-
private apiDelete;
|
|
3524
|
-
private apiPublicPost;
|
|
3525
|
-
}
|
|
3526
|
-
declare function createMarketModule(config?: MarketModuleConfig): MarketModule;
|
|
3527
|
-
|
|
3528
3355
|
/**
|
|
3529
3356
|
* SDK2 Constants
|
|
3530
3357
|
* Default configuration values and storage keys
|
|
@@ -3583,6 +3410,10 @@ declare const STORAGE_KEYS: {
|
|
|
3583
3410
|
readonly TOKEN_REGISTRY_CACHE: "token_registry_cache";
|
|
3584
3411
|
/** Timestamp of last token registry cache update (ms since epoch) */
|
|
3585
3412
|
readonly TOKEN_REGISTRY_CACHE_TS: "token_registry_cache_ts";
|
|
3413
|
+
/** Cached price data JSON (from CoinGecko or other provider) */
|
|
3414
|
+
readonly PRICE_CACHE: "price_cache";
|
|
3415
|
+
/** Timestamp of last price cache update (ms since epoch) */
|
|
3416
|
+
readonly PRICE_CACHE_TS: "price_cache_ts";
|
|
3586
3417
|
};
|
|
3587
3418
|
/** Default Nostr relays */
|
|
3588
3419
|
declare const DEFAULT_NOSTR_RELAYS: readonly ["wss://relay.unicity.network", "wss://relay.damus.io", "wss://nos.lol", "wss://relay.nostr.band"];
|
|
@@ -3716,8 +3547,6 @@ declare const TIMEOUTS: {
|
|
|
3716
3547
|
/** Sync interval */
|
|
3717
3548
|
readonly SYNC_INTERVAL: 60000;
|
|
3718
3549
|
};
|
|
3719
|
-
/** Default Market API URL (intent bulletin board) */
|
|
3720
|
-
declare const DEFAULT_MARKET_API_URL: "https://market-api.unicity.network";
|
|
3721
3550
|
/** Validation limits */
|
|
3722
3551
|
declare const LIMITS: {
|
|
3723
3552
|
/** Min nametag length */
|
|
@@ -3883,8 +3712,6 @@ interface SphereCreateOptions {
|
|
|
3883
3712
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3884
3713
|
/** Optional password to encrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3885
3714
|
password?: string;
|
|
3886
|
-
/** Market module configuration. true = enable with defaults, object = custom config. */
|
|
3887
|
-
market?: MarketModuleConfig | boolean;
|
|
3888
3715
|
}
|
|
3889
3716
|
/** Options for loading existing wallet */
|
|
3890
3717
|
interface SphereLoadOptions {
|
|
@@ -3910,8 +3737,6 @@ interface SphereLoadOptions {
|
|
|
3910
3737
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3911
3738
|
/** Optional password to decrypt the wallet. Must match the password used during creation. */
|
|
3912
3739
|
password?: string;
|
|
3913
|
-
/** Market module configuration. true = enable with defaults, object = custom config. */
|
|
3914
|
-
market?: MarketModuleConfig | boolean;
|
|
3915
3740
|
}
|
|
3916
3741
|
/** Options for importing a wallet */
|
|
3917
3742
|
interface SphereImportOptions {
|
|
@@ -3945,8 +3770,6 @@ interface SphereImportOptions {
|
|
|
3945
3770
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3946
3771
|
/** Optional password to encrypt the wallet. If omitted, mnemonic/key is stored as plaintext. */
|
|
3947
3772
|
password?: string;
|
|
3948
|
-
/** Market module configuration. true = enable with defaults, object = custom config. */
|
|
3949
|
-
market?: MarketModuleConfig | boolean;
|
|
3950
3773
|
}
|
|
3951
3774
|
/** L1 (ALPHA blockchain) configuration */
|
|
3952
3775
|
interface L1Config {
|
|
@@ -3994,8 +3817,6 @@ interface SphereInitOptions {
|
|
|
3994
3817
|
groupChat?: GroupChatModuleConfig | boolean;
|
|
3995
3818
|
/** Optional password to encrypt/decrypt the wallet. If omitted, mnemonic is stored as plaintext. */
|
|
3996
3819
|
password?: string;
|
|
3997
|
-
/** Market module configuration. true = enable with defaults, object = custom config. */
|
|
3998
|
-
market?: MarketModuleConfig | boolean;
|
|
3999
3820
|
}
|
|
4000
3821
|
/** Result of init operation */
|
|
4001
3822
|
interface SphereInitResult {
|
|
@@ -4033,7 +3854,6 @@ declare class Sphere {
|
|
|
4033
3854
|
private _payments;
|
|
4034
3855
|
private _communications;
|
|
4035
3856
|
private _groupChat;
|
|
4036
|
-
private _market;
|
|
4037
3857
|
private eventHandlers;
|
|
4038
3858
|
private _disabledProviders;
|
|
4039
3859
|
private _providerEventCleanups;
|
|
@@ -4082,12 +3902,15 @@ declare class Sphere {
|
|
|
4082
3902
|
*/
|
|
4083
3903
|
private static resolveGroupChatConfig;
|
|
4084
3904
|
/**
|
|
4085
|
-
*
|
|
4086
|
-
*
|
|
4087
|
-
*
|
|
4088
|
-
*
|
|
3905
|
+
* Configure TokenRegistry in the main bundle context.
|
|
3906
|
+
*
|
|
3907
|
+
* The provider factory functions (createBrowserProviders / createNodeProviders)
|
|
3908
|
+
* are compiled into separate bundles by tsup, each with their own inlined copy
|
|
3909
|
+
* of TokenRegistry. Their TokenRegistry.configure() call configures a different
|
|
3910
|
+
* singleton than the one used by PaymentsModule (which lives in the main bundle).
|
|
3911
|
+
* This method ensures the main bundle's TokenRegistry is properly configured.
|
|
4089
3912
|
*/
|
|
4090
|
-
private static
|
|
3913
|
+
private static configureTokenRegistry;
|
|
4091
3914
|
/**
|
|
4092
3915
|
* Create new wallet with mnemonic
|
|
4093
3916
|
*/
|
|
@@ -4146,8 +3969,6 @@ declare class Sphere {
|
|
|
4146
3969
|
get communications(): CommunicationsModule;
|
|
4147
3970
|
/** Group chat module (NIP-29). Null if not configured. */
|
|
4148
3971
|
get groupChat(): GroupChatModule | null;
|
|
4149
|
-
/** Market module (intent bulletin board). Null if not configured. */
|
|
4150
|
-
get market(): MarketModule | null;
|
|
4151
3972
|
/** Current identity (public info only) */
|
|
4152
3973
|
get identity(): Identity | null;
|
|
4153
3974
|
/** Is ready */
|
|
@@ -6023,6 +5844,7 @@ declare class TokenRegistry {
|
|
|
6023
5844
|
private refreshTimer;
|
|
6024
5845
|
private lastRefreshAt;
|
|
6025
5846
|
private refreshPromise;
|
|
5847
|
+
private initialLoadPromise;
|
|
6026
5848
|
private constructor();
|
|
6027
5849
|
/**
|
|
6028
5850
|
* Get singleton instance of TokenRegistry
|
|
@@ -6051,6 +5873,18 @@ declare class TokenRegistry {
|
|
|
6051
5873
|
* Destroy the singleton: stop auto-refresh and reset.
|
|
6052
5874
|
*/
|
|
6053
5875
|
static destroy(): void;
|
|
5876
|
+
/**
|
|
5877
|
+
* Wait for the initial data load (cache or remote) to complete.
|
|
5878
|
+
* Returns true if data was loaded, false if not (timeout or no data source).
|
|
5879
|
+
*
|
|
5880
|
+
* @param timeoutMs - Maximum wait time in ms (default: 10s). Set to 0 for no timeout.
|
|
5881
|
+
*/
|
|
5882
|
+
static waitForReady(timeoutMs?: number): Promise<boolean>;
|
|
5883
|
+
/**
|
|
5884
|
+
* Perform initial data load: try cache first, fall back to remote fetch.
|
|
5885
|
+
* After initial data is available, start periodic auto-refresh if configured.
|
|
5886
|
+
*/
|
|
5887
|
+
private performInitialLoad;
|
|
6054
5888
|
/**
|
|
6055
5889
|
* Load definitions from StorageProvider cache.
|
|
6056
5890
|
* Only applies if cache exists and is fresh (within refreshIntervalMs).
|
|
@@ -6217,4 +6051,4 @@ declare function getCoinIdBySymbol(symbol: string): string | undefined;
|
|
|
6217
6051
|
*/
|
|
6218
6052
|
declare function getCoinIdByName(name: string): string | undefined;
|
|
6219
6053
|
|
|
6220
|
-
export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type CreateGroupOptions, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS,
|
|
6054
|
+
export { type AddressInfo, type AddressMode, type AggregatorClient, type AggregatorEvent, type AggregatorEventCallback, type AggregatorEventType, type AggregatorProvider, type AggregatorProviderConfig, type Asset, type BackgroundProgressStatus, type BaseProvider, type BroadcastHandler, type BroadcastMessage, type CMasterKeyData, COIN_TYPES, type CheckNetworkHealthOptions, CoinGeckoPriceProvider, CommunicationsModule, type CommunicationsModuleConfig, type CommunicationsModuleDependencies, type CreateGroupOptions, DEFAULT_AGGREGATOR_TIMEOUT, DEFAULT_AGGREGATOR_URL, DEFAULT_DERIVATION_PATH, DEFAULT_ELECTRUM_URL, DEFAULT_GROUP_RELAYS, DEFAULT_IPFS_BOOTSTRAP_PEERS, DEFAULT_IPFS_GATEWAYS, DEFAULT_NOSTR_RELAYS, DEV_AGGREGATOR_URL, type DecryptionProgressCallback, type DerivationMode, type DirectMessage, type ExtendedValidationResult, type FullIdentity, GroupChatModule, type GroupChatModuleConfig, type GroupChatModuleDependencies, type GroupData, type GroupMemberData, type GroupMessageData, GroupRole, GroupVisibility, type HealthCheckFn, type Identity, type IdentityConfig, type InclusionProof, type IncomingBroadcast, type IncomingMessage, type IncomingPaymentRequest$1 as IncomingPaymentRequest, type IncomingTokenTransfer, type IncomingTransfer, type InstantSplitBundle, type InstantSplitBundleV4, type InstantSplitBundleV5, type InstantSplitOptions, type InstantSplitProcessResult, type InstantSplitResult, type InstantSplitV5RecoveryMetadata, type InvalidatedNametagEntry, index as L1, type L1Balance, L1PaymentsModule, type L1PaymentsModuleConfig, type L1PaymentsModuleDependencies, type L1SendRequest, type L1SendResult, type L1Transaction, type L1Utxo, LIMITS, type LegacyFileImportOptions, type LegacyFileInfo, type LegacyFileParseResult, type LegacyFileParsedData, type LegacyFileType, type LoadResult, type LoggingConfig, type MessageHandler, type MintOutboxEntry, type MintParams, type MintResult, NETWORKS, NIP29_KINDS, NOSTR_EVENT_KINDS, type NametagData, type NetworkHealthResult, type NetworkType, type OracleEvent, type OracleEventCallback, type OracleEventType, type OracleProvider, type OutboxEntry, type OutgoingPaymentRequest, type ParsedStorageData, type PaymentRequest, type PaymentRequestHandler$1 as PaymentRequestHandler, type PaymentRequestResponse, type PaymentRequestResponseHandler$1 as PaymentRequestResponseHandler, type PaymentRequestResponseType$1 as PaymentRequestResponseType, type PaymentRequestResult, type PaymentRequestStatus, type PaymentSession, type PaymentSessionDirection, type PaymentSessionError, type PaymentSessionErrorCode, type PaymentSessionStatus, PaymentsModule, type PaymentsModuleConfig, type PaymentsModuleDependencies, type PeerInfo, type PendingV5Finalization, type PricePlatform, type PriceProvider, type PriceProviderConfig, type ProviderMetadata, type ProviderRole, type ProviderStatus, type ProviderStatusInfo, type ReceiveOptions, type ReceiveResult, type RegistryNetwork, STORAGE_KEYS, STORAGE_PREFIX, type SaveResult, type ScanAddressProgress, type ScanAddressesOptions, type ScanAddressesResult, type ScannedAddressResult, type ServiceHealthResult, type SpentTokenInfo, type SpentTokenResult, Sphere, type SphereConfig, type SphereCreateOptions, SphereError, type SphereErrorCode, type SphereEventHandler, type SphereEventMap, type SphereEventType, type SphereInitOptions, type SphereInitResult, type SphereLoadOptions, type SphereStatus, type SplitPaymentSession, type SplitRecoveryResult, type StorageEvent, type StorageEventCallback, type StorageEventType, type StorageProvider, type StorageProviderConfig, type SubmitResult, type SyncResult, TEST_AGGREGATOR_URL, TEST_ELECTRUM_URL, TEST_NOSTR_RELAYS, TIMEOUTS, type Token, type TokenDefinition, type TokenIcon, type TokenPrice, TokenRegistry, type TokenState, type TokenStatus, type TokenStorageProvider, type TokenTransferDetail, type TokenTransferHandler, type TokenTransferPayload, type ValidationResult as TokenValidationResult, TokenValidator, type TombstoneEntry, type TrackedAddress, type TrackedAddressEntry, type TransactionHistoryEntry, type TransferCommitment, type TransferMode, type TransferRequest, type TransferResult, type TransferStatus, type TransportEvent, type TransportEventCallback, type TransportEventType, type TransportProvider, type TransportProviderConfig, type TrustBaseLoader, type TxfAuthenticator, type TxfGenesis, type TxfGenesisData, type TxfInclusionProof, type TxfIntegrity, type TxfInvalidEntry, type TxfMerkleStep, type TxfMerkleTreePath, type TxfMeta, type TxfOutboxEntry, type TxfSentEntry, type TxfState, type TxfStorageData, type TxfStorageDataBase, type TxfToken, type TxfTombstone, type TxfTransaction, type UnconfirmedResolutionResult, type V5FinalizationStage, type ValidationAction, type ValidationIssue, type ValidationResult$1 as ValidationResult, type WaitOptions, type WalletDatInfo, type WalletInfo, type WalletJSON$1 as WalletJSON, type WalletJSONExportOptions$1 as WalletJSONExportOptions, type WalletSource, archivedKeyFromTokenId, base58Decode, base58Encode, buildTxfStorageData, bytesToHex, checkNetworkHealth, countCommittedTransactions, createAddress, createCommunicationsModule, createGroupChatModule, createKeyPair, createL1PaymentsModule, createPaymentSession, createPaymentSessionError, createPaymentsModule, createPriceProvider, createSphere, createSplitPaymentSession, createTokenValidator, decodeBech32, decryptCMasterKey, decryptPrivateKey, decryptTextFormatKey, deriveAddressInfo, deriveChildKey$1 as deriveChildKey, deriveKeyAtPath$1 as deriveKeyAtPath, doubleSha256, encodeBech32, extractFromText, findPattern, forkedKeyFromTokenIdAndState, formatAmount, generateMasterKey, generateMnemonic, getAddressHrp, getCoinIdByName, getCoinIdBySymbol, getCurrentStateHash, getPublicKey, getSphere, getTokenDecimals, getTokenDefinition, getTokenIconUrl, getTokenId, getTokenName, getTokenSymbol, hasMissingNewStateHash, hasUncommittedTransactions, hasValidTxfData, hash160, hexToBytes, identityFromMnemonicSync, initSphere, isArchivedKey, isForkedKey, isInstantSplitBundle, isInstantSplitBundleV4, isInstantSplitBundleV5, isKnownToken, isPaymentSessionTerminal, isPaymentSessionTimedOut, isSQLiteDatabase, isTextWalletEncrypted, isTokenKey, isValidBech32, isValidNametag, isValidPrivateKey, isValidTokenId, isWalletDatEncrypted, isWalletTextFormat, keyFromTokenId, loadSphere, mnemonicToSeedSync, normalizeSdkTokenToStorage, objectToTxf, parseAndDecryptWalletDat, parseAndDecryptWalletText, parseForkedKey, parseTxfStorageData, parseWalletDat, parseWalletText, randomBytes, randomHex, randomUUID, ripemd160, sha256, sleep, sphereExists, toHumanReadable, toSmallestUnit, tokenIdFromArchivedKey, tokenIdFromKey, tokenToTxf, txfToToken, validateMnemonic };
|