thirdweb 5.98.1 → 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/extensions/erc20/read/getCurrencyMetadata.js +2 -2
- package/dist/cjs/extensions/erc20/read/getCurrencyMetadata.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/react/native/ui/connect/ConnectButton.js +4 -1
- package/dist/cjs/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js +6 -4
- package/dist/cjs/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +5 -15
- package/dist/cjs/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/cjs/react/web/ui/PayEmbed.js +8 -1
- package/dist/cjs/react/web/ui/PayEmbed.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/connection/autoConnectCore.js +29 -12
- package/dist/cjs/wallets/connection/autoConnectCore.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/in-app/core/wallet/is-in-app-signer.js +15 -0
- package/dist/cjs/wallets/in-app/core/wallet/is-in-app-signer.js.map +1 -0
- 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/extensions/erc20/read/getCurrencyMetadata.js +2 -2
- package/dist/esm/extensions/erc20/read/getCurrencyMetadata.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/react/native/ui/connect/ConnectButton.js +4 -1
- package/dist/esm/react/native/ui/connect/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js +6 -4
- package/dist/esm/react/web/ui/ConnectWallet/ConnectButton.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/Modal/ConnectEmbed.js.map +1 -1
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js +1 -11
- package/dist/esm/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.js.map +1 -1
- package/dist/esm/react/web/ui/PayEmbed.js +8 -1
- package/dist/esm/react/web/ui/PayEmbed.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/connection/autoConnectCore.js +29 -12
- package/dist/esm/wallets/connection/autoConnectCore.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/in-app/core/wallet/is-in-app-signer.js +12 -0
- package/dist/esm/wallets/in-app/core/wallet/is-in-app-signer.js.map +1 -0
- 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/react/native/ui/connect/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/ConnectButton.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/Modal/ConnectEmbed.d.ts.map +1 -1
- package/dist/types/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.d.ts.map +1 -1
- package/dist/types/react/web/ui/PayEmbed.d.ts +1 -1
- package/dist/types/react/web/ui/PayEmbed.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/connection/autoConnectCore.d.ts.map +1 -1
- package/dist/types/wallets/connection/types.d.ts +9 -0
- package/dist/types/wallets/connection/types.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/in-app/core/wallet/is-in-app-signer.d.ts +6 -0
- package/dist/types/wallets/in-app/core/wallet/is-in-app-signer.d.ts.map +1 -0
- 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/extensions/erc20/read/getCurrencyMetadata.ts +2 -2
- 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/react/native/ui/connect/ConnectButton.tsx +4 -1
- package/src/react/web/ui/ConnectWallet/ConnectButton.tsx +11 -3
- package/src/react/web/ui/ConnectWallet/Modal/ConnectEmbed.tsx +1 -0
- package/src/react/web/ui/ConnectWallet/screens/Buy/fiat/OnRampScreen.tsx +1 -21
- package/src/react/web/ui/PayEmbed.tsx +15 -1
- package/src/version.ts +1 -1
- package/src/wallets/coinbase/coinbase-web.ts +6 -117
- package/src/wallets/connection/autoConnectCore.ts +33 -12
- package/src/wallets/connection/types.ts +10 -0
- 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/in-app/core/wallet/is-in-app-signer.ts +21 -0
- 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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/wallets/eip5792/types.ts"],"names":[],"mappings":"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"}
|
@@ -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"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"is-in-app-signer.d.ts","sourceRoot":"","sources":["../../../../../../src/wallets/in-app/core/wallet/is-in-app-signer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAI5D,wBAAgB,aAAa,CAAC,OAAO,EAAE;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,WAYA"}
|
@@ -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
|
+
}
|
@@ -3,16 +3,12 @@ import {
|
|
3
3
|
useMutation,
|
4
4
|
useQueryClient,
|
5
5
|
} from "@tanstack/react-query";
|
6
|
-
import type { ThirdwebClient } from "../../../../client/client.js";
|
7
6
|
import {
|
8
7
|
type SendCallsOptions,
|
8
|
+
type SendCallsResult,
|
9
9
|
sendCalls,
|
10
10
|
} from "../../../../wallets/eip5792/send-calls.js";
|
11
|
-
import
|
12
|
-
GetCallsStatusResponse,
|
13
|
-
WalletSendCallsId,
|
14
|
-
} from "../../../../wallets/eip5792/types.js";
|
15
|
-
import { waitForBundle } from "../../../../wallets/eip5792/wait-for-bundle.js";
|
11
|
+
import { waitForCallsReceipt } from "../../../../wallets/eip5792/wait-for-calls-receipt.js";
|
16
12
|
import type { Wallet } from "../../../../wallets/interfaces/wallet.js";
|
17
13
|
import { invalidateWalletBalance } from "../../providers/invalidateWalletBalance.js";
|
18
14
|
import { useActiveWallet } from "./useActiveWallet.js";
|
@@ -46,7 +42,7 @@ import { useActiveWallet } from "./useActiveWallet.js";
|
|
46
42
|
amount: 100,
|
47
43
|
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
|
48
44
|
});
|
49
|
-
* const { mutate: sendCalls, data:
|
45
|
+
* const { mutate: sendCalls, data: id } = useSendCalls();
|
50
46
|
* await sendCalls({
|
51
47
|
* wallet,
|
52
48
|
* client,
|
@@ -55,16 +51,19 @@ import { useActiveWallet } from "./useActiveWallet.js";
|
|
55
51
|
* ```
|
56
52
|
* Await the bundle's full confirmation:
|
57
53
|
* ```tsx
|
58
|
-
* const { mutate: sendCalls, data
|
54
|
+
* const { mutate: sendCalls, data } = useSendCalls();
|
55
|
+
* const { data: result, isLoading } = useWaitForCallsReceipt(data);
|
59
56
|
* await sendCalls({
|
60
57
|
* wallet,
|
61
58
|
* client,
|
62
59
|
* calls: [sendTx1, sendTx2],
|
63
60
|
* });
|
61
|
+
*
|
62
|
+
* console.log("Receipts:", result.receipts);
|
64
63
|
* ```
|
65
64
|
* Sponsor transactions with a paymaster:
|
66
65
|
* ```ts
|
67
|
-
* const { mutate: sendCalls, data:
|
66
|
+
* const { mutate: sendCalls, data: id } = useSendCalls();
|
68
67
|
* await sendCalls({
|
69
68
|
* client,
|
70
69
|
* calls: [sendTx1, sendTx2],
|
@@ -75,15 +74,11 @@ import { useActiveWallet } from "./useActiveWallet.js";
|
|
75
74
|
* }
|
76
75
|
* });
|
77
76
|
* ```
|
78
|
-
*
|
79
77
|
* We recommend proxying any paymaster calls via an API route you setup and control.
|
80
78
|
* @extension EIP5792
|
81
79
|
*/
|
82
|
-
export function useSendCalls(
|
83
|
-
|
84
|
-
waitForResult = true,
|
85
|
-
}: { client: ThirdwebClient; waitForResult?: boolean }): UseMutationResult<
|
86
|
-
GetCallsStatusResponse | WalletSendCallsId,
|
80
|
+
export function useSendCalls(): UseMutationResult<
|
81
|
+
SendCallsResult,
|
87
82
|
Error,
|
88
83
|
Omit<SendCallsOptions, "chain" | "wallet"> & { wallet?: Wallet } // Optional wallet override
|
89
84
|
> {
|
@@ -100,52 +95,40 @@ export function useSendCalls({
|
|
100
95
|
);
|
101
96
|
}
|
102
97
|
|
103
|
-
|
104
|
-
if (!waitForResult) {
|
105
|
-
return callsPromise;
|
106
|
-
}
|
107
|
-
|
108
|
-
const result = await waitForBundle({
|
109
|
-
bundleId: await callsPromise,
|
110
|
-
wallet,
|
111
|
-
client,
|
112
|
-
chain,
|
113
|
-
});
|
114
|
-
return result;
|
98
|
+
return sendCalls({ ...options, wallet });
|
115
99
|
},
|
116
|
-
onSettled: async (
|
100
|
+
onSettled: async (result, _error, variables) => {
|
117
101
|
// Attempt to invalidate any reads related to the sent transactions
|
118
|
-
|
119
|
-
|
102
|
+
if (!result) {
|
103
|
+
return;
|
104
|
+
}
|
105
|
+
const call = variables.calls[0];
|
106
|
+
if (!call) {
|
120
107
|
return;
|
121
108
|
}
|
109
|
+
const chain = call.__contract?.chain || call.chain;
|
122
110
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
111
|
+
waitForCallsReceipt(result)
|
112
|
+
.then(() => {
|
113
|
+
for (const call of variables.calls) {
|
114
|
+
queryClient.invalidateQueries({
|
115
|
+
queryKey: [
|
116
|
+
"readContract",
|
117
|
+
call.__contract?.chain.id || chain.id,
|
118
|
+
call.__contract?.address || call.to,
|
119
|
+
],
|
120
|
+
});
|
121
|
+
}
|
122
|
+
invalidateWalletBalance(queryClient, chain.id);
|
123
|
+
})
|
124
|
+
.catch((error) => {
|
130
125
|
console.error(
|
131
126
|
"Failed to confirm sent bundle and invalidate queries",
|
132
|
-
|
127
|
+
result,
|
133
128
|
error,
|
134
129
|
);
|
135
130
|
return undefined;
|
136
131
|
});
|
137
|
-
}
|
138
|
-
|
139
|
-
for (const call of variables.calls) {
|
140
|
-
queryClient.invalidateQueries({
|
141
|
-
queryKey: [
|
142
|
-
"readContract",
|
143
|
-
call.__contract?.chain.id,
|
144
|
-
call.__contract?.address,
|
145
|
-
],
|
146
|
-
});
|
147
|
-
}
|
148
|
-
invalidateWalletBalance(queryClient, chain.id);
|
149
132
|
},
|
150
133
|
});
|
151
134
|
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
2
|
+
import type { SendCallsResult } from "../../../../wallets/eip5792/send-calls.js";
|
3
|
+
import { waitForCallsReceipt } from "../../../../wallets/eip5792/wait-for-calls-receipt.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* A hook to wait for the receipt of eip5792 calls.
|
7
|
+
* @param options - The options for the hook.
|
8
|
+
* @returns A useQuery object.
|
9
|
+
* @example
|
10
|
+
* ```tsx
|
11
|
+
* const { data: receipt, isLoading } = useWaitForCallsReceipt({ id, client, chain, wallet });
|
12
|
+
* ```
|
13
|
+
*
|
14
|
+
* Example with useSendCalls:
|
15
|
+
* ```tsx
|
16
|
+
* const { mutate: sendCalls, data } = useSendCalls();
|
17
|
+
* const { data: receipt, isLoading } = useWaitForCallsReceipt(data);
|
18
|
+
* ```
|
19
|
+
* @extension EIP5792
|
20
|
+
*/
|
21
|
+
export function useWaitForCallsReceipt(
|
22
|
+
args:
|
23
|
+
| (SendCallsResult & {
|
24
|
+
maxBlocksWaitTime?: number;
|
25
|
+
queryOptions?: { enabled?: boolean };
|
26
|
+
})
|
27
|
+
| undefined,
|
28
|
+
) {
|
29
|
+
return useQuery({
|
30
|
+
queryKey: ["waitForCallsReceipt", args?.id] as const,
|
31
|
+
queryFn: async () => {
|
32
|
+
if (!args?.id) {
|
33
|
+
throw new Error("No call result provided");
|
34
|
+
}
|
35
|
+
return waitForCallsReceipt({
|
36
|
+
...args,
|
37
|
+
maxBlocksWaitTime: args.maxBlocksWaitTime,
|
38
|
+
});
|
39
|
+
},
|
40
|
+
enabled: !!args?.id && (args?.queryOptions?.enabled ?? true),
|
41
|
+
retry: false,
|
42
|
+
});
|
43
|
+
}
|
@@ -46,13 +46,14 @@ export function ThirdwebProviderCore(props: {
|
|
46
46
|
// invalidate any readContract queries for this chainId:contractAddress
|
47
47
|
[
|
48
48
|
"readContract",
|
49
|
-
variables.__contract?.chain.id
|
50
|
-
|
49
|
+
variables.__contract?.chain.id ||
|
50
|
+
variables.chain.id,
|
51
|
+
variables.__contract?.address || variables.to,
|
51
52
|
] as const,
|
52
53
|
}),
|
53
54
|
invalidateWalletBalance(
|
54
55
|
queryClient,
|
55
|
-
variables.__contract?.chain.id,
|
56
|
+
variables.__contract?.chain.id || variables.chain.id,
|
56
57
|
),
|
57
58
|
]);
|
58
59
|
});
|
@@ -47,7 +47,10 @@ export function ConnectButton(props: ConnectButtonProps) {
|
|
47
47
|
const status = useActiveWalletConnectionStatus();
|
48
48
|
const connectionManager = useConnectionManager();
|
49
49
|
const siweAuth = useSiweAuth(wallet, account, props.auth);
|
50
|
-
useAutoConnect(
|
50
|
+
useAutoConnect({
|
51
|
+
...props,
|
52
|
+
siweAuth: siweAuth,
|
53
|
+
});
|
51
54
|
|
52
55
|
const fadeAnim = useRef(new Animated.Value(0)); // For background opacity
|
53
56
|
const slideAnim = useRef(new Animated.Value(screenHeight)); // For bottom sheet position
|