applesauce-wallet 0.0.0-next-20250312162115 → 0.0.0-next-20250312195837
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.
package/dist/actions/tokens.d.ts
CHANGED
|
@@ -7,5 +7,7 @@ import { NostrEvent } from "nostr-tools";
|
|
|
7
7
|
* @param redeemed an array of nutzap event ids to mark as redeemed
|
|
8
8
|
*/
|
|
9
9
|
export declare function ReceiveToken(token: Token, redeemed?: string[]): Action;
|
|
10
|
+
/** An action that deletes old tokens and creates a new one but does not add a history event */
|
|
11
|
+
export declare function RolloverTokens(tokens: NostrEvent[], token: Token): Action;
|
|
10
12
|
/** An action that deletes old token events and adds a spend history item */
|
|
11
13
|
export declare function CompleteSpend(spent: NostrEvent[], change: Token): Action;
|
package/dist/actions/tokens.js
CHANGED
|
@@ -16,6 +16,21 @@ export function ReceiveToken(token, redeemed) {
|
|
|
16
16
|
await publish("Save transaction", history);
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
+
/** An action that deletes old tokens and creates a new one but does not add a history event */
|
|
20
|
+
export function RolloverTokens(tokens, token) {
|
|
21
|
+
return async ({ factory, publish }) => {
|
|
22
|
+
// create a delete event for old tokens
|
|
23
|
+
const deleteDraft = await factory.create(DeleteBlueprint, tokens);
|
|
24
|
+
// create a new token event
|
|
25
|
+
const tokenDraft = await factory.create(WalletTokenBlueprint, token, tokens.map((e) => e.id));
|
|
26
|
+
// sign events
|
|
27
|
+
const signedDelete = await factory.sign(deleteDraft);
|
|
28
|
+
const signedToken = await factory.sign(tokenDraft);
|
|
29
|
+
// publish events
|
|
30
|
+
await publish("Delete old tokens", signedDelete);
|
|
31
|
+
await publish("Save new token", signedToken);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
19
34
|
/** An action that deletes old token events and adds a spend history item */
|
|
20
35
|
export function CompleteSpend(spent, change) {
|
|
21
36
|
return async ({ factory, publish }) => {
|
|
@@ -3,6 +3,7 @@ import { EventFactory } from "applesauce-factory";
|
|
|
3
3
|
import { FakeUser } from "../../__tests__/fake-user.js";
|
|
4
4
|
import { WalletTokenBlueprint } from "../../blueprints/tokens.js";
|
|
5
5
|
import { dumbTokenSelection, unlockTokenContent } from "../tokens.js";
|
|
6
|
+
import { HiddenContentSymbol } from "applesauce-core/helpers";
|
|
6
7
|
const user = new FakeUser();
|
|
7
8
|
const factory = new EventFactory({ signer: user });
|
|
8
9
|
describe("dumbTokenSelection", () => {
|
|
@@ -49,6 +50,8 @@ describe("dumbTokenSelection", () => {
|
|
|
49
50
|
mint: "https://money.com",
|
|
50
51
|
proofs: [{ secret: "A", C: "A", id: "A", amount: 100 }],
|
|
51
52
|
}));
|
|
53
|
+
// manually remove the hidden content to lock it again
|
|
54
|
+
Reflect.deleteProperty(a, HiddenContentSymbol);
|
|
52
55
|
expect(() => dumbTokenSelection([a], 20)).toThrow();
|
|
53
56
|
});
|
|
54
57
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "applesauce-wallet",
|
|
3
|
-
"version": "0.0.0-next-
|
|
3
|
+
"version": "0.0.0-next-20250312195837",
|
|
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-
|
|
83
|
-
"applesauce-core": "0.0.0-next-
|
|
84
|
-
"applesauce-factory": "0.0.0-next-
|
|
82
|
+
"applesauce-actions": "0.0.0-next-20250312195837",
|
|
83
|
+
"applesauce-core": "0.0.0-next-20250312195837",
|
|
84
|
+
"applesauce-factory": "0.0.0-next-20250312195837",
|
|
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-
|
|
91
|
+
"applesauce-signers": "0.0.0-next-20250312195837",
|
|
92
92
|
"typescript": "^5.7.3",
|
|
93
93
|
"vitest": "^3.0.5"
|
|
94
94
|
},
|