applesauce-wallet 0.0.0-next-20250930093922 → 0.0.0-next-20251203172109

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,6 +1,6 @@
1
1
  import { Token } from "@cashu/cashu-ts";
2
2
  import { Action } from "applesauce-actions";
3
- import { NostrEvent } from "nostr-tools";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
4
  /**
5
5
  * Adds a cashu token to the wallet and marks a list of nutzaps as redeemed
6
6
  * @param token the cashu token to add
@@ -1,8 +1,8 @@
1
- import { CashuMint, CashuWallet, CheckStateEnum } from "@cashu/cashu-ts";
2
- import { DeleteBlueprint } from "applesauce-factory/blueprints";
3
- import { getTokenContent, ignoreDuplicateProofs, isTokenContentUnlocked, WALLET_TOKEN_KIND, } from "../helpers/tokens.js";
4
- import { WalletTokenBlueprint } from "../blueprints/tokens.js";
1
+ import { CheckStateEnum, Wallet, Mint } from "@cashu/cashu-ts";
2
+ import { DeleteBlueprint } from "applesauce-common/blueprints/delete";
5
3
  import { WalletHistoryBlueprint } from "../blueprints/history.js";
4
+ import { WalletTokenBlueprint } from "../blueprints/tokens.js";
5
+ import { getTokenContent, ignoreDuplicateProofs, isTokenContentUnlocked, WALLET_TOKEN_KIND, } from "../helpers/tokens.js";
6
6
  /**
7
7
  * Adds a cashu token to the wallet and marks a list of nutzaps as redeemed
8
8
  * @param token the cashu token to add
@@ -85,8 +85,8 @@ export function ConsolidateTokens(opts) {
85
85
  }, new Map());
86
86
  // loop over each mint and consolidate proofs
87
87
  for (const [mint, tokens] of byMint) {
88
- const cashuMint = new CashuMint(mint);
89
- const cashuWallet = new CashuWallet(cashuMint);
88
+ const cashuMint = new Mint(mint);
89
+ const cashuWallet = new Wallet(cashuMint);
90
90
  // get all tokens proofs
91
91
  const proofs = tokens
92
92
  .map((t) => getTokenContent(t).proofs)
@@ -1,7 +1,7 @@
1
- import { getWalletMints, getWalletPrivateKey, isWalletUnlocked, unlockWallet, WALLET_KIND } from "../helpers/wallet.js";
2
1
  import { WalletBackupBlueprint, WalletBlueprint } from "../blueprints/wallet.js";
3
- import { isTokenContentUnlocked, unlockTokenContent, WALLET_TOKEN_KIND } from "../helpers/tokens.js";
4
2
  import { isHistoryContentUnlocked, unlockHistoryContent, WALLET_HISTORY_KIND } from "../helpers/history.js";
3
+ import { isTokenContentUnlocked, unlockTokenContent, WALLET_TOKEN_KIND } from "../helpers/tokens.js";
4
+ import { getWalletMints, getWalletPrivateKey, isWalletUnlocked, unlockWallet, WALLET_KIND } from "../helpers/wallet.js";
5
5
  /** An action that creates a new 17375 wallet event and 375 wallet backup */
6
6
  export function CreateWallet(mints, privateKey) {
7
7
  return async function* ({ events, factory, self }) {
@@ -1,5 +1,5 @@
1
- import { modifyPublicTags } from "applesauce-factory/operations";
2
- import { addNameValueTag, removeNameValueTag, setSingletonTag } from "applesauce-factory/operations/tag";
1
+ import { modifyPublicTags } from "applesauce-core/operations/tags";
2
+ import { addNameValueTag, removeNameValueTag, setSingletonTag } from "applesauce-core/operations/tag/common";
3
3
  import { NUTZAP_INFO_KIND } from "../helpers/zap-info.js";
4
4
  import { setNutzapInfoMints, setNutzapInfoPubkey, setNutzapInfoRelays } from "../operations/zap-info.js";
5
5
  /** An action to add a relay to the kind 10019 nutzap info event */
@@ -1,7 +1,7 @@
1
1
  import { Token } from "@cashu/cashu-ts";
2
2
  import { Action } from "applesauce-actions";
3
- import { NostrEvent } from "nostr-tools";
4
- import { ProfilePointer } from "nostr-tools/nip19";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
5
5
  /** Creates a NIP-61 nutzap event for an event with a token */
6
6
  export declare function NutzapEvent(event: NostrEvent, token: Token, comment?: string): Action;
7
7
  /** Creates a NIP-61 nutzap event to a users profile */
@@ -1,4 +1,4 @@
1
- import { EventPointer } from "nostr-tools/nip19";
1
+ import { EventPointer } from "applesauce-core/helpers/pointers";
2
2
  import { HistoryContent } from "../helpers/history.js";
3
3
  /** A blueprint that creates a wallet history event */
4
- export declare function WalletHistoryBlueprint(content: HistoryContent, redeemed: (string | EventPointer)[]): import("applesauce-factory").EventBlueprint;
4
+ export declare function WalletHistoryBlueprint(content: HistoryContent, redeemed: (string | EventPointer)[]): import("applesauce-core").EventBlueprint;
@@ -1,4 +1,4 @@
1
- import { blueprint } from "applesauce-factory";
1
+ import { blueprint } from "applesauce-core";
2
2
  import { WALLET_HISTORY_KIND } from "../helpers/history.js";
3
3
  import { setHistoryContent, setHistoryRedeemed } from "../operations/history.js";
4
4
  /** A blueprint that creates a wallet history event */
@@ -4,4 +4,4 @@ import { Token } from "@cashu/cashu-ts";
4
4
  * @param token the cashu token to store
5
5
  * @param [del=[]] an array of previous token event ids that are deleted
6
6
  */
7
- export declare function WalletTokenBlueprint(token: Token, del?: string[]): import("applesauce-factory").EventBlueprint;
7
+ export declare function WalletTokenBlueprint(token: Token, del?: string[]): import("applesauce-core").EventBlueprint;
@@ -1,4 +1,4 @@
1
- import { blueprint } from "applesauce-factory";
1
+ import { blueprint } from "applesauce-core";
2
2
  import { WALLET_TOKEN_KIND } from "../helpers/tokens.js";
3
3
  import { setToken } from "../operations/tokens.js";
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { NostrEvent } from "nostr-tools";
1
+ import { NostrEvent } from "applesauce-core/helpers/event";
2
2
  /** A blueprint to create a new 17375 wallet */
3
- export declare function WalletBlueprint(mints: string[], privateKey?: Uint8Array): import("applesauce-factory").EventBlueprint;
3
+ export declare function WalletBlueprint(mints: string[], privateKey?: Uint8Array): import("applesauce-core").EventBlueprint;
4
4
  /** A blueprint that creates a new 375 wallet backup event */
5
- export declare function WalletBackupBlueprint(wallet: NostrEvent): import("applesauce-factory").EventBlueprint;
5
+ export declare function WalletBackupBlueprint(wallet: NostrEvent): import("applesauce-core").EventBlueprint;
@@ -1,4 +1,4 @@
1
- import { blueprint } from "applesauce-factory";
1
+ import { blueprint } from "applesauce-core";
2
2
  import { WALLET_BACKUP_KIND, WALLET_KIND } from "../helpers/wallet.js";
3
3
  import { setBackupContent, setMints, setPrivateKey } from "../operations/wallet.js";
4
4
  /** A blueprint to create a new 17375 wallet */
@@ -1,7 +1,7 @@
1
1
  import { Token } from "@cashu/cashu-ts";
2
- import { EventBlueprint } from "applesauce-factory";
3
- import { NostrEvent } from "nostr-tools";
4
- import { ProfilePointer } from "nostr-tools/nip19";
2
+ import { EventBlueprint } from "applesauce-core/event-factory";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
+ import { ProfilePointer } from "applesauce-core/helpers/pointers";
5
5
  /** A blueprint to create a NIP-61 nutzap event for an event */
6
6
  export declare function NutzapBlueprint(event: NostrEvent, token: Token, comment?: string): EventBlueprint;
7
7
  /** A blueprint to create a NIP-61 nutzap event for a user instead of an event */
@@ -1,5 +1,5 @@
1
- import { blueprint } from "applesauce-factory";
2
- import { skip } from "applesauce-factory/helpers";
1
+ import { blueprint } from "applesauce-core/event-factory";
2
+ import { skip } from "applesauce-core/helpers";
3
3
  import { NUTZAP_KIND } from "../helpers/nutzap.js";
4
4
  import { setComment, setEvent, setMint, setProofs, setRecipient } from "../operations/nutzap.js";
5
5
  /** A blueprint to create a NIP-61 nutzap event for an event */
@@ -1,5 +1,5 @@
1
1
  import { HiddenContentSigner, UnlockedHiddenTags } from "applesauce-core/helpers";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  export declare const WALLET_HISTORY_KIND = 7376;
4
4
  export type HistoryDirection = "in" | "out";
5
5
  export type HistoryContent = {
@@ -1,7 +1,7 @@
1
1
  import { Proof } from "@cashu/cashu-ts";
2
2
  import { KnownEvent } from "applesauce-core/helpers";
3
- import { NostrEvent } from "nostr-tools";
4
- import { AddressPointer, EventPointer, ProfilePointer } from "nostr-tools/nip19";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
+ import { AddressPointer, EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
5
5
  export declare const NUTZAP_KIND = 9321;
6
6
  /** Validated NIP-61 nutzap event */
7
7
  export type NutzapEvent = KnownEvent<typeof NUTZAP_KIND>;
@@ -1,6 +1,6 @@
1
1
  import { Proof, Token } from "@cashu/cashu-ts";
2
2
  import { HiddenContentSigner, UnlockedHiddenContent } from "applesauce-core/helpers";
3
- import { NostrEvent } from "nostr-tools";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
4
  export declare const WALLET_TOKEN_KIND = 7375;
5
5
  /** Internal method for creating a unique id for each proof */
6
6
  export declare function getProofUID(proof: Proof): string;
@@ -1,5 +1,5 @@
1
1
  import { HiddenContentSigner, UnlockedHiddenTags } from "applesauce-core/helpers";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  export declare const WALLET_KIND = 17375;
4
4
  export declare const WALLET_BACKUP_KIND = 375;
5
5
  export declare const WalletPrivateKeySymbol: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import { Proof } from "@cashu/cashu-ts";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  export declare const NUTZAP_INFO_KIND = 10019;
4
4
  export declare const NutzapMintsSymbol: unique symbol;
5
5
  export declare const NutzapRelaysSymbol: unique symbol;
@@ -1,5 +1,5 @@
1
1
  import { Model } from "applesauce-core";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  /** A model that returns an array of redeemed event ids for a wallet */
4
4
  export declare function WalletRedeemedModel(pubkey: string): Model<string[]>;
5
5
  /** A model that returns a timeline of wallet history events */
@@ -1,6 +1,6 @@
1
1
  import { Model } from "applesauce-core";
2
2
  import { KnownEvent } from "applesauce-core/helpers";
3
- import { NostrEvent } from "nostr-tools";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
4
  import { NUTZAP_KIND } from "../helpers/nutzap.js";
5
5
  /** A model that returns all nutzap events for an event */
6
6
  export declare function EventNutZapzModel(event: NostrEvent): Model<KnownEvent<typeof NUTZAP_KIND>[]>;
@@ -1,5 +1,5 @@
1
1
  import { Model } from "applesauce-core";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  /** A model that subscribes to all token events for a wallet, passing locked will filter by token locked status */
4
4
  export declare function WalletTokensModel(pubkey: string, locked?: boolean | undefined): Model<NostrEvent[]>;
5
5
  /** A model that returns the visible balance of a wallet for each mint */
@@ -1,5 +1,5 @@
1
1
  import { Model } from "applesauce-core";
2
- import { NostrEvent } from "nostr-tools";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  export type WalletInfo = {
4
4
  locked: true;
5
5
  event: NostrEvent;
@@ -1,5 +1,5 @@
1
- import { EventOperation } from "applesauce-factory";
2
- import { EventPointer } from "nostr-tools/nip19";
1
+ import { EventOperation } from "applesauce-core/event-factory";
2
+ import { EventPointer } from "applesauce-core/helpers";
3
3
  import { HistoryContent } from "../helpers/history.js";
4
4
  /** Sets the encrypted tags of a wallet history event */
5
5
  export declare function setHistoryContent(content: HistoryContent): EventOperation;
@@ -1,6 +1,6 @@
1
- import { ensureMarkedEventPointerTag } from "applesauce-factory/helpers";
2
- import { modifyHiddenTags, modifyPublicTags } from "applesauce-factory/operations";
3
- import { setSingletonTag } from "applesauce-factory/operations/tag";
1
+ import { ensureMarkedEventPointerTag } from "applesauce-core/helpers";
2
+ import { setSingletonTag } from "applesauce-core/operations/tag/common";
3
+ import { modifyHiddenTags, modifyPublicTags } from "applesauce-core/operations/tags";
4
4
  /** Includes "e" "created" tags in wallet history tags */
5
5
  function includeHistoryCreatedTags(created) {
6
6
  return (tags) => {
@@ -1,7 +1,7 @@
1
- import { Proof } from "@cashu/cashu-ts";
2
- import { EventOperation } from "applesauce-factory";
3
- import { NostrEvent } from "nostr-tools";
4
- import { AddressPointer, EventPointer, ProfilePointer } from "nostr-tools/nip19";
1
+ import { type Proof } from "@cashu/cashu-ts";
2
+ import { EventOperation } from "applesauce-core";
3
+ import { NostrEvent } from "applesauce-core/helpers/event";
4
+ import { AddressPointer, EventPointer, ProfilePointer } from "applesauce-core/helpers/pointers";
5
5
  /** Sets the cashu proofs for a nutzap event */
6
6
  export declare function setProofs(proofs: Proof[]): EventOperation;
7
7
  /** Sets the mint URL for a nutzap event */
@@ -1,7 +1,7 @@
1
1
  import { getReplaceableAddress, isAddressPointer, isEvent, isReplaceable } from "applesauce-core/helpers";
2
- import { modifyPublicTags } from "applesauce-factory/operations";
3
- import { setContent } from "applesauce-factory/operations/content";
4
- import { addAddressTag, addEventTag, addPubkeyTag, setSingletonTag } from "applesauce-factory/operations/tag";
2
+ import { modifyPublicTags } from "applesauce-core/operations";
3
+ import { setContent } from "applesauce-core/operations/content";
4
+ import { addAddressPointerTag, addEventPointerTag, addProfilePointerTag, setSingletonTag, } from "applesauce-core/operations/tag/common";
5
5
  /** Sets the cashu proofs for a nutzap event */
6
6
  export function setProofs(proofs) {
7
7
  // Create an operation to append proof tags
@@ -14,17 +14,19 @@ export function setMint(mint) {
14
14
  }
15
15
  /** Sets the recipient of a nutzap event */
16
16
  export function setRecipient(recipient) {
17
- return modifyPublicTags(addPubkeyTag(recipient, true));
17
+ return modifyPublicTags(addProfilePointerTag(recipient, true));
18
18
  }
19
19
  /** Sets the event that is being nutzapped */
20
20
  export function setEvent(event) {
21
21
  let operation;
22
22
  if (isEvent(event))
23
- operation = isReplaceable(event.kind) ? addEventTag(event.id) : addAddressTag(getReplaceableAddress(event));
23
+ operation = isReplaceable(event.kind)
24
+ ? addEventPointerTag(event.id)
25
+ : addAddressPointerTag(getReplaceableAddress(event));
24
26
  else if (isAddressPointer(event))
25
- operation = addAddressTag(event);
27
+ operation = addAddressPointerTag(event);
26
28
  else
27
- operation = addEventTag(event);
29
+ operation = addEventPointerTag(event);
28
30
  return modifyPublicTags(operation);
29
31
  }
30
32
  /** Sets the comment content for a nutzap event */
@@ -1,4 +1,4 @@
1
- import { Token } from "@cashu/cashu-ts";
2
- import { EventOperation } from "applesauce-factory";
1
+ import { type Token } from "@cashu/cashu-ts";
2
+ import { EventOperation } from "applesauce-core";
3
3
  /** Sets the content of a 7375 token event */
4
4
  export declare function setToken(token: Token, del?: string[]): EventOperation;
@@ -1,5 +1,5 @@
1
1
  import { EventContentEncryptionMethod } from "applesauce-core/helpers";
2
- import { setEncryptedContent } from "applesauce-factory/operations/content";
2
+ import { setEncryptedContent } from "applesauce-core/operations/encrypted-content";
3
3
  /** Sets the content of a 7375 token event */
4
4
  export function setToken(token, del = []) {
5
5
  return async (draft, ctx) => {
@@ -1,5 +1,5 @@
1
- import { EventOperation } from "applesauce-factory";
2
- import { NostrEvent } from "nostr-tools";
1
+ import { EventOperation } from "applesauce-core/event-factory";
2
+ import { NostrEvent } from "applesauce-core/helpers/event";
3
3
  /** Sets the content of a kind 375 wallet backup event */
4
4
  export declare function setBackupContent(wallet: NostrEvent): EventOperation;
5
5
  /** Sets the "mint" tags in a wallet event */
@@ -1,6 +1,6 @@
1
- import { bytesToHex } from "@noble/hashes/utils";
2
- import { modifyHiddenTags } from "applesauce-factory/operations";
3
- import { setSingletonTag } from "applesauce-factory/operations/tag";
1
+ import { bytesToHex } from "applesauce-core/helpers/event";
2
+ import { setSingletonTag } from "applesauce-core/operations/tag/common";
3
+ import { modifyHiddenTags } from "applesauce-core/operations/tags";
4
4
  import { WALLET_KIND } from "../helpers/wallet.js";
5
5
  /** Sets the content of a kind 375 wallet backup event */
6
6
  export function setBackupContent(wallet) {
@@ -1,4 +1,4 @@
1
- import { EventOperation } from "applesauce-factory";
1
+ import { EventOperation } from "applesauce-core";
2
2
  /** Sets the relays for a nutzap info event */
3
3
  export declare function setNutzapInfoRelays(relays: string[]): EventOperation;
4
4
  /** Sets the mints for a nutzap info event */
@@ -1,5 +1,5 @@
1
- import { modifyPublicTags } from "applesauce-factory/operations";
2
- import { addNameValueTag, setSingletonTag } from "applesauce-factory/operations/tag";
1
+ import { modifyPublicTags } from "applesauce-core/operations";
2
+ import { addNameValueTag, setSingletonTag } from "applesauce-core/operations/tag/common";
3
3
  /** Sets the relays for a nutzap info event */
4
4
  export function setNutzapInfoRelays(relays) {
5
5
  return modifyPublicTags(...relays.map((relay) => addNameValueTag(["relay", relay], false)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-wallet",
3
- "version": "0.0.0-next-20250930093922",
3
+ "version": "0.0.0-next-20251203172109",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -72,22 +72,21 @@
72
72
  }
73
73
  },
74
74
  "dependencies": {
75
- "@cashu/cashu-ts": "^2.7.2",
75
+ "@cashu/cashu-ts": "^3.1.1",
76
76
  "@gandlaf21/bc-ur": "^1.1.12",
77
77
  "@noble/hashes": "^1.7.1",
78
- "applesauce-actions": "0.0.0-next-20250930093922",
79
- "applesauce-core": "0.0.0-next-20250930093922",
80
- "applesauce-factory": "0.0.0-next-20250930093922",
81
- "nostr-tools": "~2.17",
78
+ "applesauce-actions": "0.0.0-next-20251203172109",
79
+ "applesauce-common": "0.0.0-next-20251203172109",
80
+ "applesauce-core": "0.0.0-next-20251203172109",
82
81
  "rxjs": "^7.8.1"
83
82
  },
84
83
  "devDependencies": {
85
84
  "@hirez_io/observer-spy": "^2.2.0",
86
85
  "@types/debug": "^4.1.12",
87
- "applesauce-signers": "0.0.0-next-20250930093922",
86
+ "applesauce-signers": "0.0.0-next-20251203172109",
88
87
  "rimraf": "^6.0.1",
89
88
  "typescript": "^5.8.3",
90
- "vitest": "^3.2.4"
89
+ "vitest": "^4.0.15"
91
90
  },
92
91
  "funding": {
93
92
  "type": "lightning",