@1sat/permission-module-ui 0.0.20 → 0.0.22

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 +1 @@
1
- {"version":3,"file":"OneSatPermissionPrompt.d.ts","sourceRoot":"","sources":["../src/OneSatPermissionPrompt.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAI5D,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAE7C,MAAM,WAAW,2BAA2B;IAC3C,mEAAmE;IACnE,OAAO,EAAE,aAAa,CAAA;IACtB,yFAAyF;IACzF,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,yFAAyF;IACzF,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,KAAK,CAAA;CACb;AAqCD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,EACtC,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAc,GACd,EAAE,2BAA2B,2CAkH7B"}
1
+ {"version":3,"file":"OneSatPermissionPrompt.d.ts","sourceRoot":"","sources":["../src/OneSatPermissionPrompt.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAK5D,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;AAE7C,MAAM,WAAW,2BAA2B;IAC3C,mEAAmE;IACnE,OAAO,EAAE,aAAa,CAAA;IACtB,yFAAyF;IACzF,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB,yFAAyF;IACzF,QAAQ,EAAE,MAAM,IAAI,CAAA;IACpB,2EAA2E;IAC3E,KAAK,CAAC,EAAE,KAAK,CAAA;CACb;AAqCD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,EACtC,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAc,GACd,EAAE,2BAA2B,2CAkH7B"}
package/dist/index.js CHANGED
@@ -1,5 +1,36 @@
1
1
  "use client";
2
2
 
3
+ // ../types/dist/constants.js
4
+ var ORDINALS_BASKET = "p 1sat ordinals";
5
+ var BSV21_BASKET = "p 1sat bsv21";
6
+ var LOCK_BASKET = "p 1sat lock";
7
+ var EXCHANGE_RATE_CACHE_TTL = 5 * 60 * 1000;
8
+
9
+ // ../types/dist/index.js
10
+ var TokenType;
11
+ (function(TokenType2) {
12
+ TokenType2["BSV20"] = "bsv20";
13
+ TokenType2["BSV21"] = "bsv21";
14
+ })(TokenType || (TokenType = {}));
15
+ var TokenSelectionStrategy;
16
+ (function(TokenSelectionStrategy2) {
17
+ TokenSelectionStrategy2["SmallestFirst"] = "smallest";
18
+ TokenSelectionStrategy2["LargestFirst"] = "largest";
19
+ TokenSelectionStrategy2["RetainOrder"] = "retain";
20
+ TokenSelectionStrategy2["Random"] = "random";
21
+ })(TokenSelectionStrategy || (TokenSelectionStrategy = {}));
22
+ var TokenInputMode;
23
+ (function(TokenInputMode2) {
24
+ TokenInputMode2["All"] = "all";
25
+ TokenInputMode2["Needed"] = "needed";
26
+ })(TokenInputMode || (TokenInputMode = {}));
27
+ var RoytaltyType;
28
+ (function(RoytaltyType2) {
29
+ RoytaltyType2["Paymail"] = "paymail";
30
+ RoytaltyType2["Address"] = "address";
31
+ RoytaltyType2["Script"] = "script";
32
+ })(RoytaltyType || (RoytaltyType = {}));
33
+
3
34
  // src/OneSatPermissionPrompt.tsx
4
35
  import { useEffect, useState } from "react";
5
36
 
@@ -537,7 +568,7 @@ function summarizeTokenTransfer(req, intent) {
537
568
  totals.set(tokenId, cur);
538
569
  }
539
570
  for (const output of intent.outputs) {
540
- if (output.basket !== "bsv21")
571
+ if (output.basket !== BSV21_BASKET)
541
572
  continue;
542
573
  const tokenId = tagValue(output.tags, "bsv21");
543
574
  if (!tokenId)
@@ -556,7 +587,7 @@ function summarizeTokenTransfer(req, intent) {
556
587
  const sent = info.inAmt - info.changeAmt;
557
588
  rows.push({ key: "Amount", value: sent.toString() });
558
589
  }
559
- const recipient = intent.outputs.find((o) => o.recipient && o.basket !== "bsv21")?.recipient;
590
+ const recipient = intent.outputs.find((o) => o.recipient && o.basket !== BSV21_BASKET)?.recipient;
560
591
  if (recipient)
561
592
  rows.push({ key: "Recipient", value: shortenValue(recipient) });
562
593
  return {
@@ -567,7 +598,7 @@ function summarizeTokenTransfer(req, intent) {
567
598
  };
568
599
  }
569
600
  function summarizeLock(req, intent) {
570
- const lockOutputs = intent.outputs.filter((o) => o.basket === "lock");
601
+ const lockOutputs = intent.outputs.filter((o) => o.basket === LOCK_BASKET);
571
602
  const sats = (lockOutputs.length > 0 ? lockOutputs : intent.outputs).reduce((s, o) => s + o.satoshis, 0);
572
603
  const until = (lockOutputs.length > 0 ? lockOutputs : intent.outputs).flatMap((o) => o.tags).find((t) => t.startsWith("until:"))?.slice("until:".length);
573
604
  const rows = [{ key: "Amount", value: `${sats} sats` }];
@@ -664,8 +695,8 @@ function summarizeCancelListing(req, intent) {
664
695
  };
665
696
  }
666
697
  function summarizePurchase(req, intent) {
667
- const incoming = intent.outputs.find((o) => o.basket === "1sat" || o.basket === "bsv21");
668
- const isToken = incoming?.basket === "bsv21";
698
+ const incoming = intent.outputs.find((o) => o.basket === ORDINALS_BASKET || o.basket === BSV21_BASKET);
699
+ const isToken = incoming?.basket === BSV21_BASKET;
669
700
  const origin = tagValue(incoming?.tags, "origin");
670
701
  const name = tagValue(incoming?.tags, "name");
671
702
  const contentType = tagValue(incoming?.tags, "type");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1sat/permission-module-ui",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "description": "React component for the 1Sat permission module's prompt UX",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,7 +28,8 @@
28
28
  ],
29
29
  "license": "MIT",
30
30
  "dependencies": {
31
- "@1sat/permission-module": "0.0.23"
31
+ "@1sat/permission-module": "0.0.25",
32
+ "@1sat/types": "0.0.30"
32
33
  },
33
34
  "peerDependencies": {
34
35
  "react": "^18.0.0 || ^19.0.0"