applesauce-wallet 0.0.0-next-20250310173615 → 0.0.0-next-20250310200358

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.
@@ -0,0 +1 @@
1
+ export * from "./wallet.js";
@@ -0,0 +1 @@
1
+ export * from "./wallet.js";
@@ -0,0 +1,3 @@
1
+ import { EventBlueprint } from "applesauce-factory";
2
+ /** A blueprint to create a new 17375 wallet */
3
+ export declare function WalletBlueprint(privateKey: Uint8Array, mints: string[]): EventBlueprint;
@@ -0,0 +1,8 @@
1
+ import { EventFactory } from "applesauce-factory";
2
+ import { WALLET_KIND } from "../helpers/wallet.js";
3
+ import { modifyHiddenTags } from "applesauce-factory/operations/event";
4
+ import { setMintTags, setPrivateKeyTag } from "../operations/index.js";
5
+ /** A blueprint to create a new 17375 wallet */
6
+ export function WalletBlueprint(privateKey, mints) {
7
+ return (ctx) => EventFactory.runProcess({ kind: WALLET_KIND }, ctx, modifyHiddenTags(setPrivateKeyTag(privateKey), setMintTags(mints)));
8
+ }
@@ -8,6 +8,10 @@ export type HistoryDetails = {
8
8
  amount: number;
9
9
  /** An array of token event ids created */
10
10
  created: string[];
11
+ /** The mint that was spent from */
12
+ mint?: string;
13
+ /** The fee paid */
14
+ fee?: number;
11
15
  };
12
16
  export declare const HistoryDetailsSymbol: unique symbol;
13
17
  /** returns an array of redeemed event ids in a history event */
@@ -24,8 +24,11 @@ export function getHistoryDetails(history) {
24
24
  const amount = parseInt(amountStr);
25
25
  if (!Number.isFinite(amount))
26
26
  throw new Error("Failed to parse amount");
27
+ const mint = tags.find((t) => t[0] === "mint")?.[1];
28
+ const feeStr = tags.find((t) => t[0] === "fee")?.[1];
29
+ const fee = feeStr ? parseInt(feeStr) : undefined;
27
30
  const created = tags.filter((t) => isETag(t) && t[3] === "created").map((t) => t[1]);
28
- return { direction, amount, created };
31
+ return { direction, amount, created, mint, fee };
29
32
  });
30
33
  }
31
34
  /** Decrypts a wallet history event */
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as Queries from "./queries/index.js";
2
2
  export * as Helpers from "./helpers/index.js";
3
+ export * as Blueprints from "./blueprints/index.js";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * as Queries from "./queries/index.js";
2
2
  export * as Helpers from "./helpers/index.js";
3
+ export * as Blueprints from "./blueprints/index.js";
@@ -0,0 +1 @@
1
+ export * from "./tags/index.js";
@@ -0,0 +1 @@
1
+ export * from "./tags/index.js";
@@ -0,0 +1 @@
1
+ export * from "./wallet.js";
@@ -0,0 +1 @@
1
+ export * from "./wallet.js";
@@ -0,0 +1,5 @@
1
+ import { TagOperation } from "applesauce-factory";
2
+ /** Sets the "mint" tags in a wallet event */
3
+ export declare function setMintTags(mints: string[]): TagOperation;
4
+ /** Sets the "privkey" tag on a wallet event */
5
+ export declare function setPrivateKeyTag(privateKey: Uint8Array): TagOperation;
@@ -0,0 +1,14 @@
1
+ import { bytesToHex } from "@noble/hashes/utils";
2
+ import { ensureSingletonTag } from "applesauce-factory/helpers";
3
+ /** Sets the "mint" tags in a wallet event */
4
+ export function setMintTags(mints) {
5
+ return (tags) => tags
6
+ // remove all existing mint tags
7
+ .filter((t) => t[0] !== "mint")
8
+ // add new mint tags
9
+ .concat(...mints.map((mint) => ["mint", mint]));
10
+ }
11
+ /** Sets the "privkey" tag on a wallet event */
12
+ export function setPrivateKeyTag(privateKey) {
13
+ return (tags) => ensureSingletonTag(tags, ["privkey", bytesToHex(privateKey)], true);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "applesauce-wallet",
3
- "version": "0.0.0-next-20250310173615",
3
+ "version": "0.0.0-next-20250310200358",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -39,10 +39,22 @@
39
39
  "import": "./dist/queries/*.js",
40
40
  "require": "./dist/queries/*.js",
41
41
  "types": "./dist/queries/*.d.ts"
42
+ },
43
+ "./blueprints": {
44
+ "import": "./dist/blueprints/index.js",
45
+ "require": "./dist/blueprints/index.js",
46
+ "types": "./dist/blueprints/index.d.ts"
47
+ },
48
+ "./blueprints/*": {
49
+ "import": "./dist/blueprints/*.js",
50
+ "require": "./dist/blueprints/*.js",
51
+ "types": "./dist/blueprints/*.d.ts"
42
52
  }
43
53
  },
44
54
  "dependencies": {
45
- "applesauce-core": "0.0.0-next-20250310173615",
55
+ "@noble/hashes": "^1.7.1",
56
+ "applesauce-core": "0.0.0-next-20250310200358",
57
+ "applesauce-factory": "0.0.0-next-20250310200358",
46
58
  "nostr-tools": "^2.10.4",
47
59
  "rxjs": "^7.8.1"
48
60
  },