@1sat/wallet-toolbox 0.0.70 → 0.0.72

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.
@@ -1,7 +1,7 @@
1
- import type { sdk } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
2
- import type { TableSettings } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSettings.js";
3
- import type { TableSyncState } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSyncState.js";
4
- import type { TableUser } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableUser.js";
1
+ import type { sdk } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
2
+ import type { TableSettings } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSettings.js";
3
+ import type { TableSyncState } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSyncState.js";
4
+ import type { TableUser } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/tables/TableUser.js";
5
5
  import { Zip, ZipDeflate } from "fflate";
6
6
  type AuthId = sdk.AuthId;
7
7
  type ProcessSyncChunkResult = sdk.ProcessSyncChunkResult;
@@ -1,5 +1,5 @@
1
- import type { sdk } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
2
- import type { TableSettings } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSettings.js";
1
+ import type { sdk } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
2
+ import type { TableSettings } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/tables/TableSettings.js";
3
3
  import type { Unzipped } from "fflate";
4
4
  import type { BackupManifest } from "./types";
5
5
  type RequestSyncChunkArgs = sdk.RequestSyncChunkArgs;
@@ -1,4 +1,4 @@
1
- import type { sdk } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
1
+ import type { sdk } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
2
2
  type Chain = sdk.Chain;
3
3
  /**
4
4
  * Manifest stored in the backup ZIP file describing the backup contents.
@@ -1,5 +1,5 @@
1
1
  import { Beef, Transaction } from "@bsv/sdk";
2
- import type { TableOutput, sdk as toolboxSdk } from "@bsv/wallet-toolbox";
2
+ import type { TableOutput, sdk as toolboxSdk } from "@bopen-io/wallet-toolbox";
3
3
  type Chain = toolboxSdk.Chain;
4
4
  type BlockHeader = toolboxSdk.BlockHeader;
5
5
  type GetMerklePathResult = toolboxSdk.GetMerklePathResult;
@@ -1,10 +1,10 @@
1
1
  import type { ChainTracker } from "@bsv/sdk";
2
- import type { BaseBlockHeader, BlockHeader, Chain } from "@bsv/wallet-toolbox";
2
+ import type { BaseBlockHeader, BlockHeader, Chain } from "@bopen-io/wallet-toolbox";
3
3
  import type { ClientOptions } from "../types";
4
4
  import { BaseClient } from "./BaseClient";
5
5
  /**
6
6
  * Client for /1sat/chaintracks/* routes.
7
- * Implements ChaintracksClientApi interface from @bsv/wallet-toolbox.
7
+ * Implements ChaintracksClientApi interface from @bopen-io/wallet-toolbox.
8
8
  *
9
9
  * Routes:
10
10
  * - GET /tip - Get chain tip
@@ -54,7 +54,7 @@ function toHex(data) {
54
54
  }
55
55
  /**
56
56
  * Client for /1sat/chaintracks/* routes.
57
- * Implements ChaintracksClientApi interface from @bsv/wallet-toolbox.
57
+ * Implements ChaintracksClientApi interface from @bopen-io/wallet-toolbox.
58
58
  *
59
59
  * Routes:
60
60
  * - GET /tip - Get chain tip
@@ -5,7 +5,7 @@
5
5
  * (browser extension) and 1sat-website (React app).
6
6
  */
7
7
  import { PrivateKey } from "@bsv/sdk";
8
- import { Monitor, type PermissionsManagerConfig, StorageClient, Wallet, WalletPermissionsManager, WalletStorageManager } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
8
+ import { Monitor, type PermissionsManagerConfig, StorageClient, Wallet, WalletPermissionsManager, WalletStorageManager } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
9
9
  import { OneSatServices } from "../services/OneSatServices";
10
10
  import { type FullSyncResult, type FullSyncStage } from "./fullSync";
11
11
  type Chain = "main" | "test";
@@ -5,7 +5,7 @@
5
5
  * (browser extension) and 1sat-website (React app).
6
6
  */
7
7
  import { KeyDeriver, PrivateKey } from "@bsv/sdk";
8
- import { Monitor, Services, StorageClient, StorageIdb, StorageProvider, Wallet, WalletPermissionsManager, WalletStorageManager, } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
8
+ import { Monitor, Services, StorageClient, StorageIdb, StorageProvider, Wallet, WalletPermissionsManager, WalletStorageManager, } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
9
9
  import { OneSatServices } from "../services/OneSatServices";
10
10
  import { fullSync } from "./fullSync";
11
11
  // Default database name for IndexedDB storage
@@ -92,9 +92,31 @@ export async function createWebWallet(config) {
92
92
  remoteClient = new StorageClient(underlyingWallet, config.remoteStorageUrl);
93
93
  const timeoutPromise = new Promise((_, reject) => setTimeout(() => reject(new Error("Remote storage connection timeout")), DEFAULT_REMOTE_STORAGE_TIMEOUT));
94
94
  await Promise.race([remoteClient.makeAvailable(), timeoutPromise]);
95
- // Add remote as backup destination (push-only, no pull)
95
+ // Add remote to storage manager - it will partition as conflicting if another device is active
96
96
  await storage.addWalletStorageProvider(remoteClient);
97
- console.log("[createWebWallet] Remote backup connected");
97
+ // Check if remote ended up in backup stores (active) or got partitioned (conflicting)
98
+ const remoteStorageKey = remoteClient.getSettings().storageIdentityKey;
99
+ const isActive = storage.getBackupStores().includes(remoteStorageKey);
100
+ if (isActive) {
101
+ console.log("[createWebWallet] Remote backup connected (we are active)");
102
+ }
103
+ else {
104
+ // Another device is active - need fullSync then setActive
105
+ // fullSync builds ID mappings before setActive attempts to merge
106
+ console.log("[createWebWallet] Another device is active, performing full sync...");
107
+ await fullSync({
108
+ storage,
109
+ remoteStorage: remoteClient,
110
+ identityKey: identityPubKey,
111
+ onProgress: (stage, msg) => console.log(`[createWebWallet] fullSync ${stage}: ${msg}`),
112
+ });
113
+ // Claim active status (merge now works because mappings exist from fullSync)
114
+ await storage.setActive(config.storageIdentityKey, (msg) => {
115
+ console.log("[createWebWallet] setActive:", msg);
116
+ return msg;
117
+ });
118
+ console.log("[createWebWallet] Remote backup connected (now active after handoff)");
119
+ }
98
120
  }
99
121
  catch (err) {
100
122
  console.log("[createWebWallet] Remote backup connection failed:", err instanceof Error ? err.message : err);
@@ -4,8 +4,8 @@
4
4
  * Performs a complete resync: push local → reset sync state → full pull from server.
5
5
  * This is a deliberate user action (not automatic) for recovering from sync issues.
6
6
  */
7
- import type { WalletStorageManager } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
8
- import type { sdk as mobileToolboxSdk } from "@bsv/wallet-toolbox-mobile/out/src/index.client.js";
7
+ import type { WalletStorageManager } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
8
+ import type { sdk as mobileToolboxSdk } from "@bopen-io/wallet-toolbox-mobile/out/src/index.client.js";
9
9
  type WalletStorageProvider = mobileToolboxSdk.WalletStorageProvider;
10
10
  export type FullSyncStage = "pushing" | "resetting" | "pulling" | "complete";
11
11
  export interface FullSyncOptions {
@@ -4,8 +4,8 @@
4
4
  * Performs a complete resync: push local → reset sync state → full pull from server.
5
5
  * This is a deliberate user action (not automatic) for recovering from sync issues.
6
6
  */
7
- import { createSyncMap } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntityBase.js";
8
- import { EntitySyncState } from "@bsv/wallet-toolbox-mobile/out/src/storage/schema/entities/EntitySyncState.js";
7
+ import { createSyncMap } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/entities/EntityBase.js";
8
+ import { EntitySyncState } from "@bopen-io/wallet-toolbox-mobile/out/src/storage/schema/entities/EntitySyncState.js";
9
9
  /**
10
10
  * Perform a full sync with the remote backup server.
11
11
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/wallet-toolbox",
3
- "version": "0.0.70",
3
+ "version": "0.0.72",
4
4
  "description": "BSV wallet library extending @bsv/wallet-toolbox with 1Sat Ordinals protocol support",
5
5
  "author": "1Sat Team",
6
6
  "license": "MIT",
@@ -45,17 +45,17 @@
45
45
  "fflate": "^0.8.2"
46
46
  },
47
47
  "peerDependencies": {
48
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.22-idb-fix.3"
48
+ "@bopen-io/wallet-toolbox-mobile": "1.7.24-idb-fix.1"
49
49
  },
50
50
  "peerDependenciesMeta": {
51
- "@bsv/wallet-toolbox-mobile": {
51
+ "@bopen-io/wallet-toolbox-mobile": {
52
52
  "optional": true
53
53
  }
54
54
  },
55
55
  "devDependencies": {
56
56
  "@biomejs/biome": "^1.9.4",
57
- "@bsv/wallet-toolbox": "npm:@bopen-io/wallet-toolbox@^1.7.22-idb-fix.3",
58
- "@bsv/wallet-toolbox-mobile": "npm:@bopen-io/wallet-toolbox-mobile@^1.7.22-idb-fix.3",
57
+ "@bopen-io/wallet-toolbox": "1.7.24-idb-fix.1",
58
+ "@bopen-io/wallet-toolbox-mobile": "1.7.24-idb-fix.1",
59
59
  "@types/bun": "^1.3.4",
60
60
  "@types/chrome": "^0.1.32",
61
61
  "typescript": "^5.9.3"