@bananapus/nana-sdk-core 2.39.0 → 2.41.0

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 (77) hide show
  1. package/dist/cjs/review/heldWrite.d.ts.map +1 -1
  2. package/dist/cjs/review/heldWrite.js +80 -46
  3. package/dist/cjs/review/heldWrite.js.map +1 -1
  4. package/dist/cjs/review/intents.d.ts +45 -0
  5. package/dist/cjs/review/intents.d.ts.map +1 -1
  6. package/dist/cjs/review/intents.js +57 -0
  7. package/dist/cjs/review/intents.js.map +1 -1
  8. package/dist/cjs/review/react/HeldWritesNotice.d.ts +11 -0
  9. package/dist/cjs/review/react/HeldWritesNotice.d.ts.map +1 -0
  10. package/dist/cjs/review/react/HeldWritesNotice.js +22 -0
  11. package/dist/cjs/review/react/HeldWritesNotice.js.map +1 -0
  12. package/dist/cjs/review/react/heldView.d.ts +25 -0
  13. package/dist/cjs/review/react/heldView.d.ts.map +1 -0
  14. package/dist/cjs/review/react/heldView.js +29 -0
  15. package/dist/cjs/review/react/heldView.js.map +1 -0
  16. package/dist/cjs/review/react/index.d.ts +6 -0
  17. package/dist/cjs/review/react/index.d.ts.map +1 -0
  18. package/dist/cjs/review/react/index.js +22 -0
  19. package/dist/cjs/review/react/index.js.map +1 -0
  20. package/dist/cjs/review/react/useHeldSend.d.ts +30 -0
  21. package/dist/cjs/review/react/useHeldSend.d.ts.map +1 -0
  22. package/dist/cjs/review/react/useHeldSend.js +80 -0
  23. package/dist/cjs/review/react/useHeldSend.js.map +1 -0
  24. package/dist/cjs/review/react/useHeldWrite.d.ts +51 -0
  25. package/dist/cjs/review/react/useHeldWrite.d.ts.map +1 -0
  26. package/dist/cjs/review/react/useHeldWrite.js +94 -0
  27. package/dist/cjs/review/react/useHeldWrite.js.map +1 -0
  28. package/dist/cjs/review/react/useHeldWrites.d.ts +40 -0
  29. package/dist/cjs/review/react/useHeldWrites.d.ts.map +1 -0
  30. package/dist/cjs/review/react/useHeldWrites.js +95 -0
  31. package/dist/cjs/review/react/useHeldWrites.js.map +1 -0
  32. package/dist/cjs/review/react/useSavedAttempt.d.ts +54 -0
  33. package/dist/cjs/review/react/useSavedAttempt.d.ts.map +1 -0
  34. package/dist/cjs/review/react/useSavedAttempt.js +105 -0
  35. package/dist/cjs/review/react/useSavedAttempt.js.map +1 -0
  36. package/dist/cjs/review/writeRecovery.d.ts.map +1 -1
  37. package/dist/cjs/review/writeRecovery.js +3 -1
  38. package/dist/cjs/review/writeRecovery.js.map +1 -1
  39. package/dist/esm/review/heldWrite.d.ts.map +1 -1
  40. package/dist/esm/review/heldWrite.js +80 -46
  41. package/dist/esm/review/heldWrite.js.map +1 -1
  42. package/dist/esm/review/intents.d.ts +45 -0
  43. package/dist/esm/review/intents.d.ts.map +1 -1
  44. package/dist/esm/review/intents.js +52 -0
  45. package/dist/esm/review/intents.js.map +1 -1
  46. package/dist/esm/review/react/HeldWritesNotice.d.ts +11 -0
  47. package/dist/esm/review/react/HeldWritesNotice.d.ts.map +1 -0
  48. package/dist/esm/review/react/HeldWritesNotice.js +19 -0
  49. package/dist/esm/review/react/HeldWritesNotice.js.map +1 -0
  50. package/dist/esm/review/react/heldView.d.ts +25 -0
  51. package/dist/esm/review/react/heldView.d.ts.map +1 -0
  52. package/dist/esm/review/react/heldView.js +22 -0
  53. package/dist/esm/review/react/heldView.js.map +1 -0
  54. package/dist/esm/review/react/index.d.ts +6 -0
  55. package/dist/esm/review/react/index.d.ts.map +1 -0
  56. package/dist/esm/review/react/index.js +6 -0
  57. package/dist/esm/review/react/index.js.map +1 -0
  58. package/dist/esm/review/react/useHeldSend.d.ts +30 -0
  59. package/dist/esm/review/react/useHeldSend.d.ts.map +1 -0
  60. package/dist/esm/review/react/useHeldSend.js +77 -0
  61. package/dist/esm/review/react/useHeldSend.js.map +1 -0
  62. package/dist/esm/review/react/useHeldWrite.d.ts +51 -0
  63. package/dist/esm/review/react/useHeldWrite.d.ts.map +1 -0
  64. package/dist/esm/review/react/useHeldWrite.js +91 -0
  65. package/dist/esm/review/react/useHeldWrite.js.map +1 -0
  66. package/dist/esm/review/react/useHeldWrites.d.ts +40 -0
  67. package/dist/esm/review/react/useHeldWrites.d.ts.map +1 -0
  68. package/dist/esm/review/react/useHeldWrites.js +91 -0
  69. package/dist/esm/review/react/useHeldWrites.js.map +1 -0
  70. package/dist/esm/review/react/useSavedAttempt.d.ts +54 -0
  71. package/dist/esm/review/react/useSavedAttempt.d.ts.map +1 -0
  72. package/dist/esm/review/react/useSavedAttempt.js +102 -0
  73. package/dist/esm/review/react/useSavedAttempt.js.map +1 -0
  74. package/dist/esm/review/writeRecovery.d.ts.map +1 -1
  75. package/dist/esm/review/writeRecovery.js +3 -1
  76. package/dist/esm/review/writeRecovery.js.map +1 -1
  77. package/package.json +16 -2
@@ -97,4 +97,56 @@ export function liquidityIntent({ chainId, pool, positions, }) {
97
97
  positions: canonicalIds(positions),
98
98
  });
99
99
  }
100
+ /** Redeeming shop items: the collection, the token id set and the holder. No terminal, payout token or minimum. */
101
+ export function redeemIntent({ chainId, project, hook, tokenIds, holder, }) {
102
+ return writeIntentKey("redeem-items", {
103
+ chainId,
104
+ project: id(project),
105
+ hook: intent.address(hook),
106
+ tokenIds: canonicalIds(tokenIds),
107
+ holder: intent.address(holder),
108
+ });
109
+ }
110
+ /** Paying out from a project's surplus allowance: the allowance line and beneficiary. No amount or minimum. */
111
+ export function allowanceIntent({ chainId, project, terminal, token, currency, beneficiary, }) {
112
+ return writeIntentKey("use-allowance", {
113
+ chainId,
114
+ project: id(project),
115
+ terminal: intent.address(terminal),
116
+ token: intent.address(token),
117
+ currency: id(currency),
118
+ beneficiary: intent.address(beneficiary),
119
+ });
120
+ }
121
+ /** Burning a holder's project tokens. No amount. */
122
+ export function burnIntent({ chainId, project, holder, }) {
123
+ return writeIntentKey("burn", {
124
+ chainId,
125
+ project: id(project),
126
+ holder: intent.address(holder),
127
+ });
128
+ }
129
+ /**
130
+ * Proposing one batch to a Safe: the Safe and its exact calls, in order. A
131
+ * generic batch has no coarser identity, so its calls are the user's choice.
132
+ */
133
+ export function safeBatchIntent({ chainId, safe, calls, }) {
134
+ return writeIntentKey("safe-batch", {
135
+ chainId,
136
+ safe: intent.address(safe),
137
+ calls: calls.map((call) => ({
138
+ to: intent.address(call.to),
139
+ data: intent.hex(call.data),
140
+ value: id(call.value ?? 0n),
141
+ })),
142
+ });
143
+ }
144
+ /** Syncing a bridge's accounting through one sucker. No fee. */
145
+ export function syncIntent({ chainId, sucker, account, }) {
146
+ return writeIntentKey("bridge-sync", {
147
+ chainId,
148
+ sucker: intent.address(sucker),
149
+ account: intent.address(account),
150
+ });
151
+ }
100
152
  //# sourceMappingURL=intents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"intents.js","sourceRoot":"","sources":["../../../src/review/intents.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,MAAM,EAAE,cAAc,EAAoB,MAAM,kBAAkB,CAAC;AAI5E;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,KAAkB;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAC3B,OAAO,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC3D,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC;QACxD,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC;YAC3C,IAAI;YACJ,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc,CAAC,KA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E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;KAC/B,CAAC,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAC9B,OAAO,EACP,IAAI,EACJ,KAAK,GASN;IACC,OAAO,cAAc,CAAC,YAAY,EAAE;QAClC,OAAO;QACP,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAC1B,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1B,EAAE,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;YAC3B,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;SAC5B,CAAC,CAAC;KACJ,CAAC,CAAC;AACL,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,UAAU,CAAC,EACzB,OAAO,EACP,MAAM,EACN,OAAO,GAKR;IACC,OAAO,cAAc,CAAC,aAAa,EAAE;QACnC,OAAO;QACP,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;KACjC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { HeldWriteItem } from "./useHeldWrites.js";
2
+ /**
3
+ * The one app-wide notice of held writes: each with its action's label, its
4
+ * line, any warning, and the release when its hold offers the exit. Feed it
5
+ * useHeldWrites, useHeldIntents, or both. Unstyled: `className` is the hook.
6
+ */
7
+ export declare function HeldWritesNotice({ items, className, }: {
8
+ items: readonly HeldWriteItem[];
9
+ className?: string;
10
+ }): import("react").JSX.Element | null;
11
+ //# sourceMappingURL=HeldWritesNotice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeldWritesNotice.d.ts","sourceRoot":"","sources":["../../../../src/review/react/HeldWritesNotice.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,SAAS,GACV,EAAE;IACD,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,sCA4BA"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { HELD_RELEASE_LABEL } from "../index.js";
3
+ import { useState } from "react";
4
+ /**
5
+ * The one app-wide notice of held writes: each with its action's label, its
6
+ * line, any warning, and the release when its hold offers the exit. Feed it
7
+ * useHeldWrites, useHeldIntents, or both. Unstyled: `className` is the hook.
8
+ */
9
+ export function HeldWritesNotice({ items, className, }) {
10
+ const [busy, setBusy] = useState(null);
11
+ const shown = items.filter(({ view }) => view.line);
12
+ if (!shown.length)
13
+ return null;
14
+ return (_jsx("div", { role: "status", className: className, children: shown.map(({ key, label, view, release }) => (_jsxs("div", { "data-phase": view.phase, children: [label ? _jsx("p", { children: label }) : null, _jsx("p", { children: view.line }), view.warning ? _jsx("p", { children: view.warning }) : null, view.notice ? _jsx("p", { children: view.notice }) : null, view.exit ? (_jsx("button", { type: "button", disabled: busy === key, onClick: () => {
15
+ setBusy(key);
16
+ void release().finally(() => setBusy(null));
17
+ }, children: HELD_RELEASE_LABEL })) : null] }, key))) }));
18
+ }
19
+ //# sourceMappingURL=HeldWritesNotice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeldWritesNotice.js","sourceRoot":"","sources":["../../../../src/review/react/HeldWritesNotice.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAGjC;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAA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{ type HeldWriteView, type HeldWriteViewController } from "../index.js";
2
+ /** The actions a shown held-write view offers, the one way both hooks show them. */
3
+ export type HeldViewActions = {
4
+ /** The exit the hold offers now, with its label; null when none. */
5
+ exitAction: {
6
+ label: string;
7
+ run: () => Promise<boolean>;
8
+ } | null;
9
+ /**
10
+ * On a success settled while away ("This went through while you were
11
+ * away."): the user's choice to send it again. Null otherwise.
12
+ */
13
+ sendAgainAction: {
14
+ label: string;
15
+ run: () => Promise<void>;
16
+ } | null;
17
+ };
18
+ export declare const IDLE: HeldWriteView;
19
+ export declare const none: () => () => void;
20
+ export declare const idle: () => HeldWriteView;
21
+ /** A value's identity for a memo key, wei amounts (bigints) included. */
22
+ export declare const keyOf: (value: unknown) => string;
23
+ /** The exit and send-again actions of what `view` shows. */
24
+ export declare function actionsOf(shown: HeldWriteView, view: HeldWriteViewController | undefined): HeldViewActions;
25
+ //# sourceMappingURL=heldView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heldView.d.ts","sourceRoot":"","sources":["../../../../src/review/react/heldView.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC7B,MAAM,aAAa,CAAC;AAErB,oFAAoF;AACpF,MAAM,MAAM,eAAe,GAAG;IAC5B,oEAAoE;IACpE,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;IAClE;;;OAGG;IACH,eAAe,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;KAAE,GAAG,IAAI,CAAC;CACrE,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,aAMlB,CAAC;AACF,eAAO,MAAM,IAAI,kBAAiB,CAAC;AACnC,eAAO,MAAM,IAAI,qBAAa,CAAC;AAC/B,yEAAyE;AACzE,eAAO,MAAM,KAAK,GAAI,OAAO,OAAO,WAGjC,CAAC;AAEJ,4DAA4D;AAC5D,wBAAgB,SAAS,CACvB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,uBAAuB,GAAG,SAAS,GACxC,eAAe,CASjB"}
@@ -0,0 +1,22 @@
1
+ import { HELD_EXIT_LABEL, HELD_SEND_AGAIN_LABEL, } from "../index.js";
2
+ export const IDLE = {
3
+ phase: "clear",
4
+ state: null,
5
+ line: null,
6
+ exit: false,
7
+ adopting: false,
8
+ };
9
+ export const none = () => () => { };
10
+ export const idle = () => IDLE;
11
+ /** A value's identity for a memo key, wei amounts (bigints) included. */
12
+ export const keyOf = (value) => JSON.stringify(value, (_, field) => typeof field === "bigint" ? `${field}n` : field);
13
+ /** The exit and send-again actions of what `view` shows. */
14
+ export function actionsOf(shown, view) {
15
+ return {
16
+ exitAction: shown.exit && view ? { label: HELD_EXIT_LABEL, run: view.exit } : null,
17
+ sendAgainAction: shown.phase === "succeeded" && view
18
+ ? { label: HELD_SEND_AGAIN_LABEL, run: view.acknowledge }
19
+ : null,
20
+ };
21
+ }
22
+ //# sourceMappingURL=heldView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"heldView.js","sourceRoot":"","sources":["../../../../src/review/react/heldView.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,qBAAqB,GAGtB,MAAM,aAAa,CAAC;AAarB,MAAM,CAAC,MAAM,IAAI,GAAkB;IACjC,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,KAAK;IACX,QAAQ,EAAE,KAAK;CAChB,CAAC;AACF,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC;AACnC,MAAM,CAAC,MAAM,IAAI,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;AAC/B,yEAAyE;AACzE,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,KAAc,EAAE,EAAE,CACtC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CACjC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,CAAC,KAAK,CAChD,CAAC;AAEJ,4DAA4D;AAC5D,MAAM,UAAU,SAAS,CACvB,KAAoB,EACpB,IAAyC;IAEzC,OAAO;QACL,UAAU,EACR,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI;QACxE,eAAe,EACb,KAAK,CAAC,KAAK,KAAK,WAAW,IAAI,IAAI;YACjC,CAAC,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE;YACzD,CAAC,CAAC,IAAI;KACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./HeldWritesNotice.js";
2
+ export * from "./useHeldWrite.js";
3
+ export * from "./useHeldWrites.js";
4
+ export * from "./useSavedAttempt.js";
5
+ export * from "./useHeldSend.js";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/review/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from "./HeldWritesNotice.js";
2
+ export * from "./useHeldWrite.js";
3
+ export * from "./useHeldWrites.js";
4
+ export * from "./useSavedAttempt.js";
5
+ export * from "./useHeldSend.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/review/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type HeldWriteView, type WriteHoldGate, type WriteHoldHandle } from "../index.js";
2
+ import type { Hex } from "viem";
3
+ import { type HeldViewActions } from "./heldView.js";
4
+ import type { UseHeldWriteOptions } from "./useHeldWrite.js";
5
+ /** One send's hold: what useHeldWrite takes up front, known only at send time. */
6
+ export type HeldSendInput = Pick<UseHeldWriteOptions, "chainId" | "account" | "safe" | "namespace" | "legacy"> & {
7
+ /** The reviewed call this send sends. */
8
+ call: NonNullable<UseHeldWriteOptions["call"]>;
9
+ };
10
+ export type UseHeldSendOptions = Pick<UseHeldWriteOptions, "hold" | "client" | "pollMs" | "onSettled" | "onReleased"> & {
11
+ /** False when the app follows the transaction or proposal itself. */
12
+ follow?: boolean;
13
+ };
14
+ export type UseHeldSendResult = HeldWriteView & HeldViewActions & {
15
+ /** Send `call` under its hold: its intent's (or call's) view, made or reused, shows from now. */
16
+ send: (input: HeldSendInput, run: (gate: WriteHoldGate) => Promise<Hex>) => Promise<Hex>;
17
+ /** Ask the chain now about the current send. */
18
+ check: () => Promise<HeldWriteView>;
19
+ /** The current send's hold handle. */
20
+ handle: WriteHoldHandle | undefined;
21
+ };
22
+ /**
23
+ * Held sends whose call is known only at send time (a generic contract write
24
+ * or Safe transaction): each send runs through the held-write view of its
25
+ * intent or exact call, made once and reused, and the result shows the
26
+ * current send's line, notice and exit as {@link useHeldWrite} does. Only
27
+ * the current send's view runs and reaches the app's callbacks.
28
+ */
29
+ export declare function useHeldSend(options: UseHeldSendOptions): UseHeldSendResult;
30
+ //# sourceMappingURL=useHeldSend.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldSend.d.ts","sourceRoot":"","sources":["../../../../src/review/react/useHeldSend.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,aAAa,CAAC;AAQrB,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAChC,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,kFAAkF;AAClF,MAAM,MAAM,aAAa,GAAG,IAAI,CAC9B,mBAAmB,EACnB,SAAS,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CACxD,GAAG;IACF,yCAAyC;IACzC,IAAI,EAAE,WAAW,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,IAAI,CACnC,mBAAmB,EACnB,MAAM,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,YAAY,CAC1D,GAAG;IACF,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAC3C,eAAe,GAAG;IAChB,iGAAiG;IACjG,IAAI,EAAE,CACJ,KAAK,EAAE,aAAa,EACpB,GAAG,EAAE,CAAC,IAAI,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,CAAC,KACvC,OAAO,CAAC,GAAG,CAAC,CAAC;IAClB,gDAAgD;IAChD,KAAK,EAAE,MAAM,OAAO,CAAC,aAAa,CAAC,CAAC;IACpC,sCAAsC;IACtC,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;CACrC,CAAC;AAIJ;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,iBAAiB,CA0F1E"}
@@ -0,0 +1,77 @@
1
+ import { createHeldWriteView, } from "../index.js";
2
+ import { useEffect, useMemo, useRef, useState, useSyncExternalStore, } from "react";
3
+ import { actionsOf, IDLE, idle, keyOf, none, } from "./heldView.js";
4
+ /**
5
+ * Held sends whose call is known only at send time (a generic contract write
6
+ * or Safe transaction): each send runs through the held-write view of its
7
+ * intent or exact call, made once and reused, and the result shows the
8
+ * current send's line, notice and exit as {@link useHeldWrite} does. Only
9
+ * the current send's view runs and reaches the app's callbacks.
10
+ */
11
+ export function useHeldSend(options) {
12
+ const { hold, client, pollMs, follow } = options;
13
+ const latest = useRef(options);
14
+ latest.current = options;
15
+ /** This hold and client's views, by their send's identity. */
16
+ const views = useMemo(() => new Map(), [hold, client, pollMs, follow]);
17
+ const [current, setCurrent] = useState();
18
+ // A view of an earlier hold or client shows nothing.
19
+ const held = current?.views === views ? current.held : undefined;
20
+ const view = held?.view;
21
+ /**
22
+ * The one view running, started at its send: a replaced view is stopped
23
+ * then, so only the current send's view ever tells the app anything, and
24
+ * a success it never told stays pending for the gate.
25
+ */
26
+ const running = useRef(undefined);
27
+ useEffect(() => () => {
28
+ if (running.current?.views !== views)
29
+ return;
30
+ running.current.stop();
31
+ running.current = undefined;
32
+ }, [views]);
33
+ const shown = useSyncExternalStore(view?.subscribe ?? none, view?.get ?? idle, view?.get ?? idle);
34
+ return {
35
+ ...shown,
36
+ ...actionsOf(shown, view),
37
+ send: (input, run) => {
38
+ if (!client)
39
+ return Promise.reject(new Error("Connect a wallet and build the call before sending."));
40
+ const { chainId, account, safe = false, namespace, legacy, call } = input;
41
+ const key = keyOf([
42
+ chainId,
43
+ account.toLowerCase(),
44
+ safe,
45
+ namespace ?? null,
46
+ call,
47
+ legacy ?? null,
48
+ ]);
49
+ let next = views.get(key);
50
+ if (!next) {
51
+ const handle = hold.open({ chainId, account, safe, call, ...(namespace ? { namespace } : {}) }, legacy ? { legacy } : undefined);
52
+ const created = createHeldWriteView(handle, {
53
+ client,
54
+ pollMs,
55
+ ...(follow === undefined ? {} : { follow }),
56
+ // A stopped view tells no settlement; a late release is dropped here.
57
+ onSettled: (settled, receipt) => latest.current.onSettled?.(settled, receipt),
58
+ onReleased: (by) => {
59
+ if (running.current?.view === created)
60
+ latest.current.onReleased?.(by);
61
+ },
62
+ });
63
+ next = { handle, view: created };
64
+ views.set(key, next);
65
+ }
66
+ if (running.current?.view !== next.view) {
67
+ running.current?.stop();
68
+ running.current = { views, view: next.view, stop: next.view.start() };
69
+ }
70
+ setCurrent({ views, held: next });
71
+ return next.view.send(run);
72
+ },
73
+ check: () => (view ? view.check() : Promise.resolve(IDLE)),
74
+ handle: held?.handle,
75
+ };
76
+ }
77
+ //# sourceMappingURL=useHeldSend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldSend.js","sourceRoot":"","sources":["../../../../src/review/react/useHeldSend.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAKpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,SAAS,EACT,OAAO,EACP,MAAM,EACN,QAAQ,EACR,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAEf,OAAO,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,IAAI,GAEL,MAAM,eAAe,CAAC;AAmCvB;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAA2B;IACrD,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IACjD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,8DAA8D;IAC9D,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,IAAI,GAAG,EAAgB,EAC7B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAC/B,CAAC;IACF,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,EAGlC,CAAC;IACL,qDAAqD;IACrD,MAAM,IAAI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YACxE,CAAC;YACD,UAAU,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;YAClC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,EAAE,IAAI,EAAE,MAAM;KACrB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { type HeldWriteEvidence, type HeldWriteView, type ReviewedWriteRecoveryInput, type WriteHold, type WriteHoldClient, type WriteHoldGate, type WriteHoldHandle, type WriteHoldSettled, type WriteHoldState } from "../index.js";
2
+ import type { Address, Hex, TransactionReceipt } from "viem";
3
+ import { type HeldViewActions } from "./heldView.js";
4
+ export type UseHeldWriteOptions = {
5
+ /** The app's one write hold controller (createWriteHold()). */
6
+ hold: WriteHold;
7
+ chainId: number;
8
+ /** The account that sends: the wallet, or the Safe. */
9
+ account: Address;
10
+ /** Whether `account` is a Safe whose writes are proposals. */
11
+ safe?: boolean;
12
+ /** The action's intent key (payIntent and the other builders). */
13
+ namespace?: string;
14
+ /** Keys an earlier version held this write under. */
15
+ legacy?: Parameters<WriteHold["open"]>[1] extends infer O ? O extends {
16
+ legacy?: infer L;
17
+ } ? L : never : never;
18
+ /** The reviewed call, when built; without one, the hold is found by `namespace`. */
19
+ call?: ReviewedWriteRecoveryInput["call"];
20
+ /** Reads the account's chain. */
21
+ client: WriteHoldClient | undefined;
22
+ /** A previous deploy's saved evidence of this write: adopted before any send. */
23
+ adopt?: () => Promise<HeldWriteEvidence | null | undefined>;
24
+ onAdopted?: (state: WriteHoldState) => void;
25
+ /** The hold settled what this view saw held, on authenticated evidence: once. */
26
+ onSettled?: (settled: WriteHoldSettled, receipt: TransactionReceipt | null) => void;
27
+ /** Released: by the user's exit (reopen the review), or by another window. */
28
+ onReleased?: (by: "user" | "other-tab") => void;
29
+ /** How often a held write is asked again (15 s to 60 s, 30 s by default). */
30
+ pollMs?: number;
31
+ };
32
+ export type UseHeldWriteResult = HeldWriteView & HeldViewActions & {
33
+ /** Send under the hold, once any adoption is done. */
34
+ send: (run: (gate: WriteHoldGate) => Promise<Hex>) => Promise<Hex>;
35
+ /** Ask the chain now. */
36
+ check: () => Promise<HeldWriteView>;
37
+ /** The hold handle, for anything else. */
38
+ handle: WriteHoldHandle | undefined;
39
+ };
40
+ /**
41
+ * One held write, the one way every app runs it: its send under the hold,
42
+ * the watch, the shared follower of its transaction or Safe proposal, its
43
+ * one line, its exit and the adoption of a previous deploy's record.
44
+ *
45
+ * The exit ("I checked my wallet") only releases the hold: `onReleased("user")`
46
+ * is where the app reopens its review, so a resend always shows the values it
47
+ * sends. A release by another window is neutral (`releasedBy: "other-tab"`),
48
+ * and `onSettled` fires only for a settlement of what this view saw held.
49
+ */
50
+ export declare function useHeldWrite(options: UseHeldWriteOptions): UseHeldWriteResult;
51
+ //# sourceMappingURL=useHeldWrite.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldWrite.d.ts","sourceRoot":"","sources":["../../../../src/review/react/useHeldWrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAElB,KAAK,0BAA0B,EAC/B,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,EAML,KAAK,eAAe,EACrB,MAAM,eAAe,CAAC;AAQvB,MAAM,MAAM,mBAAmB,GAAG;IAChC,+DAA+D;IAC/D,IAAI,EAAE,SAAS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AAa,CAAC,CAAC;IACpC,0CAA0C;IAC1C,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;CACrC,CAAC;AAEJ;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,kBAAkB,CA2F7E"}
@@ -0,0 +1,91 @@
1
+ import { createHeldWriteView, } from "../index.js";
2
+ import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
3
+ import { actionsOf, IDLE, idle, keyOf, none, } from "./heldView.js";
4
+ /** A call stand-in for a hold found by its intent alone, before any call is built. */
5
+ const NO_CALL = {
6
+ to: "0x0000000000000000000000000000000000000000",
7
+ data: "0x",
8
+ };
9
+ /**
10
+ * One held write, the one way every app runs it: its send under the hold,
11
+ * the watch, the shared follower of its transaction or Safe proposal, its
12
+ * one line, its exit and the adoption of a previous deploy's record.
13
+ *
14
+ * The exit ("I checked my wallet") only releases the hold: `onReleased("user")`
15
+ * is where the app reopens its review, so a resend always shows the values it
16
+ * sends. A release by another window is neutral (`releasedBy: "other-tab"`),
17
+ * and `onSettled` fires only for a settlement of what this view saw held.
18
+ */
19
+ export function useHeldWrite(options) {
20
+ const { hold, chainId, account, safe = false, namespace, client, pollMs, } = options;
21
+ const callKey = keyOf(options.call ?? null);
22
+ const legacyKey = keyOf(options.legacy ?? null);
23
+ const latest = useRef(options);
24
+ latest.current = options;
25
+ const handle = useMemo(() => {
26
+ const call = latest.current.call;
27
+ if (!call && !namespace)
28
+ return undefined;
29
+ const legacy = latest.current.legacy;
30
+ return hold.open({
31
+ chainId,
32
+ account,
33
+ safe,
34
+ call: call ?? NO_CALL,
35
+ ...(namespace ? { namespace } : {}),
36
+ }, legacy ? { legacy } : undefined);
37
+ // The call and legacy keys stand for their values.
38
+ }, [hold, chainId, account, safe, namespace, callKey, legacyKey]);
39
+ // Whether the app has a previous deploy's record to adopt: a change makes a
40
+ // new view, whose adoption runs before any send.
41
+ const adopts = !!options.adopt;
42
+ /** The view whose callbacks are the app's now: an earlier one's late answers reach none. */
43
+ const active = useRef(undefined);
44
+ const view = useMemo(() => {
45
+ if (!handle || !client)
46
+ return undefined;
47
+ /** Only while this view is the app's: an earlier one's late answers reach no callback. */
48
+ const own = (callback) => (...args) => {
49
+ if (active.current === created)
50
+ callback(...args);
51
+ };
52
+ const created = createHeldWriteView(handle, {
53
+ client,
54
+ pollMs,
55
+ onSettled: own((settled, receipt) => latest.current.onSettled?.(settled, receipt)),
56
+ onReleased: own((by) => latest.current.onReleased?.(by)),
57
+ onAdopted: own((state) => latest.current.onAdopted?.(state)),
58
+ // A view made with a provider: the app's current one (a removed one
59
+ // makes a new view, and this one stops).
60
+ ...(adopts ? { adopt: () => latest.current.adopt() } : {}),
61
+ });
62
+ return created;
63
+ }, [handle, client, pollMs, adopts]);
64
+ useEffect(() => {
65
+ if (!view)
66
+ return;
67
+ active.current = view;
68
+ const stop = view.start();
69
+ return () => {
70
+ if (active.current === view)
71
+ active.current = undefined;
72
+ stop();
73
+ };
74
+ }, [view]);
75
+ const shown = useSyncExternalStore(view?.subscribe ?? none, view?.get ?? idle, view?.get ?? idle);
76
+ return {
77
+ ...shown,
78
+ ...actionsOf(shown, view),
79
+ send: (run) => {
80
+ if (!view)
81
+ return Promise.reject(new Error("Connect a wallet and build the call before sending."));
82
+ // A record to adopt that this view doesn't know of yet: never send past it.
83
+ if (!!latest.current.adopt !== adopts)
84
+ return Promise.reject(new Error("Saved transactions are still being checked. Try again in a moment."));
85
+ return view.send(run);
86
+ },
87
+ check: () => (view ? view.check() : Promise.resolve(IDLE)),
88
+ handle,
89
+ };
90
+ }
91
+ //# sourceMappingURL=useHeldWrite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldWrite.js","sourceRoot":"","sources":["../../../../src/review/react/useHeldWrite.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAWpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,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,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { type HeldWriteView, type WriteHold, type WriteHoldClient } from "../index.js";
2
+ import type { Address } from "viem";
3
+ /** One held write an app-wide notice shows. */
4
+ export type HeldWriteItem = {
5
+ key: string;
6
+ /** What the action is, when the app names it. */
7
+ label?: string;
8
+ view: HeldWriteView;
9
+ /** Release it (the notice's exit): true when released. */
10
+ release: () => Promise<boolean>;
11
+ };
12
+ /**
13
+ * The holds of a fixed set of actions, found by their intents alone and
14
+ * shown with their lines and exits, whatever the actions' buttons allow now.
15
+ */
16
+ export declare function useHeldIntents({ hold, chainId, account, client, intents, pollMs, }: {
17
+ hold: WriteHold;
18
+ chainId: number;
19
+ account: Address | undefined;
20
+ client: WriteHoldClient | undefined;
21
+ intents: readonly {
22
+ namespace: string;
23
+ label?: string;
24
+ }[];
25
+ pollMs?: number;
26
+ }): HeldWriteItem[];
27
+ /**
28
+ * Every write held for `account` on `chainId`, whatever action made it
29
+ * (`hold.list`), read again when another window changes one and every poll.
30
+ */
31
+ export declare function useHeldWrites({ hold, chainId, account, client, label, pollMs, }: {
32
+ hold: WriteHold;
33
+ chainId: number;
34
+ account: Address | undefined;
35
+ client: WriteHoldClient | undefined;
36
+ /** The app's name for a listed write's action, when it knows it. */
37
+ label?: (record: ReturnType<WriteHold["list"]>[number]["record"]) => string | undefined;
38
+ pollMs?: number;
39
+ }): HeldWriteItem[];
40
+ //# sourceMappingURL=useHeldWrites.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldWrites.d.ts","sourceRoot":"","sources":["../../../../src/review/react/useHeldWrites.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,SAAS,EACd,KAAK,eAAe,EAErB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,OAAO,EAAO,MAAM,MAAM,CAAC;AAEzC,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,iDAAiD;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,aAAa,CAAC;IACpB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAqDF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,IAAI,EACJ,OAAO,EACP,OAAO,EACP,MAAM,EACN,OAAO,EACP,MAAM,GACP,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,SAAS;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,aAAa,EAAE,CAqBlB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,OAAO,EACP,OAAO,EACP,MAAM,EACN,KAAK,EACL,MAAe,GAChB,EAAE;IACD,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,eAAe,GAAG,SAAS,CAAC;IACpC,oEAAoE;IACpE,KAAK,CAAC,EAAE,CACN,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,KACpD,MAAM,GAAG,SAAS,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,aAAa,EAAE,CA6BlB"}
@@ -0,0 +1,91 @@
1
+ import { createHeldWriteView, } from "../index.js";
2
+ import { useEffect, useMemo, useState, useSyncExternalStore } from "react";
3
+ /** Watch each entry's hold as one held write view; held ones (and fresh results) come back as items. */
4
+ function useHeldViews(entries, client, pollMs) {
5
+ const views = useMemo(() => client
6
+ ? entries.map((entry) => ({
7
+ entry,
8
+ view: createHeldWriteView(entry.handle, { client, pollMs }),
9
+ }))
10
+ : [], [entries, client, pollMs]);
11
+ useEffect(() => {
12
+ const stops = views.map(({ view }) => view.start());
13
+ return () => stops.forEach((stop) => stop());
14
+ }, [views]);
15
+ const store = useMemo(() => feed(views.map(({ view }) => view)), [views]);
16
+ const shown = useSyncExternalStore(store.subscribe, store.get, store.get);
17
+ return views
18
+ .map(({ entry, view }, index) => ({
19
+ key: entry.key,
20
+ ...(entry.label ? { label: entry.label } : {}),
21
+ view: shown[index],
22
+ release: view.exit,
23
+ }))
24
+ .filter(({ view }) => view.phase !== "clear");
25
+ }
26
+ /** Several views as one store: a snapshot array that changes when any view does. */
27
+ function feed(views) {
28
+ let snapshot = views.map((view) => view.get());
29
+ return {
30
+ subscribe(listener) {
31
+ const stops = views.map((view) => view.subscribe(() => {
32
+ snapshot = views.map((each) => each.get());
33
+ listener();
34
+ }));
35
+ return () => stops.forEach((stop) => stop());
36
+ },
37
+ get: () => snapshot,
38
+ };
39
+ }
40
+ /**
41
+ * The holds of a fixed set of actions, found by their intents alone and
42
+ * shown with their lines and exits, whatever the actions' buttons allow now.
43
+ */
44
+ export function useHeldIntents({ hold, chainId, account, client, intents, pollMs, }) {
45
+ const intentsKey = JSON.stringify(intents);
46
+ const entries = useMemo(() => account
47
+ ? intents.map(({ namespace, label }) => ({
48
+ key: namespace,
49
+ label,
50
+ handle: hold.open({
51
+ chainId,
52
+ account,
53
+ safe: false,
54
+ namespace,
55
+ call: { to: account, data: "0x" },
56
+ }),
57
+ }))
58
+ : [],
59
+ // The intents key stands for the intents.
60
+ [hold, chainId, account, intentsKey]);
61
+ return useHeldViews(entries, client, pollMs);
62
+ }
63
+ /**
64
+ * Every write held for `account` on `chainId`, whatever action made it
65
+ * (`hold.list`), read again when another window changes one and every poll.
66
+ */
67
+ export function useHeldWrites({ hold, chainId, account, client, label, pollMs = 30_000, }) {
68
+ const [generation, setGeneration] = useState(0);
69
+ useEffect(() => {
70
+ const again = () => setGeneration((value) => value + 1);
71
+ globalThis.addEventListener?.("storage", again);
72
+ const timer = setInterval(again, pollMs);
73
+ return () => {
74
+ globalThis.removeEventListener?.("storage", again);
75
+ clearInterval(timer);
76
+ };
77
+ }, [pollMs]);
78
+ const listed = useMemo(() => (account ? hold.list({ account, chainId }) : []), [hold, account, chainId, generation]);
79
+ const listedKey = listed
80
+ .map(({ key, record }) => `${key}:${record.id}`)
81
+ .join("|");
82
+ const entries = useMemo(() => listed.map(({ key, record, handle }) => ({
83
+ key,
84
+ label: label?.(record),
85
+ handle,
86
+ })),
87
+ // The listed key stands for the list.
88
+ [listedKey]);
89
+ return useHeldViews(entries, client, pollMs);
90
+ }
91
+ //# sourceMappingURL=useHeldWrites.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useHeldWrites.js","sourceRoot":"","sources":["../../../../src/review/react/useHeldWrites.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,GAMpB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAe3E,wGAAwG;AACxG,SAAS,YAAY,CACnB,OAAyB,EACzB,MAAmC,EACnC,MAA0B;IAE1B,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CACH,MAAM;QACJ,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACtB,KAAK;YACL,IAAI,EAAE,mBAAmB,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;SAC5D,CAAC,CAAC;QACL,CAAC,CAAC,EAAE,EACR,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,CAC1B,CAAC;IACF,SAAS,CAAC,GAAG,EAAE;QACb,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