@dynamic-labs/sdk-react-core 4.80.0 → 4.82.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/CHANGELOG.md +38 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +63 -3
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +63 -3
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.cjs +40 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.d.ts +16 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/TransactionModeSegmentedControl.js +36 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.cjs +17 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.d.ts +8 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/icons.js +12 -0
- package/src/lib/components/SendBalanceForm/TransactionModeSegmentedControl/index.d.ts +1 -0
- package/src/lib/data/api/aleo/getAleoCuratedPrices.cjs +73 -0
- package/src/lib/data/api/aleo/getAleoCuratedPrices.d.ts +38 -0
- package/src/lib/data/api/aleo/getAleoCuratedPrices.js +69 -0
- package/src/lib/shared/assets/index.d.ts +2 -0
- package/src/lib/shared/assets/midnight-shielded.cjs +54 -0
- package/src/lib/shared/assets/midnight-shielded.js +30 -0
- package/src/lib/shared/assets/midnight-unshielded.cjs +54 -0
- package/src/lib/shared/assets/midnight-unshielded.js +30 -0
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/functions/compareChains/compareChains.cjs +1 -0
- package/src/lib/utils/functions/compareChains/compareChains.js +1 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.cjs +12 -0
- package/src/lib/utils/functions/getTransactionLink/blockExplorerPatterns.js +12 -0
- package/src/lib/utils/hooks/useAleoAutoMergeRecords/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAleoAutoMergeRecords/useAleoAutoMergeRecords.cjs +246 -0
- package/src/lib/utils/hooks/useAleoAutoMergeRecords/useAleoAutoMergeRecords.d.ts +17 -0
- package/src/lib/utils/hooks/useAleoAutoMergeRecords/useAleoAutoMergeRecords.js +242 -0
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.cjs +263 -0
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.d.ts +59 -0
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.js +259 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/index.d.ts +1 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.cjs +443 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.d.ts +24 -0
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.js +439 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.d.ts +1 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js +1 -0
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.cjs +12 -1
- package/src/lib/views/BackupUnsuccessfulView/BackupUnsuccessfulView.js +12 -1
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +53 -0
- package/src/lib/views/SendBalanceView/SendBalanceView.js +53 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.cjs +193 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.d.ts +7 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/ActiveMidnightWalletBalance.js +189 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveMidnightWalletBalance/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +216 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +216 -11
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.cjs +5 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.d.ts +10 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/TokenBalanceItem.js +5 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceItem/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.cjs +2 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.d.ts +3 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/TokenBalanceList/TokenBalanceList.js +2 -2
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveMidnightWalletAddresses/ActiveMidnightWalletAddresses.cjs +124 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveMidnightWalletAddresses/ActiveMidnightWalletAddresses.d.ts +9 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveMidnightWalletAddresses/ActiveMidnightWalletAddresses.js +120 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveMidnightWalletAddresses/index.d.ts +1 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.cjs +21 -10
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletInformation/ActiveWalletInformation.js +22 -11
- package/src/lib/widgets/DynamicWidget/components/WalletDetailsCard/WalletDetailsCard.cjs +22 -2
- package/src/lib/widgets/DynamicWidget/components/WalletDetailsCard/WalletDetailsCard.d.ts +8 -1
- package/src/lib/widgets/DynamicWidget/components/WalletDetailsCard/WalletDetailsCard.js +23 -3
|
@@ -20,6 +20,18 @@ const BLOCK_EXPLORER_PATTERNS = [
|
|
|
20
20
|
return `${url.origin}/#/transaction/${hash}`;
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
+
{
|
|
24
|
+
// Provable hosts both mainnet (`explorer.provable.com`) and testnet
|
|
25
|
+
// (`testnet.explorer.provable.com`). Matching the bare
|
|
26
|
+
// `explorer.provable.com` substring covers both subdomains.
|
|
27
|
+
description: 'Aleo (Provable) - Uses /transaction/{hash}',
|
|
28
|
+
domain: 'explorer.provable.com',
|
|
29
|
+
generateUrl: (baseUrl, hash) => {
|
|
30
|
+
const url = new URL(baseUrl);
|
|
31
|
+
url.pathname = `/transaction/${hash}`;
|
|
32
|
+
return url.toString();
|
|
33
|
+
},
|
|
34
|
+
},
|
|
23
35
|
];
|
|
24
36
|
/**
|
|
25
37
|
* Default pattern for standard block explorers
|
|
@@ -16,6 +16,18 @@ const BLOCK_EXPLORER_PATTERNS = [
|
|
|
16
16
|
return `${url.origin}/#/transaction/${hash}`;
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
// Provable hosts both mainnet (`explorer.provable.com`) and testnet
|
|
21
|
+
// (`testnet.explorer.provable.com`). Matching the bare
|
|
22
|
+
// `explorer.provable.com` substring covers both subdomains.
|
|
23
|
+
description: 'Aleo (Provable) - Uses /transaction/{hash}',
|
|
24
|
+
domain: 'explorer.provable.com',
|
|
25
|
+
generateUrl: (baseUrl, hash) => {
|
|
26
|
+
const url = new URL(baseUrl);
|
|
27
|
+
url.pathname = `/transaction/${hash}`;
|
|
28
|
+
return url.toString();
|
|
29
|
+
},
|
|
30
|
+
},
|
|
19
31
|
];
|
|
20
32
|
/**
|
|
21
33
|
* Default pattern for standard block explorers
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAleoAutoMergeRecords } from './useAleoAutoMergeRecords';
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
10
|
+
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
11
|
+
require('@dynamic-labs/iconic');
|
|
12
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
13
|
+
require('react/jsx-runtime');
|
|
14
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
require('../../../shared/logger.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../constants/colors.cjs');
|
|
19
|
+
require('../../constants/values.cjs');
|
|
20
|
+
require('../../../shared/consts/index.cjs');
|
|
21
|
+
require('../../../events/dynamicEvents.cjs');
|
|
22
|
+
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
23
|
+
require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
24
|
+
require('@dynamic-labs/multi-wallet');
|
|
25
|
+
require('react-international-phone');
|
|
26
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
27
|
+
require('@dynamic-labs-sdk/client/core');
|
|
28
|
+
require('eventemitter3');
|
|
29
|
+
require('@dynamic-labs-sdk/client');
|
|
30
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
31
|
+
require('@dynamic-labs/locale');
|
|
32
|
+
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
33
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
34
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
35
|
+
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
36
|
+
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
37
|
+
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
38
|
+
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
39
|
+
require('../../../store/state/authMode/authMode.cjs');
|
|
40
|
+
require('../../../context/VerificationContext/VerificationContext.cjs');
|
|
41
|
+
require('react-dom');
|
|
42
|
+
require('../../functions/compareChains/compareChains.cjs');
|
|
43
|
+
require('../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.cjs');
|
|
44
|
+
require('../../../context/ThemeContext/ThemeContext.cjs');
|
|
45
|
+
require('../useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
|
|
46
|
+
require('bs58');
|
|
47
|
+
require('@dynamic-labs/types');
|
|
48
|
+
require('../../../context/SocialRedirectContext/SocialRedirectContext.cjs');
|
|
49
|
+
require('../../../context/LoadingContext/LoadingContext.cjs');
|
|
50
|
+
require('../../../context/WalletContext/WalletContext.cjs');
|
|
51
|
+
require('../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
|
|
52
|
+
require('yup');
|
|
53
|
+
require('../../../context/MockContext/MockContext.cjs');
|
|
54
|
+
require('../../../views/CollectUserDataView/useFields.cjs');
|
|
55
|
+
require('../../../context/FieldsStateContext/FieldsStateContext.cjs');
|
|
56
|
+
require('../../../context/UserFieldEditorContext/UserFieldEditorContext.cjs');
|
|
57
|
+
require('@dynamic-labs/rpc-providers');
|
|
58
|
+
require('../../../store/state/walletOptions/walletOptions.cjs');
|
|
59
|
+
require('react-i18next');
|
|
60
|
+
require('../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
|
|
61
|
+
require('../../../components/Alert/Alert.cjs');
|
|
62
|
+
require('../../../components/ShadowDOM/ShadowDOM.cjs');
|
|
63
|
+
require('../../../components/IconButton/IconButton.cjs');
|
|
64
|
+
require('../../../components/InlineWidget/InlineWidget.cjs');
|
|
65
|
+
require('../../../components/Input/Input.cjs');
|
|
66
|
+
require('../../../components/IsBrowser/IsBrowser.cjs');
|
|
67
|
+
require('../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
68
|
+
require('../../../components/OverlayCard/OverlayCard.cjs');
|
|
69
|
+
require('../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
70
|
+
require('../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
71
|
+
require('../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
72
|
+
require('../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
|
|
73
|
+
require('../../../components/Popper/Popper/Popper.cjs');
|
|
74
|
+
require('../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
75
|
+
require('react-focus-lock');
|
|
76
|
+
require('qrcode');
|
|
77
|
+
require('formik');
|
|
78
|
+
require('../useSubdomainCheck/useSubdomainCheck.cjs');
|
|
79
|
+
require('../../../context/WalletGroupContext/WalletGroupContext.cjs');
|
|
80
|
+
require('../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
|
|
81
|
+
require('../useGetMfaToken/useGetMfaToken.cjs');
|
|
82
|
+
require('../useWalletBackup/useWalletBackup.cjs');
|
|
83
|
+
require('../useWalletBackup/types.cjs');
|
|
84
|
+
require('../useWalletBackup/cloudProviders.cjs');
|
|
85
|
+
require('../../../context/IpConfigurationContext/IpConfigurationContext.cjs');
|
|
86
|
+
require('../../../context/ConnectWithOtpContext/ConnectWithOtpContext.cjs');
|
|
87
|
+
require('../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
|
|
88
|
+
require('@hcaptcha/react-hcaptcha');
|
|
89
|
+
require('../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.cjs');
|
|
90
|
+
require('../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.cjs');
|
|
91
|
+
require('../../../context/ErrorContext/hooks/useErrorText/useErrorText.cjs');
|
|
92
|
+
require('../../../context/FooterAnimationContext/index.cjs');
|
|
93
|
+
require('../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.cjs');
|
|
94
|
+
require('../../../context/PasskeyContext/PasskeyContext.cjs');
|
|
95
|
+
require('../../../context/OnrampContext/OnrampContext.cjs');
|
|
96
|
+
require('../../../store/state/sendBalances.cjs');
|
|
97
|
+
require('../../../store/state/connectorsInitializing/connectorsInitializing.cjs');
|
|
98
|
+
require('../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.cjs');
|
|
99
|
+
require('../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
|
|
100
|
+
require('../../../views/TransactionConfirmationView/TransactionConfirmationView.cjs');
|
|
101
|
+
require('../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.cjs');
|
|
102
|
+
require('../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.cjs');
|
|
103
|
+
require('../../../../index.cjs');
|
|
104
|
+
require('../../../widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.cjs');
|
|
105
|
+
require('../../../widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.cjs');
|
|
106
|
+
require('../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.cjs');
|
|
107
|
+
require('../../../store/state/tokenBalances.cjs');
|
|
108
|
+
require('../../../store/state/multichainBalances.cjs');
|
|
109
|
+
require('@dynamic-labs/store');
|
|
110
|
+
require('../../../shared/utils/functions/getInitialUrl/getInitialUrl.cjs');
|
|
111
|
+
var useInternalDynamicContext = require('../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Programs whose `join` transition the Aleo Feemaster has historically
|
|
115
|
+
* sponsored — `credits.aleo` and the two stablecoins. ARC-21 lives on
|
|
116
|
+
* `token_registry.aleo` which is per-`token_id` and out of scope for v1.
|
|
117
|
+
*
|
|
118
|
+
* The list is intentionally explicit (not pulled from the connector's
|
|
119
|
+
* private allowlist) so adding a program here is a deliberate decision
|
|
120
|
+
* coupled to Feemaster coverage rather than an automatic side-effect of a
|
|
121
|
+
* shape-registry change.
|
|
122
|
+
*/
|
|
123
|
+
const AUTO_MERGE_PROGRAMS = [
|
|
124
|
+
'credits.aleo',
|
|
125
|
+
'usad_stablecoin.aleo',
|
|
126
|
+
'usdcx_stablecoin.aleo',
|
|
127
|
+
'test_usad_stablecoin.aleo',
|
|
128
|
+
'test_usdcx_stablecoin.aleo',
|
|
129
|
+
];
|
|
130
|
+
/**
|
|
131
|
+
* On Aleo wallet load, scan the user's owned records and silently fire a
|
|
132
|
+
* merge ceremony for every program with ≥2 records that the Feemaster
|
|
133
|
+
* currently sponsors. Programs the Feemaster doesn't cover are skipped —
|
|
134
|
+
* the user can still trigger a manual merge via the explicit "Merge all
|
|
135
|
+
* records" CTA, which dispatches with user-paid fees.
|
|
136
|
+
*
|
|
137
|
+
* Idempotency is per-session, keyed by `(accountAddress, programId)`. A
|
|
138
|
+
* page reload re-runs auto-merge once; mid-session balance refreshes do
|
|
139
|
+
* not re-trigger merges for the same program. On error the program key
|
|
140
|
+
* is removed from the seen-set so the next refresh can retry.
|
|
141
|
+
*
|
|
142
|
+
* Failures are swallowed by design — auto-merge is a background
|
|
143
|
+
* optimisation, not a user-facing flow. Errors surface only via the
|
|
144
|
+
* connector's own logger.
|
|
145
|
+
*/
|
|
146
|
+
const useAleoAutoMergeRecords = () => {
|
|
147
|
+
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
148
|
+
// Tracks `(accountAddress:programId)` pairs we've already attempted in
|
|
149
|
+
// this React session. Cleared implicitly on a full page reload (the ref
|
|
150
|
+
// lives in module-private React state). We do NOT persist to
|
|
151
|
+
// localStorage on purpose — the Feemaster check on every attempt is
|
|
152
|
+
// cheap server-side and survives mid-session policy changes.
|
|
153
|
+
const seenKeysRef = React.useRef(new Set());
|
|
154
|
+
React.useEffect(() => {
|
|
155
|
+
var _a;
|
|
156
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
157
|
+
if (!connector)
|
|
158
|
+
return;
|
|
159
|
+
const isAleo = ((_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.connectedChain) === sdkApiCore.ChainEnum.Aleo;
|
|
160
|
+
if (!isAleo)
|
|
161
|
+
return;
|
|
162
|
+
if (typeof connector.listOwnedRecords !== 'function' ||
|
|
163
|
+
typeof connector.isFeemasterSponsored !== 'function' ||
|
|
164
|
+
typeof connector.joinRecords !== 'function') {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
let cancelled = false;
|
|
168
|
+
const accountAddress = primaryWallet
|
|
169
|
+
.address;
|
|
170
|
+
if (!accountAddress)
|
|
171
|
+
return;
|
|
172
|
+
const run = () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
173
|
+
var _b, _c, _d, _e, _f, _g;
|
|
174
|
+
const result = yield ((_b = connector.listOwnedRecords) === null || _b === void 0 ? void 0 : _b.call(connector));
|
|
175
|
+
if (cancelled)
|
|
176
|
+
return;
|
|
177
|
+
const records = ((_c = result === null || result === void 0 ? void 0 : result.records) !== null && _c !== void 0 ? _c : []).filter((r) => Boolean(r === null || r === void 0 ? void 0 : r.program_name) && typeof (r === null || r === void 0 ? void 0 : r.record_plaintext) === 'string');
|
|
178
|
+
// Group record counts per program.
|
|
179
|
+
const countsByProgram = new Map();
|
|
180
|
+
for (const record of records) {
|
|
181
|
+
const programId = record.program_name;
|
|
182
|
+
countsByProgram.set(programId, ((_d = countsByProgram.get(programId)) !== null && _d !== void 0 ? _d : 0) + 1);
|
|
183
|
+
}
|
|
184
|
+
const candidates = AUTO_MERGE_PROGRAMS.filter((programId) => {
|
|
185
|
+
var _a;
|
|
186
|
+
const count = (_a = countsByProgram.get(programId)) !== null && _a !== void 0 ? _a : 0;
|
|
187
|
+
if (count < 2)
|
|
188
|
+
return false;
|
|
189
|
+
const key = `${accountAddress}:${programId}`;
|
|
190
|
+
return !seenKeysRef.current.has(key);
|
|
191
|
+
});
|
|
192
|
+
for (const programId of candidates) {
|
|
193
|
+
if (cancelled)
|
|
194
|
+
return;
|
|
195
|
+
const key = `${accountAddress}:${programId}`;
|
|
196
|
+
seenKeysRef.current.add(key);
|
|
197
|
+
let sponsored = false;
|
|
198
|
+
try {
|
|
199
|
+
sponsored =
|
|
200
|
+
(_f = (yield ((_e = connector.isFeemasterSponsored) === null || _e === void 0 ? void 0 : _e.call(connector, {
|
|
201
|
+
functionName: 'join',
|
|
202
|
+
programId,
|
|
203
|
+
})))) !== null && _f !== void 0 ? _f : false;
|
|
204
|
+
}
|
|
205
|
+
catch (_h) {
|
|
206
|
+
sponsored = false;
|
|
207
|
+
}
|
|
208
|
+
if (cancelled)
|
|
209
|
+
return;
|
|
210
|
+
if (!sponsored) {
|
|
211
|
+
// Allow a future attempt if Feemaster coverage flips on later in
|
|
212
|
+
// the session (e.g. after a policy refresh).
|
|
213
|
+
seenKeysRef.current.delete(key);
|
|
214
|
+
continue;
|
|
215
|
+
}
|
|
216
|
+
try {
|
|
217
|
+
yield ((_g = connector.joinRecords) === null || _g === void 0 ? void 0 : _g.call(connector, { programIds: [programId] }));
|
|
218
|
+
}
|
|
219
|
+
catch (_j) {
|
|
220
|
+
// Background optimisation — swallow and let the next session
|
|
221
|
+
// retry. Removing the key allows a retry on the next records
|
|
222
|
+
// refresh.
|
|
223
|
+
seenKeysRef.current.delete(key);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
run().catch(() => {
|
|
228
|
+
/* swallow — see method jsdoc */
|
|
229
|
+
});
|
|
230
|
+
return () => {
|
|
231
|
+
cancelled = true;
|
|
232
|
+
};
|
|
233
|
+
// Depend on the stable address + connector reference rather than the
|
|
234
|
+
// whole `primaryWallet` object. The wallet object can be re-created
|
|
235
|
+
// on every context update (balance refreshes, metadata churn, etc.),
|
|
236
|
+
// which would re-fire this effect even when no merge-relevant state
|
|
237
|
+
// has changed and re-spam `listOwnedRecords` / `isFeemasterSponsored`.
|
|
238
|
+
// Address + connector are the only fields the effect actually reads.
|
|
239
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
240
|
+
}, [
|
|
241
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address,
|
|
242
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
|
|
243
|
+
]);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
exports.useAleoAutoMergeRecords = useAleoAutoMergeRecords;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* On Aleo wallet load, scan the user's owned records and silently fire a
|
|
3
|
+
* merge ceremony for every program with ≥2 records that the Feemaster
|
|
4
|
+
* currently sponsors. Programs the Feemaster doesn't cover are skipped —
|
|
5
|
+
* the user can still trigger a manual merge via the explicit "Merge all
|
|
6
|
+
* records" CTA, which dispatches with user-paid fees.
|
|
7
|
+
*
|
|
8
|
+
* Idempotency is per-session, keyed by `(accountAddress, programId)`. A
|
|
9
|
+
* page reload re-runs auto-merge once; mid-session balance refreshes do
|
|
10
|
+
* not re-trigger merges for the same program. On error the program key
|
|
11
|
+
* is removed from the seen-set so the next refresh can retry.
|
|
12
|
+
*
|
|
13
|
+
* Failures are swallowed by design — auto-merge is a background
|
|
14
|
+
* optimisation, not a user-facing flow. Errors surface only via the
|
|
15
|
+
* connector's own logger.
|
|
16
|
+
*/
|
|
17
|
+
export declare const useAleoAutoMergeRecords: () => void;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useRef, useEffect } from 'react';
|
|
4
|
+
import { ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import '../../../context/DynamicContext/DynamicContext.js';
|
|
6
|
+
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
7
|
+
import '@dynamic-labs/iconic';
|
|
8
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import '../../../shared/logger.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../constants/colors.js';
|
|
15
|
+
import '../../constants/values.js';
|
|
16
|
+
import '../../../shared/consts/index.js';
|
|
17
|
+
import '../../../events/dynamicEvents.js';
|
|
18
|
+
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
19
|
+
import '../../../context/ErrorContext/ErrorContext.js';
|
|
20
|
+
import '@dynamic-labs/multi-wallet';
|
|
21
|
+
import 'react-international-phone';
|
|
22
|
+
import '../../../store/state/nonce/nonce.js';
|
|
23
|
+
import '@dynamic-labs-sdk/client/core';
|
|
24
|
+
import 'eventemitter3';
|
|
25
|
+
import '@dynamic-labs-sdk/client';
|
|
26
|
+
import '../../../config/ApiEndpoint.js';
|
|
27
|
+
import '@dynamic-labs/locale';
|
|
28
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
29
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
30
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
31
|
+
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
32
|
+
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
33
|
+
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
34
|
+
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
35
|
+
import '../../../store/state/authMode/authMode.js';
|
|
36
|
+
import '../../../context/VerificationContext/VerificationContext.js';
|
|
37
|
+
import 'react-dom';
|
|
38
|
+
import '../../functions/compareChains/compareChains.js';
|
|
39
|
+
import '../../../views/Passkey/utils/findPrimaryEmbeddedChain/findPrimaryEmbeddedChain.js';
|
|
40
|
+
import '../../../context/ThemeContext/ThemeContext.js';
|
|
41
|
+
import '../useUserUpdateRequest/useUpdateUser/userFieldsSchema.js';
|
|
42
|
+
import 'bs58';
|
|
43
|
+
import '@dynamic-labs/types';
|
|
44
|
+
import '../../../context/SocialRedirectContext/SocialRedirectContext.js';
|
|
45
|
+
import '../../../context/LoadingContext/LoadingContext.js';
|
|
46
|
+
import '../../../context/WalletContext/WalletContext.js';
|
|
47
|
+
import '../useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
|
|
48
|
+
import 'yup';
|
|
49
|
+
import '../../../context/MockContext/MockContext.js';
|
|
50
|
+
import '../../../views/CollectUserDataView/useFields.js';
|
|
51
|
+
import '../../../context/FieldsStateContext/FieldsStateContext.js';
|
|
52
|
+
import '../../../context/UserFieldEditorContext/UserFieldEditorContext.js';
|
|
53
|
+
import '@dynamic-labs/rpc-providers';
|
|
54
|
+
import '../../../store/state/walletOptions/walletOptions.js';
|
|
55
|
+
import 'react-i18next';
|
|
56
|
+
import '../../../components/Accordion/components/AccordionItem/AccordionItem.js';
|
|
57
|
+
import '../../../components/Alert/Alert.js';
|
|
58
|
+
import '../../../components/ShadowDOM/ShadowDOM.js';
|
|
59
|
+
import '../../../components/IconButton/IconButton.js';
|
|
60
|
+
import '../../../components/InlineWidget/InlineWidget.js';
|
|
61
|
+
import '../../../components/Input/Input.js';
|
|
62
|
+
import '../../../components/IsBrowser/IsBrowser.js';
|
|
63
|
+
import '../../../components/MenuList/Dropdown/Dropdown.js';
|
|
64
|
+
import '../../../components/OverlayCard/OverlayCard.js';
|
|
65
|
+
import '../../../components/Transition/ZoomTransition/ZoomTransition.js';
|
|
66
|
+
import '../../../components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
67
|
+
import '../../../components/Transition/OpacityTransition/OpacityTransition.js';
|
|
68
|
+
import '../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.js';
|
|
69
|
+
import '../../../components/Popper/Popper/Popper.js';
|
|
70
|
+
import '../../../components/Popper/PopperContext/PopperContext.js';
|
|
71
|
+
import 'react-focus-lock';
|
|
72
|
+
import 'qrcode';
|
|
73
|
+
import 'formik';
|
|
74
|
+
import '../useSubdomainCheck/useSubdomainCheck.js';
|
|
75
|
+
import '../../../context/WalletGroupContext/WalletGroupContext.js';
|
|
76
|
+
import '../../../widgets/DynamicWidget/context/DynamicWidgetContext.js';
|
|
77
|
+
import '../useGetMfaToken/useGetMfaToken.js';
|
|
78
|
+
import '../useWalletBackup/useWalletBackup.js';
|
|
79
|
+
import '../useWalletBackup/types.js';
|
|
80
|
+
import '../useWalletBackup/cloudProviders.js';
|
|
81
|
+
import '../../../context/IpConfigurationContext/IpConfigurationContext.js';
|
|
82
|
+
import '../../../context/ConnectWithOtpContext/ConnectWithOtpContext.js';
|
|
83
|
+
import '../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.js';
|
|
84
|
+
import '@hcaptcha/react-hcaptcha';
|
|
85
|
+
import '../../../widgets/DynamicWidget/helpers/convertExchangeKeyAndProviderEnum.js';
|
|
86
|
+
import '../../../views/ExchangeWhitelistWarning/ExchangeWhitelistWarning.js';
|
|
87
|
+
import '../../../context/ErrorContext/hooks/useErrorText/useErrorText.js';
|
|
88
|
+
import '../../../context/FooterAnimationContext/index.js';
|
|
89
|
+
import '../../../views/MfaChooseDeviceView/useGetMfaOptions/useGetMfaOptions.js';
|
|
90
|
+
import '../../../context/PasskeyContext/PasskeyContext.js';
|
|
91
|
+
import '../../../context/OnrampContext/OnrampContext.js';
|
|
92
|
+
import '../../../store/state/sendBalances.js';
|
|
93
|
+
import '../../../store/state/connectorsInitializing/connectorsInitializing.js';
|
|
94
|
+
import '../../../components/OverlayCardBase/OverlayCardTarget/OverlayCardTarget.js';
|
|
95
|
+
import '../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
|
|
96
|
+
import '../../../views/TransactionConfirmationView/TransactionConfirmationView.js';
|
|
97
|
+
import '../../../widgets/DynamicWidget/components/PasskeyCard/PasskeyCard.js';
|
|
98
|
+
import '../../../widgets/DynamicWidget/views/CryptoComOnramp/CryptoComOnramp.js';
|
|
99
|
+
import '../../../../index.js';
|
|
100
|
+
import '../../../widgets/DynamicWidget/views/ManagePasskeysMfaWidgetView/ManagePasskeysMfaWidgetView.js';
|
|
101
|
+
import '../../../widgets/DynamicWidget/views/ManageTotpMfaWidgetView/ManageTotpMfaWidgetView.js';
|
|
102
|
+
import '../../../widgets/DynamicWidget/views/ReceiveWalletFunds/ReceiveWalletFunds.js';
|
|
103
|
+
import '../../../store/state/tokenBalances.js';
|
|
104
|
+
import '../../../store/state/multichainBalances.js';
|
|
105
|
+
import '@dynamic-labs/store';
|
|
106
|
+
import '../../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
107
|
+
import { useInternalDynamicContext } from '../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Programs whose `join` transition the Aleo Feemaster has historically
|
|
111
|
+
* sponsored — `credits.aleo` and the two stablecoins. ARC-21 lives on
|
|
112
|
+
* `token_registry.aleo` which is per-`token_id` and out of scope for v1.
|
|
113
|
+
*
|
|
114
|
+
* The list is intentionally explicit (not pulled from the connector's
|
|
115
|
+
* private allowlist) so adding a program here is a deliberate decision
|
|
116
|
+
* coupled to Feemaster coverage rather than an automatic side-effect of a
|
|
117
|
+
* shape-registry change.
|
|
118
|
+
*/
|
|
119
|
+
const AUTO_MERGE_PROGRAMS = [
|
|
120
|
+
'credits.aleo',
|
|
121
|
+
'usad_stablecoin.aleo',
|
|
122
|
+
'usdcx_stablecoin.aleo',
|
|
123
|
+
'test_usad_stablecoin.aleo',
|
|
124
|
+
'test_usdcx_stablecoin.aleo',
|
|
125
|
+
];
|
|
126
|
+
/**
|
|
127
|
+
* On Aleo wallet load, scan the user's owned records and silently fire a
|
|
128
|
+
* merge ceremony for every program with ≥2 records that the Feemaster
|
|
129
|
+
* currently sponsors. Programs the Feemaster doesn't cover are skipped —
|
|
130
|
+
* the user can still trigger a manual merge via the explicit "Merge all
|
|
131
|
+
* records" CTA, which dispatches with user-paid fees.
|
|
132
|
+
*
|
|
133
|
+
* Idempotency is per-session, keyed by `(accountAddress, programId)`. A
|
|
134
|
+
* page reload re-runs auto-merge once; mid-session balance refreshes do
|
|
135
|
+
* not re-trigger merges for the same program. On error the program key
|
|
136
|
+
* is removed from the seen-set so the next refresh can retry.
|
|
137
|
+
*
|
|
138
|
+
* Failures are swallowed by design — auto-merge is a background
|
|
139
|
+
* optimisation, not a user-facing flow. Errors surface only via the
|
|
140
|
+
* connector's own logger.
|
|
141
|
+
*/
|
|
142
|
+
const useAleoAutoMergeRecords = () => {
|
|
143
|
+
const { primaryWallet } = useInternalDynamicContext();
|
|
144
|
+
// Tracks `(accountAddress:programId)` pairs we've already attempted in
|
|
145
|
+
// this React session. Cleared implicitly on a full page reload (the ref
|
|
146
|
+
// lives in module-private React state). We do NOT persist to
|
|
147
|
+
// localStorage on purpose — the Feemaster check on every attempt is
|
|
148
|
+
// cheap server-side and survives mid-session policy changes.
|
|
149
|
+
const seenKeysRef = useRef(new Set());
|
|
150
|
+
useEffect(() => {
|
|
151
|
+
var _a;
|
|
152
|
+
const connector = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
153
|
+
if (!connector)
|
|
154
|
+
return;
|
|
155
|
+
const isAleo = ((_a = primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) === null || _a === void 0 ? void 0 : _a.connectedChain) === ChainEnum.Aleo;
|
|
156
|
+
if (!isAleo)
|
|
157
|
+
return;
|
|
158
|
+
if (typeof connector.listOwnedRecords !== 'function' ||
|
|
159
|
+
typeof connector.isFeemasterSponsored !== 'function' ||
|
|
160
|
+
typeof connector.joinRecords !== 'function') {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
let cancelled = false;
|
|
164
|
+
const accountAddress = primaryWallet
|
|
165
|
+
.address;
|
|
166
|
+
if (!accountAddress)
|
|
167
|
+
return;
|
|
168
|
+
const run = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
169
|
+
var _b, _c, _d, _e, _f, _g;
|
|
170
|
+
const result = yield ((_b = connector.listOwnedRecords) === null || _b === void 0 ? void 0 : _b.call(connector));
|
|
171
|
+
if (cancelled)
|
|
172
|
+
return;
|
|
173
|
+
const records = ((_c = result === null || result === void 0 ? void 0 : result.records) !== null && _c !== void 0 ? _c : []).filter((r) => Boolean(r === null || r === void 0 ? void 0 : r.program_name) && typeof (r === null || r === void 0 ? void 0 : r.record_plaintext) === 'string');
|
|
174
|
+
// Group record counts per program.
|
|
175
|
+
const countsByProgram = new Map();
|
|
176
|
+
for (const record of records) {
|
|
177
|
+
const programId = record.program_name;
|
|
178
|
+
countsByProgram.set(programId, ((_d = countsByProgram.get(programId)) !== null && _d !== void 0 ? _d : 0) + 1);
|
|
179
|
+
}
|
|
180
|
+
const candidates = AUTO_MERGE_PROGRAMS.filter((programId) => {
|
|
181
|
+
var _a;
|
|
182
|
+
const count = (_a = countsByProgram.get(programId)) !== null && _a !== void 0 ? _a : 0;
|
|
183
|
+
if (count < 2)
|
|
184
|
+
return false;
|
|
185
|
+
const key = `${accountAddress}:${programId}`;
|
|
186
|
+
return !seenKeysRef.current.has(key);
|
|
187
|
+
});
|
|
188
|
+
for (const programId of candidates) {
|
|
189
|
+
if (cancelled)
|
|
190
|
+
return;
|
|
191
|
+
const key = `${accountAddress}:${programId}`;
|
|
192
|
+
seenKeysRef.current.add(key);
|
|
193
|
+
let sponsored = false;
|
|
194
|
+
try {
|
|
195
|
+
sponsored =
|
|
196
|
+
(_f = (yield ((_e = connector.isFeemasterSponsored) === null || _e === void 0 ? void 0 : _e.call(connector, {
|
|
197
|
+
functionName: 'join',
|
|
198
|
+
programId,
|
|
199
|
+
})))) !== null && _f !== void 0 ? _f : false;
|
|
200
|
+
}
|
|
201
|
+
catch (_h) {
|
|
202
|
+
sponsored = false;
|
|
203
|
+
}
|
|
204
|
+
if (cancelled)
|
|
205
|
+
return;
|
|
206
|
+
if (!sponsored) {
|
|
207
|
+
// Allow a future attempt if Feemaster coverage flips on later in
|
|
208
|
+
// the session (e.g. after a policy refresh).
|
|
209
|
+
seenKeysRef.current.delete(key);
|
|
210
|
+
continue;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
yield ((_g = connector.joinRecords) === null || _g === void 0 ? void 0 : _g.call(connector, { programIds: [programId] }));
|
|
214
|
+
}
|
|
215
|
+
catch (_j) {
|
|
216
|
+
// Background optimisation — swallow and let the next session
|
|
217
|
+
// retry. Removing the key allows a retry on the next records
|
|
218
|
+
// refresh.
|
|
219
|
+
seenKeysRef.current.delete(key);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
run().catch(() => {
|
|
224
|
+
/* swallow — see method jsdoc */
|
|
225
|
+
});
|
|
226
|
+
return () => {
|
|
227
|
+
cancelled = true;
|
|
228
|
+
};
|
|
229
|
+
// Depend on the stable address + connector reference rather than the
|
|
230
|
+
// whole `primaryWallet` object. The wallet object can be re-created
|
|
231
|
+
// on every context update (balance refreshes, metadata churn, etc.),
|
|
232
|
+
// which would re-fire this effect even when no merge-relevant state
|
|
233
|
+
// has changed and re-spam `listOwnedRecords` / `isFeemasterSponsored`.
|
|
234
|
+
// Address + connector are the only fields the effect actually reads.
|
|
235
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
236
|
+
}, [
|
|
237
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.address,
|
|
238
|
+
primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector,
|
|
239
|
+
]);
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export { useAleoAutoMergeRecords };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useAleoAutoShieldSponsoredTokens } from './useAleoAutoShieldSponsoredTokens';
|