@dynamic-labs/sdk-react-core 4.100.3 → 4.100.5
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 +17 -0
- package/package.cjs +4 -4
- package/package.js +4 -4
- package/package.json +15 -15
- package/src/lib/styles/index.shadow.cjs +1 -1
- package/src/lib/styles/index.shadow.js +1 -1
- package/src/lib/utils/hooks/useDynamicWaas/constants.cjs +16 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.d.ts +14 -0
- package/src/lib/utils/hooks/useDynamicWaas/constants.js +15 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +13 -31
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +14 -32
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +25 -14
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +25 -14
|
@@ -7,8 +7,24 @@ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to
|
|
|
7
7
|
const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
|
|
8
8
|
const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
|
|
9
9
|
const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
|
|
10
|
+
const UPGRADE_TO_WAAS_MESSAGES = {
|
|
11
|
+
completed: 'Upgrade to WaaS - migration completed',
|
|
12
|
+
import: 'Upgrade to WaaS - importing private key',
|
|
13
|
+
restore: 'Upgrade to WaaS - restoring legacy wallet after failed import',
|
|
14
|
+
softDelete: 'Upgrade to WaaS - soft deleting legacy wallet',
|
|
15
|
+
started: 'Upgrade to WaaS - migration started',
|
|
16
|
+
};
|
|
17
|
+
const UPGRADE_TO_WAAS_KEYS = {
|
|
18
|
+
completed: 'upgradeToWaasCompleted',
|
|
19
|
+
import: 'upgradeToWaasImportPrivateKey',
|
|
20
|
+
restore: 'upgradeToWaasRestore',
|
|
21
|
+
softDelete: 'upgradeToWaasSoftDelete',
|
|
22
|
+
started: 'upgradeToWaasStarted',
|
|
23
|
+
};
|
|
10
24
|
|
|
11
25
|
exports.DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR;
|
|
12
26
|
exports.INVALID_CHAINS_ERROR = INVALID_CHAINS_ERROR;
|
|
13
27
|
exports.NO_ENABLED_CHAINS_ERROR = NO_ENABLED_CHAINS_ERROR;
|
|
28
|
+
exports.UPGRADE_TO_WAAS_KEYS = UPGRADE_TO_WAAS_KEYS;
|
|
29
|
+
exports.UPGRADE_TO_WAAS_MESSAGES = UPGRADE_TO_WAAS_MESSAGES;
|
|
14
30
|
exports.WALLET_CREATION_FAILED_ERROR = WALLET_CREATION_FAILED_ERROR;
|
|
@@ -2,3 +2,17 @@ export declare const NO_ENABLED_CHAINS_ERROR = "No enabled embedded wallet chain
|
|
|
2
2
|
export declare const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = "Dynamic Waas connector not found";
|
|
3
3
|
export declare const INVALID_CHAINS_ERROR = "The following chains are not enabled for embedded wallets";
|
|
4
4
|
export declare const WALLET_CREATION_FAILED_ERROR = "Failed to create wallet account for the following chains";
|
|
5
|
+
export declare const UPGRADE_TO_WAAS_MESSAGES: {
|
|
6
|
+
readonly completed: "Upgrade to WaaS - migration completed";
|
|
7
|
+
readonly import: "Upgrade to WaaS - importing private key";
|
|
8
|
+
readonly restore: "Upgrade to WaaS - restoring legacy wallet after failed import";
|
|
9
|
+
readonly softDelete: "Upgrade to WaaS - soft deleting legacy wallet";
|
|
10
|
+
readonly started: "Upgrade to WaaS - migration started";
|
|
11
|
+
};
|
|
12
|
+
export declare const UPGRADE_TO_WAAS_KEYS: {
|
|
13
|
+
readonly completed: "upgradeToWaasCompleted";
|
|
14
|
+
readonly import: "upgradeToWaasImportPrivateKey";
|
|
15
|
+
readonly restore: "upgradeToWaasRestore";
|
|
16
|
+
readonly softDelete: "upgradeToWaasSoftDelete";
|
|
17
|
+
readonly started: "upgradeToWaasStarted";
|
|
18
|
+
};
|
|
@@ -3,5 +3,19 @@ const NO_ENABLED_CHAINS_ERROR = 'No enabled embedded wallet chains. Please go to
|
|
|
3
3
|
const DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR = 'Dynamic Waas connector not found';
|
|
4
4
|
const INVALID_CHAINS_ERROR = 'The following chains are not enabled for embedded wallets';
|
|
5
5
|
const WALLET_CREATION_FAILED_ERROR = 'Failed to create wallet account for the following chains';
|
|
6
|
+
const UPGRADE_TO_WAAS_MESSAGES = {
|
|
7
|
+
completed: 'Upgrade to WaaS - migration completed',
|
|
8
|
+
import: 'Upgrade to WaaS - importing private key',
|
|
9
|
+
restore: 'Upgrade to WaaS - restoring legacy wallet after failed import',
|
|
10
|
+
softDelete: 'Upgrade to WaaS - soft deleting legacy wallet',
|
|
11
|
+
started: 'Upgrade to WaaS - migration started',
|
|
12
|
+
};
|
|
13
|
+
const UPGRADE_TO_WAAS_KEYS = {
|
|
14
|
+
completed: 'upgradeToWaasCompleted',
|
|
15
|
+
import: 'upgradeToWaasImportPrivateKey',
|
|
16
|
+
restore: 'upgradeToWaasRestore',
|
|
17
|
+
softDelete: 'upgradeToWaasSoftDelete',
|
|
18
|
+
started: 'upgradeToWaasStarted',
|
|
19
|
+
};
|
|
6
20
|
|
|
7
|
-
export { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, INVALID_CHAINS_ERROR, NO_ENABLED_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR };
|
|
21
|
+
export { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, INVALID_CHAINS_ERROR, NO_ENABLED_CHAINS_ERROR, UPGRADE_TO_WAAS_KEYS, UPGRADE_TO_WAAS_MESSAGES, WALLET_CREATION_FAILED_ERROR };
|
|
@@ -511,36 +511,28 @@ const useDynamicWaas = () => {
|
|
|
511
511
|
throw new utils.DynamicError('Wallet connector not found', 'wallet_connector_not_found');
|
|
512
512
|
}
|
|
513
513
|
isUpgrading.current = true;
|
|
514
|
+
const migrationStart = Date.now();
|
|
514
515
|
let softDeleteSucceeded = false;
|
|
515
516
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
516
517
|
const normalizedWalletId = (walletId === null || walletId === void 0 ? void 0 : walletId.replace('-zerodev', '')) || walletId;
|
|
517
|
-
|
|
518
|
+
const upgradeLogBase = {
|
|
518
519
|
chain: chainName,
|
|
519
520
|
environmentId,
|
|
520
|
-
key: 'upgradeToWaasStarted',
|
|
521
521
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
522
522
|
walletId: normalizedWalletId,
|
|
523
|
-
}
|
|
523
|
+
};
|
|
524
|
+
walletConnectorCore.logger.info(constants.UPGRADE_TO_WAAS_MESSAGES.started, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.started }, upgradeLogBase));
|
|
525
|
+
walletConnectorCore.logger.instrument(constants.UPGRADE_TO_WAAS_MESSAGES.started, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.started, time: 0 }, upgradeLogBase));
|
|
524
526
|
try {
|
|
525
|
-
walletConnectorCore.logger.info(
|
|
526
|
-
|
|
527
|
-
environmentId,
|
|
528
|
-
key: 'upgradeToWaasSoftDelete',
|
|
529
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
530
|
-
walletId: normalizedWalletId,
|
|
531
|
-
});
|
|
527
|
+
walletConnectorCore.logger.info(constants.UPGRADE_TO_WAAS_MESSAGES.softDelete, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.softDelete }, upgradeLogBase));
|
|
528
|
+
walletConnectorCore.logger.instrument(constants.UPGRADE_TO_WAAS_MESSAGES.softDelete, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.softDelete, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
532
529
|
yield wallets.softDeleteEmbeddedWallet({
|
|
533
530
|
environmentId,
|
|
534
531
|
walletId: normalizedWalletId,
|
|
535
532
|
});
|
|
536
533
|
softDeleteSucceeded = true;
|
|
537
|
-
walletConnectorCore.logger.info(
|
|
538
|
-
|
|
539
|
-
environmentId,
|
|
540
|
-
key: 'upgradeToWaasImportPrivateKey',
|
|
541
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
542
|
-
walletId: normalizedWalletId,
|
|
543
|
-
});
|
|
534
|
+
walletConnectorCore.logger.info(constants.UPGRADE_TO_WAAS_MESSAGES.import, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.import }, upgradeLogBase));
|
|
535
|
+
walletConnectorCore.logger.instrument(constants.UPGRADE_TO_WAAS_MESSAGES.import, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.import, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
544
536
|
yield walletConnector.importPrivateKey({
|
|
545
537
|
chainName,
|
|
546
538
|
legacyWalletId: normalizedWalletId,
|
|
@@ -549,13 +541,8 @@ const useDynamicWaas = () => {
|
|
|
549
541
|
publicAddressCheck: wallet.address,
|
|
550
542
|
});
|
|
551
543
|
isUpgrading.current = false;
|
|
552
|
-
walletConnectorCore.logger.info(
|
|
553
|
-
|
|
554
|
-
environmentId,
|
|
555
|
-
key: 'upgradeToWaasCompleted',
|
|
556
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
557
|
-
walletId: normalizedWalletId,
|
|
558
|
-
});
|
|
544
|
+
walletConnectorCore.logger.info(constants.UPGRADE_TO_WAAS_MESSAGES.completed, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.completed }, upgradeLogBase));
|
|
545
|
+
walletConnectorCore.logger.instrument(constants.UPGRADE_TO_WAAS_MESSAGES.completed, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.completed, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
559
546
|
}
|
|
560
547
|
catch (error) {
|
|
561
548
|
walletConnectorCore.logger.error('Upgrade to WaaS - migration failed', {
|
|
@@ -568,13 +555,8 @@ const useDynamicWaas = () => {
|
|
|
568
555
|
});
|
|
569
556
|
// If soft delete succeeded but import failed, try to restore the wallet
|
|
570
557
|
if (softDeleteSucceeded) {
|
|
571
|
-
walletConnectorCore.logger.info(
|
|
572
|
-
|
|
573
|
-
environmentId,
|
|
574
|
-
key: 'upgradeToWaasRestore',
|
|
575
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
576
|
-
walletId: normalizedWalletId,
|
|
577
|
-
});
|
|
558
|
+
walletConnectorCore.logger.info(constants.UPGRADE_TO_WAAS_MESSAGES.restore, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.restore }, upgradeLogBase));
|
|
559
|
+
walletConnectorCore.logger.instrument(constants.UPGRADE_TO_WAAS_MESSAGES.restore, Object.assign({ key: constants.UPGRADE_TO_WAAS_KEYS.restore, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
578
560
|
yield wallets.restoreEmbeddedWallet({
|
|
579
561
|
environmentId,
|
|
580
562
|
walletId: normalizedWalletId,
|
|
@@ -49,7 +49,7 @@ import { useGetWalletPassword } from '../useGetWalletPassword/useGetWalletPasswo
|
|
|
49
49
|
import { useRefreshAuth } from '../useRefreshAuth/useRefreshAuth.js';
|
|
50
50
|
import { findSmartWallet } from '../useWalletConnectors/utils/smartWallet/smartWallet.js';
|
|
51
51
|
import { useGetElevatedAccessToken } from '../useGetElevatedAccessToken/useGetElevatedAccessToken.js';
|
|
52
|
-
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
52
|
+
import { DYNAMIC_WAAS_CONNECTOR_NOT_FOUND_ERROR, NO_ENABLED_CHAINS_ERROR, UPGRADE_TO_WAAS_MESSAGES, UPGRADE_TO_WAAS_KEYS, INVALID_CHAINS_ERROR, WALLET_CREATION_FAILED_ERROR } from './constants.js';
|
|
53
53
|
import { normalizeWaasChainName } from './normalizeWaasChainName.js';
|
|
54
54
|
import { normalizeWalletRequirements } from './normalizeWalletRequirements.js';
|
|
55
55
|
|
|
@@ -507,36 +507,28 @@ const useDynamicWaas = () => {
|
|
|
507
507
|
throw new DynamicError('Wallet connector not found', 'wallet_connector_not_found');
|
|
508
508
|
}
|
|
509
509
|
isUpgrading.current = true;
|
|
510
|
+
const migrationStart = Date.now();
|
|
510
511
|
let softDeleteSucceeded = false;
|
|
511
512
|
// 7702 wallets have a -zerodev suffix because it's a credential created on the fly
|
|
512
513
|
const normalizedWalletId = (walletId === null || walletId === void 0 ? void 0 : walletId.replace('-zerodev', '')) || walletId;
|
|
513
|
-
|
|
514
|
+
const upgradeLogBase = {
|
|
514
515
|
chain: chainName,
|
|
515
516
|
environmentId,
|
|
516
|
-
key: 'upgradeToWaasStarted',
|
|
517
517
|
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
518
518
|
walletId: normalizedWalletId,
|
|
519
|
-
}
|
|
519
|
+
};
|
|
520
|
+
logger.info(UPGRADE_TO_WAAS_MESSAGES.started, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.started }, upgradeLogBase));
|
|
521
|
+
logger.instrument(UPGRADE_TO_WAAS_MESSAGES.started, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.started, time: 0 }, upgradeLogBase));
|
|
520
522
|
try {
|
|
521
|
-
logger.info(
|
|
522
|
-
|
|
523
|
-
environmentId,
|
|
524
|
-
key: 'upgradeToWaasSoftDelete',
|
|
525
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
526
|
-
walletId: normalizedWalletId,
|
|
527
|
-
});
|
|
523
|
+
logger.info(UPGRADE_TO_WAAS_MESSAGES.softDelete, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.softDelete }, upgradeLogBase));
|
|
524
|
+
logger.instrument(UPGRADE_TO_WAAS_MESSAGES.softDelete, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.softDelete, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
528
525
|
yield softDeleteEmbeddedWallet({
|
|
529
526
|
environmentId,
|
|
530
527
|
walletId: normalizedWalletId,
|
|
531
528
|
});
|
|
532
529
|
softDeleteSucceeded = true;
|
|
533
|
-
logger.info(
|
|
534
|
-
|
|
535
|
-
environmentId,
|
|
536
|
-
key: 'upgradeToWaasImportPrivateKey',
|
|
537
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
538
|
-
walletId: normalizedWalletId,
|
|
539
|
-
});
|
|
530
|
+
logger.info(UPGRADE_TO_WAAS_MESSAGES.import, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.import }, upgradeLogBase));
|
|
531
|
+
logger.instrument(UPGRADE_TO_WAAS_MESSAGES.import, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.import, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
540
532
|
yield walletConnector.importPrivateKey({
|
|
541
533
|
chainName,
|
|
542
534
|
legacyWalletId: normalizedWalletId,
|
|
@@ -545,13 +537,8 @@ const useDynamicWaas = () => {
|
|
|
545
537
|
publicAddressCheck: wallet.address,
|
|
546
538
|
});
|
|
547
539
|
isUpgrading.current = false;
|
|
548
|
-
logger.info(
|
|
549
|
-
|
|
550
|
-
environmentId,
|
|
551
|
-
key: 'upgradeToWaasCompleted',
|
|
552
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
553
|
-
walletId: normalizedWalletId,
|
|
554
|
-
});
|
|
540
|
+
logger.info(UPGRADE_TO_WAAS_MESSAGES.completed, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.completed }, upgradeLogBase));
|
|
541
|
+
logger.instrument(UPGRADE_TO_WAAS_MESSAGES.completed, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.completed, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
555
542
|
}
|
|
556
543
|
catch (error) {
|
|
557
544
|
logger.error('Upgrade to WaaS - migration failed', {
|
|
@@ -564,13 +551,8 @@ const useDynamicWaas = () => {
|
|
|
564
551
|
});
|
|
565
552
|
// If soft delete succeeded but import failed, try to restore the wallet
|
|
566
553
|
if (softDeleteSucceeded) {
|
|
567
|
-
logger.info(
|
|
568
|
-
|
|
569
|
-
environmentId,
|
|
570
|
-
key: 'upgradeToWaasRestore',
|
|
571
|
-
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
572
|
-
walletId: normalizedWalletId,
|
|
573
|
-
});
|
|
554
|
+
logger.info(UPGRADE_TO_WAAS_MESSAGES.restore, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.restore }, upgradeLogBase));
|
|
555
|
+
logger.instrument(UPGRADE_TO_WAAS_MESSAGES.restore, Object.assign({ key: UPGRADE_TO_WAAS_KEYS.restore, time: Date.now() - migrationStart }, upgradeLogBase));
|
|
574
556
|
yield restoreEmbeddedWallet({
|
|
575
557
|
environmentId,
|
|
576
558
|
walletId: normalizedWalletId,
|
|
@@ -138,7 +138,7 @@ var SimulationStatus;
|
|
|
138
138
|
SimulationStatus["SUCCESS"] = "success";
|
|
139
139
|
})(SimulationStatus || (SimulationStatus = {}));
|
|
140
140
|
const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
|
|
141
|
-
var _a, _b, _c;
|
|
141
|
+
var _a, _b, _c, _d;
|
|
142
142
|
const { primaryWallet, environmentId } = useInternalDynamicContext.useInternalDynamicContext();
|
|
143
143
|
// The connector that is actually signing this transaction. A transaction can
|
|
144
144
|
// be sent from a non-primary wallet (e.g. an EVM wallet while the primary
|
|
@@ -148,6 +148,14 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
148
148
|
const activeConnector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
149
149
|
const projectSettings = useProjectSettings.useProjectSettings();
|
|
150
150
|
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;
|
|
151
|
+
// Solana sponsorship is applied at send time, so before that the
|
|
152
|
+
// transaction itself reports unsponsored. A per-transaction sponsorship mode
|
|
153
|
+
// overrides the project default.
|
|
154
|
+
const sponsorshipMode = (_d = transaction.sponsorshipMode) !== null && _d !== void 0 ? _d : 'auto';
|
|
155
|
+
const isSvm = (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'SOL';
|
|
156
|
+
const isSvmSponsorshipRequired = isSvm && sponsorshipMode === 'required';
|
|
157
|
+
const treatSvmAsSponsored = isSvmSponsorshipRequired ||
|
|
158
|
+
(isSvm && sponsorshipMode === 'auto' && svmGasSponsorshipEnabled);
|
|
151
159
|
const [isGasSponsored, setIsGasSponsored] = React.useState(false);
|
|
152
160
|
const [isGasSponsoredLoading, setIsGasSponsoredLoading] = React.useState(false);
|
|
153
161
|
const update = useForceUpdate.useForceUpdate();
|
|
@@ -169,7 +177,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
169
177
|
const [preSubmitValidationError, setPreSubmitValidationError] = React.useState(undefined);
|
|
170
178
|
const isFetchingSimulationRef = React.useRef(false);
|
|
171
179
|
const fetchSimulationResult = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
172
|
-
var
|
|
180
|
+
var _e, _f, _g, _h, _j, _k;
|
|
173
181
|
if (simulationState.status !== SimulationStatus.LOADING) {
|
|
174
182
|
return;
|
|
175
183
|
}
|
|
@@ -207,19 +215,19 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
207
215
|
const formattedUserOperation = yield connector.formatUserOperation(userOperation);
|
|
208
216
|
// Set the gas fee on the transaction, only for zero dev
|
|
209
217
|
transaction.fee.gas = calculateGasUnits(userOperation);
|
|
210
|
-
const entryPoint = yield ((
|
|
218
|
+
const entryPoint = yield ((_e = connector.getAccountAbstractionProvider()) === null || _e === void 0 ? void 0 : _e.account.entryPoint);
|
|
211
219
|
if (!entryPoint) {
|
|
212
220
|
logger.logger.error('[TransactionConfirmationView] Simulation failed: No entry point address found');
|
|
213
221
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
214
222
|
return;
|
|
215
223
|
}
|
|
216
|
-
setRecipient((
|
|
224
|
+
setRecipient((_f = transaction === null || transaction === void 0 ? void 0 : transaction.getTransactionRecipient) === null || _f === void 0 ? void 0 : _f.call(transaction));
|
|
217
225
|
result = yield blockaid.simulateBlockaidUserOperation({
|
|
218
226
|
chainId: String(chainId),
|
|
219
227
|
entryPoint,
|
|
220
228
|
environmentId,
|
|
221
229
|
userOperation: formattedUserOperation,
|
|
222
|
-
value: ((
|
|
230
|
+
value: ((_g = transaction.value) === null || _g === void 0 ? void 0 : _g.toString()) || '0',
|
|
223
231
|
});
|
|
224
232
|
}
|
|
225
233
|
else {
|
|
@@ -230,7 +238,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
230
238
|
else {
|
|
231
239
|
// Handle SOLANA
|
|
232
240
|
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'SOL') {
|
|
233
|
-
const encodedTransactions = (
|
|
241
|
+
const encodedTransactions = (_h = transaction.multipleTransactions) === null || _h === void 0 ? void 0 : _h.map((tx) => bs58__default["default"].encode(tx.serialize({ requireAllSignatures: false })));
|
|
234
242
|
if (!encodedTransactions) {
|
|
235
243
|
logger.logger.error('[TransactionConfirmationView] Simulation failed: No encoded transactions');
|
|
236
244
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
@@ -244,7 +252,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
244
252
|
});
|
|
245
253
|
}
|
|
246
254
|
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'EVM') {
|
|
247
|
-
setRecipient((
|
|
255
|
+
setRecipient((_j = transaction === null || transaction === void 0 ? void 0 : transaction.getTransactionRecipient) === null || _j === void 0 ? void 0 : _j.call(transaction));
|
|
248
256
|
// EVM
|
|
249
257
|
result = yield blockaid.simulateBlockaidEVMTransaction({
|
|
250
258
|
chainId: String(chainId),
|
|
@@ -252,7 +260,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
252
260
|
environmentId,
|
|
253
261
|
from: transaction.from,
|
|
254
262
|
to: transaction.to || '',
|
|
255
|
-
value: ((
|
|
263
|
+
value: ((_k = transaction.value) === null || _k === void 0 ? void 0 : _k.toString()) || '0',
|
|
256
264
|
});
|
|
257
265
|
}
|
|
258
266
|
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'TON') {
|
|
@@ -331,18 +339,21 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
331
339
|
// confirmation card renders the gas row with a `--` value
|
|
332
340
|
// (since `fee.gas = 0n` for sponsored calls). Re-read once
|
|
333
341
|
// the cached flag is populated so the row hides itself.
|
|
334
|
-
|
|
342
|
+
// A required Solana mode is guaranteed to be sponsored at send
|
|
343
|
+
// time, so the unsigned transaction's `false` must not override it.
|
|
344
|
+
// In `auto`, sponsorship can still be skipped, so keep the re-read.
|
|
345
|
+
if (transaction.isGasSponsored && !isSvmSponsorshipRequired) {
|
|
335
346
|
setIsGasSponsored(transaction.isGasSponsored());
|
|
336
347
|
}
|
|
337
348
|
update();
|
|
338
349
|
});
|
|
339
350
|
}
|
|
340
351
|
}
|
|
341
|
-
}, [activeConnector, transaction, update]);
|
|
352
|
+
}, [activeConnector, isSvmSponsorshipRequired, transaction, update]);
|
|
342
353
|
React.useEffect(() => {
|
|
343
|
-
//
|
|
344
|
-
//
|
|
345
|
-
if (
|
|
354
|
+
// Treat as sponsored before the fee payer is actually replaced (which
|
|
355
|
+
// happens at send time).
|
|
356
|
+
if (treatSvmAsSponsored) {
|
|
346
357
|
setIsGasSponsored(true);
|
|
347
358
|
return;
|
|
348
359
|
}
|
|
@@ -352,7 +363,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
352
363
|
if (transaction.isGasSponsored) {
|
|
353
364
|
setIsGasSponsored(transaction.isGasSponsored());
|
|
354
365
|
}
|
|
355
|
-
}, [transaction,
|
|
366
|
+
}, [transaction, treatSvmAsSponsored]);
|
|
356
367
|
const { mutate: send, isLoading, error: transactionError, } = useMutation.useMutation(mutation, {
|
|
357
368
|
onFailure: React.useCallback((error) => {
|
|
358
369
|
fetchTransactionFee();
|
|
@@ -130,7 +130,7 @@ var SimulationStatus;
|
|
|
130
130
|
SimulationStatus["SUCCESS"] = "success";
|
|
131
131
|
})(SimulationStatus || (SimulationStatus = {}));
|
|
132
132
|
const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation, onClickBack, walletConnector, onClickClose, title, displayPoweredByDynamicFooter = false, copykey, hideModal, currentToken, isNativeToken, transactionValue, isModal, sendBalanceTransaction, }) => {
|
|
133
|
-
var _a, _b, _c;
|
|
133
|
+
var _a, _b, _c, _d;
|
|
134
134
|
const { primaryWallet, environmentId } = useInternalDynamicContext();
|
|
135
135
|
// The connector that is actually signing this transaction. A transaction can
|
|
136
136
|
// be sent from a non-primary wallet (e.g. an EVM wallet while the primary
|
|
@@ -140,6 +140,14 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
140
140
|
const activeConnector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
141
141
|
const projectSettings = useProjectSettings();
|
|
142
142
|
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;
|
|
143
|
+
// Solana sponsorship is applied at send time, so before that the
|
|
144
|
+
// transaction itself reports unsponsored. A per-transaction sponsorship mode
|
|
145
|
+
// overrides the project default.
|
|
146
|
+
const sponsorshipMode = (_d = transaction.sponsorshipMode) !== null && _d !== void 0 ? _d : 'auto';
|
|
147
|
+
const isSvm = (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'SOL';
|
|
148
|
+
const isSvmSponsorshipRequired = isSvm && sponsorshipMode === 'required';
|
|
149
|
+
const treatSvmAsSponsored = isSvmSponsorshipRequired ||
|
|
150
|
+
(isSvm && sponsorshipMode === 'auto' && svmGasSponsorshipEnabled);
|
|
143
151
|
const [isGasSponsored, setIsGasSponsored] = useState(false);
|
|
144
152
|
const [isGasSponsoredLoading, setIsGasSponsoredLoading] = useState(false);
|
|
145
153
|
const update = useForceUpdate();
|
|
@@ -161,7 +169,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
161
169
|
const [preSubmitValidationError, setPreSubmitValidationError] = useState(undefined);
|
|
162
170
|
const isFetchingSimulationRef = useRef(false);
|
|
163
171
|
const fetchSimulationResult = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
|
-
var
|
|
172
|
+
var _e, _f, _g, _h, _j, _k;
|
|
165
173
|
if (simulationState.status !== SimulationStatus.LOADING) {
|
|
166
174
|
return;
|
|
167
175
|
}
|
|
@@ -199,19 +207,19 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
199
207
|
const formattedUserOperation = yield connector.formatUserOperation(userOperation);
|
|
200
208
|
// Set the gas fee on the transaction, only for zero dev
|
|
201
209
|
transaction.fee.gas = calculateGasUnits(userOperation);
|
|
202
|
-
const entryPoint = yield ((
|
|
210
|
+
const entryPoint = yield ((_e = connector.getAccountAbstractionProvider()) === null || _e === void 0 ? void 0 : _e.account.entryPoint);
|
|
203
211
|
if (!entryPoint) {
|
|
204
212
|
logger.error('[TransactionConfirmationView] Simulation failed: No entry point address found');
|
|
205
213
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
206
214
|
return;
|
|
207
215
|
}
|
|
208
|
-
setRecipient((
|
|
216
|
+
setRecipient((_f = transaction === null || transaction === void 0 ? void 0 : transaction.getTransactionRecipient) === null || _f === void 0 ? void 0 : _f.call(transaction));
|
|
209
217
|
result = yield simulateBlockaidUserOperation({
|
|
210
218
|
chainId: String(chainId),
|
|
211
219
|
entryPoint,
|
|
212
220
|
environmentId,
|
|
213
221
|
userOperation: formattedUserOperation,
|
|
214
|
-
value: ((
|
|
222
|
+
value: ((_g = transaction.value) === null || _g === void 0 ? void 0 : _g.toString()) || '0',
|
|
215
223
|
});
|
|
216
224
|
}
|
|
217
225
|
else {
|
|
@@ -222,7 +230,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
222
230
|
else {
|
|
223
231
|
// Handle SOLANA
|
|
224
232
|
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'SOL') {
|
|
225
|
-
const encodedTransactions = (
|
|
233
|
+
const encodedTransactions = (_h = transaction.multipleTransactions) === null || _h === void 0 ? void 0 : _h.map((tx) => bs58.encode(tx.serialize({ requireAllSignatures: false })));
|
|
226
234
|
if (!encodedTransactions) {
|
|
227
235
|
logger.error('[TransactionConfirmationView] Simulation failed: No encoded transactions');
|
|
228
236
|
setSimulationState({ status: SimulationStatus.FAILED });
|
|
@@ -236,7 +244,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
236
244
|
});
|
|
237
245
|
}
|
|
238
246
|
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'EVM') {
|
|
239
|
-
setRecipient((
|
|
247
|
+
setRecipient((_j = transaction === null || transaction === void 0 ? void 0 : transaction.getTransactionRecipient) === null || _j === void 0 ? void 0 : _j.call(transaction));
|
|
240
248
|
// EVM
|
|
241
249
|
result = yield simulateBlockaidEVMTransaction({
|
|
242
250
|
chainId: String(chainId),
|
|
@@ -244,7 +252,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
244
252
|
environmentId,
|
|
245
253
|
from: transaction.from,
|
|
246
254
|
to: transaction.to || '',
|
|
247
|
-
value: ((
|
|
255
|
+
value: ((_k = transaction.value) === null || _k === void 0 ? void 0 : _k.toString()) || '0',
|
|
248
256
|
});
|
|
249
257
|
}
|
|
250
258
|
else if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.connectedChain) === 'TON') {
|
|
@@ -323,18 +331,21 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
323
331
|
// confirmation card renders the gas row with a `--` value
|
|
324
332
|
// (since `fee.gas = 0n` for sponsored calls). Re-read once
|
|
325
333
|
// the cached flag is populated so the row hides itself.
|
|
326
|
-
|
|
334
|
+
// A required Solana mode is guaranteed to be sponsored at send
|
|
335
|
+
// time, so the unsigned transaction's `false` must not override it.
|
|
336
|
+
// In `auto`, sponsorship can still be skipped, so keep the re-read.
|
|
337
|
+
if (transaction.isGasSponsored && !isSvmSponsorshipRequired) {
|
|
327
338
|
setIsGasSponsored(transaction.isGasSponsored());
|
|
328
339
|
}
|
|
329
340
|
update();
|
|
330
341
|
});
|
|
331
342
|
}
|
|
332
343
|
}
|
|
333
|
-
}, [activeConnector, transaction, update]);
|
|
344
|
+
}, [activeConnector, isSvmSponsorshipRequired, transaction, update]);
|
|
334
345
|
useEffect(() => {
|
|
335
|
-
//
|
|
336
|
-
//
|
|
337
|
-
if (
|
|
346
|
+
// Treat as sponsored before the fee payer is actually replaced (which
|
|
347
|
+
// happens at send time).
|
|
348
|
+
if (treatSvmAsSponsored) {
|
|
338
349
|
setIsGasSponsored(true);
|
|
339
350
|
return;
|
|
340
351
|
}
|
|
@@ -344,7 +355,7 @@ const TransactionConfirmationView = ({ transaction, onError, onSuccess, mutation
|
|
|
344
355
|
if (transaction.isGasSponsored) {
|
|
345
356
|
setIsGasSponsored(transaction.isGasSponsored());
|
|
346
357
|
}
|
|
347
|
-
}, [transaction,
|
|
358
|
+
}, [transaction, treatSvmAsSponsored]);
|
|
348
359
|
const { mutate: send, isLoading, error: transactionError, } = useMutation(mutation, {
|
|
349
360
|
onFailure: useCallback((error) => {
|
|
350
361
|
fetchTransactionFee();
|