applesauce-wallet 0.0.0-next-20250312195837 → 0.0.0-next-20250313084132

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,8 +1,8 @@
1
1
  import { generateSecretKey } from "nostr-tools";
2
2
  import { isWalletLocked, unlockWallet, WALLET_KIND } from "../helpers/wallet.js";
3
3
  import { WalletBackupBlueprint, WalletBlueprint } from "../blueprints/wallet.js";
4
- import { unlockTokenContent, WALLET_TOKEN_KIND } from "../helpers/tokens.js";
5
- import { unlockHistoryContent, WALLET_HISTORY_KIND } from "../helpers/history.js";
4
+ import { isTokenContentLocked, unlockTokenContent, WALLET_TOKEN_KIND } from "../helpers/tokens.js";
5
+ import { isHistoryContentLocked, unlockHistoryContent, WALLET_HISTORY_KIND } from "../helpers/history.js";
6
6
  /** An action that creates a new 17375 wallet event and 375 wallet backup */
7
7
  export function CreateWallet(mints, privateKey = generateSecretKey()) {
8
8
  return async ({ events, factory, self, publish }) => {
@@ -24,17 +24,19 @@ export function UnlockWallet(unlock) {
24
24
  const wallet = events.getReplaceable(WALLET_KIND, self);
25
25
  if (!wallet)
26
26
  throw new Error("Wallet does not exist");
27
- if (!isWalletLocked(wallet))
27
+ if (isWalletLocked(wallet))
28
28
  await unlockWallet(wallet, signer);
29
29
  if (unlock?.tokens) {
30
30
  const tokens = events.getTimeline({ kinds: [WALLET_TOKEN_KIND], authors: [self] });
31
31
  for (const token of tokens)
32
- await unlockTokenContent(token, signer);
32
+ if (isTokenContentLocked(token))
33
+ await unlockTokenContent(token, signer);
33
34
  }
34
35
  if (unlock?.history) {
35
36
  const history = events.getTimeline({ kinds: [WALLET_HISTORY_KIND], authors: [self] });
36
37
  for (const entry of history)
37
- await unlockHistoryContent(entry, signer);
38
+ if (isHistoryContentLocked(entry))
39
+ await unlockHistoryContent(entry, signer);
38
40
  }
39
41
  };
40
42
  }
@@ -9,11 +9,8 @@ function filterDeleted(tokens) {
9
9
  // skip this event if it a newer event says its deleted
10
10
  if (deleted.has(token.id))
11
11
  return false;
12
- // skip if token is locked
13
- if (isTokenContentLocked(token))
14
- return false;
15
- else {
16
- // add ids to deleted array
12
+ // add ids to deleted array
13
+ if (!isTokenContentLocked(token)) {
17
14
  const details = getTokenContent(token);
18
15
  for (const id of details.del)
19
16
  deleted.add(id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-wallet",
3
- "version": "0.0.0-next-20250312195837",
3
+ "version": "0.0.0-next-20250313084132",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -79,16 +79,16 @@
79
79
  "dependencies": {
80
80
  "@cashu/cashu-ts": "2.0.0-rc1",
81
81
  "@noble/hashes": "^1.7.1",
82
- "applesauce-actions": "0.0.0-next-20250312195837",
83
- "applesauce-core": "0.0.0-next-20250312195837",
84
- "applesauce-factory": "0.0.0-next-20250312195837",
82
+ "applesauce-actions": "0.0.0-next-20250313084132",
83
+ "applesauce-core": "0.0.0-next-20250313084132",
84
+ "applesauce-factory": "0.0.0-next-20250313084132",
85
85
  "nostr-tools": "^2.10.4",
86
86
  "rxjs": "^7.8.1"
87
87
  },
88
88
  "devDependencies": {
89
89
  "@hirez_io/observer-spy": "^2.2.0",
90
90
  "@types/debug": "^4.1.12",
91
- "applesauce-signers": "0.0.0-next-20250312195837",
91
+ "applesauce-signers": "0.0.0-next-20250313084132",
92
92
  "typescript": "^5.7.3",
93
93
  "vitest": "^3.0.5"
94
94
  },