@unicitylabs/sphere-sdk 0.13.2 → 0.13.3-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -633,14 +633,14 @@ if (await Sphere.exists(storage)) {
633
633
 
634
634
  ## Import from Master Key (Legacy Wallets)
635
635
 
636
- For compatibility with legacy wallet files (.dat, .txt):
636
+ For wallets whose master key was extracted elsewhere (e.g. an older backup):
637
637
 
638
638
  ```typescript
639
639
  // Import from master key + chain code (BIP32 mode)
640
640
  const sphere = await Sphere.import({
641
641
  masterKey: '64-hex-chars-master-private-key',
642
642
  chainCode: '64-hex-chars-chain-code',
643
- basePath: "m/84'/1'/0'", // from wallet.dat descriptor
643
+ basePath: "m/84'/1'/0'", // BIP84 account path
644
644
  derivationMode: 'bip32',
645
645
  storage, transport, oracle,
646
646
  });
@@ -695,43 +695,6 @@ if (mnemonic) {
695
695
  }
696
696
  ```
697
697
 
698
- ## Import from Legacy Files (.dat, .txt)
699
-
700
- ```typescript
701
- // Import from wallet.dat file
702
- const fileBuffer = await file.arrayBuffer();
703
- const result = await Sphere.importFromLegacyFile({
704
- fileContent: new Uint8Array(fileBuffer),
705
- fileName: 'wallet.dat',
706
- password: 'wallet-password', // if encrypted
707
- onDecryptProgress: (i, total) => console.log(`Decrypting: ${i}/${total}`),
708
- storage, transport, oracle,
709
- });
710
-
711
- if (result.needsPassword) {
712
- // Re-prompt user for password
713
- }
714
-
715
- if (result.success) {
716
- const sphere = result.sphere;
717
- console.log('Imported wallet:', sphere.identity?.directAddress);
718
- }
719
-
720
- // Import from text backup file
721
- const textContent = await file.text();
722
- const result = await Sphere.importFromLegacyFile({
723
- fileContent: textContent,
724
- fileName: 'backup.txt',
725
- storage, transport, oracle,
726
- });
727
-
728
- // Detect file type and encryption status
729
- const fileType = Sphere.detectLegacyFileType(fileName, content);
730
- // Returns: 'dat' | 'txt' | 'json' | 'mnemonic' | 'unknown'
731
-
732
- const isEncrypted = Sphere.isLegacyFileEncrypted(fileName, content);
733
- ```
734
-
735
698
  ## Core Utilities
736
699
 
737
700
  The SDK exports commonly needed utility functions:
@@ -750,10 +713,6 @@ import {
750
713
  toHumanReadable, // 1500000000000000000n → "1.5"
751
714
  formatAmount, // Format with decimals and symbol
752
715
 
753
- // Address encoding
754
- encodeBech32, decodeBech32,
755
- createAddress, isValidBech32,
756
-
757
716
  // Base58 (Bitcoin-style)
758
717
  base58Encode, base58Decode,
759
718
  isValidPrivateKey,
@@ -764,30 +723,14 @@ import {
764
723
  } from '@unicitylabs/sphere-sdk';
765
724
  ```
766
725
 
767
- ## TXF Serialization
726
+ ## Token storage format
768
727
 
769
- Token eXchange Format for storage. **Note:** TXF is the legacy v1 token format — post v2-cutover, stored v1 TXF tokens remain visible in the wallet (display only) but are unspendable; v2 tokens travel and persist as CBOR blob hex strings. These helpers remain for storage-data handling and legacy display:
728
+ Tokens persist as opaque **v2 CBOR blob hex** in `Token.sdkData`. The storage
729
+ document around them (the `_meta` / `_nametags` / `_tombstones` / `_history`
730
+ envelope) is built and parsed by:
770
731
 
771
732
  ```typescript
772
- import {
773
- tokenToTxf, // Token → TXF format
774
- txfToToken, // TXF → Token
775
- buildTxfStorageData, // Build TXF storage data
776
- parseTxfStorageData, // Parse storage data
777
- getCurrentStateHash, // Get token's current state hash
778
- hasUncommittedTransactions,
779
- } from '@unicitylabs/sphere-sdk';
780
-
781
- // Convert token to TXF
782
- const txf = tokenToTxf(token);
783
- console.log(txf.genesis.data.tokenId);
784
-
785
- // Build TXF storage data
786
- const storageData = await buildTxfStorageData(tokens, {
787
- version: 1,
788
- address: '02abc123...', // chain pubkey
789
- ipnsName: 'k51...',
790
- });
733
+ import { buildTxfStorageData, parseTxfStorageData } from '@unicitylabs/sphere-sdk';
791
734
  ```
792
735
 
793
736
  ## Token Validation
@@ -857,7 +800,6 @@ Implementation (platform-specific)
857
800
  Core Utilities
858
801
  ├── crypto - Key derivation, hashing, signatures
859
802
  ├── currency - Amount formatting and conversion
860
- ├── bech32 - Address encoding (BIP-173)
861
803
  └── utils - Base58, patterns, sleep, random
862
804
  ```
863
805
 
@@ -550,7 +550,7 @@ function checkCompatibility(input) {
550
550
  }
551
551
 
552
552
  // connect/version.ts
553
- var SDK_VERSION = "0.13.2";
553
+ var SDK_VERSION = "0.13.3-dev.1";
554
554
 
555
555
  // connect/permissions.ts
556
556
  var PERMISSION_SCOPES = {