@dynamic-labs/sdk-react-core 4.45.3 → 4.46.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useEVMTransactionSimulation.cjs +33 -13
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useEVMTransactionSimulation.d.ts +3 -2
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useEVMTransactionSimulation.js +33 -13
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.cjs +12 -5
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.d.ts +2 -1
- package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.js +12 -5
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +12 -5
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +12 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
### [4.46.1](https://github.com/dynamic-labs/dynamic-auth/compare/v4.46.0...v4.46.1) (2025-11-20)
|
|
3
|
+
|
|
4
|
+
## [4.46.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.45.3...v4.46.0) (2025-11-19)
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* **react-native:** add client.solana.simulateTransaction method ([#9910](https://github.com/dynamic-labs/dynamic-auth/issues/9910)) ([61bbe45](https://github.com/dynamic-labs/dynamic-auth/commit/61bbe453eeb2790dffc533aa57f6bc050c3c0461))
|
|
10
|
+
* **react-native:** add simulateEVMTransactionAA and simulateEVMTransaction methods ([#9907](https://github.com/dynamic-labs/dynamic-auth/issues/9907)) ([e54d63e](https://github.com/dynamic-labs/dynamic-auth/commit/e54d63eaa80c2bc865ef6199405b0ed7943d4b83))
|
|
11
|
+
|
|
2
12
|
### [4.45.3](https://github.com/dynamic-labs/dynamic-auth/compare/v4.45.2...v4.45.3) (2025-11-18)
|
|
3
13
|
|
|
4
14
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.46.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.0.821",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.1.0-alpha.28",
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
19
|
-
"@dynamic-labs/iconic": "4.
|
|
20
|
-
"@dynamic-labs/locale": "4.
|
|
21
|
-
"@dynamic-labs/logger": "4.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
24
|
-
"@dynamic-labs/store": "4.
|
|
25
|
-
"@dynamic-labs/types": "4.
|
|
26
|
-
"@dynamic-labs/utils": "4.
|
|
27
|
-
"@dynamic-labs/wallet-book": "4.
|
|
28
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.46.1",
|
|
19
|
+
"@dynamic-labs/iconic": "4.46.1",
|
|
20
|
+
"@dynamic-labs/locale": "4.46.1",
|
|
21
|
+
"@dynamic-labs/logger": "4.46.1",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "4.46.1",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "4.46.1",
|
|
24
|
+
"@dynamic-labs/store": "4.46.1",
|
|
25
|
+
"@dynamic-labs/types": "4.46.1",
|
|
26
|
+
"@dynamic-labs/utils": "4.46.1",
|
|
27
|
+
"@dynamic-labs/wallet-book": "4.46.1",
|
|
28
|
+
"@dynamic-labs/wallet-connector-core": "4.46.1",
|
|
29
29
|
"eventemitter3": "5.0.1"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
package/src/lib/utils/hooks/useTransactionSimulation/classes/useEVMTransactionSimulation.cjs
CHANGED
|
@@ -25,10 +25,14 @@ const useEVMTransactionSimulation = () => {
|
|
|
25
25
|
var _a, _b;
|
|
26
26
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) ||
|
|
27
27
|
!utils.isZeroDevConnector(primaryWallet.connector)) {
|
|
28
|
-
|
|
28
|
+
const error = new Error('Account abstraction simulation requires ZeroDev connector');
|
|
29
|
+
handleSimulationError(error, 'AA');
|
|
30
|
+
throw error;
|
|
29
31
|
}
|
|
30
32
|
if (!chainId) {
|
|
31
|
-
|
|
33
|
+
const error = new Error('No chain ID found');
|
|
34
|
+
handleSimulationError(error, 'AA');
|
|
35
|
+
throw error;
|
|
32
36
|
}
|
|
33
37
|
const { transaction } = params;
|
|
34
38
|
try {
|
|
@@ -36,12 +40,16 @@ const useEVMTransactionSimulation = () => {
|
|
|
36
40
|
const connector = primaryWallet.connector;
|
|
37
41
|
const { userOperation } = yield connector.getCurrentUserOperation(transaction);
|
|
38
42
|
if (!userOperation) {
|
|
39
|
-
|
|
43
|
+
const error = new Error('failed to get user operation');
|
|
44
|
+
handleSimulationError(error, 'AA');
|
|
45
|
+
throw error;
|
|
40
46
|
}
|
|
41
47
|
const formattedUserOperation = yield connector.formatUserOperation(userOperation);
|
|
42
48
|
const entryPoint = (_a = connector.getAccountAbstractionProvider()) === null || _a === void 0 ? void 0 : _a.account.entryPoint;
|
|
43
49
|
if (!entryPoint) {
|
|
44
|
-
|
|
50
|
+
const error = new Error('No entry point address found');
|
|
51
|
+
handleSimulationError(error, 'AA');
|
|
52
|
+
throw error;
|
|
45
53
|
}
|
|
46
54
|
const result = yield blockaid.simulateBlockaidUserOperation({
|
|
47
55
|
chainId,
|
|
@@ -51,7 +59,9 @@ const useEVMTransactionSimulation = () => {
|
|
|
51
59
|
value: ((_b = transaction.value) === null || _b === void 0 ? void 0 : _b.toString()) || '0',
|
|
52
60
|
});
|
|
53
61
|
if (!result) {
|
|
54
|
-
|
|
62
|
+
const error = new Error('Simulation failed: No result returned');
|
|
63
|
+
handleSimulationError(error, 'AA');
|
|
64
|
+
throw error;
|
|
55
65
|
}
|
|
56
66
|
const fee = utils.calculateAAFees(userOperation);
|
|
57
67
|
const isSponsored = yield connector.canSponsorTransactionGas(transaction);
|
|
@@ -66,10 +76,11 @@ const useEVMTransactionSimulation = () => {
|
|
|
66
76
|
isLoading: false,
|
|
67
77
|
result: resultWithFee,
|
|
68
78
|
});
|
|
69
|
-
return;
|
|
79
|
+
return result;
|
|
70
80
|
}
|
|
71
81
|
catch (error) {
|
|
72
|
-
|
|
82
|
+
handleSimulationError(error, 'AA');
|
|
83
|
+
throw error;
|
|
73
84
|
}
|
|
74
85
|
}), [
|
|
75
86
|
chainId,
|
|
@@ -83,15 +94,21 @@ const useEVMTransactionSimulation = () => {
|
|
|
83
94
|
var _c;
|
|
84
95
|
const { transaction } = params;
|
|
85
96
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector)) {
|
|
86
|
-
|
|
97
|
+
const error = new Error('No wallet connected');
|
|
98
|
+
handleSimulationError(error, 'EVM');
|
|
99
|
+
throw error;
|
|
87
100
|
}
|
|
88
101
|
if (!chainId) {
|
|
89
|
-
|
|
102
|
+
const error = new Error('No chain ID found');
|
|
103
|
+
handleSimulationError(error, 'EVM');
|
|
104
|
+
throw error;
|
|
90
105
|
}
|
|
91
106
|
try {
|
|
92
107
|
setSimulationState({ isLoading: true });
|
|
93
108
|
if (!utils.isEthereumWallet(primaryWallet)) {
|
|
94
|
-
|
|
109
|
+
const error = new Error('EVM simulation requires Ethereum wallet');
|
|
110
|
+
handleSimulationError(error, 'EVM');
|
|
111
|
+
throw error;
|
|
95
112
|
}
|
|
96
113
|
const publicClient = yield primaryWallet.getPublicClient();
|
|
97
114
|
const totalFee = yield utils.calculateEVMFees(publicClient, transaction);
|
|
@@ -104,7 +121,9 @@ const useEVMTransactionSimulation = () => {
|
|
|
104
121
|
value: ((_c = transaction.value) === null || _c === void 0 ? void 0 : _c.toString()) || '0',
|
|
105
122
|
});
|
|
106
123
|
if (!result) {
|
|
107
|
-
|
|
124
|
+
const error = new Error('Simulation failed: No result returned');
|
|
125
|
+
handleSimulationError(error, 'EVM');
|
|
126
|
+
throw error;
|
|
108
127
|
}
|
|
109
128
|
const resultWithFee = utils.generateAllFeeData(totalFee, nativeTokenDecimals, result);
|
|
110
129
|
// Filter out native asset if it's just gas fee (no ETH transfer)
|
|
@@ -115,10 +134,11 @@ const useEVMTransactionSimulation = () => {
|
|
|
115
134
|
isLoading: false,
|
|
116
135
|
result: resultWithFee,
|
|
117
136
|
});
|
|
118
|
-
return;
|
|
137
|
+
return resultWithFee;
|
|
119
138
|
}
|
|
120
139
|
catch (error) {
|
|
121
|
-
|
|
140
|
+
handleSimulationError(error, 'EVM');
|
|
141
|
+
throw error;
|
|
122
142
|
}
|
|
123
143
|
}), [
|
|
124
144
|
chainId,
|
package/src/lib/utils/hooks/useTransactionSimulation/classes/useEVMTransactionSimulation.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { IEVMTransaction } from '@dynamic-labs/types';
|
|
2
|
+
import { SimulateTransactionResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
3
|
import { type TransactionType, type FeeData, type SimulationState } from './useBaseTransactionSimulation';
|
|
3
4
|
export type { TransactionType, SimulationState, FeeData };
|
|
4
5
|
export type EVMTransactionParams = {
|
|
@@ -6,7 +7,7 @@ export type EVMTransactionParams = {
|
|
|
6
7
|
type: Omit<TransactionType, 'SignAllTransactions' | 'SignTransaction'>;
|
|
7
8
|
};
|
|
8
9
|
export type EVMTransactionSimulationHook = {
|
|
9
|
-
simulateEVMTransaction: (params: EVMTransactionParams) => Promise<
|
|
10
|
-
simulateEVMTransactionAA: (params: EVMTransactionParams) => Promise<
|
|
10
|
+
simulateEVMTransaction: (params: EVMTransactionParams) => Promise<SimulateTransactionResponse>;
|
|
11
|
+
simulateEVMTransactionAA: (params: EVMTransactionParams) => Promise<SimulateTransactionResponse>;
|
|
11
12
|
} & SimulationState;
|
|
12
13
|
export declare const useEVMTransactionSimulation: () => EVMTransactionSimulationHook;
|
|
@@ -21,10 +21,14 @@ const useEVMTransactionSimulation = () => {
|
|
|
21
21
|
var _a, _b;
|
|
22
22
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) ||
|
|
23
23
|
!isZeroDevConnector(primaryWallet.connector)) {
|
|
24
|
-
|
|
24
|
+
const error = new Error('Account abstraction simulation requires ZeroDev connector');
|
|
25
|
+
handleSimulationError(error, 'AA');
|
|
26
|
+
throw error;
|
|
25
27
|
}
|
|
26
28
|
if (!chainId) {
|
|
27
|
-
|
|
29
|
+
const error = new Error('No chain ID found');
|
|
30
|
+
handleSimulationError(error, 'AA');
|
|
31
|
+
throw error;
|
|
28
32
|
}
|
|
29
33
|
const { transaction } = params;
|
|
30
34
|
try {
|
|
@@ -32,12 +36,16 @@ const useEVMTransactionSimulation = () => {
|
|
|
32
36
|
const connector = primaryWallet.connector;
|
|
33
37
|
const { userOperation } = yield connector.getCurrentUserOperation(transaction);
|
|
34
38
|
if (!userOperation) {
|
|
35
|
-
|
|
39
|
+
const error = new Error('failed to get user operation');
|
|
40
|
+
handleSimulationError(error, 'AA');
|
|
41
|
+
throw error;
|
|
36
42
|
}
|
|
37
43
|
const formattedUserOperation = yield connector.formatUserOperation(userOperation);
|
|
38
44
|
const entryPoint = (_a = connector.getAccountAbstractionProvider()) === null || _a === void 0 ? void 0 : _a.account.entryPoint;
|
|
39
45
|
if (!entryPoint) {
|
|
40
|
-
|
|
46
|
+
const error = new Error('No entry point address found');
|
|
47
|
+
handleSimulationError(error, 'AA');
|
|
48
|
+
throw error;
|
|
41
49
|
}
|
|
42
50
|
const result = yield simulateBlockaidUserOperation({
|
|
43
51
|
chainId,
|
|
@@ -47,7 +55,9 @@ const useEVMTransactionSimulation = () => {
|
|
|
47
55
|
value: ((_b = transaction.value) === null || _b === void 0 ? void 0 : _b.toString()) || '0',
|
|
48
56
|
});
|
|
49
57
|
if (!result) {
|
|
50
|
-
|
|
58
|
+
const error = new Error('Simulation failed: No result returned');
|
|
59
|
+
handleSimulationError(error, 'AA');
|
|
60
|
+
throw error;
|
|
51
61
|
}
|
|
52
62
|
const fee = calculateAAFees(userOperation);
|
|
53
63
|
const isSponsored = yield connector.canSponsorTransactionGas(transaction);
|
|
@@ -62,10 +72,11 @@ const useEVMTransactionSimulation = () => {
|
|
|
62
72
|
isLoading: false,
|
|
63
73
|
result: resultWithFee,
|
|
64
74
|
});
|
|
65
|
-
return;
|
|
75
|
+
return result;
|
|
66
76
|
}
|
|
67
77
|
catch (error) {
|
|
68
|
-
|
|
78
|
+
handleSimulationError(error, 'AA');
|
|
79
|
+
throw error;
|
|
69
80
|
}
|
|
70
81
|
}), [
|
|
71
82
|
chainId,
|
|
@@ -79,15 +90,21 @@ const useEVMTransactionSimulation = () => {
|
|
|
79
90
|
var _c;
|
|
80
91
|
const { transaction } = params;
|
|
81
92
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector)) {
|
|
82
|
-
|
|
93
|
+
const error = new Error('No wallet connected');
|
|
94
|
+
handleSimulationError(error, 'EVM');
|
|
95
|
+
throw error;
|
|
83
96
|
}
|
|
84
97
|
if (!chainId) {
|
|
85
|
-
|
|
98
|
+
const error = new Error('No chain ID found');
|
|
99
|
+
handleSimulationError(error, 'EVM');
|
|
100
|
+
throw error;
|
|
86
101
|
}
|
|
87
102
|
try {
|
|
88
103
|
setSimulationState({ isLoading: true });
|
|
89
104
|
if (!isEthereumWallet(primaryWallet)) {
|
|
90
|
-
|
|
105
|
+
const error = new Error('EVM simulation requires Ethereum wallet');
|
|
106
|
+
handleSimulationError(error, 'EVM');
|
|
107
|
+
throw error;
|
|
91
108
|
}
|
|
92
109
|
const publicClient = yield primaryWallet.getPublicClient();
|
|
93
110
|
const totalFee = yield calculateEVMFees(publicClient, transaction);
|
|
@@ -100,7 +117,9 @@ const useEVMTransactionSimulation = () => {
|
|
|
100
117
|
value: ((_c = transaction.value) === null || _c === void 0 ? void 0 : _c.toString()) || '0',
|
|
101
118
|
});
|
|
102
119
|
if (!result) {
|
|
103
|
-
|
|
120
|
+
const error = new Error('Simulation failed: No result returned');
|
|
121
|
+
handleSimulationError(error, 'EVM');
|
|
122
|
+
throw error;
|
|
104
123
|
}
|
|
105
124
|
const resultWithFee = generateAllFeeData(totalFee, nativeTokenDecimals, result);
|
|
106
125
|
// Filter out native asset if it's just gas fee (no ETH transfer)
|
|
@@ -111,10 +130,11 @@ const useEVMTransactionSimulation = () => {
|
|
|
111
130
|
isLoading: false,
|
|
112
131
|
result: resultWithFee,
|
|
113
132
|
});
|
|
114
|
-
return;
|
|
133
|
+
return resultWithFee;
|
|
115
134
|
}
|
|
116
135
|
catch (error) {
|
|
117
|
-
|
|
136
|
+
handleSimulationError(error, 'EVM');
|
|
137
|
+
throw error;
|
|
118
138
|
}
|
|
119
139
|
}), [
|
|
120
140
|
chainId,
|
package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.cjs
CHANGED
|
@@ -19,7 +19,9 @@ const useSVMTransactionSimulation = () => {
|
|
|
19
19
|
const { simulationState, setSimulationState, nativeTokenDecimals, handleSimulationError, primaryWallet, environmentId, } = useBaseTransactionSimulation.useBaseTransactionSimulation('useSVMTransactionSimulation');
|
|
20
20
|
const simulateSVMTransaction = React.useCallback((params) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
21
21
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) || primaryWallet.chain !== sdkApiCore.ChainEnum.Sol) {
|
|
22
|
-
|
|
22
|
+
const error = new Error('Solana simulation requires Solana wallet');
|
|
23
|
+
handleSimulationError(error);
|
|
24
|
+
throw error;
|
|
23
25
|
}
|
|
24
26
|
const transactions = Array.isArray(params.transaction)
|
|
25
27
|
? params.transaction
|
|
@@ -48,12 +50,16 @@ const useSVMTransactionSimulation = () => {
|
|
|
48
50
|
transactions: encodedTransactions,
|
|
49
51
|
});
|
|
50
52
|
if (!result) {
|
|
51
|
-
|
|
53
|
+
const error = new Error('Simulation failed: No result returned');
|
|
54
|
+
handleSimulationError(error);
|
|
55
|
+
throw error;
|
|
52
56
|
}
|
|
53
57
|
const finalFee = isSponsored ? BigInt(0) : fee || BigInt(0);
|
|
54
58
|
// For Solana, we need to ensure we have a valid fee
|
|
55
59
|
if (!isSponsored && finalFee === BigInt(0)) {
|
|
56
|
-
|
|
60
|
+
const error = new Error('Failed to calculate transaction fee');
|
|
61
|
+
handleSimulationError(error);
|
|
62
|
+
throw error;
|
|
57
63
|
}
|
|
58
64
|
const resultWithFee = utils.generateAllFeeData(finalFee, nativeTokenDecimals, result);
|
|
59
65
|
// simulations include gas fees in the outAssets, so we need to remove them
|
|
@@ -64,10 +70,11 @@ const useSVMTransactionSimulation = () => {
|
|
|
64
70
|
isLoading: false,
|
|
65
71
|
result: resultWithFee,
|
|
66
72
|
});
|
|
67
|
-
return;
|
|
73
|
+
return resultWithFee;
|
|
68
74
|
}
|
|
69
75
|
catch (error) {
|
|
70
|
-
|
|
76
|
+
handleSimulationError(error);
|
|
77
|
+
throw error;
|
|
71
78
|
}
|
|
72
79
|
}), [
|
|
73
80
|
primaryWallet,
|
package/src/lib/utils/hooks/useTransactionSimulation/classes/useSVMTransactionSimulation.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SimulateTransactionResponse } from '@dynamic-labs/sdk-api-core';
|
|
1
2
|
import { ISolanaTransaction } from '@dynamic-labs/types';
|
|
2
3
|
import { type TransactionType, type SimulationState, type FeeData } from './useBaseTransactionSimulation';
|
|
3
4
|
export type { TransactionType, SimulationState, FeeData };
|
|
@@ -7,6 +8,6 @@ export type SVMTransactionParams = {
|
|
|
7
8
|
type: Omit<TransactionType, 'SendTransaction'>;
|
|
8
9
|
};
|
|
9
10
|
export type SVMTransactionSimulationHook = {
|
|
10
|
-
simulateSVMTransaction: (params: SVMTransactionParams) => Promise<
|
|
11
|
+
simulateSVMTransaction: (params: SVMTransactionParams) => Promise<SimulateTransactionResponse>;
|
|
11
12
|
} & SimulationState;
|
|
12
13
|
export declare const useSVMTransactionSimulation: () => SVMTransactionSimulationHook;
|
|
@@ -11,7 +11,9 @@ const useSVMTransactionSimulation = () => {
|
|
|
11
11
|
const { simulationState, setSimulationState, nativeTokenDecimals, handleSimulationError, primaryWallet, environmentId, } = useBaseTransactionSimulation('useSVMTransactionSimulation');
|
|
12
12
|
const simulateSVMTransaction = useCallback((params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
13
13
|
if (!(primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector) || primaryWallet.chain !== ChainEnum.Sol) {
|
|
14
|
-
|
|
14
|
+
const error = new Error('Solana simulation requires Solana wallet');
|
|
15
|
+
handleSimulationError(error);
|
|
16
|
+
throw error;
|
|
15
17
|
}
|
|
16
18
|
const transactions = Array.isArray(params.transaction)
|
|
17
19
|
? params.transaction
|
|
@@ -40,12 +42,16 @@ const useSVMTransactionSimulation = () => {
|
|
|
40
42
|
transactions: encodedTransactions,
|
|
41
43
|
});
|
|
42
44
|
if (!result) {
|
|
43
|
-
|
|
45
|
+
const error = new Error('Simulation failed: No result returned');
|
|
46
|
+
handleSimulationError(error);
|
|
47
|
+
throw error;
|
|
44
48
|
}
|
|
45
49
|
const finalFee = isSponsored ? BigInt(0) : fee || BigInt(0);
|
|
46
50
|
// For Solana, we need to ensure we have a valid fee
|
|
47
51
|
if (!isSponsored && finalFee === BigInt(0)) {
|
|
48
|
-
|
|
52
|
+
const error = new Error('Failed to calculate transaction fee');
|
|
53
|
+
handleSimulationError(error);
|
|
54
|
+
throw error;
|
|
49
55
|
}
|
|
50
56
|
const resultWithFee = generateAllFeeData(finalFee, nativeTokenDecimals, result);
|
|
51
57
|
// simulations include gas fees in the outAssets, so we need to remove them
|
|
@@ -56,10 +62,11 @@ const useSVMTransactionSimulation = () => {
|
|
|
56
62
|
isLoading: false,
|
|
57
63
|
result: resultWithFee,
|
|
58
64
|
});
|
|
59
|
-
return;
|
|
65
|
+
return resultWithFee;
|
|
60
66
|
}
|
|
61
67
|
catch (error) {
|
|
62
|
-
|
|
68
|
+
handleSimulationError(error);
|
|
69
|
+
throw error;
|
|
63
70
|
}
|
|
64
71
|
}), [
|
|
65
72
|
primaryWallet,
|
|
@@ -125,16 +125,23 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
125
125
|
const { modal: zkSyncCreateSessionModal, open: openZkSyncCreateSession } = useConfirmationModal.useConfirmationModal({
|
|
126
126
|
elementId: 'dynamic-zksync-approval',
|
|
127
127
|
});
|
|
128
|
-
const shouldConfirmAction = React.useCallback(() => {
|
|
128
|
+
const shouldConfirmAction = React.useCallback(({ walletConnector }) => {
|
|
129
|
+
// For Dynamic Waas connector, we disable confirmation if hideEmbeddedWalletTransactionUIs is true
|
|
130
|
+
// V2 wallets require the UI component to be rendered even if the confirmation is disabled
|
|
131
|
+
// Waas does not require the UI component to be rendered so it can be skipped
|
|
132
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.overrideKey) === 'dynamicwaas' &&
|
|
133
|
+
hideEmbeddedWalletTransactionUIs) {
|
|
134
|
+
return false;
|
|
135
|
+
}
|
|
129
136
|
if (confirmationStateRef.current === 'disabled') {
|
|
130
137
|
confirmationStateRef.current = 'enabled';
|
|
131
138
|
return false;
|
|
132
139
|
}
|
|
133
140
|
return true;
|
|
134
|
-
}, [confirmationStateRef]);
|
|
141
|
+
}, [hideEmbeddedWalletTransactionUIs, confirmationStateRef]);
|
|
135
142
|
const signMessage = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletConnector, message, handler }) {
|
|
136
143
|
// prevent the modal from opening itself again
|
|
137
|
-
if (!shouldConfirmAction())
|
|
144
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
138
145
|
return handler();
|
|
139
146
|
return openSignMessage((resolve, reject) => (jsxRuntime.jsx(SignMessageConfirmationModal.SignMessageConfirmationModal, { message: message, handler: handler, onSignMessage: resolve, onReject: reject, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
140
147
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedMessage) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -146,7 +153,7 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
146
153
|
}), [hideEmbeddedWalletTransactionUIs, openSignMessage, shouldConfirmAction]);
|
|
147
154
|
const sendTransaction = React.useCallback((walletConnector, transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
148
155
|
// prevent the modal from opening itself again
|
|
149
|
-
if (!shouldConfirmAction())
|
|
156
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
150
157
|
return transaction.submit();
|
|
151
158
|
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), transaction: transaction, onTransactionResponseSuccess: resolve, onReject: reject, walletConnector: walletConnector, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
152
159
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedTransaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -164,7 +171,7 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
164
171
|
// Solana only
|
|
165
172
|
const signTransaction = React.useCallback((walletConnector, transaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
166
173
|
// prevent the modal from opening itself again
|
|
167
|
-
if (!shouldConfirmAction())
|
|
174
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
168
175
|
return transaction.submit();
|
|
169
176
|
return openSendTransaction((resolve, reject) => (jsxRuntime.jsx(TransactionConfirmationModal.TransactionConfirmationModal, { copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), transaction: transaction, onTransactionResponseSuccess: resolve, onReject: reject, walletConnector: walletConnector, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
170
177
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedTransaction) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -121,16 +121,23 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
121
121
|
const { modal: zkSyncCreateSessionModal, open: openZkSyncCreateSession } = useConfirmationModal({
|
|
122
122
|
elementId: 'dynamic-zksync-approval',
|
|
123
123
|
});
|
|
124
|
-
const shouldConfirmAction = useCallback(() => {
|
|
124
|
+
const shouldConfirmAction = useCallback(({ walletConnector }) => {
|
|
125
|
+
// For Dynamic Waas connector, we disable confirmation if hideEmbeddedWalletTransactionUIs is true
|
|
126
|
+
// V2 wallets require the UI component to be rendered even if the confirmation is disabled
|
|
127
|
+
// Waas does not require the UI component to be rendered so it can be skipped
|
|
128
|
+
if ((walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.overrideKey) === 'dynamicwaas' &&
|
|
129
|
+
hideEmbeddedWalletTransactionUIs) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
125
132
|
if (confirmationStateRef.current === 'disabled') {
|
|
126
133
|
confirmationStateRef.current = 'enabled';
|
|
127
134
|
return false;
|
|
128
135
|
}
|
|
129
136
|
return true;
|
|
130
|
-
}, [confirmationStateRef]);
|
|
137
|
+
}, [hideEmbeddedWalletTransactionUIs, confirmationStateRef]);
|
|
131
138
|
const signMessage = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ walletConnector, message, handler }) {
|
|
132
139
|
// prevent the modal from opening itself again
|
|
133
|
-
if (!shouldConfirmAction())
|
|
140
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
134
141
|
return handler();
|
|
135
142
|
return openSignMessage((resolve, reject) => (jsx(SignMessageConfirmationModal, { message: message, handler: handler, onSignMessage: resolve, onReject: reject, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
136
143
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedMessage) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -142,7 +149,7 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
142
149
|
}), [hideEmbeddedWalletTransactionUIs, openSignMessage, shouldConfirmAction]);
|
|
143
150
|
const sendTransaction = useCallback((walletConnector, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
144
151
|
// prevent the modal from opening itself again
|
|
145
|
-
if (!shouldConfirmAction())
|
|
152
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
146
153
|
return transaction.submit();
|
|
147
154
|
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), transaction: transaction, onTransactionResponseSuccess: resolve, onReject: reject, walletConnector: walletConnector, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
148
155
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedTransaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -160,7 +167,7 @@ const useWalletUiUtils = ({ hideEmbeddedWalletTransactionUIs = false, }) => {
|
|
|
160
167
|
// Solana only
|
|
161
168
|
const signTransaction = useCallback((walletConnector, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
162
169
|
// prevent the modal from opening itself again
|
|
163
|
-
if (!shouldConfirmAction())
|
|
170
|
+
if (!shouldConfirmAction({ walletConnector }))
|
|
164
171
|
return transaction.submit();
|
|
165
172
|
return openSendTransaction((resolve, reject) => (jsx(TransactionConfirmationModal, { copykey: 'dyn_send_transaction.confirmation.title', title: t('dyn_send_transaction.confirmation.title'), transaction: transaction, onTransactionResponseSuccess: resolve, onReject: reject, walletConnector: walletConnector, hideModal: hideEmbeddedWalletTransactionUIs &&
|
|
166
173
|
!(walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.isGlobalTransaction) }))).then((signedTransaction) => __awaiter(void 0, void 0, void 0, function* () {
|