applesauce-wallet 0.0.0-next-20250313104750 → 0.0.0-next-20250313135311

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.
@@ -6,7 +6,7 @@ import { NostrEvent } from "nostr-tools";
6
6
  * @param token the cashu token to add
7
7
  * @param redeemed an array of nutzap event ids to mark as redeemed
8
8
  */
9
- export declare function ReceiveToken(token: Token, redeemed?: string[]): Action;
9
+ export declare function ReceiveToken(token: Token, redeemed?: string[], fee?: number): Action;
10
10
  /** An action that deletes old tokens and creates a new one but does not add a history event */
11
11
  export declare function RolloverTokens(tokens: NostrEvent[], token: Token): Action;
12
12
  /** An action that deletes old token events and adds a spend history item */
@@ -7,11 +7,11 @@ import { WalletHistoryBlueprint } from "../blueprints/history.js";
7
7
  * @param token the cashu token to add
8
8
  * @param redeemed an array of nutzap event ids to mark as redeemed
9
9
  */
10
- export function ReceiveToken(token, redeemed) {
10
+ export function ReceiveToken(token, redeemed, fee) {
11
11
  return async ({ factory, publish }) => {
12
12
  const amount = token.proofs.reduce((t, p) => t + p.amount, 0);
13
13
  const tokenEvent = await factory.sign(await factory.create(WalletTokenBlueprint, token, []));
14
- const history = await factory.sign(await factory.create(WalletHistoryBlueprint, { direction: "in", amount, mint: token.mint, created: [tokenEvent.id] }, redeemed ?? []));
14
+ const history = await factory.sign(await factory.create(WalletHistoryBlueprint, { direction: "in", amount, mint: token.mint, created: [tokenEvent.id], fee }, redeemed ?? []));
15
15
  await publish("Save tokens", tokenEvent);
16
16
  await publish("Save transaction", history);
17
17
  };
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import { getDecodedToken } from "@cashu/cashu-ts";
3
- import { lastValueFrom, take, timer } from "rxjs";
3
+ import { lastValueFrom, map, take, timer } from "rxjs";
4
4
  import { subscribeSpyTo } from "@hirez_io/observer-spy";
5
5
  import { receiveAnimated, sendAnimated } from "../animated-qr.js";
6
6
  const tokenStr = "cashuBo2FteBtodHRwczovL3Rlc3RudXQuY2FzaHUuc3BhY2VhdWNzYXRhdIGiYWlIAJofKTJT5B5hcIOkYWEQYXN4QDA2M2VlYjgwZDZjODM4NWU4NzYwODVhN2E4NzdkOTkyY2U4N2QwNTRmY2RjYzNiODMwMzhjOWY3MmNmMDY1ZGVhY1ghAynsxZ-OuZfZDcqYTLPYfCqHO7jkGjn97aolgtSYhYykYWSjYWVYIGbp_9B9aztSlZxz7g6Tqx5M_1PuFzJCVEMOVd8XAF8wYXNYINTOU77ODcj28v04pq7ektdf6sq2XuxvMjVE0wK6jFolYXJYIM_gZnUGT5jDOyZiQ-2vG9zYnuWaY8vPoWGe_3sXvrvbpGFhBGFzeEA0MWMwZDk1YTU5ZjkxNTdlYTc5NTJlNGFlMzYzYTI3NTMxNTllNmQ1NGJiNzExMTg5ZDk5YjU1MmYzYjIzZTJiYWNYIQM-49gen_1nPchxbaAiKprVr78VmMRVpHH_Tu9P8TO5mGFko2FlWCB9j7rlpdBH_m7tNYnLpzPhn-nGmS1CcbUfnPzjxy6G92FzWCDdsby7fGM5324T5UEoV858YWzZ9MCY59KgKP362fJDfmFyWCDL73v4FRo7iMe83bfMuEy3RJPtC1Vr1jdOpw2-x-7EAaRhYQFhc3hANjRhZDI3NmExOGNmNDhiMDZmYjdiMGYwOWFiMTU4ZTA0ZmM0NmIxYzA4YzMyNjJlODUxNzZkYTMzMTgyYzQ3YWFjWCECMDpCbNbrgA9FcQEIYxobU7ik_pTl8sByPqHDmkY4azxhZKNhZVggqHGaff9M270EU8LGxRpG_G4rn2bMgjyk3hFFg78ZXRVhc1ggP6DsNsWykwKE94yZF23gpCyapcoqh6DDZdVu0lKn2Z5hclggmPKig-lObsuxi_1XCm7_Y_tqaCcqEDz8eCwVhJ8gq9M";
@@ -28,7 +28,7 @@ describe("sendAnimated", () => {
28
28
  });
29
29
  describe("receiveAnimated", () => {
30
30
  it("should decode animated qr", async () => {
31
- const qr$ = sendAnimated(token, { interval: 0 }).pipe(receiveAnimated);
31
+ const qr$ = sendAnimated(token, { interval: 0 }).pipe(receiveAnimated, map((part) => (typeof part === "string" ? getDecodedToken(part) : part)));
32
32
  const spy = subscribeSpyTo(qr$);
33
33
  await lastValueFrom(qr$);
34
34
  expect(spy.getValues()).toEqual([
@@ -27,4 +27,4 @@ export type SendAnimatedOptions = {
27
27
  /** Creates an observable that iterates through a multi-part animated qr code */
28
28
  export declare function sendAnimated(token: Token | string, options?: SendAnimatedOptions): Observable<string>;
29
29
  /** Creates an observable that completes with decoded token */
30
- export declare function receiveAnimated(input: Observable<string>): Observable<Token | number>;
30
+ export declare function receiveAnimated(input: Observable<string>): Observable<string | number>;
@@ -1,4 +1,4 @@
1
- import { getDecodedToken, getEncodedTokenV4 } from "@cashu/cashu-ts";
1
+ import { getEncodedTokenV4 } from "@cashu/cashu-ts";
2
2
  import { UR, URDecoder, UREncoder } from "@gandlaf21/bc-ur/dist/lib/es6/index.js";
3
3
  import { defer, filter, interval, map, Observable, shareReplay } from "rxjs";
4
4
  /** Preset speeds for the animated qr code */
@@ -62,16 +62,9 @@ export function receiveAnimated(input) {
62
62
  // convert to lower case
63
63
  map((str) => str.toLowerCase()),
64
64
  // filter out non UR parts
65
- filter((str) => str.startsWith("ur:")),
65
+ filter((str) => str.startsWith("ur:bytes")),
66
66
  // decode UR and complete
67
67
  urDecoder(),
68
- // decode cashu token
69
- map((part) => {
70
- if (typeof part === "string")
71
- return getDecodedToken(part);
72
- else
73
- return part;
74
- }),
75
68
  // only run one decoder
76
69
  shareReplay(1));
77
70
  }
@@ -46,7 +46,7 @@ export function WalletBalanceQuery(pubkey) {
46
46
  run: (events) => {
47
47
  const updates = events.updates.pipe(filter((e) => e.kind === WALLET_TOKEN_KIND && e.pubkey === pubkey), startWith(undefined));
48
48
  const timeline = events.timeline({ kinds: [WALLET_TOKEN_KIND], authors: [pubkey] });
49
- return combineLatest([updates, timeline]).pipe(map(([_, tokens]) => tokens),
49
+ return combineLatest([updates, timeline]).pipe(map(([_, tokens]) => tokens.filter((t) => !isTokenContentLocked(t))),
50
50
  // filter out deleted tokens
51
51
  map(filterDeleted),
52
52
  // map tokens to totals
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-wallet",
3
- "version": "0.0.0-next-20250313104750",
3
+ "version": "0.0.0-next-20250313135311",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -80,9 +80,9 @@
80
80
  "@cashu/cashu-ts": "2.0.0-rc1",
81
81
  "@gandlaf21/bc-ur": "^1.1.12",
82
82
  "@noble/hashes": "^1.7.1",
83
- "applesauce-actions": "0.0.0-next-20250313104750",
84
- "applesauce-core": "0.0.0-next-20250313104750",
85
- "applesauce-factory": "0.0.0-next-20250313104750",
83
+ "applesauce-actions": "0.0.0-next-20250313135311",
84
+ "applesauce-core": "0.0.0-next-20250313135311",
85
+ "applesauce-factory": "0.0.0-next-20250313135311",
86
86
  "buffer": "^6.0.3",
87
87
  "nostr-tools": "^2.10.4",
88
88
  "rxjs": "^7.8.1"
@@ -90,7 +90,7 @@
90
90
  "devDependencies": {
91
91
  "@hirez_io/observer-spy": "^2.2.0",
92
92
  "@types/debug": "^4.1.12",
93
- "applesauce-signers": "0.0.0-next-20250313104750",
93
+ "applesauce-signers": "0.0.0-next-20250313135311",
94
94
  "typescript": "^5.7.3",
95
95
  "vitest": "^3.0.5"
96
96
  },