@dynamic-labs/sdk-react-core 1.0.0-alpha.11 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/index.cjs +3 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +2 -0
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.cjs +1 -1
- package/src/lib/components/SecureTurnkeyWalletCard/SecureTurnkeyWalletCard.js +1 -1
- package/src/lib/context/FundingContext/FundingContext.cjs +35 -27
- package/src/lib/context/FundingContext/FundingContext.d.ts +4 -0
- package/src/lib/context/FundingContext/FundingContext.js +36 -28
- package/src/lib/context/FundingContext/index.d.ts +1 -0
- package/src/lib/context/FundingContext/useFunding/index.d.ts +1 -0
- package/src/lib/context/FundingContext/useFunding/useFunding.cjs +39 -0
- package/src/lib/context/FundingContext/useFunding/useFunding.d.ts +9 -0
- package/src/lib/context/FundingContext/useFunding/useFunding.js +35 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## [1.0.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.11...v1.0.0-alpha.12) (2023-12-11)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add useFunding hook ([#4098](https://github.com/dynamic-labs/DynamicAuth/issues/4098)) ([27424ab](https://github.com/dynamic-labs/DynamicAuth/commit/27424ab1a15202ee2b7c73c8a19f11e480e1794a))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add primary color to the secure wallet text ([#4127](https://github.com/dynamic-labs/DynamicAuth/issues/4127)) ([7c642d0](https://github.com/dynamic-labs/DynamicAuth/commit/7c642d0385112289df52874bc5dd2eaa0e6cdf50))
|
|
13
|
+
|
|
2
14
|
## [1.0.0-alpha.11](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.10...v1.0.0-alpha.11) (2023-12-11)
|
|
3
15
|
|
|
4
16
|
## [1.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2023-12-08)
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.12",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
"react-focus-lock": "2.9.2",
|
|
18
18
|
"react-i18next": "^13.2.0",
|
|
19
19
|
"yup": "0.32.11",
|
|
20
|
-
"@dynamic-labs/ethereum": "1.0.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "1.0.0-alpha.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "1.0.0-alpha.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "1.0.0-alpha.
|
|
24
|
-
"@dynamic-labs/types": "1.0.0-alpha.
|
|
25
|
-
"@dynamic-labs/utils": "1.0.0-alpha.
|
|
26
|
-
"@dynamic-labs/viem-utils": "1.0.0-alpha.
|
|
27
|
-
"@dynamic-labs/wallet-book": "1.0.0-alpha.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "1.0.0-alpha.
|
|
20
|
+
"@dynamic-labs/ethereum": "1.0.0-alpha.12",
|
|
21
|
+
"@dynamic-labs/logger": "1.0.0-alpha.12",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "1.0.0-alpha.12",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "1.0.0-alpha.12",
|
|
24
|
+
"@dynamic-labs/types": "1.0.0-alpha.12",
|
|
25
|
+
"@dynamic-labs/utils": "1.0.0-alpha.12",
|
|
26
|
+
"@dynamic-labs/viem-utils": "1.0.0-alpha.12",
|
|
27
|
+
"@dynamic-labs/wallet-book": "1.0.0-alpha.12",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "1.0.0-alpha.12",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -177,6 +177,8 @@ var themesData = require('./lib/context/ThemeContext/themesData.cjs');
|
|
|
177
177
|
var getNetwork = require('./lib/utils/functions/getNetwork/getNetwork.cjs');
|
|
178
178
|
var index$3 = require('./lib/utils/functions/walletFilters/index.cjs');
|
|
179
179
|
var SendBalanceContext = require('./lib/context/SendBalanceContext/SendBalanceContext.cjs');
|
|
180
|
+
require('./lib/context/FundingContext/FundingContext.cjs');
|
|
181
|
+
var useFunding = require('./lib/context/FundingContext/useFunding/useFunding.cjs');
|
|
180
182
|
|
|
181
183
|
|
|
182
184
|
|
|
@@ -336,3 +338,4 @@ exports.RemoveWallets = index$3.RemoveWallets;
|
|
|
336
338
|
exports.SortWallets = index$3.SortWallets;
|
|
337
339
|
exports.UniswapFilter = index$3.UniswapFilter;
|
|
338
340
|
exports.useSendBalance = SendBalanceContext.useSendBalance;
|
|
341
|
+
exports.useFunding = useFunding.useFunding;
|
package/src/index.d.ts
CHANGED
|
@@ -31,3 +31,4 @@ export type { UpdateUserFieldsArg } from './lib/utils/hooks/';
|
|
|
31
31
|
export { type DynamicJwt, DynamicJwtFromJSON } from '@dynamic-labs/sdk-api';
|
|
32
32
|
export { useSendBalance } from './lib/context/SendBalanceContext';
|
|
33
33
|
export type { LocaleResource } from './lib/locale';
|
|
34
|
+
export { useFunding } from './lib/context/FundingContext';
|
package/src/index.js
CHANGED
|
@@ -173,3 +173,5 @@ export { getDefaultColor, getThemeConfig, themesData } from './lib/context/Theme
|
|
|
173
173
|
export { getNetwork } from './lib/utils/functions/getNetwork/getNetwork.js';
|
|
174
174
|
export { FilterAndSortWallets, FilterBridgeChainsName, FilterWallets, RemoveWallets, SortWallets, UniswapFilter } from './lib/utils/functions/walletFilters/index.js';
|
|
175
175
|
export { useSendBalance } from './lib/context/SendBalanceContext/SendBalanceContext.js';
|
|
176
|
+
import './lib/context/FundingContext/FundingContext.js';
|
|
177
|
+
export { useFunding } from './lib/context/FundingContext/useFunding/useFunding.js';
|
|
@@ -16,7 +16,7 @@ const SecureTurnkeyWalletCard = ({ className }) => {
|
|
|
16
16
|
const { initPasskeyRecoveryProcess } = usePasskeyRecovery.usePasskeyRecovery();
|
|
17
17
|
if (!isTurnkeyWalletWithoutAuthenticator)
|
|
18
18
|
return null;
|
|
19
|
-
return (jsxRuntime.jsxs("div", { className: classNames.classNames('secure-turnkey-wallet-card', className), children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', className: 'secure-turnkey-wallet-card__text', children: t('dyn_secure_pregenerated_wallet.description') }), jsxRuntime.jsx(Button.Button, { onClick: initPasskeyRecoveryProcess, buttonVariant: 'brand-primary', color: 'primary', typographyProps: {
|
|
19
|
+
return (jsxRuntime.jsxs("div", { className: classNames.classNames('secure-turnkey-wallet-card', className), children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', weight: 'regular', className: 'secure-turnkey-wallet-card__text', color: 'primary', children: t('dyn_secure_pregenerated_wallet.description') }), jsxRuntime.jsx(Button.Button, { onClick: initPasskeyRecoveryProcess, buttonVariant: 'brand-primary', color: 'primary', typographyProps: {
|
|
20
20
|
color: 'inherit',
|
|
21
21
|
}, showInternalLoading: false, children: t('dyn_secure_pregenerated_wallet.secure_button') })] }));
|
|
22
22
|
};
|
|
@@ -12,7 +12,7 @@ const SecureTurnkeyWalletCard = ({ className }) => {
|
|
|
12
12
|
const { initPasskeyRecoveryProcess } = usePasskeyRecovery();
|
|
13
13
|
if (!isTurnkeyWalletWithoutAuthenticator)
|
|
14
14
|
return null;
|
|
15
|
-
return (jsxs("div", { className: classNames('secure-turnkey-wallet-card', className), children: [jsx(Typography, { variant: 'body_small', weight: 'regular', className: 'secure-turnkey-wallet-card__text', children: t('dyn_secure_pregenerated_wallet.description') }), jsx(Button, { onClick: initPasskeyRecoveryProcess, buttonVariant: 'brand-primary', color: 'primary', typographyProps: {
|
|
15
|
+
return (jsxs("div", { className: classNames('secure-turnkey-wallet-card', className), children: [jsx(Typography, { variant: 'body_small', weight: 'regular', className: 'secure-turnkey-wallet-card__text', color: 'primary', children: t('dyn_secure_pregenerated_wallet.description') }), jsx(Button, { onClick: initPasskeyRecoveryProcess, buttonVariant: 'brand-primary', color: 'primary', typographyProps: {
|
|
16
16
|
color: 'inherit',
|
|
17
17
|
}, showInternalLoading: false, children: t('dyn_secure_pregenerated_wallet.secure_button') })] }));
|
|
18
18
|
};
|
|
@@ -30,6 +30,32 @@ const FundingContextProvider = ({ children, }) => {
|
|
|
30
30
|
const [fundingUrl, setFundingUrl] = React.useState('');
|
|
31
31
|
const { environmentId, network, primaryWallet, projectSettings } = useInternalDynamicContext.useInternalDynamicContext();
|
|
32
32
|
const fundingEnabled = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.some((p) => isOnrampProvider.isOnrampProvider(p) && Boolean(p.enabledAt))) !== null && _b !== void 0 ? _b : false;
|
|
33
|
+
const updateSupportsFunding = React.useCallback(({ address, token } = {}) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
var _c;
|
|
35
|
+
if (!fundingEnabled)
|
|
36
|
+
return;
|
|
37
|
+
if (!primaryWallet)
|
|
38
|
+
return;
|
|
39
|
+
const chainName = (_c = walletConnectorCore.getChainInfo(primaryWallet.chain)) === null || _c === void 0 ? void 0 : _c.name;
|
|
40
|
+
if (!chainName)
|
|
41
|
+
return;
|
|
42
|
+
try {
|
|
43
|
+
const [{ url }] = yield api.getOnrampProviders({
|
|
44
|
+
chain: chainName,
|
|
45
|
+
environmentId,
|
|
46
|
+
networkId: network ? network.toString() : undefined,
|
|
47
|
+
token,
|
|
48
|
+
walletAddress: address ? address : primaryWallet.address,
|
|
49
|
+
});
|
|
50
|
+
if (!url)
|
|
51
|
+
throw new Error('No onramp url found');
|
|
52
|
+
setFundingUrl(url);
|
|
53
|
+
setSupportsFunding(true);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
setSupportsFunding(false);
|
|
57
|
+
}
|
|
58
|
+
}), [environmentId, fundingEnabled, network, primaryWallet]);
|
|
33
59
|
const value = React.useMemo(() => ({
|
|
34
60
|
fundingEnabled,
|
|
35
61
|
fundingRef,
|
|
@@ -37,35 +63,17 @@ const FundingContextProvider = ({ children, }) => {
|
|
|
37
63
|
setShowFunding,
|
|
38
64
|
showFunding,
|
|
39
65
|
supportsFunding,
|
|
40
|
-
|
|
66
|
+
updateSupportsFunding,
|
|
67
|
+
}), [
|
|
68
|
+
fundingEnabled,
|
|
69
|
+
fundingUrl,
|
|
70
|
+
showFunding,
|
|
71
|
+
supportsFunding,
|
|
72
|
+
updateSupportsFunding,
|
|
73
|
+
]);
|
|
41
74
|
React.useEffect(() => {
|
|
42
|
-
const updateSupportsFunding = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
43
|
-
var _a;
|
|
44
|
-
if (!fundingEnabled)
|
|
45
|
-
return;
|
|
46
|
-
if (!primaryWallet)
|
|
47
|
-
return;
|
|
48
|
-
const chainName = (_a = walletConnectorCore.getChainInfo(primaryWallet.chain)) === null || _a === void 0 ? void 0 : _a.name;
|
|
49
|
-
if (!chainName)
|
|
50
|
-
return;
|
|
51
|
-
try {
|
|
52
|
-
const [{ url }] = yield api.getOnrampProviders({
|
|
53
|
-
chain: chainName,
|
|
54
|
-
environmentId,
|
|
55
|
-
networkId: network ? network.toString() : undefined,
|
|
56
|
-
walletAddress: primaryWallet.address,
|
|
57
|
-
});
|
|
58
|
-
if (!url)
|
|
59
|
-
throw new Error('No onramp url found');
|
|
60
|
-
setFundingUrl(url);
|
|
61
|
-
setSupportsFunding(true);
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
setSupportsFunding(false);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
75
|
updateSupportsFunding();
|
|
68
|
-
}, [
|
|
76
|
+
}, [environmentId, fundingEnabled, network, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address]);
|
|
69
77
|
return (jsxRuntime.jsx(FundingContext.Provider, { value: value, children: children }));
|
|
70
78
|
};
|
|
71
79
|
const useFundingContext = () => {
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { ReactNode, SetStateAction, Dispatch } from 'react';
|
|
2
2
|
export type FundingContextProps = {
|
|
3
|
+
updateSupportsFunding: (props?: {
|
|
4
|
+
address?: string;
|
|
5
|
+
token?: string;
|
|
6
|
+
}) => Promise<void>;
|
|
3
7
|
fundingEnabled: boolean;
|
|
4
8
|
fundingRef: React.RefObject<HTMLDivElement>;
|
|
5
9
|
fundingUrl: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../_virtual/_tslib.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { createContext, useContext, useRef, useState, useMemo, useEffect } from 'react';
|
|
3
|
+
import { createContext, useContext, useRef, useState, useCallback, useMemo, useEffect } from 'react';
|
|
4
4
|
import { getChainInfo } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { getOnrampProviders } from '../../data/api.js';
|
|
6
6
|
import { useInternalDynamicContext } from '../DynamicContext/useInternalDynamicContext.js';
|
|
@@ -26,6 +26,32 @@ const FundingContextProvider = ({ children, }) => {
|
|
|
26
26
|
const [fundingUrl, setFundingUrl] = useState('');
|
|
27
27
|
const { environmentId, network, primaryWallet, projectSettings } = useInternalDynamicContext();
|
|
28
28
|
const fundingEnabled = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) === null || _a === void 0 ? void 0 : _a.some((p) => isOnrampProvider(p) && Boolean(p.enabledAt))) !== null && _b !== void 0 ? _b : false;
|
|
29
|
+
const updateSupportsFunding = useCallback(({ address, token } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
var _c;
|
|
31
|
+
if (!fundingEnabled)
|
|
32
|
+
return;
|
|
33
|
+
if (!primaryWallet)
|
|
34
|
+
return;
|
|
35
|
+
const chainName = (_c = getChainInfo(primaryWallet.chain)) === null || _c === void 0 ? void 0 : _c.name;
|
|
36
|
+
if (!chainName)
|
|
37
|
+
return;
|
|
38
|
+
try {
|
|
39
|
+
const [{ url }] = yield getOnrampProviders({
|
|
40
|
+
chain: chainName,
|
|
41
|
+
environmentId,
|
|
42
|
+
networkId: network ? network.toString() : undefined,
|
|
43
|
+
token,
|
|
44
|
+
walletAddress: address ? address : primaryWallet.address,
|
|
45
|
+
});
|
|
46
|
+
if (!url)
|
|
47
|
+
throw new Error('No onramp url found');
|
|
48
|
+
setFundingUrl(url);
|
|
49
|
+
setSupportsFunding(true);
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
setSupportsFunding(false);
|
|
53
|
+
}
|
|
54
|
+
}), [environmentId, fundingEnabled, network, primaryWallet]);
|
|
29
55
|
const value = useMemo(() => ({
|
|
30
56
|
fundingEnabled,
|
|
31
57
|
fundingRef,
|
|
@@ -33,35 +59,17 @@ const FundingContextProvider = ({ children, }) => {
|
|
|
33
59
|
setShowFunding,
|
|
34
60
|
showFunding,
|
|
35
61
|
supportsFunding,
|
|
36
|
-
|
|
62
|
+
updateSupportsFunding,
|
|
63
|
+
}), [
|
|
64
|
+
fundingEnabled,
|
|
65
|
+
fundingUrl,
|
|
66
|
+
showFunding,
|
|
67
|
+
supportsFunding,
|
|
68
|
+
updateSupportsFunding,
|
|
69
|
+
]);
|
|
37
70
|
useEffect(() => {
|
|
38
|
-
const updateSupportsFunding = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
var _a;
|
|
40
|
-
if (!fundingEnabled)
|
|
41
|
-
return;
|
|
42
|
-
if (!primaryWallet)
|
|
43
|
-
return;
|
|
44
|
-
const chainName = (_a = getChainInfo(primaryWallet.chain)) === null || _a === void 0 ? void 0 : _a.name;
|
|
45
|
-
if (!chainName)
|
|
46
|
-
return;
|
|
47
|
-
try {
|
|
48
|
-
const [{ url }] = yield getOnrampProviders({
|
|
49
|
-
chain: chainName,
|
|
50
|
-
environmentId,
|
|
51
|
-
networkId: network ? network.toString() : undefined,
|
|
52
|
-
walletAddress: primaryWallet.address,
|
|
53
|
-
});
|
|
54
|
-
if (!url)
|
|
55
|
-
throw new Error('No onramp url found');
|
|
56
|
-
setFundingUrl(url);
|
|
57
|
-
setSupportsFunding(true);
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
setSupportsFunding(false);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
71
|
updateSupportsFunding();
|
|
64
|
-
}, [
|
|
72
|
+
}, [environmentId, fundingEnabled, network, primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address]);
|
|
65
73
|
return (jsx(FundingContext.Provider, { value: value, children: children }));
|
|
66
74
|
};
|
|
67
75
|
const useFundingContext = () => {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useFunding } from './useFunding';
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var FundingContext = require('../FundingContext.cjs');
|
|
9
|
+
|
|
10
|
+
const useFunding = () => {
|
|
11
|
+
const promiseRef = React.useRef(null);
|
|
12
|
+
const { fundingEnabled, setShowFunding, showFunding, updateSupportsFunding } = FundingContext.useFundingContext();
|
|
13
|
+
const openFunding = ({ address, token } = {}) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
if (!fundingEnabled) {
|
|
15
|
+
throw new Error('Funding is not enabled');
|
|
16
|
+
}
|
|
17
|
+
if (promiseRef.current) {
|
|
18
|
+
return promiseRef.current.promise;
|
|
19
|
+
}
|
|
20
|
+
if (address || token) {
|
|
21
|
+
yield updateSupportsFunding({ address, token });
|
|
22
|
+
}
|
|
23
|
+
promiseRef.current = new utils.DeferredPromise();
|
|
24
|
+
setShowFunding(true);
|
|
25
|
+
return promiseRef.current.promise;
|
|
26
|
+
});
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
if (!showFunding && promiseRef.current) {
|
|
29
|
+
promiseRef.current.resolve();
|
|
30
|
+
promiseRef.current = null;
|
|
31
|
+
}
|
|
32
|
+
}, [showFunding]);
|
|
33
|
+
return {
|
|
34
|
+
enabled: fundingEnabled,
|
|
35
|
+
openFunding,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
exports.useFunding = useFunding;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
+
import { useRef, useEffect } from 'react';
|
|
3
|
+
import { DeferredPromise } from '@dynamic-labs/utils';
|
|
4
|
+
import { useFundingContext } from '../FundingContext.js';
|
|
5
|
+
|
|
6
|
+
const useFunding = () => {
|
|
7
|
+
const promiseRef = useRef(null);
|
|
8
|
+
const { fundingEnabled, setShowFunding, showFunding, updateSupportsFunding } = useFundingContext();
|
|
9
|
+
const openFunding = ({ address, token } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
10
|
+
if (!fundingEnabled) {
|
|
11
|
+
throw new Error('Funding is not enabled');
|
|
12
|
+
}
|
|
13
|
+
if (promiseRef.current) {
|
|
14
|
+
return promiseRef.current.promise;
|
|
15
|
+
}
|
|
16
|
+
if (address || token) {
|
|
17
|
+
yield updateSupportsFunding({ address, token });
|
|
18
|
+
}
|
|
19
|
+
promiseRef.current = new DeferredPromise();
|
|
20
|
+
setShowFunding(true);
|
|
21
|
+
return promiseRef.current.promise;
|
|
22
|
+
});
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!showFunding && promiseRef.current) {
|
|
25
|
+
promiseRef.current.resolve();
|
|
26
|
+
promiseRef.current = null;
|
|
27
|
+
}
|
|
28
|
+
}, [showFunding]);
|
|
29
|
+
return {
|
|
30
|
+
enabled: fundingEnabled,
|
|
31
|
+
openFunding,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export { useFunding };
|