@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ChainEnum, TokenBalance } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
/**
|
|
3
|
+
* Optional inputs that intentionally mirror the corresponding
|
|
4
|
+
* `useTokenBalances` params so callers can move between the public
|
|
5
|
+
* and private hooks with minimal call-site changes. Boolean defaults
|
|
6
|
+
* match `useTokenBalances` (`includeNativeBalance: false`,
|
|
7
|
+
* `includeFiat: false`) — opt in explicitly when you want either.
|
|
8
|
+
*/
|
|
9
|
+
export type UsePrivateTokenBalancesArgs = {
|
|
10
|
+
accountAddress?: string;
|
|
11
|
+
tokenAddresses?: string[];
|
|
12
|
+
includeNativeBalance?: boolean;
|
|
13
|
+
includeFiat?: boolean;
|
|
14
|
+
chainName?: ChainEnum;
|
|
15
|
+
networkId?: number;
|
|
16
|
+
};
|
|
17
|
+
export type UsePrivateTokenBalancesReturn = {
|
|
18
|
+
tokenBalances: TokenBalance[];
|
|
19
|
+
isLoading: boolean;
|
|
20
|
+
error: string | undefined;
|
|
21
|
+
refetch: () => Promise<void>;
|
|
22
|
+
supportsPrivateBalances: boolean;
|
|
23
|
+
};
|
|
24
|
+
export declare const usePrivateTokenBalances: (args?: UsePrivateTokenBalancesArgs) => UsePrivateTokenBalancesReturn;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useAleoShieldedBalances } from '../useAleoShieldedBalances/useAleoShieldedBalances.js';
|
|
3
|
+
|
|
4
|
+
const usePrivateTokenBalances = (args = {}) => {
|
|
5
|
+
const { accountAddress, tokenAddresses, includeNativeBalance = false, includeFiat = false, chainName, networkId, } = args;
|
|
6
|
+
const { tokenBalances, isLoading, error, refetch, supportsShielded } = useAleoShieldedBalances({
|
|
7
|
+
accountAddress,
|
|
8
|
+
chainName,
|
|
9
|
+
includeFiat,
|
|
10
|
+
includeNativeBalance,
|
|
11
|
+
networkId,
|
|
12
|
+
tokenAddresses,
|
|
13
|
+
});
|
|
14
|
+
return {
|
|
15
|
+
error,
|
|
16
|
+
isLoading,
|
|
17
|
+
refetch,
|
|
18
|
+
supportsPrivateBalances: supportsShielded,
|
|
19
|
+
tokenBalances,
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { usePrivateTokenBalances };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
require('@dynamic-labs/iconic');
|
|
8
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
9
|
+
require('react');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
var logger = require('../../../shared/logger.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('@dynamic-labs/utils');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
require('@dynamic-labs/sdk-api-core');
|
|
18
|
+
require('../../../shared/consts/index.cjs');
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Soft watchdog for the embedded-wallet auto-creation ceremony. Long enough to
|
|
22
|
+
* clear a healthy MPC ceremony (observed ~7s, iframe load timeout is 10s) so a
|
|
23
|
+
* fire here means the flow genuinely stalled rather than just being slow.
|
|
24
|
+
*/
|
|
25
|
+
const AUTO_WALLET_CREATION_TIMEOUT_MS = 30000;
|
|
26
|
+
/**
|
|
27
|
+
* Wraps the auto-wallet-creation ceremony so that "silent" failures carry a
|
|
28
|
+
* reason. Without this, a ceremony that hangs (promise never settles) or a user
|
|
29
|
+
* who navigates away mid-flow produces an `initiated` log with no `success` or
|
|
30
|
+
* `failed` counterpart, leaving the failure undiagnosable.
|
|
31
|
+
*
|
|
32
|
+
* Emits:
|
|
33
|
+
* - `auto_wallet_creation_timeout` if `run` has not settled within `timeoutMs`.
|
|
34
|
+
* - `auto_wallet_creation_abandoned` if the page is hidden while `run` is still
|
|
35
|
+
* in flight (relies on the logger's keepalive transport to survive unload).
|
|
36
|
+
*
|
|
37
|
+
* The watchdog is observational: it never aborts `run`, and its return value /
|
|
38
|
+
* rejection is passed through unchanged.
|
|
39
|
+
*/
|
|
40
|
+
const instrumentWalletCreation = (_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ run, logData, timeoutMs = AUTO_WALLET_CREATION_TIMEOUT_MS, }) {
|
|
41
|
+
var _b, _c;
|
|
42
|
+
const startTime = Date.now();
|
|
43
|
+
const timeoutId = setTimeout(() => {
|
|
44
|
+
logger.logger.instrument('Auto wallet creation timed out', Object.assign(Object.assign({}, logData), { key: 'auto_wallet_creation_timeout', reason: 'timeout', time: Date.now() - startTime }));
|
|
45
|
+
}, timeoutMs);
|
|
46
|
+
const handlePageHide = () => {
|
|
47
|
+
logger.logger.instrument('Auto wallet creation abandoned', Object.assign(Object.assign({}, logData), { key: 'auto_wallet_creation_abandoned', reason: 'page_hidden', time: Date.now() - startTime }));
|
|
48
|
+
};
|
|
49
|
+
(_b = globalThis.addEventListener) === null || _b === void 0 ? void 0 : _b.call(globalThis, 'pagehide', handlePageHide);
|
|
50
|
+
try {
|
|
51
|
+
return yield run();
|
|
52
|
+
}
|
|
53
|
+
finally {
|
|
54
|
+
clearTimeout(timeoutId);
|
|
55
|
+
(_c = globalThis.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(globalThis, 'pagehide', handlePageHide);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
exports.AUTO_WALLET_CREATION_TIMEOUT_MS = AUTO_WALLET_CREATION_TIMEOUT_MS;
|
|
60
|
+
exports.instrumentWalletCreation = instrumentWalletCreation;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Soft watchdog for the embedded-wallet auto-creation ceremony. Long enough to
|
|
3
|
+
* clear a healthy MPC ceremony (observed ~7s, iframe load timeout is 10s) so a
|
|
4
|
+
* fire here means the flow genuinely stalled rather than just being slow.
|
|
5
|
+
*/
|
|
6
|
+
export declare const AUTO_WALLET_CREATION_TIMEOUT_MS = 30000;
|
|
7
|
+
type InstrumentWalletCreationArgs<T> = {
|
|
8
|
+
/** The wallet-creation work to run and observe (the MPC ceremony). */
|
|
9
|
+
run: () => Promise<T>;
|
|
10
|
+
/** Shared fields attached to every emitted event (chains, env, user). */
|
|
11
|
+
logData: Record<string, unknown>;
|
|
12
|
+
timeoutMs?: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Wraps the auto-wallet-creation ceremony so that "silent" failures carry a
|
|
16
|
+
* reason. Without this, a ceremony that hangs (promise never settles) or a user
|
|
17
|
+
* who navigates away mid-flow produces an `initiated` log with no `success` or
|
|
18
|
+
* `failed` counterpart, leaving the failure undiagnosable.
|
|
19
|
+
*
|
|
20
|
+
* Emits:
|
|
21
|
+
* - `auto_wallet_creation_timeout` if `run` has not settled within `timeoutMs`.
|
|
22
|
+
* - `auto_wallet_creation_abandoned` if the page is hidden while `run` is still
|
|
23
|
+
* in flight (relies on the logger's keepalive transport to survive unload).
|
|
24
|
+
*
|
|
25
|
+
* The watchdog is observational: it never aborts `run`, and its return value /
|
|
26
|
+
* rejection is passed through unchanged.
|
|
27
|
+
*/
|
|
28
|
+
export declare const instrumentWalletCreation: <T>({ run, logData, timeoutMs, }: InstrumentWalletCreationArgs<T>) => Promise<T>;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import '@dynamic-labs/iconic';
|
|
4
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import 'react';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import { logger } from '../../../shared/logger.js';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '@dynamic-labs/utils';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import '@dynamic-labs/sdk-api-core';
|
|
14
|
+
import '../../../shared/consts/index.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Soft watchdog for the embedded-wallet auto-creation ceremony. Long enough to
|
|
18
|
+
* clear a healthy MPC ceremony (observed ~7s, iframe load timeout is 10s) so a
|
|
19
|
+
* fire here means the flow genuinely stalled rather than just being slow.
|
|
20
|
+
*/
|
|
21
|
+
const AUTO_WALLET_CREATION_TIMEOUT_MS = 30000;
|
|
22
|
+
/**
|
|
23
|
+
* Wraps the auto-wallet-creation ceremony so that "silent" failures carry a
|
|
24
|
+
* reason. Without this, a ceremony that hangs (promise never settles) or a user
|
|
25
|
+
* who navigates away mid-flow produces an `initiated` log with no `success` or
|
|
26
|
+
* `failed` counterpart, leaving the failure undiagnosable.
|
|
27
|
+
*
|
|
28
|
+
* Emits:
|
|
29
|
+
* - `auto_wallet_creation_timeout` if `run` has not settled within `timeoutMs`.
|
|
30
|
+
* - `auto_wallet_creation_abandoned` if the page is hidden while `run` is still
|
|
31
|
+
* in flight (relies on the logger's keepalive transport to survive unload).
|
|
32
|
+
*
|
|
33
|
+
* The watchdog is observational: it never aborts `run`, and its return value /
|
|
34
|
+
* rejection is passed through unchanged.
|
|
35
|
+
*/
|
|
36
|
+
const instrumentWalletCreation = (_a) => __awaiter(void 0, [_a], void 0, function* ({ run, logData, timeoutMs = AUTO_WALLET_CREATION_TIMEOUT_MS, }) {
|
|
37
|
+
var _b, _c;
|
|
38
|
+
const startTime = Date.now();
|
|
39
|
+
const timeoutId = setTimeout(() => {
|
|
40
|
+
logger.instrument('Auto wallet creation timed out', Object.assign(Object.assign({}, logData), { key: 'auto_wallet_creation_timeout', reason: 'timeout', time: Date.now() - startTime }));
|
|
41
|
+
}, timeoutMs);
|
|
42
|
+
const handlePageHide = () => {
|
|
43
|
+
logger.instrument('Auto wallet creation abandoned', Object.assign(Object.assign({}, logData), { key: 'auto_wallet_creation_abandoned', reason: 'page_hidden', time: Date.now() - startTime }));
|
|
44
|
+
};
|
|
45
|
+
(_b = globalThis.addEventListener) === null || _b === void 0 ? void 0 : _b.call(globalThis, 'pagehide', handlePageHide);
|
|
46
|
+
try {
|
|
47
|
+
return yield run();
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
(_c = globalThis.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(globalThis, 'pagehide', handlePageHide);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export { AUTO_WALLET_CREATION_TIMEOUT_MS, instrumentWalletCreation };
|
|
@@ -41,6 +41,7 @@ var useMutation = require('../useMutation/useMutation.cjs');
|
|
|
41
41
|
var useSetupPassword = require('../useSetupPassword/useSetupPassword.cjs');
|
|
42
42
|
var useWalletDelegation = require('../useWalletDelegation/useWalletDelegation.cjs');
|
|
43
43
|
require('../useWalletDelegation/DelegationError.cjs');
|
|
44
|
+
var instrumentWalletCreation = require('./instrumentWalletCreation.cjs');
|
|
44
45
|
|
|
45
46
|
// Validate if all required conditions are met for wallet creation
|
|
46
47
|
const useWalletCreationValidation = () => {
|
|
@@ -77,31 +78,28 @@ const useWalletCreation = () => {
|
|
|
77
78
|
return useMutation.useMutation((requirements) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
78
79
|
const startTime = Date.now();
|
|
79
80
|
const chainsString = requirements.map((req) => req.chain).join(',');
|
|
80
|
-
|
|
81
|
-
logger.logger.instrument('Auto wallet creation initiated', {
|
|
81
|
+
const baseLogData = {
|
|
82
82
|
chainCount: requirements.length,
|
|
83
83
|
chains: chainsString,
|
|
84
84
|
environmentId,
|
|
85
|
-
key: 'auto_wallet_creation_initiated',
|
|
86
|
-
time: 0,
|
|
87
85
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
88
|
-
}
|
|
86
|
+
};
|
|
87
|
+
// Log wallet creation initiation to DataDog
|
|
88
|
+
logger.logger.instrument('Auto wallet creation initiated', Object.assign(Object.assign({}, baseLogData), { key: 'auto_wallet_creation_initiated', time: 0 }));
|
|
89
89
|
try {
|
|
90
90
|
// If passcodeRequired is enabled, prompt user to set up password first
|
|
91
91
|
const password = yield setupPassword();
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
// Wrap the ceremony so a hang or mid-flow page exit emits a reason
|
|
93
|
+
// instead of leaving a silent "initiated" with no resolution.
|
|
94
|
+
yield instrumentWalletCreation.instrumentWalletCreation({
|
|
95
|
+
logData: baseLogData,
|
|
96
|
+
run: () => createWalletAccount(requirements, password, undefined, {
|
|
97
|
+
skipCloseAuthFlow: Boolean(password),
|
|
98
|
+
}),
|
|
94
99
|
});
|
|
95
100
|
const duration = Date.now() - startTime;
|
|
96
101
|
// Log successful wallet creation to DataDog
|
|
97
|
-
logger.logger.instrument('Auto wallet creation successful', {
|
|
98
|
-
chainCount: requirements.length,
|
|
99
|
-
chains: chainsString,
|
|
100
|
-
environmentId,
|
|
101
|
-
key: 'auto_wallet_creation_success',
|
|
102
|
-
time: duration,
|
|
103
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
104
|
-
});
|
|
102
|
+
logger.logger.instrument('Auto wallet creation successful', Object.assign(Object.assign({}, baseLogData), { key: 'auto_wallet_creation_success', time: duration }));
|
|
105
103
|
}
|
|
106
104
|
catch (error) {
|
|
107
105
|
const duration = Date.now() - startTime;
|
|
@@ -110,15 +108,7 @@ const useWalletCreation = () => {
|
|
|
110
108
|
// UI for this case; the metric should be consistent with that intent.
|
|
111
109
|
if (!(error instanceof Error &&
|
|
112
110
|
error.message === useSetupPassword.PASSWORD_SETUP_CANCELLED_ERROR)) {
|
|
113
|
-
logger.logger.instrument('Auto wallet creation failed', {
|
|
114
|
-
chainCount: requirements.length,
|
|
115
|
-
chains: chainsString,
|
|
116
|
-
environmentId,
|
|
117
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
118
|
-
key: 'auto_wallet_creation_failed',
|
|
119
|
-
time: duration,
|
|
120
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
121
|
-
});
|
|
111
|
+
logger.logger.instrument('Auto wallet creation failed', Object.assign(Object.assign({}, baseLogData), { error: error instanceof Error ? error.message : 'Unknown error', key: 'auto_wallet_creation_failed', time: duration }));
|
|
122
112
|
}
|
|
123
113
|
throw error;
|
|
124
114
|
}
|
|
@@ -37,6 +37,7 @@ import { useMutation } from '../useMutation/useMutation.js';
|
|
|
37
37
|
import { useSetupPassword, PASSWORD_SETUP_CANCELLED_ERROR } from '../useSetupPassword/useSetupPassword.js';
|
|
38
38
|
import { useWalletDelegation } from '../useWalletDelegation/useWalletDelegation.js';
|
|
39
39
|
import '../useWalletDelegation/DelegationError.js';
|
|
40
|
+
import { instrumentWalletCreation } from './instrumentWalletCreation.js';
|
|
40
41
|
|
|
41
42
|
// Validate if all required conditions are met for wallet creation
|
|
42
43
|
const useWalletCreationValidation = () => {
|
|
@@ -73,31 +74,28 @@ const useWalletCreation = () => {
|
|
|
73
74
|
return useMutation((requirements) => __awaiter(void 0, void 0, void 0, function* () {
|
|
74
75
|
const startTime = Date.now();
|
|
75
76
|
const chainsString = requirements.map((req) => req.chain).join(',');
|
|
76
|
-
|
|
77
|
-
logger.instrument('Auto wallet creation initiated', {
|
|
77
|
+
const baseLogData = {
|
|
78
78
|
chainCount: requirements.length,
|
|
79
79
|
chains: chainsString,
|
|
80
80
|
environmentId,
|
|
81
|
-
key: 'auto_wallet_creation_initiated',
|
|
82
|
-
time: 0,
|
|
83
81
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
84
|
-
}
|
|
82
|
+
};
|
|
83
|
+
// Log wallet creation initiation to DataDog
|
|
84
|
+
logger.instrument('Auto wallet creation initiated', Object.assign(Object.assign({}, baseLogData), { key: 'auto_wallet_creation_initiated', time: 0 }));
|
|
85
85
|
try {
|
|
86
86
|
// If passcodeRequired is enabled, prompt user to set up password first
|
|
87
87
|
const password = yield setupPassword();
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
// Wrap the ceremony so a hang or mid-flow page exit emits a reason
|
|
89
|
+
// instead of leaving a silent "initiated" with no resolution.
|
|
90
|
+
yield instrumentWalletCreation({
|
|
91
|
+
logData: baseLogData,
|
|
92
|
+
run: () => createWalletAccount(requirements, password, undefined, {
|
|
93
|
+
skipCloseAuthFlow: Boolean(password),
|
|
94
|
+
}),
|
|
90
95
|
});
|
|
91
96
|
const duration = Date.now() - startTime;
|
|
92
97
|
// Log successful wallet creation to DataDog
|
|
93
|
-
logger.instrument('Auto wallet creation successful', {
|
|
94
|
-
chainCount: requirements.length,
|
|
95
|
-
chains: chainsString,
|
|
96
|
-
environmentId,
|
|
97
|
-
key: 'auto_wallet_creation_success',
|
|
98
|
-
time: duration,
|
|
99
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
100
|
-
});
|
|
98
|
+
logger.instrument('Auto wallet creation successful', Object.assign(Object.assign({}, baseLogData), { key: 'auto_wallet_creation_success', time: duration }));
|
|
101
99
|
}
|
|
102
100
|
catch (error) {
|
|
103
101
|
const duration = Date.now() - startTime;
|
|
@@ -106,15 +104,7 @@ const useWalletCreation = () => {
|
|
|
106
104
|
// UI for this case; the metric should be consistent with that intent.
|
|
107
105
|
if (!(error instanceof Error &&
|
|
108
106
|
error.message === PASSWORD_SETUP_CANCELLED_ERROR)) {
|
|
109
|
-
logger.instrument('Auto wallet creation failed', {
|
|
110
|
-
chainCount: requirements.length,
|
|
111
|
-
chains: chainsString,
|
|
112
|
-
environmentId,
|
|
113
|
-
error: error instanceof Error ? error.message : 'Unknown error',
|
|
114
|
-
key: 'auto_wallet_creation_failed',
|
|
115
|
-
time: duration,
|
|
116
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
117
|
-
});
|
|
107
|
+
logger.instrument('Auto wallet creation failed', Object.assign(Object.assign({}, baseLogData), { error: error instanceof Error ? error.message : 'Unknown error', key: 'auto_wallet_creation_failed', time: duration }));
|
|
118
108
|
}
|
|
119
109
|
throw error;
|
|
120
110
|
}
|
|
@@ -41,6 +41,14 @@ var useDynamicWaas = require('../useDynamicWaas/useDynamicWaas.cjs');
|
|
|
41
41
|
var useRefreshAuth = require('../useRefreshAuth/useRefreshAuth.cjs');
|
|
42
42
|
var DelegationError = require('./DelegationError.cjs');
|
|
43
43
|
|
|
44
|
+
// Pre-share-set backends mark delegation via keyShares[].backupLocation='delegated';
|
|
45
|
+
// share-set backends use otherShareSets[].shareSetType='delegated' instead.
|
|
46
|
+
const isWalletDelegated = (walletProperties) => {
|
|
47
|
+
var _a, _b;
|
|
48
|
+
const hasDelegatedKeyShare = (_a = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.keyShares) === null || _a === void 0 ? void 0 : _a.some((keyShare) => keyShare.backupLocation === 'delegated');
|
|
49
|
+
const hasDelegatedShareSet = (_b = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.otherShareSets) === null || _b === void 0 ? void 0 : _b.some((shareSet) => shareSet.shareSetType === 'delegated');
|
|
50
|
+
return Boolean(hasDelegatedKeyShare || hasDelegatedShareSet);
|
|
51
|
+
};
|
|
44
52
|
/**
|
|
45
53
|
* Gets pending wallets that are eligible for delegation.
|
|
46
54
|
* If wallets are provided and not empty, converts them to WalletWithStatus[] with pending status.
|
|
@@ -87,15 +95,11 @@ const useWalletDelegation = () => {
|
|
|
87
95
|
const waasCredentials = user.verifiedCredentials.filter((vc) => vc.walletName === 'dynamicwaas' &&
|
|
88
96
|
vc.format === sdkApiCore.JwtVerifiedCredentialFormatEnum.Blockchain);
|
|
89
97
|
const hasWalletNeedingDelegation = waasCredentials.some((vc) => {
|
|
90
|
-
var _a, _b, _c
|
|
91
|
-
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
// Check if dismissed this session
|
|
96
|
-
const isDismissedThisSession = (_e = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _e === void 0 ? void 0 : _e.includes(vc.id);
|
|
97
|
-
// Needs delegation if: not delegated, not denied, and not dismissed this session
|
|
98
|
-
return (!hasDelegatedKeyShare && !hasDeniedAccess && !isDismissedThisSession);
|
|
98
|
+
var _a, _b, _c;
|
|
99
|
+
const isDelegated = isWalletDelegated(vc.walletProperties);
|
|
100
|
+
const hasDeniedAccess = ((_b = (_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.hasDeniedDelegatedAccess) === true;
|
|
101
|
+
const isDismissedThisSession = (_c = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _c === void 0 ? void 0 : _c.includes(vc.id);
|
|
102
|
+
return !isDelegated && !hasDeniedAccess && !isDismissedThisSession;
|
|
99
103
|
});
|
|
100
104
|
return hasWalletNeedingDelegation;
|
|
101
105
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, delegatedAccessEnabled, promptUsersOnSignIn]);
|
|
@@ -129,20 +133,18 @@ const useWalletDelegation = () => {
|
|
|
129
133
|
// Map credentials to wallets with status
|
|
130
134
|
return waasCredentials
|
|
131
135
|
.map((vc) => {
|
|
132
|
-
var _a, _b, _c
|
|
136
|
+
var _a, _b, _c;
|
|
133
137
|
let status = 'pending';
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
const hasDeniedAccess = ((_d = (_c = vc.walletProperties) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.hasDeniedDelegatedAccess) === true;
|
|
138
|
-
if (hasDelegatedKeyShare) {
|
|
138
|
+
const isDelegated = isWalletDelegated(vc.walletProperties);
|
|
139
|
+
const hasDeniedAccess = ((_b = (_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.hasDeniedDelegatedAccess) === true;
|
|
140
|
+
if (isDelegated) {
|
|
139
141
|
status = 'delegated';
|
|
140
142
|
}
|
|
141
143
|
else if (hasDeniedAccess) {
|
|
142
144
|
status = 'denied';
|
|
143
145
|
}
|
|
144
146
|
// Check if dismissed this session (UI state only)
|
|
145
|
-
const isDismissedThisSession = (
|
|
147
|
+
const isDismissedThisSession = (_c = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _c === void 0 ? void 0 : _c.includes(vc.id);
|
|
146
148
|
// Find corresponding wallet from userWallets
|
|
147
149
|
const wallet = userWallets.find((w) => w.address === vc.address);
|
|
148
150
|
if (!wallet) {
|
|
@@ -309,4 +311,5 @@ const useWalletDelegation = () => {
|
|
|
309
311
|
};
|
|
310
312
|
|
|
311
313
|
exports.getWalletsToDelegate = getWalletsToDelegate;
|
|
314
|
+
exports.isWalletDelegated = isWalletDelegated;
|
|
312
315
|
exports.useWalletDelegation = useWalletDelegation;
|
|
@@ -5,6 +5,14 @@ export type WalletWithStatus = Wallet & {
|
|
|
5
5
|
status: WalletDelegationStatus;
|
|
6
6
|
isDismissedThisSession?: boolean;
|
|
7
7
|
};
|
|
8
|
+
export declare const isWalletDelegated: (walletProperties: {
|
|
9
|
+
keyShares?: Array<{
|
|
10
|
+
backupLocation?: string;
|
|
11
|
+
}>;
|
|
12
|
+
otherShareSets?: Array<{
|
|
13
|
+
shareSetType?: string;
|
|
14
|
+
}>;
|
|
15
|
+
} | null | undefined) => boolean;
|
|
8
16
|
/**
|
|
9
17
|
* Gets pending wallets that are eligible for delegation.
|
|
10
18
|
* If wallets are provided and not empty, converts them to WalletWithStatus[] with pending status.
|
|
@@ -37,6 +37,14 @@ import { useDynamicWaas } from '../useDynamicWaas/useDynamicWaas.js';
|
|
|
37
37
|
import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
|
|
38
38
|
import { DelegationError } from './DelegationError.js';
|
|
39
39
|
|
|
40
|
+
// Pre-share-set backends mark delegation via keyShares[].backupLocation='delegated';
|
|
41
|
+
// share-set backends use otherShareSets[].shareSetType='delegated' instead.
|
|
42
|
+
const isWalletDelegated = (walletProperties) => {
|
|
43
|
+
var _a, _b;
|
|
44
|
+
const hasDelegatedKeyShare = (_a = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.keyShares) === null || _a === void 0 ? void 0 : _a.some((keyShare) => keyShare.backupLocation === 'delegated');
|
|
45
|
+
const hasDelegatedShareSet = (_b = walletProperties === null || walletProperties === void 0 ? void 0 : walletProperties.otherShareSets) === null || _b === void 0 ? void 0 : _b.some((shareSet) => shareSet.shareSetType === 'delegated');
|
|
46
|
+
return Boolean(hasDelegatedKeyShare || hasDelegatedShareSet);
|
|
47
|
+
};
|
|
40
48
|
/**
|
|
41
49
|
* Gets pending wallets that are eligible for delegation.
|
|
42
50
|
* If wallets are provided and not empty, converts them to WalletWithStatus[] with pending status.
|
|
@@ -83,15 +91,11 @@ const useWalletDelegation = () => {
|
|
|
83
91
|
const waasCredentials = user.verifiedCredentials.filter((vc) => vc.walletName === 'dynamicwaas' &&
|
|
84
92
|
vc.format === JwtVerifiedCredentialFormatEnum.Blockchain);
|
|
85
93
|
const hasWalletNeedingDelegation = waasCredentials.some((vc) => {
|
|
86
|
-
var _a, _b, _c
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Check if dismissed this session
|
|
92
|
-
const isDismissedThisSession = (_e = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _e === void 0 ? void 0 : _e.includes(vc.id);
|
|
93
|
-
// Needs delegation if: not delegated, not denied, and not dismissed this session
|
|
94
|
-
return (!hasDelegatedKeyShare && !hasDeniedAccess && !isDismissedThisSession);
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
const isDelegated = isWalletDelegated(vc.walletProperties);
|
|
96
|
+
const hasDeniedAccess = ((_b = (_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.hasDeniedDelegatedAccess) === true;
|
|
97
|
+
const isDismissedThisSession = (_c = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _c === void 0 ? void 0 : _c.includes(vc.id);
|
|
98
|
+
return !isDelegated && !hasDeniedAccess && !isDismissedThisSession;
|
|
95
99
|
});
|
|
96
100
|
return hasWalletNeedingDelegation;
|
|
97
101
|
}, [user === null || user === void 0 ? void 0 : user.verifiedCredentials, delegatedAccessEnabled, promptUsersOnSignIn]);
|
|
@@ -125,20 +129,18 @@ const useWalletDelegation = () => {
|
|
|
125
129
|
// Map credentials to wallets with status
|
|
126
130
|
return waasCredentials
|
|
127
131
|
.map((vc) => {
|
|
128
|
-
var _a, _b, _c
|
|
132
|
+
var _a, _b, _c;
|
|
129
133
|
let status = 'pending';
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
const hasDeniedAccess = ((_d = (_c = vc.walletProperties) === null || _c === void 0 ? void 0 : _c.settings) === null || _d === void 0 ? void 0 : _d.hasDeniedDelegatedAccess) === true;
|
|
134
|
-
if (hasDelegatedKeyShare) {
|
|
134
|
+
const isDelegated = isWalletDelegated(vc.walletProperties);
|
|
135
|
+
const hasDeniedAccess = ((_b = (_a = vc.walletProperties) === null || _a === void 0 ? void 0 : _a.settings) === null || _b === void 0 ? void 0 : _b.hasDeniedDelegatedAccess) === true;
|
|
136
|
+
if (isDelegated) {
|
|
135
137
|
status = 'delegated';
|
|
136
138
|
}
|
|
137
139
|
else if (hasDeniedAccess) {
|
|
138
140
|
status = 'denied';
|
|
139
141
|
}
|
|
140
142
|
// Check if dismissed this session (UI state only)
|
|
141
|
-
const isDismissedThisSession = (
|
|
143
|
+
const isDismissedThisSession = (_c = sessionState === null || sessionState === void 0 ? void 0 : sessionState.dismissedWallets) === null || _c === void 0 ? void 0 : _c.includes(vc.id);
|
|
142
144
|
// Find corresponding wallet from userWallets
|
|
143
145
|
const wallet = userWallets.find((w) => w.address === vc.address);
|
|
144
146
|
if (!wallet) {
|
|
@@ -304,4 +306,4 @@ const useWalletDelegation = () => {
|
|
|
304
306
|
};
|
|
305
307
|
};
|
|
306
308
|
|
|
307
|
-
export { getWalletsToDelegate, useWalletDelegation };
|
|
309
|
+
export { getWalletsToDelegate, isWalletDelegated, useWalletDelegation };
|
|
@@ -312,7 +312,23 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
312
312
|
if (transaction.fetchFee) {
|
|
313
313
|
const feePromise = transaction.fetchFee();
|
|
314
314
|
if (feePromise && typeof feePromise.finally === 'function') {
|
|
315
|
-
feePromise.finally(
|
|
315
|
+
feePromise.finally(() => {
|
|
316
|
+
// `transaction.isGasSponsored()` is a synchronous getter that
|
|
317
|
+
// reads a flag the transaction caches during `fetchFee`. On
|
|
318
|
+
// Aleo we can't know whether Feemaster covers the call until
|
|
319
|
+
// that async lookup resolves, so the flag starts at `false`
|
|
320
|
+
// and flips to `true` once the policy answer lands. The
|
|
321
|
+
// initial-mount `useEffect` below only runs when
|
|
322
|
+
// `transaction` itself changes, so without re-reading here
|
|
323
|
+
// React's `isGasSponsored` state stays `false` and the
|
|
324
|
+
// confirmation card renders the gas row with a `--` value
|
|
325
|
+
// (since `fee.gas = 0n` for sponsored calls). Re-read once
|
|
326
|
+
// the cached flag is populated so the row hides itself.
|
|
327
|
+
if (transaction.isGasSponsored) {
|
|
328
|
+
setIsGasSponsored(transaction.isGasSponsored());
|
|
329
|
+
}
|
|
330
|
+
update();
|
|
331
|
+
});
|
|
316
332
|
}
|
|
317
333
|
}
|
|
318
334
|
}, [primaryWallet, transaction, update]);
|
|
@@ -304,7 +304,23 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
304
304
|
if (transaction.fetchFee) {
|
|
305
305
|
const feePromise = transaction.fetchFee();
|
|
306
306
|
if (feePromise && typeof feePromise.finally === 'function') {
|
|
307
|
-
feePromise.finally(
|
|
307
|
+
feePromise.finally(() => {
|
|
308
|
+
// `transaction.isGasSponsored()` is a synchronous getter that
|
|
309
|
+
// reads a flag the transaction caches during `fetchFee`. On
|
|
310
|
+
// Aleo we can't know whether Feemaster covers the call until
|
|
311
|
+
// that async lookup resolves, so the flag starts at `false`
|
|
312
|
+
// and flips to `true` once the policy answer lands. The
|
|
313
|
+
// initial-mount `useEffect` below only runs when
|
|
314
|
+
// `transaction` itself changes, so without re-reading here
|
|
315
|
+
// React's `isGasSponsored` state stays `false` and the
|
|
316
|
+
// confirmation card renders the gas row with a `--` value
|
|
317
|
+
// (since `fee.gas = 0n` for sponsored calls). Re-read once
|
|
318
|
+
// the cached flag is populated so the row hides itself.
|
|
319
|
+
if (transaction.isGasSponsored) {
|
|
320
|
+
setIsGasSponsored(transaction.isGasSponsored());
|
|
321
|
+
}
|
|
322
|
+
update();
|
|
323
|
+
});
|
|
308
324
|
}
|
|
309
325
|
}
|
|
310
326
|
}, [primaryWallet, transaction, update]);
|