@bananapus/nana-sdk-core 2.29.0 → 2.31.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/dist/cjs/review/index.d.ts +1 -0
- package/dist/cjs/review/index.d.ts.map +1 -1
- package/dist/cjs/review/index.js +1 -0
- package/dist/cjs/review/index.js.map +1 -1
- package/dist/cjs/review/messages.d.ts +43 -0
- package/dist/cjs/review/messages.d.ts.map +1 -0
- package/dist/cjs/review/messages.js +55 -0
- package/dist/cjs/review/messages.js.map +1 -0
- package/dist/cjs/review/relayr.d.ts +43 -7
- package/dist/cjs/review/relayr.d.ts.map +1 -1
- package/dist/cjs/review/relayr.js +141 -8
- package/dist/cjs/review/relayr.js.map +1 -1
- package/dist/cjs/review/safeRelayr.d.ts.map +1 -1
- package/dist/cjs/review/safeRelayr.js +23 -3
- package/dist/cjs/review/safeRelayr.js.map +1 -1
- package/dist/cjs/review/transaction-message.js +2 -2
- package/dist/cjs/review/transaction-message.js.map +1 -1
- package/dist/cjs/review/writeRecovery.d.ts +92 -7
- package/dist/cjs/review/writeRecovery.d.ts.map +1 -1
- package/dist/cjs/review/writeRecovery.js +473 -70
- package/dist/cjs/review/writeRecovery.js.map +1 -1
- package/dist/cjs/safeService.d.ts +18 -12
- package/dist/cjs/safeService.d.ts.map +1 -1
- package/dist/cjs/safeService.js +97 -9
- package/dist/cjs/safeService.js.map +1 -1
- package/dist/esm/review/index.d.ts +1 -0
- package/dist/esm/review/index.d.ts.map +1 -1
- package/dist/esm/review/index.js +1 -0
- package/dist/esm/review/index.js.map +1 -1
- package/dist/esm/review/messages.d.ts +43 -0
- package/dist/esm/review/messages.d.ts.map +1 -0
- package/dist/esm/review/messages.js +48 -0
- package/dist/esm/review/messages.js.map +1 -0
- package/dist/esm/review/relayr.d.ts +43 -7
- package/dist/esm/review/relayr.d.ts.map +1 -1
- package/dist/esm/review/relayr.js +139 -7
- package/dist/esm/review/relayr.js.map +1 -1
- package/dist/esm/review/safeRelayr.d.ts.map +1 -1
- package/dist/esm/review/safeRelayr.js +23 -3
- package/dist/esm/review/safeRelayr.js.map +1 -1
- package/dist/esm/review/transaction-message.js +2 -2
- package/dist/esm/review/transaction-message.js.map +1 -1
- package/dist/esm/review/writeRecovery.d.ts +92 -7
- package/dist/esm/review/writeRecovery.d.ts.map +1 -1
- package/dist/esm/review/writeRecovery.js +472 -72
- package/dist/esm/review/writeRecovery.js.map +1 -1
- package/dist/esm/safeService.d.ts +18 -12
- package/dist/esm/safeService.d.ts.map +1 -1
- package/dist/esm/safeService.js +97 -9
- package/dist/esm/safeService.js.map +1 -1
- package/package.json +3 -2
|
@@ -20,8 +20,19 @@ export type ReviewedWriteRecoveryRecord = Omit<ReviewedWriteRecoveryInput, "call
|
|
|
20
20
|
data: Hex;
|
|
21
21
|
value: string;
|
|
22
22
|
};
|
|
23
|
-
/** The identity returned by the wallet,
|
|
23
|
+
/** The identity returned by the wallet, or the exact call found at its nonce. */
|
|
24
24
|
hash?: Hex;
|
|
25
|
+
/** The account's next nonce when the wallet opened, as a decimal string. */
|
|
26
|
+
nonce?: string;
|
|
27
|
+
/** The block that nonce was read at, as a decimal string. */
|
|
28
|
+
fromBlock?: string;
|
|
29
|
+
/** The nonce the chain showed for `hash`'s own transaction: the nonce it was actually sent at. */
|
|
30
|
+
sentNonce?: string;
|
|
31
|
+
};
|
|
32
|
+
/** The account's next nonce and the block it was read at, from {@link readReviewedWriteNonce}. */
|
|
33
|
+
export type ReviewedWriteNonceEvidence = {
|
|
34
|
+
nonce: number | bigint;
|
|
35
|
+
blockNumber: bigint;
|
|
25
36
|
};
|
|
26
37
|
type RecoveryStorage = Pick<Storage, "getItem" | "setItem" | "removeItem">;
|
|
27
38
|
type RecoveryLocks = Pick<LockManager, "request">;
|
|
@@ -49,25 +60,99 @@ export declare function readBrowserWriteRecovery(input: ReviewedWriteRecoverySco
|
|
|
49
60
|
/** Exact reviewed evidence, independent of the reservation and submission identities. */
|
|
50
61
|
export declare function sameReviewedWrite(record: ReviewedWriteRecoveryRecord, input: ReviewedWriteRecoveryInput): boolean;
|
|
51
62
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
63
|
+
* The browser's Web Locks. Where a browser or wallet webview has none, an
|
|
64
|
+
* IndexedDB lease shared by the origin's tabs (one transaction, no visible
|
|
65
|
+
* delay; it waits only while another tab holds the action), with a one-time
|
|
66
|
+
* console note. With neither, a lock within this tab. Never refuses.
|
|
67
|
+
*/
|
|
68
|
+
export declare function browserLocks(): RecoveryLocks;
|
|
69
|
+
/**
|
|
70
|
+
* One ordinary-write reservation per exact call (account, chain, target,
|
|
71
|
+
* value and calldata) by default, or per account/chain/explicit stable
|
|
72
|
+
* namespace when provided. Use the existing domain journal instead when an
|
|
73
|
+
* action already has one. A hold ends on proof ({@link checkReviewedWrite} via
|
|
74
|
+
* `resolve`) or when the user confirms they checked their wallet (`abandon`).
|
|
56
75
|
*
|
|
57
76
|
* Every mutation must run inside withLock, including receipt-based clearing.
|
|
58
|
-
* Storage
|
|
77
|
+
* Storage is mandatory before opening a wallet; without Web Locks the lock
|
|
78
|
+
* is an IndexedDB lease across tabs ({@link browserLocks}).
|
|
59
79
|
*/
|
|
60
80
|
export declare function createBrowserWriteRecovery(input: ReviewedWriteRecoveryInput, options?: {
|
|
61
81
|
storage?: RecoveryStorage;
|
|
62
82
|
locks?: RecoveryLocks;
|
|
63
83
|
}): {
|
|
64
84
|
read: () => ReviewedWriteRecoveryRecord | null;
|
|
65
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Save the attempt before the wallet opens. `evidence`, the account's next
|
|
87
|
+
* nonce from {@link readReviewedWriteNonce}, lets `resolve` release it
|
|
88
|
+
* on proof from the chain.
|
|
89
|
+
*/
|
|
90
|
+
reserve(actualCall?: ReviewedWriteRecoveryInput["call"], evidence?: ReviewedWriteNonceEvidence): ReviewedWriteRecoveryRecord;
|
|
66
91
|
submitted(hash: Hex, expected?: ReviewedWriteRecoveryRecord | undefined): ReviewedWriteRecoveryRecord;
|
|
67
92
|
rejected: () => void;
|
|
68
93
|
clear: (expected: ReviewedWriteRecoveryRecord) => void;
|
|
94
|
+
/**
|
|
95
|
+
* Check the saved write against the chain ({@link checkReviewedWrite}) and
|
|
96
|
+
* apply the finding: `sent` records the hash to track, `ran` releases it.
|
|
97
|
+
* Null when nothing is saved.
|
|
98
|
+
*/
|
|
99
|
+
resolve(client: ReviewedWriteNonceClient, checkOptions?: {
|
|
100
|
+
effect?: (chainId: number) => Promise<boolean>;
|
|
101
|
+
}): Promise<ReviewedWriteCheck | null>;
|
|
102
|
+
/**
|
|
103
|
+
* The user confirmed they checked their wallet; release the write. It
|
|
104
|
+
* marks only the record `expected` names (by its ID) as released and never
|
|
105
|
+
* removes the saved key, so a stale exit can't erase a newer write another
|
|
106
|
+
* tab saved there. It needs no lock and still works when the cross-tab lock
|
|
107
|
+
* can't be taken; new sends still need `withLock`. `expected` may be what
|
|
108
|
+
* `read()` showed, including a returned hash kept only in memory.
|
|
109
|
+
*/
|
|
110
|
+
abandon(expected: ReviewedWriteRecoveryRecord, acknowledgement: {
|
|
111
|
+
checkedWallet: true;
|
|
112
|
+
}): void;
|
|
69
113
|
withLock<T>(work: () => Promise<T>, wait?: boolean): Promise<T>;
|
|
70
114
|
};
|
|
115
|
+
/** What the chain shows of a write with no confirmed result. */
|
|
116
|
+
export type ReviewedWriteCheck =
|
|
117
|
+
/** Nothing proven yet. The user's exit (`abandon`) stays open. */
|
|
118
|
+
{
|
|
119
|
+
status: "pending";
|
|
120
|
+
}
|
|
121
|
+
/** The saved hash, or the exact call, is the transaction at its nonce: track that receipt. */
|
|
122
|
+
| {
|
|
123
|
+
status: "sent";
|
|
124
|
+
hash: Hex;
|
|
125
|
+
}
|
|
126
|
+
/** The app's effect read shows the call took effect. */
|
|
127
|
+
| {
|
|
128
|
+
status: "ran";
|
|
129
|
+
};
|
|
130
|
+
/** The reads {@link checkReviewedWrite} makes; a viem PublicClient satisfies it. */
|
|
131
|
+
export type ReviewedWriteNonceClient = Pick<PublicClient, "getBlock" | "getChainId" | "getTransaction" | "getTransactionCount">;
|
|
132
|
+
/** The account's next nonce, counting its pending transactions, and the block it was read at. Read it right before `reserve`. */
|
|
133
|
+
export declare function readReviewedWriteNonce(client: Pick<PublicClient, "getBlockNumber" | "getTransactionCount">, account: Address): Promise<ReviewedWriteNonceEvidence>;
|
|
134
|
+
/**
|
|
135
|
+
* What the chain shows of a saved ordinary write. Every read is on the
|
|
136
|
+
* record's chain, at or below a canonical finalized block where it matters.
|
|
137
|
+
*
|
|
138
|
+
* - The saved hash, when the node knows it, is the transaction: `sent` once
|
|
139
|
+
* mined (its receipt decides, wallet wrappers included), `pending` while in
|
|
140
|
+
* the mempool. Its nonce is the nonce it was sent at (`sentNonce`).
|
|
141
|
+
* - Otherwise, once the account's nonce is past the nonce to look at, the
|
|
142
|
+
* block where it moved holds the transaction that used it. The saved hash or
|
|
143
|
+
* the exact call there is `sent`. Any other transaction there may have run
|
|
144
|
+
* the call inside it (a wrapper, or an EIP-7702 wallet that ran code and
|
|
145
|
+
* cleared its delegation in the same block), so it stays `pending` and the
|
|
146
|
+
* user's exit (`abandon`) ends it.
|
|
147
|
+
* - `effect`, the app's read of the call's result on the saved chain, ends it
|
|
148
|
+
* as `ran` when true. The client's chain is checked first.
|
|
149
|
+
*
|
|
150
|
+
* Anything else stays `pending`: a Safe write, a record without nonce
|
|
151
|
+
* evidence, another chain, or a node without the history to answer.
|
|
152
|
+
*/
|
|
153
|
+
export declare function checkReviewedWrite(client: ReviewedWriteNonceClient, saved: ReviewedWriteRecoveryRecord, { effect }?: {
|
|
154
|
+
effect?: (chainId: number) => Promise<boolean>;
|
|
155
|
+
}): Promise<ReviewedWriteCheck>;
|
|
71
156
|
/** Minimal RPC reads; PublicClient instances for any chain satisfy this shape. */
|
|
72
157
|
export type ReviewedWriteReceiptClient = {
|
|
73
158
|
getChainId(): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRecovery.d.ts","sourceRoot":"","sources":["../../../src/review/writeRecovery.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"writeRecovery.d.ts","sourceRoot":"","sources":["../../../src/review/writeRecovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,GAAG,EACR,KAAK,YAAY,EACjB,KAAK,kBAAkB,EACxB,MAAM,MAAM,CAAC;AACd,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,mBAAmB,CAAC;AAO3B,MAAM,MAAM,0BAA0B,GAAG;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,OAAO,CAAC;IACd,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAC5C,0BAA0B,EAC1B,MAAM,CACP,GAAG;IACF,OAAO,EAAE,CAAC,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAChD,iFAAiF;IACjF,IAAI,CAAC,EAAE,GAAG,CAAC;IACX,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,kGAAkG;AAClG,MAAM,MAAM,0BAA0B,GAAG;IACvC,KAAK,EAAE,MA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