@permissionless/wagmi 0.0.4 → 0.1.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/CHANGELOG.md +6 -0
- package/_cjs/context.js +14 -0
- package/_cjs/context.js.map +1 -0
- package/_cjs/hooks/useAvailableCapabilities.js +37 -0
- package/_cjs/hooks/useAvailableCapabilities.js.map +1 -0
- package/_cjs/hooks/useSendTransaction.js +42 -0
- package/_cjs/hooks/useSendTransaction.js.map +1 -0
- package/_cjs/hooks/useWaitForTransactionReceipt.js +168 -0
- package/_cjs/hooks/useWaitForTransactionReceipt.js.map +1 -0
- package/_cjs/index.js +7 -11
- package/_cjs/index.js.map +1 -1
- package/_cjs/utils/observe.js +43 -0
- package/_cjs/utils/observe.js.map +1 -0
- package/_esm/context.js +10 -0
- package/_esm/context.js.map +1 -0
- package/_esm/hooks/useAvailableCapabilities.js +33 -0
- package/_esm/hooks/useAvailableCapabilities.js.map +1 -0
- package/_esm/hooks/useSendTransaction.js +38 -0
- package/_esm/hooks/useSendTransaction.js.map +1 -0
- package/_esm/hooks/useWaitForTransactionReceipt.js +175 -0
- package/_esm/hooks/useWaitForTransactionReceipt.js.map +1 -0
- package/_esm/index.js +3 -6
- package/_esm/index.js.map +1 -1
- package/_esm/utils/observe.js +46 -0
- package/_esm/utils/observe.js.map +1 -0
- package/_types/context.d.ts +12 -0
- package/_types/context.d.ts.map +1 -0
- package/_types/hooks/useAvailableCapabilities.d.ts +5 -0
- package/_types/hooks/useAvailableCapabilities.d.ts.map +1 -0
- package/_types/hooks/useSendTransaction.d.ts +34 -0
- package/_types/hooks/useSendTransaction.d.ts.map +1 -0
- package/_types/hooks/useWaitForTransactionReceipt.d.ts +92 -0
- package/_types/hooks/useWaitForTransactionReceipt.d.ts.map +1 -0
- package/_types/index.d.ts +3 -6
- package/_types/index.d.ts.map +1 -1
- package/_types/utils/observe.d.ts +23 -0
- package/_types/utils/observe.d.ts.map +1 -0
- package/context.ts +22 -0
- package/hooks/useAvailableCapabilities.ts +43 -0
- package/hooks/useSendTransaction.ts +148 -0
- package/hooks/useWaitForTransactionReceipt.ts +431 -0
- package/index.ts +6 -31
- package/package.json +3 -11
- package/utils/observe.ts +76 -0
- package/_cjs/connectors/biconomySmartAccount.js +0 -18
- package/_cjs/connectors/biconomySmartAccount.js.map +0 -1
- package/_cjs/connectors/kernelSmartAccount.js +0 -18
- package/_cjs/connectors/kernelSmartAccount.js.map +0 -1
- package/_cjs/connectors/safeSmartAccount.js +0 -18
- package/_cjs/connectors/safeSmartAccount.js.map +0 -1
- package/_cjs/connectors/simpleSmartAccount.js +0 -30
- package/_cjs/connectors/simpleSmartAccount.js.map +0 -1
- package/_cjs/connectors/smartAccount.js +0 -51
- package/_cjs/connectors/smartAccount.js.map +0 -1
- package/_esm/connectors/biconomySmartAccount.js +0 -14
- package/_esm/connectors/biconomySmartAccount.js.map +0 -1
- package/_esm/connectors/kernelSmartAccount.js +0 -14
- package/_esm/connectors/kernelSmartAccount.js.map +0 -1
- package/_esm/connectors/safeSmartAccount.js +0 -14
- package/_esm/connectors/safeSmartAccount.js.map +0 -1
- package/_esm/connectors/simpleSmartAccount.js +0 -26
- package/_esm/connectors/simpleSmartAccount.js.map +0 -1
- package/_esm/connectors/smartAccount.js +0 -53
- package/_esm/connectors/smartAccount.js.map +0 -1
- package/_types/connectors/biconomySmartAccount.d.ts +0 -317
- package/_types/connectors/biconomySmartAccount.d.ts.map +0 -1
- package/_types/connectors/kernelSmartAccount.d.ts +0 -317
- package/_types/connectors/kernelSmartAccount.d.ts.map +0 -1
- package/_types/connectors/safeSmartAccount.d.ts +0 -317
- package/_types/connectors/safeSmartAccount.d.ts.map +0 -1
- package/_types/connectors/simpleSmartAccount.d.ts +0 -635
- package/_types/connectors/simpleSmartAccount.d.ts.map +0 -1
- package/_types/connectors/smartAccount.d.ts +0 -294
- package/_types/connectors/smartAccount.d.ts.map +0 -1
- package/connectors/biconomySmartAccount.ts +0 -53
- package/connectors/kernelSmartAccount.ts +0 -53
- package/connectors/safeSmartAccount.ts +0 -50
- package/connectors/simpleSmartAccount.ts +0 -90
- package/connectors/smartAccount.ts +0 -72
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getConnectorClient, waitForTransactionReceipt } from "@wagmi/core";
|
|
3
|
+
import { ConnectorNotConnectedError } from "@wagmi/core";
|
|
4
|
+
import { WaitForTransactionReceiptTimeoutError, isHash, stringify } from "viem";
|
|
5
|
+
import { getTransactionReceipt, watchBlockNumber } from "viem/actions";
|
|
6
|
+
import { getCallsStatus } from "viem/experimental";
|
|
7
|
+
import { getAction } from "viem/utils";
|
|
8
|
+
import { useChainId, useConfig } from "wagmi";
|
|
9
|
+
import { useQuery } from "wagmi/query";
|
|
10
|
+
import { observe } from "../utils/observe.js";
|
|
11
|
+
import { useAvailableCapabilities } from "./useAvailableCapabilities.js";
|
|
12
|
+
export function waitForTransactionReceiptQueryKey(options = {}) {
|
|
13
|
+
const { ...rest } = options;
|
|
14
|
+
return ["waitForTransactionReceipt", filterQueryOptions(rest)];
|
|
15
|
+
}
|
|
16
|
+
export function filterQueryOptions(options) {
|
|
17
|
+
// destructuring is super fast
|
|
18
|
+
// biome-ignore format: no formatting
|
|
19
|
+
const {
|
|
20
|
+
// import('@tanstack/query-core').QueryOptions
|
|
21
|
+
_defaulted, behavior, gcTime, initialData, initialDataUpdatedAt, maxPages, meta, networkMode, queryFn, queryHash, queryKey, queryKeyHashFn, retry, retryDelay, structuralSharing,
|
|
22
|
+
// import('@tanstack/query-core').InfiniteQueryObserverOptions
|
|
23
|
+
getPreviousPageParam, getNextPageParam, initialPageParam,
|
|
24
|
+
// import('@tanstack/react-query').UseQueryOptions
|
|
25
|
+
_optimisticResults, enabled, notifyOnChangeProps, placeholderData, refetchInterval, refetchIntervalInBackground, refetchOnMount, refetchOnReconnect, refetchOnWindowFocus, retryOnMount, select, staleTime, suspense, throwOnError,
|
|
26
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
27
|
+
// wagmi
|
|
28
|
+
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
29
|
+
config, connector, query, ...rest } = options;
|
|
30
|
+
return rest;
|
|
31
|
+
}
|
|
32
|
+
export function getCallsStatusQueryKey(options) {
|
|
33
|
+
return ["callsStatus", filterQueryOptions(options)];
|
|
34
|
+
}
|
|
35
|
+
export async function waitForCallsStatus(config, parameters) {
|
|
36
|
+
const { timeout = 0, id, pollingInterval, retryCount = 6, confirmations = 1 } = parameters;
|
|
37
|
+
const client = await getConnectorClient(config, {});
|
|
38
|
+
const observerId = stringify(["waitForTransactionReceipt", client.uid, id]);
|
|
39
|
+
let count = 0;
|
|
40
|
+
let receipt;
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
if (timeout)
|
|
43
|
+
setTimeout(() => reject(new WaitForTransactionReceiptTimeoutError({
|
|
44
|
+
hash: id
|
|
45
|
+
})), timeout);
|
|
46
|
+
const _unobserve = observe(observerId, { resolve, reject }, (emit) => {
|
|
47
|
+
const _unwatch = getAction(client, watchBlockNumber, "watchBlockNumber")({
|
|
48
|
+
emitMissed: true,
|
|
49
|
+
emitOnBegin: true,
|
|
50
|
+
poll: true,
|
|
51
|
+
pollingInterval,
|
|
52
|
+
async onBlockNumber(blockNumber) {
|
|
53
|
+
const done = (fn) => {
|
|
54
|
+
_unwatch();
|
|
55
|
+
fn();
|
|
56
|
+
_unobserve();
|
|
57
|
+
};
|
|
58
|
+
if (count > retryCount)
|
|
59
|
+
done(() => emit.reject(new WaitForTransactionReceiptTimeoutError({
|
|
60
|
+
hash: id
|
|
61
|
+
})));
|
|
62
|
+
try {
|
|
63
|
+
// If we already have a valid receipt, let's check if we have enough
|
|
64
|
+
// confirmations. If we do, then we can resolve.
|
|
65
|
+
if (receipt) {
|
|
66
|
+
if (confirmations > 1 &&
|
|
67
|
+
(!receipt.receipts?.[0]?.blockNumber ||
|
|
68
|
+
blockNumber -
|
|
69
|
+
receipt.receipts?.[0]?.blockNumber +
|
|
70
|
+
1n <
|
|
71
|
+
confirmations))
|
|
72
|
+
return;
|
|
73
|
+
if (receipt.status === "PENDING") {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (receipt.receipts?.length === 0) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const finalReceipt = receipt.receipts;
|
|
80
|
+
if (!finalReceipt) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const transactionReceipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: finalReceipt[0].transactionHash });
|
|
84
|
+
done(() => emit.resolve({
|
|
85
|
+
...transactionReceipt,
|
|
86
|
+
chainId: client.chain.id
|
|
87
|
+
}));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
// Get the receipt to check if it's been processed.
|
|
91
|
+
receipt = await getAction(client, getCallsStatus, "getCallsStatus")({ id });
|
|
92
|
+
if (receipt.status === "PENDING") {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
// Check if we have enough confirmations. If not, continue polling.
|
|
96
|
+
if (confirmations > 1 &&
|
|
97
|
+
(!receipt.receipts?.[0]?.blockNumber ||
|
|
98
|
+
blockNumber -
|
|
99
|
+
receipt.receipts?.[0]?.blockNumber +
|
|
100
|
+
1n <
|
|
101
|
+
confirmations))
|
|
102
|
+
return;
|
|
103
|
+
if (receipt.receipts?.length === 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const finalReceipt = receipt.receipts;
|
|
107
|
+
if (!finalReceipt) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const transactionReceipt = await getAction(client, getTransactionReceipt, "getTransactionReceipt")({ hash: finalReceipt[0].transactionHash });
|
|
111
|
+
done(() => emit.resolve({
|
|
112
|
+
...transactionReceipt,
|
|
113
|
+
chainId: client.chain.id
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
done(() => emit.reject(err));
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
count++;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
export function waitForTransactionReceiptQueryOptions(config, options) {
|
|
128
|
+
return {
|
|
129
|
+
async queryFn({ queryKey }) {
|
|
130
|
+
const { scopeKey: _, id, ...parameters } = queryKey[1];
|
|
131
|
+
if (!id)
|
|
132
|
+
throw new Error("id is required");
|
|
133
|
+
if (!options.capabilities && !isHash(id)) {
|
|
134
|
+
throw new Error("capabilities or hash is required");
|
|
135
|
+
}
|
|
136
|
+
if (options.capabilities) {
|
|
137
|
+
const status = await waitForCallsStatus(config, {
|
|
138
|
+
id,
|
|
139
|
+
...parameters
|
|
140
|
+
});
|
|
141
|
+
return status;
|
|
142
|
+
}
|
|
143
|
+
const status = await waitForTransactionReceipt(config, {
|
|
144
|
+
hash: id,
|
|
145
|
+
...options,
|
|
146
|
+
...parameters
|
|
147
|
+
});
|
|
148
|
+
return status;
|
|
149
|
+
},
|
|
150
|
+
queryKey: waitForTransactionReceiptQueryKey(options),
|
|
151
|
+
retry(failureCount, error) {
|
|
152
|
+
if (error instanceof ConnectorNotConnectedError)
|
|
153
|
+
return false;
|
|
154
|
+
return failureCount < 3;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export function useWaitForTransactionReceipt(parameters = {}) {
|
|
159
|
+
const { query = {} } = parameters;
|
|
160
|
+
const { capabilities } = useAvailableCapabilities();
|
|
161
|
+
const config = useConfig(parameters);
|
|
162
|
+
const chainId = useChainId({ config });
|
|
163
|
+
const enabled = Boolean(parameters.id && (query.enabled ?? true));
|
|
164
|
+
const options = waitForTransactionReceiptQueryOptions(config, {
|
|
165
|
+
...parameters,
|
|
166
|
+
chainId: parameters.chainId ?? chainId,
|
|
167
|
+
capabilities
|
|
168
|
+
});
|
|
169
|
+
return useQuery({
|
|
170
|
+
...query,
|
|
171
|
+
...options,
|
|
172
|
+
enabled
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=useWaitForTransactionReceipt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWaitForTransactionReceipt.js","sourceRoot":"","sources":["../../hooks/useWaitForTransactionReceipt.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AAOZ,OAAO,EAKH,kBAAkB,EAClB,yBAAyB,EAC5B,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAA;AAQxD,OAAO,EAGH,qCAAqC,EAGrC,MAAM,EACN,SAAS,EACZ,MAAM,MAAM,CAAA;AACb,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACtE,OAAO,EAGH,cAAc,EACjB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC7C,OAAO,EAKH,QAAQ,EACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAC1C,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AAQrE,MAAM,UAAU,iCAAiC,CAI7C,UAMI,EAAE;IAEN,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IAC3B,OAAO,CAAC,2BAA2B,EAAE,kBAAkB,CAAC,IAAI,CAAC,CAAU,CAAA;AAC3E,CAAC;AAED,MAAM,UAAU,kBAAkB,CAC9B,OAAa;IAEb,8BAA8B;IAC9B,qCAAqC;IACrC,MAAM;IACJ,8CAA8C;IAC9C,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,oBAAoB,EAAE,QAAQ,EAAE,IAAI,EAA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,KAAK,CAAC,YAAY,EAAE,KAAK;YACrB,IAAI,KAAK,YAAY,0BAA0B;gBAAE,OAAO,KAAK,CAAA;YAC7D,OAAO,YAAY,GAAG,CAAC,CAAA;QAC3B,CAAC;KAMJ,CAAA;AACL,CAAC;AAmCD,MAAM,UAAU,4BAA4B,CAMxC,aAII,EAAE;IAEN,MAAM,EAAE,KAAK,GAAG,EAAE,EAAE,GAAG,UAAU,CAAA;IACjC,MAAM,EAAE,YAAY,EAAE,GAAG,wBAAwB,EAAE,CAAA;IAEnD,MAAM,MAAM,GAAG,SAAS,CAAC,UAAU,CAAC,CAAA;IACpC,MAAM,OAAO,GAAG,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC,CAAA;IAEtC,MAAM,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,CAAA;IAEjE,MAAM,OAAO,GAAG,qCAAqC,CAAC,MAAM,EAAE;QAC1D,GAAG,UAAU;QACb,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,OAAO;QACtC,YAAY;KACf,CAAC,CAAA;IAEF,OAAO,QAAQ,CAAC;QACZ,GAAG,KAAK;QACR,GAAG,OAAO;QACV,OAAO;KACV,CAAwE,CAAA;AAC7E,CAAC"}
|
package/_esm/index.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { biconomySmartAccount } from "./connectors/biconomySmartAccount.js";
|
|
5
|
-
import { kernelSmartAccount } from "./connectors/kernelSmartAccount.js";
|
|
6
|
-
export { smartAccount, simpleSmartAccount, safeSmartAccount, biconomySmartAccount, kernelSmartAccount };
|
|
1
|
+
export { PermissionlessProvider } from "./context.js";
|
|
2
|
+
export { useSendTransaction } from "./hooks/useSendTransaction.js";
|
|
3
|
+
export { useWaitForTransactionReceipt } from "./hooks/useWaitForTransactionReceipt.js";
|
|
7
4
|
//# sourceMappingURL=index.js.map
|
package/_esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EAEzB,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** @internal */
|
|
2
|
+
export const listenersCache = /*#__PURE__*/ new Map();
|
|
3
|
+
/** @internal */
|
|
4
|
+
export const cleanupCache = /*#__PURE__*/ new Map();
|
|
5
|
+
let callbackCount = 0;
|
|
6
|
+
/**
|
|
7
|
+
* @description Sets up an observer for a given function. If another function
|
|
8
|
+
* is set up under the same observer id, the function will only be called once
|
|
9
|
+
* for both instances of the observer.
|
|
10
|
+
*/
|
|
11
|
+
export function observe(observerId, callbacks, fn) {
|
|
12
|
+
const callbackId = ++callbackCount;
|
|
13
|
+
const getListeners = () => listenersCache.get(observerId) || [];
|
|
14
|
+
const unsubscribe = () => {
|
|
15
|
+
const listeners = getListeners();
|
|
16
|
+
listenersCache.set(observerId, listeners.filter((cb) => cb.id !== callbackId));
|
|
17
|
+
};
|
|
18
|
+
const unwatch = () => {
|
|
19
|
+
const cleanup = cleanupCache.get(observerId);
|
|
20
|
+
if (getListeners().length === 1 && cleanup)
|
|
21
|
+
cleanup();
|
|
22
|
+
unsubscribe();
|
|
23
|
+
};
|
|
24
|
+
const listeners = getListeners();
|
|
25
|
+
listenersCache.set(observerId, [
|
|
26
|
+
...listeners,
|
|
27
|
+
{ id: callbackId, fns: callbacks }
|
|
28
|
+
]);
|
|
29
|
+
if (listeners && listeners.length > 0)
|
|
30
|
+
return unwatch;
|
|
31
|
+
const emit = {};
|
|
32
|
+
for (const key in callbacks) {
|
|
33
|
+
emit[key] = ((...args) => {
|
|
34
|
+
const listeners = getListeners();
|
|
35
|
+
if (listeners.length === 0)
|
|
36
|
+
return;
|
|
37
|
+
for (const listener of listeners)
|
|
38
|
+
listener.fns[key]?.(...args);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
const cleanup = fn(emit);
|
|
42
|
+
if (typeof cleanup === "function")
|
|
43
|
+
cleanupCache.set(observerId, cleanup);
|
|
44
|
+
return unwatch;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=observe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.js","sourceRoot":"","sources":["../../utils/observe.ts"],"names":[],"mappings":"AASA,gBAAgB;AAChB,MAAM,CAAC,MAAM,cAAc,GAAG,aAAa,CAAC,IAAI,GAAG,EAGhD,CAAA;AACH,gBAAgB;AAChB,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,GAAG,EAAsB,CAAA;AAOvE,IAAI,aAAa,GAAG,CAAC,CAAA;AAErB;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACnB,UAAkB,EAClB,SAAoB,EACpB,EAA2B;IAE3B,MAAM,UAAU,GAAG,EAAE,aAAa,CAAA;IAElC,MAAM,YAAY,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,CAAA;IAE/D,MAAM,WAAW,GAAG,GAAG,EAAE;QACrB,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;QAChC,cAAc,CAAC,GAAG,CACd,UAAU,EACV,SAAS,CAAC,MAAM,CAAC,CAAC,EAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,UAAU,CAAC,CACtD,CAAA;IACL,CAAC,CAAA;IAED,MAAM,OAAO,GAAG,GAAG,EAAE;QACjB,MAAM,OAAO,GAAG,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QAC5C,IAAI,YAAY,EAAE,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO;YAAE,OAAO,EAAE,CAAA;QACrD,WAAW,EAAE,CAAA;IACjB,CAAC,CAAA;IAED,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;IAChC,cAAc,CAAC,GAAG,CAAC,UAAU,EAAE;QAC3B,GAAG,SAAS;QACZ,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE;KACrC,CAAC,CAAA;IAEF,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,OAAO,CAAA;IAErD,MAAM,IAAI,GAAc,EAAe,CAAA;IACvC,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CACT,GAAG,IAAyD,EAC9D,EAAE;YACA,MAAM,SAAS,GAAG,YAAY,EAAE,CAAA;YAChC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAM;YAClC,KAAK,MAAM,QAAQ,IAAI,SAAS;gBAAE,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;QAClE,CAAC,CAAgD,CAAA;IACrD,CAAC;IAED,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;IACxB,IAAI,OAAO,OAAO,KAAK,UAAU;QAAE,YAAY,CAAC,GAAG,CAAC,UAAU,EAAE,OAAO,CAAC,CAAA;IAExE,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { WalletCapabilities, WalletSendCallsParameters } from "viem";
|
|
3
|
+
export declare const PermissionlessContext: import("react").Context<{
|
|
4
|
+
capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
5
|
+
}>;
|
|
6
|
+
export type PermissionlessProviderProps = {
|
|
7
|
+
capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
8
|
+
};
|
|
9
|
+
export declare const PermissionlessProvider: (parameters: React.PropsWithChildren<PermissionlessProviderProps>) => import("react").FunctionComponentElement<import("react").ProviderProps<{
|
|
10
|
+
capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
11
|
+
}>>;
|
|
12
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../context.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,MAAM,CAAA;AAEzE,eAAO,MAAM,qBAAqB;kBAChB,0BAA0B,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;EAGrF,CAAA;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACtC,YAAY,EAAE,yBAAyB,CAAC,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,CAAA;CACtF,CAAA;AAED,eAAO,MAAM,sBAAsB,eACnB,MAAM,iBAAiB,CAAC,2BAA2B,CAAC;kBAVlD,0BAA0B,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC;GAiBtF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAvailableCapabilities.d.ts","sourceRoot":"","sources":["../../hooks/useAvailableCapabilities.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAA6B,MAAM,MAAM,CAAA;AAKzE,eAAO,MAAM,wBAAwB;;CAkCpC,CAAA"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type MutateOptions } from "@tanstack/react-query";
|
|
2
|
+
import type { Prettify, SendTransactionErrorType } from "viem";
|
|
3
|
+
import type { SendCallsErrorType } from "viem/experimental";
|
|
4
|
+
import { type Config, type ResolvedRegister } from "wagmi";
|
|
5
|
+
import type { SendTransactionVariables, UseMutationParameters, UseMutationReturnType } from "wagmi/query";
|
|
6
|
+
export type SendTransactionData = string;
|
|
7
|
+
export type SendTransactionMutate<config extends Config, context = unknown> = <chainId extends config["chains"][number]["id"]>(variables: SendTransactionVariables<config, chainId>, options?: Prettify<MutateOptions<SendTransactionData, SendTransactionErrorType | SendCallsErrorType, Prettify<SendTransactionVariables<config, chainId>>, context>> | undefined) => void;
|
|
8
|
+
export type SendTransactionMutateAsync<config extends Config, context = unknown> = <chainId extends config["chains"][number]["id"]>(variables: SendTransactionVariables<config, chainId>, options?: Prettify<MutateOptions<SendTransactionData, SendTransactionErrorType | SendCallsErrorType, Prettify<SendTransactionVariables<config, chainId>>, context>> | undefined) => Promise<SendTransactionData>;
|
|
9
|
+
export type UseSendTransactionReturnType<config extends Config = Config, context = unknown> = Prettify<UseMutationReturnType<SendTransactionData, SendTransactionErrorType | SendCallsErrorType, SendTransactionVariables<config, config["chains"][number]["id"]>, context> & {
|
|
10
|
+
sendTransaction: SendTransactionMutate<config, context>;
|
|
11
|
+
sendTransactionAsync: SendTransactionMutateAsync<config, context>;
|
|
12
|
+
}>;
|
|
13
|
+
export type ConfigParameter<config extends Config = Config> = {
|
|
14
|
+
config?: Config | config | undefined;
|
|
15
|
+
};
|
|
16
|
+
export type UseSendTransactionParameters<config extends Config = ResolvedRegister["config"], context = unknown> = Prettify<ConfigParameter<config> & {
|
|
17
|
+
mutation?: UseMutationParameters<SendTransactionData, SendTransactionErrorType | SendCallsErrorType, SendTransactionVariables<config, config["chains"][number]["id"]>, context> | undefined;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const useSendTransaction: <config extends Config = Config, context = unknown>(parameters?: {
|
|
20
|
+
config?: Config | config | undefined;
|
|
21
|
+
mutation?: {
|
|
22
|
+
meta?: Record<string, unknown> | undefined;
|
|
23
|
+
onMutate?: ((variables: SendTransactionVariables<config, config["chains"][number]["id"]> extends infer T ? { [key in keyof T]: SendTransactionVariables<config, config["chains"][number]["id"]>[key]; } : never) => context | Promise<context | undefined> | undefined) | undefined;
|
|
24
|
+
onSuccess?: ((data: string, variables: SendTransactionVariables<config, config["chains"][number]["id"]> extends infer T ? { [key in keyof T]: SendTransactionVariables<config, config["chains"][number]["id"]>[key]; } : never, context: context) => unknown) | undefined;
|
|
25
|
+
onError?: ((error: import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/utils").GetTransactionErrorReturnType<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/_types/errors/account").AccountNotFoundErrorType | import("viem/_types/errors/account").AccountTypeNotSupportedErrorType | import("viem").ChainNotFoundErrorType | import("viem").ChainMismatchErrorType | import("viem").InvalidAddressErrorType | import("viem").FeeConflictErrorType | import("viem").FeeCapTooHighErrorType | import("viem").TipAboveFeeCapErrorType | import("viem").SizeOverflowErrorType | import("viem").IsHexErrorType | import("viem").BlockNotFoundErrorType | import("viem").IntegerOutOfRangeErrorType | import("viem").SizeExceedsPaddingSizeErrorType | import("viem").ConcatHexErrorType | import("viem/_types/errors/cursor").PositionOutOfBoundsErrorType | import("viem/_types/errors/cursor").NegativeOffsetError | import("viem/_types/errors/cursor").NegativeOffsetErrorType | import("viem/_types/errors/cursor").RecursiveReadLimitExceededErrorType | import("viem").RecoverAddressErrorType | import("viem").EstimateGasErrorType | import("viem").BaseFeeScalarErrorType | import("viem").Eip1559FeesNotSupportedErrorType>, variables: SendTransactionVariables<config, config["chains"][number]["id"]> extends infer T ? { [key in keyof T]: SendTransactionVariables<config, config["chains"][number]["id"]>[key]; } : never, context: context | undefined) => unknown) | undefined;
|
|
26
|
+
onSettled?: ((data: string | undefined, error: import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/utils").GetTransactionErrorReturnType<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/_types/errors/account").AccountNotFoundErrorType | import("viem/_types/errors/account").AccountTypeNotSupportedErrorType | import("viem").ChainNotFoundErrorType | import("viem").ChainMismatchErrorType | import("viem").InvalidAddressErrorType | import("viem").FeeConflictErrorType | import("viem").FeeCapTooHighErrorType | import("viem").TipAboveFeeCapErrorType | import("viem").SizeOverflowErrorType | import("viem").IsHexErrorType | import("viem").BlockNotFoundErrorType | import("viem").IntegerOutOfRangeErrorType | import("viem").SizeExceedsPaddingSizeErrorType | import("viem").ConcatHexErrorType | import("viem/_types/errors/cursor").PositionOutOfBoundsErrorType | import("viem/_types/errors/cursor").NegativeOffsetError | import("viem/_types/errors/cursor").NegativeOffsetErrorType | import("viem/_types/errors/cursor").RecursiveReadLimitExceededErrorType | import("viem").RecoverAddressErrorType | import("viem").EstimateGasErrorType | import("viem").BaseFeeScalarErrorType | import("viem").Eip1559FeesNotSupportedErrorType> | null, variables: SendTransactionVariables<config, config["chains"][number]["id"]> extends infer T ? { [key in keyof T]: SendTransactionVariables<config, config["chains"][number]["id"]>[key]; } : never, context: context | undefined) => unknown) | undefined;
|
|
27
|
+
retry?: import("@tanstack/query-core/build/legacy/hydration-BZ2M_xzi").bo<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/utils").GetTransactionErrorReturnType<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/_types/errors/account").AccountNotFoundErrorType | import("viem/_types/errors/account").AccountTypeNotSupportedErrorType | import("viem").ChainNotFoundErrorType | import("viem").ChainMismatchErrorType | import("viem").InvalidAddressErrorType | import("viem").FeeConflictErrorType | import("viem").FeeCapTooHighErrorType | import("viem").TipAboveFeeCapErrorType | import("viem").SizeOverflowErrorType | import("viem").IsHexErrorType | import("viem").BlockNotFoundErrorType | import("viem").IntegerOutOfRangeErrorType | import("viem").SizeExceedsPaddingSizeErrorType | import("viem").ConcatHexErrorType | import("viem/_types/errors/cursor").PositionOutOfBoundsErrorType | import("viem/_types/errors/cursor").NegativeOffsetError | import("viem/_types/errors/cursor").NegativeOffsetErrorType | import("viem/_types/errors/cursor").RecursiveReadLimitExceededErrorType | import("viem").RecoverAddressErrorType | import("viem").EstimateGasErrorType | import("viem").BaseFeeScalarErrorType | import("viem").Eip1559FeesNotSupportedErrorType>> | undefined;
|
|
28
|
+
retryDelay?: import("@tanstack/query-core/build/legacy/hydration-BZ2M_xzi").bp<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/utils").GetTransactionErrorReturnType<import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem/accounts").ParseAccountErrorType | import("viem/_types/errors/account").AccountNotFoundErrorType | import("viem/_types/errors/account").AccountTypeNotSupportedErrorType | import("viem").ChainNotFoundErrorType | import("viem").ChainMismatchErrorType | import("viem").InvalidAddressErrorType | import("viem").FeeConflictErrorType | import("viem").FeeCapTooHighErrorType | import("viem").TipAboveFeeCapErrorType | import("viem").SizeOverflowErrorType | import("viem").IsHexErrorType | import("viem").BlockNotFoundErrorType | import("viem").IntegerOutOfRangeErrorType | import("viem").SizeExceedsPaddingSizeErrorType | import("viem").ConcatHexErrorType | import("viem/_types/errors/cursor").PositionOutOfBoundsErrorType | import("viem/_types/errors/cursor").NegativeOffsetError | import("viem/_types/errors/cursor").NegativeOffsetErrorType | import("viem/_types/errors/cursor").RecursiveReadLimitExceededErrorType | import("viem").RecoverAddressErrorType | import("viem").EstimateGasErrorType | import("viem").BaseFeeScalarErrorType | import("viem").Eip1559FeesNotSupportedErrorType>> | undefined;
|
|
29
|
+
networkMode?: import("@tanstack/react-query").NetworkMode | undefined;
|
|
30
|
+
gcTime?: number | undefined;
|
|
31
|
+
scope?: import("@tanstack/react-query").MutationScope | undefined;
|
|
32
|
+
} | undefined;
|
|
33
|
+
}) => UseSendTransactionReturnType<config, context>;
|
|
34
|
+
//# sourceMappingURL=useSendTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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CAAC,CAAC,EACnD,OAAO,CACV,CACJ,GACD,SAAS,KACd,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEjC,MAAM,MAAM,4BAA4B,CACpC,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,GAAG,OAAO,IACjB,QAAQ,CACR,qBAAqB,CACjB,mBAAmB,EACnB,wBAAwB,GAAG,kBAAkB,EAC7C,wBAAwB,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,EAChE,OAAO,CACV,GAAG;IACA,eAAe,EAAE,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACvD,oBAAoB,EAAE,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpE,CACJ,CAAA;AAED,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,IAAI;IAC1D,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACvC,CAAA;AAED,MAAM,MAAM,4BAA4B,CACpC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAClD,OAAO,GAAG,OAAO,IACjB,QAAQ,CACR,eAAe,CAAC,MAAM,CAAC,GAAG;IACtB,QAAQ,CAAC,EACH,qBAAqB,CACjB,mBAAmB,EACnB,wBAAwB,GAAG,kBAAkB,EAC7C,wBAAwB,CACpB,MAAM,EACN,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CACjC,EACD,OAAO,CACV,GACD,SAAS,CAAA;CAClB,CACJ,CAAA;AAED,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;mDA2B9B,CAAA"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { DefaultError, QueryKey } from "@tanstack/react-query";
|
|
2
|
+
import { type Config, type ResolvedRegister, type WaitForTransactionReceiptErrorType, type WaitForTransactionReceiptReturnType } from "@wagmi/core";
|
|
3
|
+
import type { GetCallsStatusData, GetCallsStatusErrorType, GetCallsStatusOptions, GetCallsStatusQueryFnData } from "@wagmi/core/experimental";
|
|
4
|
+
import type { WaitForTransactionReceiptData } from "@wagmi/core/query";
|
|
5
|
+
import { type Prettify, type WalletCapabilities, type WalletSendCallsParameters } from "viem";
|
|
6
|
+
import { type ShowCallsStatusErrorType } from "viem/experimental";
|
|
7
|
+
import { type UseQueryParameters, type UseQueryReturnType, type WaitForTransactionReceiptOptions, type WaitForTransactionReceiptQueryFnData } from "wagmi/query";
|
|
8
|
+
import type { ConfigParameter } from "./useSendTransaction";
|
|
9
|
+
export type WaitForTransactionReceiptQueryKey<config extends Config, chainId extends config["chains"][number]["id"]> = ReturnType<typeof waitForTransactionReceiptQueryKey<config, chainId>>;
|
|
10
|
+
export declare function waitForTransactionReceiptQueryKey<config extends Config, chainId extends config["chains"][number]["id"]>(options?: Omit<WaitForTransactionReceiptOptions<config, chainId>, "hash" | "onReplaced"> & {
|
|
11
|
+
id?: string;
|
|
12
|
+
capabilities?: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
13
|
+
}): readonly ["waitForTransactionReceipt", {
|
|
14
|
+
scopeKey?: string | undefined;
|
|
15
|
+
pollingInterval?: number | undefined;
|
|
16
|
+
chainId?: config["chains"][number]["id"] | (chainId extends config["chains"][number]["id"] ? chainId : undefined) | undefined;
|
|
17
|
+
retryDelay?: number | ((config: {
|
|
18
|
+
count: number;
|
|
19
|
+
error: Error;
|
|
20
|
+
}) => number) | undefined;
|
|
21
|
+
confirmations?: number | undefined;
|
|
22
|
+
retryCount?: number | undefined;
|
|
23
|
+
timeout?: number | undefined;
|
|
24
|
+
id?: string | undefined;
|
|
25
|
+
capabilities?: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
26
|
+
}];
|
|
27
|
+
export declare function filterQueryOptions<type extends Record<string, unknown>>(options: type): type;
|
|
28
|
+
export type QueryParameter<queryFnData = unknown, error = DefaultError, data = queryFnData, queryKey extends QueryKey = QueryKey> = {
|
|
29
|
+
query?: Omit<UseQueryParameters<queryFnData, error, data, queryKey>, "queryFn" | "queryHash" | "queryKey" | "queryKeyHashFn" | "throwOnError"> | undefined;
|
|
30
|
+
};
|
|
31
|
+
export type UseCallsStatusParameters<config extends Config = Config, chainId extends config["chains"][number]["id"] = config["chains"][number]["id"], selectData = GetCallsStatusData> = Prettify<Partial<GetCallsStatusOptions> & ConfigParameter<config> & QueryParameter<GetCallsStatusQueryFnData, GetCallsStatusErrorType, selectData, ReturnType<typeof getCallsStatusQueryKey>> & {
|
|
32
|
+
chainId?: (chainId extends config["chains"][number]["id"] ? chainId : undefined) | config["chains"][number]["id"] | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
export declare function getCallsStatusQueryKey(options: Partial<GetCallsStatusOptions>): readonly ["callsStatus", Partial<{
|
|
35
|
+
id: string;
|
|
36
|
+
connector?: import("wagmi").Connector | undefined;
|
|
37
|
+
scopeKey?: string | undefined;
|
|
38
|
+
}>];
|
|
39
|
+
export declare function waitForCallsStatus<config extends Config, chainId extends config["chains"][number]["id"] = config["chains"][number]["id"]>(config: config, parameters: Omit<WaitForTransactionReceiptOptions<config, chainId>, "hash" | "onReplaced"> & {
|
|
40
|
+
id: string;
|
|
41
|
+
}): Promise<WaitForTransactionReceiptReturnType<config, chainId>>;
|
|
42
|
+
export declare function waitForTransactionReceiptQueryOptions<config extends Config, chainId extends config["chains"][number]["id"] = config["chains"][number]["id"]>(config: config, options: Omit<WaitForTransactionReceiptOptions<config, chainId>, "hash" | "onReplaced"> & {
|
|
43
|
+
id?: string;
|
|
44
|
+
capabilities?: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"];
|
|
45
|
+
}): {
|
|
46
|
+
readonly queryFn: ({ queryKey }: {
|
|
47
|
+
queryKey: readonly ["waitForTransactionReceipt", {
|
|
48
|
+
scopeKey?: string | undefined;
|
|
49
|
+
pollingInterval?: number | undefined;
|
|
50
|
+
chainId?: config["chains"][number]["id"] | (chainId extends config["chains"][number]["id"] ? chainId : undefined) | undefined;
|
|
51
|
+
retryDelay?: number | ((config: {
|
|
52
|
+
count: number;
|
|
53
|
+
error: Error;
|
|
54
|
+
}) => number) | undefined;
|
|
55
|
+
confirmations?: number | undefined;
|
|
56
|
+
retryCount?: number | undefined;
|
|
57
|
+
timeout?: number | undefined;
|
|
58
|
+
id?: string | undefined;
|
|
59
|
+
capabilities?: WalletCapabilities | undefined;
|
|
60
|
+
}];
|
|
61
|
+
signal: AbortSignal;
|
|
62
|
+
meta: Record<string, unknown> | undefined;
|
|
63
|
+
pageParam?: unknown;
|
|
64
|
+
direction?: unknown;
|
|
65
|
+
}) => Promise<(import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]> extends infer T_2 extends readonly import("viem").Chain[] ? { [key_1 in keyof T_2]: import("viem").ExtractChainFormatterReturnType<import("@wagmi/core/dist/types/types/utils").IsNarrowable<import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1], import("viem").Chain> extends true ? import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1] : undefined, "transactionReceipt", import("viem").TransactionReceipt> & {
|
|
66
|
+
chainId: import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1]["id"];
|
|
67
|
+
}; } : never)[number] extends infer T ? { [key in keyof T]: (import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]> extends infer T_1 extends readonly import("viem").Chain[] ? { [key_1 in keyof T_1]: import("viem").ExtractChainFormatterReturnType<import("@wagmi/core/dist/types/types/utils").IsNarrowable<import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1], import("viem").Chain> extends true ? import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1] : undefined, "transactionReceipt", import("viem").TransactionReceipt> & {
|
|
68
|
+
chainId: import("@wagmi/core").SelectChains<config, config["chains"][number]["id"]>[key_1]["id"];
|
|
69
|
+
}; } : never)[number][key]; } : never>;
|
|
70
|
+
readonly queryKey: readonly ["waitForTransactionReceipt", {
|
|
71
|
+
scopeKey?: string | undefined;
|
|
72
|
+
pollingInterval?: number | undefined;
|
|
73
|
+
chainId?: config["chains"][number]["id"] | (config["chains"][number]["id"] extends infer T_3 ? T_3 extends config["chains"][number]["id"] ? T_3 extends config["chains"][number]["id"] ? T_3 : undefined : never : never) | undefined;
|
|
74
|
+
retryDelay?: number | ((config: {
|
|
75
|
+
count: number;
|
|
76
|
+
error: Error;
|
|
77
|
+
}) => number) | undefined;
|
|
78
|
+
confirmations?: number | undefined;
|
|
79
|
+
retryCount?: number | undefined;
|
|
80
|
+
timeout?: number | undefined;
|
|
81
|
+
id?: string | undefined;
|
|
82
|
+
capabilities?: WalletCapabilities | undefined;
|
|
83
|
+
}];
|
|
84
|
+
readonly retry: (failureCount: number, error: import("viem").ChainDisconnectedErrorType | import("viem/_types/utils/promise/createBatchScheduler").CreateBatchSchedulerErrorType | import("viem").HttpRequestErrorType | import("viem").InternalRpcErrorType | import("viem").InvalidInputRpcErrorType | import("viem").InvalidParamsRpcErrorType | import("viem").InvalidRequestRpcErrorType | import("viem/_types/errors/utils").ErrorType | import("viem").JsonRpcVersionUnsupportedErrorType | import("viem").LimitExceededRpcErrorType | import("viem").MethodNotFoundRpcErrorType | import("viem").MethodNotSupportedRpcErrorType | import("viem").ParseRpcErrorType | import("viem").ProviderDisconnectedErrorType | import("viem").ResourceNotFoundRpcErrorType | import("viem").ResourceUnavailableRpcErrorType | import("viem").RpcErrorType | import("viem").RpcRequestErrorType | import("viem/_types/errors/rpc").SwitchChainErrorType | import("viem").TimeoutErrorType | import("viem").TransactionRejectedRpcErrorType | import("viem").UnauthorizedProviderErrorType | import("viem").UnknownRpcErrorType | import("viem").UnsupportedProviderMethodErrorType | import("viem").UserRejectedRequestErrorType | import("viem").WebSocketRequestErrorType | import("viem").WithRetryErrorType | import("viem").BlockNotFoundErrorType | import("viem").IntegerOutOfRangeErrorType | import("viem").SizeExceedsPaddingSizeErrorType | import("viem/_types/utils/observe").ObserveErrorType | import("viem").TransactionReceiptNotFoundErrorType | import("viem/_types/utils/poll").PollErrorType) => boolean;
|
|
85
|
+
};
|
|
86
|
+
export type UseCallsStatusReturnType<selectData = GetCallsStatusData> = UseQueryReturnType<selectData, GetCallsStatusErrorType>;
|
|
87
|
+
export type UseWaitForTransactionReceiptReturnType<config extends Config = Config, chainId extends config["chains"][number]["id"] = config["chains"][number]["id"], selectData = WaitForTransactionReceiptData<config, chainId>> = UseQueryReturnType<selectData, WaitForTransactionReceiptErrorType | ShowCallsStatusErrorType>;
|
|
88
|
+
export type UseWaitForTransactionReceiptParameters<config extends Config = Config, chainId extends config["chains"][number]["id"] = config["chains"][number]["id"], selectData = WaitForTransactionReceiptData<config, chainId>> = Prettify<Omit<WaitForTransactionReceiptOptions<config, chainId>, "hash" | "onReplaced"> & {
|
|
89
|
+
id?: string;
|
|
90
|
+
} & ConfigParameter<config> & QueryParameter<WaitForTransactionReceiptQueryFnData<config, chainId>, WaitForTransactionReceiptErrorType, selectData, WaitForTransactionReceiptQueryKey<config, chainId>>>;
|
|
91
|
+
export declare function useWaitForTransactionReceipt<config extends Config = ResolvedRegister["config"], chainId extends config["chains"][number]["id"] = config["chains"][number]["id"], selectData = WaitForTransactionReceiptData<config, chainId>>(parameters?: UseWaitForTransactionReceiptParameters<config, chainId, selectData>): UseWaitForTransactionReceiptReturnType<config, chainId, selectData>;
|
|
92
|
+
//# sourceMappingURL=useWaitForTransactionReceipt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useWaitForTransactionReceipt.d.ts","sourceRoot":"","sources":["../../hooks/useWaitForTransactionReceipt.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACR,YAAY,EACZ,QAAQ,EAEX,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACH,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,kCAAkC,EACvC,KAAK,mCAAmC,EAG3C,MAAM,aAAa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B,CAChE,CAAA;AAED,MAAM,MAAM,sCAAsC,CAC9C,MAAM,SAAS,MAAM,GAAG,MAAM,EAC9B,OAAO,SACH,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EACnE,UAAU,GAAG,6BAA6B,CAAC,MAAM,EAAE,OAAO,CAAC,IAC3D,QAAQ,CACR,IAAI,CACA,gCAAgC,CAAC,MAAM,EAAE,OAAO,CAAC,EACjD,MAAM,GAAG,YAAY,CACxB,GAAG;IACA,EAAE,CAAC,EAAE,MAAM,CAAA;CACd,GAAG,eAAe,CAAC,MAAM,CAAC,GACvB,cAAc,CACV,oCAAoC,CAAC,MAAM,EAAE,OAAO,CAAC,EACrD,kCAAkC,EAClC,UAAU,EACV,iCAAiC,CAAC,MAAM,EAAE,OAAO,CAAC,CACrD,CACR,CAAA;AAED,wBAAgB,4BAA4B,CACxC,MAAM,SAAS,MAAM,GAAG,gBAAgB,CAAC,QAAQ,CAAC,EAClD,OAAO,SACH,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EACnE,UAAU,GAAG,6BAA6B,CAAC,MAAM,EAAE,OAAO,CAAC,EAE3D,UAAU,GAAE,sCAAsC,CAC9C,MAAM,EACN,OAAO,EACP,UAAU,CACR,GACP,sCAAsC,CAAC,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,CAoBrE"}
|
package/_types/index.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { type BiconomySmartAccountParameters, biconomySmartAccount } from "./connectors/biconomySmartAccount";
|
|
5
|
-
import { type KernelSmartAccountParameters, kernelSmartAccount } from "./connectors/kernelSmartAccount";
|
|
6
|
-
export { smartAccount, simpleSmartAccount, type SimpleSmartAccountParameters, safeSmartAccount, type SafeSmartAccountParameters, biconomySmartAccount, type BiconomySmartAccountParameters, kernelSmartAccount, type KernelSmartAccountParameters };
|
|
1
|
+
export { PermissionlessProvider, type PermissionlessProviderProps } from "./context";
|
|
2
|
+
export { useSendTransaction } from "./hooks/useSendTransaction";
|
|
3
|
+
export { useWaitForTransactionReceipt } from "./hooks/useWaitForTransactionReceipt";
|
|
7
4
|
//# sourceMappingURL=index.d.ts.map
|
package/_types/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,sBAAsB,EACtB,KAAK,2BAA2B,EACnC,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { MaybePromise } from "viem";
|
|
2
|
+
type Callback = ((...args: any[]) => any) | undefined;
|
|
3
|
+
type Callbacks = Record<string, Callback>;
|
|
4
|
+
export type ErrorType<name extends string = "Error"> = Error & {
|
|
5
|
+
name: name;
|
|
6
|
+
};
|
|
7
|
+
export type ObserveErrorType = ErrorType;
|
|
8
|
+
/** @internal */
|
|
9
|
+
export declare const listenersCache: Map<string, {
|
|
10
|
+
id: number;
|
|
11
|
+
fns: Callbacks;
|
|
12
|
+
}[]>;
|
|
13
|
+
/** @internal */
|
|
14
|
+
export declare const cleanupCache: Map<string, () => void>;
|
|
15
|
+
type EmitFunction<callbacks extends Callbacks> = (emit: callbacks) => MaybePromise<void | (() => void)>;
|
|
16
|
+
/**
|
|
17
|
+
* @description Sets up an observer for a given function. If another function
|
|
18
|
+
* is set up under the same observer id, the function will only be called once
|
|
19
|
+
* for both instances of the observer.
|
|
20
|
+
*/
|
|
21
|
+
export declare function observe<callbacks extends Callbacks>(observerId: string, callbacks: callbacks, fn: EmitFunction<callbacks>): () => void;
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=observe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observe.d.ts","sourceRoot":"","sources":["../../utils/observe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAA;AAExC,KAAK,QAAQ,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,SAAS,CAAA;AACrD,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;AAEzC,MAAM,MAAM,SAAS,CAAC,IAAI,SAAS,MAAM,GAAG,OAAO,IAAI,KAAK,GAAG;IAAE,IAAI,EAAE,IAAI,CAAA;CAAE,CAAA;AAE7E,MAAM,MAAM,gBAAgB,GAAG,SAAS,CAAA;AAExC,gBAAgB;AAChB,eAAO,MAAM,cAAc;QAEjB,MAAM;SAAO,SAAS;IAC7B,CAAA;AACH,gBAAgB;AAChB,eAAO,MAAM,YAAY,oBAAuC,IAAI,CAAG,CAAA;AAEvE,KAAK,YAAY,CAAC,SAAS,SAAS,SAAS,IAAI,CAC7C,IAAI,EAAE,SAAS,KAEd,YAAY,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC,CAAA;AAItC;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,SAAS,SAAS,SAAS,EAC/C,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,EACpB,EAAE,EAAE,YAAY,CAAC,SAAS,CAAC,cA2C9B"}
|
package/context.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createContext, createElement } from "react"
|
|
2
|
+
import type { WalletCapabilities, WalletSendCallsParameters } from "viem"
|
|
3
|
+
|
|
4
|
+
export const PermissionlessContext = createContext<{
|
|
5
|
+
capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"]
|
|
6
|
+
}>({
|
|
7
|
+
capabilities: {}
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
export type PermissionlessProviderProps = {
|
|
11
|
+
capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PermissionlessProvider = (
|
|
15
|
+
parameters: React.PropsWithChildren<PermissionlessProviderProps>
|
|
16
|
+
) => {
|
|
17
|
+
const { capabilities, children } = parameters
|
|
18
|
+
|
|
19
|
+
const props = { value: { capabilities } }
|
|
20
|
+
|
|
21
|
+
return createElement(PermissionlessContext.Provider, props, children)
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import { useContext, useMemo } from "react"
|
|
4
|
+
import type { WalletCapabilities, WalletSendCallsParameters } from "viem"
|
|
5
|
+
import { useAccount } from "wagmi"
|
|
6
|
+
import { useCapabilities } from "wagmi/experimental"
|
|
7
|
+
import { PermissionlessContext } from "../context"
|
|
8
|
+
|
|
9
|
+
export const useAvailableCapabilities = () => {
|
|
10
|
+
const { capabilities: capabilitiesConfigured } = useContext(
|
|
11
|
+
PermissionlessContext
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
const account = useAccount()
|
|
15
|
+
|
|
16
|
+
const { data: availableCapabilities } = useCapabilities({
|
|
17
|
+
account: account.address
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
const memoisedCapabilities = useMemo(() => {
|
|
21
|
+
if (!availableCapabilities || !account.chainId) return undefined
|
|
22
|
+
const capabilitiesForChain = availableCapabilities[account.chainId]
|
|
23
|
+
if (capabilitiesConfigured === undefined) return undefined
|
|
24
|
+
|
|
25
|
+
let capabilities: WalletSendCallsParameters<WalletCapabilities>[number]["capabilities"] =
|
|
26
|
+
undefined
|
|
27
|
+
|
|
28
|
+
for (const capabilityConfigured in capabilitiesConfigured) {
|
|
29
|
+
if (capabilitiesForChain[capabilityConfigured]?.supported) {
|
|
30
|
+
if (!capabilities) {
|
|
31
|
+
capabilities = {}
|
|
32
|
+
}
|
|
33
|
+
capabilities[capabilityConfigured] = {
|
|
34
|
+
...capabilitiesConfigured[capabilityConfigured]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return capabilities
|
|
40
|
+
}, [availableCapabilities, account.chainId, capabilitiesConfigured])
|
|
41
|
+
|
|
42
|
+
return { capabilities: memoisedCapabilities }
|
|
43
|
+
}
|