@bananapus/nana-sdk-core 3.5.1 → 4.0.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.
- package/bin/wallet-check.mjs +489 -0
- package/dist/cjs/actions/suckerPairs.d.ts +5 -3
- package/dist/cjs/actions/suckerPairs.d.ts.map +1 -1
- package/dist/cjs/actions/suckerPairs.js +6 -26
- package/dist/cjs/actions/suckerPairs.js.map +1 -1
- package/dist/cjs/pause.d.ts +2 -0
- package/dist/cjs/pause.d.ts.map +1 -1
- package/dist/cjs/pause.js +17 -0
- package/dist/cjs/pause.js.map +1 -1
- package/dist/cjs/review/confirm.d.ts +52 -0
- package/dist/cjs/review/confirm.d.ts.map +1 -0
- package/dist/cjs/review/confirm.js +88 -0
- package/dist/cjs/review/confirm.js.map +1 -0
- package/dist/cjs/review/contractWrite.d.ts +5 -3
- package/dist/cjs/review/contractWrite.d.ts.map +1 -1
- package/dist/cjs/review/contractWrite.js +8 -7
- package/dist/cjs/review/contractWrite.js.map +1 -1
- package/dist/cjs/review/decode.d.ts +19 -1
- package/dist/cjs/review/decode.d.ts.map +1 -1
- package/dist/cjs/review/decode.js +30 -11
- package/dist/cjs/review/decode.js.map +1 -1
- package/dist/cjs/review/decodeCall.d.ts +21 -0
- package/dist/cjs/review/decodeCall.d.ts.map +1 -0
- package/dist/cjs/review/decodeCall.js +183 -0
- package/dist/cjs/review/decodeCall.js.map +1 -0
- package/dist/cjs/review/heldWrite.d.ts.map +1 -1
- package/dist/cjs/review/heldWrite.js +5 -4
- package/dist/cjs/review/heldWrite.js.map +1 -1
- package/dist/cjs/review/index.d.ts +11 -0
- package/dist/cjs/review/index.d.ts.map +1 -1
- package/dist/cjs/review/index.js +24 -0
- package/dist/cjs/review/index.js.map +1 -1
- package/dist/cjs/review/intents.d.ts +10 -0
- package/dist/cjs/review/intents.d.ts.map +1 -1
- package/dist/cjs/review/intents.js +13 -0
- package/dist/cjs/review/intents.js.map +1 -1
- package/dist/cjs/review/lineError.d.ts +34 -0
- package/dist/cjs/review/lineError.d.ts.map +1 -0
- package/dist/cjs/review/lineError.js +42 -0
- package/dist/cjs/review/lineError.js.map +1 -0
- package/dist/cjs/review/messages.d.ts +15 -3
- package/dist/cjs/review/messages.d.ts.map +1 -1
- package/dist/cjs/review/messages.js +16 -4
- package/dist/cjs/review/messages.js.map +1 -1
- package/dist/cjs/review/model.d.ts +149 -0
- package/dist/cjs/review/model.d.ts.map +1 -0
- package/dist/cjs/review/model.js +750 -0
- package/dist/cjs/review/model.js.map +1 -0
- package/dist/cjs/review/plan.d.ts +63 -0
- package/dist/cjs/review/plan.d.ts.map +1 -0
- package/dist/cjs/review/plan.js +149 -0
- package/dist/cjs/review/plan.js.map +1 -0
- package/dist/cjs/review/react/index.d.ts +1 -0
- package/dist/cjs/review/react/index.d.ts.map +1 -1
- package/dist/cjs/review/react/index.js +1 -0
- package/dist/cjs/review/react/index.js.map +1 -1
- package/dist/cjs/review/react/useReviewedRun.d.ts +96 -0
- package/dist/cjs/review/react/useReviewedRun.d.ts.map +1 -0
- package/dist/cjs/review/react/useReviewedRun.js +261 -0
- package/dist/cjs/review/react/useReviewedRun.js.map +1 -0
- package/dist/cjs/review/receipt.d.ts +4 -1
- package/dist/cjs/review/receipt.d.ts.map +1 -1
- package/dist/cjs/review/receipt.js +7 -3
- package/dist/cjs/review/receipt.js.map +1 -1
- package/dist/cjs/review/relayr.d.ts +13 -4
- package/dist/cjs/review/relayr.d.ts.map +1 -1
- package/dist/cjs/review/relayr.js +51 -8
- package/dist/cjs/review/relayr.js.map +1 -1
- package/dist/cjs/review/relayrSend.d.ts +135 -0
- package/dist/cjs/review/relayrSend.d.ts.map +1 -0
- package/dist/cjs/review/relayrSend.js +943 -0
- package/dist/cjs/review/relayrSend.js.map +1 -0
- package/dist/cjs/review/reviewQueue.d.ts +10 -9
- package/dist/cjs/review/reviewQueue.d.ts.map +1 -1
- package/dist/cjs/review/reviewQueue.js +19 -29
- package/dist/cjs/review/reviewQueue.js.map +1 -1
- package/dist/cjs/review/reviewRequests.d.ts +86 -0
- package/dist/cjs/review/reviewRequests.d.ts.map +1 -0
- package/dist/cjs/review/reviewRequests.js +266 -0
- package/dist/cjs/review/reviewRequests.js.map +1 -0
- package/dist/cjs/review/safeRelayr.d.ts +3 -1
- package/dist/cjs/review/safeRelayr.d.ts.map +1 -1
- package/dist/cjs/review/safeRelayr.js +5 -1
- package/dist/cjs/review/safeRelayr.js.map +1 -1
- package/dist/cjs/review/safeSend.d.ts +69 -0
- package/dist/cjs/review/safeSend.d.ts.map +1 -0
- package/dist/cjs/review/safeSend.js +308 -0
- package/dist/cjs/review/safeSend.js.map +1 -0
- package/dist/cjs/review/send.d.ts +241 -0
- package/dist/cjs/review/send.d.ts.map +1 -0
- package/dist/cjs/review/send.js +1017 -0
- package/dist/cjs/review/send.js.map +1 -0
- package/dist/cjs/review/sequence.d.ts +77 -0
- package/dist/cjs/review/sequence.d.ts.map +1 -0
- package/dist/cjs/review/sequence.js +232 -0
- package/dist/cjs/review/sequence.js.map +1 -0
- package/dist/cjs/review/sign.d.ts +109 -0
- package/dist/cjs/review/sign.d.ts.map +1 -0
- package/dist/cjs/review/sign.js +374 -0
- package/dist/cjs/review/sign.js.map +1 -0
- package/dist/cjs/review/simulation.d.ts +41 -2
- package/dist/cjs/review/simulation.d.ts.map +1 -1
- package/dist/cjs/review/simulation.js +99 -29
- package/dist/cjs/review/simulation.js.map +1 -1
- package/dist/cjs/review/transaction-message.d.ts +13 -0
- package/dist/cjs/review/transaction-message.d.ts.map +1 -1
- package/dist/cjs/review/transaction-message.js +25 -0
- package/dist/cjs/review/transaction-message.js.map +1 -1
- package/dist/cjs/review/transactionReview.d.ts +27 -19
- package/dist/cjs/review/transactionReview.d.ts.map +1 -1
- package/dist/cjs/review/transactionReview.js +22 -63
- package/dist/cjs/review/transactionReview.js.map +1 -1
- package/dist/cjs/review/wallet.d.ts +82 -0
- package/dist/cjs/review/wallet.d.ts.map +1 -0
- package/dist/cjs/review/wallet.js +157 -0
- package/dist/cjs/review/wallet.js.map +1 -0
- package/dist/cjs/review/writeHold.d.ts +100 -12
- package/dist/cjs/review/writeHold.d.ts.map +1 -1
- package/dist/cjs/review/writeHold.js +61 -13
- package/dist/cjs/review/writeHold.js.map +1 -1
- package/dist/cjs/review/writeRecovery.d.ts +6 -1
- package/dist/cjs/review/writeRecovery.d.ts.map +1 -1
- package/dist/cjs/review/writeRecovery.js +108 -40
- package/dist/cjs/review/writeRecovery.js.map +1 -1
- package/dist/cjs/safeService.d.ts +27 -4
- package/dist/cjs/safeService.d.ts.map +1 -1
- package/dist/cjs/safeService.js +120 -3
- package/dist/cjs/safeService.js.map +1 -1
- package/dist/cjs/testing.d.ts +24 -0
- package/dist/cjs/testing.d.ts.map +1 -1
- package/dist/cjs/testing.js +26 -1
- package/dist/cjs/testing.js.map +1 -1
- package/dist/cjs/v6/defifa.d.ts.map +1 -1
- package/dist/cjs/v6/defifa.js +24 -23
- package/dist/cjs/v6/defifa.js.map +1 -1
- package/dist/cjs/v6/executionErrors.d.ts.map +1 -1
- package/dist/cjs/v6/executionErrors.js +3 -2
- package/dist/cjs/v6/executionErrors.js.map +1 -1
- package/dist/cjs/v6/pay.d.ts +25 -7
- package/dist/cjs/v6/pay.d.ts.map +1 -1
- package/dist/cjs/v6/pay.js +168 -40
- package/dist/cjs/v6/pay.js.map +1 -1
- package/dist/cjs/v6/suckers.d.ts +30 -0
- package/dist/cjs/v6/suckers.d.ts.map +1 -1
- package/dist/cjs/v6/suckers.js +69 -5
- package/dist/cjs/v6/suckers.js.map +1 -1
- package/dist/esm/actions/suckerPairs.d.ts +5 -3
- package/dist/esm/actions/suckerPairs.d.ts.map +1 -1
- package/dist/esm/actions/suckerPairs.js +7 -27
- package/dist/esm/actions/suckerPairs.js.map +1 -1
- package/dist/esm/pause.d.ts +2 -0
- package/dist/esm/pause.d.ts.map +1 -1
- package/dist/esm/pause.js +16 -0
- package/dist/esm/pause.js.map +1 -1
- package/dist/esm/review/confirm.d.ts +52 -0
- package/dist/esm/review/confirm.d.ts.map +1 -0
- package/dist/esm/review/confirm.js +83 -0
- package/dist/esm/review/confirm.js.map +1 -0
- package/dist/esm/review/contractWrite.d.ts +5 -3
- package/dist/esm/review/contractWrite.d.ts.map +1 -1
- package/dist/esm/review/contractWrite.js +8 -7
- package/dist/esm/review/contractWrite.js.map +1 -1
- package/dist/esm/review/decode.d.ts +19 -1
- package/dist/esm/review/decode.d.ts.map +1 -1
- package/dist/esm/review/decode.js +29 -14
- package/dist/esm/review/decode.js.map +1 -1
- package/dist/esm/review/decodeCall.d.ts +21 -0
- package/dist/esm/review/decodeCall.d.ts.map +1 -0
- package/dist/esm/review/decodeCall.js +180 -0
- package/dist/esm/review/decodeCall.js.map +1 -0
- package/dist/esm/review/heldWrite.d.ts.map +1 -1
- package/dist/esm/review/heldWrite.js +5 -4
- package/dist/esm/review/heldWrite.js.map +1 -1
- package/dist/esm/review/index.d.ts +11 -0
- package/dist/esm/review/index.d.ts.map +1 -1
- package/dist/esm/review/index.js +11 -0
- package/dist/esm/review/index.js.map +1 -1
- package/dist/esm/review/intents.d.ts +10 -0
- package/dist/esm/review/intents.d.ts.map +1 -1
- package/dist/esm/review/intents.js +12 -0
- package/dist/esm/review/intents.js.map +1 -1
- package/dist/esm/review/lineError.d.ts +34 -0
- package/dist/esm/review/lineError.d.ts.map +1 -0
- package/dist/esm/review/lineError.js +36 -0
- package/dist/esm/review/lineError.js.map +1 -0
- package/dist/esm/review/messages.d.ts +15 -3
- package/dist/esm/review/messages.d.ts.map +1 -1
- package/dist/esm/review/messages.js +15 -3
- package/dist/esm/review/messages.js.map +1 -1
- package/dist/esm/review/model.d.ts +149 -0
- package/dist/esm/review/model.d.ts.map +1 -0
- package/dist/esm/review/model.js +746 -0
- package/dist/esm/review/model.js.map +1 -0
- package/dist/esm/review/plan.d.ts +63 -0
- package/dist/esm/review/plan.d.ts.map +1 -0
- package/dist/esm/review/plan.js +141 -0
- package/dist/esm/review/plan.js.map +1 -0
- package/dist/esm/review/react/index.d.ts +1 -0
- package/dist/esm/review/react/index.d.ts.map +1 -1
- package/dist/esm/review/react/index.js +1 -0
- package/dist/esm/review/react/index.js.map +1 -1
- package/dist/esm/review/react/useReviewedRun.d.ts +96 -0
- package/dist/esm/review/react/useReviewedRun.d.ts.map +1 -0
- package/dist/esm/review/react/useReviewedRun.js +257 -0
- package/dist/esm/review/react/useReviewedRun.js.map +1 -0
- package/dist/esm/review/receipt.d.ts +4 -1
- package/dist/esm/review/receipt.d.ts.map +1 -1
- package/dist/esm/review/receipt.js +6 -2
- package/dist/esm/review/receipt.js.map +1 -1
- package/dist/esm/review/relayr.d.ts +13 -4
- package/dist/esm/review/relayr.d.ts.map +1 -1
- package/dist/esm/review/relayr.js +50 -8
- package/dist/esm/review/relayr.js.map +1 -1
- package/dist/esm/review/relayrSend.d.ts +135 -0
- package/dist/esm/review/relayrSend.d.ts.map +1 -0
- package/dist/esm/review/relayrSend.js +934 -0
- package/dist/esm/review/relayrSend.js.map +1 -0
- package/dist/esm/review/reviewQueue.d.ts +10 -9
- package/dist/esm/review/reviewQueue.d.ts.map +1 -1
- package/dist/esm/review/reviewQueue.js +17 -26
- package/dist/esm/review/reviewQueue.js.map +1 -1
- package/dist/esm/review/reviewRequests.d.ts +86 -0
- package/dist/esm/review/reviewRequests.d.ts.map +1 -0
- package/dist/esm/review/reviewRequests.js +263 -0
- package/dist/esm/review/reviewRequests.js.map +1 -0
- package/dist/esm/review/safeRelayr.d.ts +3 -1
- package/dist/esm/review/safeRelayr.d.ts.map +1 -1
- package/dist/esm/review/safeRelayr.js +5 -1
- package/dist/esm/review/safeRelayr.js.map +1 -1
- package/dist/esm/review/safeSend.d.ts +69 -0
- package/dist/esm/review/safeSend.d.ts.map +1 -0
- package/dist/esm/review/safeSend.js +303 -0
- package/dist/esm/review/safeSend.js.map +1 -0
- package/dist/esm/review/send.d.ts +241 -0
- package/dist/esm/review/send.d.ts.map +1 -0
- package/dist/esm/review/send.js +1011 -0
- package/dist/esm/review/send.js.map +1 -0
- package/dist/esm/review/sequence.d.ts +77 -0
- package/dist/esm/review/sequence.d.ts.map +1 -0
- package/dist/esm/review/sequence.js +223 -0
- package/dist/esm/review/sequence.js.map +1 -0
- package/dist/esm/review/sign.d.ts +109 -0
- package/dist/esm/review/sign.d.ts.map +1 -0
- package/dist/esm/review/sign.js +368 -0
- package/dist/esm/review/sign.js.map +1 -0
- package/dist/esm/review/simulation.d.ts +41 -2
- package/dist/esm/review/simulation.d.ts.map +1 -1
- package/dist/esm/review/simulation.js +95 -29
- package/dist/esm/review/simulation.js.map +1 -1
- package/dist/esm/review/transaction-message.d.ts +13 -0
- package/dist/esm/review/transaction-message.d.ts.map +1 -1
- package/dist/esm/review/transaction-message.js +23 -0
- package/dist/esm/review/transaction-message.js.map +1 -1
- package/dist/esm/review/transactionReview.d.ts +27 -19
- package/dist/esm/review/transactionReview.d.ts.map +1 -1
- package/dist/esm/review/transactionReview.js +19 -56
- package/dist/esm/review/transactionReview.js.map +1 -1
- package/dist/esm/review/wallet.d.ts +82 -0
- package/dist/esm/review/wallet.d.ts.map +1 -0
- package/dist/esm/review/wallet.js +150 -0
- package/dist/esm/review/wallet.js.map +1 -0
- package/dist/esm/review/writeHold.d.ts +100 -12
- package/dist/esm/review/writeHold.d.ts.map +1 -1
- package/dist/esm/review/writeHold.js +59 -13
- package/dist/esm/review/writeHold.js.map +1 -1
- package/dist/esm/review/writeRecovery.d.ts +6 -1
- package/dist/esm/review/writeRecovery.d.ts.map +1 -1
- package/dist/esm/review/writeRecovery.js +111 -43
- package/dist/esm/review/writeRecovery.js.map +1 -1
- package/dist/esm/safeService.d.ts +27 -4
- package/dist/esm/safeService.d.ts.map +1 -1
- package/dist/esm/safeService.js +119 -4
- package/dist/esm/safeService.js.map +1 -1
- package/dist/esm/testing.d.ts +24 -0
- package/dist/esm/testing.d.ts.map +1 -1
- package/dist/esm/testing.js +23 -1
- package/dist/esm/testing.js.map +1 -1
- package/dist/esm/v6/defifa.d.ts.map +1 -1
- package/dist/esm/v6/defifa.js +24 -23
- package/dist/esm/v6/defifa.js.map +1 -1
- package/dist/esm/v6/executionErrors.d.ts.map +1 -1
- package/dist/esm/v6/executionErrors.js +3 -2
- package/dist/esm/v6/executionErrors.js.map +1 -1
- package/dist/esm/v6/pay.d.ts +25 -7
- package/dist/esm/v6/pay.d.ts.map +1 -1
- package/dist/esm/v6/pay.js +166 -39
- package/dist/esm/v6/pay.js.map +1 -1
- package/dist/esm/v6/suckers.d.ts +30 -0
- package/dist/esm/v6/suckers.d.ts.map +1 -1
- package/dist/esm/v6/suckers.js +67 -5
- package/dist/esm/v6/suckers.js.map +1 -1
- package/package.json +11 -2
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.proposeReviewedSafeTransaction = proposeReviewedSafeTransaction;
|
|
4
|
+
exports.confirmReviewedSafeTransaction = confirmReviewedSafeTransaction;
|
|
5
|
+
exports.executeReviewedSafeTransaction = executeReviewedSafeTransaction;
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const safe_js_1 = require("../safe.js");
|
|
8
|
+
const safeService_js_1 = require("../safeService.js");
|
|
9
|
+
const intents_js_1 = require("./intents.js");
|
|
10
|
+
const receipt_js_1 = require("./receipt.js");
|
|
11
|
+
const send_js_1 = require("./send.js");
|
|
12
|
+
const sign_js_1 = require("./sign.js");
|
|
13
|
+
const simulation_js_1 = require("./simulation.js");
|
|
14
|
+
const wallet_js_1 = require("./wallet.js");
|
|
15
|
+
const UNVERIFIED = "Could not verify this Safe onchain.";
|
|
16
|
+
const SAFE_CHANGED = "The Safe policy or nonce changed. Review the transaction again.";
|
|
17
|
+
const REFUND = "This transaction pays a gas refund, so it can't be executed here.";
|
|
18
|
+
function connectedAccount(deps) {
|
|
19
|
+
const account = deps.adapter.account();
|
|
20
|
+
if (!account)
|
|
21
|
+
throw new Error("Connect a wallet first.");
|
|
22
|
+
return account;
|
|
23
|
+
}
|
|
24
|
+
function requireService(chainId) {
|
|
25
|
+
if (!(0, safeService_js_1.hasSafeService)(chainId)) {
|
|
26
|
+
throw new Error(`Safe does not host a transaction service on chain ${chainId}.`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The Safe's live policy and nonce. Fails closed on anything but a recognized
|
|
31
|
+
* Safe whose every module was read: a module can change the policy without
|
|
32
|
+
* moving the nonce.
|
|
33
|
+
*/
|
|
34
|
+
async function liveSafe(client, safe) {
|
|
35
|
+
const [identity, nonce] = await Promise.all([
|
|
36
|
+
(0, safe_js_1.readAuthorityIdentity)(client, safe),
|
|
37
|
+
(0, safe_js_1.readBoundedSafeNonce)(client, safe),
|
|
38
|
+
]);
|
|
39
|
+
if (identity?.kind !== "safe" ||
|
|
40
|
+
!identity.modules ||
|
|
41
|
+
nonce === null ||
|
|
42
|
+
nonce > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
43
|
+
throw new Error(UNVERIFIED);
|
|
44
|
+
}
|
|
45
|
+
return { identity, nonce: Number(nonce) };
|
|
46
|
+
}
|
|
47
|
+
/** Throws unless `after` is `before`: the same policy, modules and nonce. */
|
|
48
|
+
function requireUnchanged(before, after) {
|
|
49
|
+
if (JSON.stringify(before) !== JSON.stringify(after)) {
|
|
50
|
+
throw new Error(SAFE_CHANGED);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function requireSigner(state, account) {
|
|
54
|
+
if (!state.identity.owners.some((owner) => (0, viem_1.isAddressEqual)(owner, account))) {
|
|
55
|
+
throw new Error("The connected wallet is not a signer of this Safe.");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/** A pending transaction may wait behind others; an executed one must be next. */
|
|
59
|
+
function requireNonce(state, tx, mode) {
|
|
60
|
+
const nonce = (0, safeService_js_1.safeTransactionMessage)(tx).nonce;
|
|
61
|
+
const live = BigInt(state.nonce);
|
|
62
|
+
if (mode === "execute" ? nonce !== live : nonce < live) {
|
|
63
|
+
throw new Error(`Safe transaction #${tx.nonce} is stale or does not match the live nonce.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** `tx` read once, so a record changed after review is not what is sent. */
|
|
67
|
+
function snapshot(tx) {
|
|
68
|
+
const copy = structuredClone(tx);
|
|
69
|
+
if ((0, safeService_js_1.safeTransactionHasRefund)(copy))
|
|
70
|
+
throw new Error(REFUND);
|
|
71
|
+
return copy;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Signs `tx` as `account`, an owner, through {@link signReviewed}'s Safe
|
|
75
|
+
* transaction review. The Safe's policy and nonce must not move while the
|
|
76
|
+
* review is open, checked before the wallet is asked, nor while the wallet
|
|
77
|
+
* is open, checked once it answers.
|
|
78
|
+
*/
|
|
79
|
+
async function signAsOwner(input, deps) {
|
|
80
|
+
const { chainId, safe, account, tx, context, title, beforePost, plan } = input;
|
|
81
|
+
const client = deps.clientFor(chainId);
|
|
82
|
+
const before = await liveSafe(client, safe);
|
|
83
|
+
requireSigner(before, account);
|
|
84
|
+
requireNonce(before, tx, "pending");
|
|
85
|
+
const unchanged = async () => requireUnchanged(before, await liveSafe(client, safe));
|
|
86
|
+
const [signature] = await (0, sign_js_1.signReviewed)([{ kind: "safe-tx", chainId, safe, tx }], {
|
|
87
|
+
account,
|
|
88
|
+
...(title ? { title } : {}),
|
|
89
|
+
...(context ? { context } : {}),
|
|
90
|
+
...(plan ? { plan } : {}),
|
|
91
|
+
reverify: unchanged,
|
|
92
|
+
}, deps);
|
|
93
|
+
await beforePost?.();
|
|
94
|
+
await unchanged();
|
|
95
|
+
return signature;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Proposes `calls` to `safe`'s owners through Safe's transaction service: one
|
|
99
|
+
* zero-refund Safe transaction, a CALL for one call or a MultiSendCallOnly
|
|
100
|
+
* batch for several, signed by the connected owner after one review. It takes
|
|
101
|
+
* the nonce after everything already queued. A queued proposal of exactly
|
|
102
|
+
* these calls is confirmed instead, or, when this owner already confirmed it,
|
|
103
|
+
* returned as it is.
|
|
104
|
+
*
|
|
105
|
+
* Mirrors jbm `src/lib/safe.ts` `runSafeCalls` (service path), `proposeSafeTx`
|
|
106
|
+
* and `signSafeTx` (`:331-420`).
|
|
107
|
+
*/
|
|
108
|
+
async function proposeReviewedSafeTransaction(input, deps) {
|
|
109
|
+
const { chainId, safe, context, title, origin = "Juicebox", service, plan, } = input;
|
|
110
|
+
requireService(chainId);
|
|
111
|
+
const calls = [...input.calls].map((call) => {
|
|
112
|
+
const { chainId: on, to, data, value } = call;
|
|
113
|
+
if (on !== chainId) {
|
|
114
|
+
throw new Error(`Every call of a Safe proposal must be on chain ${chainId}.`);
|
|
115
|
+
}
|
|
116
|
+
return { to, data, value: value ?? 0n };
|
|
117
|
+
});
|
|
118
|
+
if (!calls.length)
|
|
119
|
+
throw new Error("There is no transaction to review.");
|
|
120
|
+
const account = connectedAccount(deps);
|
|
121
|
+
const state = await liveSafe(deps.clientFor(chainId), safe);
|
|
122
|
+
requireSigner(state, account);
|
|
123
|
+
// An outage must not read as an empty queue: the proposal would take a
|
|
124
|
+
// queued nonce and strand one of the two.
|
|
125
|
+
const pending = await (0, safeService_js_1.listPendingSafeTransactions)(chainId, safe, state.nonce, service);
|
|
126
|
+
const build = (nonce) => calls.length === 1
|
|
127
|
+
? (0, safeService_js_1.safeProposalFor)(calls[0], nonce)
|
|
128
|
+
: (0, safeService_js_1.safeBatchProposalFor)(calls, nonce);
|
|
129
|
+
const shape = (0, safeService_js_1.safeTransactionMessage)(build(state.nonce));
|
|
130
|
+
const queued = pending.find((tx) => (0, safeService_js_1.safeTransactionMatchesCall)(tx, shape));
|
|
131
|
+
if (queued) {
|
|
132
|
+
const confirmed = (0, safeService_js_1.usableSafeConfirmations)(queued, state.identity.owners).some(({ owner }) => (0, viem_1.isAddressEqual)(owner, account));
|
|
133
|
+
if (confirmed) {
|
|
134
|
+
return { safeTxHash: (0, safeService_js_1.canonicalSafeTxHash)(chainId, safe, queued) };
|
|
135
|
+
}
|
|
136
|
+
return confirmAs(account, {
|
|
137
|
+
chainId,
|
|
138
|
+
safe,
|
|
139
|
+
tx: queued,
|
|
140
|
+
...(context ? { context } : {}),
|
|
141
|
+
...(plan ? { plan } : {}),
|
|
142
|
+
service,
|
|
143
|
+
}, deps);
|
|
144
|
+
}
|
|
145
|
+
const nonce = (0, safeService_js_1.nextProposalNonce)(state.nonce, pending);
|
|
146
|
+
const tx = build(nonce);
|
|
147
|
+
const safeTxHash = (0, safeService_js_1.safeTransactionHash)(chainId, safe, tx);
|
|
148
|
+
const signature = await signAsOwner({
|
|
149
|
+
chainId,
|
|
150
|
+
safe,
|
|
151
|
+
account,
|
|
152
|
+
tx,
|
|
153
|
+
context,
|
|
154
|
+
title,
|
|
155
|
+
...(plan ? { plan } : {}),
|
|
156
|
+
// Another proposal queued at this nonce meanwhile would be replaced by this one.
|
|
157
|
+
beforePost: async () => {
|
|
158
|
+
const since = await (0, safeService_js_1.listPendingSafeTransactions)(chainId, safe, state.nonce, service);
|
|
159
|
+
if (since.some((other) => other.nonce === nonce)) {
|
|
160
|
+
throw new Error(`Another proposal took Safe nonce ${nonce} during review. Nothing was proposed; review it again.`);
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
}, deps);
|
|
164
|
+
try {
|
|
165
|
+
await (0, safeService_js_1.proposeSafeTransaction)(chainId, safe, tx, { sender: account, signature, origin }, service);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
// The service may have queued it and lost its answer: a retry must find
|
|
169
|
+
// it, not propose the same calls again at the next nonce. Only this
|
|
170
|
+
// owner's own signature on the record proves this proposal landed.
|
|
171
|
+
const queued = await (0, safeService_js_1.readSafeTransaction)(chainId, safe, safeTxHash, service).then((record) => Array.isArray(record.confirmations) &&
|
|
172
|
+
record.confirmations.some((confirmation) => typeof confirmation?.owner === "string" &&
|
|
173
|
+
(0, viem_1.isAddressEqual)(confirmation.owner, account) &&
|
|
174
|
+
confirmation.signature?.toLowerCase() === signature.toLowerCase()), () => false);
|
|
175
|
+
if (!queued)
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
return { safeTxHash };
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Adds the connected owner's signature to the queued `tx`, after one review
|
|
182
|
+
* of exactly its fields, safeTxGas included. Refuses a record whose fields do
|
|
183
|
+
* not hash to the hash it advertises, one that pays a gas refund, and one
|
|
184
|
+
* whose nonce the Safe has passed.
|
|
185
|
+
*
|
|
186
|
+
* Mirrors jbm `src/lib/safe.ts` `confirmSafeTx` and `signSafeTx`
|
|
187
|
+
* (`:331-420`).
|
|
188
|
+
*/
|
|
189
|
+
async function confirmReviewedSafeTransaction(input, deps) {
|
|
190
|
+
return confirmAs(connectedAccount(deps), input, deps);
|
|
191
|
+
}
|
|
192
|
+
async function confirmAs(account, input, deps) {
|
|
193
|
+
const { chainId, safe, context, service, plan } = input;
|
|
194
|
+
const tx = snapshot(input.tx);
|
|
195
|
+
requireService(chainId);
|
|
196
|
+
const safeTxHash = (0, safeService_js_1.canonicalSafeTxHash)(chainId, safe, tx);
|
|
197
|
+
const signature = await signAsOwner({ chainId, safe, account, tx, context, ...(plan ? { plan } : {}) }, deps);
|
|
198
|
+
await (0, safeService_js_1.submitSafeConfirmation)(chainId, safe, tx, signature, service);
|
|
199
|
+
return { safeTxHash };
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Executes the queued `tx` from the connected wallet, signed by its usable
|
|
203
|
+
* current-owner confirmations, through {@link sendReviewed}: one review, the
|
|
204
|
+
* step's write hold, and before the wallet opens, the Safe's policy and nonce
|
|
205
|
+
* checked unchanged and the exact call simulated to return true. The result
|
|
206
|
+
* is decided by the Safe's own ExecutionSuccess for the exact hash, never by
|
|
207
|
+
* the receipt's status alone. A Safe-connected wallet's proposal is returned
|
|
208
|
+
* as `proposed`.
|
|
209
|
+
*
|
|
210
|
+
* Mirrors jbm `src/lib/safe.ts` `executeSafeTx` and `sendContractAndConfirm`
|
|
211
|
+
* (`:595-760`).
|
|
212
|
+
*/
|
|
213
|
+
async function executeReviewedSafeTransaction(input, deps) {
|
|
214
|
+
const { chainId, safe, context } = input;
|
|
215
|
+
const tx = snapshot(input.tx);
|
|
216
|
+
const account = connectedAccount(deps);
|
|
217
|
+
// A Safe app wraps the call in a transaction of its own Safe, which spends
|
|
218
|
+
// the nonce this one is signed for.
|
|
219
|
+
if ((0, viem_1.isAddressEqual)(account, safe)) {
|
|
220
|
+
throw new Error("A Safe can't execute its own queued transaction from inside itself. Execute it from an owner's wallet.");
|
|
221
|
+
}
|
|
222
|
+
const safeTxHash = (0, safeService_js_1.canonicalSafeTxHash)(chainId, safe, tx);
|
|
223
|
+
const client = deps.clientFor(chainId);
|
|
224
|
+
const state = await liveSafe(client, safe);
|
|
225
|
+
requireNonce(state, tx, "execute");
|
|
226
|
+
const { owners, threshold } = state.identity;
|
|
227
|
+
const usable = (0, safeService_js_1.usableSafeConfirmations)(tx, owners);
|
|
228
|
+
if (usable.length < threshold) {
|
|
229
|
+
throw new Error(`This transaction needs ${threshold} current-owner signature${threshold === 1 ? "" : "s"} before it can execute.`);
|
|
230
|
+
}
|
|
231
|
+
// Safe accepts the executor's own approval (v = 1) without checking its
|
|
232
|
+
// hash, so it does not bind the execution to this nonce: with it alone, a
|
|
233
|
+
// nonce spent meanwhile would run the same call again at the next one.
|
|
234
|
+
const bound = usable.filter(({ owner, signature }) => !(0, viem_1.isAddressEqual)(owner, account) ||
|
|
235
|
+
(!!signature && signature.slice(130, 132) !== "01"));
|
|
236
|
+
if (!bound.length) {
|
|
237
|
+
throw new Error("Your own approval alone does not bind this execution to its nonce. Sign the Safe transaction first.");
|
|
238
|
+
}
|
|
239
|
+
const args = (0, safeService_js_1.safeExecutionArgs)({ ...tx, confirmations: bound.length >= threshold ? bound : usable }, owners);
|
|
240
|
+
const data = (0, viem_1.encodeFunctionData)({
|
|
241
|
+
abi: safeService_js_1.SAFE_EXEC_ABI,
|
|
242
|
+
functionName: "execTransaction",
|
|
243
|
+
args,
|
|
244
|
+
});
|
|
245
|
+
/**
|
|
246
|
+
* Before the wallet opens: the Safe unchanged since review, and the exact
|
|
247
|
+
* call simulated to return true. A Safe signed with safeTxGas or gasPrice
|
|
248
|
+
* returns false for a failed call instead of reverting.
|
|
249
|
+
*/
|
|
250
|
+
const stillExecutes = async () => {
|
|
251
|
+
requireUnchanged(state, await liveSafe(client, safe));
|
|
252
|
+
let executes = false;
|
|
253
|
+
try {
|
|
254
|
+
executes = (0, viem_1.decodeFunctionResult)({
|
|
255
|
+
abi: safeService_js_1.SAFE_EXEC_ABI,
|
|
256
|
+
functionName: "execTransaction",
|
|
257
|
+
data: await (0, simulation_js_1.simulateStateChangingTransaction)(client, {
|
|
258
|
+
from: account,
|
|
259
|
+
to: safe,
|
|
260
|
+
data,
|
|
261
|
+
}),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// A revert or an unreadable answer is not an execution.
|
|
266
|
+
}
|
|
267
|
+
if (executes !== true) {
|
|
268
|
+
throw new Error(`Safe transaction #${tx.nonce} would not execute successfully.`);
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
await (0, wallet_js_1.walletReady)(deps.adapter);
|
|
272
|
+
// A self-reviewing wallet sends with no step of core's before it.
|
|
273
|
+
if (deps.adapter.kind === "self-reviewing")
|
|
274
|
+
await stillExecutes();
|
|
275
|
+
const result = await (0, send_js_1.sendReviewed)({
|
|
276
|
+
account,
|
|
277
|
+
calls: [
|
|
278
|
+
{
|
|
279
|
+
chainId,
|
|
280
|
+
to: safe,
|
|
281
|
+
data,
|
|
282
|
+
abi: safeService_js_1.SAFE_EXEC_ABI,
|
|
283
|
+
functionName: "execTransaction",
|
|
284
|
+
args,
|
|
285
|
+
label: `Execute Safe transaction #${tx.nonce}`,
|
|
286
|
+
contractName: "Safe",
|
|
287
|
+
intent: (0, intents_js_1.safeExecutionIntent)({ chainId, safe, safeTxHash }),
|
|
288
|
+
},
|
|
289
|
+
],
|
|
290
|
+
...(context ? { context } : {}),
|
|
291
|
+
reverify: stillExecutes,
|
|
292
|
+
}, {
|
|
293
|
+
...deps,
|
|
294
|
+
// Done only once the Safe's own event says so, below.
|
|
295
|
+
onProgress: (progress) => {
|
|
296
|
+
if (progress.phase !== "done")
|
|
297
|
+
deps.onProgress?.(progress);
|
|
298
|
+
},
|
|
299
|
+
});
|
|
300
|
+
if (result.status !== "done")
|
|
301
|
+
return result;
|
|
302
|
+
const receipt = result.receipts[0] ??
|
|
303
|
+
(await (0, receipt_js_1.waitForTrackedReceipt)(client, result.hashes[0]));
|
|
304
|
+
(0, safeService_js_1.requireSafeExecutionSuccess)(receipt, safe, safeTxHash);
|
|
305
|
+
deps.onProgress?.({ step: 0, total: 1, phase: "done" });
|
|
306
|
+
return result;
|
|
307
|
+
}
|
|
308
|
+
//# sourceMappingURL=safeSend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"safeSend.js","sourceRoot":"","sources":["../../../src/review/safeSend.ts"],"names":[],"mappings":";;AAwLA,wEAqIC;AAWD,wEAaC;AA+BD,wEAoHC;AAxeD,+BAOc;AACd,wCAIoB;AACpB,sDAoB2B;AAC3B,6CAAmD;AAGnD,6CAAqD;AACrD,uCAKmB;AACnB,uCAAyC;AACzC,mDAAmE;AACnE,2CAA0C;AAI1C,MAAM,UAAU,GAAG,qCAAqC,CAAC;AACzD,MAAM,YAAY,GAChB,iEAAiE,CAAC;AACpE,MAAM,MAAM,GACV,mEAAmE,CAAC;AAEtE,SAAS,gBAAgB,CAAC,IAAsB;IAC9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;IACvC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IACzD,OAAO,OAAO,CAAC;A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KAAK,KAAK,MAAM;gBAAE,IAAI,CAAC,UAAU,EAAE,CAAC,QAAQ,CAAC,CAAC;QAC7D,CAAC;KACF,CACF,CAAC;IACF,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC;IAC5C,MAAM,OAAO,GACX,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;QAClB,CAAC,MAAM,IAAA,kCAAqB,EAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1D,IAAA,4CAA2B,EAAC,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC;IACvD,IAAI,CAAC,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;IACxD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { type Abi, type Address, type Hex, type PublicClient, type TransactionReceipt } from "viem";
|
|
2
|
+
import { type ReviewedWritePhase } from "./contractWrite.js";
|
|
3
|
+
import { type ReviewContextRow, type ReviewModel } from "./model.js";
|
|
4
|
+
import { type ReviewedPlan } from "./plan.js";
|
|
5
|
+
import { type ReviewedSequenceRecord } from "./sequence.js";
|
|
6
|
+
import { type ReviewedSignature } from "./sign.js";
|
|
7
|
+
import { type WalletAdapter } from "./wallet.js";
|
|
8
|
+
import { type WriteHold, type WriteHoldLegacySource } from "./writeHold.js";
|
|
9
|
+
import { type HeldWriteStorage } from "./writeRecovery.js";
|
|
10
|
+
export type ReviewedCall = {
|
|
11
|
+
chainId: number;
|
|
12
|
+
to: Address;
|
|
13
|
+
data: Hex;
|
|
14
|
+
value?: bigint;
|
|
15
|
+
/**
|
|
16
|
+
* The exact gas limit to send with, when the app fixes it (a saved gas
|
|
17
|
+
* envelope, say). It is shown and bound in the review, simulated and sent
|
|
18
|
+
* as it is, never estimated or padded. A Safe app proposes with safeTxGas 0
|
|
19
|
+
* whatever this is.
|
|
20
|
+
*/
|
|
21
|
+
gas?: bigint;
|
|
22
|
+
/**
|
|
23
|
+
* For a Safe app only, with `abi` and `functionName`: the indexes of the
|
|
24
|
+
* args (a fresh deadline) a proposal its Safe already queued may differ in
|
|
25
|
+
* and still be adopted instead of proposed twice. The queued data must
|
|
26
|
+
* decode with `abi` to the same function, encode back to exactly its bytes,
|
|
27
|
+
* and match every other arg; the target, value and operation must match as
|
|
28
|
+
* they are. Bound into the review. Unset compares exact bytes.
|
|
29
|
+
*/
|
|
30
|
+
adoptIgnoringArgs?: readonly number[];
|
|
31
|
+
/** When given, `data` must be exactly this function's encoding of `args`. */
|
|
32
|
+
abi?: Abi;
|
|
33
|
+
functionName?: string;
|
|
34
|
+
args?: readonly unknown[];
|
|
35
|
+
label?: string;
|
|
36
|
+
contractName?: string;
|
|
37
|
+
/** The hold namespace, as `useSafeTx`'s `TxSendOptions` today. */
|
|
38
|
+
intent?: string;
|
|
39
|
+
/** The keys an earlier version held this write under, as the hold's `open` takes them. */
|
|
40
|
+
legacy?: readonly WriteHoldLegacySource[];
|
|
41
|
+
/** Simulate on the previous step's receipt block. */
|
|
42
|
+
dependsOnPrior?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* The block where a prerequisite confirmed outside this run (an earlier
|
|
45
|
+
* approval, say) took effect: the call is simulated on the latest block,
|
|
46
|
+
* or on this one while the node has not reached it. Used where the call
|
|
47
|
+
* is simulated alone and not on a prior step's block; a resumed run
|
|
48
|
+
* simulates on the latest block.
|
|
49
|
+
*/
|
|
50
|
+
simulationBlockNumber?: bigint;
|
|
51
|
+
};
|
|
52
|
+
/** Where the step before this one confirmed. */
|
|
53
|
+
export type ReviewedPriorBlock = {
|
|
54
|
+
chainId: number;
|
|
55
|
+
blockNumber: bigint;
|
|
56
|
+
blockHash: Hex;
|
|
57
|
+
};
|
|
58
|
+
export type ReviewedAction = {
|
|
59
|
+
account: Address;
|
|
60
|
+
calls: readonly ReviewedCall[];
|
|
61
|
+
/**
|
|
62
|
+
* Signatures shown in the same prompt as `calls`, and signed after confirm,
|
|
63
|
+
* before the first send. A resumed sequence signs none.
|
|
64
|
+
*/
|
|
65
|
+
signatures?: readonly ReviewedSignature[];
|
|
66
|
+
title?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
confirmLabel?: string;
|
|
69
|
+
context?: readonly ReviewContextRow[];
|
|
70
|
+
/**
|
|
71
|
+
* A stale-state check before each step; it throws to stop with nothing
|
|
72
|
+
* sent. `prior` is where the previous step of the action confirmed (on its
|
|
73
|
+
* own chain), so the check can read state at or after it; undefined for
|
|
74
|
+
* the first step, or on resume when that step's receipt can't be read.
|
|
75
|
+
*/
|
|
76
|
+
reverify?: (call: ReviewedCall, index: number, prior: ReviewedPriorBlock | undefined) => Promise<void>;
|
|
77
|
+
/** The final synchronous gate before the wallet opens. */
|
|
78
|
+
assertWriteState?: () => void;
|
|
79
|
+
/** Refuses the action, before anything else (view-as, say). */
|
|
80
|
+
guard?: () => void;
|
|
81
|
+
/**
|
|
82
|
+
* A site's own record of a step at the wallet boundary, awaited: after its
|
|
83
|
+
* hold reserved it (and its journal saved it), right before the wallet
|
|
84
|
+
* opens. It throws to stop with nothing sent, which releases the step.
|
|
85
|
+
* `step` is the index in the whole action.
|
|
86
|
+
*/
|
|
87
|
+
beforeWallet?: (call: ReviewedCall, step: number) => void | Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Awaited when nothing was sent for a step whose `beforeWallet` began: a
|
|
90
|
+
* gate refused, `beforeWallet` threw, or the wallet rejected (4001). Never
|
|
91
|
+
* after an ambiguous failure.
|
|
92
|
+
*/
|
|
93
|
+
onUnsent?: (call: ReviewedCall, step: number) => void | Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Awaited once the wallet returned a step's hash, before its receipt is
|
|
96
|
+
* awaited: a Safe app's proposal hash (`safe`), or one its Safe already
|
|
97
|
+
* queued (`adopted`). A throw keeps the step pending, never unsent.
|
|
98
|
+
*/
|
|
99
|
+
onSubmitted?: (call: ReviewedCall, step: number, hash: Hex, sent: {
|
|
100
|
+
safe: boolean;
|
|
101
|
+
adopted: boolean;
|
|
102
|
+
}) => void | Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Awaited once a step's receipt shows it succeeded and its progress is
|
|
105
|
+
* saved, before the next step; on resume, for a step that went through
|
|
106
|
+
* while away, when its receipt can be read. A throw is ignored: the step
|
|
107
|
+
* went through. A Safe app's proposal is never told here: its hold's
|
|
108
|
+
* settlement is (`useReviewedRun`'s `done` and `receipt`).
|
|
109
|
+
*/
|
|
110
|
+
onConfirmed?: (call: ReviewedCall, step: number, receipt: TransactionReceipt) => void | Promise<void>;
|
|
111
|
+
/**
|
|
112
|
+
* Through a Safe app, every call goes to the Safe as one proposal (the
|
|
113
|
+
* app folds `sendCalls` into a MultiSend its signers approve once and run
|
|
114
|
+
* together, in order), under one hold: the first call's `intent`, or else
|
|
115
|
+
* `safeBatchIntent` of the calls. The calls must share a chain and
|
|
116
|
+
* the adapter must offer `sendCalls`. Nothing is journaled: the proposal
|
|
117
|
+
* runs whole or not at all. A resumed sequence, and any other wallet, sends
|
|
118
|
+
* the calls one by one.
|
|
119
|
+
*/
|
|
120
|
+
batch?: boolean;
|
|
121
|
+
/**
|
|
122
|
+
* Withdraws the review while it is open: the run ends as cancelled with
|
|
123
|
+
* nothing sent, and the prompt's own `signal` aborts so its UI closes.
|
|
124
|
+
* Once the review is confirmed it changes nothing.
|
|
125
|
+
*/
|
|
126
|
+
signal?: AbortSignal;
|
|
127
|
+
/**
|
|
128
|
+
* The site's key for this action (`payIntent(...)`, say). When set, the
|
|
129
|
+
* action is journaled once its review is confirmed, before the first
|
|
130
|
+
* wallet call, so {@link resumeReviewed} can finish it without sending a
|
|
131
|
+
* completed step again.
|
|
132
|
+
*/
|
|
133
|
+
scope?: string;
|
|
134
|
+
/**
|
|
135
|
+
* A plan the person already reviewed ({@link reviewPlan}): nothing is
|
|
136
|
+
* asked, and every call (and every call the `signatures` let someone run)
|
|
137
|
+
* is spent from it, or nothing is sent.
|
|
138
|
+
*/
|
|
139
|
+
plan?: ReviewedPlan;
|
|
140
|
+
};
|
|
141
|
+
export type ReviewedSendDeps = {
|
|
142
|
+
adapter: WalletAdapter;
|
|
143
|
+
clientFor: (chainId: number) => PublicClient;
|
|
144
|
+
hold: WriteHold;
|
|
145
|
+
onProgress?: (progress: ReviewedProgress) => void;
|
|
146
|
+
/** Self-reviewing adapters only: the model core would have shown. */
|
|
147
|
+
onPreview?: (model: ReviewModel) => void;
|
|
148
|
+
/** Where sequences are journaled: the hold's storage (the browser's, by default). */
|
|
149
|
+
storage?: HeldWriteStorage;
|
|
150
|
+
};
|
|
151
|
+
export type ReviewedProgress = {
|
|
152
|
+
step: number;
|
|
153
|
+
total: number;
|
|
154
|
+
phase: ReviewedWritePhase | "receipt" | "proposed" | "done";
|
|
155
|
+
hash?: Hex;
|
|
156
|
+
};
|
|
157
|
+
export type ReviewedResult = ({
|
|
158
|
+
status: "done";
|
|
159
|
+
hashes: Hex[];
|
|
160
|
+
receipts: TransactionReceipt[];
|
|
161
|
+
} | {
|
|
162
|
+
status: "proposed";
|
|
163
|
+
step: number;
|
|
164
|
+
safeTxHash: Hex;
|
|
165
|
+
}) & {
|
|
166
|
+
/** The action's `signatures`, signed in order, when it had any. */
|
|
167
|
+
signatures?: Hex[];
|
|
168
|
+
};
|
|
169
|
+
export declare const SAFE_BATCH_UNSUPPORTED_LINE = "This Safe connection can't propose these calls as one transaction. Nothing was sent.";
|
|
170
|
+
export declare const SAFE_BATCH_UNFOLLOWABLE_LINE = "Your Safe took this batch, but it can't be followed from here. Check your Safe before sending again.";
|
|
171
|
+
/** What {@link reviewPlan} reviews: calls from `account`, or from their own `from`. */
|
|
172
|
+
export type ReviewedPlanAction = Pick<ReviewedAction, "account" | "title" | "description" | "confirmLabel" | "context" | "signal"> & {
|
|
173
|
+
calls: readonly (ReviewedCall & {
|
|
174
|
+
/** Who sends the call: a Safe `account` owns, say, or "relayr" for one Relayr's own account runs. */
|
|
175
|
+
from?: Address | "relayr";
|
|
176
|
+
/**
|
|
177
|
+
* The Relayr round this call goes in, by the app's key: a
|
|
178
|
+
* `runRelayrReviewed` run, or a quote paid by `payRelayrReviewed` with
|
|
179
|
+
* this `relayrRound`. The review shows each round's fee bound (Relayr's
|
|
180
|
+
* stand-in quote plus `RELAYR_FEE_MARGIN_BPS`, paid on the round's
|
|
181
|
+
* payment chain); a round whose quote is within it pays with no prompt.
|
|
182
|
+
*/
|
|
183
|
+
relayrRound?: string;
|
|
184
|
+
})[];
|
|
185
|
+
/** Each Relayr round's payment chain, by its key: by default, the round's first call's chain. */
|
|
186
|
+
relayrRounds?: Readonly<Record<string, {
|
|
187
|
+
paymentChainId: number;
|
|
188
|
+
}>>;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* One review of calls an app then sends one by one, across chains and
|
|
192
|
+
* paths: core's prompt over exactly `action.calls`, simulated as their
|
|
193
|
+
* senders, and nothing else. The plan it returns lets {@link sendReviewed},
|
|
194
|
+
* `signReviewed`, `proposeReviewedSafeTransaction`, `payRelayrReviewed` and
|
|
195
|
+
* `runRelayrReviewed` skip their prompt for a call identical to one of its
|
|
196
|
+
* calls (account, chain, sender, target, data, value and gas: a call's
|
|
197
|
+
* exact gas limit, or a forward request's signed gas, is set before the
|
|
198
|
+
* review), each spent once, for {@link REVIEWED_PLAN_TTL_MS} after confirm.
|
|
199
|
+
* Anything else is refused.
|
|
200
|
+
*/
|
|
201
|
+
export declare function reviewPlan(action: ReviewedPlanAction, deps: Pick<ReviewedSendDeps, "clientFor">): Promise<ReviewedPlan>;
|
|
202
|
+
/**
|
|
203
|
+
* Sends one reviewed action: one call, or a sequence (approve then pay, say),
|
|
204
|
+
* reviewed once and sent without asking again.
|
|
205
|
+
*
|
|
206
|
+
* Core builds one model over every call and asks the registered review
|
|
207
|
+
* handler once ({@link registerReviewHandler}); nothing is sent unless the
|
|
208
|
+
* handler returns the confirmation core minted for that model. The
|
|
209
|
+
* review-time simulation runs while the review is open, and confirm never
|
|
210
|
+
* waits on it. Then, for each call in order: `reverify`, a check that the call
|
|
211
|
+
* still encodes to exactly the reviewed bytes, a simulation (at the previous
|
|
212
|
+
* step's receipt block when `dependsOnPrior`), and the send of those bytes
|
|
213
|
+
* through the adapter under the call's write hold, by
|
|
214
|
+
* `submitReviewedContractWrite`. The connected account must stay
|
|
215
|
+
* `action.account`, and the wallet on the call's chain. Each step waits for
|
|
216
|
+
* its receipt; a revert stops the sequence. A Safe-connected wallet's first
|
|
217
|
+
* step becomes a proposal, and the sequence stops there.
|
|
218
|
+
*
|
|
219
|
+
* The action's `signatures` show in the same model and prompt, and are
|
|
220
|
+
* signed after confirm and before the first send, as `signReviewed` signs.
|
|
221
|
+
*
|
|
222
|
+
* Only an explicit wallet rejection (EIP-1193 4001) releases a step's hold;
|
|
223
|
+
* any other failure once the wallet opened keeps it held.
|
|
224
|
+
*
|
|
225
|
+
* A self-reviewing adapter (Signa) is never prompted: `onPreview` gets the
|
|
226
|
+
* model, and the adapter gets the raw calls to review on its own page. An
|
|
227
|
+
* action with `signatures` is refused for it with EIP-1193 4200.
|
|
228
|
+
*/
|
|
229
|
+
export declare function sendReviewed(action: ReviewedAction, deps: ReviewedSendDeps): Promise<ReviewedResult>;
|
|
230
|
+
/**
|
|
231
|
+
* Finish a sequence {@link sendReviewed} saved under `record.scope`: the step
|
|
232
|
+
* whose wallet call opened is decided by its write hold first (still held is
|
|
233
|
+
* refused; a settled success counts as completed, its receipt's hash
|
|
234
|
+
* recorded), then every remaining step, and only those, is reviewed once
|
|
235
|
+
* more as one fresh model and sent as `sendReviewed` sends. `reverify` gets
|
|
236
|
+
* each step's original index in the action. Only `record.account` can resume
|
|
237
|
+
* it. The result's `hashes` are every completed step's, `receipts` this
|
|
238
|
+
* run's.
|
|
239
|
+
*/
|
|
240
|
+
export declare function resumeReviewed(record: ReviewedSequenceRecord, action: Pick<ReviewedAction, "reverify" | "assertWriteState" | "guard" | "context" | "title" | "beforeWallet" | "onUnsent" | "onSubmitted" | "onConfirmed" | "signal">, deps: ReviewedSendDeps): Promise<ReviewedResult>;
|
|
241
|
+
//# sourceMappingURL=send.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send.d.ts","sourceRoot":"","sources":["../../../src/review/send.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,MAAM,CAAC;AAEd,OAAO,EAIL,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAa5B,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAEjB,MAAM,YAAY,CAAC;AACpB,OAAO,EAML,KAAK,YAAY,EAClB,MAAM,WAAW,CAAC;AAInB,OAAO,EAQL,KAAK,sBAAsB,EAC5B,MAAM,eAAe,CAAC;AACvB,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,WAAW,CAAC;AAcnB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AACrB,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAEL,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,OAAO,CAAC;IACZ,IAAI,EAAE,GAAG,CAAC;IACV,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;;;;OAOG;IACH,iBAAiB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,6EAA6E;IAC7E,GAAG,CAAC,EAAE,GAAG,CAAC;IACV,YAAY,CAAC,EAAE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