@dynamic-labs/sdk-react-core 4.96.4 → 4.98.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 +25 -0
- package/package.cjs +3 -3
- package/package.js +3 -3
- package/package.json +14 -14
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -0
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.cjs +1 -0
- package/src/lib/context/ErrorContext/hooks/useErrorText/useErrorText.js +2 -1
- package/src/lib/data/api/transactions/index.d.ts +1 -0
- package/src/lib/data/api/transactions/screenTransaction.cjs +107 -0
- package/src/lib/data/api/transactions/screenTransaction.d.ts +12 -0
- package/src/lib/data/api/transactions/screenTransaction.js +101 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isEvmClientGasSponsorshipEnabled/index.d.ts +1 -0
- package/src/lib/utils/functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.cjs +24 -0
- package/src/lib/utils/functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.d.ts +7 -0
- package/src/lib/utils/functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.js +20 -0
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.cjs +1 -1
- package/src/lib/utils/functions/updatePrimaryWalletId/updatePrimaryWalletId.js +1 -1
- package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.d.ts +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +17 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +17 -1
- package/src/lib/utils/hooks/useMfa/useMfa.cjs +1 -1
- package/src/lib/utils/hooks/useMfa/useMfa.js +1 -1
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.cjs +17 -1
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.d.ts +11 -0
- package/src/lib/utils/hooks/useSendDynamicProps/useSendDynamicProps.js +17 -2
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.cjs +5 -0
- package/src/lib/utils/hooks/useSetWalletConnectorFetchers/useSetWalletConnectorFetchers.js +5 -0
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs +1 -1
- package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.98.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.97.0...v4.98.0) (2026-09-02)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **waas-evm:** route embedded EVM sends through gas sponsorship when enabled (V4) ([#12307](https://github.com/dynamic-labs/dynamic-auth/issues/12307)) ([d8e6b94](https://github.com/dynamic-labs/dynamic-auth/commit/d8e6b94dc86e1d48b66a246bf8bf0b857e7e69c4))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **sdk-react-core:** send a css overrides summary in sdkSettings telemetry (v4) ([#12330](https://github.com/dynamic-labs/dynamic-auth/issues/12330)) ([8547ee7](https://github.com/dynamic-labs/dynamic-auth/commit/8547ee7a7c3fef8de0ff384778f86542b809e7aa))
|
|
13
|
+
* **waas-svm:** apply overrideBlockhash before sponsorship [v4 backport] ([#12320](https://github.com/dynamic-labs/dynamic-auth/issues/12320)) ([0551f01](https://github.com/dynamic-labs/dynamic-auth/commit/0551f01953f5e623ac113b03e1b010d3dc58a81e)), closes [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599) [#10599](https://github.com/dynamic-labs/dynamic-auth/issues/10599)
|
|
14
|
+
|
|
15
|
+
## [4.97.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.96.4...v4.97.0) (2026-08-27)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **screening:** connected-wallet transaction screening [v4 backport] (DYNT-1663) ([#12284](https://github.com/dynamic-labs/dynamic-auth/issues/12284)) ([294adba](https://github.com/dynamic-labs/dynamic-auth/commit/294adba7dba8f321f3b1e8413f73545701e51252)), closes [#12160](https://github.com/dynamic-labs/dynamic-auth/issues/12160) [#12167](https://github.com/dynamic-labs/dynamic-auth/issues/12167) [#12168](https://github.com/dynamic-labs/dynamic-auth/issues/12168) [#12169](https://github.com/dynamic-labs/dynamic-auth/issues/12169) [#12172](https://github.com/dynamic-labs/dynamic-auth/issues/12172)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* **screening:** wire connected-wallet screening into the Send Balance UI (DYNT-1663) ([#12289](https://github.com/dynamic-labs/dynamic-auth/issues/12289)) ([1587cd8](https://github.com/dynamic-labs/dynamic-auth/commit/1587cd833370e18fa383f942521500e4c1576390))
|
|
26
|
+
|
|
2
27
|
### [4.96.4](https://github.com/dynamic-labs/dynamic-auth/compare/v4.96.3...v4.96.4) (2026-08-26)
|
|
3
28
|
|
|
4
29
|
|
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.98.0";
|
|
7
7
|
var dependencies = {
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
9
9
|
"@dynamic-labs-sdk/client": "1.27.1",
|
|
10
|
-
"@dynamic-labs-wallet/browser-wallet-client": "1.
|
|
11
|
-
"@dynamic-labs-wallet/forward-mpc-client": "
|
|
10
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.1.2",
|
|
11
|
+
"@dynamic-labs-wallet/forward-mpc-client": "2.0.1",
|
|
12
12
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
13
13
|
"@marsidev/react-turnstile": "1.5.2",
|
|
14
14
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
package/package.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.
|
|
2
|
+
var version = "4.98.0";
|
|
3
3
|
var dependencies = {
|
|
4
4
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
5
5
|
"@dynamic-labs-sdk/client": "1.27.1",
|
|
6
|
-
"@dynamic-labs-wallet/browser-wallet-client": "1.
|
|
7
|
-
"@dynamic-labs-wallet/forward-mpc-client": "
|
|
6
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.1.2",
|
|
7
|
+
"@dynamic-labs-wallet/forward-mpc-client": "2.0.1",
|
|
8
8
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
9
9
|
"@marsidev/react-turnstile": "1.5.2",
|
|
10
10
|
"@thumbmarkjs/thumbmarkjs": "0.16.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.98.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
6
6
|
"@dynamic-labs-sdk/client": "1.27.1",
|
|
7
|
-
"@dynamic-labs-wallet/browser-wallet-client": "1.
|
|
8
|
-
"@dynamic-labs-wallet/forward-mpc-client": "
|
|
7
|
+
"@dynamic-labs-wallet/browser-wallet-client": "1.1.2",
|
|
8
|
+
"@dynamic-labs-wallet/forward-mpc-client": "2.0.1",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
10
10
|
"@marsidev/react-turnstile": "1.5.2",
|
|
11
11
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
@@ -18,17 +18,17 @@
|
|
|
18
18
|
"react-i18next": "13.5.0",
|
|
19
19
|
"react-international-phone": "4.5.0",
|
|
20
20
|
"yup": "0.32.11",
|
|
21
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
22
|
-
"@dynamic-labs/iconic": "4.
|
|
23
|
-
"@dynamic-labs/locale": "4.
|
|
24
|
-
"@dynamic-labs/logger": "4.
|
|
25
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
26
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
27
|
-
"@dynamic-labs/store": "4.
|
|
28
|
-
"@dynamic-labs/types": "4.
|
|
29
|
-
"@dynamic-labs/utils": "4.
|
|
30
|
-
"@dynamic-labs/wallet-book": "4.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "4.98.0",
|
|
22
|
+
"@dynamic-labs/iconic": "4.98.0",
|
|
23
|
+
"@dynamic-labs/locale": "4.98.0",
|
|
24
|
+
"@dynamic-labs/logger": "4.98.0",
|
|
25
|
+
"@dynamic-labs/multi-wallet": "4.98.0",
|
|
26
|
+
"@dynamic-labs/rpc-providers": "4.98.0",
|
|
27
|
+
"@dynamic-labs/store": "4.98.0",
|
|
28
|
+
"@dynamic-labs/types": "4.98.0",
|
|
29
|
+
"@dynamic-labs/utils": "4.98.0",
|
|
30
|
+
"@dynamic-labs/wallet-book": "4.98.0",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "4.98.0",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -34,6 +34,7 @@ var nonce = require('../../store/state/nonce/nonce.cjs');
|
|
|
34
34
|
require('@dynamic-labs-wallet/browser-wallet-client');
|
|
35
35
|
var ApiEndpoint = require('../../config/ApiEndpoint.cjs');
|
|
36
36
|
var settings = require('../../data/api/settings/settings.cjs');
|
|
37
|
+
var screenTransaction = require('../../data/api/transactions/screenTransaction.cjs');
|
|
37
38
|
var dynamicContextProps = require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
38
39
|
var primaryWalletId = require('../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
39
40
|
var connectedWalletsInfo = require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
@@ -301,6 +302,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
301
302
|
mobileExperience,
|
|
302
303
|
networkConfigurations: serverNetworkConfigurations,
|
|
303
304
|
projectSettings,
|
|
305
|
+
transactionScreening: screenTransaction.transactionScreeningService,
|
|
304
306
|
useMetamaskSdk,
|
|
305
307
|
walletBook: walletBook$1,
|
|
306
308
|
walletConnectPreferredChains,
|
|
@@ -30,6 +30,7 @@ import { useFetchNonce, useNonce } from '../../store/state/nonce/nonce.js';
|
|
|
30
30
|
import '@dynamic-labs-wallet/browser-wallet-client';
|
|
31
31
|
import ApiEndpoint from '../../config/ApiEndpoint.js';
|
|
32
32
|
import { sendDynamicProps } from '../../data/api/settings/settings.js';
|
|
33
|
+
import { transactionScreeningService } from '../../data/api/transactions/screenTransaction.js';
|
|
33
34
|
import { useSyncDynamicContextProps } from '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
34
35
|
import { usePrimaryWalletId } from '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
35
36
|
import { resetConnectedWalletsInfo } from '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
@@ -297,6 +298,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
297
298
|
mobileExperience,
|
|
298
299
|
networkConfigurations: serverNetworkConfigurations,
|
|
299
300
|
projectSettings,
|
|
301
|
+
transactionScreening: transactionScreeningService,
|
|
300
302
|
useMetamaskSdk,
|
|
301
303
|
walletBook,
|
|
302
304
|
walletConnectPreferredChains,
|
|
@@ -23,6 +23,7 @@ const mapErrorCodeToTranslation = {
|
|
|
23
23
|
[utils.ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN]: 'dyn_error.credential_not_enabled_for_sign_in',
|
|
24
24
|
[utils.ErrorCode.SEI_NOT_ENABLED_IN_KEPLR_WALLET]: 'dyn_error.sei_not_enabled_in_keplr_wallet',
|
|
25
25
|
[utils.RATE_LIMIT_ERROR_CODE]: 'dyn_error.rate_limit_error',
|
|
26
|
+
[utils.TRANSACTION_SCREENING_BLOCKED_ERROR_CODE]: 'dyn_error.transaction_screening_blocked',
|
|
26
27
|
};
|
|
27
28
|
/** A hook that listens to the error context and returns a translated value */
|
|
28
29
|
const useErrorText = () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
|
-
import { ErrorCode, RATE_LIMIT_ERROR_CODE } from '@dynamic-labs/utils';
|
|
4
|
+
import { ErrorCode, RATE_LIMIT_ERROR_CODE, TRANSACTION_SCREENING_BLOCKED_ERROR_CODE } from '@dynamic-labs/utils';
|
|
5
5
|
import { useErrorContext } from '../../ErrorContext.js';
|
|
6
6
|
|
|
7
7
|
const mapErrorCodeToTranslation = {
|
|
@@ -19,6 +19,7 @@ const mapErrorCodeToTranslation = {
|
|
|
19
19
|
[ErrorCode.CREDENTIAL_NOT_ENABLED_FOR_SIGN_IN]: 'dyn_error.credential_not_enabled_for_sign_in',
|
|
20
20
|
[ErrorCode.SEI_NOT_ENABLED_IN_KEPLR_WALLET]: 'dyn_error.sei_not_enabled_in_keplr_wallet',
|
|
21
21
|
[RATE_LIMIT_ERROR_CODE]: 'dyn_error.rate_limit_error',
|
|
22
|
+
[TRANSACTION_SCREENING_BLOCKED_ERROR_CODE]: 'dyn_error.transaction_screening_blocked',
|
|
22
23
|
};
|
|
23
24
|
/** A hook that listens to the error context and returns a translated value */
|
|
24
25
|
const useErrorText = () => {
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
var api = require('../api.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('react');
|
|
13
|
+
require('react/jsx-runtime');
|
|
14
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
15
|
+
var logger = require('../../../shared/logger.cjs');
|
|
16
|
+
require('@dynamic-labs/wallet-book');
|
|
17
|
+
require('../../../utils/constants/colors.cjs');
|
|
18
|
+
require('../../../utils/constants/values.cjs');
|
|
19
|
+
require('../../../shared/consts/index.cjs');
|
|
20
|
+
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
21
|
+
require('@dynamic-labs-sdk/client/core');
|
|
22
|
+
require('eventemitter3');
|
|
23
|
+
require('@dynamic-labs-sdk/client');
|
|
24
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
25
|
+
require('@dynamic-labs/multi-wallet');
|
|
26
|
+
require('react-international-phone');
|
|
27
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
28
|
+
require('@dynamic-labs-wallet/browser-wallet-client');
|
|
29
|
+
require('@dynamic-labs/locale');
|
|
30
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
31
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
32
|
+
require('../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
33
|
+
require('../../../events/dynamicEvents.cjs');
|
|
34
|
+
var getProjectSettings = require('../../../client/extension/projectSettings/getProjectSettings/getProjectSettings.cjs');
|
|
35
|
+
|
|
36
|
+
// The SDK-internal chain union (shared across connector packages) is decoupled
|
|
37
|
+
// from the wire-level enum; this is the one place that needs to know both.
|
|
38
|
+
// Resolved per call rather than as a module-scope map, as is the block decision
|
|
39
|
+
// at the bottom of this file: reading an enum member at module scope resolves it
|
|
40
|
+
// the moment anything in this barrel's import graph loads, which takes down every
|
|
41
|
+
// spec that partially mocks sdk-api-core before a single test can run.
|
|
42
|
+
const chainEnumFor = (chain) => {
|
|
43
|
+
const chainEnumByScreeningChain = {
|
|
44
|
+
BTC: sdkApiCore.ChainEnum.Btc,
|
|
45
|
+
EVM: sdkApiCore.ChainEnum.Evm,
|
|
46
|
+
SOL: sdkApiCore.ChainEnum.Sol,
|
|
47
|
+
};
|
|
48
|
+
return chainEnumByScreeningChain[chain];
|
|
49
|
+
};
|
|
50
|
+
// A human is waiting on this call: it sits between "send" and the wallet
|
|
51
|
+
// prompt, so an unbounded fetch would stall the prompt indefinitely on a
|
|
52
|
+
// redcoast outage. Matches the enclave hook's 2000 ms wall-clock bound
|
|
53
|
+
// (SANCTIONS_SCREENING_TIMEOUT_MS) so both screening paths degrade alike.
|
|
54
|
+
const SCREENING_TIMEOUT_MS = 2000;
|
|
55
|
+
const isScreeningEnabled = () => {
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
return Boolean((_c = (_b = (_a = getProjectSettings.getProjectSettings()) === null || _a === void 0 ? void 0 : _a.sdk) === null || _b === void 0 ? void 0 : _b.featureFlags) === null || _c === void 0 ? void 0 : _c.enableExternalWalletOnTransactionSanctions);
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Screens a connected-wallet transaction against the environment's sanctions
|
|
61
|
+
* providers before the wallet is prompted. Best-effort by construction:
|
|
62
|
+
* resolves on allow and on any screening failure (fail-open — signing must
|
|
63
|
+
* never hard-fail on a screening outage), and throws
|
|
64
|
+
* TransactionScreeningBlockedError only on an explicit block decision. A
|
|
65
|
+
* screen that outlives SCREENING_TIMEOUT_MS is one of those failures.
|
|
66
|
+
*/
|
|
67
|
+
const screenTransaction = (args) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
+
let abortTimer;
|
|
69
|
+
let response;
|
|
70
|
+
try {
|
|
71
|
+
// Reading settings can itself throw (e.g. the client store isn't
|
|
72
|
+
// initialized yet), which must fail open like everything else here.
|
|
73
|
+
if (!isScreeningEnabled())
|
|
74
|
+
return;
|
|
75
|
+
// The signal cancels the in-flight request so a hung endpoint can't tie up
|
|
76
|
+
// the browser's connections to the API; the race is what actually bounds the
|
|
77
|
+
// wait, since a host-supplied FetchService implementation need not honour it.
|
|
78
|
+
const abortController = new AbortController();
|
|
79
|
+
abortTimer = setTimeout(() => abortController.abort(), SCREENING_TIMEOUT_MS);
|
|
80
|
+
response = yield utils.promiseWithTimeout(api.sdkApi().screenTransaction({
|
|
81
|
+
environmentId: dynamicContextProps.getEnvironmentId(),
|
|
82
|
+
screenTransactionRequest: Object.assign(Object.assign({}, args), { chain: chainEnumFor(args.chain) }),
|
|
83
|
+
}, { signal: abortController.signal }), SCREENING_TIMEOUT_MS, { timeoutMessage: 'screenTransaction timed out' });
|
|
84
|
+
}
|
|
85
|
+
catch (_a) {
|
|
86
|
+
// Not the raw error: it can carry internal details (endpoint paths,
|
|
87
|
+
// server-side messages) that shouldn't cross the logger's broadcast
|
|
88
|
+
// boundary to whatever a host app has subscribed to its log events.
|
|
89
|
+
logger.logger.warn('screenTransaction error', {
|
|
90
|
+
message: 'Transaction screening failed',
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
clearTimeout(abortTimer);
|
|
96
|
+
}
|
|
97
|
+
if ((response === null || response === void 0 ? void 0 : response.decision) === sdkApiCore.ScreenTransactionResponseDecisionEnum.Block) {
|
|
98
|
+
throw new utils.TransactionScreeningBlockedError(response.blockedAddresses);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
const transactionScreeningService = {
|
|
102
|
+
screenTransaction,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
exports.SCREENING_TIMEOUT_MS = SCREENING_TIMEOUT_MS;
|
|
106
|
+
exports.screenTransaction = screenTransaction;
|
|
107
|
+
exports.transactionScreeningService = transactionScreeningService;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ScreenTransactionArgs, TransactionScreeningService } from '@dynamic-labs/types';
|
|
2
|
+
export declare const SCREENING_TIMEOUT_MS = 2000;
|
|
3
|
+
/**
|
|
4
|
+
* Screens a connected-wallet transaction against the environment's sanctions
|
|
5
|
+
* providers before the wallet is prompted. Best-effort by construction:
|
|
6
|
+
* resolves on allow and on any screening failure (fail-open — signing must
|
|
7
|
+
* never hard-fail on a screening outage), and throws
|
|
8
|
+
* TransactionScreeningBlockedError only on an explicit block decision. A
|
|
9
|
+
* screen that outlives SCREENING_TIMEOUT_MS is one of those failures.
|
|
10
|
+
*/
|
|
11
|
+
export declare const screenTransaction: (args: ScreenTransactionArgs) => Promise<void>;
|
|
12
|
+
export declare const transactionScreeningService: TransactionScreeningService;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { ScreenTransactionResponseDecisionEnum, ChainEnum } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { promiseWithTimeout, TransactionScreeningBlockedError } from '@dynamic-labs/utils';
|
|
5
|
+
import { sdkApi } from '../api.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import 'react';
|
|
9
|
+
import 'react/jsx-runtime';
|
|
10
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
11
|
+
import { logger } from '../../../shared/logger.js';
|
|
12
|
+
import '@dynamic-labs/wallet-book';
|
|
13
|
+
import '../../../utils/constants/colors.js';
|
|
14
|
+
import '../../../utils/constants/values.js';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
17
|
+
import '@dynamic-labs-sdk/client/core';
|
|
18
|
+
import 'eventemitter3';
|
|
19
|
+
import '@dynamic-labs-sdk/client';
|
|
20
|
+
import '../../../config/ApiEndpoint.js';
|
|
21
|
+
import '@dynamic-labs/multi-wallet';
|
|
22
|
+
import 'react-international-phone';
|
|
23
|
+
import '../../../store/state/nonce/nonce.js';
|
|
24
|
+
import '@dynamic-labs-wallet/browser-wallet-client';
|
|
25
|
+
import '@dynamic-labs/locale';
|
|
26
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
27
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
28
|
+
import '../../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
29
|
+
import '../../../events/dynamicEvents.js';
|
|
30
|
+
import { getProjectSettings } from '../../../client/extension/projectSettings/getProjectSettings/getProjectSettings.js';
|
|
31
|
+
|
|
32
|
+
// The SDK-internal chain union (shared across connector packages) is decoupled
|
|
33
|
+
// from the wire-level enum; this is the one place that needs to know both.
|
|
34
|
+
// Resolved per call rather than as a module-scope map, as is the block decision
|
|
35
|
+
// at the bottom of this file: reading an enum member at module scope resolves it
|
|
36
|
+
// the moment anything in this barrel's import graph loads, which takes down every
|
|
37
|
+
// spec that partially mocks sdk-api-core before a single test can run.
|
|
38
|
+
const chainEnumFor = (chain) => {
|
|
39
|
+
const chainEnumByScreeningChain = {
|
|
40
|
+
BTC: ChainEnum.Btc,
|
|
41
|
+
EVM: ChainEnum.Evm,
|
|
42
|
+
SOL: ChainEnum.Sol,
|
|
43
|
+
};
|
|
44
|
+
return chainEnumByScreeningChain[chain];
|
|
45
|
+
};
|
|
46
|
+
// A human is waiting on this call: it sits between "send" and the wallet
|
|
47
|
+
// prompt, so an unbounded fetch would stall the prompt indefinitely on a
|
|
48
|
+
// redcoast outage. Matches the enclave hook's 2000 ms wall-clock bound
|
|
49
|
+
// (SANCTIONS_SCREENING_TIMEOUT_MS) so both screening paths degrade alike.
|
|
50
|
+
const SCREENING_TIMEOUT_MS = 2000;
|
|
51
|
+
const isScreeningEnabled = () => {
|
|
52
|
+
var _a, _b, _c;
|
|
53
|
+
return Boolean((_c = (_b = (_a = getProjectSettings()) === null || _a === void 0 ? void 0 : _a.sdk) === null || _b === void 0 ? void 0 : _b.featureFlags) === null || _c === void 0 ? void 0 : _c.enableExternalWalletOnTransactionSanctions);
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Screens a connected-wallet transaction against the environment's sanctions
|
|
57
|
+
* providers before the wallet is prompted. Best-effort by construction:
|
|
58
|
+
* resolves on allow and on any screening failure (fail-open — signing must
|
|
59
|
+
* never hard-fail on a screening outage), and throws
|
|
60
|
+
* TransactionScreeningBlockedError only on an explicit block decision. A
|
|
61
|
+
* screen that outlives SCREENING_TIMEOUT_MS is one of those failures.
|
|
62
|
+
*/
|
|
63
|
+
const screenTransaction = (args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
|
+
let abortTimer;
|
|
65
|
+
let response;
|
|
66
|
+
try {
|
|
67
|
+
// Reading settings can itself throw (e.g. the client store isn't
|
|
68
|
+
// initialized yet), which must fail open like everything else here.
|
|
69
|
+
if (!isScreeningEnabled())
|
|
70
|
+
return;
|
|
71
|
+
// The signal cancels the in-flight request so a hung endpoint can't tie up
|
|
72
|
+
// the browser's connections to the API; the race is what actually bounds the
|
|
73
|
+
// wait, since a host-supplied FetchService implementation need not honour it.
|
|
74
|
+
const abortController = new AbortController();
|
|
75
|
+
abortTimer = setTimeout(() => abortController.abort(), SCREENING_TIMEOUT_MS);
|
|
76
|
+
response = yield promiseWithTimeout(sdkApi().screenTransaction({
|
|
77
|
+
environmentId: getEnvironmentId(),
|
|
78
|
+
screenTransactionRequest: Object.assign(Object.assign({}, args), { chain: chainEnumFor(args.chain) }),
|
|
79
|
+
}, { signal: abortController.signal }), SCREENING_TIMEOUT_MS, { timeoutMessage: 'screenTransaction timed out' });
|
|
80
|
+
}
|
|
81
|
+
catch (_a) {
|
|
82
|
+
// Not the raw error: it can carry internal details (endpoint paths,
|
|
83
|
+
// server-side messages) that shouldn't cross the logger's broadcast
|
|
84
|
+
// boundary to whatever a host app has subscribed to its log events.
|
|
85
|
+
logger.warn('screenTransaction error', {
|
|
86
|
+
message: 'Transaction screening failed',
|
|
87
|
+
});
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
finally {
|
|
91
|
+
clearTimeout(abortTimer);
|
|
92
|
+
}
|
|
93
|
+
if ((response === null || response === void 0 ? void 0 : response.decision) === ScreenTransactionResponseDecisionEnum.Block) {
|
|
94
|
+
throw new TransactionScreeningBlockedError(response.blockedAddresses);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
const transactionScreeningService = {
|
|
98
|
+
screenTransaction,
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export { SCREENING_TIMEOUT_MS, screenTransaction, transactionScreeningService };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './isEvmClientGasSponsorshipEnabled';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether EVM gas sponsorship can be relayed from the client for this project.
|
|
10
|
+
* The serverOnly relay mode rejects client submissions, so the SDK must keep
|
|
11
|
+
* using regular transactions in that case.
|
|
12
|
+
*/
|
|
13
|
+
const isEvmClientGasSponsorshipEnabled = (projectSettings) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const embeddedWallets = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets;
|
|
16
|
+
if (!(embeddedWallets === null || embeddedWallets === void 0 ? void 0 : embeddedWallets.evmGasSponsorshipEnabled)) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
const isServerOnlyRelayMode = embeddedWallets.evmGasSponsorshipRelayMode ===
|
|
20
|
+
sdkApiCore.ProjectSettingsSdkEmbeddedWalletsEvmGasSponsorshipRelayModeEnum.ServerOnly;
|
|
21
|
+
return !isServerOnlyRelayMode;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.isEvmClientGasSponsorshipEnabled = isEvmClientGasSponsorshipEnabled;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
+
/**
|
|
3
|
+
* Whether EVM gas sponsorship can be relayed from the client for this project.
|
|
4
|
+
* The serverOnly relay mode rejects client submissions, so the SDK must keep
|
|
5
|
+
* using regular transactions in that case.
|
|
6
|
+
*/
|
|
7
|
+
export declare const isEvmClientGasSponsorshipEnabled: (projectSettings: ProjectSettings | undefined) => boolean;
|
package/src/lib/utils/functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ProjectSettingsSdkEmbeddedWalletsEvmGasSponsorshipRelayModeEnum } from '@dynamic-labs/sdk-api-core';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Whether EVM gas sponsorship can be relayed from the client for this project.
|
|
6
|
+
* The serverOnly relay mode rejects client submissions, so the SDK must keep
|
|
7
|
+
* using regular transactions in that case.
|
|
8
|
+
*/
|
|
9
|
+
const isEvmClientGasSponsorshipEnabled = (projectSettings) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const embeddedWallets = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets;
|
|
12
|
+
if (!(embeddedWallets === null || embeddedWallets === void 0 ? void 0 : embeddedWallets.evmGasSponsorshipEnabled)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const isServerOnlyRelayMode = embeddedWallets.evmGasSponsorshipRelayMode ===
|
|
16
|
+
ProjectSettingsSdkEmbeddedWalletsEvmGasSponsorshipRelayModeEnum.ServerOnly;
|
|
17
|
+
return !isServerOnlyRelayMode;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { isEvmClientGasSponsorshipEnabled };
|
|
@@ -25,8 +25,8 @@ require('react-international-phone');
|
|
|
25
25
|
require('../../../store/state/nonce/nonce.cjs');
|
|
26
26
|
require('@dynamic-labs-wallet/browser-wallet-client');
|
|
27
27
|
require('@dynamic-labs/locale');
|
|
28
|
-
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
29
28
|
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
29
|
+
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
30
30
|
var primaryWalletId = require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
31
31
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
32
32
|
require('../getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
@@ -21,8 +21,8 @@ import 'react-international-phone';
|
|
|
21
21
|
import '../../../store/state/nonce/nonce.js';
|
|
22
22
|
import '@dynamic-labs-wallet/browser-wallet-client';
|
|
23
23
|
import '@dynamic-labs/locale';
|
|
24
|
-
import { storeSelectedWallet } from '../../../data/api/wallets/wallets.js';
|
|
25
24
|
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
25
|
+
import { storeSelectedWallet } from '../../../data/api/wallets/wallets.js';
|
|
26
26
|
import { setPrimaryWalletId } from '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
27
27
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
28
28
|
import '../getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
package/src/lib/utils/hooks/useCreateWalletConnectorOptions/useCreateWalletConnectorOptions.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProjectSettings } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
import { type MobileExperience, type CoinbaseWalletPreference, type NetworkConfigurationMap, type WalletUiUtils } from '@dynamic-labs/types';
|
|
2
|
+
import { type MobileExperience, type CoinbaseWalletPreference, type NetworkConfigurationMap, type TransactionScreeningService, type WalletUiUtils } from '@dynamic-labs/types';
|
|
3
3
|
import { DeepLinkVariant, InternalWalletConnector, WalletConnectorExtension, WalletConnectorsMethod } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
5
5
|
export type WalletConnectorProps = {
|
|
@@ -11,6 +11,7 @@ export type WalletConnectorProps = {
|
|
|
11
11
|
mobileExperience?: MobileExperience;
|
|
12
12
|
networkConfigurations: NetworkConfigurationMap | undefined;
|
|
13
13
|
projectSettings: ProjectSettings | undefined;
|
|
14
|
+
transactionScreening?: TransactionScreeningService;
|
|
14
15
|
walletBook: WalletBookSchema;
|
|
15
16
|
walletConnectPreferredChains?: `eip155:${number}`[];
|
|
16
17
|
walletConnectorsProp?: WalletConnectorsMethod[];
|
|
@@ -30,9 +30,11 @@ var updatePrimaryWalletId = require('../../functions/updatePrimaryWalletId/updat
|
|
|
30
30
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
31
31
|
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
32
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
|
+
var api = require('../../../data/api/api.cjs');
|
|
33
34
|
require('@dynamic-labs/locale');
|
|
34
35
|
var wallets = require('../../../data/api/wallets/wallets.cjs');
|
|
35
36
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
37
|
+
var isEvmClientGasSponsorshipEnabled = require('../../functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.cjs');
|
|
36
38
|
var convertSdkUserToUserProfile = require('../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.cjs');
|
|
37
39
|
var useUser = require('../../../client/extension/user/useUser/useUser.cjs');
|
|
38
40
|
var useProjectSettings = require('../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.cjs');
|
|
@@ -56,7 +58,7 @@ var normalizeWaasChainName = require('./normalizeWaasChainName.cjs');
|
|
|
56
58
|
var normalizeWalletRequirements = require('./normalizeWalletRequirements.cjs');
|
|
57
59
|
|
|
58
60
|
const dynamicWaasKey = 'dynamicwaas';
|
|
59
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, getElevatedAccessToken, onUnauthorized, }) => {
|
|
61
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, getEvmGasSponsorshipEnabled = () => false, getElevatedAccessToken, onUnauthorized, }) => {
|
|
60
62
|
var _a, _b;
|
|
61
63
|
walletConnector.setEnvironmentId(environmentId);
|
|
62
64
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || apiUrl.DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -95,6 +97,16 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
95
97
|
if (isSolConnector && supportsSponsorshipSetting) {
|
|
96
98
|
walletConnector.setSvmGasSponsorshipEnabled(getSvmGasSponsorshipEnabled);
|
|
97
99
|
}
|
|
100
|
+
// Sync EVM gas sponsorship setting for EVM connectors, so the send flow can
|
|
101
|
+
// relay sponsored transactions instead of charging the wallet's native balance
|
|
102
|
+
const isEvmConnector = walletConnector.connectedChain === 'EVM';
|
|
103
|
+
const supportsEvmSponsorshipConfig = 'setEvmGasSponsorshipConfig' in walletConnector;
|
|
104
|
+
if (isEvmConnector && supportsEvmSponsorshipConfig) {
|
|
105
|
+
walletConnector.setEvmGasSponsorshipConfig({
|
|
106
|
+
getEnabled: getEvmGasSponsorshipEnabled,
|
|
107
|
+
getSdkApi: () => api.sdkApi(),
|
|
108
|
+
});
|
|
109
|
+
}
|
|
98
110
|
return walletConnector;
|
|
99
111
|
};
|
|
100
112
|
const useDynamicWaas = () => {
|
|
@@ -121,6 +133,9 @@ const useDynamicWaas = () => {
|
|
|
121
133
|
const svmGasSponsorshipEnabled = (_e = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _e !== void 0 ? _e : false;
|
|
122
134
|
const svmGasSponsorshipEnabledRef = React.useRef(svmGasSponsorshipEnabled);
|
|
123
135
|
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
136
|
+
const evmGasSponsorshipEnabled = isEvmClientGasSponsorshipEnabled.isEvmClientGasSponsorshipEnabled(projectSettings);
|
|
137
|
+
const evmGasSponsorshipEnabledRef = React.useRef(evmGasSponsorshipEnabled);
|
|
138
|
+
evmGasSponsorshipEnabledRef.current = evmGasSponsorshipEnabled;
|
|
124
139
|
const authToken = getMinAuthToken.getMinAuthToken();
|
|
125
140
|
const getMfaToken = useGetMfaToken.useGetMfaToken();
|
|
126
141
|
const getWalletPassword = useGetWalletPassword.useGetWalletPassword();
|
|
@@ -158,6 +173,7 @@ const useDynamicWaas = () => {
|
|
|
158
173
|
baseClientKeysharesRelayApiUrl,
|
|
159
174
|
environmentId,
|
|
160
175
|
getElevatedAccessToken,
|
|
176
|
+
getEvmGasSponsorshipEnabled: () => evmGasSponsorshipEnabledRef.current,
|
|
161
177
|
getMfaToken,
|
|
162
178
|
getSessionPublicKey: getSessionPublicKey.getSessionPublicKey,
|
|
163
179
|
getSignedSessionId: generateChainingSignature.generateChainingSignature,
|
|
@@ -12,7 +12,7 @@ export type WalletCreationRequirement = {
|
|
|
12
12
|
network?: string;
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled, getElevatedAccessToken, onUnauthorized, }: {
|
|
15
|
+
export declare const configWaasWalletConnector: ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode, getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled, getEvmGasSponsorshipEnabled, getElevatedAccessToken, onUnauthorized, }: {
|
|
16
16
|
walletConnector: IDynamicWaasConnector;
|
|
17
17
|
environmentId: string;
|
|
18
18
|
apiBaseUrl: string;
|
|
@@ -26,6 +26,7 @@ export declare const configWaasWalletConnector: ({ walletConnector, environmentI
|
|
|
26
26
|
}) => Promise<string | undefined>;
|
|
27
27
|
getWalletPassword?: GetWalletPasswordFn;
|
|
28
28
|
getSvmGasSponsorshipEnabled?: () => boolean;
|
|
29
|
+
getEvmGasSponsorshipEnabled?: () => boolean;
|
|
29
30
|
getElevatedAccessToken?: (params: {
|
|
30
31
|
scope: TokenScope;
|
|
31
32
|
}) => Promise<string | undefined>;
|
|
@@ -26,9 +26,11 @@ import { updatePrimaryWalletId } from '../../functions/updatePrimaryWalletId/upd
|
|
|
26
26
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
27
27
|
import { useApiBaseUrl, useEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
28
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
|
+
import { sdkApi } from '../../../data/api/api.js';
|
|
29
30
|
import '@dynamic-labs/locale';
|
|
30
31
|
import { softDeleteEmbeddedWallet, restoreEmbeddedWallet } from '../../../data/api/wallets/wallets.js';
|
|
31
32
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
33
|
+
import { isEvmClientGasSponsorshipEnabled } from '../../functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.js';
|
|
32
34
|
import { convertSdkUserToUserProfile } from '../../../client/extension/user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.js';
|
|
33
35
|
import { useUser } from '../../../client/extension/user/useUser/useUser.js';
|
|
34
36
|
import { useProjectSettings } from '../../../client/extension/projectSettings/useProjectSettings/useProjectSettings.js';
|
|
@@ -52,7 +54,7 @@ import { normalizeWaasChainName } from './normalizeWaasChainName.js';
|
|
|
52
54
|
import { normalizeWalletRequirements } from './normalizeWalletRequirements.js';
|
|
53
55
|
|
|
54
56
|
const dynamicWaasKey = 'dynamicwaas';
|
|
55
|
-
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, getElevatedAccessToken, onUnauthorized, }) => {
|
|
57
|
+
const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl, relayUrl, baseClientKeysharesRelayApiUrl, authMode = 'header', getSignedSessionId, getSessionPublicKey, getMfaToken, getWalletPassword, getSvmGasSponsorshipEnabled = () => false, getEvmGasSponsorshipEnabled = () => false, getElevatedAccessToken, onUnauthorized, }) => {
|
|
56
58
|
var _a, _b;
|
|
57
59
|
walletConnector.setEnvironmentId(environmentId);
|
|
58
60
|
walletConnector.setBaseApiUrl((_a = (apiBaseUrl || DEFAULT_WAAS_API_URL)) === null || _a === void 0 ? void 0 : _a.replace('/api/v0', ''));
|
|
@@ -91,6 +93,16 @@ const configWaasWalletConnector = ({ walletConnector, environmentId, apiBaseUrl,
|
|
|
91
93
|
if (isSolConnector && supportsSponsorshipSetting) {
|
|
92
94
|
walletConnector.setSvmGasSponsorshipEnabled(getSvmGasSponsorshipEnabled);
|
|
93
95
|
}
|
|
96
|
+
// Sync EVM gas sponsorship setting for EVM connectors, so the send flow can
|
|
97
|
+
// relay sponsored transactions instead of charging the wallet's native balance
|
|
98
|
+
const isEvmConnector = walletConnector.connectedChain === 'EVM';
|
|
99
|
+
const supportsEvmSponsorshipConfig = 'setEvmGasSponsorshipConfig' in walletConnector;
|
|
100
|
+
if (isEvmConnector && supportsEvmSponsorshipConfig) {
|
|
101
|
+
walletConnector.setEvmGasSponsorshipConfig({
|
|
102
|
+
getEnabled: getEvmGasSponsorshipEnabled,
|
|
103
|
+
getSdkApi: () => sdkApi(),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
94
106
|
return walletConnector;
|
|
95
107
|
};
|
|
96
108
|
const useDynamicWaas = () => {
|
|
@@ -117,6 +129,9 @@ const useDynamicWaas = () => {
|
|
|
117
129
|
const svmGasSponsorshipEnabled = (_e = embeddedWalletSettings === null || embeddedWalletSettings === void 0 ? void 0 : embeddedWalletSettings.svmGasSponsorshipEnabled) !== null && _e !== void 0 ? _e : false;
|
|
118
130
|
const svmGasSponsorshipEnabledRef = useRef(svmGasSponsorshipEnabled);
|
|
119
131
|
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
132
|
+
const evmGasSponsorshipEnabled = isEvmClientGasSponsorshipEnabled(projectSettings);
|
|
133
|
+
const evmGasSponsorshipEnabledRef = useRef(evmGasSponsorshipEnabled);
|
|
134
|
+
evmGasSponsorshipEnabledRef.current = evmGasSponsorshipEnabled;
|
|
120
135
|
const authToken = getMinAuthToken();
|
|
121
136
|
const getMfaToken = useGetMfaToken();
|
|
122
137
|
const getWalletPassword = useGetWalletPassword();
|
|
@@ -154,6 +169,7 @@ const useDynamicWaas = () => {
|
|
|
154
169
|
baseClientKeysharesRelayApiUrl,
|
|
155
170
|
environmentId,
|
|
156
171
|
getElevatedAccessToken,
|
|
172
|
+
getEvmGasSponsorshipEnabled: () => evmGasSponsorshipEnabledRef.current,
|
|
157
173
|
getMfaToken,
|
|
158
174
|
getSessionPublicKey,
|
|
159
175
|
getSignedSessionId: generateChainingSignature,
|
|
@@ -26,8 +26,8 @@ require('react-international-phone');
|
|
|
26
26
|
require('../../../store/state/nonce/nonce.cjs');
|
|
27
27
|
require('@dynamic-labs-wallet/browser-wallet-client');
|
|
28
28
|
require('@dynamic-labs/locale');
|
|
29
|
-
var user = require('../../../data/api/user/user.cjs');
|
|
30
29
|
var dynamicContextProps = require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
30
|
+
var user = require('../../../data/api/user/user.cjs');
|
|
31
31
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
32
32
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
33
33
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
@@ -22,8 +22,8 @@ import 'react-international-phone';
|
|
|
22
22
|
import '../../../store/state/nonce/nonce.js';
|
|
23
23
|
import '@dynamic-labs-wallet/browser-wallet-client';
|
|
24
24
|
import '@dynamic-labs/locale';
|
|
25
|
-
import { refreshUserJwt } from '../../../data/api/user/user.js';
|
|
26
25
|
import { getEnvironmentId } from '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
26
|
+
import { refreshUserJwt } from '../../../data/api/user/user.js';
|
|
27
27
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
28
28
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
29
29
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
@@ -45,13 +45,28 @@ const useSendDynamicProps = ({ settings: settings$1, environmentId, }) => {
|
|
|
45
45
|
};
|
|
46
46
|
const serializedEventsCallbacks = serializeEventsCallbacks(settings$1.events);
|
|
47
47
|
const serializedWalletConnectors = serializeWalletConnectors.serializeWalletConnectors(settings$1.walletConnectors);
|
|
48
|
-
const serializedDynamicContextProps = Object.assign(Object.assign({}, updatedDynamicProps), { settings: Object.assign(Object.assign({}, updatedDynamicProps.settings), { events: serializedEventsCallbacks, walletConnectors: serializedWalletConnectors }) });
|
|
48
|
+
const serializedDynamicContextProps = Object.assign(Object.assign({}, updatedDynamicProps), { settings: Object.assign(Object.assign({}, updatedDynamicProps.settings), { cssOverrides: summarizeCssOverrides(settings$1.cssOverrides), events: serializedEventsCallbacks, walletConnectors: serializedWalletConnectors }) });
|
|
49
49
|
settings.sendDynamicProps(environmentId, {
|
|
50
50
|
dynamicContextProps: serializedDynamicContextProps,
|
|
51
51
|
frameworkSettings: getFrameworkSettings(),
|
|
52
52
|
});
|
|
53
53
|
});
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Describes the configured CSS overrides without carrying the stylesheet
|
|
57
|
+
* itself. The raw CSS is several kilobytes of style-rule text, which reads as
|
|
58
|
+
* an injection payload to web application firewalls scoring this request body,
|
|
59
|
+
* and the shape of the overrides is all the settings telemetry needs.
|
|
60
|
+
*/
|
|
61
|
+
const summarizeCssOverrides = (cssOverrides) => {
|
|
62
|
+
if (!cssOverrides) {
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
if (typeof cssOverrides !== 'string') {
|
|
66
|
+
return { kind: 'element' };
|
|
67
|
+
}
|
|
68
|
+
return { characters: cssOverrides.length, kind: 'string' };
|
|
69
|
+
};
|
|
55
70
|
const serializeEventsCallbacks = (events) => {
|
|
56
71
|
try {
|
|
57
72
|
if (!events)
|
|
@@ -85,4 +100,5 @@ const getFrameworkSettings = () => {
|
|
|
85
100
|
};
|
|
86
101
|
|
|
87
102
|
exports.serializeEventsCallbacks = serializeEventsCallbacks;
|
|
103
|
+
exports.summarizeCssOverrides = summarizeCssOverrides;
|
|
88
104
|
exports.useSendDynamicProps = useSendDynamicProps;
|
|
@@ -5,5 +5,16 @@ type UseSendDynamicHookProps = {
|
|
|
5
5
|
environmentId: string;
|
|
6
6
|
};
|
|
7
7
|
export declare const useSendDynamicProps: ({ settings, environmentId, }: UseSendDynamicHookProps) => void;
|
|
8
|
+
type CssOverridesSummary = {
|
|
9
|
+
characters?: number;
|
|
10
|
+
kind: 'element' | 'string';
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Describes the configured CSS overrides without carrying the stylesheet
|
|
14
|
+
* itself. The raw CSS is several kilobytes of style-rule text, which reads as
|
|
15
|
+
* an injection payload to web application firewalls scoring this request body,
|
|
16
|
+
* and the shape of the overrides is all the settings telemetry needs.
|
|
17
|
+
*/
|
|
18
|
+
export declare const summarizeCssOverrides: (cssOverrides: DynamicContextProps['settings']['cssOverrides']) => CssOverridesSummary | undefined;
|
|
8
19
|
export declare const serializeEventsCallbacks: (events: DynamicEventsCallbacks | undefined) => string[] | undefined;
|
|
9
20
|
export {};
|
|
@@ -41,13 +41,28 @@ const useSendDynamicProps = ({ settings, environmentId, }) => {
|
|
|
41
41
|
};
|
|
42
42
|
const serializedEventsCallbacks = serializeEventsCallbacks(settings.events);
|
|
43
43
|
const serializedWalletConnectors = serializeWalletConnectors(settings.walletConnectors);
|
|
44
|
-
const serializedDynamicContextProps = Object.assign(Object.assign({}, updatedDynamicProps), { settings: Object.assign(Object.assign({}, updatedDynamicProps.settings), { events: serializedEventsCallbacks, walletConnectors: serializedWalletConnectors }) });
|
|
44
|
+
const serializedDynamicContextProps = Object.assign(Object.assign({}, updatedDynamicProps), { settings: Object.assign(Object.assign({}, updatedDynamicProps.settings), { cssOverrides: summarizeCssOverrides(settings.cssOverrides), events: serializedEventsCallbacks, walletConnectors: serializedWalletConnectors }) });
|
|
45
45
|
sendDynamicProps(environmentId, {
|
|
46
46
|
dynamicContextProps: serializedDynamicContextProps,
|
|
47
47
|
frameworkSettings: getFrameworkSettings(),
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Describes the configured CSS overrides without carrying the stylesheet
|
|
53
|
+
* itself. The raw CSS is several kilobytes of style-rule text, which reads as
|
|
54
|
+
* an injection payload to web application firewalls scoring this request body,
|
|
55
|
+
* and the shape of the overrides is all the settings telemetry needs.
|
|
56
|
+
*/
|
|
57
|
+
const summarizeCssOverrides = (cssOverrides) => {
|
|
58
|
+
if (!cssOverrides) {
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
if (typeof cssOverrides !== 'string') {
|
|
62
|
+
return { kind: 'element' };
|
|
63
|
+
}
|
|
64
|
+
return { characters: cssOverrides.length, kind: 'string' };
|
|
65
|
+
};
|
|
51
66
|
const serializeEventsCallbacks = (events) => {
|
|
52
67
|
try {
|
|
53
68
|
if (!events)
|
|
@@ -80,4 +95,4 @@ const getFrameworkSettings = () => {
|
|
|
80
95
|
});
|
|
81
96
|
};
|
|
82
97
|
|
|
83
|
-
export { serializeEventsCallbacks, useSendDynamicProps };
|
|
98
|
+
export { serializeEventsCallbacks, summarizeCssOverrides, useSendDynamicProps };
|
|
@@ -38,6 +38,7 @@ var dynamicContextProps = require('../../../store/state/dynamicContextProps/dyna
|
|
|
38
38
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
39
39
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
40
40
|
require('../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
|
41
|
+
var isEvmClientGasSponsorshipEnabled = require('../../functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.cjs');
|
|
41
42
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
42
43
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
43
44
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -133,6 +134,9 @@ onUnauthorized) => {
|
|
|
133
134
|
const svmGasSponsorshipEnabled = (_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.svmGasSponsorshipEnabled) !== null && _c !== void 0 ? _c : false;
|
|
134
135
|
const svmGasSponsorshipEnabledRef = React.useRef(svmGasSponsorshipEnabled);
|
|
135
136
|
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
137
|
+
const evmGasSponsorshipEnabled = isEvmClientGasSponsorshipEnabled.isEvmClientGasSponsorshipEnabled(projectSettings);
|
|
138
|
+
const evmGasSponsorshipEnabledRef = React.useRef(evmGasSponsorshipEnabled);
|
|
139
|
+
evmGasSponsorshipEnabledRef.current = evmGasSponsorshipEnabled;
|
|
136
140
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
137
141
|
return;
|
|
138
142
|
walletOptions.forEach((walletOption) => {
|
|
@@ -146,6 +150,7 @@ onUnauthorized) => {
|
|
|
146
150
|
apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : apiUrl.DEFAULT_WAAS_API_URL,
|
|
147
151
|
authMode: isCookieAuthEnabled ? 'cookie' : 'header',
|
|
148
152
|
environmentId,
|
|
153
|
+
getEvmGasSponsorshipEnabled: () => evmGasSponsorshipEnabledRef.current,
|
|
149
154
|
getMfaToken,
|
|
150
155
|
getSessionPublicKey: getSessionPublicKey.getSessionPublicKey,
|
|
151
156
|
getSignedSessionId: generateChainingSignature.generateChainingSignature,
|
|
@@ -34,6 +34,7 @@ import { useApiBaseUrl } from '../../../store/state/dynamicContextProps/dynamicC
|
|
|
34
34
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
35
35
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
36
36
|
import '../../functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|
|
37
|
+
import { isEvmClientGasSponsorshipEnabled } from '../../functions/isEvmClientGasSponsorshipEnabled/isEvmClientGasSponsorshipEnabled.js';
|
|
37
38
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
38
39
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
39
40
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -129,6 +130,9 @@ onUnauthorized) => {
|
|
|
129
130
|
const svmGasSponsorshipEnabled = (_c = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.embeddedWallets) === null || _b === void 0 ? void 0 : _b.svmGasSponsorshipEnabled) !== null && _c !== void 0 ? _c : false;
|
|
130
131
|
const svmGasSponsorshipEnabledRef = useRef(svmGasSponsorshipEnabled);
|
|
131
132
|
svmGasSponsorshipEnabledRef.current = svmGasSponsorshipEnabled;
|
|
133
|
+
const evmGasSponsorshipEnabled = isEvmClientGasSponsorshipEnabled(projectSettings);
|
|
134
|
+
const evmGasSponsorshipEnabledRef = useRef(evmGasSponsorshipEnabled);
|
|
135
|
+
evmGasSponsorshipEnabledRef.current = evmGasSponsorshipEnabled;
|
|
132
136
|
if (!(walletOptions === null || walletOptions === void 0 ? void 0 : walletOptions.length))
|
|
133
137
|
return;
|
|
134
138
|
walletOptions.forEach((walletOption) => {
|
|
@@ -142,6 +146,7 @@ onUnauthorized) => {
|
|
|
142
146
|
apiBaseUrl: apiBaseUrl !== null && apiBaseUrl !== void 0 ? apiBaseUrl : DEFAULT_WAAS_API_URL,
|
|
143
147
|
authMode: isCookieAuthEnabled ? 'cookie' : 'header',
|
|
144
148
|
environmentId,
|
|
149
|
+
getEvmGasSponsorshipEnabled: () => evmGasSponsorshipEnabledRef.current,
|
|
145
150
|
getMfaToken,
|
|
146
151
|
getSessionPublicKey,
|
|
147
152
|
getSignedSessionId: generateChainingSignature,
|
package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.cjs
CHANGED
|
@@ -35,8 +35,8 @@ require('eventemitter3');
|
|
|
35
35
|
require('@dynamic-labs-sdk/client');
|
|
36
36
|
require('../../config/ApiEndpoint.cjs');
|
|
37
37
|
require('@dynamic-labs/locale');
|
|
38
|
-
var user = require('../../data/api/user/user.cjs');
|
|
39
38
|
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
39
|
+
var user = require('../../data/api/user/user.cjs');
|
|
40
40
|
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
41
41
|
require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
42
42
|
require('../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.cjs');
|
package/src/lib/views/MergeUserAccountsWithSameEmailView/MergeUserAccountsWithSameEmailView.js
CHANGED
|
@@ -31,8 +31,8 @@ import 'eventemitter3';
|
|
|
31
31
|
import '@dynamic-labs-sdk/client';
|
|
32
32
|
import '../../config/ApiEndpoint.js';
|
|
33
33
|
import '@dynamic-labs/locale';
|
|
34
|
-
import { mergeUserAccounts } from '../../data/api/user/user.js';
|
|
35
34
|
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
35
|
+
import { mergeUserAccounts } from '../../data/api/user/user.js';
|
|
36
36
|
import '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
37
37
|
import '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
38
38
|
import '../../utils/functions/getWaasAddressTypeLabel/getWaasAddressTypeLabel.js';
|