@edgeandnode/graph-auth-kit 1.0.1 → 1.0.2
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/hooks.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { type Compute } from '@wagmi/core/internal';
|
|
|
2
2
|
import { type providers } from 'ethers';
|
|
3
3
|
import { type Address, type Chain } from 'viem';
|
|
4
4
|
import { type Config, type Connector, type ResolvedRegister, type UseAccountReturnType, type UseConfigParameters, type UseWalletClientReturnType, type UseWriteContractParameters, type UseWriteContractReturnType } from 'wagmi';
|
|
5
|
+
import { MultisigSchema } from './inner/GraphAuthKitInner.context';
|
|
5
6
|
import { SafeEthersSigner } from './safe/SafeEthersSigner';
|
|
6
7
|
import { GraphAuthKitConnector } from './types';
|
|
7
8
|
/**
|
|
@@ -46,6 +47,12 @@ export type UseAuthAccountReturnType<config extends Config = Config, chain = Con
|
|
|
46
47
|
* preventing checks if the `address` is null further down the tree.
|
|
47
48
|
*/
|
|
48
49
|
export declare function useAuthAccount<const config extends Config = ResolvedRegister['config']>(): UseAuthAccountReturnType<config>;
|
|
50
|
+
/**
|
|
51
|
+
* Retrieve the entered multisig info from:
|
|
52
|
+
* - the innter context object
|
|
53
|
+
* - if not in the inner context, check if found in storage
|
|
54
|
+
*/
|
|
55
|
+
export declare function useMultisigInfo<const config extends Config = ResolvedRegister['config']>(): MultisigSchema | null;
|
|
49
56
|
export type UseGraphAuthKitAccountEffectArgs<config extends Config = ResolvedRegister['config']> = Compute<{
|
|
50
57
|
onConnect?(data: Compute<Pick<Extract<UseGraphAuthKitAccountReturnType<config>, {
|
|
51
58
|
status: 'connected';
|
package/dist/hooks.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,sBAAsB,CAAA;AACnD,O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M,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EACnG,IAAI,GAAE,gCAAgC,CAAC,MAAM,CAAM,QAgDpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,2BAA2B,CACzC,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,KACrD,yBAAyB,CAAC,MAAM,CAAC,CAgBrC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,CAAC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EACxD,OAAO,GAAG,OAAO,EACjB,UAAU,GAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAM,GAAG,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CA8B3G"}
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
-
import { b as createSafe, c as createApiKit, G as GraphAuthKitConnector } from "./utils-DE0JzXpv.js";
|
|
5
|
-
import { l, A, j, B, D, s, L, m, n, o,
|
|
6
|
-
import { u as useGraphAuthKitInnerContext, c as clientToProvider } from "./utils-
|
|
7
|
-
import { G,
|
|
4
|
+
import { b as createSafe, c as createApiKit, G as GraphAuthKitConnector, M as MULTISIG_AUTH_STORAGE_KEY } from "./utils-DE0JzXpv.js";
|
|
5
|
+
import { l, A, j, B, D, s, L, m, n, o, R, r, a, S, p, q, k, e, h, f, g, d, i } from "./utils-DE0JzXpv.js";
|
|
6
|
+
import { u as useGraphAuthKitInnerContext, c as clientToProvider, a as MultisigSchema } from "./utils-D0Bwfe42.js";
|
|
7
|
+
import { G, f as f2, M, b, g as g2, l as l2, d as d2, h as h2, i as i2, j as j2, k as k2, e as e2 } from "./utils-D0Bwfe42.js";
|
|
8
8
|
import { useMutation } from "@tanstack/react-query";
|
|
9
9
|
import { watchAccount } from "@wagmi/core";
|
|
10
|
-
import { useMemo, useEffect } from "react";
|
|
11
|
-
import { encodeFunctionData, getAddress } from "viem";
|
|
10
|
+
import { useMemo, useState, useEffect } from "react";
|
|
11
|
+
import { encodeFunctionData, getAddress, isAddress } from "viem";
|
|
12
12
|
import { useChainId, useConnectorClient, useAccount, useConfig, useWalletClient, useSwitchChain } from "wagmi";
|
|
13
13
|
import { writeContractMutationOptions } from "wagmi/query";
|
|
14
14
|
import { VoidSigner } from "@ethersproject/abstract-signer";
|
|
@@ -388,10 +388,35 @@ function useAuthAccount() {
|
|
|
388
388
|
eoa: auth.eoa
|
|
389
389
|
};
|
|
390
390
|
}
|
|
391
|
+
function useMultisigInfo() {
|
|
392
|
+
const conf = useConfig();
|
|
393
|
+
const { _enteredMultisigInfo } = useGraphAuthKitInnerContext();
|
|
394
|
+
const [multisigInfo, setMultisigInfo] = useState(null);
|
|
395
|
+
useEffect(() => {
|
|
396
|
+
async function retrieveFromStorage() {
|
|
397
|
+
var _a;
|
|
398
|
+
const multisigCookie = await ((_a = conf.storage) == null ? void 0 : _a.getItem(MULTISIG_AUTH_STORAGE_KEY));
|
|
399
|
+
if (multisigCookie) {
|
|
400
|
+
const parsedMultisigSchema = MultisigSchema.safeParse(
|
|
401
|
+
typeof multisigCookie === "string" ? JSON.parse(multisigCookie) : multisigCookie
|
|
402
|
+
);
|
|
403
|
+
if (parsedMultisigSchema.success && isAddress(parsedMultisigSchema.data.address)) {
|
|
404
|
+
setMultisigInfo(parsedMultisigSchema.data);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
if (_enteredMultisigInfo != null) {
|
|
409
|
+
setMultisigInfo(_enteredMultisigInfo);
|
|
410
|
+
} else {
|
|
411
|
+
void retrieveFromStorage();
|
|
412
|
+
}
|
|
413
|
+
}, [conf, _enteredMultisigInfo]);
|
|
414
|
+
return multisigInfo;
|
|
415
|
+
}
|
|
391
416
|
function useGraphAuthKitAccountEffect(args = {}) {
|
|
392
417
|
const { onConnect, onDisconnect } = args;
|
|
393
418
|
const conf = useConfig(args);
|
|
394
|
-
const
|
|
419
|
+
const _enteredMultisigInfo = useMultisigInfo();
|
|
395
420
|
useEffect(() => {
|
|
396
421
|
return watchAccount(conf, {
|
|
397
422
|
onChange(account, prevAccount) {
|
|
@@ -522,13 +547,13 @@ export {
|
|
|
522
547
|
GraphAuthKitConnector,
|
|
523
548
|
G as GraphAuthKitContext,
|
|
524
549
|
s as GraphAuthKitProps,
|
|
525
|
-
|
|
550
|
+
f2 as GraphAuthKitProvider,
|
|
526
551
|
L as L1Chain,
|
|
527
552
|
m as L1ChainTestnet,
|
|
528
553
|
n as L2Chain,
|
|
529
554
|
o as L2ChainTestnet,
|
|
530
|
-
|
|
531
|
-
|
|
555
|
+
MULTISIG_AUTH_STORAGE_KEY,
|
|
556
|
+
M as MockGraphAuthKitProvider,
|
|
532
557
|
R as RequiredInfuraKey,
|
|
533
558
|
r as RequiredWalletConnectProjectId,
|
|
534
559
|
a as SafeSupportedNetworkNames,
|
|
@@ -540,26 +565,27 @@ export {
|
|
|
540
565
|
e as buildInfuraHttpTransport,
|
|
541
566
|
b as buildMockProviderState,
|
|
542
567
|
h as buildPublicClient,
|
|
543
|
-
|
|
568
|
+
g2 as chainIsSupportedChain,
|
|
544
569
|
clientToProvider,
|
|
545
|
-
|
|
570
|
+
l2 as connectedWalletIsEoA,
|
|
546
571
|
createApiKit,
|
|
547
572
|
createSafe,
|
|
548
573
|
d2 as disconnectedMockState,
|
|
549
574
|
f as fetchOwnedSafes,
|
|
550
575
|
g as isBuildPublicClientArgs,
|
|
551
|
-
|
|
576
|
+
h2 as isChainL1,
|
|
552
577
|
i2 as isChainL2,
|
|
553
|
-
|
|
554
|
-
|
|
578
|
+
j2 as isChainMainnet,
|
|
579
|
+
k2 as isChainTestnet,
|
|
555
580
|
d as isSafeOwner,
|
|
556
581
|
i as isValidSafe,
|
|
557
582
|
useAuthAccount,
|
|
558
583
|
useClientToEthersSigner,
|
|
559
|
-
|
|
584
|
+
e2 as useGraphAuthKit,
|
|
560
585
|
useGraphAuthKitAccount,
|
|
561
586
|
useGraphAuthKitAccountEffect,
|
|
562
587
|
useGraphAuthKitConnector,
|
|
563
588
|
useGraphAuthKitWalletClient,
|
|
564
|
-
useGraphAuthKitWriteContract
|
|
589
|
+
useGraphAuthKitWriteContract,
|
|
590
|
+
useMultisigInfo
|
|
565
591
|
};
|
|
@@ -1097,16 +1097,17 @@ function selectedTypeToMockConnector(connector) {
|
|
|
1097
1097
|
export {
|
|
1098
1098
|
GraphAuthKitContext as G,
|
|
1099
1099
|
MockGraphAuthKitProvider as M,
|
|
1100
|
-
|
|
1100
|
+
MultisigSchema as a,
|
|
1101
1101
|
buildMockProviderState as b,
|
|
1102
1102
|
clientToProvider as c,
|
|
1103
1103
|
disconnectedMockState as d,
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1104
|
+
useGraphAuthKit as e,
|
|
1105
|
+
GraphAuthKitProvider as f,
|
|
1106
|
+
chainIsSupportedChain as g,
|
|
1107
|
+
isChainL1 as h,
|
|
1108
1108
|
isChainL2 as i,
|
|
1109
|
-
|
|
1110
|
-
|
|
1109
|
+
isChainMainnet as j,
|
|
1110
|
+
isChainTestnet as k,
|
|
1111
|
+
connectedWalletIsEoA as l,
|
|
1111
1112
|
useGraphAuthKitInnerContext as u
|
|
1112
1113
|
};
|