@getpara/react-core 3.20.0 → 3.21.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.
Files changed (35) hide show
  1. package/dist/chains/evm/ethers/mutations.js +10 -1
  2. package/dist/chains/evm/ethers/useParaEthersSigner.d.ts +2 -2
  3. package/dist/chains/evm/ethers/useParaEthersSigner.js +11 -3
  4. package/dist/chains/evm/viem/isSameEvmAddress.d.ts +1 -0
  5. package/dist/chains/evm/viem/isSameEvmAddress.js +6 -0
  6. package/dist/chains/evm/viem/mutations.js +6 -12
  7. package/dist/chains/evm/viem/useParaViemAccount.js +13 -9
  8. package/dist/chains/evm/viem/useParaViemClient.d.ts +2 -1
  9. package/dist/chains/evm/viem/useParaViemClient.js +22 -8
  10. package/dist/chains/solana/types.d.ts +3 -3
  11. package/dist/chains/solana/useParaSolanaSigner.js +4 -1
  12. package/dist/chains/stellar/mutations.js +2 -4
  13. package/dist/chains/sui/mutations.js +2 -4
  14. package/dist/chains/sui/suiClientKey.d.ts +2 -0
  15. package/dist/chains/sui/suiClientKey.js +5 -0
  16. package/dist/chains/sui/useParaSuiMultiSigSigner.d.ts +5 -3
  17. package/dist/chains/sui/useParaSuiMultiSigSigner.js +14 -3
  18. package/dist/chains/sui/useParaSuiSigner.d.ts +10 -3
  19. package/dist/chains/sui/useParaSuiSigner.js +13 -3
  20. package/dist/provider/ParaProviderCore.js +21 -6
  21. package/dist/provider/actions/getEmbeddedAccount.d.ts +2 -2
  22. package/dist/provider/actions/getWallet.d.ts +6 -0
  23. package/dist/provider/actions/index.d.ts +1 -1
  24. package/dist/provider/hooks/index.d.ts +0 -1
  25. package/dist/provider/hooks/index.js +0 -1
  26. package/dist/provider/hooks/permissions/utils.js +2 -7
  27. package/dist/provider/hooks/queries/createAccountHook.d.ts +2 -2
  28. package/dist/provider/hooks/queries/createAccountHook.js +19 -7
  29. package/dist/provider/hooks/queries/useWallet.d.ts +7 -0
  30. package/dist/provider/index.d.ts +1 -0
  31. package/dist/provider/utils/objectIdentity.d.ts +1 -0
  32. package/dist/provider/utils/objectIdentity.js +15 -0
  33. package/package.json +177 -15
  34. package/dist/provider/hooks/aa/index.d.ts +0 -12
  35. package/dist/provider/hooks/aa/index.js +0 -48
@@ -43,6 +43,15 @@ const ETHERS_SEND_TRANSACTION_KEY = "PARA_ETHERS_SEND_TRANSACTION";
43
43
  const ETHERS_SIGN_MESSAGE_KEY = "PARA_ETHERS_SIGN_MESSAGE";
44
44
  const ETHERS_SIGN_TYPED_DATA_KEY = "PARA_ETHERS_SIGN_TYPED_DATA";
45
45
  const ETHERS_WRITE_CONTRACT_KEY = "PARA_ETHERS_WRITE_CONTRACT";
46
+ function loadEthers() {
47
+ return __async(this, null, function* () {
48
+ try {
49
+ return yield import("ethers");
50
+ } catch (e) {
51
+ throw new Error("[@getpara/react-core] Install ethers to use useParaEthersWriteContract.");
52
+ }
53
+ });
54
+ }
46
55
  const useParaEthersSendTransaction = (signer) => {
47
56
  const mutation = renameMutations(
48
57
  useMutation({
@@ -90,7 +99,7 @@ const useParaEthersWriteContract = (signer) => {
90
99
  mutationFn: (params) => __async(null, null, function* () {
91
100
  var _a;
92
101
  if (!signer) throw new Error("Ethers signer not ready. Ensure useParaEthersSigner has resolved.");
93
- const { Contract } = yield import("ethers");
102
+ const { Contract } = yield loadEthers();
94
103
  const contract = new Contract(params.address, params.abi, signer);
95
104
  const tx = yield contract[params.functionName](...(_a = params.args) != null ? _a : []);
96
105
  return tx.wait();
@@ -1,11 +1,11 @@
1
1
  import { type UseQueryResult } from '@tanstack/react-query';
2
2
  import type { WalletSelector } from '../../types.js';
3
3
  import type { EthersEnhancement } from './types.js';
4
- import type { AbstractSigner } from '@getpara/ethers-v6-integration';
4
+ import type { AbstractSigner, CreateParaEthersSignerOptions } from '@getpara/ethers-v6-integration';
5
5
  export declare const ETHERS_SIGNER_BASE_KEY = "PARA_ETHERS_SIGNER";
6
6
  type UseParaEthersSignerParameters = WalletSelector & {
7
7
  /** ethers.Provider instance for the target chain. */
8
- provider?: unknown;
8
+ provider?: CreateParaEthersSignerOptions['provider'];
9
9
  messageSigningTimeoutMs?: number;
10
10
  };
11
11
  type EthersSignerData = AbstractSigner | null | undefined;
@@ -51,7 +51,9 @@ import { useClient } from "../../../provider/hooks/utils/useClient.js";
51
51
  import { useIsFullyLoggedIn } from "../../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
52
  import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
53
53
  import { resolveWalletForChain } from "../../resolveWallet.js";
54
+ import { createObjectIdentity } from "../../../provider/utils/objectIdentity.js";
54
55
  const ETHERS_SIGNER_BASE_KEY = "PARA_ETHERS_SIGNER";
56
+ const ethersProviderKey = createObjectIdentity();
55
57
  function createParaEthersSignerHook(useEnhancer) {
56
58
  return function useParaEthersSigner2({
57
59
  address,
@@ -71,7 +73,8 @@ function createParaEthersSignerHook(useEnhancer) {
71
73
  ETHERS_SIGNER_BASE_KEY,
72
74
  isEmbeddedActive,
73
75
  (_b = walletId != null ? walletId : address) != null ? _b : (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet == null ? void 0 : wallet.id : null,
74
- hasExternalSigner ? "external-available" : "embedded-only"
76
+ hasExternalSigner ? "external-available" : "embedded-only",
77
+ ethersProviderKey(provider)
75
78
  ],
76
79
  enabled: !enhancement.isLoading && !!para && (isEmbeddedActive || hasExternalSigner),
77
80
  queryFn: () => __async(null, null, function* () {
@@ -86,7 +89,12 @@ function createParaEthersSignerHook(useEnhancer) {
86
89
  }
87
90
  if ((resolved == null ? void 0 : resolved.id) && !resolved.isExternal) {
88
91
  const mod = yield importEthers();
89
- return mod.createParaEthersSigner({ para, provider, walletId: resolved.id, messageSigningTimeoutMs });
92
+ return mod.createParaEthersSigner({
93
+ para,
94
+ provider,
95
+ walletId: resolved.id,
96
+ messageSigningTimeoutMs
97
+ });
90
98
  }
91
99
  }
92
100
  if (hasExternalSigner) {
@@ -103,7 +111,7 @@ function importEthers() {
103
111
  try {
104
112
  return yield import("@getpara/ethers-v6-integration");
105
113
  } catch (e) {
106
- throw new Error("[@getpara/react-core] Please install @getpara/ethers-v6-integration to use useParaEthersSigner");
114
+ throw new Error("[@getpara/react-core] Install ethers and @getpara/ethers-v6-integration to use useParaEthersSigner.");
107
115
  }
108
116
  });
109
117
  }
@@ -0,0 +1 @@
1
+ export declare function isSameEvmAddress(left: string | null | undefined, right: string | null | undefined): boolean;
@@ -0,0 +1,6 @@
1
+ function isSameEvmAddress(left, right) {
2
+ return !!left && !!right && left.toLowerCase() === right.toLowerCase();
3
+ }
4
+ export {
5
+ isSameEvmAddress
6
+ };
@@ -47,10 +47,9 @@ const VIEM_SIGN_TYPED_DATA_KEY = "PARA_VIEM_SIGN_TYPED_DATA";
47
47
  const VIEM_WRITE_CONTRACT_KEY = "PARA_VIEM_WRITE_CONTRACT";
48
48
  const VIEM_DEPLOY_CONTRACT_KEY = "PARA_VIEM_DEPLOY_CONTRACT";
49
49
  const useParaViemSendTransaction = (viemClient) => {
50
- var _a, _b;
51
50
  const mutation = renameMutations(
52
51
  useMutation({
53
- mutationKey: [VIEM_SEND_TRANSACTION_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
52
+ mutationKey: [VIEM_SEND_TRANSACTION_KEY],
54
53
  mutationFn: (params) => __async(null, null, function* () {
55
54
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
56
55
  return viemClient.sendTransaction(fwd(params));
@@ -61,10 +60,9 @@ const useParaViemSendTransaction = (viemClient) => {
61
60
  return __spreadProps(__spreadValues({}, mutation), { isPending: !viemClient || mutation.isPending });
62
61
  };
63
62
  const useParaViemSignTransaction = (viemClient) => {
64
- var _a, _b;
65
63
  const mutation = renameMutations(
66
64
  useMutation({
67
- mutationKey: [VIEM_SIGN_TRANSACTION_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
65
+ mutationKey: [VIEM_SIGN_TRANSACTION_KEY],
68
66
  mutationFn: (params) => __async(null, null, function* () {
69
67
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
70
68
  return viemClient.signTransaction(fwd(params));
@@ -75,10 +73,9 @@ const useParaViemSignTransaction = (viemClient) => {
75
73
  return __spreadProps(__spreadValues({}, mutation), { isPending: !viemClient || mutation.isPending });
76
74
  };
77
75
  const useParaViemSignMessage = (viemClient) => {
78
- var _a, _b;
79
76
  const mutation = renameMutations(
80
77
  useMutation({
81
- mutationKey: [VIEM_SIGN_MESSAGE_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
78
+ mutationKey: [VIEM_SIGN_MESSAGE_KEY],
82
79
  mutationFn: (params) => __async(null, null, function* () {
83
80
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
84
81
  return viemClient.signMessage(fwd(params));
@@ -89,10 +86,9 @@ const useParaViemSignMessage = (viemClient) => {
89
86
  return __spreadProps(__spreadValues({}, mutation), { isPending: !viemClient || mutation.isPending });
90
87
  };
91
88
  const useParaViemSignTypedData = (viemClient) => {
92
- var _a, _b;
93
89
  const mutation = renameMutations(
94
90
  useMutation({
95
- mutationKey: [VIEM_SIGN_TYPED_DATA_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
91
+ mutationKey: [VIEM_SIGN_TYPED_DATA_KEY],
96
92
  mutationFn: (params) => __async(null, null, function* () {
97
93
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
98
94
  return viemClient.signTypedData(fwd(params));
@@ -103,10 +99,9 @@ const useParaViemSignTypedData = (viemClient) => {
103
99
  return __spreadProps(__spreadValues({}, mutation), { isPending: !viemClient || mutation.isPending });
104
100
  };
105
101
  const useParaViemWriteContract = (viemClient) => {
106
- var _a, _b;
107
102
  const mutation = renameMutations(
108
103
  useMutation({
109
- mutationKey: [VIEM_WRITE_CONTRACT_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
104
+ mutationKey: [VIEM_WRITE_CONTRACT_KEY],
110
105
  mutationFn: (params) => __async(null, null, function* () {
111
106
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
112
107
  return viemClient.writeContract(fwd(params));
@@ -117,10 +112,9 @@ const useParaViemWriteContract = (viemClient) => {
117
112
  return __spreadProps(__spreadValues({}, mutation), { isPending: !viemClient || mutation.isPending });
118
113
  };
119
114
  const useParaViemDeployContract = (viemClient) => {
120
- var _a, _b;
121
115
  const mutation = renameMutations(
122
116
  useMutation({
123
- mutationKey: [VIEM_DEPLOY_CONTRACT_KEY, (_b = (_a = viemClient == null ? void 0 : viemClient.account) == null ? void 0 : _a.address) != null ? _b : null],
117
+ mutationKey: [VIEM_DEPLOY_CONTRACT_KEY],
124
118
  mutationFn: (params) => __async(null, null, function* () {
125
119
  if (!viemClient) throw new Error("Viem client not ready. Ensure useParaViemClient has resolved.");
126
120
  return viemClient.deployContract(fwd(params));
@@ -51,24 +51,28 @@ import { useClient } from "../../../provider/hooks/utils/useClient.js";
51
51
  import { useIsFullyLoggedIn } from "../../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
52
  import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
53
53
  import { resolveWalletForChain } from "../../resolveWallet.js";
54
+ import { isSameEvmAddress } from "./isSameEvmAddress.js";
54
55
  const VIEM_ACCOUNT_BASE_KEY = "PARA_VIEM_ACCOUNT";
55
56
  function createParaViemAccountHook(useEnhancer) {
56
57
  return function useParaViemAccount2({ address, walletId } = {}) {
57
- var _a, _b, _c;
58
+ var _a, _b, _c, _d, _e;
58
59
  const para = useClient();
59
60
  const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
60
61
  const { data: wallet } = useWallet();
61
62
  const enhancement = (_a = useEnhancer == null ? void 0 : useEnhancer()) != null ? _a : {};
62
63
  const hasExternalWalletClient = !!enhancement.walletClient;
63
64
  const isEmbeddedActive = !!isFullyLoggedIn;
64
- const _d = useQuery({
65
- queryKey: [
66
- VIEM_ACCOUNT_BASE_KEY,
67
- isEmbeddedActive,
68
- (_c = (_b = address != null ? address : walletId) != null ? _b : enhancement.address) != null ? _c : (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet == null ? void 0 : wallet.address : null,
69
- hasExternalWalletClient ? "external" : "embedded"
70
- ],
65
+ const querySelector = address ? ["address", address] : walletId ? ["walletId", walletId] : [
66
+ "default",
67
+ (wallet == null ? void 0 : wallet.type) === "EVM" ? (_b = wallet.id) != null ? _b : null : null,
68
+ (wallet == null ? void 0 : wallet.type) === "EVM" ? (_c = wallet.address) != null ? _c : null : null,
69
+ (_d = enhancement.address) != null ? _d : null
70
+ ];
71
+ const expectedAddress = address != null ? address : walletId ? void 0 : (_e = (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet.address : void 0) != null ? _e : enhancement.address;
72
+ const _f = useQuery({
73
+ queryKey: [VIEM_ACCOUNT_BASE_KEY, isEmbeddedActive, querySelector, hasExternalWalletClient ? "external" : "embedded"],
71
74
  enabled: !enhancement.isLoading && !!para && (isEmbeddedActive || hasExternalWalletClient),
75
+ placeholderData: (previousAccount) => isSameEvmAddress(previousAccount == null ? void 0 : previousAccount.address, expectedAddress) ? previousAccount : void 0,
72
76
  queryFn: () => __async(null, null, function* () {
73
77
  var _a2, _b2;
74
78
  if (isEmbeddedActive) {
@@ -87,7 +91,7 @@ function createParaViemAccountHook(useEnhancer) {
87
91
  }
88
92
  return null;
89
93
  })
90
- }), { data, isLoading } = _d, rest = __objRest(_d, ["data", "isLoading"]);
94
+ }), { data, isLoading } = _f, rest = __objRest(_f, ["data", "isLoading"]);
91
95
  return __spreadValues({ viemAccount: data, data, isLoading: enhancement.isLoading || isLoading }, rest);
92
96
  };
93
97
  }
@@ -3,8 +3,9 @@ import type { WalletSelector } from '../../types.js';
3
3
  import type { ViemEnhancement } from './types.js';
4
4
  import type { WalletClient } from 'viem';
5
5
  export declare const VIEM_CLIENT_BASE_KEY = "PARA_VIEM_CLIENT";
6
+ type WalletClientConfigParameter = Omit<import('viem').WalletClientConfig, 'account'>;
6
7
  type UseParaViemClientParameters = WalletSelector & {
7
- walletClientConfig: Omit<import('viem').WalletClientConfig, 'account'>;
8
+ walletClientConfig: WalletClientConfigParameter;
8
9
  };
9
10
  type ViemClientData = WalletClient | null | undefined;
10
11
  /** Return type for `useParaViemClient`. Extends the react-query result with a named `viemClient` alias for `data`. */
@@ -49,17 +49,22 @@ var __async = (__this, __arguments, generator) => {
49
49
  step((generator = generator.apply(__this, __arguments)).next());
50
50
  });
51
51
  };
52
- import { useQuery } from "@tanstack/react-query";
52
+ import { hashKey, useQuery } from "@tanstack/react-query";
53
53
  import { useClient } from "../../../provider/hooks/utils/useClient.js";
54
54
  import { useIsFullyLoggedIn } from "../../../provider/hooks/queries/useIsFullyLoggedIn.js";
55
55
  import { useWallet } from "../../../provider/hooks/queries/useWallet.js";
56
56
  import { resolveWalletForChain } from "../../resolveWallet.js";
57
57
  import { createParaViemAccountHook } from "./useParaViemAccount.js";
58
+ import { isSameEvmAddress } from "./isSameEvmAddress.js";
58
59
  const VIEM_CLIENT_BASE_KEY = "PARA_VIEM_CLIENT";
60
+ const WALLET_CLIENT_CONFIG_KEY_INDEX = 3;
61
+ function isSameWalletClientConfig(previousKey, walletClientConfig) {
62
+ return !!previousKey && hashKey([previousKey[WALLET_CLIENT_CONFIG_KEY_INDEX]]) === hashKey([walletClientConfig]);
63
+ }
59
64
  function createParaViemClientHook(useEnhancer) {
60
65
  const useAccount = createParaViemAccountHook(useEnhancer);
61
66
  return function useParaViemClient2({ address, walletId, walletClientConfig }) {
62
- var _a, _b;
67
+ var _a, _b, _c, _d, _e;
63
68
  const para = useClient();
64
69
  const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
65
70
  const { data: wallet } = useWallet();
@@ -68,19 +73,28 @@ function createParaViemClientHook(useEnhancer) {
68
73
  const hasExternalWalletClient = !!enhancement.walletClient;
69
74
  const isEmbeddedActive = !!isFullyLoggedIn;
70
75
  const account = viemAccount;
71
- const _c = useQuery({
76
+ const expectedAddress = (_d = (_b = account == null ? void 0 : account.address) != null ? _b : address) != null ? _d : walletId ? void 0 : (_c = (wallet == null ? void 0 : wallet.type) === "EVM" ? wallet.address : void 0) != null ? _c : enhancement.address;
77
+ const _f = useQuery({
72
78
  queryKey: [
73
79
  VIEM_CLIENT_BASE_KEY,
74
- (_b = account == null ? void 0 : account.address) != null ? _b : null,
80
+ isEmbeddedActive,
81
+ (_e = account == null ? void 0 : account.address) != null ? _e : null,
75
82
  walletClientConfig,
76
83
  hasExternalWalletClient ? "external" : "embedded"
77
84
  ],
78
85
  enabled: !enhancement.isLoading && !!para && (!!account || hasExternalWalletClient),
79
- queryFn: () => __async(null, null, function* () {
86
+ placeholderData: (previousClient, previousQuery) => {
80
87
  var _a2;
81
- const resolved = isEmbeddedActive ? resolveWalletForChain(para, { address, walletId }, "EVM", wallet != null ? wallet : void 0) : null;
88
+ return isSameEvmAddress((_a2 = previousClient == null ? void 0 : previousClient.account) == null ? void 0 : _a2.address, expectedAddress) && isSameWalletClientConfig(previousQuery == null ? void 0 : previousQuery.queryKey, walletClientConfig) ? previousClient : void 0;
89
+ },
90
+ queryFn: () => __async(null, null, function* () {
91
+ var _a2, _b2;
92
+ if (!isEmbeddedActive) {
93
+ return (_a2 = enhancement.walletClient) != null ? _a2 : null;
94
+ }
95
+ const resolved = resolveWalletForChain(para, { address, walletId }, "EVM", wallet != null ? wallet : void 0);
82
96
  if ((resolved == null ? void 0 : resolved.isExternal) && resolved.address) {
83
- const externalClient = yield (_a2 = enhancement.getWalletClientForAddress) == null ? void 0 : _a2.call(enhancement, resolved.address);
97
+ const externalClient = yield (_b2 = enhancement.getWalletClientForAddress) == null ? void 0 : _b2.call(enhancement, resolved.address);
84
98
  if (externalClient) return externalClient;
85
99
  if (hasExternalWalletClient) return enhancement.walletClient;
86
100
  return null;
@@ -94,7 +108,7 @@ function createParaViemClientHook(useEnhancer) {
94
108
  }
95
109
  return null;
96
110
  })
97
- }), { data, isLoading } = _c, rest = __objRest(_c, ["data", "isLoading"]);
111
+ }), { data, isLoading } = _f, rest = __objRest(_f, ["data", "isLoading"]);
98
112
  return __spreadValues({ viemClient: data, data, isLoading: enhancement.isLoading || isLoading }, rest);
99
113
  };
100
114
  }
@@ -1,7 +1,7 @@
1
1
  import type { ChainEnhancement } from '../types.js';
2
- import type { MessagePartialSigner, TransactionPartialSigner } from '@solana/signers';
3
- export type SolanaSigner = MessagePartialSigner & TransactionPartialSigner;
2
+ import type { MessagePartialSigner, TransactionModifyingSigner, TransactionPartialSigner } from '@solana/signers';
3
+ export type SolanaSigner = MessagePartialSigner & TransactionPartialSigner & TransactionModifyingSigner;
4
4
  export interface SolanaEnhancement extends ChainEnhancement {
5
- /** External signer implementing MessagePartialSigner + TransactionPartialSigner. */
5
+ /** External signer implementing MessagePartialSigner, TransactionPartialSigner and TransactionModifyingSigner. */
6
6
  signer?: SolanaSigner | null;
7
7
  }
@@ -51,7 +51,9 @@ import { useClient } from "../../provider/hooks/utils/useClient.js";
51
51
  import { useIsFullyLoggedIn } from "../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
52
  import { useWallet } from "../../provider/hooks/queries/useWallet.js";
53
53
  import { resolveWalletForChain } from "../resolveWallet.js";
54
+ import { createObjectIdentity } from "../../provider/utils/objectIdentity.js";
54
55
  const SOLANA_SIGNER_BASE_KEY = "PARA_SOLANA_SIGNER";
56
+ const solanaRpcKey = createObjectIdentity();
55
57
  function createParaSolanaSignerHook(useEnhancer) {
56
58
  return function useParaSolanaSigner2({ address, walletId, rpc }) {
57
59
  var _a, _b;
@@ -66,7 +68,8 @@ function createParaSolanaSignerHook(useEnhancer) {
66
68
  SOLANA_SIGNER_BASE_KEY,
67
69
  isEmbeddedActive,
68
70
  (_b = walletId != null ? walletId : address) != null ? _b : (wallet == null ? void 0 : wallet.type) === "SOLANA" ? wallet == null ? void 0 : wallet.id : null,
69
- hasExternalSigner ? "external-available" : "embedded-only"
71
+ hasExternalSigner ? "external-available" : "embedded-only",
72
+ solanaRpcKey(rpc)
70
73
  ],
71
74
  enabled: !enhancement.isLoading && !!para && (isEmbeddedActive || hasExternalSigner),
72
75
  queryFn: () => __async(null, null, function* () {
@@ -42,10 +42,9 @@ import { renameMutations } from "../../provider/utils/renameMutations.js";
42
42
  const STELLAR_SIGN_TRANSACTION_KEY = "PARA_STELLAR_SIGN_TRANSACTION";
43
43
  const STELLAR_SIGN_AUTH_ENTRY_KEY = "PARA_STELLAR_SIGN_AUTH_ENTRY";
44
44
  const useParaStellarSignTransaction = (signer) => {
45
- var _a;
46
45
  const mutation = renameMutations(
47
46
  useMutation({
48
- mutationKey: [STELLAR_SIGN_TRANSACTION_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
47
+ mutationKey: [STELLAR_SIGN_TRANSACTION_KEY],
49
48
  mutationFn: (transaction) => __async(null, null, function* () {
50
49
  if (!signer) throw new Error("Stellar signer not ready. Ensure useParaStellarSigner has resolved.");
51
50
  return signer.signTransaction(transaction);
@@ -56,10 +55,9 @@ const useParaStellarSignTransaction = (signer) => {
56
55
  return __spreadProps(__spreadValues({}, mutation), { isPending: !signer || mutation.isPending });
57
56
  };
58
57
  const useParaStellarSignAuthEntry = (signer) => {
59
- var _a;
60
58
  const mutation = renameMutations(
61
59
  useMutation({
62
- mutationKey: [STELLAR_SIGN_AUTH_ENTRY_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
60
+ mutationKey: [STELLAR_SIGN_AUTH_ENTRY_KEY],
63
61
  mutationFn: (authEntry) => __async(null, null, function* () {
64
62
  if (!signer) throw new Error("Stellar signer not ready. Ensure useParaStellarSigner has resolved.");
65
63
  return signer.signAuthEntry(authEntry);
@@ -42,10 +42,9 @@ import { renameMutations } from "../../provider/utils/renameMutations.js";
42
42
  const SUI_SIGN_TRANSACTION_KEY = "PARA_SUI_SIGN_TRANSACTION";
43
43
  const SUI_SIGN_PERSONAL_MESSAGE_KEY = "PARA_SUI_SIGN_PERSONAL_MESSAGE";
44
44
  const useParaSuiSignTransaction = (signer) => {
45
- var _a;
46
45
  const mutation = renameMutations(
47
46
  useMutation({
48
- mutationKey: [SUI_SIGN_TRANSACTION_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
47
+ mutationKey: [SUI_SIGN_TRANSACTION_KEY],
49
48
  mutationFn: (transaction) => __async(null, null, function* () {
50
49
  if (!signer) throw new Error("Sui signer not ready. Ensure useParaSuiSigner has resolved.");
51
50
  return signer.signTransaction(transaction);
@@ -56,10 +55,9 @@ const useParaSuiSignTransaction = (signer) => {
56
55
  return __spreadProps(__spreadValues({}, mutation), { isPending: !signer || mutation.isPending });
57
56
  };
58
57
  const useParaSuiSignPersonalMessage = (signer) => {
59
- var _a;
60
58
  const mutation = renameMutations(
61
59
  useMutation({
62
- mutationKey: [SUI_SIGN_PERSONAL_MESSAGE_KEY, (_a = signer == null ? void 0 : signer.address) != null ? _a : null],
60
+ mutationKey: [SUI_SIGN_PERSONAL_MESSAGE_KEY],
63
61
  mutationFn: (message) => __async(null, null, function* () {
64
62
  if (!signer) throw new Error("Sui signer not ready. Ensure useParaSuiSigner has resolved.");
65
63
  return signer.signPersonalMessage(message);
@@ -0,0 +1,2 @@
1
+ import type { ParaSuiNetworkClient } from '@getpara/sui-sdk-integration';
2
+ export declare const suiClientKey: (value: ParaSuiNetworkClient) => number | null;
@@ -0,0 +1,5 @@
1
+ import { createObjectIdentity } from "../../provider/utils/objectIdentity.js";
2
+ const suiClientKey = createObjectIdentity();
3
+ export {
4
+ suiClientKey
5
+ };
@@ -1,8 +1,8 @@
1
1
  import { type UseQueryResult } from '@tanstack/react-query';
2
- import type { SuiMultiSigMember } from '@getpara/sui-sdk-integration';
2
+ import type { ParaSuiNetworkOptions, SuiMultiSigMember } from '@getpara/sui-sdk-integration';
3
3
  import type { WalletSelector } from '../types.js';
4
4
  export declare const SUI_MULTISIG_SIGNER_BASE_KEY = "PARA_SUI_MULTISIG_SIGNER";
5
- type UseParaSuiMultiSigSignerParameters = WalletSelector & {
5
+ type UseParaSuiMultiSigSignerParameters = WalletSelector & ParaSuiNetworkOptions & {
6
6
  /** The other co-signers (public keys + weights) — everyone except the Para member. */
7
7
  otherMembers: SuiMultiSigMember[];
8
8
  /** k-of-n threshold: the summed weight required for a valid multisig signature. */
@@ -24,6 +24,8 @@ export type UseParaSuiMultiSigSignerReturn = UseQueryResult<NonNullable<SuiMulti
24
24
  * Embedded-only: unlike `useParaSuiSigner`, this hook has no external-wallet enhancer path — the Para
25
25
  * member is always the embedded MPC wallet.
26
26
  *
27
+ * Pass a Sui `client` or an explicit `network` to report the signed network, as with `useParaSuiSigner`.
28
+ *
27
29
  * @example
28
30
  * ```tsx
29
31
  * const { multiSigSigner } = useParaSuiMultiSigSigner({
@@ -37,6 +39,6 @@ export type UseParaSuiMultiSigSignerReturn = UseQueryResult<NonNullable<SuiMulti
37
39
  * const ok = await multiSigSigner.verifyPersonalMessage(bytes, combined);
38
40
  * ```
39
41
  */
40
- export declare function createParaSuiMultiSigSignerHook(): ({ address, walletId, otherMembers, threshold, paraWeight, }: UseParaSuiMultiSigSignerParameters) => UseParaSuiMultiSigSignerReturn;
42
+ export declare function createParaSuiMultiSigSignerHook(): ({ address, walletId, otherMembers, threshold, paraWeight, client, network, }: UseParaSuiMultiSigSignerParameters) => UseParaSuiMultiSigSignerReturn;
41
43
  export declare const useParaSuiMultiSigSigner: (params: UseParaSuiMultiSigSignerParameters) => UseParaSuiMultiSigSignerReturn;
42
44
  export {};
@@ -51,6 +51,7 @@ import { useClient } from "../../provider/hooks/utils/useClient.js";
51
51
  import { useIsFullyLoggedIn } from "../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
52
  import { useWallet } from "../../provider/hooks/queries/useWallet.js";
53
53
  import { resolveWalletForChain } from "../resolveWallet.js";
54
+ import { suiClientKey } from "./suiClientKey.js";
54
55
  const SUI_MULTISIG_SIGNER_BASE_KEY = "PARA_SUI_MULTISIG_SIGNER";
55
56
  function membersKey(members) {
56
57
  if (!members) return "";
@@ -66,7 +67,9 @@ function createParaSuiMultiSigSignerHook() {
66
67
  walletId,
67
68
  otherMembers,
68
69
  threshold,
69
- paraWeight
70
+ paraWeight,
71
+ client,
72
+ network
70
73
  }) {
71
74
  const para = useClient();
72
75
  const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
@@ -79,14 +82,22 @@ function createParaSuiMultiSigSignerHook() {
79
82
  walletId != null ? walletId : (wallet == null ? void 0 : wallet.type) === "SUI" ? wallet == null ? void 0 : wallet.id : null,
80
83
  threshold,
81
84
  paraWeight != null ? paraWeight : 1,
82
- membersKey(otherMembers)
85
+ membersKey(otherMembers),
86
+ network != null ? network : null,
87
+ suiClientKey(client)
83
88
  ],
84
89
  enabled: isEmbeddedActive && !!para && Array.isArray(otherMembers) && otherMembers.length > 0 && (threshold != null ? threshold : 0) > 0,
85
90
  queryFn: () => __async(null, null, function* () {
86
91
  if (!isEmbeddedActive || !para) return null;
87
92
  const resolved = resolveWalletForChain(para, { address, walletId }, "SUI", wallet != null ? wallet : void 0);
88
93
  const mod = yield importSui();
89
- return mod.createParaSuiMultiSigSigner({ para, walletId: resolved == null ? void 0 : resolved.id, otherMembers, threshold, paraWeight });
94
+ return mod.createParaSuiMultiSigSigner(__spreadValues(__spreadValues({
95
+ para,
96
+ walletId: resolved == null ? void 0 : resolved.id,
97
+ otherMembers,
98
+ threshold,
99
+ paraWeight
100
+ }, client ? { client } : {}), network ? { network } : {}));
90
101
  })
91
102
  }), { data, isLoading } = _a, rest = __objRest(_a, ["data", "isLoading"]);
92
103
  return __spreadValues({ multiSigSigner: data, data, isLoading }, rest);
@@ -1,8 +1,9 @@
1
1
  import { type UseQueryResult } from '@tanstack/react-query';
2
2
  import type { WalletSelector } from '../types.js';
3
3
  import type { SuiEnhancement } from './types.js';
4
+ import type { ParaSuiNetworkOptions } from '@getpara/sui-sdk-integration';
4
5
  export declare const SUI_SIGNER_BASE_KEY = "PARA_SUI_SIGNER";
5
- type UseParaSuiSignerParameters = WalletSelector;
6
+ type UseParaSuiSignerParameters = WalletSelector & ParaSuiNetworkOptions;
6
7
  /** The signer object returned by `@getpara/sui-sdk-integration`'s `createParaSuiSigner` (synchronous). */
7
8
  type SuiSignerData = ReturnType<Awaited<typeof import('@getpara/sui-sdk-integration')>['createParaSuiSigner']> | null | undefined;
8
9
  /** Return type for `useParaSuiSigner`. Extends the react-query result with a named `suiSigner` alias for `data`. */
@@ -17,7 +18,7 @@ export type UseParaSuiSignerReturn = UseQueryResult<NonNullable<SuiSignerData> |
17
18
  * @param useEnhancer - Optional hook that provides an external Sui signer.
18
19
  * @returns A `useParaSuiSigner` hook.
19
20
  */
20
- export declare function createParaSuiSignerHook(useEnhancer?: () => SuiEnhancement): ({ address, walletId }?: UseParaSuiSignerParameters) => UseParaSuiSignerReturn;
21
+ export declare function createParaSuiSignerHook(useEnhancer?: () => SuiEnhancement): ({ address, walletId, client, network }?: UseParaSuiSignerParameters) => UseParaSuiSignerReturn;
21
22
  /**
22
23
  * Hook that returns a Sui signer backed by the user's embedded Para wallet (Sui reuses the Solana
23
24
  * Ed25519 key material). Requires `@getpara/sui-sdk-integration` and `@mysten/sui` as peer dependencies.
@@ -25,12 +26,18 @@ export declare function createParaSuiSignerHook(useEnhancer?: () => SuiEnhanceme
25
26
  * If the user has multiple Ed25519 wallets, pass `address` or `walletId` to select one. When omitted,
26
27
  * the active wallet from `useWalletState` is used automatically.
27
28
  *
29
+ * Pass a Sui `client` so signed transactions report their mainnet or testnet network, or an explicit
30
+ * `network`, which is required to report devnet. A signed `ValidDuring` chain always takes precedence.
31
+ *
28
32
  * @example
29
33
  * ```tsx
30
34
  * import { useParaSuiSigner } from "@getpara/react-sdk";
35
+ * import { SuiGrpcClient } from "@mysten/sui/grpc";
36
+ *
37
+ * const client = new SuiGrpcClient({ network: "mainnet", baseUrl: "https://fullnode.mainnet.sui.io:443" });
31
38
  *
32
39
  * function SignMessage() {
33
- * const { suiSigner, isLoading } = useParaSuiSigner();
40
+ * const { suiSigner, isLoading } = useParaSuiSigner({ client });
34
41
  *
35
42
  * const handleSign = async () => {
36
43
  * if (!suiSigner) return;
@@ -51,9 +51,10 @@ import { useClient } from "../../provider/hooks/utils/useClient.js";
51
51
  import { useIsFullyLoggedIn } from "../../provider/hooks/queries/useIsFullyLoggedIn.js";
52
52
  import { useWallet } from "../../provider/hooks/queries/useWallet.js";
53
53
  import { resolveWalletForChain } from "../resolveWallet.js";
54
+ import { suiClientKey } from "./suiClientKey.js";
54
55
  const SUI_SIGNER_BASE_KEY = "PARA_SUI_SIGNER";
55
56
  function createParaSuiSignerHook(useEnhancer) {
56
- return function useParaSuiSigner2({ address, walletId } = {}) {
57
+ return function useParaSuiSigner2({ address, walletId, client, network } = {}) {
57
58
  var _a;
58
59
  const para = useClient();
59
60
  const { data: isFullyLoggedIn } = useIsFullyLoggedIn();
@@ -61,13 +62,22 @@ function createParaSuiSignerHook(useEnhancer) {
61
62
  const enhancement = (_a = useEnhancer == null ? void 0 : useEnhancer()) != null ? _a : {};
62
63
  const isEmbeddedActive = !!isFullyLoggedIn;
63
64
  const _b = useQuery({
64
- queryKey: [SUI_SIGNER_BASE_KEY, isEmbeddedActive, walletId != null ? walletId : (wallet == null ? void 0 : wallet.type) === "SUI" ? wallet == null ? void 0 : wallet.id : null],
65
+ queryKey: [
66
+ SUI_SIGNER_BASE_KEY,
67
+ isEmbeddedActive,
68
+ walletId != null ? walletId : (wallet == null ? void 0 : wallet.type) === "SUI" ? wallet == null ? void 0 : wallet.id : null,
69
+ network != null ? network : null,
70
+ suiClientKey(client)
71
+ ],
65
72
  enabled: !enhancement.isLoading && isEmbeddedActive && !!para,
66
73
  queryFn: () => __async(null, null, function* () {
67
74
  if (!isEmbeddedActive || !para) return null;
68
75
  const resolved = resolveWalletForChain(para, { address, walletId }, "SUI", wallet != null ? wallet : void 0);
69
76
  const mod = yield importSui();
70
- return mod.createParaSuiSigner({ para, walletId: resolved == null ? void 0 : resolved.id });
77
+ return mod.createParaSuiSigner(__spreadValues(__spreadValues({
78
+ para,
79
+ walletId: resolved == null ? void 0 : resolved.id
80
+ }, client ? { client } : {}), network ? { network } : {}));
71
81
  })
72
82
  }), { data, isLoading } = _b, rest = __objRest(_b, ["data", "isLoading"]);
73
83
  return __spreadValues({ suiSigner: data, data, isLoading }, rest);
@@ -30,6 +30,7 @@ const ParaProviderCoreInner = ({ children, paraClientConfig: paraClient, config,
30
30
  const rpcUrl = useCoreStore((state) => state.rpcUrl);
31
31
  const setParaState = useCoreStore((state) => state.setParaState);
32
32
  const paraState = useCoreStore((state) => state.paraState);
33
+ const initRef = useRef(null);
33
34
  useCoreStore((state) => state.paraConfigVersion);
34
35
  useEffect(() => {
35
36
  setClient(paraClient);
@@ -48,22 +49,27 @@ const ParaProviderCoreInner = ({ children, paraClientConfig: paraClient, config,
48
49
  }
49
50
  }, [config.farcasterMiniAppConfig]);
50
51
  useEffect(() => {
52
+ var _a2;
51
53
  if (!client) return;
52
54
  let cancelled = false;
53
- void client.init().then(() => {
55
+ if (((_a2 = initRef.current) == null ? void 0 : _a2.client) !== client) {
56
+ initRef.current = { client, promise: client.init() };
57
+ }
58
+ void initRef.current.promise.then(() => {
54
59
  if (cancelled) return;
55
60
  const unsubscribe = client.onStatePhaseChange((snapshot) => {
56
61
  setParaState(snapshot);
57
62
  });
58
63
  unsubRef.current = unsubscribe;
59
64
  }).catch((error) => {
65
+ if (cancelled) return;
60
66
  setParaState(client.getCurrentState());
61
67
  console.error(error);
62
68
  });
63
69
  return () => {
64
- var _a2;
70
+ var _a3;
65
71
  cancelled = true;
66
- (_a2 = unsubRef.current) == null ? void 0 : _a2.call(unsubRef);
72
+ (_a3 = unsubRef.current) == null ? void 0 : _a3.call(unsubRef);
67
73
  };
68
74
  }, [client, setParaState]);
69
75
  const callbacksRef = useRef(callbacks);
@@ -105,12 +111,21 @@ function ParaProviderCore({
105
111
  [externalStore, storageAdapter]
106
112
  );
107
113
  const [resolvedClient, setResolvedClient] = useState(null);
114
+ const clientResolutionRef = useRef(null);
115
+ const configuredClientRef = useRef(null);
108
116
  const configureClientRef = useRef(configureClient);
109
117
  configureClientRef.current = configureClient;
110
118
  useEffect(() => {
111
- var _a;
112
- const client = isClientConfig(paraClientInput) ? paraClientInput.createClient(paraClientInput.apiKey, paraClientInput.env, paraClientInput.opts) : paraClientInput;
113
- (_a = configureClientRef.current) == null ? void 0 : _a.call(configureClientRef, client);
119
+ var _a, _b;
120
+ if (((_a = clientResolutionRef.current) == null ? void 0 : _a.input) !== paraClientInput) {
121
+ const client2 = isClientConfig(paraClientInput) ? paraClientInput.createClient(paraClientInput.apiKey, paraClientInput.env, paraClientInput.opts) : paraClientInput;
122
+ clientResolutionRef.current = { input: paraClientInput, client: client2 };
123
+ }
124
+ const client = clientResolutionRef.current.client;
125
+ if (configuredClientRef.current !== client) {
126
+ (_b = configureClientRef.current) == null ? void 0 : _b.call(configureClientRef, client);
127
+ configuredClientRef.current = client;
128
+ }
114
129
  setResolvedClient(client);
115
130
  }, [paraClientInput]);
116
131
  if (!resolvedClient) {
@@ -18,7 +18,7 @@ type AccountValue = PrimaryAuthInfo & {
18
18
  /** Profile picture URL from the provider, when available. */
19
19
  pfpUrl?: string;
20
20
  };
21
- export type Account = ({
21
+ export type EmbeddedAccount = ({
22
22
  isConnected: false;
23
23
  isGuestMode?: false;
24
24
  } & {
@@ -32,5 +32,5 @@ export type Account = ({
32
32
  isConnected: true;
33
33
  isGuestMode: false;
34
34
  } & AccountValue);
35
- export declare const getEmbeddedAccount: (para: ParaCore | undefined, isFullyLoggedIn: boolean | undefined) => Promise<Account>;
35
+ export declare const getEmbeddedAccount: (para: ParaCore | undefined, isFullyLoggedIn: boolean | undefined) => Promise<EmbeddedAccount>;
36
36
  export {};
@@ -0,0 +1,6 @@
1
+ import type ParaCore from '@getpara/core-sdk';
2
+ import type { TWalletType, WalletNoSigner } from '@getpara/core-sdk';
3
+ export declare const getWallet: (para?: ParaCore, selectedWallet?: {
4
+ id?: string;
5
+ type?: TWalletType;
6
+ }, isConnected?: boolean) => Promise<WalletNoSigner | null>;
@@ -1,7 +1,7 @@
1
1
  import type ParaCore from '@getpara/core-sdk';
2
2
  import type { SignUpOrLogInParams, SignUpOrLogInResponse, WaitForLoginParams, WaitForLoginResponse, WaitForSignupParams, WaitForWalletCreationParams, WaitForWalletCreationResponse, VerifyOAuthProcessParams, OAuthResponse, VerifyFarcasterParams, VerifyTelegramParams, LoginExternalWalletParams, LoginExternalWalletResponse, VerifyExternalWalletParams, VerifyExternalWalletResponse, Setup2faResponse, Enable2faParams, Verify2faParams, Verify2faResponse, EnrollMfaResponse, VerifyMfaParams, VerifyMfaResult, LogoutParams, ResendVerificationCodeParams, ResendVerificationCodeResponse, CreateWalletParams, CreateWalletResponse, CreateWalletPerTypeParams, CreateWalletPerTypeResponse, CreatePregenWalletParams, CreatePregenWalletResponse, CreatePregenWalletPerTypeParams, CreatePregenWalletPerTypeResponse, ClaimPregenWalletsParams, ClaimPregenWalletsResponse, HasPregenWalletParams, UpdatePregenWalletIdentifierParams, CreateGuestWalletsResponse, SignMessageParams, SignTransactionParams, FullSignatureRes, GetWalletBalanceParams, IssueJwtParams, IssueJwtResponse, GetLinkedAccountsParams, GetLinkedAccountsResponse, GetAuthFactorsResponse, AddAuthFactorParams, AddAuthFactorResponse, AddOAuthFactorParams, AddOAuthFactorResponse, AddExternalWalletFactorParams, AddExternalWalletFactorResponse, ContinueAuthFactorLinkParams, ContinueAuthFactorLinkResponse, UnlinkAuthFactorParams, AddCredentialParams, ExportPrivateKeyParams, ExportPrivateKeyResponse, RequestFaucetParams, RequestFaucetResponse, AuthenticateWithEmailOrPhoneParams, AuthenticateWithEmailOrPhoneResponse, AuthenticateWithOAuthParams, AuthenticateWithOAuthResponse, AuthenticateWithCustomOAuthParams, AuthenticateWithCustomOAuthResponse } from '@getpara/core-sdk';
3
3
  export { generateCoreAction, type CoreAction } from './utils.js';
4
- export { getEmbeddedAccount, type Account } from './getEmbeddedAccount.js';
4
+ export { getEmbeddedAccount, type EmbeddedAccount } from './getEmbeddedAccount.js';
5
5
  export { getWallet } from './getWallet.js';
6
6
  export declare const signUpOrLogIn: (para?: ParaCore, args?: SignUpOrLogInParams) => Promise<SignUpOrLogInResponse>;
7
7
  export declare const verifyNewAccount: import("./utils.js").CoreAction<"verifyNewAccount">;
@@ -1,4 +1,3 @@
1
1
  export * from './utils/index.js';
2
2
  export * from './queries/index.js';
3
3
  export * from './mutations/index.js';
4
- export * from './aa/index.js';
@@ -1,4 +1,3 @@
1
1
  export * from "./utils/index.js";
2
2
  export * from "./queries/index.js";
3
3
  export * from "./mutations/index.js";
4
- export * from "./aa/index.js";
@@ -22,14 +22,9 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
22
22
  import { useClient } from "../utils/useClient.js";
23
23
  import { useIsFullyLoggedIn } from "../queries/useIsFullyLoggedIn.js";
24
24
  import { renameMutations } from "../../utils/renameMutations.js";
25
+ import { createObjectIdentity } from "../../utils/objectIdentity.js";
25
26
  const PERMISSIONS_KEY = "PARA_PERMISSIONS";
26
- const clients = /* @__PURE__ */ new WeakMap();
27
- let nextClientId = 0;
28
- function clientKey(client) {
29
- if (!client) return null;
30
- if (!clients.has(client)) clients.set(client, ++nextClientId);
31
- return clients.get(client);
32
- }
27
+ const clientKey = createObjectIdentity();
33
28
  function usePermissionsQuery(method, args, read, isPublic = false) {
34
29
  const client = useClient();
35
30
  const { data: loggedIn } = useIsFullyLoggedIn();
@@ -1,4 +1,4 @@
1
- import { type Account } from '../../actions/getEmbeddedAccount.js';
1
+ import { type EmbeddedAccount } from '../../actions/getEmbeddedAccount.js';
2
2
  export declare const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
3
3
  export type ConnectionType = 'embedded' | 'external' | 'both' | 'none';
4
4
  /**
@@ -28,7 +28,7 @@ export interface UseAccountReturn<TExternal = Record<string, unknown>> {
28
28
  */
29
29
  connectionType: ConnectionType;
30
30
  /** The embedded Para account. Use this instead of deprecated top-level properties. */
31
- embedded: Omit<Account, 'isReady' | 'isFarcasterMiniApp' | 'isConnected' | 'isGuestMode'> & {
31
+ embedded: Omit<EmbeddedAccount, 'isReady' | 'isFarcasterMiniApp' | 'isConnected' | 'isGuestMode'> & {
32
32
  isConnected: boolean;
33
33
  isGuestMode?: boolean;
34
34
  };
@@ -44,6 +44,14 @@ import { useIsFullyLoggedIn } from "./useIsFullyLoggedIn.js";
44
44
  import { useCoreStore } from "../../stores/CoreStoreContext.js";
45
45
  import { getEmbeddedAccount } from "../../actions/getEmbeddedAccount.js";
46
46
  const ACCOUNT_BASE_KEY = "PARA_ACCOUNT";
47
+ const ACCOUNT_IDENTITY_KEY_LENGTH = 3;
48
+ function isSameAccountIdentity(previousKey, nextKey) {
49
+ if (!previousKey) return false;
50
+ for (let index = 0; index < ACCOUNT_IDENTITY_KEY_LENGTH; index += 1) {
51
+ if (previousKey[index] !== nextKey[index]) return false;
52
+ }
53
+ return true;
54
+ }
47
55
  function useInvalidation(connections, queryKey) {
48
56
  const queryClient = useQueryClient();
49
57
  const lastConnectionStateRef = useRef(null);
@@ -92,18 +100,22 @@ function createAccountHook(useExternalWallets) {
92
100
  const { data, isLoading } = useQuery({
93
101
  enabled: isSuccess && !!client && !isFullyLoggedInLoading,
94
102
  queryKey,
103
+ // Connector state participates in the key. Keep the last valid account
104
+ // mounted while a replacement key resolves so active actions are not lost.
105
+ placeholderData: (previousData, previousQuery) => isSameAccountIdentity(previousQuery == null ? void 0 : previousQuery.queryKey, queryKey) ? previousData : void 0,
95
106
  queryFn: () => __async(null, null, function* () {
107
+ var _a2;
96
108
  const paraAccount = yield getEmbeddedAccount(client, isEmbeddedReady);
97
109
  let connectionType = "none";
98
110
  const hasExternalConnection = Object.values(external.connections).some(Boolean);
111
+ const wallets = (_a2 = paraAccount.wallets) != null ? _a2 : [];
112
+ const hasExternalWallet = wallets.some((w) => "isExternal" in w && w.isExternal);
113
+ const hasEmbeddedWallet = wallets.some((w) => !("isExternal" in w) || !w.isExternal);
99
114
  if (paraAccount.isConnected) {
100
- connectionType = "embedded";
101
- if (paraAccount.wallets.some((w) => "isExternal" in w && w.isExternal)) {
102
- connectionType = "both";
103
- }
104
- if (paraAccount.wallets.every((w) => "isExternal" in w && w.isExternal) && hasExternalConnection) {
105
- connectionType = "external";
106
- }
115
+ if (hasEmbeddedWallet && hasExternalWallet) connectionType = "both";
116
+ else if (hasEmbeddedWallet) connectionType = "embedded";
117
+ else if (hasExternalWallet || hasExternalConnection) connectionType = "external";
118
+ else connectionType = "embedded";
107
119
  }
108
120
  const isEmbeddedConnected = connectionType === "embedded" || connectionType === "both";
109
121
  const connectedNetworks = Object.entries(external.connections).filter(([, connected]) => connected).map(([network]) => network);
@@ -0,0 +1,7 @@
1
+ import { type UseQueryResult } from '@tanstack/react-query';
2
+ import { getWallet } from '../../actions/getWallet.js';
3
+ export declare const WALLET_BASE_KEY = "PARA_WALLET";
4
+ /**
5
+ * Hook for retrieving the selected wallet.
6
+ */
7
+ export declare const useWallet: () => UseQueryResult<Awaited<ReturnType<typeof getWallet>>>;
@@ -1,5 +1,6 @@
1
1
  export { ParaProviderCore, type ParaProviderBaseProps, type ParaProviderCoreProps, type ParaClientConfig, type ParaClientConfigWithFactory, type CoreProviderConfig, type CoreCallbacks, type ParaCallbackEvent, } from './ParaProviderCore.js';
2
2
  export * from './stores/index.js';
3
3
  export * from './hooks/index.js';
4
+ export type { Account } from './hooks/index.js';
4
5
  export * from './actions/index.js';
5
6
  export { renameMutations, type Compute } from './utils/renameMutations.js';
@@ -0,0 +1 @@
1
+ export declare function createObjectIdentity<T extends object>(): (value: T | null | undefined) => number | null;
@@ -0,0 +1,15 @@
1
+ function createObjectIdentity() {
2
+ const identities = /* @__PURE__ */ new WeakMap();
3
+ let nextIdentity = 0;
4
+ return function identify(value) {
5
+ if (!value) return null;
6
+ const existingIdentity = identities.get(value);
7
+ if (existingIdentity !== void 0) return existingIdentity;
8
+ const identity = ++nextIdentity;
9
+ identities.set(value, identity);
10
+ return identity;
11
+ };
12
+ }
13
+ export {
14
+ createObjectIdentity
15
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-core",
3
- "version": "3.20.0",
3
+ "version": "3.21.0",
4
4
  "description": "Platform-agnostic ParaProvider, hooks, and store for Para SDK",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -16,6 +16,50 @@
16
16
  "types": "./dist/provider/index.d.ts",
17
17
  "import": "./dist/provider/index.js"
18
18
  },
19
+ "./internal/aa/types": {
20
+ "types": "./dist/provider/hooks/aa/types.d.ts",
21
+ "import": "./dist/provider/hooks/aa/types.js"
22
+ },
23
+ "./internal/aa/alchemy": {
24
+ "types": "./dist/provider/hooks/aa/alchemy.d.ts",
25
+ "import": "./dist/provider/hooks/aa/alchemy.js"
26
+ },
27
+ "./internal/aa/biconomy": {
28
+ "types": "./dist/provider/hooks/aa/biconomy.d.ts",
29
+ "import": "./dist/provider/hooks/aa/biconomy.js"
30
+ },
31
+ "./internal/aa/cdp": {
32
+ "types": "./dist/provider/hooks/aa/cdp.d.ts",
33
+ "import": "./dist/provider/hooks/aa/cdp.js"
34
+ },
35
+ "./internal/aa/gelato": {
36
+ "types": "./dist/provider/hooks/aa/gelato.d.ts",
37
+ "import": "./dist/provider/hooks/aa/gelato.js"
38
+ },
39
+ "./internal/aa/pimlico": {
40
+ "types": "./dist/provider/hooks/aa/pimlico.d.ts",
41
+ "import": "./dist/provider/hooks/aa/pimlico.js"
42
+ },
43
+ "./internal/aa/porto": {
44
+ "types": "./dist/provider/hooks/aa/porto.d.ts",
45
+ "import": "./dist/provider/hooks/aa/porto.js"
46
+ },
47
+ "./internal/aa/rhinestone": {
48
+ "types": "./dist/provider/hooks/aa/rhinestone.d.ts",
49
+ "import": "./dist/provider/hooks/aa/rhinestone.js"
50
+ },
51
+ "./internal/aa/safe": {
52
+ "types": "./dist/provider/hooks/aa/safe.d.ts",
53
+ "import": "./dist/provider/hooks/aa/safe.js"
54
+ },
55
+ "./internal/aa/thirdweb": {
56
+ "types": "./dist/provider/hooks/aa/thirdweb.d.ts",
57
+ "import": "./dist/provider/hooks/aa/thirdweb.js"
58
+ },
59
+ "./internal/aa/zerodev": {
60
+ "types": "./dist/provider/hooks/aa/zerodev.d.ts",
61
+ "import": "./dist/provider/hooks/aa/zerodev.js"
62
+ },
19
63
  "./mutations": {
20
64
  "types": "./dist/mutations.d.ts",
21
65
  "import": "./dist/mutations.js"
@@ -54,6 +98,39 @@
54
98
  "internal": [
55
99
  "./dist/provider/index.d.ts"
56
100
  ],
101
+ "internal/aa/types": [
102
+ "./dist/provider/hooks/aa/types.d.ts"
103
+ ],
104
+ "internal/aa/alchemy": [
105
+ "./dist/provider/hooks/aa/alchemy.d.ts"
106
+ ],
107
+ "internal/aa/biconomy": [
108
+ "./dist/provider/hooks/aa/biconomy.d.ts"
109
+ ],
110
+ "internal/aa/cdp": [
111
+ "./dist/provider/hooks/aa/cdp.d.ts"
112
+ ],
113
+ "internal/aa/gelato": [
114
+ "./dist/provider/hooks/aa/gelato.d.ts"
115
+ ],
116
+ "internal/aa/pimlico": [
117
+ "./dist/provider/hooks/aa/pimlico.d.ts"
118
+ ],
119
+ "internal/aa/porto": [
120
+ "./dist/provider/hooks/aa/porto.d.ts"
121
+ ],
122
+ "internal/aa/rhinestone": [
123
+ "./dist/provider/hooks/aa/rhinestone.d.ts"
124
+ ],
125
+ "internal/aa/safe": [
126
+ "./dist/provider/hooks/aa/safe.d.ts"
127
+ ],
128
+ "internal/aa/thirdweb": [
129
+ "./dist/provider/hooks/aa/thirdweb.d.ts"
130
+ ],
131
+ "internal/aa/zerodev": [
132
+ "./dist/provider/hooks/aa/zerodev.d.ts"
133
+ ],
57
134
  "mutations": [
58
135
  "./dist/mutations.d.ts"
59
136
  ],
@@ -85,48 +162,116 @@
85
162
  "package.json"
86
163
  ],
87
164
  "scripts": {
88
- "build": "rm -rf dist && node ./scripts/build.mjs; tsc --emitDeclarationOnly || true",
89
- "test": "vitest run"
165
+ "build": "rm -rf dist && node ./scripts/build.mjs && yarn build:types",
166
+ "test": "vitest run --coverage",
167
+ "build:types": "tsc --emitDeclarationOnly",
168
+ "typecheck": "tsc --noEmit"
90
169
  },
91
170
  "dependencies": {
92
- "@getpara/core-sdk": "3.20.0",
171
+ "@getpara/core-sdk": "3.21.0",
93
172
  "zustand": "^5.0.0"
94
173
  },
95
174
  "devDependencies": {
96
- "@cosmjs/amino": "^0.32.0",
97
- "@cosmjs/proto-signing": "^0.32.0",
98
- "@getpara/cosmjs-v0-integration": "3.20.0",
99
- "@getpara/ethers-v6-integration": "3.20.0",
100
- "@getpara/solana-signers-v2-integration": "3.20.0",
101
- "@getpara/stellar-sdk-v14-integration": "3.20.0",
102
- "@getpara/sui-sdk-integration": "3.20.0",
103
- "@getpara/viem-v2-integration": "3.20.0",
175
+ "@cosmjs/amino": "^0.32.4",
176
+ "@cosmjs/proto-signing": "^0.32.4",
177
+ "@cosmjs/stargate": "^0.32.4",
178
+ "@getpara/aa-alchemy": "3.21.0",
179
+ "@getpara/aa-biconomy": "3.21.0",
180
+ "@getpara/aa-cdp": "3.21.0",
181
+ "@getpara/aa-gelato": "3.21.0",
182
+ "@getpara/aa-pimlico": "3.21.0",
183
+ "@getpara/aa-porto": "3.21.0",
184
+ "@getpara/aa-rhinestone": "3.21.0",
185
+ "@getpara/aa-safe": "3.21.0",
186
+ "@getpara/aa-thirdweb": "3.21.0",
187
+ "@getpara/aa-zerodev": "3.21.0",
188
+ "@getpara/cosmjs-v0-integration": "3.21.0",
189
+ "@getpara/ethers-v6-integration": "3.21.0",
190
+ "@getpara/solana-signers-v2-integration": "3.21.0",
191
+ "@getpara/stellar-sdk-v14-integration": "3.21.0",
192
+ "@getpara/sui-sdk-integration": "3.21.0",
193
+ "@getpara/viem-v2-integration": "3.21.0",
194
+ "@mysten/sui": "^2.0.0",
195
+ "@solana/keys": "^2.2.1",
104
196
  "@solana/signers": "^2.0.0",
197
+ "@stellar/stellar-sdk": "^14.0.0",
105
198
  "@tanstack/react-query": "^5.74.0",
106
199
  "@testing-library/dom": "^10.4.0",
107
200
  "@testing-library/react": "^16.3.0",
108
201
  "@types/react": "^18.3.3",
109
202
  "esbuild": "^0.28.1",
203
+ "ethers": "^6.13.5",
110
204
  "glob": "^11.0.2",
111
205
  "jsdom": "^25.0.0",
112
206
  "react": "^18.3.1",
113
207
  "react-dom": "^18.3.1",
114
208
  "typescript": "^5.8.3",
115
- "viem": "2.42.1",
209
+ "viem": "^2.39.0",
116
210
  "vitest": "^3.0.0"
117
211
  },
118
212
  "peerDependencies": {
213
+ "@cosmjs/amino": ">=0.32.4",
214
+ "@cosmjs/proto-signing": ">=0.32.4",
215
+ "@getpara/aa-alchemy": ">=2.15.0",
216
+ "@getpara/aa-biconomy": ">=2.15.0",
217
+ "@getpara/aa-cdp": ">=2.15.0",
218
+ "@getpara/aa-gelato": ">=2.15.0",
219
+ "@getpara/aa-pimlico": ">=2.15.0",
220
+ "@getpara/aa-porto": ">=2.15.0",
221
+ "@getpara/aa-rhinestone": ">=2.15.0",
222
+ "@getpara/aa-safe": ">=2.15.0",
223
+ "@getpara/aa-thirdweb": ">=2.15.0",
224
+ "@getpara/aa-zerodev": ">=2.15.0",
119
225
  "@getpara/cosmjs-v0-integration": ">=2",
120
226
  "@getpara/ethers-v6-integration": ">=2",
121
227
  "@getpara/solana-signers-v2-integration": ">=2",
122
228
  "@getpara/stellar-sdk-v14-integration": ">=2",
123
229
  "@getpara/sui-sdk-integration": ">=2",
124
230
  "@getpara/viem-v2-integration": ">=2",
231
+ "@solana/signers": ">=2.0.0",
232
+ "@stellar/stellar-sdk": "^14.0.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
125
233
  "@tanstack/react-query": ">=5",
234
+ "ethers": "^6.0.0",
126
235
  "react": ">=18",
127
- "viem": ">=2"
236
+ "viem": "^2.0.0"
128
237
  },
129
238
  "peerDependenciesMeta": {
239
+ "@cosmjs/amino": {
240
+ "optional": true
241
+ },
242
+ "@cosmjs/proto-signing": {
243
+ "optional": true
244
+ },
245
+ "@getpara/aa-alchemy": {
246
+ "optional": true
247
+ },
248
+ "@getpara/aa-biconomy": {
249
+ "optional": true
250
+ },
251
+ "@getpara/aa-cdp": {
252
+ "optional": true
253
+ },
254
+ "@getpara/aa-gelato": {
255
+ "optional": true
256
+ },
257
+ "@getpara/aa-pimlico": {
258
+ "optional": true
259
+ },
260
+ "@getpara/aa-porto": {
261
+ "optional": true
262
+ },
263
+ "@getpara/aa-rhinestone": {
264
+ "optional": true
265
+ },
266
+ "@getpara/aa-safe": {
267
+ "optional": true
268
+ },
269
+ "@getpara/aa-thirdweb": {
270
+ "optional": true
271
+ },
272
+ "@getpara/aa-zerodev": {
273
+ "optional": true
274
+ },
130
275
  "@getpara/cosmjs-v0-integration": {
131
276
  "optional": true
132
277
  },
@@ -144,7 +289,24 @@
144
289
  },
145
290
  "@getpara/viem-v2-integration": {
146
291
  "optional": true
292
+ },
293
+ "@solana/signers": {
294
+ "optional": true
295
+ },
296
+ "@stellar/stellar-sdk": {
297
+ "optional": true
298
+ },
299
+ "ethers": {
300
+ "optional": true
301
+ },
302
+ "viem": {
303
+ "optional": true
147
304
  }
148
305
  },
149
- "gitHead": "0a7224c678bc2b172bd41cce75637a8783869a93"
306
+ "nx": {
307
+ "implicitDependencies": [
308
+ "@getpara/aa-*"
309
+ ]
310
+ },
311
+ "gitHead": "e1ca81fb06f6337aaa7cc1860584b7ba5d1d9ca8"
150
312
  }
@@ -1,12 +0,0 @@
1
- export { createSmartAccountHook } from './createSmartAccountHook.js';
2
- export type { SmartAccountHookConfig, SmartAccountEnhancement, UseSmartAccountResult } from './types.js';
3
- export { useAlchemySmartAccount, createAlchemySmartAccountHook, ALCHEMY_SMART_ACCOUNT_BASE_KEY } from './alchemy.js';
4
- export { useBiconomySmartAccount, createBiconomySmartAccountHook, BICONOMY_SMART_ACCOUNT_BASE_KEY } from './biconomy.js';
5
- export { useCDPSmartAccount, createCDPSmartAccountHook, CDP_SMART_ACCOUNT_BASE_KEY } from './cdp.js';
6
- export { useGelatoSmartAccount, createGelatoSmartAccountHook, GELATO_SMART_ACCOUNT_BASE_KEY } from './gelato.js';
7
- export { usePimlicoSmartAccount, createPimlicoSmartAccountHook, PIMLICO_SMART_ACCOUNT_BASE_KEY } from './pimlico.js';
8
- export { usePortoSmartAccount, createPortoSmartAccountHook, PORTO_ACCOUNT_BASE_KEY } from './porto.js';
9
- export { useRhinestoneSmartAccount, createRhinestoneSmartAccountHook, RHINESTONE_SMART_ACCOUNT_BASE_KEY, } from './rhinestone.js';
10
- export { useSafeSmartAccount, createSafeSmartAccountHook, SAFE_SMART_ACCOUNT_BASE_KEY } from './safe.js';
11
- export { useThirdwebSmartAccount, createThirdwebSmartAccountHook, THIRDWEB_SMART_ACCOUNT_BASE_KEY } from './thirdweb.js';
12
- export { useZeroDevSmartAccount, createZeroDevSmartAccountHook, ZERODEV_SMART_ACCOUNT_BASE_KEY } from './zerodev.js';
@@ -1,48 +0,0 @@
1
- import { createSmartAccountHook } from "./createSmartAccountHook.js";
2
- import { useAlchemySmartAccount, createAlchemySmartAccountHook, ALCHEMY_SMART_ACCOUNT_BASE_KEY } from "./alchemy.js";
3
- import { useBiconomySmartAccount, createBiconomySmartAccountHook, BICONOMY_SMART_ACCOUNT_BASE_KEY } from "./biconomy.js";
4
- import { useCDPSmartAccount, createCDPSmartAccountHook, CDP_SMART_ACCOUNT_BASE_KEY } from "./cdp.js";
5
- import { useGelatoSmartAccount, createGelatoSmartAccountHook, GELATO_SMART_ACCOUNT_BASE_KEY } from "./gelato.js";
6
- import { usePimlicoSmartAccount, createPimlicoSmartAccountHook, PIMLICO_SMART_ACCOUNT_BASE_KEY } from "./pimlico.js";
7
- import { usePortoSmartAccount, createPortoSmartAccountHook, PORTO_ACCOUNT_BASE_KEY } from "./porto.js";
8
- import {
9
- useRhinestoneSmartAccount,
10
- createRhinestoneSmartAccountHook,
11
- RHINESTONE_SMART_ACCOUNT_BASE_KEY
12
- } from "./rhinestone.js";
13
- import { useSafeSmartAccount, createSafeSmartAccountHook, SAFE_SMART_ACCOUNT_BASE_KEY } from "./safe.js";
14
- import { useThirdwebSmartAccount, createThirdwebSmartAccountHook, THIRDWEB_SMART_ACCOUNT_BASE_KEY } from "./thirdweb.js";
15
- import { useZeroDevSmartAccount, createZeroDevSmartAccountHook, ZERODEV_SMART_ACCOUNT_BASE_KEY } from "./zerodev.js";
16
- export {
17
- ALCHEMY_SMART_ACCOUNT_BASE_KEY,
18
- BICONOMY_SMART_ACCOUNT_BASE_KEY,
19
- CDP_SMART_ACCOUNT_BASE_KEY,
20
- GELATO_SMART_ACCOUNT_BASE_KEY,
21
- PIMLICO_SMART_ACCOUNT_BASE_KEY,
22
- PORTO_ACCOUNT_BASE_KEY,
23
- RHINESTONE_SMART_ACCOUNT_BASE_KEY,
24
- SAFE_SMART_ACCOUNT_BASE_KEY,
25
- THIRDWEB_SMART_ACCOUNT_BASE_KEY,
26
- ZERODEV_SMART_ACCOUNT_BASE_KEY,
27
- createAlchemySmartAccountHook,
28
- createBiconomySmartAccountHook,
29
- createCDPSmartAccountHook,
30
- createGelatoSmartAccountHook,
31
- createPimlicoSmartAccountHook,
32
- createPortoSmartAccountHook,
33
- createRhinestoneSmartAccountHook,
34
- createSafeSmartAccountHook,
35
- createSmartAccountHook,
36
- createThirdwebSmartAccountHook,
37
- createZeroDevSmartAccountHook,
38
- useAlchemySmartAccount,
39
- useBiconomySmartAccount,
40
- useCDPSmartAccount,
41
- useGelatoSmartAccount,
42
- usePimlicoSmartAccount,
43
- usePortoSmartAccount,
44
- useRhinestoneSmartAccount,
45
- useSafeSmartAccount,
46
- useThirdwebSmartAccount,
47
- useZeroDevSmartAccount
48
- };