thirdweb 5.98.2 → 5.99.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/exports/react.js +11 -8
- package/dist/cjs/exports/react.js.map +1 -1
- package/dist/cjs/exports/react.native.js +11 -8
- package/dist/cjs/exports/react.native.js.map +1 -1
- package/dist/cjs/exports/wallets/eip5792.js +7 -3
- package/dist/cjs/exports/wallets/eip5792.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useCapabilities.js +5 -6
- package/dist/cjs/react/core/hooks/wallets/useCapabilities.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useSendAndConfirmCalls.js +99 -0
- package/dist/cjs/react/core/hooks/wallets/useSendAndConfirmCalls.js.map +1 -0
- package/dist/cjs/react/core/hooks/wallets/useSendCalls.js +32 -40
- package/dist/cjs/react/core/hooks/wallets/useSendCalls.js.map +1 -1
- package/dist/cjs/react/core/hooks/wallets/useWaitForCallsReceipt.js +38 -0
- package/dist/cjs/react/core/hooks/wallets/useWaitForCallsReceipt.js.map +1 -0
- package/dist/cjs/react/core/providers/thirdweb-provider.js +4 -3
- package/dist/cjs/react/core/providers/thirdweb-provider.js.map +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/wallets/coinbase/coinbase-web.js +2 -85
- package/dist/cjs/wallets/coinbase/coinbase-web.js.map +1 -1
- package/dist/cjs/wallets/eip5792/get-calls-status.js +54 -15
- package/dist/cjs/wallets/eip5792/get-calls-status.js.map +1 -1
- package/dist/cjs/wallets/eip5792/get-capabilities.js +21 -8
- package/dist/cjs/wallets/eip5792/get-capabilities.js.map +1 -1
- package/dist/cjs/wallets/eip5792/send-and-confirm-calls.js +41 -0
- package/dist/cjs/wallets/eip5792/send-and-confirm-calls.js.map +1 -0
- package/dist/cjs/wallets/eip5792/send-calls.js +27 -14
- package/dist/cjs/wallets/eip5792/send-calls.js.map +1 -1
- package/dist/cjs/wallets/eip5792/show-calls-status.js +8 -7
- package/dist/cjs/wallets/eip5792/show-calls-status.js.map +1 -1
- package/dist/cjs/wallets/eip5792/{wait-for-bundle.js → wait-for-calls-receipt.js} +23 -10
- package/dist/cjs/wallets/eip5792/wait-for-calls-receipt.js.map +1 -0
- package/dist/cjs/wallets/in-app/core/eip5972/in-app-wallet-calls.js +15 -10
- package/dist/cjs/wallets/in-app/core/eip5972/in-app-wallet-calls.js.map +1 -1
- package/dist/cjs/wallets/in-app/core/eip5972/in-app-wallet-capabilities.js +13 -3
- package/dist/cjs/wallets/in-app/core/eip5972/in-app-wallet-capabilities.js.map +1 -1
- package/dist/cjs/wallets/smart/lib/smart-wallet-capabilities.js +4 -2
- package/dist/cjs/wallets/smart/lib/smart-wallet-capabilities.js.map +1 -1
- package/dist/esm/exports/react.js +5 -3
- package/dist/esm/exports/react.js.map +1 -1
- package/dist/esm/exports/react.native.js +5 -3
- package/dist/esm/exports/react.native.js.map +1 -1
- package/dist/esm/exports/wallets/eip5792.js +3 -1
- package/dist/esm/exports/wallets/eip5792.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useCapabilities.js +5 -6
- package/dist/esm/react/core/hooks/wallets/useCapabilities.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useSendAndConfirmCalls.js +96 -0
- package/dist/esm/react/core/hooks/wallets/useSendAndConfirmCalls.js.map +1 -0
- package/dist/esm/react/core/hooks/wallets/useSendCalls.js +32 -40
- package/dist/esm/react/core/hooks/wallets/useSendCalls.js.map +1 -1
- package/dist/esm/react/core/hooks/wallets/useWaitForCallsReceipt.js +35 -0
- package/dist/esm/react/core/hooks/wallets/useWaitForCallsReceipt.js.map +1 -0
- package/dist/esm/react/core/providers/thirdweb-provider.js +4 -3
- package/dist/esm/react/core/providers/thirdweb-provider.js.map +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/wallets/coinbase/coinbase-web.js +2 -81
- package/dist/esm/wallets/coinbase/coinbase-web.js.map +1 -1
- package/dist/esm/wallets/eip5792/get-calls-status.js +54 -15
- package/dist/esm/wallets/eip5792/get-calls-status.js.map +1 -1
- package/dist/esm/wallets/eip5792/get-capabilities.js +22 -9
- package/dist/esm/wallets/eip5792/get-capabilities.js.map +1 -1
- package/dist/esm/wallets/eip5792/send-and-confirm-calls.js +38 -0
- package/dist/esm/wallets/eip5792/send-and-confirm-calls.js.map +1 -0
- package/dist/esm/wallets/eip5792/send-calls.js +28 -15
- package/dist/esm/wallets/eip5792/send-calls.js.map +1 -1
- package/dist/esm/wallets/eip5792/show-calls-status.js +9 -8
- package/dist/esm/wallets/eip5792/show-calls-status.js.map +1 -1
- package/dist/esm/wallets/eip5792/{wait-for-bundle.js → wait-for-calls-receipt.js} +22 -9
- package/dist/esm/wallets/eip5792/wait-for-calls-receipt.js.map +1 -0
- package/dist/esm/wallets/in-app/core/eip5972/in-app-wallet-calls.js +15 -10
- package/dist/esm/wallets/in-app/core/eip5972/in-app-wallet-calls.js.map +1 -1
- package/dist/esm/wallets/in-app/core/eip5972/in-app-wallet-capabilities.js +13 -3
- package/dist/esm/wallets/in-app/core/eip5972/in-app-wallet-capabilities.js.map +1 -1
- package/dist/esm/wallets/smart/lib/smart-wallet-capabilities.js +4 -2
- package/dist/esm/wallets/smart/lib/smart-wallet-capabilities.js.map +1 -1
- package/dist/types/exports/react.d.ts +4 -3
- package/dist/types/exports/react.d.ts.map +1 -1
- package/dist/types/exports/react.native.d.ts +4 -3
- package/dist/types/exports/react.native.d.ts.map +1 -1
- package/dist/types/exports/wallets/eip5792.d.ts +3 -1
- package/dist/types/exports/wallets/eip5792.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useCapabilities.d.ts +1 -0
- package/dist/types/react/core/hooks/wallets/useCapabilities.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useSendAndConfirmCalls.d.ts +66 -0
- package/dist/types/react/core/hooks/wallets/useSendAndConfirmCalls.d.ts.map +1 -0
- package/dist/types/react/core/hooks/wallets/useSendCalls.d.ts +8 -11
- package/dist/types/react/core/hooks/wallets/useSendCalls.d.ts.map +1 -1
- package/dist/types/react/core/hooks/wallets/useWaitForCallsReceipt.d.ts +32 -0
- package/dist/types/react/core/hooks/wallets/useWaitForCallsReceipt.d.ts.map +1 -0
- package/dist/types/react/core/providers/thirdweb-provider.d.ts.map +1 -1
- package/dist/types/version.d.ts +1 -1
- package/dist/types/wallets/coinbase/coinbase-web.d.ts +2 -30
- package/dist/types/wallets/coinbase/coinbase-web.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/get-calls-status.d.ts +5 -6
- package/dist/types/wallets/eip5792/get-calls-status.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/get-capabilities.d.ts +2 -1
- package/dist/types/wallets/eip5792/get-capabilities.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/send-and-confirm-calls.d.ts +39 -0
- package/dist/types/wallets/eip5792/send-and-confirm-calls.d.ts.map +1 -0
- package/dist/types/wallets/eip5792/send-calls.d.ts +12 -5
- package/dist/types/wallets/eip5792/send-calls.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/show-calls-status.d.ts +2 -2
- package/dist/types/wallets/eip5792/show-calls-status.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/types.d.ts +33 -4
- package/dist/types/wallets/eip5792/types.d.ts.map +1 -1
- package/dist/types/wallets/eip5792/{wait-for-bundle.d.ts → wait-for-calls-receipt.d.ts} +21 -9
- package/dist/types/wallets/eip5792/wait-for-calls-receipt.d.ts.map +1 -0
- package/dist/types/wallets/in-app/core/eip5972/in-app-wallet-calls.d.ts +3 -3
- package/dist/types/wallets/in-app/core/eip5972/in-app-wallet-calls.d.ts.map +1 -1
- package/dist/types/wallets/in-app/core/eip5972/in-app-wallet-capabilities.d.ts +3 -3
- package/dist/types/wallets/in-app/core/eip5972/in-app-wallet-capabilities.d.ts.map +1 -1
- package/dist/types/wallets/smart/lib/smart-wallet-capabilities.d.ts +2 -2
- package/dist/types/wallets/smart/lib/smart-wallet-capabilities.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/exports/react.native.ts +6 -3
- package/src/exports/react.ts +6 -3
- package/src/exports/wallets/eip5792.ts +5 -3
- package/src/react/core/hooks/wallets/useCapabilities.ts +6 -6
- package/src/react/core/hooks/wallets/useSendAndConfirmCalls.ts +114 -0
- package/src/react/core/hooks/wallets/useSendCalls.ts +33 -50
- package/src/react/core/hooks/wallets/useWaitForCallsReceipt.ts +43 -0
- package/src/react/core/providers/thirdweb-provider.tsx +4 -3
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbase-web.ts +6 -117
- package/src/wallets/eip5792/get-calls-status.test.ts +27 -33
- package/src/wallets/eip5792/get-calls-status.ts +68 -19
- package/src/wallets/eip5792/get-capabilities.test.ts +10 -10
- package/src/wallets/eip5792/get-capabilities.ts +33 -11
- package/src/wallets/eip5792/send-and-confirm-calls.ts +48 -0
- package/src/wallets/eip5792/send-calls.test.ts +7 -7
- package/src/wallets/eip5792/send-calls.ts +43 -21
- package/src/wallets/eip5792/show-calls-status.test.ts +3 -3
- package/src/wallets/eip5792/show-calls-status.ts +13 -12
- package/src/wallets/eip5792/types.ts +43 -4
- package/src/wallets/eip5792/{wait-for-bundle.test.ts → wait-for-calls-receipt.test.ts} +19 -9
- package/src/wallets/eip5792/{wait-for-bundle.ts → wait-for-calls-receipt.ts} +26 -16
- package/src/wallets/in-app/core/eip5972/in-app-wallet-calls.ts +17 -16
- package/src/wallets/in-app/core/eip5972/in-app-wallet-capabilities.ts +14 -3
- package/src/wallets/smart/lib/smart-wallet-capabilities.ts +5 -2
- package/dist/cjs/react/core/hooks/wallets/useCallsStatus.js +0 -41
- package/dist/cjs/react/core/hooks/wallets/useCallsStatus.js.map +0 -1
- package/dist/cjs/wallets/eip5792/wait-for-bundle.js.map +0 -1
- package/dist/esm/react/core/hooks/wallets/useCallsStatus.js +0 -38
- package/dist/esm/react/core/hooks/wallets/useCallsStatus.js.map +0 -1
- package/dist/esm/wallets/eip5792/wait-for-bundle.js.map +0 -1
- package/dist/types/react/core/hooks/wallets/useCallsStatus.d.ts +0 -26
- package/dist/types/react/core/hooks/wallets/useCallsStatus.d.ts.map +0 -1
- package/dist/types/wallets/eip5792/wait-for-bundle.d.ts.map +0 -1
- package/src/react/core/hooks/wallets/useCallsStatus.ts +0 -48
@@ -0,0 +1,39 @@
|
|
1
|
+
import type { WalletId } from "../wallet-types.js";
|
2
|
+
import { type SendCallsOptions } from "./send-calls.js";
|
3
|
+
import type { GetCallsStatusResponse } from "./types.js";
|
4
|
+
/**
|
5
|
+
* Send and confirm calls in a single transaction.
|
6
|
+
*
|
7
|
+
* This is a convenience function that sends the calls with `sendCalls` and then waits for the receipts with `waitForCallsReceipt`.
|
8
|
+
*
|
9
|
+
* @param options - The options for sending and confirming calls.
|
10
|
+
* @returns The receipts of the calls.
|
11
|
+
* @example
|
12
|
+
* ```ts
|
13
|
+
* const call1 = approve({
|
14
|
+
* contract: USDT_CONTRACT,
|
15
|
+
* amount: 100,
|
16
|
+
* spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
17
|
+
* });
|
18
|
+
* const call2 = transfer({
|
19
|
+
* contract: USDT_CONTRACT,
|
20
|
+
* to: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
21
|
+
* amount: 100,
|
22
|
+
* });
|
23
|
+
* const result = await sendAndConfirmCalls({
|
24
|
+
* calls: [call1, call2],
|
25
|
+
* wallet: wallet,
|
26
|
+
* });
|
27
|
+
* console.log("Transaction receipts:", result.receipts);
|
28
|
+
* ```
|
29
|
+
* @extension EIP5792
|
30
|
+
* @beta
|
31
|
+
*/
|
32
|
+
export declare function sendAndConfirmCalls<const ID extends WalletId>(options: SendCallsOptions<ID> & {
|
33
|
+
/**
|
34
|
+
* The maximum number of blocks to wait for the calls to be confirmed.
|
35
|
+
* @defaultValue 100
|
36
|
+
*/
|
37
|
+
maxBlocksWaitTime?: number;
|
38
|
+
}): Promise<GetCallsStatusResponse>;
|
39
|
+
//# sourceMappingURL=send-and-confirm-calls.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"send-and-confirm-calls.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/send-and-confirm-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAa,MAAM,iBAAiB,CAAC;AACnE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGzD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,CAAC,EAAE,SAAS,QAAQ,EACjE,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG;IAC9B;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GACA,OAAO,CAAC,sBAAsB,CAAC,CAMjC"}
|
@@ -4,7 +4,7 @@ import type { ThirdwebClient } from "../../client/client.js";
|
|
4
4
|
import type { PreparedTransaction } from "../../transaction/prepare-transaction.js";
|
5
5
|
import { type Hex } from "../../utils/encoding/hex.js";
|
6
6
|
import { type PromisedObject } from "../../utils/promise/resolve-promised-value.js";
|
7
|
-
import type { OneOf } from "../../utils/type-utils.js";
|
7
|
+
import type { OneOf, Prettify } from "../../utils/type-utils.js";
|
8
8
|
import type { Wallet } from "../interfaces/wallet.js";
|
9
9
|
import type { WalletId } from "../wallet-types.js";
|
10
10
|
import type { WalletSendCallsId, WalletSendCallsParameters } from "./types.js";
|
@@ -18,15 +18,20 @@ export type PrepareCallOptions = {
|
|
18
18
|
chain: Chain;
|
19
19
|
client: ThirdwebClient;
|
20
20
|
} & PromisedObject<WalletCall>;
|
21
|
-
export type SendCallsOptions<ID extends WalletId = WalletId, abi extends Abi = [], abiFunction extends AbiFunction = AbiFunction> = {
|
21
|
+
export type SendCallsOptions<ID extends WalletId = WalletId, abi extends Abi = [], abiFunction extends AbiFunction = AbiFunction> = Prettify<{
|
22
22
|
wallet: Wallet<ID>;
|
23
23
|
calls: PreparedSendCall<abi, abiFunction>[];
|
24
24
|
capabilities?: WalletSendCallsParameters[number]["capabilities"];
|
25
25
|
version?: WalletSendCallsParameters[number]["version"];
|
26
26
|
chain?: Chain;
|
27
27
|
atomicRequired?: boolean;
|
28
|
-
}
|
29
|
-
export type SendCallsResult =
|
28
|
+
}>;
|
29
|
+
export type SendCallsResult = Prettify<{
|
30
|
+
id: WalletSendCallsId;
|
31
|
+
client: ThirdwebClient;
|
32
|
+
chain: Chain;
|
33
|
+
wallet: Wallet;
|
34
|
+
}>;
|
30
35
|
/**
|
31
36
|
* Send [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) calls to a wallet.
|
32
37
|
* This function works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792.
|
@@ -53,6 +58,7 @@ export type SendCallsResult = WalletSendCallsId;
|
|
53
58
|
*
|
54
59
|
* const client = createThirdwebClient({ clientId: ... });
|
55
60
|
* const wallet = createWallet("com.coinbase.wallet");
|
61
|
+
* await wallet.connect({ client });
|
56
62
|
*
|
57
63
|
* const sendTx1 = approve({
|
58
64
|
contract: USDT_CONTRACT,
|
@@ -82,8 +88,9 @@ export type SendCallsResult = WalletSendCallsId;
|
|
82
88
|
* }
|
83
89
|
* }
|
84
90
|
* });
|
85
|
-
* We recommend proxying any paymaster calls via an API route you setup and control.
|
86
91
|
* ```
|
92
|
+
* We recommend proxying any paymaster calls via an API route you setup and control.
|
93
|
+
*
|
87
94
|
* @extension EIP5792
|
88
95
|
*/
|
89
96
|
export declare function sendCalls<const ID extends WalletId>(options: SendCallsOptions<ID>): Promise<SendCallsResult>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"send-calls.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/send-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;A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
type ShowCallsStatusOptions = {
|
4
4
|
wallet: Wallet;
|
5
|
-
|
5
|
+
id: WalletSendCallsId;
|
6
6
|
};
|
7
7
|
/**
|
8
8
|
* Request a wallet to show the status of a bundle of calls.
|
@@ -28,6 +28,6 @@ type ShowCallsStatusOptions = {
|
|
28
28
|
* @extension EIP5792
|
29
29
|
* @internal
|
30
30
|
*/
|
31
|
-
export declare function showCallsStatus({ wallet,
|
31
|
+
export declare function showCallsStatus({ wallet, id, }: ShowCallsStatusOptions): Promise<void>;
|
32
32
|
export {};
|
33
33
|
//# sourceMappingURL=show-calls-status.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"show-calls-status.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/show-calls-status.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"show-calls-status.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/show-calls-status.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,KAAK,sBAAsB,GAAG;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,iBAAiB,CAAC;CACvB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,EAAE,GACH,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgCxC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { Address } from "../../utils/address.js";
|
2
2
|
import type { Hex } from "../../utils/encoding/hex.js";
|
3
|
-
import type { OneOf } from "../../utils/type-utils.js";
|
3
|
+
import type { OneOf, Prettify } from "../../utils/type-utils.js";
|
4
4
|
export type WalletCapabilities = {
|
5
5
|
[capability: string]: unknown;
|
6
6
|
};
|
@@ -27,9 +27,37 @@ export type EIP5792Call = OneOf<{
|
|
27
27
|
} | {
|
28
28
|
data: Hex;
|
29
29
|
}>;
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
type WalletGetCallsStatusReturnType<numberType = Hex, bigintType = Hex, receiptStatus = Hex> = Prettify<{
|
31
|
+
atomic: boolean;
|
32
|
+
chainId: numberType;
|
33
|
+
id: string;
|
34
|
+
receipts?: WalletCallReceipt<bigintType, receiptStatus>[] | undefined;
|
35
|
+
status: number;
|
36
|
+
version: string;
|
37
|
+
}>;
|
38
|
+
export type GetCallsStatusResponse = Prettify<Omit<WalletGetCallsStatusReturnType<number, bigint, "success" | "reverted">, "status"> & {
|
39
|
+
statusCode: number;
|
40
|
+
status: "pending" | "success" | "failure" | undefined;
|
41
|
+
}>;
|
42
|
+
export type GetCallsStatusRawResponse = {
|
43
|
+
version: string;
|
44
|
+
id: `0x${string}`;
|
45
|
+
chainId: `0x${string}`;
|
46
|
+
status: number;
|
47
|
+
atomic: boolean;
|
48
|
+
receipts?: {
|
49
|
+
logs: {
|
50
|
+
address: `0x${string}`;
|
51
|
+
data: `0x${string}`;
|
52
|
+
topics: `0x${string}`[];
|
53
|
+
}[];
|
54
|
+
status: `0x${string}`;
|
55
|
+
blockHash: `0x${string}`;
|
56
|
+
blockNumber: `0x${string}`;
|
57
|
+
gasUsed: `0x${string}`;
|
58
|
+
transactionHash: `0x${string}`;
|
59
|
+
}[];
|
60
|
+
capabilities?: Record<string, unknown>;
|
33
61
|
};
|
34
62
|
export type WalletCallReceipt<quantity = Hex, status = Hex> = {
|
35
63
|
logs: {
|
@@ -43,4 +71,5 @@ export type WalletCallReceipt<quantity = Hex, status = Hex> = {
|
|
43
71
|
gasUsed: quantity;
|
44
72
|
transactionHash: Hex;
|
45
73
|
};
|
74
|
+
export {};
|
46
75
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/types.ts"],"names":[],"mappings":"AAAA,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AAE,KAAK,MAAM,EAAE,CAAC;QAC3B,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;QACvB,eAAe,EAAE,KAAK,MAAM,EAAE,CAAC;KAChC,EAAE,CAAC;IACJ,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,QAAQ,GAAG,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI;IAC5D,IAAI,EAAE;QACJ,OAAO,EAAE,MAAM,CAAC;QAChB,IAAI,EAAE,GAAG,CAAC;QACV,MAAM,EAAE,GAAG,EAAE,CAAC;KACf,EAAE,CAAC;IACJ,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,GAAG,CAAC;IACf,WAAW,EAAE,QAAQ,CAAC;IACtB,OAAO,EAAE,QAAQ,CAAC;IAClB,eAAe,EAAE,GAAG,CAAC;CACtB,CAAC"}
|
@@ -2,12 +2,12 @@ import type { Chain } from "../../chains/types.js";
|
|
2
2
|
import type { ThirdwebClient } from "../../client/client.js";
|
3
3
|
import type { Prettify } from "../../utils/type-utils.js";
|
4
4
|
import type { Wallet } from "../interfaces/wallet.js";
|
5
|
-
import type { GetCallsStatusResponse
|
6
|
-
export type
|
7
|
-
|
8
|
-
wallet: Wallet;
|
5
|
+
import type { GetCallsStatusResponse } from "./types.js";
|
6
|
+
export type WaitForCallsReceiptOptions = Prettify<{
|
7
|
+
id: string;
|
9
8
|
client: ThirdwebClient;
|
10
9
|
chain: Chain;
|
10
|
+
wallet: Wallet;
|
11
11
|
maxBlocksWaitTime?: number;
|
12
12
|
}>;
|
13
13
|
/**
|
@@ -22,15 +22,27 @@ export type WaitForBundleOptions = Prettify<{
|
|
22
22
|
* @beta
|
23
23
|
* @example
|
24
24
|
* ```ts
|
25
|
-
* import {
|
26
|
-
* const result = await
|
25
|
+
* import { waitForCallsReceipt } from "thirdweb/wallets/eip5792";
|
26
|
+
* const result = await waitForCallsReceipt({
|
27
|
+
* client,
|
28
|
+
* chain,
|
29
|
+
* wallet,
|
30
|
+
* id: "0x123...",
|
31
|
+
* });
|
32
|
+
* ```
|
33
|
+
*
|
34
|
+
* Example with useSendCalls:
|
35
|
+
* ```ts
|
36
|
+
* const sendResult = await sendCalls({
|
27
37
|
* client,
|
28
38
|
* chain,
|
29
39
|
* wallet,
|
30
|
-
*
|
40
|
+
* calls: [...],
|
31
41
|
* });
|
42
|
+
* const confirmResult = await waitForCallsReceipt(sendResult);
|
43
|
+
* console.log("Transaction confirmed: ", confirmResult.receipts?.[0].transactionHash);
|
32
44
|
* ```
|
33
45
|
* @extension EIP5792
|
34
46
|
*/
|
35
|
-
export declare function
|
36
|
-
//# sourceMappingURL=wait-for-
|
47
|
+
export declare function waitForCallsReceipt(options: WaitForCallsReceiptOptions): Promise<GetCallsStatusResponse>;
|
48
|
+
//# sourceMappingURL=wait-for-calls-receipt.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"wait-for-calls-receipt.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/wait-for-calls-receipt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAKzD,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAAC;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,cAAc,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,sBAAsB,CAAC,CAqDjC"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ThirdwebClient } from "../../../../client/client.js";
|
2
2
|
import type { PreparedSendCall } from "../../../eip5792/send-calls.js";
|
3
|
-
import type { GetCallsStatusResponse
|
3
|
+
import type { GetCallsStatusResponse } from "../../../eip5792/types.js";
|
4
4
|
import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
5
5
|
/**
|
6
6
|
* @internal
|
@@ -8,13 +8,13 @@ import type { Account, Wallet } from "../../../interfaces/wallet.js";
|
|
8
8
|
export declare function inAppWalletSendCalls(args: {
|
9
9
|
account: Account;
|
10
10
|
calls: PreparedSendCall[];
|
11
|
-
}): Promise<
|
11
|
+
}): Promise<string>;
|
12
12
|
/**
|
13
13
|
* @internal
|
14
14
|
*/
|
15
15
|
export declare function inAppWalletGetCallsStatus(args: {
|
16
16
|
wallet: Wallet;
|
17
17
|
client: ThirdwebClient;
|
18
|
-
|
18
|
+
id: string;
|
19
19
|
}): Promise<GetCallsStatusResponse>;
|
20
20
|
//# sourceMappingURL=in-app-wallet-calls.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"in-app-wallet-calls.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/eip5972/in-app-wallet-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EACV,sBAAsB,
|
1
|
+
{"version":3,"file":"in-app-wallet-calls.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/eip5972/in-app-wallet-calls.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAQnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EACV,sBAAsB,EAEvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAIrE;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,IAAI,EAAE;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,gBAAgB,EAAE,CAAC;CAC3B,GAAG,OAAO,CAAC,MAAM,CAAC,CAyBlB;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,cAAc,CAAC;IACvB,EAAE,EAAE,MAAM,CAAC;CACZ,GAAG,OAAO,CAAC,sBAAsB,CAAC,CA+ClC"}
|
@@ -9,10 +9,10 @@ export declare function inAppWalletGetCapabilities(args: {
|
|
9
9
|
} | {
|
10
10
|
[x: number]: {
|
11
11
|
paymasterService: {
|
12
|
-
supported: boolean;
|
12
|
+
supported: boolean | undefined;
|
13
13
|
};
|
14
|
-
|
15
|
-
|
14
|
+
atomic: {
|
15
|
+
status: string;
|
16
16
|
};
|
17
17
|
};
|
18
18
|
message?: undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"in-app-wallet-capabilities.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/eip5972/in-app-wallet-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAE5D;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;CACtC;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"in-app-wallet-capabilities.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/eip5972/in-app-wallet-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAE5D;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC,OAAO,GAAG,UAAU,CAAC,CAAC;CACtC;;;;;;;;;;;;EAuCA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"smart-wallet-capabilities.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/smart-wallet-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"smart-wallet-capabilities.d.ts","sourceRoot":"","sources":["../../../../../src/wallets/smart/lib/smart-wallet-capabilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,EAAE;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;;;;;;;;;;;;EA0BA"}
|
package/package.json
CHANGED
@@ -14,21 +14,24 @@ export { useActiveWalletChain } from "../react/core/hooks/wallets/useActiveWalle
|
|
14
14
|
export { useActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useActiveWalletConnectionStatus.js";
|
15
15
|
export { useActiveAccount } from "../react/core/hooks/wallets/useActiveAccount.js";
|
16
16
|
export { useAutoConnect } from "../react/native/hooks/wallets/useAutoConnect.js";
|
17
|
-
export { useCapabilities } from "../react/core/hooks/wallets/useCapabilities.js";
|
18
17
|
export { useConnect } from "../react/core/hooks/wallets/useConnect.js";
|
19
18
|
export { useConnectedWallets } from "../react/core/hooks/wallets/useConnectedWallets.js";
|
20
19
|
export { useDisconnect } from "../react/core/hooks/wallets/useDisconnect.js";
|
21
20
|
export { useIsAutoConnecting } from "../react/core/hooks/wallets/useIsAutoConnecting.js";
|
22
21
|
export { useSetActiveWallet } from "../react/core/hooks/wallets/useSetActiveWallet.js";
|
23
22
|
export { useSetActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useSetActiveWalletConnectionStatus.js";
|
24
|
-
export { useSendCalls } from "../react/core/hooks/wallets/useSendCalls.js";
|
25
23
|
export { useSwitchActiveWalletChain } from "../react/core/hooks/wallets/useSwitchActiveWalletChain.js";
|
26
|
-
export { useCallsStatus } from "../react/core/hooks/wallets/useCallsStatus.js";
|
27
24
|
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
28
25
|
export { useProfiles } from "../react/native/hooks/wallets/useProfiles.js";
|
29
26
|
export { useLinkProfile } from "../react/native/hooks/wallets/useLinkProfile.js";
|
30
27
|
export { useUnlinkProfile } from "../react/native/hooks/wallets/useUnlinkProfile.js";
|
31
28
|
|
29
|
+
// eip5792
|
30
|
+
export { useCapabilities } from "../react/core/hooks/wallets/useCapabilities.js";
|
31
|
+
export { useSendCalls } from "../react/core/hooks/wallets/useSendCalls.js";
|
32
|
+
export { useSendAndConfirmCalls } from "../react/core/hooks/wallets/useSendAndConfirmCalls.js";
|
33
|
+
export { useWaitForCallsReceipt } from "../react/core/hooks/wallets/useWaitForCallsReceipt.js";
|
34
|
+
|
32
35
|
// contract
|
33
36
|
export { useReadContract } from "../react/core/hooks/contract/useReadContract.js";
|
34
37
|
export { useWaitForReceipt } from "../react/core/hooks/contract/useWaitForReceipt.js";
|
package/src/exports/react.ts
CHANGED
@@ -45,21 +45,24 @@ export { useActiveWalletChain } from "../react/core/hooks/wallets/useActiveWalle
|
|
45
45
|
export { useActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useActiveWalletConnectionStatus.js";
|
46
46
|
export { useActiveAccount } from "../react/core/hooks/wallets/useActiveAccount.js";
|
47
47
|
export { useAutoConnect } from "../react/web/hooks/wallets/useAutoConnect.js";
|
48
|
-
export { useCapabilities } from "../react/core/hooks/wallets/useCapabilities.js";
|
49
48
|
export { useConnect } from "../react/core/hooks/wallets/useConnect.js";
|
50
49
|
export { useConnectedWallets } from "../react/core/hooks/wallets/useConnectedWallets.js";
|
51
50
|
export { useDisconnect } from "../react/core/hooks/wallets/useDisconnect.js";
|
52
51
|
export { useIsAutoConnecting } from "../react/core/hooks/wallets/useIsAutoConnecting.js";
|
53
52
|
export { useSetActiveWallet } from "../react/core/hooks/wallets/useSetActiveWallet.js";
|
54
53
|
export { useSetActiveWalletConnectionStatus } from "../react/core/hooks/wallets/useSetActiveWalletConnectionStatus.js";
|
55
|
-
export { useSendCalls } from "../react/core/hooks/wallets/useSendCalls.js";
|
56
54
|
export { useSwitchActiveWalletChain } from "../react/core/hooks/wallets/useSwitchActiveWalletChain.js";
|
57
|
-
export { useCallsStatus } from "../react/core/hooks/wallets/useCallsStatus.js";
|
58
55
|
export { useWalletBalance } from "../react/core/hooks/others/useWalletBalance.js";
|
59
56
|
export { useProfiles } from "../react/web/hooks/wallets/useProfiles.js";
|
60
57
|
export { useLinkProfile } from "../react/web/hooks/wallets/useLinkProfile.js";
|
61
58
|
export { useUnlinkProfile } from "../react/web/hooks/wallets/useUnlinkProfile.js";
|
62
59
|
|
60
|
+
// eip5792
|
61
|
+
export { useCapabilities } from "../react/core/hooks/wallets/useCapabilities.js";
|
62
|
+
export { useSendCalls } from "../react/core/hooks/wallets/useSendCalls.js";
|
63
|
+
export { useSendAndConfirmCalls } from "../react/core/hooks/wallets/useSendAndConfirmCalls.js";
|
64
|
+
export { useWaitForCallsReceipt } from "../react/core/hooks/wallets/useWaitForCallsReceipt.js";
|
65
|
+
|
63
66
|
// chain hooks
|
64
67
|
export { useChainMetadata } from "../react/core/hooks/others/useChainQuery.js";
|
65
68
|
|
@@ -4,6 +4,8 @@ export type {
|
|
4
4
|
GetCapabilitiesResult,
|
5
5
|
} from "../../wallets/eip5792/get-capabilities.js";
|
6
6
|
export { sendCalls } from "../../wallets/eip5792/send-calls.js";
|
7
|
+
export { sendAndConfirmCalls } from "../../wallets/eip5792/send-and-confirm-calls.js";
|
8
|
+
export { showCallsStatus } from "../../wallets/eip5792/show-calls-status.js";
|
7
9
|
export type {
|
8
10
|
SendCallsOptions,
|
9
11
|
SendCallsResult,
|
@@ -15,9 +17,9 @@ export {
|
|
15
17
|
getCallsStatus,
|
16
18
|
} from "../../wallets/eip5792/get-calls-status.js";
|
17
19
|
export {
|
18
|
-
|
19
|
-
type
|
20
|
-
} from "../../wallets/eip5792/wait-for-
|
20
|
+
waitForCallsReceipt,
|
21
|
+
type WaitForCallsReceiptOptions,
|
22
|
+
} from "../../wallets/eip5792/wait-for-calls-receipt.js";
|
21
23
|
export type {
|
22
24
|
WalletCapabilities,
|
23
25
|
WalletCapabilitiesRecord,
|
@@ -21,6 +21,7 @@ import { useActiveWallet } from "./useActiveWallet.js";
|
|
21
21
|
* @extension EIP5792
|
22
22
|
*/
|
23
23
|
export function useCapabilities(options?: {
|
24
|
+
chainId?: number;
|
24
25
|
queryOptions?: {
|
25
26
|
enabled?: boolean;
|
26
27
|
retry?: number;
|
@@ -28,18 +29,17 @@ export function useCapabilities(options?: {
|
|
28
29
|
}): UseQueryResult<GetCapabilitiesResult> {
|
29
30
|
const wallet = useActiveWallet();
|
30
31
|
return useQuery({
|
31
|
-
queryKey: [
|
32
|
-
"getCapabilities",
|
33
|
-
wallet?.getChain()?.id || -1,
|
34
|
-
wallet?.id,
|
35
|
-
] as const,
|
32
|
+
queryKey: ["getCapabilities", wallet?.id, options?.chainId] as const,
|
36
33
|
queryFn: async () => {
|
37
34
|
if (!wallet) {
|
38
35
|
return {
|
39
36
|
message: "Can't get capabilities, no wallet connected",
|
40
37
|
} as const;
|
41
38
|
}
|
42
|
-
return getCapabilities({
|
39
|
+
return getCapabilities({
|
40
|
+
wallet,
|
41
|
+
chainId: options?.chainId,
|
42
|
+
});
|
43
43
|
},
|
44
44
|
retry: false,
|
45
45
|
...options?.queryOptions,
|
@@ -0,0 +1,114 @@
|
|
1
|
+
import {
|
2
|
+
type UseMutationResult,
|
3
|
+
useMutation,
|
4
|
+
useQueryClient,
|
5
|
+
} from "@tanstack/react-query";
|
6
|
+
import { sendAndConfirmCalls } from "../../../../wallets/eip5792/send-and-confirm-calls.js";
|
7
|
+
import type { SendCallsOptions } from "../../../../wallets/eip5792/send-calls.js";
|
8
|
+
import type { GetCallsStatusResponse } from "../../../../wallets/eip5792/types.js";
|
9
|
+
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
10
|
+
import { invalidateWalletBalance } from "../../providers/invalidateWalletBalance.js";
|
11
|
+
import { useActiveWallet } from "./useActiveWallet.js";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* A hook to send [EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) calls to a wallet.
|
15
|
+
* This hook works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792.
|
16
|
+
* Transactions will be batched and sponsored when those capabilities are supported, otherwise they will be sent as individual transactions.
|
17
|
+
*
|
18
|
+
* When calls are sent, all contracts that are interacted with will have their corresponding reads revalidated via React Query.
|
19
|
+
*
|
20
|
+
* This hook is dependent on the wallet's support for EIP-5792 and could fail.
|
21
|
+
* The mutation function will use your currently connected wallet by default, but you can pass it a specific wallet to use if you'd like.
|
22
|
+
*
|
23
|
+
* @returns A React Query mutation object to interact with {@link sendAndConfirmCalls}
|
24
|
+
* @throws an error if the wallet does not support EIP-5792.
|
25
|
+
* @returns The ID of the bundle of the calls.
|
26
|
+
*
|
27
|
+
* @beta
|
28
|
+
* @example
|
29
|
+
* ```tsx
|
30
|
+
* import { useSendCalls } from "thirdweb/react";
|
31
|
+
*
|
32
|
+
* const sendTx1 = approve({
|
33
|
+
contract: USDT_CONTRACT,
|
34
|
+
amount: 100,
|
35
|
+
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
|
36
|
+
});
|
37
|
+
* const sendTx2 = approve({
|
38
|
+
contract: USDT_CONTRACT,
|
39
|
+
amount: 100,
|
40
|
+
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
41
|
+
});
|
42
|
+
* const { mutate: sendCalls, data: result } = useSendAndConfirmCalls();
|
43
|
+
* await sendCalls({
|
44
|
+
* client,
|
45
|
+
* calls: [sendTx1, sendTx2],
|
46
|
+
* });
|
47
|
+
*
|
48
|
+
* console.log("Transaction hash:", result.receipts?.[0]?.transactionHash);
|
49
|
+
* ```
|
50
|
+
|
51
|
+
* Sponsor transactions with a paymaster:
|
52
|
+
* ```ts
|
53
|
+
* const { mutate: sendAndConfirmCalls, data: id } = useSendAndConfirmCalls();
|
54
|
+
* const result = await sendAndConfirmCalls({
|
55
|
+
* client,
|
56
|
+
* calls: [sendTx1, sendTx2],
|
57
|
+
* capabilities: {
|
58
|
+
* paymasterService: {
|
59
|
+
* url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`
|
60
|
+
* }
|
61
|
+
* }
|
62
|
+
* });
|
63
|
+
* console.log("Transaction hash:", result.receipts?.[0]?.transactionHash);
|
64
|
+
* ```
|
65
|
+
*
|
66
|
+
* We recommend proxying any paymaster calls via an API route you setup and control.
|
67
|
+
* @extension EIP5792
|
68
|
+
*/
|
69
|
+
export function useSendAndConfirmCalls(args?: {
|
70
|
+
maxBlocksWaitTime?: number;
|
71
|
+
}): UseMutationResult<
|
72
|
+
GetCallsStatusResponse,
|
73
|
+
Error,
|
74
|
+
Omit<SendCallsOptions, "chain" | "wallet"> & { wallet?: Wallet } // Optional wallet override
|
75
|
+
> {
|
76
|
+
const activeWallet = useActiveWallet();
|
77
|
+
const queryClient = useQueryClient();
|
78
|
+
|
79
|
+
return useMutation({
|
80
|
+
mutationFn: async (options) => {
|
81
|
+
const { wallet = activeWallet } = options;
|
82
|
+
if (!wallet) {
|
83
|
+
throw new Error(
|
84
|
+
"Failed to send transactions, no connected wallet found.",
|
85
|
+
);
|
86
|
+
}
|
87
|
+
|
88
|
+
return sendAndConfirmCalls({
|
89
|
+
...options,
|
90
|
+
wallet,
|
91
|
+
maxBlocksWaitTime: args?.maxBlocksWaitTime,
|
92
|
+
});
|
93
|
+
},
|
94
|
+
onSettled: async (_result, _error, variables) => {
|
95
|
+
// Attempt to invalidate any reads related to the sent transactions
|
96
|
+
const call = variables.calls[0];
|
97
|
+
if (!call) {
|
98
|
+
return;
|
99
|
+
}
|
100
|
+
const chain = call.__contract?.chain || call.chain;
|
101
|
+
|
102
|
+
for (const call of variables.calls) {
|
103
|
+
queryClient.invalidateQueries({
|
104
|
+
queryKey: [
|
105
|
+
"readContract",
|
106
|
+
call.__contract?.chain.id || call.chain.id,
|
107
|
+
call.__contract?.address || call.to,
|
108
|
+
],
|
109
|
+
});
|
110
|
+
}
|
111
|
+
invalidateWalletBalance(queryClient, chain.id);
|
112
|
+
},
|
113
|
+
});
|
114
|
+
}
|