@dynamic-labs/sdk-react-core 4.84.0 → 4.85.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 +35 -1
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +14 -14
- package/src/index.cjs +2 -0
- package/src/index.d.ts +2 -2
- package/src/index.js +1 -0
- package/src/lib/components/SendBalanceForm/SendBalanceForm.cjs +26 -1
- package/src/lib/components/SendBalanceForm/SendBalanceForm.js +26 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.cjs +6 -1
- package/src/lib/components/SendBalancePageLayout/SendBalancePageLayout.js +6 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.cjs +5 -1
- package/src/lib/components/SendBalancePageLayout/components/TokensBalanceDropdown/TokensBalanceDropdown.js +5 -1
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.cjs +2 -6
- package/src/lib/context/OnrampContext/utils/getOnrampProviders.js +4 -8
- package/src/lib/data/api/onramp/onramp.cjs +26 -1
- package/src/lib/data/api/onramp/onramp.d.ts +11 -1
- package/src/lib/data/api/onramp/onramp.js +26 -1
- package/src/lib/utils/functions/onrampProviders/index.cjs +1 -0
- package/src/lib/utils/functions/onrampProviders/index.js +1 -0
- package/src/lib/utils/hooks/index.d.ts +2 -0
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.cjs +24 -4
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.d.ts +10 -2
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/pollOnShielded.js +24 -4
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.cjs +14 -3
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.d.ts +5 -1
- package/src/lib/utils/hooks/useAleoAutoShieldSponsoredTokens/useAleoAutoShieldSponsoredTokens.js +14 -3
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.cjs +95 -10
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.d.ts +18 -2
- package/src/lib/utils/hooks/useAleoShieldedBalances/useAleoShieldedBalances.js +96 -11
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +4 -4
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +4 -4
- package/src/lib/utils/hooks/usePrivateTokenBalances/index.d.ts +2 -0
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.cjs +27 -0
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.d.ts +24 -0
- package/src/lib/utils/hooks/usePrivateTokenBalances/usePrivateTokenBalances.js +23 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.cjs +60 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.d.ts +29 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/instrumentWalletCreation.js +55 -0
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.cjs +14 -24
- package/src/lib/utils/hooks/useSyncDynamicWaas/useSyncDynamicWaas.js +14 -24
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.cjs +19 -16
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.d.ts +8 -0
- package/src/lib/utils/hooks/useWalletDelegation/useWalletDelegation.js +19 -17
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +17 -1
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +17 -1
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.cjs +138 -21
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/ActiveWalletBalance.js +139 -22
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.cjs +150 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.d.ts +74 -0
- package/src/lib/widgets/DynamicWidget/components/ActiveWalletBalance/optimisticShield.js +143 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.85.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.84.1...v4.85.0) (2026-05-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **moonpay:** add getMoonPayCurrencies API, MOONPAY_PROVIDER_ID, and chain enum fix ([#11362](https://github.com/dynamic-labs/dynamic-auth/issues/11362)) ([8f1c841](https://github.com/dynamic-labs/dynamic-auth/commit/8f1c841dcab3249e82a7152be373c0e0204a2f47))
|
|
8
|
+
* **sdk-react-core:** extend usePrivateTokenBalances with `accountAddress`, `tokenAddresses`, `includeNativeBalance`, `includeFiat` ([#11380](https://github.com/dynamic-labs/dynamic-auth/issues/11380)) ([ccb6d47](https://github.com/dynamic-labs/dynamic-auth/commit/ccb6d47b4683a12a13aaf8311ecffae3d46464a3))
|
|
9
|
+
* **sdk-react-core:** forward `chainName` + `networkId` through `usePrivateTokenBalances` ([#11383](https://github.com/dynamic-labs/dynamic-auth/issues/11383)) ([c2ad110](https://github.com/dynamic-labs/dynamic-auth/commit/c2ad1103d4d4fdba67fc9b50b60945a843adae99))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* **aleo:** drop optimistically deducted unshielded rows when balance hits zero ([#11371](https://github.com/dynamic-labs/dynamic-auth/issues/11371)) ([a3bb8e8](https://github.com/dynamic-labs/dynamic-auth/commit/a3bb8e8fa7e877340c829c991ba31eeb8fa4fcf1)), closes [#11337](https://github.com/dynamic-labs/dynamic-auth/issues/11337)
|
|
15
|
+
* **aleo:** re-read gas sponsored flag after async fetchFee resolves ([#11375](https://github.com/dynamic-labs/dynamic-auth/issues/11375)) ([d27e74a](https://github.com/dynamic-labs/dynamic-auth/commit/d27e74a309aff18eb6b18046fe34e9e64363d331))
|
|
16
|
+
* remediate high-severity dependency vulnerabilities ([#11339](https://github.com/dynamic-labs/dynamic-auth/issues/11339)) ([f025b30](https://github.com/dynamic-labs/dynamic-auth/commit/f025b308e29153de49c88d91233139bb00caaf4e))
|
|
17
|
+
* **waas:** guard upgradeToDynamicWaas on the wallet arg, not primaryWallet ([#11324](https://github.com/dynamic-labs/dynamic-auth/issues/11324)) ([3e95eaf](https://github.com/dynamic-labs/dynamic-auth/commit/3e95eaf50afd2f49ff1cc416e5bf211ee04fbb23))
|
|
18
|
+
|
|
19
|
+
### [4.84.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.84.0...v4.84.1) (2026-05-28)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Features
|
|
23
|
+
|
|
24
|
+
* **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))
|
|
25
|
+
* **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))
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **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))
|
|
31
|
+
* **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))
|
|
32
|
+
* **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))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
2
36
|
## [4.84.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.83.2-alpha.0...v4.84.0) (2026-05-22)
|
|
3
37
|
|
|
4
38
|
|
|
@@ -6522,4 +6556,4 @@ Enjoy!
|
|
|
6522
6556
|
* setPrimaryWallet and useSyncPrimaryWallet updates ([#2128](https://github.com/dynamic-labs/DynamicAuth/issues/2128)) ([fb47b17](https://github.com/dynamic-labs/DynamicAuth/commit/fb47b17ddc7f41c29f140a1a85a1e47dbf017fff))
|
|
6523
6557
|
* 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
6558
|
|
|
6525
|
-
## [0.17.0-RC.16](https://github.com/dynamic-labs/Dyna
|
|
6559
|
+
## [0.17.0-RC.16](https://github.com/dynamic-labs/Dyna
|
package/package.cjs
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "4.
|
|
6
|
+
var version = "4.85.0";
|
|
7
7
|
var dependencies = {
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "0.0.985",
|
|
9
9
|
"@dynamic-labs-sdk/client": "1.1.0",
|
|
10
|
-
"@dynamic-labs-wallet/browser-wallet-client": "
|
|
11
|
-
"@dynamic-labs-wallet/forward-mpc-client": "0.
|
|
10
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.0.7",
|
|
11
|
+
"@dynamic-labs-wallet/forward-mpc-client": "0.10.1",
|
|
12
12
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
13
13
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
14
14
|
"country-list": "2.3.0",
|
package/package.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.
|
|
2
|
+
var version = "4.85.0";
|
|
3
3
|
var dependencies = {
|
|
4
4
|
"@dynamic-labs/sdk-api-core": "0.0.985",
|
|
5
5
|
"@dynamic-labs-sdk/client": "1.1.0",
|
|
6
|
-
"@dynamic-labs-wallet/browser-wallet-client": "
|
|
7
|
-
"@dynamic-labs-wallet/forward-mpc-client": "0.
|
|
6
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.0.7",
|
|
7
|
+
"@dynamic-labs-wallet/forward-mpc-client": "0.10.1",
|
|
8
8
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
9
9
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
10
10
|
"country-list": "2.3.0",
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.85.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.985",
|
|
6
6
|
"@dynamic-labs-sdk/client": "1.1.0",
|
|
7
|
-
"@dynamic-labs-wallet/browser-wallet-client": "
|
|
8
|
-
"@dynamic-labs-wallet/forward-mpc-client": "0.
|
|
7
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.0.7",
|
|
8
|
+
"@dynamic-labs-wallet/forward-mpc-client": "0.10.1",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
11
11
|
"country-list": "2.3.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.
|
|
21
|
-
"@dynamic-labs/iconic": "4.
|
|
22
|
-
"@dynamic-labs/locale": "4.
|
|
23
|
-
"@dynamic-labs/logger": "4.
|
|
24
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
26
|
-
"@dynamic-labs/store": "4.
|
|
27
|
-
"@dynamic-labs/types": "4.
|
|
28
|
-
"@dynamic-labs/utils": "4.
|
|
29
|
-
"@dynamic-labs/wallet-book": "4.
|
|
30
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
20
|
+
"@dynamic-labs/assert-package-version": "4.85.0",
|
|
21
|
+
"@dynamic-labs/iconic": "4.85.0",
|
|
22
|
+
"@dynamic-labs/locale": "4.85.0",
|
|
23
|
+
"@dynamic-labs/logger": "4.85.0",
|
|
24
|
+
"@dynamic-labs/multi-wallet": "4.85.0",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "4.85.0",
|
|
26
|
+
"@dynamic-labs/store": "4.85.0",
|
|
27
|
+
"@dynamic-labs/types": "4.85.0",
|
|
28
|
+
"@dynamic-labs/utils": "4.85.0",
|
|
29
|
+
"@dynamic-labs/wallet-book": "4.85.0",
|
|
30
|
+
"@dynamic-labs/wallet-connector-core": "4.85.0",
|
|
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, UsePrivateTokenBalancesArgs, 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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
@@ -123,7 +123,11 @@ require('../../../Popper/PopperContext/PopperContext.cjs');
|
|
|
123
123
|
const TokensBalanceDropdown = ({ tokenBalances, currentToken, setCurrentToken, isLoading, setFieldValue, setErrors, }) => {
|
|
124
124
|
const { t } = reactI18next.useTranslation();
|
|
125
125
|
const [isDropdownOpen, setIsDropdownOpen] = React.useState(false);
|
|
126
|
-
|
|
126
|
+
// Hide rows the user can't actually send from: anonymous tokens (no
|
|
127
|
+
// `name` set — usually a server-side data hole) and tokens whose
|
|
128
|
+
// on-chain balance is non-positive. The picker is a "pick what to
|
|
129
|
+
// send" affordance, so an entry the user can't pick is just noise.
|
|
130
|
+
const filteredTokenBalances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => { var _a; return token.name && ((_a = token.rawBalance) !== null && _a !== void 0 ? _a : 0) > 0; })) || [];
|
|
127
131
|
const { primaryWallet } = useInternalDynamicContext.useInternalDynamicContext();
|
|
128
132
|
const anchorRef = React.useRef(null);
|
|
129
133
|
const fetchTokenData = (selectedToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -119,7 +119,11 @@ import '../../../Popper/PopperContext/PopperContext.js';
|
|
|
119
119
|
const TokensBalanceDropdown = ({ tokenBalances, currentToken, setCurrentToken, isLoading, setFieldValue, setErrors, }) => {
|
|
120
120
|
const { t } = useTranslation();
|
|
121
121
|
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
|
|
122
|
-
|
|
122
|
+
// Hide rows the user can't actually send from: anonymous tokens (no
|
|
123
|
+
// `name` set — usually a server-side data hole) and tokens whose
|
|
124
|
+
// on-chain balance is non-positive. The picker is a "pick what to
|
|
125
|
+
// send" affordance, so an entry the user can't pick is just noise.
|
|
126
|
+
const filteredTokenBalances = (tokenBalances === null || tokenBalances === void 0 ? void 0 : tokenBalances.filter((token) => { var _a; return token.name && ((_a = token.rawBalance) !== null && _a !== void 0 ? _a : 0) > 0; })) || [];
|
|
123
127
|
const { primaryWallet } = useInternalDynamicContext();
|
|
124
128
|
const anchorRef = useRef(null);
|
|
125
129
|
const fetchTokenData = (selectedToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -9,18 +9,14 @@ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
|
9
9
|
var onramp = require('../../../data/api/onramp/onramp.cjs');
|
|
10
10
|
var getWalletAdditionalAddressByType = require('../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.cjs');
|
|
11
11
|
|
|
12
|
-
const DEFAULT_NETWORK = 'evm';
|
|
13
12
|
const DEFAULT_CHAIN = '1';
|
|
14
13
|
const getOnrampProviders = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, merchantName, }) {
|
|
15
14
|
var _b;
|
|
16
|
-
const
|
|
17
|
-
? (_b = walletConnectorCore.getChainInfo(primaryWallet.chain)) === null || _b === void 0 ? void 0 : _b.name
|
|
18
|
-
: undefined;
|
|
19
|
-
const chainNameToUse = chainName !== null && chainName !== void 0 ? chainName : tempChainNameToUse;
|
|
15
|
+
const chainNameToUse = (_b = chainName !== null && chainName !== void 0 ? chainName : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== null && _b !== void 0 ? _b : undefined;
|
|
20
16
|
const bitcoinAddress = primaryWallet &&
|
|
21
17
|
walletConnectorCore.isBitcoinConnector(primaryWallet.connector) &&
|
|
22
18
|
getWalletAdditionalAddressByType.getWalletAdditionalAddressByType(sdkApiCore.WalletAddressType.Payment, primaryWallet);
|
|
23
|
-
const chainHasNetwork = network && chainNameToUse ===
|
|
19
|
+
const chainHasNetwork = network && chainNameToUse === sdkApiCore.ChainEnum.Evm;
|
|
24
20
|
let networkToUse;
|
|
25
21
|
if (chainHasNetwork) {
|
|
26
22
|
networkToUse = (network === null || network === void 0 ? void 0 : network.toString()) || DEFAULT_CHAIN;
|
|
@@ -1,22 +1,18 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { WalletAddressType } from '@dynamic-labs/sdk-api-core';
|
|
4
|
-
import {
|
|
3
|
+
import { WalletAddressType, ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { isBitcoinConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { getOnrampProviders as getOnrampProviders$1 } from '../../../data/api/onramp/onramp.js';
|
|
6
6
|
import { getWalletAdditionalAddressByType } from '../../../utils/functions/getWalletAdditionalAddressByType/getWalletAdditionalAddressByType.js';
|
|
7
7
|
|
|
8
|
-
const DEFAULT_NETWORK = 'evm';
|
|
9
8
|
const DEFAULT_CHAIN = '1';
|
|
10
9
|
const getOnrampProviders = (_a) => __awaiter(void 0, [_a], void 0, function* ({ address, chainName, environmentId, network, primaryWallet, token, tokenAmount, currency, includeDisabled = false, merchantName, }) {
|
|
11
10
|
var _b;
|
|
12
|
-
const
|
|
13
|
-
? (_b = getChainInfo(primaryWallet.chain)) === null || _b === void 0 ? void 0 : _b.name
|
|
14
|
-
: undefined;
|
|
15
|
-
const chainNameToUse = chainName !== null && chainName !== void 0 ? chainName : tempChainNameToUse;
|
|
11
|
+
const chainNameToUse = (_b = chainName !== null && chainName !== void 0 ? chainName : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.chain) !== null && _b !== void 0 ? _b : undefined;
|
|
16
12
|
const bitcoinAddress = primaryWallet &&
|
|
17
13
|
isBitcoinConnector(primaryWallet.connector) &&
|
|
18
14
|
getWalletAdditionalAddressByType(WalletAddressType.Payment, primaryWallet);
|
|
19
|
-
const chainHasNetwork = network && chainNameToUse ===
|
|
15
|
+
const chainHasNetwork = network && chainNameToUse === ChainEnum.Evm;
|
|
20
16
|
let networkToUse;
|
|
21
17
|
if (chainHasNetwork) {
|
|
22
18
|
networkToUse = (network === null || network === void 0 ? void 0 : network.toString()) || DEFAULT_CHAIN;
|
|
@@ -4,9 +4,34 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
8
|
+
require('@dynamic-labs-sdk/client/core');
|
|
9
|
+
require('@dynamic-labs/sdk-api-core');
|
|
10
|
+
require('react');
|
|
11
|
+
require('eventemitter3');
|
|
12
|
+
require('@dynamic-labs/utils');
|
|
13
|
+
require('@dynamic-labs-sdk/client');
|
|
14
|
+
require('@dynamic-labs/iconic');
|
|
15
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
16
|
+
require('react/jsx-runtime');
|
|
17
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
18
|
+
require('../../../shared/logger.cjs');
|
|
19
|
+
require('@dynamic-labs/wallet-book');
|
|
20
|
+
require('../../../utils/constants/colors.cjs');
|
|
21
|
+
require('../../../utils/constants/values.cjs');
|
|
22
|
+
require('../../../shared/consts/index.cjs');
|
|
23
|
+
require('@dynamic-labs/multi-wallet');
|
|
24
|
+
require('react-international-phone');
|
|
25
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
7
26
|
var api = require('../api.cjs');
|
|
27
|
+
require('@dynamic-labs/locale');
|
|
28
|
+
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
30
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
31
|
+
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
32
|
+
require('../../../events/dynamicEvents.cjs');
|
|
8
33
|
|
|
9
|
-
const getOnrampProviders = (
|
|
34
|
+
const getOnrampProviders = (_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ chain, environmentId, networkId, token, tokenAmount, walletAddress, currency, includeDisabled, merchantName, }) {
|
|
10
35
|
const { onramps } = yield api.sdkApi().getSupportedOnramps({
|
|
11
36
|
chain,
|
|
12
37
|
currency,
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
import { RampConfiguration } from '@dynamic-labs/sdk-api-core';
|
|
1
|
+
import { ChainEnum, RampConfiguration } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
export type MoonPayCurrency = {
|
|
3
|
+
code: string;
|
|
4
|
+
icon: string;
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
export declare const getMoonPayCurrencies: ({ chain, environmentId, networkId, }: {
|
|
8
|
+
chain: ChainEnum;
|
|
9
|
+
environmentId: string;
|
|
10
|
+
networkId?: string;
|
|
11
|
+
}) => Promise<MoonPayCurrency[]>;
|
|
2
12
|
export declare const getOnrampProviders: ({ chain, environmentId, networkId, token, tokenAmount, walletAddress, currency, includeDisabled, merchantName, }: {
|
|
3
13
|
chain: string;
|
|
4
14
|
environmentId: string;
|
|
@@ -1,8 +1,33 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import '../../../config/ApiEndpoint.js';
|
|
4
|
+
import '@dynamic-labs-sdk/client/core';
|
|
5
|
+
import '@dynamic-labs/sdk-api-core';
|
|
6
|
+
import 'react';
|
|
7
|
+
import 'eventemitter3';
|
|
8
|
+
import '@dynamic-labs/utils';
|
|
9
|
+
import '@dynamic-labs-sdk/client';
|
|
10
|
+
import '@dynamic-labs/iconic';
|
|
11
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
12
|
+
import 'react/jsx-runtime';
|
|
13
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
14
|
+
import '../../../shared/logger.js';
|
|
15
|
+
import '@dynamic-labs/wallet-book';
|
|
16
|
+
import '../../../utils/constants/colors.js';
|
|
17
|
+
import '../../../utils/constants/values.js';
|
|
18
|
+
import '../../../shared/consts/index.js';
|
|
19
|
+
import '@dynamic-labs/multi-wallet';
|
|
20
|
+
import 'react-international-phone';
|
|
21
|
+
import '../../../store/state/nonce/nonce.js';
|
|
3
22
|
import { sdkApi } from '../api.js';
|
|
23
|
+
import '@dynamic-labs/locale';
|
|
24
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
26
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
27
|
+
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
28
|
+
import '../../../events/dynamicEvents.js';
|
|
4
29
|
|
|
5
|
-
const getOnrampProviders = (
|
|
30
|
+
const getOnrampProviders = (_c) => __awaiter(void 0, [_c], void 0, function* ({ chain, environmentId, networkId, token, tokenAmount, walletAddress, currency, includeDisabled, merchantName, }) {
|
|
6
31
|
const { onramps } = yield sdkApi().getSupportedOnramps({
|
|
7
32
|
chain,
|
|
8
33
|
currency,
|
|
@@ -15,6 +15,7 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
|
15
15
|
const providerDisplayModes = {
|
|
16
16
|
[sdkApiCore.ProviderEnum.CoinbaseOnramp]: 'popup',
|
|
17
17
|
[sdkApiCore.ProviderEnum.CryptoDotCom]: 'popup',
|
|
18
|
+
[sdkApiCore.ProviderEnum.MoonPay]: 'popup',
|
|
18
19
|
// Default for other providers is iframe
|
|
19
20
|
};
|
|
20
21
|
|
|
@@ -11,6 +11,7 @@ import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
|
11
11
|
const providerDisplayModes = {
|
|
12
12
|
[ProviderEnum.CoinbaseOnramp]: 'popup',
|
|
13
13
|
[ProviderEnum.CryptoDotCom]: 'popup',
|
|
14
|
+
[ProviderEnum.MoonPay]: 'popup',
|
|
14
15
|
// Default for other providers is iframe
|
|
15
16
|
};
|
|
16
17
|
|
|
@@ -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 { UsePrivateTokenBalancesArgs, 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
|
|
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
|
|
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
|
|
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>;
|