@getpara/react-sdk-lite 2.9.0 → 2.11.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/modal/ParaModal.js +3 -1
- package/dist/modal/components/Account/Account.js +114 -22
- package/dist/modal/components/Account/AccountMonitorTx.d.ts +1 -0
- package/dist/modal/components/Account/AccountMonitorTx.js +256 -0
- package/dist/modal/components/Account/AccountSend/AccountSendAsset.js +2 -2
- package/dist/modal/components/Account/AccountSend/AccountSendForm.js +68 -10
- package/dist/modal/components/Account/AccountSend/context.d.ts +2 -0
- package/dist/modal/components/Account/AccountSend/context.js +36 -109
- package/dist/modal/components/AddFunds/AddFundsContext.d.ts +2 -0
- package/dist/modal/components/AddFunds/AddFundsContext.js +88 -31
- package/dist/modal/components/AddFunds/AddFundsProvider.js +2 -2
- package/dist/modal/components/AddFunds/AddFundsReceive.js +1 -1
- package/dist/modal/components/AddFunds/AddFundsSettings.js +134 -29
- package/dist/modal/components/Body/Body.js +4 -0
- package/dist/modal/components/ErrorBoundary.d.ts +20 -0
- package/dist/modal/components/ErrorBoundary.js +27 -0
- package/dist/modal/components/OnRampComponents/OnRampProviderButton.js +3 -8
- package/dist/modal/components/common.d.ts +5 -1
- package/dist/modal/components/common.js +27 -1
- package/dist/modal/hooks/index.d.ts +1 -0
- package/dist/modal/hooks/index.js +1 -0
- package/dist/modal/hooks/useSendMutations.d.ts +51 -0
- package/dist/modal/hooks/useSendMutations.js +170 -0
- package/dist/modal/hooks/useTransactionMonitoring.d.ts +1 -0
- package/dist/modal/hooks/useTransactionMonitoring.js +175 -0
- package/dist/modal/index.d.ts +1 -1
- package/dist/modal/index.js +1 -1
- package/dist/modal/stores/index.d.ts +1 -0
- package/dist/modal/stores/index.js +1 -0
- package/dist/modal/stores/modal/actions.js +0 -1
- package/dist/modal/stores/modal/useModalSessionStore.d.ts +28 -0
- package/dist/modal/stores/modal/useModalSessionStore.js +26 -0
- package/dist/modal/stores/modal/useModalStore.d.ts +1 -3
- package/dist/modal/stores/modal/useModalStore.js +0 -1
- package/dist/modal/types/modalProps.d.ts +3 -1
- package/dist/modal/utils/onramps.d.ts +61 -0
- package/dist/modal/utils/onramps.js +112 -0
- package/dist/modal/utils/steps.d.ts +4 -2
- package/dist/modal/utils/steps.js +6 -2
- package/dist/provider/hooks/queries/useProfileBalance.js +33 -6
- package/dist/provider/hooks/utils/index.d.ts +1 -0
- package/dist/provider/hooks/utils/index.js +2 -0
- package/dist/provider/hooks/utils/useEventListeners.js +2 -2
- package/dist/provider/hooks/utils/useSetBalanceOverrides.d.ts +34 -0
- package/dist/provider/hooks/utils/useSetBalanceOverrides.js +12 -0
- package/dist/provider/stores/slices/modal.js +11 -1
- package/dist/provider/stores/types.d.ts +8 -0
- package/package.json +9 -8
- package/dist/modal/utils/validateOnRampConfig.d.ts +0 -5
- package/dist/modal/utils/validateOnRampConfig.js +0 -32
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BalanceOverrides } from '@getpara/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a function to set the balance overrides, similar to React `setState`. Use this once your balance overrides are available to modify or replace the displayed wallet balances in the Para Modal. Both the individual wallet and the cumulative total balance will be modified.
|
|
4
|
+
*
|
|
5
|
+
* If you have set `useBalanceOverrides` to `true` in your configuration, you must call this function at least once with a non-null value for balances to be displayed.
|
|
6
|
+
*
|
|
7
|
+
* **Behavior notes:**
|
|
8
|
+
* - Both numeric `value.value` and `formattedValue` strings are recalculated after overrides.
|
|
9
|
+
* - Wallets not present in the override map retain their original values.
|
|
10
|
+
* - Overrides are re-applied whenever the underlying balance data refetches; they do not need to be re-set.
|
|
11
|
+
* - Non-finite values (`NaN`, `Infinity`) are silently skipped.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```tsx
|
|
15
|
+
* import { useAccount, useSetBalanceOverrides } from '@getpara/react-sdk';
|
|
16
|
+
*
|
|
17
|
+
* const ComponentWithinParaProvider = () => {
|
|
18
|
+
* const setBalanceOverrides = useSetBalanceOverrides();
|
|
19
|
+
* const { embedded: embeddedWallets } = useAccount();
|
|
20
|
+
*
|
|
21
|
+
* useEffect(() => {
|
|
22
|
+
* const interval = setInterval(async () => {
|
|
23
|
+
* const balances = await getBalancesFromYourApi({ addresses: embeddedWallets.map(w => w.address!) });
|
|
24
|
+
*
|
|
25
|
+
* // Pass a Record<string, number> mapping wallet addresses to their new balance values:
|
|
26
|
+
* setBalanceOverrides(balances);
|
|
27
|
+
* }, 10000);
|
|
28
|
+
* return () => clearInterval(interval);
|
|
29
|
+
* }, [embeddedWallets, setBalanceOverrides]);
|
|
30
|
+
*
|
|
31
|
+
* // ...
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const useSetBalanceOverrides: () => (balanceOverrides: BalanceOverrides) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "../../../chunk-MMUBH76A.js";
|
|
3
|
+
import { useStore } from "../../stores/useStore.js";
|
|
4
|
+
const useSetBalanceOverrides = () => {
|
|
5
|
+
const setBalanceOverrides = useStore((state) => state.setBalanceOverrides);
|
|
6
|
+
return (balanceOverrides) => {
|
|
7
|
+
setBalanceOverrides(balanceOverrides);
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
useSetBalanceOverrides
|
|
12
|
+
};
|
|
@@ -18,7 +18,17 @@ const createModalSlice = (set) => ({
|
|
|
18
18
|
refs: {
|
|
19
19
|
openedToStep: createRef(),
|
|
20
20
|
balancesInvalidationTime: createRef()
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
balanceOverrides: null,
|
|
23
|
+
setBalanceOverrides: (balanceOverrides) => set((state) => {
|
|
24
|
+
var _a, _b;
|
|
25
|
+
return {
|
|
26
|
+
balanceOverrides: balanceOverrides ? {
|
|
27
|
+
version: ((_b = (_a = state.balanceOverrides) == null ? void 0 : _a.version) != null ? _b : 0) + 1,
|
|
28
|
+
value: balanceOverrides
|
|
29
|
+
} : null
|
|
30
|
+
};
|
|
31
|
+
})
|
|
22
32
|
});
|
|
23
33
|
export {
|
|
24
34
|
createModalSlice
|
|
@@ -7,6 +7,12 @@ import { ParaSolanaProvider, SolanaExternalWalletContextType, WalletList as Sola
|
|
|
7
7
|
import { ModalStep, ParaModalProps } from '../../modal/index.js';
|
|
8
8
|
import { OAuthLogoVariantType } from '../../modal/types/modalProps.js';
|
|
9
9
|
import { type TExternalWallet } from '@getpara/react-common';
|
|
10
|
+
import { BalanceOverrides } from '@getpara/shared';
|
|
11
|
+
/** Balance overrides with a version field for React Query cache invalidation (version must be serializable). */
|
|
12
|
+
export type BalanceOverridesWithVersion = {
|
|
13
|
+
version: number;
|
|
14
|
+
value: BalanceOverrides;
|
|
15
|
+
};
|
|
10
16
|
export type FarcasterMiniAppConfig = {
|
|
11
17
|
/**
|
|
12
18
|
* Whether to disable automatic sign-in via the Farcaster user's existing miniapp wallet(s).
|
|
@@ -40,6 +46,8 @@ export interface ModalSlice {
|
|
|
40
46
|
openedToStep: MutableRefObject<ModalStep | null>;
|
|
41
47
|
balancesInvalidationTime: MutableRefObject<number | null>;
|
|
42
48
|
};
|
|
49
|
+
balanceOverrides: BalanceOverridesWithVersion | null;
|
|
50
|
+
setBalanceOverrides: (_: BalanceOverrides | null) => void;
|
|
43
51
|
}
|
|
44
52
|
export interface WalletSlice {
|
|
45
53
|
rpcUrl?: string;
|
package/package.json
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-sdk-lite",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"bin": {
|
|
5
5
|
"setup-para": "dist/cli/cli.mjs"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@getpara/react-common": "2.
|
|
9
|
-
"@getpara/react-components": "2.
|
|
10
|
-
"@getpara/web-sdk": "2.
|
|
8
|
+
"@getpara/react-common": "2.11.0",
|
|
9
|
+
"@getpara/react-components": "2.11.0",
|
|
10
|
+
"@getpara/web-sdk": "2.11.0",
|
|
11
11
|
"date-fns": "^3.6.0",
|
|
12
12
|
"framer-motion": "^11.3.31",
|
|
13
13
|
"libphonenumber-js": "^1.11.7",
|
|
14
|
+
"socket.io-client": "^4.5.1",
|
|
14
15
|
"styled-components": "^6.1.8",
|
|
15
16
|
"zustand": "^4.5.2",
|
|
16
17
|
"zustand-sync-tabs": "^0.2.2"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
|
-
"@getpara/cosmos-wallet-connectors": "2.
|
|
20
|
-
"@getpara/evm-wallet-connectors": "2.
|
|
21
|
-
"@getpara/solana-wallet-connectors": "2.
|
|
20
|
+
"@getpara/cosmos-wallet-connectors": "2.11.0",
|
|
21
|
+
"@getpara/evm-wallet-connectors": "2.11.0",
|
|
22
|
+
"@getpara/solana-wallet-connectors": "2.11.0",
|
|
22
23
|
"@tanstack/react-query": "^5.74.0",
|
|
23
24
|
"@testing-library/dom": "^10.4.0",
|
|
24
25
|
"@testing-library/react": "^16.3.0",
|
|
@@ -38,7 +39,7 @@
|
|
|
38
39
|
"package.json",
|
|
39
40
|
"styles.css"
|
|
40
41
|
],
|
|
41
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "1cce45857320460cca03c4a9d0a59db169b222d6",
|
|
42
43
|
"main": "dist/index.js",
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@tanstack/react-query": ">=5.0.0",
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import "../../chunk-MMUBH76A.js";
|
|
3
|
-
class OnRampConfigError extends Error {
|
|
4
|
-
constructor(message) {
|
|
5
|
-
super(`On-ramp configuration error: ${message}.`);
|
|
6
|
-
this.name = "OnRampConfigError";
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function checkHasProviders({ providers }) {
|
|
10
|
-
if (!providers || providers.length < 1) {
|
|
11
|
-
throw new OnRampConfigError("No providers are configured");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
function checkDuplicateProviders({ providers }) {
|
|
15
|
-
providers.forEach((id, index) => {
|
|
16
|
-
if (providers.findIndex((p) => p === id) !== index) {
|
|
17
|
-
throw new OnRampConfigError(`Provider ${id} is configured more than once`);
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
function validateOnRampConfig(obj) {
|
|
22
|
-
if (!obj) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
checkHasProviders(obj);
|
|
26
|
-
checkDuplicateProviders(obj);
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
OnRampConfigError,
|
|
31
|
-
validateOnRampConfig
|
|
32
|
-
};
|