@0xio/sdk 2.5.0 → 2.7.0

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/index.d.ts CHANGED
@@ -1,3 +1,140 @@
1
+ /**
2
+ * 0xio SDK — Wallet Transport Adapter Interface
3
+ *
4
+ * Implement WalletTransportAdapter to add support for a new wallet without
5
+ * touching any core SDK code. Drop the adapter file in src/supports/ and
6
+ * pass it to ZeroXIOWallet via SDKConfig.adapter.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * import { ZeroXIOWallet } from '@0xio/sdk';
11
+ * import { QubitzAdapter } from '@0xio/sdk/supports/qubitz';
12
+ *
13
+ * const wallet = new ZeroXIOWallet({
14
+ * appName: 'My DApp',
15
+ * adapter: QubitzAdapter,
16
+ * });
17
+ * ```
18
+ */
19
+ /**
20
+ * Outbound request — the SDK passes this to adapter.postRequest() for every
21
+ * outbound wallet call. Adapters translate this into their wallet-specific wire format.
22
+ */
23
+ interface AdapterRequest {
24
+ /** Unique request ID (UUID). Used to correlate the response. */
25
+ id: string;
26
+ /** Method name, e.g. 'connect', 'sendTransaction', 'signMessage' */
27
+ method: string;
28
+ /** Method parameters */
29
+ params: unknown;
30
+ /** Unix timestamp (ms) when the request was created */
31
+ timestamp: number;
32
+ }
33
+ /**
34
+ * Normalized inbound message from a wallet.
35
+ * Adapters translate their wallet-specific wire format into this structure
36
+ * and pass it to the handler registered via listen().
37
+ *
38
+ * A message is either a response (requestId set) or a push event (eventType set).
39
+ */
40
+ interface AdapterIncomingMessage {
41
+ /** Must match the id from the outbound AdapterRequest */
42
+ requestId?: string;
43
+ /** Whether the request succeeded. Required when requestId is set. */
44
+ success?: boolean;
45
+ /** Response payload on success */
46
+ data?: unknown;
47
+ /** Structured error on failure */
48
+ error?: {
49
+ code: string;
50
+ message: string;
51
+ details?: unknown;
52
+ };
53
+ /** Event type, e.g. 'connect', 'disconnect', 'accountChanged', 'balanceChanged' */
54
+ eventType?: string;
55
+ /** Event payload */
56
+ eventData?: unknown;
57
+ }
58
+ /**
59
+ * Wallet transport adapter.
60
+ *
61
+ * Encapsulates the entire wallet-specific communication layer:
62
+ * - How to detect if the wallet is installed
63
+ * - How to send requests (postRequest)
64
+ * - How to receive responses and events (listen)
65
+ *
66
+ * Everything else — request lifecycle, timeouts, retries, rate limiting,
67
+ * event routing — is handled by the SDK core and does not change per wallet.
68
+ *
69
+ * @example Minimal adapter for a hypothetical wallet
70
+ * ```typescript
71
+ * export const MyWalletAdapter: WalletTransportAdapter = {
72
+ * name: 'mywallet',
73
+ * displayName: 'My Wallet',
74
+ * detect: () => !!(window as any).myWallet,
75
+ * postRequest: (req) =>
76
+ * window.postMessage({ source: 'mywallet-request', ...req }, location.origin),
77
+ * listen: (handler) => {
78
+ * const fn = (e: MessageEvent) => {
79
+ * if (e.data?.source !== 'mywallet-response') return;
80
+ * handler({ requestId: e.data.id, success: e.data.ok, data: e.data.result });
81
+ * };
82
+ * window.addEventListener('message', fn);
83
+ * return () => window.removeEventListener('message', fn);
84
+ * },
85
+ * };
86
+ * ```
87
+ */
88
+ interface WalletTransportAdapter {
89
+ /**
90
+ * Machine-readable wallet identifier. Used in logs and adapter selection.
91
+ * Examples: '0xio', 'qubitz', 'fhex'
92
+ */
93
+ readonly name: string;
94
+ /**
95
+ * Human-readable wallet name shown in error messages.
96
+ * Examples: '0xio Wallet', 'Qubitz Wallet', 'FHEX Wallet'
97
+ */
98
+ readonly displayName: string;
99
+ /**
100
+ * Returns true when this wallet's extension / injected provider is present
101
+ * in the current page context. Called periodically by the SDK to check availability.
102
+ */
103
+ detect(): boolean;
104
+ /**
105
+ * Send a request to the wallet.
106
+ * Called once per outbound request — translate AdapterRequest into your
107
+ * wallet's wire format and post it (window.postMessage, direct API call, etc.).
108
+ */
109
+ postRequest(request: AdapterRequest): void;
110
+ /**
111
+ * Optional: send the same request to a trusted parent frame (iframe/desktop bridge).
112
+ * Only implement this if your wallet supports an embedded iframe bridge mode.
113
+ * The SDK calls this when window.parent !== window and a trusted parent origin exists.
114
+ */
115
+ postRequestToParent?(request: AdapterRequest, parentOrigin: string): void;
116
+ /**
117
+ * Set up response and event listening.
118
+ * The SDK calls this once during initialization. Normalise all incoming wallet
119
+ * messages into AdapterIncomingMessage and pass them to handler.
120
+ *
121
+ * @param handler Callback for responses and push events
122
+ * @param options SDK-level options, e.g. additional trusted parent origins
123
+ * @returns A teardown function — the SDK calls it on cleanup()
124
+ */
125
+ listen(handler: (msg: AdapterIncomingMessage) => void, options?: {
126
+ trustedParentOrigins?: string[];
127
+ }): () => void;
128
+ /**
129
+ * Optional: register wallet-ready event listeners (e.g. 'myWalletReady' CustomEvent).
130
+ * Called once during SDK init. When the wallet signals it is ready, call onReady().
131
+ * Returns a cleanup function.
132
+ *
133
+ * If not implemented, the SDK falls back to polling detect() every 2 seconds.
134
+ */
135
+ listenForReady?(onReady: () => void): () => void;
136
+ }
137
+
1
138
  /**
2
139
  * 0xio Wallet SDK - Type Definitions
3
140
  * Comprehensive type system for 0xio wallet integration with Octra Network
@@ -25,7 +162,8 @@ interface NetworkInfo {
25
162
  }
26
163
  interface TransactionData {
27
164
  readonly to: string;
28
- readonly amount: number;
165
+ /** Amount in OCT. Accepts string or number — use string for amounts above 9 billion OCT to avoid JS number precision loss. */
166
+ readonly amount: string | number;
29
167
  readonly message?: string;
30
168
  readonly feeLevel?: 1 | 3;
31
169
  readonly isPrivate?: boolean;
@@ -81,7 +219,7 @@ interface SignedTransaction {
81
219
  readonly signature: string;
82
220
  readonly public_key: string;
83
221
  }
84
- type TransactionFinality = 'pending' | 'confirmed' | 'rejected';
222
+ type TransactionFinality = 'pending' | 'confirmed' | 'rejected' | 'dropped';
85
223
  interface TransactionResult {
86
224
  readonly txHash: string;
87
225
  readonly success: boolean;
@@ -99,10 +237,12 @@ interface Transaction {
99
237
  readonly hash: string;
100
238
  readonly from: string;
101
239
  readonly to: string;
102
- readonly amount: number;
103
- readonly fee: number;
240
+ /** Amount in OCT as returned by the node (may be string or number depending on extension version). */
241
+ readonly amount: string | number;
242
+ /** Fee in OCT as returned by the node (may be string or number depending on extension version). */
243
+ readonly fee: string | number;
104
244
  readonly timestamp: number;
105
- readonly status: 'pending' | 'confirmed' | 'failed';
245
+ readonly status: 'pending' | 'confirmed' | 'failed' | 'dropped';
106
246
  readonly finality?: TransactionFinality;
107
247
  readonly message?: string;
108
248
  readonly blockHeight?: number;
@@ -114,6 +254,7 @@ interface ConnectionInfo {
114
254
  balance?: Balance;
115
255
  networkInfo?: NetworkInfo;
116
256
  connectedAt?: number;
257
+ permissions?: Permission[];
117
258
  }
118
259
  interface ConnectOptions {
119
260
  readonly requestPermissions?: Permission[];
@@ -128,7 +269,7 @@ interface WalletEvent<T = any> {
128
269
  }
129
270
  interface ConnectEvent {
130
271
  readonly address: string;
131
- readonly publicKey?: string;
272
+ readonly publicKey: string | undefined;
132
273
  readonly balance: Balance;
133
274
  readonly networkInfo: NetworkInfo;
134
275
  readonly permissions: Permission[];
@@ -140,6 +281,7 @@ interface AccountChangedEvent {
140
281
  readonly previousAddress?: string;
141
282
  readonly newAddress: string;
142
283
  readonly balance: Balance;
284
+ readonly publicKey?: string;
143
285
  }
144
286
  interface BalanceChangedEvent {
145
287
  readonly address: string;
@@ -192,7 +334,8 @@ interface PrivateBalanceInfo {
192
334
  }
193
335
  interface PrivateTransferData {
194
336
  readonly to: string;
195
- readonly amount: number;
337
+ /** Amount in OCT. Accepts string or number — use string for amounts above 9 billion OCT to avoid JS number precision loss. */
338
+ readonly amount: string | number;
196
339
  readonly message?: string;
197
340
  }
198
341
  interface PendingPrivateTransfer {
@@ -212,6 +355,16 @@ interface SDKConfig {
212
355
  readonly requiredPermissions?: Permission[];
213
356
  readonly networkId?: string;
214
357
  readonly debug?: boolean;
358
+ /**
359
+ * Custom wallet transport adapter.
360
+ * Defaults to ZeroXIOAdapter (0xio extension postMessage protocol).
361
+ * Pass an adapter from src/supports/ to target a different wallet.
362
+ *
363
+ * @example
364
+ * import { QubitzAdapter } from '@0xio/sdk/supports/qubitz';
365
+ * new ZeroXIOWallet({ appName: 'My DApp', adapter: QubitzAdapter });
366
+ */
367
+ readonly adapter?: WalletTransportAdapter;
215
368
  }
216
369
  interface ExtensionRequest {
217
370
  readonly id: string;
@@ -285,6 +438,8 @@ declare class ZeroXIOWallet extends EventEmitter {
285
438
  private config;
286
439
  private connectionInfo;
287
440
  private isInitialized;
441
+ private _initPromise;
442
+ private _sessionVersion;
288
443
  private logger;
289
444
  constructor(config: SDKConfig);
290
445
  /**
@@ -370,21 +525,29 @@ declare class ZeroXIOWallet extends EventEmitter {
370
525
  /**
371
526
  * Encrypt public balance to private
372
527
  */
373
- encryptBalance(amount: number): Promise<boolean>;
528
+ encryptBalance(amount: string | number): Promise<TransactionResult>;
374
529
  /**
375
530
  * Decrypt private balance to public
376
531
  */
377
- decryptBalance(amount: number): Promise<boolean>;
532
+ decryptBalance(amount: string | number): Promise<TransactionResult>;
378
533
  /**
379
- * Send private transfer
534
+ * Send a private (encrypted) transfer to another address.
535
+ * The extension builds the PVAC ciphertext subtraction + range proof + zero proof,
536
+ * then submits the encrypted transaction to the network. The recipient's encrypted
537
+ * balance is updated by the node using re-encryption under their public key.
538
+ * Requires 'private_transfers' permission.
539
+ * @since 2.6.0
380
540
  */
381
541
  sendPrivateTransfer(transferData: PrivateTransferData): Promise<TransactionResult>;
382
542
  /**
383
- * Get pending private transfers
543
+ * Get pending private transfers that can be claimed by this wallet.
544
+ * Returns transfers where the connected address is the recipient.
545
+ * @since 2.6.0
384
546
  */
385
547
  getPendingPrivateTransfers(): Promise<PendingPrivateTransfer[]>;
386
548
  /**
387
- * Claim private transfer
549
+ * Claim a pending private transfer, adding it to the wallet's encrypted balance.
550
+ * @since 2.6.0
388
551
  */
389
552
  claimPrivateTransfer(transferId: string): Promise<TransactionResult>;
390
553
  /**
@@ -400,6 +563,16 @@ declare class ZeroXIOWallet extends EventEmitter {
400
563
  * ```
401
564
  */
402
565
  signMessage(message: string): Promise<string>;
566
+ /**
567
+ * Sign a domain-separated authentication message.
568
+ * Unlike `signMessage()`, this prepends a standard header that binds the signature
569
+ * to the calling service and a one-time nonce, preventing cross-service replay attacks.
570
+ *
571
+ * @param service - Identifies the relying service (e.g. 'MyDApp' or 'api.mydapp.com')
572
+ * @param nonce - Unique one-time value — use a server-generated UUID or challenge
573
+ * @returns Promise resolving to the base64-encoded Ed25519 signature
574
+ */
575
+ signAuthMessage(service: string, nonce: string): Promise<string>;
403
576
  private ensureInitialized;
404
577
  private ensureConnected;
405
578
  private setupExtensionEventListeners;
@@ -441,197 +614,68 @@ declare class ZeroXIOWallet extends EventEmitter {
441
614
  * to ensure secure wallet interactions.
442
615
  *
443
616
  * @module communication
444
- * @version 2.5.0
617
+ * @version 2.7.0
445
618
  * @license MIT
446
619
  */
447
620
 
448
- /**
449
- * ExtensionCommunicator - Manages communication with the 0xio Wallet browser extension
450
- *
451
- * @class
452
- * @extends EventEmitter
453
- *
454
- * @description
455
- * Handles all communication between the SDK and wallet extension including:
456
- * - Request/response message passing with origin validation
457
- * - Rate limiting to prevent DoS attacks
458
- * - Automatic retry logic with exponential backoff
459
- * - Extension detection and availability monitoring
460
- * - Cryptographically secure request ID generation
461
- *
462
- * @example
463
- * ```typescript
464
- * const communicator = new ExtensionCommunicator(true); // debug mode
465
- * await communicator.initialize();
466
- *
467
- * const response = await communicator.sendRequest('get_balance', {});
468
- * console.log(response);
469
- * ```
470
- */
471
621
  declare class ExtensionCommunicator extends EventEmitter {
472
- /** Legacy request counter (deprecated, kept for fallback) */
473
- private requestId;
474
- /** Map of pending requests awaiting responses */
475
622
  private pendingRequests;
476
- /** Initialization state flag */
477
623
  private isInitialized;
478
- /** Logger instance for debugging */
479
624
  private logger;
480
- /** Interval handle for periodic extension detection */
481
625
  private extensionDetectionInterval;
482
- /** Current extension availability state */
483
626
  private isExtensionAvailableState;
484
- /** Message listener reference for cleanup */
485
- private messageListener;
486
- /** Trusted parent origins for iframe communication */
487
627
  private trustedOrigins;
488
- /** Parent origin learned from walletReady signal */
489
628
  private _parentOrigin;
490
- /** Maximum number of concurrent pending requests */
491
- private readonly MAX_CONCURRENT_REQUESTS;
492
- /** Time window for rate limiting (milliseconds) */
493
- private readonly RATE_LIMIT_WINDOW;
494
- /** Maximum requests allowed per time window */
495
- private readonly MAX_REQUESTS_PER_WINDOW;
496
- /** Timestamps of recent requests for rate limiting */
497
- private requestTimestamps;
629
+ /** Pluggable transport defaults to the 0xio postMessage protocol. */
630
+ private adapter;
631
+ /** Teardown fn returned by adapter.listen() */
632
+ private _adapterTeardown;
633
+ /** Teardown fn returned by adapter.listenForReady() */
634
+ private _adapterReadyTeardown;
498
635
  /**
499
- * Creates a new ExtensionCommunicator instance
500
- *
501
- * @param {boolean} debug - Enable debug logging
636
+ * Set when a trusted walletReady has been received from window.parent.
637
+ * The polling fallback must NOT clear this flag.
502
638
  */
503
- constructor(debug?: boolean, trustedOrigins?: string[]);
639
+ private _parentTrusted;
640
+ /** walletReady postMessage listener stored for cleanup */
641
+ private _walletReadyMessageListener;
504
642
  /**
505
- * Add trusted origins for iframe/bridge communication
506
- * Call this before connecting if your dApp runs inside a trusted frame
643
+ * In-flight interactive request lock.
644
+ * Methods that open approval popups are serialized only one at a time.
507
645
  */
646
+ private _interactiveInFlight;
647
+ private readonly MAX_CONCURRENT_REQUESTS;
648
+ private readonly RATE_LIMIT_WINDOW;
649
+ private readonly MAX_REQUESTS_PER_WINDOW;
650
+ private requestTimestamps;
651
+ constructor(debug?: boolean, trustedOrigins?: string[], adapter?: WalletTransportAdapter);
508
652
  setTrustedOrigins(origins: string[]): void;
509
- /**
510
- * Initialize communication with the wallet extension
511
- *
512
- * @description
513
- * Performs initial setup and verification:
514
- * 1. Waits for extension to become available
515
- * 2. Sends ping to verify communication
516
- * 3. Establishes message handlers
517
- *
518
- * Must be called before any other methods.
519
- *
520
- * @returns {Promise<boolean>} True if initialization succeeded, false otherwise
521
- * @throws {ZeroXIOWalletError} If extension is not available after timeout
522
- *
523
- * @example
524
- * ```typescript
525
- * const success = await communicator.initialize();
526
- * if (!success) {
527
- * console.error('Failed to initialize wallet connection');
528
- * }
529
- * ```
530
- */
531
653
  initialize(): Promise<boolean>;
532
- /**
533
- * Check if extension is available
534
- */
535
654
  isExtensionAvailable(): boolean;
536
655
  private static readonly NO_RETRY_METHODS;
537
- /**
538
- * Send request to extension
539
- */
656
+ private static readonly INTERACTIVE_METHODS;
540
657
  sendRequest<T = any>(method: string, params?: any, timeout?: number): Promise<T>;
541
- /**
542
- * Send request to extension with automatic retry logic
543
- */
544
658
  sendRequestWithRetry<T = any>(method: string, params?: any, maxRetries?: number, timeout?: number): Promise<T>;
545
- /**
546
- * Setup message listener for responses from extension
547
- */
548
659
  private setupMessageListener;
549
- /**
550
- * Handle extension event
551
- */
660
+ private static readonly VALID_EVENT_TYPES;
552
661
  private handleExtensionEvent;
553
- /**
554
- * Handle response from extension
555
- */
556
662
  private handleExtensionResponse;
557
- /**
558
- * Post message to extension via content script
559
- */
560
663
  private postMessageToExtension;
561
- /**
562
- * Check if we're in a context that can communicate with extension
563
- */
564
664
  private hasExtensionContext;
565
- /**
566
- * Check and enforce rate limits to prevent denial-of-service attacks
567
- *
568
- * @private
569
- * @throws {ZeroXIOWalletError} RATE_LIMIT_EXCEEDED if limits are exceeded
570
- *
571
- * @description
572
- * Implements two-tier rate limiting:
573
- * 1. Concurrent requests: Maximum 50 pending requests at once
574
- * 2. Request frequency: Maximum 20 requests per second
575
- *
576
- * Rate limiting protects both the SDK and extension from:
577
- * - Accidental infinite loops in dApp code
578
- * - Malicious DoS attacks
579
- * - Resource exhaustion
580
- *
581
- * @security Critical security function - enforces resource limits
582
- */
583
665
  private checkRateLimit;
584
- /**
585
- * Generate cryptographically secure unique request ID
586
- *
587
- * @private
588
- * @returns {string} A unique, unpredictable request identifier
589
- *
590
- * @description
591
- * Uses Web Crypto API for secure random ID generation:
592
- * 1. Primary: crypto.randomUUID() - UUID v4 format
593
- * 2. Fallback: crypto.getRandomValues() - 128-bit random hex
594
- * 3. Last resort: timestamp + counter (logs warning)
595
- *
596
- * Security importance:
597
- * - Prevents request ID prediction attacks
598
- * - Mitigates replay attacks
599
- * - Makes session hijacking more difficult
600
- *
601
- * @security Critical - IDs must be cryptographically unpredictable
602
- */
603
666
  private generateRequestId;
604
- /**
605
- * Start continuous extension detection
606
- */
607
667
  private startExtensionDetection;
608
- /**
609
- * Check if extension is currently available
610
- */
611
668
  private checkExtensionAvailability;
612
- /**
613
- * Detect extension signals/indicators
614
- */
615
669
  private detectExtensionSignals;
616
- /**
617
- * Wait for extension to become available
618
- */
619
670
  private waitForExtensionAvailability;
620
- /**
621
- * Get browser diagnostics for error reporting
622
- */
623
671
  private getBrowserDiagnostics;
624
- /**
625
- * Get extension state diagnostics
626
- */
627
672
  private getExtensionDiagnostics;
628
673
  /**
629
- * Cleanup pending requests
674
+ * Clean up SDK resources.
675
+ * After cleanup() the instance is terminal — do not call initialize() again.
676
+ * Construct a new instance instead.
630
677
  */
631
678
  cleanup(): void;
632
- /**
633
- * Get debug information
634
- */
635
679
  getDebugInfo(): {
636
680
  initialized: boolean;
637
681
  available: boolean;
@@ -641,34 +685,105 @@ declare class ExtensionCommunicator extends EventEmitter {
641
685
  };
642
686
  }
643
687
 
688
+ /**
689
+ * 0xio Wallet transport adapter.
690
+ *
691
+ * Implements the postMessage protocol used by the 0xio browser extension (>= v2.4.0).
692
+ *
693
+ * Outbound wire format:
694
+ * window.postMessage({ source: '0xio-sdk-request', request: { id, method, params, timestamp } }, origin)
695
+ *
696
+ * Inbound wire format:
697
+ * window.postMessage({ source: '0xio-sdk-bridge', response: { id, success, data, error }, sessionNonce })
698
+ * window.postMessage({ source: '0xio-sdk-bridge', event: { type, data } })
699
+ *
700
+ * H-2: Session nonce validation — injected.ts broadcasts the nonce received from the
701
+ * isolated content script. Once set, any '0xio-sdk-bridge' response with a missing or
702
+ * mismatched nonce is rejected, preventing response injection by malicious page scripts.
703
+ */
704
+
705
+ /**
706
+ * Creates a 0xio adapter. The factory accepts optional extra trusted parent origins
707
+ * so the communicator can forward its own trustedOrigins setting to origin validation.
708
+ */
709
+ declare function createZeroXIOAdapter(extraTrustedOrigins?: string[]): WalletTransportAdapter;
710
+ /** Default 0xio adapter instance (no extra trusted origins). */
711
+ declare const ZeroXIOAdapter: WalletTransportAdapter;
712
+
713
+ /**
714
+ * RFC-O-1 OctraProvider transport adapter.
715
+ *
716
+ * Targets any wallet that exposes `window.octra` per the RFC-O-1 specification:
717
+ * window.octra.isOctra === true
718
+ * window.octra.request({ method, params }) → Promise<unknown>
719
+ * window.octra.on(event, listener) / removeListener(event, listener)
720
+ *
721
+ * This adapter translates the SDK's internal method names into RFC-O-1 method
722
+ * names and maps events back to the SDK event vocabulary.
723
+ *
724
+ * Non-standard SDK methods (ping, register_dapp, getTransactionHistory, etc.)
725
+ * are passed through as-is; the wallet's request() handles or rejects them.
726
+ */
727
+
728
+ declare function createOctraProviderAdapter(): WalletTransportAdapter;
729
+ /** Default RFC-O-1 adapter instance. */
730
+ declare const OctraProviderAdapter: WalletTransportAdapter;
731
+
732
+ /**
733
+ * 0xio SDK — Wallet Adapter Registry
734
+ *
735
+ * Add new wallet adapters here. Detection order determines which wallet takes
736
+ * priority when multiple wallets are installed at the same time.
737
+ */
738
+
739
+ /**
740
+ * Auto-detects the first available wallet in the current page.
741
+ * Returns null if no supported wallet is found.
742
+ *
743
+ * @example
744
+ * const adapter = detectWalletAdapter();
745
+ * if (!adapter) throw new Error('No supported wallet found');
746
+ * const wallet = new ZeroXIOWallet({ appName: 'My DApp', adapter });
747
+ */
748
+ declare function detectWalletAdapter(): WalletTransportAdapter | null;
749
+ /** Returns all registered adapter instances. */
750
+ declare function getAllAdapters(): WalletTransportAdapter[];
751
+
644
752
  /**
645
753
  * Network configuration for 0xio SDK
646
754
  */
647
755
 
648
- declare const NETWORKS: Record<string, NetworkInfo>;
756
+ /**
757
+ * Immutable public copy of the built-in network table.
758
+ * Modifications to returned objects do not affect SDK-internal state.
759
+ */
760
+ declare const NETWORKS: Readonly<Record<string, Readonly<NetworkInfo>>>;
649
761
  declare const DEFAULT_NETWORK_ID = "mainnet";
650
762
  /**
651
- * Get network configuration by ID
763
+ * Get network configuration by ID.
764
+ * Returns a frozen copy — callers cannot mutate SDK-internal state.
652
765
  */
653
766
  declare function getNetworkConfig(networkId?: string): NetworkInfo;
654
767
  /**
655
- * Get all available networks
768
+ * Get all available networks.
769
+ * Returns frozen copies — callers cannot mutate SDK-internal state.
656
770
  */
657
771
  declare function getAllNetworks(): NetworkInfo[];
658
772
  /**
659
- * Check if network ID is valid
773
+ * Check if network ID is valid (own property check, prevents prototype pollution).
660
774
  */
661
775
  declare function isValidNetworkId(networkId: string): boolean;
662
776
 
663
777
  /**
664
- * Default balance structure
778
+ * Default balance structure.
779
+ * Accepts a numeric total or undefined — never pass a Balance object here.
665
780
  */
666
781
  declare function createDefaultBalance(total?: number): Balance;
667
782
  /**
668
783
  * SDK Configuration constants
669
784
  */
670
785
  declare const SDK_CONFIG: {
671
- readonly version: "2.5.0";
786
+ readonly version: "2.7.0";
672
787
  readonly defaultNetworkId: "mainnet";
673
788
  readonly communicationTimeout: 30000;
674
789
  readonly retryAttempts: 3;
@@ -689,9 +804,11 @@ declare function getDefaultNetwork(): NetworkInfo;
689
804
  */
690
805
  declare function isValidAddress(address: string): boolean;
691
806
  /**
692
- * Validate transaction amount
807
+ * Validate transaction amount.
808
+ * Accepts both number and string representations.
809
+ * String amounts avoid JS number precision loss for very large values.
693
810
  */
694
- declare function isValidAmount(amount: number): boolean;
811
+ declare function isValidAmount(amount: string | number): boolean;
695
812
  /**
696
813
  * Validate transaction message
697
814
  */
@@ -700,10 +817,16 @@ declare function isValidMessage(message: string): boolean;
700
817
  * Validate fee level
701
818
  */
702
819
  declare function isValidFeeLevel(feeLevel: number): boolean;
820
+ /**
821
+ * Derive the canonical Octra address from a base64-encoded Ed25519 public key.
822
+ * Algorithm: SHA-256(pubkey_bytes) → base58 → prepend "oct"
823
+ * Source of truth: ocho-push-server/src/index.ts#deriveAddressFromPubkey
824
+ */
825
+ declare function deriveOctraAddress(publicKeyBase64: string): Promise<string>;
703
826
  /**
704
827
  * Format OCT amount for display
705
828
  */
706
- declare function formatOCT(amount: number, decimals?: number): string;
829
+ declare function formatOCT(amount: number | string, decimals?: number): string;
707
830
  /**
708
831
  * Format address for display (truncated)
709
832
  */
@@ -736,14 +859,6 @@ declare function isErrorType(error: any, code: ErrorCode): boolean;
736
859
  * Create a promise that resolves after a delay
737
860
  */
738
861
  declare function delay(ms: number): Promise<void>;
739
- /**
740
- * Retry an async operation with exponential backoff
741
- */
742
- declare function retry<T>(operation: () => Promise<T>, maxRetries?: number, baseDelay?: number): Promise<T>;
743
- /**
744
- * Timeout wrapper for promises
745
- */
746
- declare function withTimeout<T>(promise: Promise<T>, timeoutMs: number, timeoutMessage?: string): Promise<T>;
747
862
  /**
748
863
  * Check if running in browser environment
749
864
  */
@@ -791,7 +906,7 @@ declare function createLogger(prefix: string, debug: boolean): {
791
906
  groupEnd: () => void;
792
907
  };
793
908
 
794
- declare const SDK_VERSION = "2.5.0";
909
+ declare const SDK_VERSION = "2.7.0";
795
910
  declare const MIN_EXTENSION_VERSION = "2.0.1";
796
911
  declare const MIN_EXTENSION_VERSION_DEVNET = "2.2.1";
797
912
  declare const SUPPORTED_EXTENSION_VERSIONS = "^2.0.1";
@@ -800,13 +915,13 @@ declare function createZeroXIOWallet(config: {
800
915
  appDescription?: string;
801
916
  debug?: boolean;
802
917
  autoConnect?: boolean;
918
+ adapter?: WalletTransportAdapter;
803
919
  }): Promise<ZeroXIOWallet>;
804
- declare const createOctraWallet: typeof createZeroXIOWallet;
805
920
  declare function checkSDKCompatibility(): {
806
921
  compatible: boolean;
807
922
  issues: string[];
808
923
  recommendations: string[];
809
924
  };
810
925
 
811
- export { DEFAULT_NETWORK_ID, ErrorCode, EventEmitter, ExtensionCommunicator, MIN_EXTENSION_VERSION, MIN_EXTENSION_VERSION_DEVNET, NETWORKS, SDK_CONFIG, SDK_VERSION, SUPPORTED_EXTENSION_VERSIONS, ZeroXIOWallet, ZeroXIOWalletError, checkBrowserSupport, checkSDKCompatibility, createDefaultBalance, createErrorMessage, createLogger, createOctraWallet, createZeroXIOWallet, delay, formatAddress, formatOCT, formatTimestamp, formatTxHash, formatOCT as formatZeroXIO, fromMicroOCT, fromMicroOCT as fromMicroZeroXIO, generateMockData, getAllNetworks, getDefaultNetwork, getNetworkConfig, isBrowser, isErrorType, isValidAddress, isValidAmount, isValidFeeLevel, isValidMessage, isValidNetworkId, retry, toMicroOCT, toMicroOCT as toMicroZeroXIO, withTimeout };
812
- export type { AccountChangedEvent, Balance, BalanceChangedEvent, ConnectEvent, ConnectOptions, ConnectionInfo, ContractCallData, ContractParam, ContractParams, ContractViewCallData, DisconnectEvent, ErrorEvent, ExtensionRequest, ExtensionResponse, NetworkChangedEvent, NetworkInfo, PendingPrivateTransfer, Permission, PrivateBalanceInfo, PrivateTransferData, SDKConfig, SignedTransaction, Transaction, TransactionConfirmedEvent, TransactionData, TransactionFinality, TransactionHistory, TransactionResult, WalletAddress, WalletEvent, WalletEventType };
926
+ export { DEFAULT_NETWORK_ID, ErrorCode, EventEmitter, ExtensionCommunicator, MIN_EXTENSION_VERSION, MIN_EXTENSION_VERSION_DEVNET, NETWORKS, OctraProviderAdapter, SDK_CONFIG, SDK_VERSION, SUPPORTED_EXTENSION_VERSIONS, ZeroXIOAdapter, ZeroXIOWallet, ZeroXIOWalletError, checkBrowserSupport, checkSDKCompatibility, createDefaultBalance, createErrorMessage, createLogger, createOctraProviderAdapter, createZeroXIOAdapter, createZeroXIOWallet, delay, deriveOctraAddress, detectWalletAdapter, formatAddress, formatOCT, formatTimestamp, formatTxHash, formatOCT as formatZeroXIO, fromMicroOCT, fromMicroOCT as fromMicroZeroXIO, generateMockData, getAllAdapters, getAllNetworks, getDefaultNetwork, getNetworkConfig, isBrowser, isErrorType, isValidAddress, isValidAmount, isValidFeeLevel, isValidMessage, isValidNetworkId, toMicroOCT, toMicroOCT as toMicroZeroXIO };
927
+ export type { AccountChangedEvent, AdapterIncomingMessage, AdapterRequest, Balance, BalanceChangedEvent, ConnectEvent, ConnectOptions, ConnectionInfo, ContractCallData, ContractParam, ContractParams, ContractViewCallData, DisconnectEvent, ErrorEvent, ExtensionRequest, ExtensionResponse, NetworkChangedEvent, NetworkInfo, PendingPrivateTransfer, Permission, PrivateBalanceInfo, PrivateTransferData, SDKConfig, SignedTransaction, Transaction, TransactionConfirmedEvent, TransactionData, TransactionFinality, TransactionHistory, TransactionResult, WalletAddress, WalletEvent, WalletEventType, WalletTransportAdapter };