@0xio/sdk 2.7.1 → 2.8.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,5 +1,5 @@
1
1
  /**
2
- * 0xio SDK Wallet Transport Adapter Interface
2
+ * 0xio SDK: Wallet Transport Adapter Interface
3
3
  *
4
4
  * Implement WalletTransportAdapter to add support for a new wallet without
5
5
  * touching any core SDK code. Drop the adapter file in src/supports/ and
@@ -17,7 +17,7 @@
17
17
  * ```
18
18
  */
19
19
  /**
20
- * Outbound request the SDK passes this to adapter.postRequest() for every
20
+ * Outbound request: the SDK passes this to adapter.postRequest() for every
21
21
  * outbound wallet call. Adapters translate this into their wallet-specific wire format.
22
22
  */
23
23
  interface AdapterRequest {
@@ -63,8 +63,8 @@ interface AdapterIncomingMessage {
63
63
  * - How to send requests (postRequest)
64
64
  * - How to receive responses and events (listen)
65
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.
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
68
  *
69
69
  * @example Minimal adapter for a hypothetical wallet
70
70
  * ```typescript
@@ -103,7 +103,7 @@ interface WalletTransportAdapter {
103
103
  detect(): boolean;
104
104
  /**
105
105
  * Send a request to the wallet.
106
- * Called once per outbound request translate AdapterRequest into your
106
+ * Called once per outbound request: translate AdapterRequest into your
107
107
  * wallet's wire format and post it (window.postMessage, direct API call, etc.).
108
108
  */
109
109
  postRequest(request: AdapterRequest): void;
@@ -120,7 +120,7 @@ interface WalletTransportAdapter {
120
120
  *
121
121
  * @param handler Callback for responses and push events
122
122
  * @param options SDK-level options, e.g. additional trusted parent origins
123
- * @returns A teardown function the SDK calls it on cleanup()
123
+ * @returns A teardown function. The SDK calls it on cleanup()
124
124
  */
125
125
  listen(handler: (msg: AdapterIncomingMessage) => void, options?: {
126
126
  trustedParentOrigins?: string[];
@@ -162,16 +162,21 @@ interface NetworkInfo {
162
162
  }
163
163
  interface TransactionData {
164
164
  readonly to: string;
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;
165
+ /**
166
+ * Raw amount in micro-OCT (1 OCT = 1000000), passed to the wallet unchanged. This is what
167
+ * the wallet and the RFC-O-1 provider expect. Prefer `amountOct` when you think in OCT.
168
+ */
169
+ readonly amount?: string | number;
170
+ /** Amount in OCT. The SDK converts it to raw units exactly (at most 6 decimals). Use this or `amount`, not both. */
171
+ readonly amountOct?: string | number;
167
172
  readonly message?: string;
168
173
  readonly feeLevel?: 1 | 3;
169
174
  readonly isPrivate?: boolean;
170
175
  }
171
176
  /**
172
- * Contract method arguments flat array of AML-compatible values.
177
+ * Contract method arguments: flat array of AML-compatible values.
173
178
  * Supports primitives and base64-encoded binary data (e.g. FHE ciphers, proofs).
174
- * Use `[arg1, arg2]` NOT `[[arg1, arg2]]` flat, not nested.
179
+ * Use `[arg1, arg2]`, not `[[arg1, arg2]]`: flat, not nested.
175
180
  */
176
181
  type ContractParam = string | number | boolean;
177
182
  type ContractParams = ReadonlyArray<ContractParam>;
@@ -181,16 +186,18 @@ interface ContractCallData {
181
186
  /** Contract method name (e.g. 'swap', 'open_private_account') */
182
187
  readonly method: string;
183
188
  /**
184
- * Method arguments flat primitives, NOT array-wrapped.
189
+ * Method arguments: flat primitives, not array-wrapped.
185
190
  * For FHE/PVAC operations, encode binary data as base64 strings:
186
191
  * `[base64(pvacPubkey), base64(zeroCipher), base64(zeroProof)]`
187
192
  */
188
193
  readonly params: ContractParams;
189
194
  /**
190
- * Native OCT to send with the call (in OCT, same unit as sendTransaction.amount).
191
- * Set to '0' for calls that don't transfer native tokens.
195
+ * Native value to attach, in raw micro-OCT (1 OCT = 1000000), passed to the wallet unchanged.
196
+ * Omit or set '0' for calls that transfer nothing. Prefer `amountOct` when you think in OCT.
192
197
  */
193
198
  readonly amount?: string | number;
199
+ /** Value to attach in OCT. The SDK converts it to raw units exactly. Use this or `amount`, not both. */
200
+ readonly amountOct?: string | number;
194
201
  /**
195
202
  * Operation units / gas limit (default: 10000).
196
203
  * Higher values for complex contract operations.
@@ -203,7 +210,7 @@ interface ContractViewCallData {
203
210
  readonly contract: string;
204
211
  /** Contract method name (e.g. 'balance_of', 'get_active_bin', 'is_paused') */
205
212
  readonly method: string;
206
- /** Method arguments flat primitives, NOT array-wrapped */
213
+ /** Method arguments: flat primitives, not array-wrapped */
207
214
  readonly params: ContractParams;
208
215
  /** Caller address for view context (defaults to connected wallet) */
209
216
  readonly caller?: string;
@@ -245,7 +252,7 @@ interface Transaction {
245
252
  readonly hash: string;
246
253
  readonly from: string;
247
254
  readonly to: string;
248
- /** Amount in OCT as returned by the node (may be string or number depending on extension version). */
255
+ /** Amount in raw micro-OCT as returned by the node (string or number depending on the wallet version). */
249
256
  readonly amount: string | number;
250
257
  /** Fee in OCT as returned by the node (may be string or number depending on extension version). */
251
258
  readonly fee: string | number;
@@ -271,8 +278,8 @@ interface ConnectOptions {
271
278
  readonly requestPermissions?: Permission[];
272
279
  readonly networkId?: string;
273
280
  }
274
- type Permission = 'read_address' | 'read_balance' | 'read_public_key' | 'send_transactions' | 'sign_messages' | 'contract_calls' | 'view_private_balance' | 'view_encrypted_balance' | 'private_transfers' | 'encrypt_balance' | 'decrypt_balance' | 'stealth_scan' | 'stealth_claim';
275
- type WalletEventType = 'connect' | 'disconnect' | 'accountChanged' | 'balanceChanged' | 'networkChanged' | 'transactionConfirmed' | 'permissionsChanged' | 'message' | 'error' | 'extensionLocked' | 'extensionUnlocked';
281
+ type Permission = 'accounts' | 'public_transactions' | 'contract_views' | 'private_balance_read' | 'private_proofs' | 'private_claims' | 'read_address' | 'read_balance' | 'read_public_key' | 'send_transactions' | 'sign_messages' | 'contract_calls' | 'view_private_balance' | 'view_encrypted_balance' | 'private_transfers' | 'encrypt_balance' | 'decrypt_balance' | 'stealth_scan' | 'stealth_claim';
282
+ type WalletEventType = 'connect' | 'disconnect' | 'accountChanged' | 'balanceChanged' | 'networkChanged' | 'transactionConfirmed' | 'transactionFailed' | 'permissionsChanged' | 'message' | 'error' | 'extensionLocked' | 'extensionUnlocked';
276
283
  interface WalletEvent<T = any> {
277
284
  readonly type: WalletEventType;
278
285
  readonly data: T;
@@ -331,7 +338,16 @@ declare enum ErrorCode {
331
338
  INVALID_SIGNATURE = "INVALID_SIGNATURE",
332
339
  DUPLICATE_TRANSACTION = "DUPLICATE_TRANSACTION",
333
340
  NONCE_TOO_FAR = "NONCE_TOO_FAR",
334
- INTERNAL_ERROR = "INTERNAL_ERROR"
341
+ INTERNAL_ERROR = "INTERNAL_ERROR",
342
+ NOT_CONNECTED = "NOT_CONNECTED",
343
+ INVALID_PARAMS = "INVALID_PARAMS",
344
+ METHOD_NOT_ALLOWED = "METHOD_NOT_ALLOWED",
345
+ NOT_AVAILABLE = "NOT_AVAILABLE",
346
+ PRIVATE_PROOF_FAILED = "PRIVATE_PROOF_FAILED",
347
+ PRIVATE_TRANSFER_FAILED = "PRIVATE_TRANSFER_FAILED",
348
+ CONTRACT_CALL_FAILED = "CONTRACT_CALL_FAILED",
349
+ SIGN_FAILED = "SIGN_FAILED",
350
+ RECIPIENT_NOT_REGISTERED = "RECIPIENT_NOT_REGISTERED"
335
351
  }
336
352
  declare class ZeroXIOWalletError extends Error {
337
353
  readonly code: ErrorCode;
@@ -345,12 +361,21 @@ interface PrivateBalanceInfo {
345
361
  }
346
362
  interface PrivateTransferData {
347
363
  readonly to: string;
348
- /** Amount in OCT. Accepts string or number use string for amounts above 9 billion OCT to avoid JS number precision loss. */
364
+ /** Amount in OCT. Accepts string or number. Use string for amounts above 9 billion OCT to avoid JS number precision loss. */
349
365
  readonly amount: string | number;
366
+ /** Exact amount in raw micro-OCT. When set, it is what the wallet uses; `amount` is then display only. */
367
+ readonly amountRaw?: string;
368
+ /** Not carried by the wallet today; private transfers have no memo on-chain. */
350
369
  readonly message?: string;
351
370
  }
371
+ /**
372
+ * A claimable stealth output as the wallet returns it. The 0xio extension fills `id` and
373
+ * `amount` (raw micro-OCT) from the node; the other fields depend on the wallet.
374
+ */
352
375
  interface PendingPrivateTransfer {
353
376
  readonly id: string;
377
+ /** Raw micro-OCT, when the wallet exposes the amount. */
378
+ readonly amount?: number | string;
354
379
  readonly from: string;
355
380
  readonly encryptedAmount: string;
356
381
  readonly message?: string;
@@ -368,7 +393,7 @@ interface SDKConfig {
368
393
  readonly debug?: boolean;
369
394
  /**
370
395
  * Exact origins allowed as parent iframe bridge (e.g. 'https://app.example.com').
371
- * When set, only these origins (plus tauri://) are trusted implicit localhost trust
396
+ * When set, only these origins (plus tauri://) are trusted: implicit localhost trust
372
397
  * is disabled. Leave unset for development (all localhost trusted by default).
373
398
  */
374
399
  readonly trustedParentOrigins?: string[];
@@ -444,8 +469,8 @@ declare class ZeroXIOWallet extends EventEmitter {
444
469
  */
445
470
  getConnectionStatus(): Promise<ConnectionInfo>;
446
471
  /**
447
- * Switch the extension's active network (e.g. 'mainnet' 'devnet').
448
- * Works silently no popup, no user confirmation needed.
472
+ * Switch the extension's active network (e.g. 'mainnet' to 'devnet').
473
+ * Works silently: no popup, no user confirmation needed.
449
474
  * The extension broadcasts 'networkChanged' event to all connected dApps.
450
475
  */
451
476
  switchNetwork(networkId: string): Promise<{
@@ -457,6 +482,11 @@ declare class ZeroXIOWallet extends EventEmitter {
457
482
  */
458
483
  getNetworkId(): string | null;
459
484
  getAddress(): string | null;
485
+ /**
486
+ * The connected account's Ed25519 public key (base64). Served from the session when the
487
+ * wallet reported it at connect, otherwise asked from the wallet.
488
+ */
489
+ getPublicKey(): Promise<string>;
460
490
  getBalance(forceRefresh?: boolean): Promise<Balance>;
461
491
  getNetworkInfo(): Promise<NetworkInfo>;
462
492
  sendTransaction(txData: TransactionData): Promise<TransactionResult>;
@@ -492,11 +522,15 @@ declare class ZeroXIOWallet extends EventEmitter {
492
522
  getTransactionHistory(page?: number, limit?: number): Promise<TransactionHistory>;
493
523
  getPrivateBalanceInfo(): Promise<PrivateBalanceInfo>;
494
524
  /**
495
- * Encrypt public balance to private
525
+ * Encrypt public balance to private.
526
+ * @deprecated The 0xio extension does not serve this through the bridge (it answers
527
+ * NOT_AVAILABLE); users encrypt from the extension's Privacy screen.
496
528
  */
497
529
  encryptBalance(amount: string | number): Promise<TransactionResult>;
498
530
  /**
499
- * Decrypt private balance to public
531
+ * Decrypt private balance to public.
532
+ * @deprecated The 0xio extension does not serve this through the bridge (it answers
533
+ * NOT_AVAILABLE); users decrypt from the extension's Privacy screen.
500
534
  */
501
535
  decryptBalance(amount: string | number): Promise<TransactionResult>;
502
536
  /**
@@ -520,15 +554,121 @@ declare class ZeroXIOWallet extends EventEmitter {
520
554
  */
521
555
  claimPrivateTransfer(transferId: string): Promise<TransactionResult>;
522
556
  /**
523
- * Sign an arbitrary message with the wallet's private key
524
- * The user will be prompted to approve the signature request in the extension
557
+ * Send any wallet method + params through the bridge. Escape hatch for
558
+ * primitives that don't have a typed helper yet (no SDK upgrade needed).
559
+ * @since 2.8.0
560
+ */
561
+ request<T = unknown>(method: string, params?: Record<string, unknown>): Promise<T>;
562
+ /**
563
+ * Read-only node RPC through the wallet. Only the wallet's allow-listed public methods work
564
+ * (octra_balance, octra_transaction, contract_call and similar); writes are refused.
565
+ * @since 2.8.0
566
+ */
567
+ rpcCall<T = unknown>(method: string, params?: unknown[]): Promise<T>;
568
+ /**
569
+ * Feature-detect which private capabilities the connected wallet supports.
570
+ * Lets a dapp render the correct UI (or fail closed) before any action.
571
+ * @since 2.8.0
572
+ */
573
+ getPrivateCapabilities(): Promise<{
574
+ wallet: string;
575
+ version: string;
576
+ supports: Record<string, boolean>;
577
+ methods: string[];
578
+ required_permissions?: Record<string, string[]>;
579
+ }>;
580
+ /** Read-only contract view (no approval popup). @since 2.8.0 */
581
+ callContractView(params: {
582
+ contract: string;
583
+ method: string;
584
+ params?: unknown[];
585
+ caller?: string;
586
+ }): Promise<unknown>;
587
+ /** Encrypt a raw integer value to a contract-ready ciphertext (keys stay in wallet). @since 2.8.0 */
588
+ encryptValue(params: {
589
+ value_raw: string;
590
+ token?: string;
591
+ owner?: string;
592
+ asset?: string;
593
+ }): Promise<{
594
+ cipher: string;
595
+ commitment?: string;
596
+ encoding?: string;
597
+ }>;
598
+ /** Decrypt a ciphertext to a raw integer value. @since 2.8.0 */
599
+ decryptValue(params: {
600
+ cipher: string;
601
+ token?: string;
602
+ owner?: string;
603
+ }): Promise<{
604
+ value_raw: string;
605
+ display?: string;
606
+ decimals?: number;
607
+ }>;
608
+ /** Zero proof for a ciphertext (proves it encrypts the given value, default 0). @since 2.8.0 */
609
+ makeZeroProof(params: {
610
+ cipher: string;
611
+ value_raw?: string;
612
+ token?: string;
613
+ owner?: string;
614
+ }): Promise<{
615
+ proof: string;
616
+ commitment?: string;
617
+ blinding?: string;
618
+ encoding?: string;
619
+ }>;
620
+ /** Range proof for a ciphertext. @since 2.8.0 */
621
+ makeRangeProof(params: {
622
+ cipher: string;
623
+ value_raw: string;
624
+ token?: string;
625
+ owner?: string;
626
+ range?: {
627
+ min_raw: string;
628
+ max_raw: string;
629
+ };
630
+ }): Promise<{
631
+ proof: string;
632
+ encoding?: string;
633
+ }>;
634
+ /** Private OCT + private token balances (decrypted inside the wallet). @since 2.8.0 */
635
+ getPrivateBalance(params?: {
636
+ address?: string;
637
+ assets?: string[];
638
+ tokens?: string[];
639
+ include_claimable?: boolean;
640
+ }): Promise<unknown>;
641
+ /** Register a receive/view public key so an address can receive private transfers. @since 2.8.0 */
642
+ registerPrivateViewKey(params: {
643
+ address: string;
644
+ }): Promise<unknown>;
645
+ /** Submit an ordered multi-step public contract flow under one approval. @since 2.8.0 */
646
+ sendContractTransactionSequence(params: {
647
+ sequence_id?: string;
648
+ transactions: Array<{
649
+ contract: string;
650
+ method: string;
651
+ params?: unknown[];
652
+ amount?: string;
653
+ ou?: string;
654
+ }>;
655
+ }): Promise<unknown>;
656
+ /**
657
+ * Sign an arbitrary message with the wallet's private key.
658
+ * The user will be prompted to approve the signature request in the extension.
659
+ *
660
+ * The wallet does not sign the raw message: it signs the 0xio Signed Message framing
661
+ * (`"Octra Signed Message:\n" + byteLength + "\n" + message`) so a signed message can never be a
662
+ * transaction pre-image. Verify with `verifyMessage(message, signature, publicKey)`, or check an
663
+ * Ed25519 signature against `getSignedMessageBytes(message)` with your own library.
664
+ *
525
665
  * @param message - The message to sign (non-empty string)
526
666
  * @returns Promise resolving to the base64-encoded Ed25519 signature
527
667
  * @throws ZeroXIOWalletError with code SIGNATURE_FAILED if signing fails
528
668
  * @example
529
669
  * ```typescript
530
670
  * const signature = await wallet.signMessage('Hello, 0xio!');
531
- * console.log('Signature:', signature);
671
+ * const ok = await verifyMessage('Hello, 0xio!', signature, await wallet.getPublicKey());
532
672
  * ```
533
673
  */
534
674
  signMessage(message: string): Promise<string>;
@@ -538,7 +678,7 @@ declare class ZeroXIOWallet extends EventEmitter {
538
678
  * to the calling service and a one-time nonce, preventing cross-service replay attacks.
539
679
  *
540
680
  * @param service - Identifies the relying service (e.g. 'MyDApp' or 'api.mydapp.com')
541
- * @param nonce - Unique one-time value use a server-generated UUID or challenge
681
+ * @param nonce - Unique one-time value. Use a server-generated UUID or challenge
542
682
  * @returns Promise resolving to the base64-encoded Ed25519 signature
543
683
  */
544
684
  signAuthMessage(service: string, nonce: string): Promise<string>;
@@ -551,9 +691,14 @@ declare class ZeroXIOWallet extends EventEmitter {
551
691
  private handleExtensionLocked;
552
692
  private handleExtensionUnlocked;
553
693
  private handleTransactionConfirmed;
694
+ /**
695
+ * The wallet takes raw micro-OCT. `amount` passes through unchanged (what every existing
696
+ * dapp sends today); `amountOct` is converted exactly. Never both.
697
+ */
698
+ private resolveRawAmount;
554
699
  /**
555
700
  * Reject numeric amounts that cannot be represented exactly in micro-OCT.
556
- * e.g. 0.1 + 0.2 = 0.30000000000000004 the extension would sign the wrong value.
701
+ * e.g. 0.1 + 0.2 = 0.30000000000000004: the extension would sign the wrong value.
557
702
  * String amounts bypass this check (caller is responsible for correctness).
558
703
  */
559
704
  private assertExactOCTAmount;
@@ -568,7 +713,7 @@ declare class ExtensionCommunicator extends EventEmitter {
568
713
  private isExtensionAvailableState;
569
714
  private trustedOrigins;
570
715
  private _parentOrigin;
571
- /** Pluggable transport defaults to the 0xio postMessage protocol. */
716
+ /** Pluggable transport, defaults to the 0xio postMessage protocol. */
572
717
  private adapter;
573
718
  /** Teardown fn returned by adapter.listen() */
574
719
  private _adapterTeardown;
@@ -576,14 +721,14 @@ declare class ExtensionCommunicator extends EventEmitter {
576
721
  private _adapterReadyTeardown;
577
722
  /**
578
723
  * Set when a trusted walletReady has been received from window.parent.
579
- * The polling fallback must NOT clear this flag.
724
+ * The polling fallback must not clear this flag.
580
725
  */
581
726
  private _parentTrusted;
582
727
  /** walletReady postMessage listener stored for cleanup */
583
728
  private _walletReadyMessageListener;
584
729
  /**
585
730
  * In-flight interactive request lock.
586
- * Methods that open approval popups are serialized only one at a time.
731
+ * Methods that open approval popups are serialized: only one at a time.
587
732
  */
588
733
  private _interactiveInFlight;
589
734
  private readonly MAX_CONCURRENT_REQUESTS;
@@ -595,6 +740,8 @@ declare class ExtensionCommunicator extends EventEmitter {
595
740
  initialize(): Promise<boolean>;
596
741
  isExtensionAvailable(): boolean;
597
742
  private static readonly NO_RETRY_METHODS;
743
+ private static readonly LONG_COMPUTE_METHODS;
744
+ private static readonly PROOF_METHODS;
598
745
  private static readonly INTERACTIVE_METHODS;
599
746
  sendRequest<T = any>(method: string, params?: any, timeout?: number): Promise<T>;
600
747
  sendRequestWithRetry<T = any>(method: string, params?: any, maxRetries?: number, timeout?: number): Promise<T>;
@@ -614,7 +761,7 @@ declare class ExtensionCommunicator extends EventEmitter {
614
761
  private getExtensionDiagnostics;
615
762
  /**
616
763
  * Clean up SDK resources.
617
- * After cleanup() the instance is terminal do not call initialize() again.
764
+ * After cleanup() the instance is terminal: do not call initialize() again.
618
765
  * Construct a new instance instead.
619
766
  */
620
767
  cleanup(): void;
@@ -639,7 +786,7 @@ declare class ExtensionCommunicator extends EventEmitter {
639
786
  * window.postMessage({ source: '0xio-sdk-bridge', response: { id, success, data, error }, sessionNonce })
640
787
  * window.postMessage({ source: '0xio-sdk-bridge', event: { type, data } })
641
788
  *
642
- * H-2: Session nonce validation injected.ts broadcasts the nonce received from the
789
+ * Session nonce validation: injected.ts broadcasts the nonce received from the
643
790
  * isolated content script. Once set, any '0xio-sdk-bridge' response with a missing or
644
791
  * mismatched nonce is rejected, preventing response injection by malicious page scripts.
645
792
  */
@@ -657,7 +804,7 @@ declare const ZeroXIOAdapter: WalletTransportAdapter;
657
804
  *
658
805
  * Targets any wallet that exposes `window.octra` per the RFC-O-1 specification:
659
806
  * window.octra.isOctra === true
660
- * window.octra.request({ method, params }) Promise<unknown>
807
+ * window.octra.request({ method, params }) returns Promise<unknown>
661
808
  * window.octra.on(event, listener) / removeListener(event, listener)
662
809
  *
663
810
  * This adapter translates the SDK's internal method names into RFC-O-1 method
@@ -672,7 +819,7 @@ declare function createOctraProviderAdapter(): WalletTransportAdapter;
672
819
  declare const OctraProviderAdapter: WalletTransportAdapter;
673
820
 
674
821
  /**
675
- * 0xio SDK Wallet Adapter Registry
822
+ * 0xio SDK: Wallet Adapter Registry
676
823
  *
677
824
  * Add new wallet adapters here. Detection order determines which wallet takes
678
825
  * priority when multiple wallets are installed at the same time.
@@ -691,6 +838,19 @@ declare function detectWalletAdapter(): WalletTransportAdapter | null;
691
838
  /** Returns all registered adapter instances. */
692
839
  declare function getAllAdapters(): WalletTransportAdapter[];
693
840
 
841
+ /** Scope names the 0xio wallet enforces. Any other name is dropped at connect. */
842
+ declare const WALLET_PERMISSIONS: readonly ["accounts", "public_transactions", "contract_calls", "contract_views", "private_balance_read", "private_proofs", "private_transfers", "private_claims"];
843
+ type WalletPermission = (typeof WALLET_PERMISSIONS)[number];
844
+ /** Older SDK permission names and the wallet scope each one means. */
845
+ declare const LEGACY_PERMISSION_MAP: Record<string, WalletPermission>;
846
+ /** Translate any mix of old and new names into the wallet's scope names, without duplicates. */
847
+ declare function toWalletPermissions(perms: readonly string[] | undefined): WalletPermission[];
848
+ /**
849
+ * The granted wallet scopes plus every requested old name they satisfy, so a dapp that checks
850
+ * for the name it asked for (for example 'read_balance') keeps seeing it.
851
+ */
852
+ declare function withLegacyAliases(granted: readonly string[] | undefined, requested: readonly string[] | undefined): Permission[];
853
+
694
854
  /**
695
855
  * Network configuration for 0xio SDK
696
856
  */
@@ -703,12 +863,12 @@ declare const NETWORKS: Readonly<Record<string, Readonly<NetworkInfo>>>;
703
863
  declare const DEFAULT_NETWORK_ID = "mainnet";
704
864
  /**
705
865
  * Get network configuration by ID.
706
- * Returns a frozen copy callers cannot mutate SDK-internal state.
866
+ * Returns a frozen copy, so callers cannot mutate SDK-internal state.
707
867
  */
708
868
  declare function getNetworkConfig(networkId?: string): NetworkInfo;
709
869
  /**
710
870
  * Get all available networks.
711
- * Returns frozen copies callers cannot mutate SDK-internal state.
871
+ * Returns frozen copies, so callers cannot mutate SDK-internal state.
712
872
  */
713
873
  declare function getAllNetworks(): NetworkInfo[];
714
874
  /**
@@ -718,11 +878,11 @@ declare function isValidNetworkId(networkId: string): boolean;
718
878
 
719
879
  /**
720
880
  * Default balance structure.
721
- * Accepts a numeric total or undefined never pass a Balance object here.
881
+ * Accepts a numeric total or undefined. Never pass a Balance object here.
722
882
  */
723
883
  declare function createDefaultBalance(total?: number): Balance;
724
884
  declare const SDK_CONFIG: {
725
- readonly version: "2.7.1";
885
+ readonly version: "2.8.0";
726
886
  readonly defaultNetworkId: "mainnet";
727
887
  readonly communicationTimeout: 30000;
728
888
  readonly retryAttempts: 3;
@@ -741,7 +901,7 @@ declare function isValidMessage(message: string): boolean;
741
901
  declare function isValidFeeLevel(feeLevel: number): boolean;
742
902
  /**
743
903
  * Derive the canonical Octra address from a base64-encoded Ed25519 public key.
744
- * Algorithm: SHA-256(pubkey_bytes) base58 prepend "oct"
904
+ * Algorithm: SHA-256 of the pubkey bytes, base58-encoded, with "oct" prepended
745
905
  * Source of truth: ocho-push-server/src/index.ts#deriveAddressFromPubkey
746
906
  */
747
907
  declare function deriveOctraAddress(publicKeyBase64: string): Promise<string>;
@@ -750,6 +910,11 @@ declare function formatAddress(address: string, prefixLength?: number, suffixLen
750
910
  declare function formatTimestamp(timestamp: number): string;
751
911
  declare function formatTxHash(hash: string, length?: number): string;
752
912
  declare function toMicroOCT(amount: number): string;
913
+ /**
914
+ * Exact OCT to raw micro-OCT conversion using string arithmetic (no float rounding).
915
+ * Accepts up to 6 decimals; anything else is rejected.
916
+ */
917
+ declare function octToMicro(amount: string | number): string;
753
918
  declare function fromMicroOCT(microAmount: string | number): number;
754
919
  declare function createErrorMessage(code: ErrorCode, context?: string): string;
755
920
  declare function isErrorType(error: any, code: ErrorCode): boolean;
@@ -789,7 +954,50 @@ declare function createLogger(prefix: string, debug: boolean): {
789
954
  groupEnd: () => void;
790
955
  };
791
956
 
792
- declare const SDK_VERSION = "2.7.1";
957
+ /**
958
+ * 0xio Signed Message standard (v1).
959
+ *
960
+ * `wallet.signMessage(message)` never signs the raw message. The wallet frames it first so a signed
961
+ * "message" can never collide with a transaction pre-image (a transaction is canonical JSON that
962
+ * begins with '{'). The framing is:
963
+ *
964
+ * "Octra Signed Message:\n" + utf8ByteLength(message) + "\n" + message
965
+ *
966
+ * signed as an Ed25519 detached signature over the UTF-8 bytes of that string. The leading 'O'
967
+ * guarantees the signed bytes never begin with '{', so a personal-message signature can never be a
968
+ * valid transaction. Any verifier MUST reconstruct the same bytes: use `getSignedMessageBytes()`
969
+ * with any Ed25519 library, or `verifyMessage()` for a batteries-included check.
970
+ */
971
+ /** Fixed prefix tag for the 0xio Signed Message scheme. */
972
+ declare const SIGNED_MESSAGE_PREFIX = "Octra Signed Message:";
973
+ /** Scheme version, bumped if the framing ever changes so verifiers can detect it. */
974
+ declare const SIGNED_MESSAGE_VERSION = 1;
975
+ /**
976
+ * The exact bytes that `wallet.signMessage(message)` produces a signature over. Verify a 0xio
977
+ * message signature by checking an Ed25519 signature against these bytes with the signer's public
978
+ * key. Zero-dependency - bring your own Ed25519 verifier, or use `verifyMessage`.
979
+ */
980
+ declare function getSignedMessageBytes(message: string): Uint8Array;
981
+ /**
982
+ * Reconstruct the auth message that `wallet.signAuthMessage(service, nonce)` signs. A relying
983
+ * service verifies an auth signature with `verifyMessage(buildAuthMessage(service, nonce, origin),
984
+ * signature, publicKey)`, where `origin` is the caller's page origin.
985
+ */
986
+ declare function buildAuthMessage(service: string, nonce: string, origin: string): string;
987
+ /**
988
+ * Verify a 0xio message signature produced by `wallet.signMessage`.
989
+ *
990
+ * @param message The original message passed to `wallet.signMessage`.
991
+ * @param signature Base64 Ed25519 signature returned by `wallet.signMessage`.
992
+ * @param publicKey Base64 Ed25519 public key of the signer (from `wallet.getPublicKey()`).
993
+ * @returns Whether the signature is valid for this message and key.
994
+ *
995
+ * Uses the Web Crypto Ed25519 primitive (Node 18+, Chrome 137+, Safari 17+, Firefox 129+). In an
996
+ * environment without it, verify `getSignedMessageBytes(message)` with your own Ed25519 library.
997
+ */
998
+ declare function verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
999
+
1000
+ declare const SDK_VERSION = "2.8.0";
793
1001
  declare const MIN_EXTENSION_VERSION = "2.0.1";
794
1002
  declare const MIN_EXTENSION_VERSION_DEVNET = "2.2.1";
795
1003
  declare const SUPPORTED_EXTENSION_VERSIONS = "^2.0.1";
@@ -806,5 +1014,5 @@ declare function checkSDKCompatibility(): {
806
1014
  recommendations: string[];
807
1015
  };
808
1016
 
809
- 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 };
810
- 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 };
1017
+ export { DEFAULT_NETWORK_ID, ErrorCode, EventEmitter, ExtensionCommunicator, LEGACY_PERMISSION_MAP, MIN_EXTENSION_VERSION, MIN_EXTENSION_VERSION_DEVNET, NETWORKS, OctraProviderAdapter, SDK_CONFIG, SDK_VERSION, SIGNED_MESSAGE_PREFIX, SIGNED_MESSAGE_VERSION, SUPPORTED_EXTENSION_VERSIONS, WALLET_PERMISSIONS, ZeroXIOAdapter, ZeroXIOWallet, ZeroXIOWalletError, buildAuthMessage, 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, getSignedMessageBytes, isBrowser, isErrorType, isValidAddress, isValidAmount, isValidFeeLevel, isValidMessage, isValidNetworkId, octToMicro, toMicroOCT, toMicroOCT as toMicroZeroXIO, toWalletPermissions, verifyMessage, withLegacyAliases };
1018
+ 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, WalletPermission, WalletTransportAdapter };