@dynamic-labs/sdk-react-core 4.84.0 → 4.84.1

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 (32) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/package.cjs +1 -1
  3. package/package.js +1 -1
  4. package/package.json +12 -12
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.ts +2 -2
  7. package/src/index.js +1 -0
  8. package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +26 -1
  9. package/src/lib/components/SendBalanceForm/SendBalanceForm.js +26 -1
  10. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +6 -1
  11. package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +6 -1
  12. package/src/lib/utils/hooks/index.d.ts +2 -0
  13. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.cjs +24 -4
  14. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.d.ts +10 -2
  15. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.js +24 -4
  16. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.cjs +14 -3
  17. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.d.ts +5 -1
  18. package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.js +14 -3
  19. package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.cjs +14 -0
  20. package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.js +14 -0
  21. package/src/lib/utils/hooks/usePrivateTokenBalances/index.d.ts +2 -0
  22. package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.cjs +19 -0
  23. package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.d.ts +9 -0
  24. package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.js +15 -0
  25. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +19 -16
  26. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +8 -0
  27. package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +19 -17
  28. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +138 -21
  29. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +139 -22
  30. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.cjs +134 -0
  31. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.d.ts +69 -0
  32. package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.js +127 -0
package/CHANGELOG.md CHANGED
@@ -1,4 +1,21 @@
1
1
 
2
+ ### [4.84.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.84.0...v4.84.1) (2026-05-28)
3
+
4
+
5
+ ### Features
6
+
7
+ * **sdk-react-core:** add usePrivateTokenBalances public hook ([#11338](https://github.com/dynamic-labs/dynamic-auth/issues/11338)) ([91125e8](https://github.com/dynamic-labs/dynamic-auth/commit/91125e8e3ac010f760e1481fd4685dfde331b94a))
8
+ * **waas:** detect delegated wallets via otherShareSets ([#11312](https://github.com/dynamic-labs/dynamic-auth/issues/11312)) ([0c8277f](https://github.com/dynamic-labs/dynamic-auth/commit/0c8277f9e2f4e622fc7a75fdfcf4180d9b7db8ff))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **aleo:** misc Send-screen UI fixes — sponsorship, 0-amount, 0-balance, glyphs ([#11337](https://github.com/dynamic-labs/dynamic-auth/issues/11337)) ([f95bc34](https://github.com/dynamic-labs/dynamic-auth/commit/f95bc34c7f8e0a01df61a72f0cbcfa3508471cd7))
14
+ * **aleo:** optimistic shield balance updates + convergence polling ([#11336](https://github.com/dynamic-labs/dynamic-auth/issues/11336)) ([c86eeec](https://github.com/dynamic-labs/dynamic-auth/commit/c86eeecd1475838a61d58b7924ac7bec0db5b9f3))
15
+ * **locale:** capitalize "Key" in Export Private Key button ([#11319](https://github.com/dynamic-labs/dynamic-auth/issues/11319)) ([58eceff](https://github.com/dynamic-labs/dynamic-auth/commit/58eceff3fdaee5d70dac0a8fef89a86f31f814aa))
16
+
17
+
18
+
2
19
  ## [4.84.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.83.2-alpha.0...v4.84.0) (2026-05-22)
3
20
 
4
21
 
@@ -6522,4 +6539,4 @@ Enjoy!
6522
6539
  * setPrimaryWallet and useSyncPrimaryWallet updates ([#2128](https://github.com/dynamic-labs/DynamicAuth/issues/2128)) ([fb47b17](https://github.com/dynamic-labs/DynamicAuth/commit/fb47b17ddc7f41c29f140a1a85a1e47dbf017fff))
6523
6540
  * update text color and add close button on extension not installed prompt ([#2122](https://github.com/dynamic-labs/DynamicAuth/issues/2122)) ([b4848a0](https://github.com/dynamic-labs/DynamicAuth/commit/b4848a0a8094b4ceac67e2667d277a9aa5e2e137))
6524
6541
 
6525
- ## [0.17.0-RC.16](https://github.com/dynamic-labs/Dyna
6542
+ ## [0.17.0-RC.16](https://github.com/dynamic-labs/Dyna
package/package.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "4.84.0";
6
+ var version = "4.84.1";
7
7
  var dependencies = {
8
8
  "@dynamic-labs/sdk-api-core": "0.0.985",
9
9
  "@dynamic-labs-sdk/client": "1.1.0",
package/package.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client'
2
- var version = "4.84.0";
2
+ var version = "4.84.1";
3
3
  var dependencies = {
4
4
  "@dynamic-labs/sdk-api-core": "0.0.985",
5
5
  "@dynamic-labs-sdk/client": "1.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "4.84.0",
3
+ "version": "4.84.1",
4
4
  "dependencies": {
5
5
  "@dynamic-labs/sdk-api-core": "0.0.985",
6
6
  "@dynamic-labs-sdk/client": "1.1.0",
@@ -17,17 +17,17 @@
17
17
  "yup": "0.32.11",
18
18
  "react-international-phone": "4.5.0",
19
19
  "bs58": "5.0.0",
20
- "@dynamic-labs/assert-package-version": "4.84.0",
21
- "@dynamic-labs/iconic": "4.84.0",
22
- "@dynamic-labs/locale": "4.84.0",
23
- "@dynamic-labs/logger": "4.84.0",
24
- "@dynamic-labs/multi-wallet": "4.84.0",
25
- "@dynamic-labs/rpc-providers": "4.84.0",
26
- "@dynamic-labs/store": "4.84.0",
27
- "@dynamic-labs/types": "4.84.0",
28
- "@dynamic-labs/utils": "4.84.0",
29
- "@dynamic-labs/wallet-book": "4.84.0",
30
- "@dynamic-labs/wallet-connector-core": "4.84.0",
20
+ "@dynamic-labs/assert-package-version": "4.84.1",
21
+ "@dynamic-labs/iconic": "4.84.1",
22
+ "@dynamic-labs/locale": "4.84.1",
23
+ "@dynamic-labs/logger": "4.84.1",
24
+ "@dynamic-labs/multi-wallet": "4.84.1",
25
+ "@dynamic-labs/rpc-providers": "4.84.1",
26
+ "@dynamic-labs/store": "4.84.1",
27
+ "@dynamic-labs/types": "4.84.1",
28
+ "@dynamic-labs/utils": "4.84.1",
29
+ "@dynamic-labs/wallet-book": "4.84.1",
30
+ "@dynamic-labs/wallet-connector-core": "4.84.1",
31
31
  "eventemitter3": "5.0.1"
32
32
  },
33
33
  "devDependencies": {
package/src/index.cjs CHANGED
@@ -173,6 +173,7 @@ var useDynamicModals = require('./lib/utils/hooks/useDynamicModals/useDynamicMod
173
173
  var useMfa = require('./lib/utils/hooks/useMfa/useMfa.cjs');
174
174
  var useTokenBalances = require('./lib/utils/hooks/useTokenBalances/useTokenBalances.cjs');
175
175
  var useMultichainTokenBalances = require('./lib/utils/hooks/useMultichainTokenBalances/useMultichainTokenBalances.cjs');
176
+ var usePrivateTokenBalances = require('./lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.cjs');
176
177
  var useEmbeddedWallet = require('./lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.cjs');
177
178
  var constants = require('./lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.cjs');
178
179
  var useExternalAuth = require('./lib/utils/hooks/useExternalAuth/useExternalAuth.cjs');
@@ -344,6 +345,7 @@ exports.useDynamicModals = useDynamicModals.useDynamicModals;
344
345
  exports.useMfa = useMfa.useMfa;
345
346
  exports.useTokenBalances = useTokenBalances.useTokenBalances;
346
347
  exports.useMultichainTokenBalances = useMultichainTokenBalances.useMultichainTokenBalances;
348
+ exports.usePrivateTokenBalances = usePrivateTokenBalances.usePrivateTokenBalances;
347
349
  exports.useEmbeddedWallet = useEmbeddedWallet.useEmbeddedWallet;
348
350
  Object.defineProperty(exports, 'EmbeddedWalletVersion', {
349
351
  enumerable: true,
package/src/index.d.ts CHANGED
@@ -123,8 +123,8 @@ export { FilterAndSortWallets, FilterBridgeChainsName, FilterChain, FilterWallet
123
123
  export {
124
124
  /** @deprecated */
125
125
  DynamicWidgetContextProvider, } from './lib/widgets/DynamicWidget/context';
126
- export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useEmbeddedWalletAuthenticator, usePasskeyRecovery, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, EmbeddedWalletVersion, useTelegramLogin, useUpgradeEmbeddedWallet, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useUpgradeToDynamicWaasFlow, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
127
- export type { GoogleDriveBackupAccessError, GoogleDriveBackupReadiness, GoogleDriveBackupReadinessStatus, UseGoogleDriveBackupReadinessReturn, } from './lib/utils/hooks';
126
+ export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useEmbeddedWalletAuthenticator, usePasskeyRecovery, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, usePrivateTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, EmbeddedWalletVersion, useTelegramLogin, useUpgradeEmbeddedWallet, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useUpgradeToDynamicWaasFlow, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
127
+ export type { GoogleDriveBackupAccessError, GoogleDriveBackupReadiness, GoogleDriveBackupReadinessStatus, UseGoogleDriveBackupReadinessReturn, UsePrivateTokenBalancesReturn, } from './lib/utils/hooks';
128
128
  export type { IsStepUpRequiredParams, PromptMfaParams, StepUpAuthenticationState, UseStepUpAuthenticationParams, UseStepUpAuthenticationReturn, VerifyOtpParams, VerifyPasskeyMfaParams, VerifyRecoveryCodeParams, VerifySocialParams, VerifyTotpMfaParams, VerifyWalletParams, } from './lib/utils/hooks';
129
129
  export {
130
130
  /** @deprecated use useOnramp instead */
package/src/index.js CHANGED
@@ -169,6 +169,7 @@ export { useDynamicModals } from './lib/utils/hooks/useDynamicModals/useDynamicM
169
169
  export { useMfa } from './lib/utils/hooks/useMfa/useMfa.js';
170
170
  export { useTokenBalances } from './lib/utils/hooks/useTokenBalances/useTokenBalances.js';
171
171
  export { useMultichainTokenBalances } from './lib/utils/hooks/useMultichainTokenBalances/useMultichainTokenBalances.js';
172
+ export { usePrivateTokenBalances } from './lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.js';
172
173
  export { useEmbeddedWallet } from './lib/utils/hooks/useEmbeddedWallet/useEmbeddedWallet.js';
173
174
  export { EmbeddedWalletVersion } from './lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/constants.js';
174
175
  export { useExternalAuth } from './lib/utils/hooks/useExternalAuth/useExternalAuth.js';
@@ -51,10 +51,12 @@ const sendBalanceFormInitialValues = {
51
51
  recipient: '',
52
52
  };
53
53
  const getDisplayErrorMessage = (errors, t, field, decimals) => {
54
+ var _a;
54
55
  const mapFieldAndErrorToMessage = {
55
56
  amount: {
56
57
  invalidDecimals: t('dyn_send_transaction.validation.amount.invalid_decimals', { decimals }),
57
58
  invalidFormat: t('dyn_send_transaction.validation.amount.invalid_decimals', { decimals }),
59
+ nonZero: t('dyn_send_transaction.validation.amount.non_zero'),
58
60
  overBalance: t('dyn_send_transaction.validation.amount.over_balance'),
59
61
  required: t('dyn_send_transaction.validation.amount.required'),
60
62
  },
@@ -63,9 +65,18 @@ const getDisplayErrorMessage = (errors, t, field, decimals) => {
63
65
  required: t('dyn_send_transaction.validation.recipient.required'),
64
66
  },
65
67
  };
68
+ // Form's two fields disagree on the validator set: `amount` adds
69
+ // `invalidDecimals` / `nonZero` / `overBalance` on top of the shared
70
+ // `invalidFormat` / `required` that `recipient` also uses. Casting
71
+ // the resolved sub-map to a string-keyed record sidesteps the union
72
+ // narrowing TS would otherwise force on the indexed access (the
73
+ // amount-only keys never reach the recipient branch in practice
74
+ // because yup labels every recipient violation with `invalidFormat`
75
+ // or `required`).
66
76
  const errorType = errors[field];
67
77
  if (errorType) {
68
- const errorMessage = mapFieldAndErrorToMessage[field][errorType];
78
+ const fieldMap = mapFieldAndErrorToMessage[field];
79
+ const errorMessage = (_a = fieldMap[errorType]) !== null && _a !== void 0 ? _a : '';
69
80
  return errorMessage.replace('{decimals}', getOrdinalNumber.getOrdinalNumber(decimals !== null && decimals !== void 0 ? decimals : 0));
70
81
  }
71
82
  return '';
@@ -133,6 +144,20 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
133
144
  .required('required')
134
145
  .matches(/^\d*(\.\d+)?$/, 'invalidFormat')
135
146
  .matches(decimalsRegex, 'invalidDecimals')
147
+ // Reject zero (and any all-zero variant: `0`, `0.0`, `00.000`,
148
+ // etc.) before we hit the balance check. Without this the
149
+ // form would happily submit a 0-value transaction — unusable
150
+ // for the user, wasted gas on chains that don't bounce it, and
151
+ // on Aleo specifically triggers a `_value_must_be_positive`
152
+ // rejection from the prover.
153
+ .test({
154
+ message: 'nonZero',
155
+ test: (value) => {
156
+ if (value === undefined)
157
+ return true;
158
+ return /^0*(?:\.0+)?$/.test(value) === false;
159
+ },
160
+ })
136
161
  .test({
137
162
  message: 'overBalance',
138
163
  test: (value) => validateAmount(value),
@@ -47,10 +47,12 @@ const sendBalanceFormInitialValues = {
47
47
  recipient: '',
48
48
  };
49
49
  const getDisplayErrorMessage = (errors, t, field, decimals) => {
50
+ var _a;
50
51
  const mapFieldAndErrorToMessage = {
51
52
  amount: {
52
53
  invalidDecimals: t('dyn_send_transaction.validation.amount.invalid_decimals', { decimals }),
53
54
  invalidFormat: t('dyn_send_transaction.validation.amount.invalid_decimals', { decimals }),
55
+ nonZero: t('dyn_send_transaction.validation.amount.non_zero'),
54
56
  overBalance: t('dyn_send_transaction.validation.amount.over_balance'),
55
57
  required: t('dyn_send_transaction.validation.amount.required'),
56
58
  },
@@ -59,9 +61,18 @@ const getDisplayErrorMessage = (errors, t, field, decimals) => {
59
61
  required: t('dyn_send_transaction.validation.recipient.required'),
60
62
  },
61
63
  };
64
+ // Form's two fields disagree on the validator set: `amount` adds
65
+ // `invalidDecimals` / `nonZero` / `overBalance` on top of the shared
66
+ // `invalidFormat` / `required` that `recipient` also uses. Casting
67
+ // the resolved sub-map to a string-keyed record sidesteps the union
68
+ // narrowing TS would otherwise force on the indexed access (the
69
+ // amount-only keys never reach the recipient branch in practice
70
+ // because yup labels every recipient violation with `invalidFormat`
71
+ // or `required`).
62
72
  const errorType = errors[field];
63
73
  if (errorType) {
64
- const errorMessage = mapFieldAndErrorToMessage[field][errorType];
74
+ const fieldMap = mapFieldAndErrorToMessage[field];
75
+ const errorMessage = (_a = fieldMap[errorType]) !== null && _a !== void 0 ? _a : '';
65
76
  return errorMessage.replace('{decimals}', getOrdinalNumber(decimals !== null && decimals !== void 0 ? decimals : 0));
66
77
  }
67
78
  return '';
@@ -129,6 +140,20 @@ const SendBalanceForm = ({ initialValues, onSubmit, decimals = 18, validateAddre
129
140
  .required('required')
130
141
  .matches(/^\d*(\.\d+)?$/, 'invalidFormat')
131
142
  .matches(decimalsRegex, 'invalidDecimals')
143
+ // Reject zero (and any all-zero variant: `0`, `0.0`, `00.000`,
144
+ // etc.) before we hit the balance check. Without this the
145
+ // form would happily submit a 0-value transaction — unusable
146
+ // for the user, wasted gas on chains that don't bounce it, and
147
+ // on Aleo specifically triggers a `_value_must_be_positive`
148
+ // rejection from the prover.
149
+ .test({
150
+ message: 'nonZero',
151
+ test: (value) => {
152
+ if (value === undefined)
153
+ return true;
154
+ return /^0*(?:\.0+)?$/.test(value) === false;
155
+ },
156
+ })
132
157
  .test({
133
158
  message: 'overBalance',
134
159
  test: (value) => validateAmount(value),
@@ -173,7 +173,12 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
173
173
  decimals: nativeTokenInfo.nativeCurrency.decimals,
174
174
  isNative: true,
175
175
  logoURI: nativeTokenInfo.nativeCurrency.iconUrl || nativeTokenInfo.iconUrls[0],
176
- name: nativeTokenInfo.name,
176
+ // `nativeTokenInfo.name` is the **network** name (e.g. "Aleo
177
+ // Mainnet" / "Aleo Testnet"); the token row in the picker should
178
+ // show the **native currency** name (e.g. "Aleo Credits") so it
179
+ // doesn't briefly flash the network label before the real
180
+ // balances load and overwrite this synthesised placeholder.
181
+ name: nativeTokenInfo.nativeCurrency.name,
177
182
  rawBalance: 0,
178
183
  rawBalanceString: '0',
179
184
  symbol: nativeTokenInfo.nativeCurrency.symbol,
@@ -169,7 +169,12 @@ const SendBalancePageLayout = ({ error, onClickClose, onClickBack, onSubmit, dis
169
169
  decimals: nativeTokenInfo.nativeCurrency.decimals,
170
170
  isNative: true,
171
171
  logoURI: nativeTokenInfo.nativeCurrency.iconUrl || nativeTokenInfo.iconUrls[0],
172
- name: nativeTokenInfo.name,
172
+ // `nativeTokenInfo.name` is the **network** name (e.g. "Aleo
173
+ // Mainnet" / "Aleo Testnet"); the token row in the picker should
174
+ // show the **native currency** name (e.g. "Aleo Credits") so it
175
+ // doesn't briefly flash the network label before the real
176
+ // balances load and overwrite this synthesised placeholder.
177
+ name: nativeTokenInfo.nativeCurrency.name,
173
178
  rawBalance: 0,
174
179
  rawBalanceString: '0',
175
180
  symbol: nativeTokenInfo.nativeCurrency.symbol,
@@ -56,6 +56,8 @@ export { useMfa } from './useMfa';
56
56
  export { useMergeUserAccounts } from './useMergeUserAccounts';
57
57
  export { useTokenBalances } from './useTokenBalances';
58
58
  export { useMultichainTokenBalances } from './useMultichainTokenBalances';
59
+ export { usePrivateTokenBalances } from './usePrivateTokenBalances';
60
+ export type { UsePrivateTokenBalancesReturn } from './usePrivateTokenBalances';
59
61
  export { useUserAuth } from './useUserAuth';
60
62
  export { useSwitchWallet } from './useSwitchWallet';
61
63
  export { useSyncEmbeddedWalletFlow } from './useSyncEmbeddedWalletFlow';
@@ -9,7 +9,7 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
9
9
  // when the relay accepts the broadcast, not when the public→private
10
10
  // transition confirms on-chain. Aleo block time + RecordScanner indexer
11
11
  // lag means the immediate post-broadcast fetch usually returns the
12
- // pre-confirmation balance, so we re-poll for ~45s before giving up.
12
+ // pre-confirmation balance, so we re-poll on a backoff schedule.
13
13
  //
14
14
  // Shared between the auto-shield hook (background) and the widget's
15
15
  // manual Shield Manually CTA (foreground), so both flows update the
@@ -17,23 +17,41 @@ var _tslib = require('../../../../../_virtual/_tslib.cjs');
17
17
  // the manual flow refreshed exactly once and the unshielded row
18
18
  // stayed at its pre-broadcast value for the full RecordScanner lag,
19
19
  // making a successful shield look like a no-op.
20
+ //
21
+ // Total window ≈106s. Provable's mapping endpoint typically reflects
22
+ // a `transfer_public_to_private` within ~30s of broadcast, but the
23
+ // RecordScanner index lag for the new private record can stretch to
24
+ // ~90s in the worst case. The tail entries (25s, 35s) keep the poll
25
+ // alive across the upper end of that range without spamming requests
26
+ // during the common case (most balances converge inside the first
27
+ // three iterations and the convergence predicate exits the loop).
20
28
  const REFRESH_DELAYS_MS = [
21
- 3000, 5000, 8000, 12000, 18000,
29
+ 3000, 5000, 8000, 12000, 18000, 25000, 35000,
22
30
  ];
23
31
  /**
24
32
  * After a successful shield broadcast, poll `onShielded` on a backoff
25
33
  * schedule so the consumer sees both the shielded and unshielded balances
26
- * update without a manual refresh click. Stops early on cancel; swallows
34
+ * update without a manual refresh click. Stops early on cancel or when
35
+ * the optional `hasConverged` predicate returns true; swallows
27
36
  * per-iteration errors (refresh is best-effort).
28
37
  *
29
38
  * `isCancelled` is a thunk so callers can hook it up to whatever liveness
30
39
  * signal they have (effect cleanup `cancelled` flag, abort signal, mount
31
40
  * ref, etc.) without this module having to know about React lifecycle.
41
+ *
42
+ * `hasConverged` is optional and lets callers exit early once the
43
+ * post-shield state has actually materialized (e.g. the just-shielded
44
+ * token's unshielded balance has dropped). When omitted, the schedule
45
+ * runs to completion. Checked both before each delay and after each
46
+ * refresh so a refresh that produces the converged state ends the loop
47
+ * immediately.
32
48
  */
33
- const pollOnShielded = (onShielded, isCancelled) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
49
+ const pollOnShielded = (onShielded, isCancelled, hasConverged) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
34
50
  for (const delay of REFRESH_DELAYS_MS) {
35
51
  if (isCancelled())
36
52
  return;
53
+ if (hasConverged === null || hasConverged === void 0 ? void 0 : hasConverged())
54
+ return;
37
55
  yield new Promise((resolve) => setTimeout(resolve, delay));
38
56
  if (isCancelled())
39
57
  return;
@@ -43,6 +61,8 @@ const pollOnShielded = (onShielded, isCancelled) => _tslib.__awaiter(void 0, voi
43
61
  catch (_a) {
44
62
  /* swallow — refresh is best-effort */
45
63
  }
64
+ if (hasConverged === null || hasConverged === void 0 ? void 0 : hasConverged())
65
+ return;
46
66
  }
47
67
  });
48
68
 
@@ -2,11 +2,19 @@ export declare const REFRESH_DELAYS_MS: ReadonlyArray<number>;
2
2
  /**
3
3
  * After a successful shield broadcast, poll `onShielded` on a backoff
4
4
  * schedule so the consumer sees both the shielded and unshielded balances
5
- * update without a manual refresh click. Stops early on cancel; swallows
5
+ * update without a manual refresh click. Stops early on cancel or when
6
+ * the optional `hasConverged` predicate returns true; swallows
6
7
  * per-iteration errors (refresh is best-effort).
7
8
  *
8
9
  * `isCancelled` is a thunk so callers can hook it up to whatever liveness
9
10
  * signal they have (effect cleanup `cancelled` flag, abort signal, mount
10
11
  * ref, etc.) without this module having to know about React lifecycle.
12
+ *
13
+ * `hasConverged` is optional and lets callers exit early once the
14
+ * post-shield state has actually materialized (e.g. the just-shielded
15
+ * token's unshielded balance has dropped). When omitted, the schedule
16
+ * runs to completion. Checked both before each delay and after each
17
+ * refresh so a refresh that produces the converged state ends the loop
18
+ * immediately.
11
19
  */
12
- export declare const pollOnShielded: (onShielded: () => Promise<void> | void, isCancelled: () => boolean) => Promise<void>;
20
+ export declare const pollOnShielded: (onShielded: () => Promise<void> | void, isCancelled: () => boolean, hasConverged?: () => boolean) => Promise<void>;
@@ -5,7 +5,7 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
5
5
  // when the relay accepts the broadcast, not when the public→private
6
6
  // transition confirms on-chain. Aleo block time + RecordScanner indexer
7
7
  // lag means the immediate post-broadcast fetch usually returns the
8
- // pre-confirmation balance, so we re-poll for ~45s before giving up.
8
+ // pre-confirmation balance, so we re-poll on a backoff schedule.
9
9
  //
10
10
  // Shared between the auto-shield hook (background) and the widget's
11
11
  // manual Shield Manually CTA (foreground), so both flows update the
@@ -13,23 +13,41 @@ import { __awaiter } from '../../../../../_virtual/_tslib.js';
13
13
  // the manual flow refreshed exactly once and the unshielded row
14
14
  // stayed at its pre-broadcast value for the full RecordScanner lag,
15
15
  // making a successful shield look like a no-op.
16
+ //
17
+ // Total window ≈106s. Provable's mapping endpoint typically reflects
18
+ // a `transfer_public_to_private` within ~30s of broadcast, but the
19
+ // RecordScanner index lag for the new private record can stretch to
20
+ // ~90s in the worst case. The tail entries (25s, 35s) keep the poll
21
+ // alive across the upper end of that range without spamming requests
22
+ // during the common case (most balances converge inside the first
23
+ // three iterations and the convergence predicate exits the loop).
16
24
  const REFRESH_DELAYS_MS = [
17
- 3000, 5000, 8000, 12000, 18000,
25
+ 3000, 5000, 8000, 12000, 18000, 25000, 35000,
18
26
  ];
19
27
  /**
20
28
  * After a successful shield broadcast, poll `onShielded` on a backoff
21
29
  * schedule so the consumer sees both the shielded and unshielded balances
22
- * update without a manual refresh click. Stops early on cancel; swallows
30
+ * update without a manual refresh click. Stops early on cancel or when
31
+ * the optional `hasConverged` predicate returns true; swallows
23
32
  * per-iteration errors (refresh is best-effort).
24
33
  *
25
34
  * `isCancelled` is a thunk so callers can hook it up to whatever liveness
26
35
  * signal they have (effect cleanup `cancelled` flag, abort signal, mount
27
36
  * ref, etc.) without this module having to know about React lifecycle.
37
+ *
38
+ * `hasConverged` is optional and lets callers exit early once the
39
+ * post-shield state has actually materialized (e.g. the just-shielded
40
+ * token's unshielded balance has dropped). When omitted, the schedule
41
+ * runs to completion. Checked both before each delay and after each
42
+ * refresh so a refresh that produces the converged state ends the loop
43
+ * immediately.
28
44
  */
29
- const pollOnShielded = (onShielded, isCancelled) => __awaiter(void 0, void 0, void 0, function* () {
45
+ const pollOnShielded = (onShielded, isCancelled, hasConverged) => __awaiter(void 0, void 0, void 0, function* () {
30
46
  for (const delay of REFRESH_DELAYS_MS) {
31
47
  if (isCancelled())
32
48
  return;
49
+ if (hasConverged === null || hasConverged === void 0 ? void 0 : hasConverged())
50
+ return;
33
51
  yield new Promise((resolve) => setTimeout(resolve, delay));
34
52
  if (isCancelled())
35
53
  return;
@@ -39,6 +57,8 @@ const pollOnShielded = (onShielded, isCancelled) => __awaiter(void 0, void 0, vo
39
57
  catch (_a) {
40
58
  /* swallow — refresh is best-effort */
41
59
  }
60
+ if (hasConverged === null || hasConverged === void 0 ? void 0 : hasConverged())
61
+ return;
42
62
  }
43
63
  });
44
64
 
@@ -47,7 +47,7 @@ const buildShieldCandidates = (args) => {
47
47
  */
48
48
  const tryShieldOneToken = (token, deps) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
49
49
  var _a, _b, _c;
50
- const { accountAddress, shieldHandle, seenKeys, isCancelled, inFlightTokenKeys, } = deps;
50
+ const { accountAddress, shieldHandle, seenKeys, isCancelled, inFlightTokenKeys, onShieldDispatched, } = deps;
51
51
  const tokenKey = buildTokenKey.buildTokenKey(token) || nativeTokenKey.nativeTokenKey;
52
52
  const key = `${accountAddress}:${tokenKey}`;
53
53
  seenKeys.add(key);
@@ -80,9 +80,19 @@ const tryShieldOneToken = (token, deps) => _tslib.__awaiter(void 0, void 0, void
80
80
  isNative: token.isNative,
81
81
  tokenAddress: token.address,
82
82
  });
83
+ // Optimistic-UI hand-off: notify the consumer the broadcast was
84
+ // accepted so it can deduct the unshielded balance locally and
85
+ // prepend a synthesised shielded row. Synchronous and best-effort;
86
+ // failures inside the callback don't roll back the shield.
87
+ try {
88
+ onShieldDispatched === null || onShieldDispatched === void 0 ? void 0 : onShieldDispatched({ amount: atomic, token });
89
+ }
90
+ catch (_e) {
91
+ /* swallow — optimistic hand-off is best-effort */
92
+ }
83
93
  return true;
84
94
  }
85
- catch (_e) {
95
+ catch (_f) {
86
96
  seenKeys.delete(key);
87
97
  return false;
88
98
  }
@@ -90,7 +100,7 @@ const tryShieldOneToken = (token, deps) => _tslib.__awaiter(void 0, void 0, void
90
100
  inFlightTokenKeys === null || inFlightTokenKeys === void 0 ? void 0 : inFlightTokenKeys.delete(tokenKey);
91
101
  }
92
102
  });
93
- const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, }) => {
103
+ const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, onShieldDispatched, }) => {
94
104
  // Tracks `(accountAddress:tokenAddress)` we've already attempted in this
95
105
  // session. Cleared implicitly on a full page reload.
96
106
  const seenKeysRef = React.useRef(new Set());
@@ -218,6 +228,7 @@ const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalan
218
228
  accountAddress,
219
229
  inFlightTokenKeys: inFlightKeysAdapter,
220
230
  isCancelled,
231
+ onShieldDispatched,
221
232
  seenKeys: seenKeysRef.current,
222
233
  shieldHandle,
223
234
  });
@@ -25,6 +25,10 @@ type UseAleoAutoShieldSponsoredTokensArgs = {
25
25
  unshieldedTokenBalances: TokenBalance[];
26
26
  shieldHandle: AleoShieldHandle | undefined;
27
27
  onShielded?: () => Promise<void> | void;
28
+ onShieldDispatched?: (info: {
29
+ token: TokenBalance;
30
+ amount: bigint;
31
+ }) => void;
28
32
  };
29
33
  /**
30
34
  * On Aleo wallet load (and on each subsequent unshielded-balance refresh),
@@ -66,5 +70,5 @@ export type UseAleoAutoShieldSponsoredTokensResult = {
66
70
  */
67
71
  currentlyShieldingTokenKeys: ReadonlySet<string>;
68
72
  };
69
- export declare const useAleoAutoShieldSponsoredTokens: ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, }: UseAleoAutoShieldSponsoredTokensArgs) => UseAleoAutoShieldSponsoredTokensResult;
73
+ export declare const useAleoAutoShieldSponsoredTokens: ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, onShieldDispatched, }: UseAleoAutoShieldSponsoredTokensArgs) => UseAleoAutoShieldSponsoredTokensResult;
70
74
  export {};
@@ -43,7 +43,7 @@ const buildShieldCandidates = (args) => {
43
43
  */
44
44
  const tryShieldOneToken = (token, deps) => __awaiter(void 0, void 0, void 0, function* () {
45
45
  var _a, _b, _c;
46
- const { accountAddress, shieldHandle, seenKeys, isCancelled, inFlightTokenKeys, } = deps;
46
+ const { accountAddress, shieldHandle, seenKeys, isCancelled, inFlightTokenKeys, onShieldDispatched, } = deps;
47
47
  const tokenKey = buildTokenKey(token) || nativeTokenKey;
48
48
  const key = `${accountAddress}:${tokenKey}`;
49
49
  seenKeys.add(key);
@@ -76,9 +76,19 @@ const tryShieldOneToken = (token, deps) => __awaiter(void 0, void 0, void 0, fun
76
76
  isNative: token.isNative,
77
77
  tokenAddress: token.address,
78
78
  });
79
+ // Optimistic-UI hand-off: notify the consumer the broadcast was
80
+ // accepted so it can deduct the unshielded balance locally and
81
+ // prepend a synthesised shielded row. Synchronous and best-effort;
82
+ // failures inside the callback don't roll back the shield.
83
+ try {
84
+ onShieldDispatched === null || onShieldDispatched === void 0 ? void 0 : onShieldDispatched({ amount: atomic, token });
85
+ }
86
+ catch (_e) {
87
+ /* swallow — optimistic hand-off is best-effort */
88
+ }
79
89
  return true;
80
90
  }
81
- catch (_e) {
91
+ catch (_f) {
82
92
  seenKeys.delete(key);
83
93
  return false;
84
94
  }
@@ -86,7 +96,7 @@ const tryShieldOneToken = (token, deps) => __awaiter(void 0, void 0, void 0, fun
86
96
  inFlightTokenKeys === null || inFlightTokenKeys === void 0 ? void 0 : inFlightTokenKeys.delete(tokenKey);
87
97
  }
88
98
  });
89
- const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, }) => {
99
+ const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalances, shieldHandle, onShielded, onShieldDispatched, }) => {
90
100
  // Tracks `(accountAddress:tokenAddress)` we've already attempted in this
91
101
  // session. Cleared implicitly on a full page reload.
92
102
  const seenKeysRef = useRef(new Set());
@@ -214,6 +224,7 @@ const useAleoAutoShieldSponsoredTokens = ({ accountAddress, unshieldedTokenBalan
214
224
  accountAddress,
215
225
  inFlightTokenKeys: inFlightKeysAdapter,
216
226
  isCancelled,
227
+ onShieldDispatched,
217
228
  seenKeys: seenKeysRef.current,
218
229
  shieldHandle,
219
230
  });
@@ -173,6 +173,12 @@ const buildCreditsBalance = (records, networkId, lookupCurated) => {
173
173
  if (creditsRecords.length === 0)
174
174
  return undefined;
175
175
  const totalMicrocredits = creditsRecords.reduce((sum, r) => sum + BigInt(r.microcredits), BigInt(0));
176
+ // Skip the row entirely when every credits record summed to zero
177
+ // (typically partially-spent change records the indexer hasn't
178
+ // pruned yet). A "0 ALEO" entry in the Shielded tab is just noise
179
+ // the user can't act on.
180
+ if (totalMicrocredits === BigInt(0))
181
+ return undefined;
176
182
  // BigInt → number for the TokenBalance shape. Aleo balances stay well
177
183
  // below Number.MAX_SAFE_INTEGER for a single wallet (max u64 supply is
178
184
  // 1.5B credits = 1.5e15 microcredits; Number can hold up to ~9e15).
@@ -227,6 +233,14 @@ const buildTokenBalances = (records, networkId, lookupCurated) => {
227
233
  const spec = specsByContract.get(contractAddress);
228
234
  if (!spec)
229
235
  continue;
236
+ // Skip tokens whose every matched record summed to zero. Provable
237
+ // occasionally surfaces serialized records with `amount: 0u128`
238
+ // (e.g. partially-spent change records that haven't been pruned by
239
+ // the indexer yet); without this filter the Shielded tab shows a
240
+ // row with "0 USAD" / "0 USDCx" that the user can't act on, which
241
+ // is just noise.
242
+ if (total === BigInt(0))
243
+ continue;
230
244
  const rawBalance = Number(total);
231
245
  const rawBalanceString = total.toString();
232
246
  const balance = rawBalance / Math.pow(10, spec.decimals);
@@ -169,6 +169,12 @@ const buildCreditsBalance = (records, networkId, lookupCurated) => {
169
169
  if (creditsRecords.length === 0)
170
170
  return undefined;
171
171
  const totalMicrocredits = creditsRecords.reduce((sum, r) => sum + BigInt(r.microcredits), BigInt(0));
172
+ // Skip the row entirely when every credits record summed to zero
173
+ // (typically partially-spent change records the indexer hasn't
174
+ // pruned yet). A "0 ALEO" entry in the Shielded tab is just noise
175
+ // the user can't act on.
176
+ if (totalMicrocredits === BigInt(0))
177
+ return undefined;
172
178
  // BigInt → number for the TokenBalance shape. Aleo balances stay well
173
179
  // below Number.MAX_SAFE_INTEGER for a single wallet (max u64 supply is
174
180
  // 1.5B credits = 1.5e15 microcredits; Number can hold up to ~9e15).
@@ -223,6 +229,14 @@ const buildTokenBalances = (records, networkId, lookupCurated) => {
223
229
  const spec = specsByContract.get(contractAddress);
224
230
  if (!spec)
225
231
  continue;
232
+ // Skip tokens whose every matched record summed to zero. Provable
233
+ // occasionally surfaces serialized records with `amount: 0u128`
234
+ // (e.g. partially-spent change records that haven't been pruned by
235
+ // the indexer yet); without this filter the Shielded tab shows a
236
+ // row with "0 USAD" / "0 USDCx" that the user can't act on, which
237
+ // is just noise.
238
+ if (total === BigInt(0))
239
+ continue;
226
240
  const rawBalance = Number(total);
227
241
  const rawBalanceString = total.toString();
228
242
  const balance = rawBalance / Math.pow(10, spec.decimals);
@@ -0,0 +1,2 @@
1
+ export { usePrivateTokenBalances } from './usePrivateTokenBalances';
2
+ export type { UsePrivateTokenBalancesReturn } from './usePrivateTokenBalances';
@@ -0,0 +1,19 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var useAleoShieldedBalances = require('../useAleoShieldedBalances/useAleoShieldedBalances.cjs');
7
+
8
+ const usePrivateTokenBalances = () => {
9
+ const { tokenBalances, isLoading, error, refetch, supportsShielded } = useAleoShieldedBalances.useAleoShieldedBalances();
10
+ return {
11
+ error,
12
+ isLoading,
13
+ refetch,
14
+ supportsPrivateBalances: supportsShielded,
15
+ tokenBalances,
16
+ };
17
+ };
18
+
19
+ exports.usePrivateTokenBalances = usePrivateTokenBalances;
@@ -0,0 +1,9 @@
1
+ import { TokenBalance } from '@dynamic-labs/sdk-api-core';
2
+ export type UsePrivateTokenBalancesReturn = {
3
+ tokenBalances: TokenBalance[];
4
+ isLoading: boolean;
5
+ error: string | undefined;
6
+ refetch: () => Promise<void>;
7
+ supportsPrivateBalances: boolean;
8
+ };
9
+ export declare const usePrivateTokenBalances: () => UsePrivateTokenBalancesReturn;