@bananapus/nana-sdk-core 2.12.2 → 2.13.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 (65) hide show
  1. package/dist/cjs/bendystrawOperations.d.ts +38 -0
  2. package/dist/cjs/bendystrawOperations.d.ts.map +1 -0
  3. package/dist/cjs/bendystrawOperations.js +212 -0
  4. package/dist/cjs/bendystrawOperations.js.map +1 -0
  5. package/dist/cjs/review/contractWrite.d.ts +38 -0
  6. package/dist/cjs/review/contractWrite.d.ts.map +1 -0
  7. package/dist/cjs/review/contractWrite.js +57 -0
  8. package/dist/cjs/review/contractWrite.js.map +1 -0
  9. package/dist/cjs/review/gas.d.ts +28 -0
  10. package/dist/cjs/review/gas.d.ts.map +1 -0
  11. package/dist/cjs/review/gas.js +40 -0
  12. package/dist/cjs/review/gas.js.map +1 -0
  13. package/dist/cjs/review/index.d.ts +4 -0
  14. package/dist/cjs/review/index.d.ts.map +1 -0
  15. package/dist/cjs/review/index.js +20 -0
  16. package/dist/cjs/review/index.js.map +1 -0
  17. package/dist/cjs/review/transactionReview.d.ts +81 -0
  18. package/dist/cjs/review/transactionReview.d.ts.map +1 -0
  19. package/dist/cjs/review/transactionReview.js +203 -0
  20. package/dist/cjs/review/transactionReview.js.map +1 -0
  21. package/dist/cjs/safeService.d.ts +36 -0
  22. package/dist/cjs/safeService.d.ts.map +1 -0
  23. package/dist/cjs/safeService.js +142 -0
  24. package/dist/cjs/safeService.js.map +1 -0
  25. package/dist/cjs/utils/bendystraw.d.ts +15 -0
  26. package/dist/cjs/utils/bendystraw.d.ts.map +1 -1
  27. package/dist/cjs/utils/bendystraw.js +54 -0
  28. package/dist/cjs/utils/bendystraw.js.map +1 -1
  29. package/dist/cjs/v6/feeBuyback.d.ts +43 -0
  30. package/dist/cjs/v6/feeBuyback.d.ts.map +1 -0
  31. package/dist/cjs/v6/feeBuyback.js +306 -0
  32. package/dist/cjs/v6/feeBuyback.js.map +1 -0
  33. package/dist/esm/bendystrawOperations.d.ts +38 -0
  34. package/dist/esm/bendystrawOperations.d.ts.map +1 -0
  35. package/dist/esm/bendystrawOperations.js +206 -0
  36. package/dist/esm/bendystrawOperations.js.map +1 -0
  37. package/dist/esm/review/contractWrite.d.ts +38 -0
  38. package/dist/esm/review/contractWrite.d.ts.map +1 -0
  39. package/dist/esm/review/contractWrite.js +54 -0
  40. package/dist/esm/review/contractWrite.js.map +1 -0
  41. package/dist/esm/review/gas.d.ts +28 -0
  42. package/dist/esm/review/gas.d.ts.map +1 -0
  43. package/dist/esm/review/gas.js +36 -0
  44. package/dist/esm/review/gas.js.map +1 -0
  45. package/dist/esm/review/index.d.ts +4 -0
  46. package/dist/esm/review/index.d.ts.map +1 -0
  47. package/dist/esm/review/index.js +4 -0
  48. package/dist/esm/review/index.js.map +1 -0
  49. package/dist/esm/review/transactionReview.d.ts +81 -0
  50. package/dist/esm/review/transactionReview.d.ts.map +1 -0
  51. package/dist/esm/review/transactionReview.js +192 -0
  52. package/dist/esm/review/transactionReview.js.map +1 -0
  53. package/dist/esm/safeService.d.ts +36 -0
  54. package/dist/esm/safeService.d.ts.map +1 -0
  55. package/dist/esm/safeService.js +135 -0
  56. package/dist/esm/safeService.js.map +1 -0
  57. package/dist/esm/utils/bendystraw.d.ts +15 -0
  58. package/dist/esm/utils/bendystraw.d.ts.map +1 -1
  59. package/dist/esm/utils/bendystraw.js +53 -0
  60. package/dist/esm/utils/bendystraw.js.map +1 -1
  61. package/dist/esm/v6/feeBuyback.d.ts +43 -0
  62. package/dist/esm/v6/feeBuyback.d.ts.map +1 -0
  63. package/dist/esm/v6/feeBuyback.js +299 -0
  64. package/dist/esm/v6/feeBuyback.js.map +1 -0
  65. package/package.json +30 -1
@@ -0,0 +1,54 @@
1
+ import { BaseError, UserRejectedRequestError } from "viem";
2
+ /**
3
+ * Shared review-to-wallet boundary for direct contract writes.
4
+ *
5
+ * The exact request object accepted by review is also handed to simulation,
6
+ * and only the simulation result reaches the wallet writer. Account identity
7
+ * is checked after a chain switch and again immediately before signing.
8
+ */
9
+ export async function submitReviewedContractWrite({ request, expectedAccount, review, switchChain, currentAccount, simulate, reverify, beforeWrite, onBeforeWriteAborted, onWriteRejected, write, onPhase, accountChangedError = "Connected account changed. Review the transaction again.", guard, }) {
10
+ guard?.();
11
+ if (!expectedAccount)
12
+ throw new Error("Connect a wallet first.");
13
+ onPhase?.("review");
14
+ await review(request);
15
+ onPhase?.("simulating");
16
+ await switchChain(request.chainId);
17
+ assertExpectedAccount(currentAccount(), expectedAccount, accountChangedError);
18
+ await reverify?.(request);
19
+ assertExpectedAccount(currentAccount(), expectedAccount, accountChangedError);
20
+ const simulated = await simulate(request);
21
+ assertExpectedAccount(currentAccount(), expectedAccount, accountChangedError);
22
+ if (beforeWrite) {
23
+ await beforeWrite();
24
+ try {
25
+ assertExpectedAccount(currentAccount(), expectedAccount, accountChangedError);
26
+ }
27
+ catch (error) {
28
+ // This is strictly before the wallet writer is invoked. An ambiguous
29
+ // write error must never reach this cleanup path.
30
+ await onBeforeWriteAborted?.();
31
+ throw error;
32
+ }
33
+ }
34
+ onPhase?.("signing");
35
+ try {
36
+ return await write(simulated);
37
+ }
38
+ catch (error) {
39
+ // The same-looking error from review/simulation never reaches this catch.
40
+ // An RPC timeout or ambiguous submission must preserve the recovery lock.
41
+ const rejected = error instanceof UserRejectedRequestError ||
42
+ (error instanceof BaseError &&
43
+ error.walk((cause) => cause instanceof UserRejectedRequestError) instanceof UserRejectedRequestError);
44
+ if (rejected)
45
+ await onWriteRejected?.();
46
+ throw error;
47
+ }
48
+ }
49
+ function assertExpectedAccount(current, expected, message) {
50
+ if (!current || current.toLowerCase() !== expected.toLowerCase()) {
51
+ throw new Error(message);
52
+ }
53
+ }
54
+ //# sourceMappingURL=contractWrite.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contractWrite.js","sourceRoot":"","sources":["../../../src/review/contractWrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SA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,SAAS,CAAC,CAAC;IACrB,IAAI,CAAC;QACH,OAAO,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0EAA0E;QAC1E,0EAA0E;QAC1E,MAAM,QAAQ,GACZ,KAAK,YAAY,wBAAwB;YACzC,CAAC,KAAK,YAAY,SAAS;gBACzB,KAAK,CAAC,IAAI,CACR,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,wBAAwB,CACrD,YAAY,wBAAwB,CAAC,CAAC;QAC3C,IAAI,QAAQ;YAAE,MAAM,eAAe,EAAE,EAAE,CAAC;QACxC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,qBAAqB,CAC5B,OAA4B,EAC5B,QAAiB,EACjB,OAAe;IAEf,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,KAAK,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { Address, Hex, PublicClient } from "viem";
2
+ /**
3
+ * Wallet gas limits are deliberately twice the latest RPC estimate.
4
+ *
5
+ * Some Juicebox terminal calls catch a failed internal fee payment and keep
6
+ * going. An RPC can therefore return an estimate for that cheaper recovery
7
+ * path even though the intended fee route needs more gas. Unused gas is not
8
+ * spent, so a 2x limit is a cheap guard against that under-estimation.
9
+ */
10
+ export declare function gasWithHeadroom(estimate: bigint): bigint;
11
+ /**
12
+ * The gas limit to send for a call that carries a reviewed cap.
13
+ *
14
+ * A cap bounds an `eth_call` against a target-controlled contract; it is not
15
+ * what the call costs. Wallets reject a transaction whose `gas * maxFeePerGas`
16
+ * exceeds the balance, so sending the cap itself turns a 1M-gas mainnet cap
17
+ * into a ~0.003 ETH balance requirement for a call that burns a tenth of that.
18
+ *
19
+ * Measurement stays bounded by the cap, and the cap survives when the node
20
+ * cannot measure.
21
+ */
22
+ export declare function gasWithinCap(client: PublicClient, tx: {
23
+ account: Address;
24
+ to: Address;
25
+ data: Hex;
26
+ value?: bigint;
27
+ }, cap?: bigint): Promise<bigint | undefined>;
28
+ //# sourceMappingURL=gas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas.d.ts","sourceRoot":"","sources":["../../../src/review/gas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEvD;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,YAAY,EACpB,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,EAAE,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAChE,GAAG,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAW7B"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Wallet gas limits are deliberately twice the latest RPC estimate.
3
+ *
4
+ * Some Juicebox terminal calls catch a failed internal fee payment and keep
5
+ * going. An RPC can therefore return an estimate for that cheaper recovery
6
+ * path even though the intended fee route needs more gas. Unused gas is not
7
+ * spent, so a 2x limit is a cheap guard against that under-estimation.
8
+ */
9
+ export function gasWithHeadroom(estimate) {
10
+ return estimate * 2n;
11
+ }
12
+ /**
13
+ * The gas limit to send for a call that carries a reviewed cap.
14
+ *
15
+ * A cap bounds an `eth_call` against a target-controlled contract; it is not
16
+ * what the call costs. Wallets reject a transaction whose `gas * maxFeePerGas`
17
+ * exceeds the balance, so sending the cap itself turns a 1M-gas mainnet cap
18
+ * into a ~0.003 ETH balance requirement for a call that burns a tenth of that.
19
+ *
20
+ * Measurement stays bounded by the cap, and the cap survives when the node
21
+ * cannot measure.
22
+ */
23
+ export async function gasWithinCap(client, tx, cap) {
24
+ try {
25
+ const estimate = await client.estimateGas({
26
+ ...tx,
27
+ ...(cap === undefined ? {} : { gas: cap }),
28
+ });
29
+ const measured = gasWithHeadroom(estimate);
30
+ return cap !== undefined && cap < measured ? cap : measured;
31
+ }
32
+ catch {
33
+ return cap;
34
+ }
35
+ }
36
+ //# sourceMappingURL=gas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gas.js","sourceRoot":"","sources":["../../../src/review/gas.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,QAAQ,GAAG,EAAE,CAAC;AACvB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAoB,EACpB,EAAgE,EAChE,GAAY;IAEZ,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;YACxC,GAAG,EAAE;YACL,GAAG,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;SAC3C,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;QAC3C,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,GAAG,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC;IAC9D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,GAAG,CAAC;IACb,CAAC;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./contractWrite.js";
2
+ export * from "./gas.js";
3
+ export * from "./transactionReview.js";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/review/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from "./contractWrite.js";
2
+ export * from "./gas.js";
3
+ export * from "./transactionReview.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/review/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,UAAU,CAAC;AACzB,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { type Abi, type Address, type Hex } from "viem";
2
+ /**
3
+ * How review prompts name a chain and link its explorer. Apps pass their own
4
+ * chain display, which also keeps a chain table out of the review bundle.
5
+ */
6
+ export type TransactionReviewDisplay = {
7
+ chainName: (chainId: number) => string;
8
+ explorerOrigin: (chainId: number) => string | null;
9
+ };
10
+ export type TransactionReviewCall = {
11
+ chainId: number;
12
+ to: Address;
13
+ data: Hex;
14
+ value?: bigint;
15
+ from?: Address;
16
+ abi?: Abi;
17
+ functionName?: string;
18
+ args?: readonly unknown[];
19
+ /** Plain-language action shown above the decoded call. */
20
+ label?: string;
21
+ /** Optional known contract name. The full address is always shown too. */
22
+ contractName?: string;
23
+ /** The calls a batching destination (MultiSend) makes in order, decoded by the caller. */
24
+ calls?: readonly TransactionReviewCall[];
25
+ };
26
+ export type TransactionReviewRequest = {
27
+ calls: readonly TransactionReviewCall[];
28
+ title?: string;
29
+ description?: string;
30
+ confirmLabel?: string;
31
+ /** Distinguishes a wallet transaction from an authorization which a relayer/Safe will submit. */
32
+ kind?: "transaction" | "authorization";
33
+ /** Exact typed data committed by a Safe/relayer signature, when applicable. */
34
+ authorization?: unknown;
35
+ };
36
+ export type ContractTransactionReviewCall = {
37
+ chainId: number;
38
+ address: Address;
39
+ abi: Abi;
40
+ functionName: string;
41
+ args?: readonly unknown[];
42
+ value?: bigint;
43
+ account?: Address;
44
+ };
45
+ export type TransactionReviewOptions = Omit<TransactionReviewRequest, "calls"> & {
46
+ label?: string;
47
+ contractName?: string;
48
+ };
49
+ type TransactionReviewHandler = (request: TransactionReviewRequest) => Promise<boolean>;
50
+ export type FundingChainOption = {
51
+ chainId: number;
52
+ /** The chain name and quoted funding cost shown to the user. */
53
+ label: string;
54
+ };
55
+ type FundingChainSelectionHandler = (options: readonly FundingChainOption[]) => Promise<number | null>;
56
+ export declare function registerFundingChainSelectionHandler(handler: FundingChainSelectionHandler): () => void;
57
+ /** Funding always requires an explicit choice, even with one quoted option. */
58
+ export declare function requireFundingChainSelection(options: readonly FundingChainOption[]): Promise<number>;
59
+ /**
60
+ * The provider registers the only UI capable of approving a transaction.
61
+ * Keeping the entry point in a small client module lets non-React wallet
62
+ * helpers (Safe and Relayr) use the same mandatory review queue.
63
+ */
64
+ export declare function registerTransactionReviewHandler(handler: TransactionReviewHandler): () => void;
65
+ export declare function requestContractTransactionReview(call: ContractTransactionReviewCall, options?: TransactionReviewOptions): Promise<boolean>;
66
+ export declare function requireTransactionReview(request: TransactionReviewRequest): Promise<void>;
67
+ export declare function requireContractTransactionReview(call: ContractTransactionReviewCall, options?: TransactionReviewOptions): Promise<void>;
68
+ export declare function transactionReviewJson(request: TransactionReviewRequest): string;
69
+ /**
70
+ * The post-transaction counterpart of the review prompt: a mined tx the user
71
+ * wants explained (or diagnosed) from explorer evidence. Points at Etherscan's
72
+ * transaction-debugger skill when the reader's agent has it, and degrades to
73
+ * the explorer page when it doesn't.
74
+ */
75
+ export declare function buildTransactionDebugPrompt(calls: {
76
+ chainId: number;
77
+ txHash: string;
78
+ }[], { chainName: displayChainName, explorerOrigin }: TransactionReviewDisplay): string;
79
+ export declare function buildTransactionReviewPrompt(request: TransactionReviewRequest, { explorerOrigin }: Pick<TransactionReviewDisplay, "explorerOrigin">): string;
80
+ export {};
81
+ //# sourceMappingURL=transactionReview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionReview.d.ts","source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O,CAAC,IAAI,CAAC,CAIf;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,wBAAwB,GAChC,MAAM,CAmBR;AAMD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,EAC5C,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,EAAE,wBAAwB,GACxE,MAAM,CAoBR;AAED,wBAAgB,4BAA4B,CAC1C,OAAO,EAAE,wBAAwB,EACjC,EAAE,cAAc,EAAE,EAAE,IAAI,CAAC,wBAAwB,EAAE,gBAAgB,CAAC,GACnE,MAAM,CAiER"}
@@ -0,0 +1,192 @@
1
+ "use client";
2
+ import { encodeFunctionData } from "viem";
3
+ const transactionReviewHandlers = [];
4
+ const fundingChainSelectionHandlers = [];
5
+ export function registerFundingChainSelectionHandler(handler) {
6
+ fundingChainSelectionHandlers.push(handler);
7
+ return () => {
8
+ const index = fundingChainSelectionHandlers.lastIndexOf(handler);
9
+ if (index >= 0)
10
+ fundingChainSelectionHandlers.splice(index, 1);
11
+ };
12
+ }
13
+ /** Funding always requires an explicit choice, even with one quoted option. */
14
+ export async function requireFundingChainSelection(options) {
15
+ const snapshot = options.map((option) => ({ ...option }));
16
+ const chainIds = new Set(snapshot.map((option) => option.chainId));
17
+ if (!snapshot.length ||
18
+ chainIds.size !== snapshot.length ||
19
+ snapshot.some((option) => !Number.isSafeInteger(option.chainId) ||
20
+ option.chainId <= 0 ||
21
+ !option.label.trim())) {
22
+ throw new Error("No valid funding chain choices are available. Request a new quote.");
23
+ }
24
+ const handler = fundingChainSelectionHandlers[fundingChainSelectionHandlers.length - 1];
25
+ if (!handler) {
26
+ throw new Error("Funding chain selection is unavailable. Reload the page before continuing.");
27
+ }
28
+ const selected = await handler(snapshot);
29
+ if (selected === null) {
30
+ throw new Error("Funding chain selection cancelled. Nothing was sent.");
31
+ }
32
+ if (!chainIds.has(selected)) {
33
+ throw new Error("The selected funding chain is not available in this quote.");
34
+ }
35
+ return selected;
36
+ }
37
+ /**
38
+ * The provider registers the only UI capable of approving a transaction.
39
+ * Keeping the entry point in a small client module lets non-React wallet
40
+ * helpers (Safe and Relayr) use the same mandatory review queue.
41
+ */
42
+ export function registerTransactionReviewHandler(handler) {
43
+ transactionReviewHandlers.push(handler);
44
+ return () => {
45
+ const index = transactionReviewHandlers.lastIndexOf(handler);
46
+ if (index >= 0)
47
+ transactionReviewHandlers.splice(index, 1);
48
+ };
49
+ }
50
+ async function requestTransactionReview(request) {
51
+ if (!request.calls.length && !request.authorization) {
52
+ throw new Error("There is no transaction to review.");
53
+ }
54
+ const transactionReviewHandler = transactionReviewHandlers[transactionReviewHandlers.length - 1];
55
+ if (!transactionReviewHandler) {
56
+ throw new Error("Transaction review is unavailable. Reload the page before continuing.");
57
+ }
58
+ return transactionReviewHandler(request);
59
+ }
60
+ /** Encode once for review using the same ABI/function/args passed to wagmi. */
61
+ function contractCallForReview(call, options = {}) {
62
+ const data = encodeFunctionData({
63
+ abi: call.abi,
64
+ functionName: call.functionName,
65
+ args: call.args,
66
+ });
67
+ return {
68
+ chainId: call.chainId,
69
+ to: call.address,
70
+ data,
71
+ value: call.value,
72
+ from: call.account,
73
+ abi: call.abi,
74
+ functionName: call.functionName,
75
+ args: call.args,
76
+ label: options.label,
77
+ contractName: options.contractName,
78
+ };
79
+ }
80
+ export function requestContractTransactionReview(call, options = {}) {
81
+ const { label, contractName, ...requestOptions } = options;
82
+ const reviewed = contractCallForReview(call, { label, contractName });
83
+ return requestTransactionReview({
84
+ ...requestOptions,
85
+ calls: [reviewed],
86
+ }).then((approved) => {
87
+ if (!approved)
88
+ return false;
89
+ const current = contractCallForReview(call, { label, contractName });
90
+ if (current.chainId !== reviewed.chainId ||
91
+ current.to.toLowerCase() !== reviewed.to.toLowerCase() ||
92
+ (current.value ?? 0n) !== (reviewed.value ?? 0n) ||
93
+ current.data !== reviewed.data) {
94
+ throw new Error("Transaction data changed after review. Nothing was sent; review it again.");
95
+ }
96
+ return true;
97
+ });
98
+ }
99
+ class TransactionReviewCancelledError extends Error {
100
+ constructor() {
101
+ super("Review closed. Nothing was sent.");
102
+ this.name = "TransactionReviewCancelledError";
103
+ }
104
+ }
105
+ export async function requireTransactionReview(request) {
106
+ if (!(await requestTransactionReview(request))) {
107
+ throw new TransactionReviewCancelledError();
108
+ }
109
+ }
110
+ export async function requireContractTransactionReview(call, options = {}) {
111
+ if (!(await requestContractTransactionReview(call, options))) {
112
+ throw new TransactionReviewCancelledError();
113
+ }
114
+ }
115
+ export function transactionReviewJson(request) {
116
+ const transactions = request.calls.map((call) => ({
117
+ chainId: call.chainId,
118
+ from: call.from,
119
+ to: call.to,
120
+ value: `0x${(call.value ?? 0n).toString(16)}`,
121
+ data: call.data,
122
+ }));
123
+ const calls = transactions.length === 1 ? transactions[0] : { transactions };
124
+ const payload = request.authorization
125
+ ? transactions.length > 0
126
+ ? { authorization: request.authorization, resultingCall: calls }
127
+ : { authorization: request.authorization }
128
+ : calls;
129
+ return JSON.stringify(payload, (_, value) => (typeof value === "bigint" ? value.toString() : value), 2);
130
+ }
131
+ /** A website/-style prompt which keeps the exact reviewed RPC call intact. */
132
+ const ETHERSCAN_SKILL_LINE = "If your agent has Etherscan's skills installed (`npx skills add etherscan/skills`), run `etherscan-contract-review` on each target address to pull its verified source, proxy roles, and privileged controls before decoding. Otherwise work from the explorer pages.";
133
+ /**
134
+ * The post-transaction counterpart of the review prompt: a mined tx the user
135
+ * wants explained (or diagnosed) from explorer evidence. Points at Etherscan's
136
+ * transaction-debugger skill when the reader's agent has it, and degrades to
137
+ * the explorer page when it doesn't.
138
+ */
139
+ export function buildTransactionDebugPrompt(calls, { chainName: displayChainName, explorerOrigin }) {
140
+ const lines = [
141
+ "A Juicebox V6 transaction (the nana V6 / revnet V6 protocol release, not an older Juicebox version) was mined. Explain what happened in it and whether it did what a Juicebox user would expect.",
142
+ "",
143
+ ];
144
+ calls.forEach((call) => {
145
+ const explorer = explorerOrigin(call.chainId);
146
+ lines.push(`- ${displayChainName(call.chainId)} (chain ${call.chainId}): ${explorer ? `${explorer}/tx/${call.txHash}` : call.txHash}`);
147
+ });
148
+ lines.push("", "If your agent has Etherscan's skills installed (`npx skills add etherscan/skills`), use `etherscan-transaction-debugger` in security mode on each hash. Otherwise work from the explorer page: receipt status, decoded input, event logs, and internal transactions.", "", "Verify contract source only against the Juicebox V6 repositories: https://github.com/Bananapus/version-6 (repositories ending in `-v6`; same-named repositories without that suffix are older versions).", "", "Report the decoded method and arguments, every native and token movement with its recipient, every permission, ownership, or ruleset change, and, if it reverted, the narrowest root cause the evidence supports. Mark each claim observed, derived, or inferred. Never invent a function name, amount, or revert reason. End with one line: what the transaction did in plain English, and anything that looks wrong.");
149
+ return lines.join("\n");
150
+ }
151
+ export function buildTransactionReviewPrompt(request, { explorerOrigin }) {
152
+ const lines = [
153
+ "I'm about to authorize a blockchain transaction in the Juicebox V6 app (the nana V6 / revnet V6 protocol release, not an older Juicebox version). Act as a careful security reviewer. Independently verify the payload against the deployed contracts and V6 source, confirm it matches my intent, and give a go/no-go. Assume the UI could be spoofed; trust the onchain call and verified V6 source over the page.",
154
+ "",
155
+ "Exact app-controlled transaction payload:",
156
+ "```json",
157
+ transactionReviewJson(request),
158
+ "```",
159
+ "",
160
+ ];
161
+ if (typeof window !== "undefined") {
162
+ lines.push("Audit the app build I am using:");
163
+ lines.push(`- Page: ${window.location.href}`);
164
+ lines.push("- Confirm this page builds exactly the destination, native value, and calldata above, with no hidden or substituted call.");
165
+ lines.push("");
166
+ }
167
+ lines.push("Verify the contracts and protocol version:");
168
+ lines.push("- Juicebox V6 ecosystem source: https://github.com/Bananapus/version-6");
169
+ lines.push("- Use only V6 repositories (normally ending in `-v6`); same-named repositories without that suffix may be older and incompatible.");
170
+ lines.push(`- ${ETHERSCAN_SKILL_LINE}`);
171
+ request.calls.forEach((call, index) => {
172
+ // Apps pass their one explorer registry; a second copy once drifted on OP mainnet.
173
+ const explorer = explorerOrigin(call.chainId);
174
+ const prefix = request.calls.length > 1 ? `Transaction ${index + 1}` : "Target";
175
+ lines.push(explorer
176
+ ? `- ${prefix} onchain: ${explorer}/address/${call.to}`
177
+ : `- ${prefix}: chain ${call.chainId}, address ${call.to}`);
178
+ });
179
+ lines.push("");
180
+ lines.push("Check specifically:");
181
+ lines.push("1. Decode the calldata selector and every argument. Explain in plain English what state, permissions, ownership, tokens, or funds can change.");
182
+ lines.push("2. Verify the chain ID, `to` address, native `value`, and calldata exactly. Flag any unexpected non-zero value or unknown target.");
183
+ lines.push("3. Identify every beneficiary, recipient, spender, operator, owner, hook, terminal, and permission-bearing address in the decoded arguments.");
184
+ lines.push("4. Warn about unlimited approvals, arbitrary-call capability, delegatecalls, ownership transfers, permission grants, upgradeability, or drain paths.");
185
+ lines.push("5. For multiple chains, confirm the intended change is consistent and that no extra chain or call was added.");
186
+ lines.push("");
187
+ lines.push("Before your verdict, quiz me with 2–4 short plain-English questions about what I expect to happen (what changes, who receives or controls what, how much value moves, and on which chain). Wait for my answers, compare them with the decoded payload, and flag every mismatch.");
188
+ lines.push("");
189
+ lines.push("End with one verdict: SAFE TO SIGN / DO NOT SIGN / NEEDS MORE INFO, followed by the most important reasons. If the target is not a recognizable verified Juicebox V6 deployment, say so explicitly.");
190
+ return lines.join("\n");
191
+ }
192
+ //# sourceMappingURL=transactionReview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactionReview.js","sourceRoot":"","sources":["../../../src/review/transactionReview.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,kBAAkB,EAAoC,MAAM,MAAM,CAAC;AA6D5E,MAAM,yBAAyB,GAA+B,EAAE,CAAC;AAYjE,MAAM,6BAA6B,GAAmC,EAAE,CAAC;AAEzE,MAAM,UAAU,oCAAoC,CAClD,OAAqC;IAErC,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC5C,OAA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AAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IAClC,KAAK,CAAC,IAAI,CACR,+IAA+I,CAChJ,CAAC;IACF,KAAK,CAAC,IAAI,CACR,mIAAmI,CACpI,CAAC;IACF,KAAK,CAAC,IAAI,CACR,8IAA8I,CAC/I,CAAC;IACF,KAAK,CAAC,IAAI,CACR,sJAAsJ,CACvJ,CAAC;IACF,KAAK,CAAC,IAAI,CACR,8GAA8G,CAC/G,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,iRAAiR,CAClR,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,KAAK,CAAC,IAAI,CACR,qMAAqM,CACtM,CAAC;IACF,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Address, Hex } from "viem";
2
+ /**
3
+ * Safe's per-chain app URL prefix. Wider than {@link SAFE_SERVICE_PREFIX}:
4
+ * Safe app links work on chains without a hosted transaction service.
5
+ */
6
+ export declare const SAFE_PREFIX: Partial<Record<number, string>>;
7
+ /**
8
+ * Chains with a HOSTED Safe Transaction Service — a smaller set than the
9
+ * chains Safe app links work on: `api.safe.global/tx-service/{opsepolia,
10
+ * arb1-sep}` both 404, while `basesep` is live. Probed against
11
+ * `/api/v1/about/`. This split from {@link SAFE_PREFIX} is DELIBERATE:
12
+ * conflating the two maps is what made service calls fire at chains with
13
+ * none. Every tx-service URL must come from here, never from `SAFE_PREFIX`.
14
+ */
15
+ export declare const SAFE_SERVICE_PREFIX: Partial<Record<number, string>>;
16
+ /** The Safe Transaction Service base URL for a chain, honoring the
17
+ * `jb-safe-tx-base` localStorage override; null when the chain has none. */
18
+ export declare function safeServiceBase(chainId: number): string | null;
19
+ export declare const SAFE_NONCE_GUIDANCE = "On Safe\u2019s confirmation screen, Nonce defaults to the next available value. Open its dropdown to see queued nonces and replace one if desired.";
20
+ /** The unix deadline for a swap/liquidity transaction proposed now. */
21
+ export declare function swapDeadline(isSafe: boolean, nowMs?: number): bigint;
22
+ export declare function safeQueueUrl(chainId: number, safe: Address): string | null;
23
+ /**
24
+ * Resolve a Safe proposal identifier to its actual onchain execution hash.
25
+ * A safeTxHash is not a transaction hash and must never be receipt-polled.
26
+ *
27
+ * The polling URL comes from {@link safeServiceBase} (the hosted-service
28
+ * map), NOT `SAFE_PREFIX`: OP Sepolia and Arbitrum Sepolia have Safe app
29
+ * URLs but no hosted transaction service, and polling a nonexistent service
30
+ * left every Safe write there pending forever.
31
+ */
32
+ export declare function waitForSafeExecutionHash(chainId: number, safeTxHash: Hex, options?: {
33
+ pollingIntervalMs?: number;
34
+ signal?: AbortSignal;
35
+ }): Promise<Hex>;
36
+ //# sourceMappingURL=safeService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeService.d.ts","sourceRoot":"","sources":["../../src/safeService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC;;;GAGG;AACH,eAAO,MAAM,WAAW,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASvD,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO/D,CAAC;AAEF;6EAC6E;AAC7E,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAW9D;AAED,eAAO,MAAM,mBAAmB,uJACiH,CAAC;AAUlJ,uEAAuE;AACvE,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,EACf,KAAK,GAAE,MAAmB,GACzB,MAAM,CAKR;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAK1E;AAWD;;;;;;;;GAQG;AACH,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,GAAG,EACf,OAAO,GAAE;IAAE,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAO,GACjE,OAAO,CAAC,GAAG,CAAC,CAiEd"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Safe's per-chain app URL prefix. Wider than {@link SAFE_SERVICE_PREFIX}:
3
+ * Safe app links work on chains without a hosted transaction service.
4
+ */
5
+ export const SAFE_PREFIX = {
6
+ 1: "eth",
7
+ 10: "oeth",
8
+ 8453: "base",
9
+ 42161: "arb1",
10
+ 11155111: "sep",
11
+ 11155420: "opsepolia",
12
+ 84532: "basesep",
13
+ 421614: "arb1-sep",
14
+ };
15
+ /**
16
+ * Chains with a HOSTED Safe Transaction Service — a smaller set than the
17
+ * chains Safe app links work on: `api.safe.global/tx-service/{opsepolia,
18
+ * arb1-sep}` both 404, while `basesep` is live. Probed against
19
+ * `/api/v1/about/`. This split from {@link SAFE_PREFIX} is DELIBERATE:
20
+ * conflating the two maps is what made service calls fire at chains with
21
+ * none. Every tx-service URL must come from here, never from `SAFE_PREFIX`.
22
+ */
23
+ export const SAFE_SERVICE_PREFIX = {
24
+ 1: "eth",
25
+ 10: "oeth",
26
+ 8453: "base",
27
+ 42161: "arb1",
28
+ 11155111: "sep",
29
+ 84532: "basesep",
30
+ };
31
+ /** The Safe Transaction Service base URL for a chain, honoring the
32
+ * `jb-safe-tx-base` localStorage override; null when the chain has none. */
33
+ export function safeServiceBase(chainId) {
34
+ try {
35
+ const custom = JSON.parse(globalThis.localStorage?.getItem("jb-safe-tx-base") ?? "null");
36
+ if (custom?.[chainId])
37
+ return custom[chainId].replace(/\/$/, "");
38
+ }
39
+ catch {
40
+ // Local overrides are optional.
41
+ }
42
+ const prefix = SAFE_SERVICE_PREFIX[chainId];
43
+ return prefix ? `https://api.safe.global/tx-service/${prefix}` : null;
44
+ }
45
+ export const SAFE_NONCE_GUIDANCE = "On Safe’s confirmation screen, Nonce defaults to the next available value. Open its dropdown to see queued nonces and replace one if desired.";
46
+ /** Swap/mint execution deadline seconds: 20 minutes for an EOA, whose review
47
+ * and signature are one sitting. */
48
+ const SWAP_DEADLINE_SECONDS = 20 * 60;
49
+ /** Safe deadline seconds: co-signer collection routinely outlives 20 minutes,
50
+ * so match the 30-day Permit2 approval windows. The longer window widens MEV
51
+ * exposure only within the swap's already-frozen slippage floor. */
52
+ const SAFE_SWAP_DEADLINE_SECONDS = 30 * 24 * 60 * 60;
53
+ /** The unix deadline for a swap/liquidity transaction proposed now. */
54
+ export function swapDeadline(isSafe, nowMs = Date.now()) {
55
+ return BigInt(Math.floor(nowMs / 1000) +
56
+ (isSafe ? SAFE_SWAP_DEADLINE_SECONDS : SWAP_DEADLINE_SECONDS));
57
+ }
58
+ export function safeQueueUrl(chainId, safe) {
59
+ const prefix = SAFE_PREFIX[chainId];
60
+ return prefix
61
+ ? `https://app.safe.global/transactions/queue?safe=${prefix}:${safe}`
62
+ : null;
63
+ }
64
+ /**
65
+ * Consecutive 404s from the transaction service before the wait gives up. The
66
+ * service can lag a just-created proposal briefly, but a sustained 404 means
67
+ * it will never report this proposal (wrong network or an unhosted chain that
68
+ * slipped through) — polling forever just strands the flow at "pending".
69
+ * At the default 5s interval this is about a minute of patience.
70
+ */
71
+ const SAFE_EXECUTION_NOT_FOUND_LIMIT = 12;
72
+ /**
73
+ * Resolve a Safe proposal identifier to its actual onchain execution hash.
74
+ * A safeTxHash is not a transaction hash and must never be receipt-polled.
75
+ *
76
+ * The polling URL comes from {@link safeServiceBase} (the hosted-service
77
+ * map), NOT `SAFE_PREFIX`: OP Sepolia and Arbitrum Sepolia have Safe app
78
+ * URLs but no hosted transaction service, and polling a nonexistent service
79
+ * left every Safe write there pending forever.
80
+ */
81
+ export async function waitForSafeExecutionHash(chainId, safeTxHash, options = {}) {
82
+ const base = safeServiceBase(chainId);
83
+ if (!base) {
84
+ throw new Error(`Safe does not host a transaction service on chain ${chainId}, so this proposal cannot be tracked here. Execute it from the Safe app; the action takes effect once it is executed there.`);
85
+ }
86
+ const interval = options.pollingIntervalMs ?? 5_000;
87
+ const endpoint = `${base}/api/v1/multisig-transactions/${safeTxHash}/`;
88
+ let consecutiveNotFound = 0;
89
+ for (;;) {
90
+ if (options.signal?.aborted) {
91
+ throw new DOMException("Safe execution wait aborted", "AbortError");
92
+ }
93
+ try {
94
+ const response = await fetch(endpoint);
95
+ if (response.ok) {
96
+ consecutiveNotFound = 0;
97
+ const transaction = (await response.json());
98
+ if (transaction.isExecuted && transaction.isSuccessful === false) {
99
+ throw new Error("Safe executed the proposal, but the onchain transaction failed.");
100
+ }
101
+ if (transaction.isExecuted && transaction.transactionHash) {
102
+ return transaction.transactionHash;
103
+ }
104
+ }
105
+ else if (response.status === 404) {
106
+ consecutiveNotFound += 1;
107
+ if (consecutiveNotFound >= SAFE_EXECUTION_NOT_FOUND_LIMIT) {
108
+ throw new Error("Safe’s transaction service has no record of this proposal. Tracking cannot continue here — check the proposal in the Safe app; if it exists there, it will still take effect once executed.");
109
+ }
110
+ }
111
+ }
112
+ catch (error) {
113
+ if (error instanceof Error &&
114
+ /executed the proposal.*failed|no record of this proposal/i.test(error.message)) {
115
+ throw error;
116
+ }
117
+ // Other service/network failures are transient. Keep the already-created
118
+ // proposal pending instead of inviting a duplicate submission.
119
+ }
120
+ await new Promise((resolve, reject) => {
121
+ function onAbort() {
122
+ clearTimeout(timer);
123
+ reject(new DOMException("Safe execution wait aborted", "AbortError"));
124
+ }
125
+ const timer = setTimeout(() => {
126
+ options.signal?.removeEventListener("abort", onAbort);
127
+ resolve();
128
+ }, interval);
129
+ options.signal?.addEventListener("abort", onAbort, { once: true });
130
+ if (options.signal?.aborted)
131
+ onAbort();
132
+ });
133
+ }
134
+ }
135
+ //# sourceMappingURL=safeService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"safeService.js","sourceRoot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