applesauce-wallet 0.0.0-next-20250723224513 → 0.0.0-next-20250725170333

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.
Files changed (75) hide show
  1. package/dist/actions/zap-info.js +2 -2
  2. package/dist/blueprints/history.js +1 -1
  3. package/dist/blueprints/tokens.js +2 -2
  4. package/dist/blueprints/wallet.js +3 -5
  5. package/dist/blueprints/zaps.js +3 -3
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +1 -1
  8. package/dist/operations/{event/history.d.ts → history.d.ts} +2 -2
  9. package/dist/operations/history.js +34 -0
  10. package/dist/operations/index.d.ts +5 -2
  11. package/dist/operations/index.js +5 -2
  12. package/dist/operations/{event/zaps.d.ts → nut-zap.d.ts} +5 -5
  13. package/dist/operations/{event/zaps.js → nut-zap.js} +8 -7
  14. package/dist/operations/{event/tokens.d.ts → tokens.d.ts} +1 -1
  15. package/dist/operations/{event/tokens.js → tokens.js} +2 -2
  16. package/dist/operations/wallet.d.ts +8 -0
  17. package/dist/operations/wallet.js +30 -0
  18. package/dist/operations/{event/zap-info.js → zap-info.js} +1 -1
  19. package/package.json +5 -5
  20. package/dist/__tests__/exports.test.d.ts +0 -1
  21. package/dist/__tests__/exports.test.js +0 -16
  22. package/dist/__tests__/fake-user.d.ts +0 -10
  23. package/dist/__tests__/fake-user.js +0 -31
  24. package/dist/actions/__tests__/exports.test.d.ts +0 -1
  25. package/dist/actions/__tests__/exports.test.js +0 -17
  26. package/dist/actions/__tests__/tokens.test.d.ts +0 -1
  27. package/dist/actions/__tests__/tokens.test.js +0 -139
  28. package/dist/actions/__tests__/wallet.test.d.ts +0 -1
  29. package/dist/actions/__tests__/wallet.test.js +0 -56
  30. package/dist/blueprints/__tests__/exports.test.d.ts +0 -1
  31. package/dist/blueprints/__tests__/exports.test.js +0 -13
  32. package/dist/helpers/__tests__/animated-qr.test.d.ts +0 -1
  33. package/dist/helpers/__tests__/animated-qr.test.js +0 -44
  34. package/dist/helpers/__tests__/exports.test.d.ts +0 -1
  35. package/dist/helpers/__tests__/exports.test.js +0 -42
  36. package/dist/helpers/__tests__/tokens.test.d.ts +0 -1
  37. package/dist/helpers/__tests__/tokens.test.js +0 -127
  38. package/dist/models/__tests__/exports.test.d.ts +0 -1
  39. package/dist/models/__tests__/exports.test.js +0 -15
  40. package/dist/models/__tests__/wallet.test.d.ts +0 -1
  41. package/dist/models/__tests__/wallet.test.js +0 -28
  42. package/dist/operations/__tests__/exports.test.d.ts +0 -1
  43. package/dist/operations/__tests__/exports.test.js +0 -12
  44. package/dist/operations/event/__tests__/exports.test.d.ts +0 -1
  45. package/dist/operations/event/__tests__/exports.test.js +0 -14
  46. package/dist/operations/event/__tests__/wallet.test.d.ts +0 -1
  47. package/dist/operations/event/__tests__/wallet.test.js +0 -25
  48. package/dist/operations/event/history.js +0 -19
  49. package/dist/operations/event/index.d.ts +0 -5
  50. package/dist/operations/event/index.js +0 -5
  51. package/dist/operations/event/wallet.d.ts +0 -4
  52. package/dist/operations/event/wallet.js +0 -14
  53. package/dist/operations/tag/__tests__/exports.test.d.ts +0 -1
  54. package/dist/operations/tag/__tests__/exports.test.js +0 -18
  55. package/dist/operations/tag/__tests__/wallet.test.d.ts +0 -1
  56. package/dist/operations/tag/__tests__/wallet.test.js +0 -16
  57. package/dist/operations/tag/history.d.ts +0 -14
  58. package/dist/operations/tag/history.js +0 -34
  59. package/dist/operations/tag/index.d.ts +0 -2
  60. package/dist/operations/tag/index.js +0 -2
  61. package/dist/operations/tag/wallet.d.ts +0 -5
  62. package/dist/operations/tag/wallet.js +0 -15
  63. package/dist/queries/__tests__/exports.test.d.ts +0 -1
  64. package/dist/queries/__tests__/exports.test.js +0 -15
  65. package/dist/queries/__tests__/wallet.test.d.ts +0 -1
  66. package/dist/queries/__tests__/wallet.test.js +0 -30
  67. package/dist/queries/history.d.ts +0 -6
  68. package/dist/queries/history.js +0 -21
  69. package/dist/queries/index.d.ts +0 -3
  70. package/dist/queries/index.js +0 -3
  71. package/dist/queries/tokens.d.ts +0 -6
  72. package/dist/queries/tokens.js +0 -58
  73. package/dist/queries/wallet.d.ts +0 -13
  74. package/dist/queries/wallet.js +0 -18
  75. /package/dist/operations/{event/zap-info.d.ts → zap-info.d.ts} +0 -0
@@ -1,58 +0,0 @@
1
- import { combineLatest, filter, map, startWith } from "rxjs";
2
- import { getTokenContent, ignoreDuplicateProofs, isTokenContentLocked, WALLET_TOKEN_KIND } from "../helpers/tokens.js";
3
- /** removes deleted events from sorted array */
4
- function filterDeleted(tokens) {
5
- const deleted = new Set();
6
- return Array.from(tokens)
7
- .reverse()
8
- .filter((token) => {
9
- // skip this event if it a newer event says its deleted
10
- if (deleted.has(token.id))
11
- return false;
12
- // add ids to deleted array
13
- if (!isTokenContentLocked(token)) {
14
- const details = getTokenContent(token);
15
- for (const id of details.del)
16
- deleted.add(id);
17
- }
18
- return true;
19
- })
20
- .reverse();
21
- }
22
- /** A query that subscribes to all token events for a wallet, passing locked will filter by token locked status */
23
- export function WalletTokensQuery(pubkey, locked) {
24
- return (events) => {
25
- const updates = events.updates.pipe(filter((e) => e.kind === WALLET_TOKEN_KIND && e.pubkey === pubkey), startWith(undefined));
26
- const timeline = events.timeline({ kinds: [WALLET_TOKEN_KIND], authors: [pubkey] });
27
- return combineLatest([updates, timeline]).pipe(
28
- // filter out locked tokens
29
- map(([_, tokens]) => {
30
- if (locked === undefined)
31
- return tokens;
32
- else
33
- return tokens.filter((t) => isTokenContentLocked(t) === locked);
34
- }),
35
- // remove deleted events
36
- map(filterDeleted));
37
- };
38
- }
39
- /** A query that returns the visible balance of a wallet for each mint */
40
- export function WalletBalanceQuery(pubkey) {
41
- return (events) => {
42
- const updates = events.updates.pipe(filter((e) => e.kind === WALLET_TOKEN_KIND && e.pubkey === pubkey), startWith(undefined));
43
- const timeline = events.timeline({ kinds: [WALLET_TOKEN_KIND], authors: [pubkey] });
44
- return combineLatest([updates, timeline]).pipe(map(([_, tokens]) => tokens.filter((t) => !isTokenContentLocked(t))),
45
- // filter out deleted tokens
46
- map(filterDeleted),
47
- // map tokens to totals
48
- map((tokens) => {
49
- // ignore duplicate proofs
50
- const seen = new Set();
51
- return tokens.reduce((totals, token) => {
52
- const details = getTokenContent(token);
53
- const total = details.proofs.filter(ignoreDuplicateProofs(seen)).reduce((t, p) => t + p.amount, 0);
54
- return { ...totals, [details.mint]: (totals[details.mint] ?? 0) + total };
55
- }, {});
56
- }));
57
- };
58
- }
@@ -1,13 +0,0 @@
1
- import { Query } from "applesauce-core";
2
- import { NostrEvent } from "nostr-tools";
3
- export type WalletInfo = {
4
- locked: true;
5
- event: NostrEvent;
6
- } | {
7
- locked: false;
8
- event: NostrEvent;
9
- privateKey?: Uint8Array;
10
- mints: string[];
11
- };
12
- /** A query to get the state of a NIP-60 wallet */
13
- export declare function WalletQuery(pubkey: string): Query<WalletInfo | undefined>;
@@ -1,18 +0,0 @@
1
- import { filter, map, merge } from "rxjs";
2
- import { getWalletMints, getWalletPrivateKey, isWalletLocked, WALLET_KIND } from "../helpers/wallet.js";
3
- /** A query to get the state of a NIP-60 wallet */
4
- export function WalletQuery(pubkey) {
5
- return (events) => merge(
6
- // get the latest replaceable event
7
- events.replaceable(WALLET_KIND, pubkey),
8
- // and listen for any updates to matching events
9
- events.updates.pipe(filter((e) => e.kind === WALLET_KIND && e.pubkey === pubkey))).pipe(map((wallet) => {
10
- if (!wallet)
11
- return;
12
- if (isWalletLocked(wallet))
13
- return { locked: true, event: wallet };
14
- const mints = getWalletMints(wallet);
15
- const privateKey = getWalletPrivateKey(wallet);
16
- return { locked: false, mints, privateKey, event: wallet };
17
- }));
18
- }