@graphprotocol/graph-auth-kit 7.10.1 → 7.11.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/README.md +53 -1
- package/dist/ens/index.js +1 -1
- package/dist/{hooks-BniInqgx.js → hooks-CCLTYUp2.js} +21 -8
- package/dist/index.js +4 -4
- package/dist/safe/SafeEthersSigner.d.ts +8 -1
- package/dist/safe/SafeEthersSigner.d.ts.map +1 -1
- package/dist/safe/index.js +2 -2
- package/dist/{useGraphAuthKitEnsNames-O_TGBu9d.js → useGraphAuthKitEnsNames-Jsc8pjxn.js} +1 -1
- package/dist/{useWaitForSafeTransaction-jBw2mhZi.js → useWaitForSafeTransaction-C3rEtkxJ.js} +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -328,11 +328,63 @@ const publicationSigner = signer.withSubmissionCallbacks({
|
|
|
328
328
|
const transaction = await publicationContract.connect(publicationSigner).publishNewSubgraph(/* arguments */)
|
|
329
329
|
```
|
|
330
330
|
|
|
331
|
-
The wallet signs before `beforeSubmit`.
|
|
331
|
+
The wallet signs before `beforeSubmit`. This existing callback receives a serializable unsigned snapshot,
|
|
332
332
|
including the Safe address, decimal chain ID, proposal hash and complete transaction data (nonce
|
|
333
333
|
as a decimal string). Its successful completion must mean durable persistence. If it rejects,
|
|
334
334
|
nothing is submitted to Safe. The original shared signer remains unchanged.
|
|
335
335
|
|
|
336
|
+
For applications that require backend verification of wallet approval, opt in to
|
|
337
|
+
`authorizeSubmission`. It receives the same owner signature that will be sent to Safe,
|
|
338
|
+
without another wallet prompt. It runs before `beforeSubmit` and Safe submission; throwing
|
|
339
|
+
prevents both subsequent callbacks and submission. The signature is provided separately
|
|
340
|
+
from the frozen unsigned snapshot:
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
const publicationSigner = signer.withSubmissionCallbacks({
|
|
344
|
+
authorizeSubmission: async (proposal, authorization) => {
|
|
345
|
+
// Verify the exact Safe hash/signature, signer ownership and application scope
|
|
346
|
+
// on your backend, then atomically admit and save the unsigned proposal.
|
|
347
|
+
await verifyAndSaveProposal(proposal, authorization)
|
|
348
|
+
},
|
|
349
|
+
afterSubmit: async (proposal) => {
|
|
350
|
+
await confirmSubmittedProposal(proposal.safeTxHash)
|
|
351
|
+
},
|
|
352
|
+
})
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
`SafeSubmissionAuthorization` contains `senderAddress` and `senderSignature`. The latter
|
|
356
|
+
uses Safe's signature encoding and must be validated accordingly by the backend, not
|
|
357
|
+
trusted because it came from this callback. Treat it as transient authorization: do not
|
|
358
|
+
persist or log it, include it in error telemetry, or return it in recovery responses.
|
|
359
|
+
Possession of sufficient signatures allows execution of the exact approved transaction.
|
|
360
|
+
The old `beforeSubmit`/`afterSubmit` callbacks, transaction response and the acknowledgement
|
|
361
|
+
error's `proposal` remain unsigned. Callbacks and SDK errors still propagate, so applications
|
|
362
|
+
must also sanitize request-bearing errors returned by their own HTTP clients.
|
|
363
|
+
|
|
364
|
+
An explicit ethers `TransactionRequest.nonce` is now honored, including zero and deferred
|
|
365
|
+
values. Omit it to use `getNextNonce()` as before. For an intentional alternative, construct
|
|
366
|
+
the new transaction with the original proposal's nonce; do not use `sendPreparedTransaction`
|
|
367
|
+
to change an existing proposal's calldata:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
await publicationSigner.sendTransaction({
|
|
371
|
+
to: contractAddress,
|
|
372
|
+
data: alternativePublicationCalldata,
|
|
373
|
+
nonce: pendingProposalNonce,
|
|
374
|
+
})
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
The explicit nonce accepts ethers `BigNumberish` representations, but its value must be a
|
|
378
|
+
nonnegative safe integer supported by the SDK. Auth Kit checks
|
|
379
|
+
nonce consumption before signing and again after admission/persistence callbacks. It never
|
|
380
|
+
silently renumbers a consumed proposal. These checks cannot prevent an external execution
|
|
381
|
+
racing the final service submission; applications must still reconcile the outcome.
|
|
382
|
+
Selecting a nonce is not a reservation: coordinate ordinary admission in the application's
|
|
383
|
+
backend, and require explicit consent to admit alternatives sharing a nonce. Keep both
|
|
384
|
+
proposals until verified execution determines which, if either, succeeded. Safe enforces
|
|
385
|
+
execution order and signature thresholds; proposing an alternative does not cancel the
|
|
386
|
+
original. These hooks do not submit, cancel or reconcile any earlier proposal automatically.
|
|
387
|
+
|
|
336
388
|
After reconciling the saved attempt, retry an absent proposal with an available nonce using
|
|
337
389
|
`publicationSigner.sendPreparedTransaction(proposal)`. This requests a fresh signature but keeps
|
|
338
390
|
the original nonce, gas fields, calldata and hash; it does not select a new nonce or estimate gas.
|
package/dist/ens/index.js
CHANGED
|
@@ -113,10 +113,14 @@ class SafeSubmissionAcknowledgementError extends Error {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
function safeNonce(value) {
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
try {
|
|
117
|
+
if (typeof value !== "number" || Number.isSafeInteger(value)) {
|
|
118
|
+
const nonce = BigNumber.from(typeof value === "number" ? String(value) : value);
|
|
119
|
+
if (!nonce.isNegative()) return nonce.toNumber();
|
|
120
|
+
}
|
|
121
|
+
} catch {
|
|
118
122
|
}
|
|
119
|
-
|
|
123
|
+
throw new RangeError("Safe nonce exceeds the SDK supported integer range");
|
|
120
124
|
}
|
|
121
125
|
class SafeEthersSigner extends VoidSigner {
|
|
122
126
|
constructor(safeAddress, provider, signerAddress, chainId, options) {
|
|
@@ -240,7 +244,8 @@ class SafeEthersSigner extends VoidSigner {
|
|
|
240
244
|
operation = OperationType.DelegateCall;
|
|
241
245
|
}
|
|
242
246
|
const apiKit = await this.getApiKitInstance();
|
|
243
|
-
const
|
|
247
|
+
const requestedNonce = await tx.nonce;
|
|
248
|
+
const nonce = requestedNonce === void 0 ? await this.getNextNonce() : safeNonce(requestedNonce);
|
|
244
249
|
const safeTransactionData = {
|
|
245
250
|
to,
|
|
246
251
|
data,
|
|
@@ -266,7 +271,7 @@ class SafeEthersSigner extends VoidSigner {
|
|
|
266
271
|
}
|
|
267
272
|
/** Retry the exact proposal, without nonce selection, estimation, or metadata reconstruction. */
|
|
268
273
|
async sendPreparedTransaction(input) {
|
|
269
|
-
var _a, _b, _c, _d;
|
|
274
|
+
var _a, _b, _c, _d, _e, _f;
|
|
270
275
|
const proposal = Object.freeze({
|
|
271
276
|
schemaVersion: input.schemaVersion,
|
|
272
277
|
safeAddress: input.safeAddress,
|
|
@@ -314,16 +319,24 @@ class SafeEthersSigner extends VoidSigner {
|
|
|
314
319
|
const senderSignature = await connectedSafe.signHash(hash);
|
|
315
320
|
const response = await this.buildTransactionResponse(hash, data);
|
|
316
321
|
const apiKit = await this.getApiKitInstance();
|
|
317
|
-
|
|
322
|
+
const authorization = Object.freeze({
|
|
323
|
+
senderAddress: this.signerAddress,
|
|
324
|
+
senderSignature: senderSignature.data
|
|
325
|
+
});
|
|
326
|
+
await ((_b = (_a = this.submissionCallbacks).authorizeSubmission) == null ? void 0 : _b.call(_a, proposal, authorization));
|
|
327
|
+
await ((_d = (_c = this.submissionCallbacks).beforeSubmit) == null ? void 0 : _d.call(_c, proposal));
|
|
328
|
+
if (BigNumber.from(await connectedSafe.getNonce()).gt(data.nonce)) {
|
|
329
|
+
throw new Error("Prepared Safe proposal nonce has been consumed; reconcile before retrying");
|
|
330
|
+
}
|
|
318
331
|
await apiKit.proposeTransaction({
|
|
319
332
|
safeAddress: this.safeAddress,
|
|
320
333
|
safeTransactionData: data,
|
|
321
334
|
safeTxHash: hash,
|
|
322
335
|
senderAddress: this.signerAddress,
|
|
323
|
-
senderSignature: senderSignature
|
|
336
|
+
senderSignature: authorization.senderSignature
|
|
324
337
|
});
|
|
325
338
|
try {
|
|
326
|
-
await ((
|
|
339
|
+
await ((_f = (_e = this.submissionCallbacks).afterSubmit) == null ? void 0 : _f.call(_e, proposal));
|
|
327
340
|
} catch (error) {
|
|
328
341
|
throw new SafeSubmissionAcknowledgementError(proposal, error);
|
|
329
342
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { m, A, k, B, D, w, G, L, n, o, p, M, O, v, R, u, a, S, q, r, s, t, l, g, j, x, I, J, c, b, f, h, E, C, F, H, e, i, y, d, z } from "./GraphAuthKitInner.context-DGIzfOnv.js";
|
|
3
3
|
import { G as G2, a as a2, M as M2, b as b2, d as d2, u as u2 } from "./utils-D-x-g3cl.js";
|
|
4
|
-
import { b as useGraphAuthKitAccount, c as useGraphAuthKitConnector } from "./hooks-
|
|
5
|
-
import { a as a3, S as S2, m as m2, e as e2, d as d3, f as f2, g as g2, h as h2, u as u3 } from "./hooks-
|
|
6
|
-
import { g as g3, u as u4, w as w2 } from "./useWaitForSafeTransaction-
|
|
4
|
+
import { b as useGraphAuthKitAccount, c as useGraphAuthKitConnector } from "./hooks-CCLTYUp2.js";
|
|
5
|
+
import { a as a3, S as S2, m as m2, e as e2, d as d3, f as f2, g as g2, h as h2, u as u3 } from "./hooks-CCLTYUp2.js";
|
|
6
|
+
import { g as g3, u as u4, w as w2 } from "./useWaitForSafeTransaction-C3rEtkxJ.js";
|
|
7
7
|
import { HttpError } from "@safe-global/api-kit";
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { Alert, ExperimentalButton } from "@graphprotocol/gds";
|
|
10
10
|
import { useConfig, useSwitchChain } from "wagmi";
|
|
11
|
-
import { u as u5, a as a4, b as b3, c as c2 } from "./useGraphAuthKitEnsNames-
|
|
11
|
+
import { u as u5, a as a4, b as b3, c as c2 } from "./useGraphAuthKitEnsNames-Jsc8pjxn.js";
|
|
12
12
|
function Connected({ children }) {
|
|
13
13
|
const account = useGraphAuthKitAccount();
|
|
14
14
|
const connector = useGraphAuthKitConnector();
|
|
@@ -10,7 +10,7 @@ export declare const mapReceipt: (receipt: providers.TransactionReceipt, safeTx:
|
|
|
10
10
|
export interface SafeTransactionResponse extends TransactionResponse {
|
|
11
11
|
operation: OperationType;
|
|
12
12
|
}
|
|
13
|
-
/** Serializable unsigned snapshot
|
|
13
|
+
/** Serializable unsigned snapshot, safe to persist independently of its authorization. */
|
|
14
14
|
export interface PreparedSafeTransaction {
|
|
15
15
|
schemaVersion: 1;
|
|
16
16
|
safeAddress: string;
|
|
@@ -20,7 +20,14 @@ export interface PreparedSafeTransaction {
|
|
|
20
20
|
nonce: string;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
+
/** Transient approval of the exact proposal. Verify server-side; never persist or log it. */
|
|
24
|
+
export interface SafeSubmissionAuthorization {
|
|
25
|
+
readonly senderAddress: string;
|
|
26
|
+
readonly senderSignature: string;
|
|
27
|
+
}
|
|
23
28
|
export interface SafeSubmissionCallbacks {
|
|
29
|
+
/** Opt-in server admission using the existing signature. Rejection prevents submission. */
|
|
30
|
+
authorizeSubmission?: (proposal: PreparedSafeTransaction, authorization: SafeSubmissionAuthorization) => Promise<void>;
|
|
24
31
|
/** Must durably save the proposal before resolving. Rejection prevents submission. */
|
|
25
32
|
beforeSubmit?: (proposal: PreparedSafeTransaction) => Promise<void>;
|
|
26
33
|
/** Safe accepted the proposal; failure here does not mean submission failed. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SafeEthersSigner.d.ts","sourceRoot":"","sources":["../../src/safe/SafeEthersSigner.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAA;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AAC3D,OAAO,KAAK,UAAU,MAAM,sBAAsB,CAAA;AAClD,OAAO,IAA8B,MAAM,2BAA2B,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAmC,MAAM,wBAAwB,CAAA;AACjH,OAAO,
|
|
1
|
+
{"version":3,"file":"SafeEthersSig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CAAC,MAAM,CAAC;IAM/B,wBAAwB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqCjH;;;;;OAKG;IACY,eAAe,CAAC,WAAW,EAAE,UAAU,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,uBAAuB,CAAC;IAqD7G,iGAAiG;IAC3F,uBAAuB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAmFhG"}
|
package/dist/safe/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { A, a, S, c, b, f, e, i, d } from "../GraphAuthKitInner.context-DGIzfOnv.js";
|
|
2
|
-
import { a as a2, S as S2, m } from "../hooks-
|
|
3
|
-
import { g, u, w } from "../useWaitForSafeTransaction-
|
|
2
|
+
import { a as a2, S as S2, m } from "../hooks-CCLTYUp2.js";
|
|
3
|
+
import { g, u, w } from "../useWaitForSafeTransaction-C3rEtkxJ.js";
|
|
4
4
|
import { HttpError } from "@safe-global/api-kit";
|
|
5
5
|
export {
|
|
6
6
|
A as ApiKitUrlMap,
|
|
@@ -3,7 +3,7 @@ import { createIdenticon } from "@graphprotocol/gds";
|
|
|
3
3
|
import { getEnsAvatarQueryKey, getEnsNameQueryKey } from "@wagmi/core/query";
|
|
4
4
|
import { useQuery } from "wagmi/query";
|
|
5
5
|
import { K as useGraphAuthKitInnerContext, y as isSupportedChainId, o as L2Chain, n as L1ChainTestnet, p as L2ChainTestnet, L as L1Chain } from "./GraphAuthKitInner.context-DGIzfOnv.js";
|
|
6
|
-
import { b as useGraphAuthKitAccount } from "./hooks-
|
|
6
|
+
import { b as useGraphAuthKitAccount } from "./hooks-CCLTYUp2.js";
|
|
7
7
|
import { useChainId } from "wagmi";
|
|
8
8
|
function useGraphAuthKitAvatar(args = {}) {
|
|
9
9
|
const innerCtx = useGraphAuthKitInnerContext();
|
package/dist/{useWaitForSafeTransaction-jBw2mhZi.js → useWaitForSafeTransaction-C3rEtkxJ.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useQuery } from "@tanstack/react-query";
|
|
2
2
|
import { useConfig } from "wagmi";
|
|
3
|
-
import { u as useMultisigInfo } from "./hooks-
|
|
3
|
+
import { u as useMultisigInfo } from "./hooks-CCLTYUp2.js";
|
|
4
4
|
import { c as createApiKit } from "./GraphAuthKitInner.context-DGIzfOnv.js";
|
|
5
5
|
async function getSafeTransaction(safeTxHash, network, safeApiKey) {
|
|
6
6
|
const apiKit = await createApiKit(network, safeApiKey);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphprotocol/graph-auth-kit",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.11.0",
|
|
5
5
|
"description": "Wallet authentication connect kit in The Graph suite of applications",
|
|
6
6
|
"author": "Edge & Node",
|
|
7
7
|
"license": "UNLICENSED",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"viem": "^2.37",
|
|
56
56
|
"wagmi": "^2.17",
|
|
57
57
|
"@graphprotocol/common": "^7.0.4",
|
|
58
|
-
"@graphprotocol/gds": "^6.9.3",
|
|
59
58
|
"@graphprotocol/ens": "^2.3.1",
|
|
59
|
+
"@graphprotocol/gds": "^6.9.3",
|
|
60
60
|
"@graphprotocol/go": "^10.5.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|