@dynamic-labs/sdk-react-core 5.3.2 → 5.4.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 +34 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +14 -14
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/components/TransactionCard/TransactionCard.cjs +21 -13
- package/src/lib/components/TransactionCard/TransactionCard.d.ts +2 -0
- package/src/lib/components/TransactionCard/TransactionCard.js +21 -13
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs +1 -1
- package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js +1 -1
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.cjs +2 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.d.ts +3 -1
- package/src/lib/utils/hooks/useDynamicWaas/useDynamicWaas.js +2 -1
- package/src/lib/utils/hooks/usePolicies/index.d.ts +1 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.cjs +64 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.d.ts +36 -0
- package/src/lib/utils/hooks/usePolicies/usePolicies.js +60 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,38 @@
|
|
|
1
1
|
|
|
2
|
+
### [5.4.1](https://github.com/dynamic-labs/dynamic-auth/compare/v5.4.0...v5.4.1) (2026-08-26)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* **webview-controller:** resolve which keychain key a session belongs to ([#12246](https://github.com/dynamic-labs/dynamic-auth/issues/12246)) ([3d110db](https://github.com/dynamic-labs/dynamic-auth/commit/3d110db831c6e9d82d07d86841f5c7733924b17e))
|
|
8
|
+
* **bitcoin:** forward the password through the BTC importPrivateKey override ([#12278](https://github.com/dynamic-labs/dynamic-auth/issues/12278)) ([21e1df3](https://github.com/dynamic-labs/dynamic-auth/commit/21e1df3e33e96e2efdb15ffa0fd29a441056202e))
|
|
9
|
+
* **react-native-extension:** recover 4.x expo-secure-store sessions on keychain miss ([#12254](https://github.com/dynamic-labs/dynamic-auth/issues/12254)) ([217e991](https://github.com/dynamic-labs/dynamic-auth/commit/217e991838f3073c12e2d2fab7a2e12830faad9e)), closes [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12092](https://github.com/dynamic-labs/dynamic-auth/issues/12092) [#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242) [#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242)
|
|
10
|
+
* **transaction-card:** use walletConnector prop for network/fee instead of primaryWallet ([#12063](https://github.com/dynamic-labs/dynamic-auth/issues/12063)) ([81314d2](https://github.com/dynamic-labs/dynamic-auth/commit/81314d25fba4b20ab89631bc2d9ceeb9e2b6b2ac))
|
|
11
|
+
* **waas-svm:** instrument sponsorship retry attempts ([#12281](https://github.com/dynamic-labs/dynamic-auth/issues/12281)) ([7273a4b](https://github.com/dynamic-labs/dynamic-auth/commit/7273a4bc456cad512c0e9fbcd2abd66532a2f7df))
|
|
12
|
+
* **webview-controller:** recover 4.x secure-storage sessions and surface init failures ([#12242](https://github.com/dynamic-labs/dynamic-auth/issues/12242)) ([b51605c](https://github.com/dynamic-labs/dynamic-auth/commit/b51605cc9bdbb5d695173192c502a58d899bbbdd)), closes [#12094](https://github.com/dynamic-labs/dynamic-auth/issues/12094) [#12095](https://github.com/dynamic-labs/dynamic-auth/issues/12095) [#12098](https://github.com/dynamic-labs/dynamic-auth/issues/12098) [dynamic-labs/flutter-sdk#256](https://github.com/dynamic-labs/flutter-sdk/issues/256)
|
|
13
|
+
|
|
14
|
+
## [5.4.0](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.2...v5.4.0) (2026-08-25)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **aleo:** wire up signMessage on the WaaS Aleo connector ([#12235](https://github.com/dynamic-labs/dynamic-auth/issues/12235)) ([e56cbf5](https://github.com/dynamic-labs/dynamic-auth/commit/e56cbf5546bdcc21ce916dece43ae36dcea9b808))
|
|
20
|
+
* **waas:** thread isRawScalarImport through importPrivateKey for ed25519 chains ([#12220](https://github.com/dynamic-labs/dynamic-auth/issues/12220)) ([ced9efa](https://github.com/dynamic-labs/dynamic-auth/commit/ced9efac5fa5a4a1280383419f56fe22733722cd))
|
|
21
|
+
* **webview:** add policies message contract and controller ([#12248](https://github.com/dynamic-labs/dynamic-auth/issues/12248)) ([8557c1e](https://github.com/dynamic-labs/dynamic-auth/commit/8557c1ed3861e12f1f06b2bb610184813b577daa))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* **bitcoin:** pass the wallet's address type when signing ([#12265](https://github.com/dynamic-labs/dynamic-auth/issues/12265)) ([b8a8eab](https://github.com/dynamic-labs/dynamic-auth/commit/b8a8eab7e4cc294cc307fb10ea6814e76111a274))
|
|
27
|
+
* remediate high-severity tar vulnerability and prune a dead override ([#12268](https://github.com/dynamic-labs/dynamic-auth/issues/12268)) ([6b1b343](https://github.com/dynamic-labs/dynamic-auth/commit/6b1b343e7947e8da30012446677e342ae9bfe14a))
|
|
28
|
+
* **waas-svm:** fix retry-classification and environmentId gaps in [#12240](https://github.com/dynamic-labs/dynamic-auth/issues/12240) ([#12247](https://github.com/dynamic-labs/dynamic-auth/issues/12247)) ([e79cecc](https://github.com/dynamic-labs/dynamic-auth/commit/e79ceccd424c48c3a7f45fdd6ea288c269ac0171))
|
|
29
|
+
* **wallet-connect:** reopen WalletConnect IndexedDB when the browser closes the connection ([#12262](https://github.com/dynamic-labs/dynamic-auth/issues/12262)) ([1a20dde](https://github.com/dynamic-labs/dynamic-auth/commit/1a20ddeaeec590ae3390c9e47ef3c14738379b83))
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
### Performance Improvements
|
|
33
|
+
|
|
34
|
+
* **ethereum-gasless-core:** parallel 7702 auth signing and long-poll sponsored-tx status ([#12225](https://github.com/dynamic-labs/dynamic-auth/issues/12225)) ([53ca916](https://github.com/dynamic-labs/dynamic-auth/commit/53ca91668f8dd839c52d55a0e5d7bb5257f7f415))
|
|
35
|
+
|
|
2
36
|
### [5.3.2](https://github.com/dynamic-labs/dynamic-auth/compare/v5.3.1...v5.3.2) (2026-08-19)
|
|
3
37
|
|
|
4
38
|
|
package/package.cjs
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "5.
|
|
6
|
+
var version = "5.4.1";
|
|
7
7
|
var dependencies = {
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
9
|
-
"@dynamic-labs-sdk/client": "1.
|
|
9
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
10
10
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
11
11
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
12
12
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
package/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "5.
|
|
2
|
+
var version = "5.4.1";
|
|
3
3
|
var dependencies = {
|
|
4
4
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
5
|
-
"@dynamic-labs-sdk/client": "1.
|
|
5
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
6
6
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
7
7
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
8
8
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.1",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@dynamic-labs/sdk-api-core": "0.12.0",
|
|
6
|
-
"@dynamic-labs-sdk/client": "1.
|
|
6
|
+
"@dynamic-labs-sdk/client": "1.29.0",
|
|
7
7
|
"@dynamic-labs-wallet/browser-wallet-client": "1.0.106",
|
|
8
8
|
"@dynamic-labs-wallet/forward-mpc-client": "1.0.1",
|
|
9
9
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
@@ -18,18 +18,18 @@
|
|
|
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": "5.
|
|
22
|
-
"@dynamic-labs/iconic": "5.
|
|
23
|
-
"@dynamic-labs/legacy-client": "5.
|
|
24
|
-
"@dynamic-labs/locale": "5.
|
|
25
|
-
"@dynamic-labs/logger": "5.
|
|
26
|
-
"@dynamic-labs/multi-wallet": "5.
|
|
27
|
-
"@dynamic-labs/rpc-providers": "5.
|
|
28
|
-
"@dynamic-labs/store": "5.
|
|
29
|
-
"@dynamic-labs/types": "5.
|
|
30
|
-
"@dynamic-labs/utils": "5.
|
|
31
|
-
"@dynamic-labs/wallet-book": "5.
|
|
32
|
-
"@dynamic-labs/wallet-connector-core": "5.
|
|
21
|
+
"@dynamic-labs/assert-package-version": "5.4.1",
|
|
22
|
+
"@dynamic-labs/iconic": "5.4.1",
|
|
23
|
+
"@dynamic-labs/legacy-client": "5.4.1",
|
|
24
|
+
"@dynamic-labs/locale": "5.4.1",
|
|
25
|
+
"@dynamic-labs/logger": "5.4.1",
|
|
26
|
+
"@dynamic-labs/multi-wallet": "5.4.1",
|
|
27
|
+
"@dynamic-labs/rpc-providers": "5.4.1",
|
|
28
|
+
"@dynamic-labs/store": "5.4.1",
|
|
29
|
+
"@dynamic-labs/types": "5.4.1",
|
|
30
|
+
"@dynamic-labs/utils": "5.4.1",
|
|
31
|
+
"@dynamic-labs/wallet-book": "5.4.1",
|
|
32
|
+
"@dynamic-labs/wallet-connector-core": "5.4.1",
|
|
33
33
|
"eventemitter3": "5.0.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -184,6 +184,7 @@ var useSignEip7702Authorization = require('./lib/utils/hooks/useSignEip7702Autho
|
|
|
184
184
|
var useTelegramLogin = require('./lib/utils/hooks/useTelegramLogin/useTelegramLogin.cjs');
|
|
185
185
|
var useDeleteUserAccount = require('./lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.cjs');
|
|
186
186
|
var useBusinessAccounts = require('./lib/utils/hooks/useBusinessAccounts/useBusinessAccounts.cjs');
|
|
187
|
+
var usePolicies = require('./lib/utils/hooks/usePolicies/usePolicies.cjs');
|
|
187
188
|
var useExchangeAccounts = require('./lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.cjs');
|
|
188
189
|
var usePayWithDynamic = require('./lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.cjs');
|
|
189
190
|
var useGetPasskeys = require('./lib/utils/hooks/useGetPasskeys/useGetPasskeys.cjs');
|
|
@@ -353,6 +354,7 @@ exports.useSignEip7702Authorization = useSignEip7702Authorization.useSignEip7702
|
|
|
353
354
|
exports.useTelegramLogin = useTelegramLogin.useTelegramLogin;
|
|
354
355
|
exports.useDeleteUserAccount = useDeleteUserAccount.useDeleteUserAccount;
|
|
355
356
|
exports.useBusinessAccounts = useBusinessAccounts.useBusinessAccounts;
|
|
357
|
+
exports.usePolicies = usePolicies.usePolicies;
|
|
356
358
|
exports.useExchangeAccounts = useExchangeAccounts.useExchangeAccounts;
|
|
357
359
|
exports.usePayWithDynamic = usePayWithDynamic.usePayWithDynamic;
|
|
358
360
|
exports.useGetPasskeys = useGetPasskeys.useGetPasskeys;
|
package/src/index.d.ts
CHANGED
|
@@ -123,7 +123,7 @@ export { FilterAndSortWallets, FilterBridgeChainsName, FilterChain, FilterWallet
|
|
|
123
123
|
export {
|
|
124
124
|
/** @deprecated */
|
|
125
125
|
DynamicWidgetContextProvider, } from './lib/widgets/DynamicWidget/context';
|
|
126
|
-
export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, usePrivateTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, useTelegramLogin, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useBusinessAccounts, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
|
|
126
|
+
export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedReveal, useIsLoggedIn, useDynamicModals, useMfa, useTokenBalances, useMultichainTokenBalances, usePrivateTokenBalances, useSwitchWallet, useRpcProviders, useRefreshUser, useRefreshAuth, useResetWaasSession, useWalletOptions, useSmartWallets, useSignEip7702Authorization, useTelegramLogin, useEVMTransactionSimulation, useSVMTransactionSimulation, useDeleteUserAccount, useDynamicWaas, useBusinessAccounts, usePolicies, useGetPasskeys, useDeletePasskey, useRegisterPasskey, useAuthenticatePasskeyMFA, useGetUserMfaMethods, usePromptMfaAuth, useGetMfaToken, useGetWalletPassword, useIsPasswordEncrypted, useWalletPassword, useIsMfaRequiredForAction, useWalletDelegation, DelegationError, type DelegationOperation, type DelegationWalletRef, useWalletBackup, useBackupWallets, isWalletBackedUp, BackupError, CloudBackupProvider, GOOGLE_DRIVE_BACKUP_REQUIRED_SCOPES, findMissingGoogleDriveBackupScopes, hasAllGoogleDriveBackupScopes, isInsufficientGoogleDriveScopesError, useGoogleDriveBackupReadiness, useExchangeAccounts, useStepUpAuthentication, } from './lib/utils/hooks';
|
|
127
127
|
export type { GoogleDriveBackupAccessError, GoogleDriveBackupReadiness, GoogleDriveBackupReadinessStatus, UseGoogleDriveBackupReadinessReturn, UsePrivateTokenBalancesArgs, UsePrivateTokenBalancesReturn, } from './lib/utils/hooks';
|
|
128
128
|
export type { IsStepUpRequiredParams, PromptMfaParams, StepUpAuthenticationState, UseStepUpAuthenticationParams, UseStepUpAuthenticationReturn, VerifyOtpParams, VerifyPasskeyMfaParams, VerifyRecoveryCodeParams, VerifySocialParams, VerifyTotpMfaParams, VerifyWalletParams, } from './lib/utils/hooks';
|
|
129
129
|
export { useOnramp } from './lib/utils/hooks/useOnramp';
|
package/src/index.js
CHANGED
|
@@ -180,6 +180,7 @@ export { useSignEip7702Authorization } from './lib/utils/hooks/useSignEip7702Aut
|
|
|
180
180
|
export { useTelegramLogin } from './lib/utils/hooks/useTelegramLogin/useTelegramLogin.js';
|
|
181
181
|
export { useDeleteUserAccount } from './lib/utils/hooks/useDeleteUserAccount/useDeleteUserAccount.js';
|
|
182
182
|
export { useBusinessAccounts } from './lib/utils/hooks/useBusinessAccounts/useBusinessAccounts.js';
|
|
183
|
+
export { usePolicies } from './lib/utils/hooks/usePolicies/usePolicies.js';
|
|
183
184
|
export { useExchangeAccounts } from './lib/utils/hooks/useExchangeAccounts/useExchangeAccounts.js';
|
|
184
185
|
export { usePayWithDynamic } from './lib/utils/hooks/usePayWithDynamic/usePayWithDynamic.js';
|
|
185
186
|
export { useGetPasskeys } from './lib/utils/hooks/useGetPasskeys/useGetPasskeys.js';
|
|
@@ -126,21 +126,22 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
126
126
|
|
|
127
127
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
128
128
|
|
|
129
|
-
const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATransaction, recipient, }) => {
|
|
130
|
-
var _a, _b, _c, _d, _e, _f
|
|
129
|
+
const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATransaction, recipient, walletConnector, }) => {
|
|
130
|
+
var _a, _b, _c, _d, _e, _f;
|
|
131
131
|
const { t } = reactI18next.useTranslation();
|
|
132
132
|
const { primaryWallet, projectSettings, overrides } = useInternalDynamicContext.useInternalDynamicContext();
|
|
133
133
|
const networkInfo = useNetworkConfigurationsFromProjectSettings.useNetworkConfigurationsFromProjectSettings({
|
|
134
134
|
evmNetworksOverrides: overrides === null || overrides === void 0 ? void 0 : overrides.evmNetworks,
|
|
135
135
|
projectSettings,
|
|
136
136
|
});
|
|
137
|
-
const
|
|
137
|
+
const activeConnector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
138
|
+
const { chain } = useFetchChain.useFetchChain(activeConnector);
|
|
138
139
|
const networkInfoEntry = networksAndChains.getNetworkInfoEntry({
|
|
139
|
-
chain:
|
|
140
|
+
chain: activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.connectedChain,
|
|
140
141
|
networkId: chain === null || chain === void 0 ? void 0 : chain.chainId,
|
|
141
142
|
networkInfo,
|
|
142
143
|
});
|
|
143
|
-
const { symbol: nativeCurrencySymbol, decimals: nativeCurrencyDecimals } = (
|
|
144
|
+
const { symbol: nativeCurrencySymbol, decimals: nativeCurrencyDecimals } = (_a = networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency) !== null && _a !== void 0 ? _a : {};
|
|
144
145
|
const blockaidOn = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.showTotalFiat;
|
|
145
146
|
const feeInUsd = React.useMemo(() => {
|
|
146
147
|
var _a;
|
|
@@ -169,7 +170,14 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
169
170
|
// for solana, the fee is included in the outgoing assets already
|
|
170
171
|
return (outgoingAssetsTotal +
|
|
171
172
|
(nativeCurrencySymbol === 'SOL' || isGasSponsored ? 0 : feeInUsd || 0));
|
|
172
|
-
}, [
|
|
173
|
+
}, [
|
|
174
|
+
simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.outAssets,
|
|
175
|
+
nativeCurrencySymbol,
|
|
176
|
+
feeInUsd,
|
|
177
|
+
blockaidOn,
|
|
178
|
+
isAATransaction,
|
|
179
|
+
isGasSponsored,
|
|
180
|
+
]);
|
|
173
181
|
const getTotalAmountInUsdDisplay = (totalAmountInUsd) => {
|
|
174
182
|
if (!totalAmountInUsd)
|
|
175
183
|
return undefined;
|
|
@@ -178,9 +186,9 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
178
186
|
: `~$${totalAmountInUsd.toFixed(2)}`;
|
|
179
187
|
};
|
|
180
188
|
const renderAssetTransfer = (transfer, index, array) => {
|
|
181
|
-
var _a, _b
|
|
189
|
+
var _a, _b;
|
|
182
190
|
if (['NATIVE', 'SOL', 'ETH'].includes(transfer.asset.type) &&
|
|
183
|
-
(
|
|
191
|
+
(activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.connectedChain) === 'SOL' &&
|
|
184
192
|
transaction.fee.gas) {
|
|
185
193
|
transfer.amount = (Number(transfer.amount) -
|
|
186
194
|
Number(transaction.fee.gas) / Math.pow(10, 9)).toString();
|
|
@@ -200,10 +208,10 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
200
208
|
}
|
|
201
209
|
return `$${usdPrice.toFixed(2)}`;
|
|
202
210
|
};
|
|
203
|
-
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `transaction-card__${transfer.direction}`, children: jsxRuntime.jsxs("div", { className: 'transaction-card__info-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', children: transfer.direction === 'in' ? 'Receive' : 'Send' }), jsxRuntime.jsxs("div", { className: 'transaction-card__amount-symbol', children: [jsxRuntime.jsxs("div", { className: 'transaction-card__token-info', children: [jsxRuntime.jsxs("div", { className: 'transaction-card__token-row', children: [jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: [transfer.direction === 'out' ? '-' : '+', getAmountDisplay()] }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: (
|
|
204
|
-
(networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency.iconUrl), alt: (
|
|
211
|
+
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: `transaction-card__${transfer.direction}`, children: jsxRuntime.jsxs("div", { className: 'transaction-card__info-container', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', children: transfer.direction === 'in' ? 'Receive' : 'Send' }), jsxRuntime.jsxs("div", { className: 'transaction-card__amount-symbol', children: [jsxRuntime.jsxs("div", { className: 'transaction-card__token-info', children: [jsxRuntime.jsxs("div", { className: 'transaction-card__token-row', children: [jsxRuntime.jsxs(Typography.Typography, { variant: 'body_normal', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: [transfer.direction === 'out' ? '-' : '+', getAmountDisplay()] }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: (_a = (transfer.asset.symbol || transfer.asset.name)) !== null && _a !== void 0 ? _a : nativeCurrencySymbol })] }), Number(transfer.usdPrice) > 0 && (jsxRuntime.jsx(Typography.Typography, { variant: 'body_small', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: getUsdPriceDisplay() }))] }), jsxRuntime.jsx("div", { className: 'transaction-card__icon', children: jsxRuntime.jsx("div", { className: 'transaction-card__icon__container', children: jsxRuntime.jsx("img", { src: transfer.asset.logoUrl ||
|
|
212
|
+
(networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency.iconUrl), alt: (_b = transfer.asset.symbol) !== null && _b !== void 0 ? _b : nativeCurrencySymbol, width: 32, height: 32, className: 'transaction-card__icon__container__main' }) }) })] })] }) }), index < array.length - 1 && (jsxRuntime.jsx("div", { className: 'transaction-card__divider' }))] }));
|
|
205
213
|
};
|
|
206
|
-
const inAssets = ((
|
|
214
|
+
const inAssets = ((_b = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.inAssets) === null || _b === void 0 ? void 0 : _b.flatMap((assetDiff) => {
|
|
207
215
|
var _a;
|
|
208
216
|
return ((_a = assetDiff.transferIn) === null || _a === void 0 ? void 0 : _a.map((inTransfer) => {
|
|
209
217
|
var _a, _b;
|
|
@@ -215,7 +223,7 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
215
223
|
});
|
|
216
224
|
})) || [];
|
|
217
225
|
})) || [];
|
|
218
|
-
const outAssets = ((
|
|
226
|
+
const outAssets = ((_c = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.outAssets) === null || _c === void 0 ? void 0 : _c.flatMap((assetDiff) => {
|
|
219
227
|
var _a;
|
|
220
228
|
return ((_a = assetDiff.transferOut) === null || _a === void 0 ? void 0 : _a.map((outTransfer) => {
|
|
221
229
|
var _a, _b;
|
|
@@ -250,7 +258,7 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
250
258
|
return `-- ${nativeCurrencySymbol}`;
|
|
251
259
|
};
|
|
252
260
|
return (jsxRuntime.jsxs("div", { className: 'transaction-card-container', children: [allAssets.length > 0 && (jsxRuntime.jsx("div", { className: 'transaction-card', children: jsxRuntime.jsx("div", { className: 'transaction-card__assets-container', children: allAssets.map((asset, index, array) => (jsxRuntime.jsx(React__default["default"].Fragment, { children: renderAssetTransfer(asset, index, array) }, `asset-${index}`))) }) })), jsxRuntime.jsx("div", { className: 'transaction-card', children: jsxRuntime.jsxs("div", { className: 'transaction-card__details', children: [recipient && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'transaction-card__row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.recipient', children: t('dyn_send_transaction.confirmation.data.recipient') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-recipient', children: shortenWalletAddress.shortenWalletAddress(recipient) })] }), jsxRuntime.jsx("div", { className: 'transaction-card__divider' })] })), !recipient &&
|
|
253
|
-
(transaction.to || ((
|
|
261
|
+
(transaction.to || ((_d = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.counterparties) === null || _d === void 0 ? void 0 : _d[0])) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'transaction-card__row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.destination', children: t('dyn_send_transaction.confirmation.data.destination') }), jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-destination', children: shortenWalletAddress.shortenWalletAddress((_e = transaction.to) !== null && _e !== void 0 ? _e : (_f = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.counterparties) === null || _f === void 0 ? void 0 : _f[0]) })] }), jsxRuntime.jsx("div", { className: 'transaction-card__divider' })] })), jsxRuntime.jsxs("div", { className: 'transaction-card__row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.network', children: t('dyn_send_transaction.confirmation.data.network') }), jsxRuntime.jsxs("div", { className: 'transaction-card__network-info', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', children: (networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.name) || 'Ethereum' }), jsxRuntime.jsx("img", { src: networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.iconUrls[0], alt: (networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.name) || 'Network icon', width: 16, height: 16, className: 'transaction-card__network-icon' })] })] }), !isGasSponsored && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'transaction-card__divider' }), jsxRuntime.jsxs("div", { className: 'transaction-card__row', children: [jsxRuntime.jsxs("div", { className: 'transaction-card__label-with-tooltip', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.gas_estimate', children: t('dyn_send_transaction.confirmation.data.gas_estimate') }), jsxRuntime.jsx(Tooltip.Tooltip, { content: 'Network fees are paid to process your transaction', className: 'transaction-confirmation', children: jsxRuntime.jsx(Icon.Icon, { size: 'small', className: 'fee-tooltip', children: jsxRuntime.jsx(tooltip.ReactComponent, {}) }) })] }), jsxRuntime.jsx("div", { className: 'transaction-card__value', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-estimated-gas-fee', children: getGasFeeDisplay() }) })] })] })), blockaidOn &&
|
|
254
262
|
totalAmountInUsd !== undefined &&
|
|
255
263
|
totalAmountInUsd > 0 &&
|
|
256
264
|
!(isAATransaction && !isGasSponsored) && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'transaction-card__divider' }), jsxRuntime.jsxs("div", { className: 'transaction-card__row', children: [jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'secondary', weight: 'bold', copykey: 'dyn_send_transaction.confirmation.data.total', children: t('dyn_send_transaction.confirmation.data.total') }), jsxRuntime.jsx("div", { className: 'transaction-card__total-amount', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-estimated-total', children: getTotalAmountInUsdDisplay(totalAmountInUsd) }) })] })] }))] }) })] }));
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { IUITransaction } from '@dynamic-labs/types';
|
|
3
3
|
import { SimulateTransactionResponse as SimulationResult } from '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
5
|
type TransactionCardProps = {
|
|
5
6
|
transaction: IUITransaction;
|
|
6
7
|
simulationResult: SimulationResult | undefined;
|
|
7
8
|
isGasSponsored: boolean;
|
|
8
9
|
isAATransaction: boolean;
|
|
9
10
|
recipient?: string;
|
|
11
|
+
walletConnector?: WalletConnector;
|
|
10
12
|
};
|
|
11
13
|
export declare const TransactionCard: React.FC<TransactionCardProps>;
|
|
12
14
|
export {};
|
|
@@ -118,21 +118,22 @@ import '@dynamic-labs/store';
|
|
|
118
118
|
import '../../shared/utils/functions/getInitialUrl/getInitialUrl.js';
|
|
119
119
|
import '@dynamic-labs-sdk/client/waas';
|
|
120
120
|
|
|
121
|
-
const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATransaction, recipient, }) => {
|
|
122
|
-
var _a, _b, _c, _d, _e, _f
|
|
121
|
+
const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATransaction, recipient, walletConnector, }) => {
|
|
122
|
+
var _a, _b, _c, _d, _e, _f;
|
|
123
123
|
const { t } = useTranslation();
|
|
124
124
|
const { primaryWallet, projectSettings, overrides } = useInternalDynamicContext();
|
|
125
125
|
const networkInfo = useNetworkConfigurationsFromProjectSettings({
|
|
126
126
|
evmNetworksOverrides: overrides === null || overrides === void 0 ? void 0 : overrides.evmNetworks,
|
|
127
127
|
projectSettings,
|
|
128
128
|
});
|
|
129
|
-
const
|
|
129
|
+
const activeConnector = walletConnector !== null && walletConnector !== void 0 ? walletConnector : primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.connector;
|
|
130
|
+
const { chain } = useFetchChain(activeConnector);
|
|
130
131
|
const networkInfoEntry = getNetworkInfoEntry({
|
|
131
|
-
chain:
|
|
132
|
+
chain: activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.connectedChain,
|
|
132
133
|
networkId: chain === null || chain === void 0 ? void 0 : chain.chainId,
|
|
133
134
|
networkInfo,
|
|
134
135
|
});
|
|
135
|
-
const { symbol: nativeCurrencySymbol, decimals: nativeCurrencyDecimals } = (
|
|
136
|
+
const { symbol: nativeCurrencySymbol, decimals: nativeCurrencyDecimals } = (_a = networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency) !== null && _a !== void 0 ? _a : {};
|
|
136
137
|
const blockaidOn = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.showTotalFiat;
|
|
137
138
|
const feeInUsd = useMemo(() => {
|
|
138
139
|
var _a;
|
|
@@ -161,7 +162,14 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
161
162
|
// for solana, the fee is included in the outgoing assets already
|
|
162
163
|
return (outgoingAssetsTotal +
|
|
163
164
|
(nativeCurrencySymbol === 'SOL' || isGasSponsored ? 0 : feeInUsd || 0));
|
|
164
|
-
}, [
|
|
165
|
+
}, [
|
|
166
|
+
simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.outAssets,
|
|
167
|
+
nativeCurrencySymbol,
|
|
168
|
+
feeInUsd,
|
|
169
|
+
blockaidOn,
|
|
170
|
+
isAATransaction,
|
|
171
|
+
isGasSponsored,
|
|
172
|
+
]);
|
|
165
173
|
const getTotalAmountInUsdDisplay = (totalAmountInUsd) => {
|
|
166
174
|
if (!totalAmountInUsd)
|
|
167
175
|
return undefined;
|
|
@@ -170,9 +178,9 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
170
178
|
: `~$${totalAmountInUsd.toFixed(2)}`;
|
|
171
179
|
};
|
|
172
180
|
const renderAssetTransfer = (transfer, index, array) => {
|
|
173
|
-
var _a, _b
|
|
181
|
+
var _a, _b;
|
|
174
182
|
if (['NATIVE', 'SOL', 'ETH'].includes(transfer.asset.type) &&
|
|
175
|
-
(
|
|
183
|
+
(activeConnector === null || activeConnector === void 0 ? void 0 : activeConnector.connectedChain) === 'SOL' &&
|
|
176
184
|
transaction.fee.gas) {
|
|
177
185
|
transfer.amount = (Number(transfer.amount) -
|
|
178
186
|
Number(transaction.fee.gas) / Math.pow(10, 9)).toString();
|
|
@@ -192,10 +200,10 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
192
200
|
}
|
|
193
201
|
return `$${usdPrice.toFixed(2)}`;
|
|
194
202
|
};
|
|
195
|
-
return (jsxs(Fragment, { children: [jsx("div", { className: `transaction-card__${transfer.direction}`, children: jsxs("div", { className: 'transaction-card__info-container', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', children: transfer.direction === 'in' ? 'Receive' : 'Send' }), jsxs("div", { className: 'transaction-card__amount-symbol', children: [jsxs("div", { className: 'transaction-card__token-info', children: [jsxs("div", { className: 'transaction-card__token-row', children: [jsxs(Typography, { variant: 'body_normal', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: [transfer.direction === 'out' ? '-' : '+', getAmountDisplay()] }), jsx(Typography, { variant: 'body_normal', color: 'primary', children: (
|
|
196
|
-
(networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency.iconUrl), alt: (
|
|
203
|
+
return (jsxs(Fragment, { children: [jsx("div", { className: `transaction-card__${transfer.direction}`, children: jsxs("div", { className: 'transaction-card__info-container', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', children: transfer.direction === 'in' ? 'Receive' : 'Send' }), jsxs("div", { className: 'transaction-card__amount-symbol', children: [jsxs("div", { className: 'transaction-card__token-info', children: [jsxs("div", { className: 'transaction-card__token-row', children: [jsxs(Typography, { variant: 'body_normal', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: [transfer.direction === 'out' ? '-' : '+', getAmountDisplay()] }), jsx(Typography, { variant: 'body_normal', color: 'primary', children: (_a = (transfer.asset.symbol || transfer.asset.name)) !== null && _a !== void 0 ? _a : nativeCurrencySymbol })] }), Number(transfer.usdPrice) > 0 && (jsx(Typography, { variant: 'body_small', color: transfer.direction === 'in' ? 'green-1' : 'error-1', children: getUsdPriceDisplay() }))] }), jsx("div", { className: 'transaction-card__icon', children: jsx("div", { className: 'transaction-card__icon__container', children: jsx("img", { src: transfer.asset.logoUrl ||
|
|
204
|
+
(networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.nativeCurrency.iconUrl), alt: (_b = transfer.asset.symbol) !== null && _b !== void 0 ? _b : nativeCurrencySymbol, width: 32, height: 32, className: 'transaction-card__icon__container__main' }) }) })] })] }) }), index < array.length - 1 && (jsx("div", { className: 'transaction-card__divider' }))] }));
|
|
197
205
|
};
|
|
198
|
-
const inAssets = ((
|
|
206
|
+
const inAssets = ((_b = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.inAssets) === null || _b === void 0 ? void 0 : _b.flatMap((assetDiff) => {
|
|
199
207
|
var _a;
|
|
200
208
|
return ((_a = assetDiff.transferIn) === null || _a === void 0 ? void 0 : _a.map((inTransfer) => {
|
|
201
209
|
var _a, _b;
|
|
@@ -207,7 +215,7 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
207
215
|
});
|
|
208
216
|
})) || [];
|
|
209
217
|
})) || [];
|
|
210
|
-
const outAssets = ((
|
|
218
|
+
const outAssets = ((_c = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.outAssets) === null || _c === void 0 ? void 0 : _c.flatMap((assetDiff) => {
|
|
211
219
|
var _a;
|
|
212
220
|
return ((_a = assetDiff.transferOut) === null || _a === void 0 ? void 0 : _a.map((outTransfer) => {
|
|
213
221
|
var _a, _b;
|
|
@@ -242,7 +250,7 @@ const TransactionCard = ({ transaction, simulationResult, isGasSponsored, isAATr
|
|
|
242
250
|
return `-- ${nativeCurrencySymbol}`;
|
|
243
251
|
};
|
|
244
252
|
return (jsxs("div", { className: 'transaction-card-container', children: [allAssets.length > 0 && (jsx("div", { className: 'transaction-card', children: jsx("div", { className: 'transaction-card__assets-container', children: allAssets.map((asset, index, array) => (jsx(React__default.Fragment, { children: renderAssetTransfer(asset, index, array) }, `asset-${index}`))) }) })), jsx("div", { className: 'transaction-card', children: jsxs("div", { className: 'transaction-card__details', children: [recipient && (jsxs(Fragment, { children: [jsxs("div", { className: 'transaction-card__row', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.recipient', children: t('dyn_send_transaction.confirmation.data.recipient') }), jsx(Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-recipient', children: shortenWalletAddress(recipient) })] }), jsx("div", { className: 'transaction-card__divider' })] })), !recipient &&
|
|
245
|
-
(transaction.to || ((
|
|
253
|
+
(transaction.to || ((_d = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.counterparties) === null || _d === void 0 ? void 0 : _d[0])) && (jsxs(Fragment, { children: [jsxs("div", { className: 'transaction-card__row', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.destination', children: t('dyn_send_transaction.confirmation.data.destination') }), jsx(Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-destination', children: shortenWalletAddress((_e = transaction.to) !== null && _e !== void 0 ? _e : (_f = simulationResult === null || simulationResult === void 0 ? void 0 : simulationResult.counterparties) === null || _f === void 0 ? void 0 : _f[0]) })] }), jsx("div", { className: 'transaction-card__divider' })] })), jsxs("div", { className: 'transaction-card__row', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.network', children: t('dyn_send_transaction.confirmation.data.network') }), jsxs("div", { className: 'transaction-card__network-info', children: [jsx(Typography, { variant: 'body_normal', color: 'primary', children: (networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.name) || 'Ethereum' }), jsx("img", { src: networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.iconUrls[0], alt: (networkInfoEntry === null || networkInfoEntry === void 0 ? void 0 : networkInfoEntry.name) || 'Network icon', width: 16, height: 16, className: 'transaction-card__network-icon' })] })] }), !isGasSponsored && (jsxs(Fragment, { children: [jsx("div", { className: 'transaction-card__divider' }), jsxs("div", { className: 'transaction-card__row', children: [jsxs("div", { className: 'transaction-card__label-with-tooltip', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', copykey: 'dyn_send_transaction.confirmation.data.gas_estimate', children: t('dyn_send_transaction.confirmation.data.gas_estimate') }), jsx(Tooltip, { content: 'Network fees are paid to process your transaction', className: 'transaction-confirmation', children: jsx(Icon, { size: 'small', className: 'fee-tooltip', children: jsx(SvgTooltip, {}) }) })] }), jsx("div", { className: 'transaction-card__value', children: jsx(Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-estimated-gas-fee', children: getGasFeeDisplay() }) })] })] })), blockaidOn &&
|
|
246
254
|
totalAmountInUsd !== undefined &&
|
|
247
255
|
totalAmountInUsd > 0 &&
|
|
248
256
|
!(isAATransaction && !isGasSponsored) && (jsxs(Fragment, { children: [jsx("div", { className: 'transaction-card__divider' }), jsxs("div", { className: 'transaction-card__row', children: [jsx(Typography, { variant: 'body_normal', color: 'secondary', weight: 'bold', copykey: 'dyn_send_transaction.confirmation.data.total', children: t('dyn_send_transaction.confirmation.data.total') }), jsx("div", { className: 'transaction-card__total-amount', children: jsx(Typography, { variant: 'body_normal', color: 'primary', "data-testid": 'transaction-estimated-total', children: getTotalAmountInUsdDisplay(totalAmountInUsd) }) })] })] }))] }) })] }));
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.cjs
CHANGED
|
@@ -155,7 +155,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
155
155
|
const totalGasFiatValue = fiatUtils.getTotalFiatCost(currentToken, transaction, nativePrice, transactionValue);
|
|
156
156
|
return hideModal ? null : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsxRuntime.jsx("div", { className: 'send-balance-page-layout__header-content', children: jsxRuntime.jsx(Typography.Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), !sendBalanceTransaction && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__banner', children: jsxRuntime.jsx(Typography.Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) })), jsxRuntime.jsx(PasskeyCreatedSuccessBanner.PasskeyCreatedSuccessBanner, {}), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__body', children: [jsxRuntime.jsxs("div", { className: 'transaction-confirmation__content', children: [error && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__error', children: jsxRuntime.jsx(ErrorContainer.ErrorContainer, { children: transactionLink && transactionSignature ? (jsxRuntime.jsx(reactI18next.Trans, { i18nKey: 'dyn_send_transaction.error_message.confirmation_timeout_with_link', components: {
|
|
157
157
|
link: (jsxRuntime.jsx(Typography.Typography, { as: 'a', href: transactionLink, target: '_blank', rel: 'noreferrer', className: 'transaction-confirmation__error-link', variant: 'body_small' })),
|
|
158
|
-
} })) : (error) }) })), !sendBalanceTransaction ? (jsxRuntime.jsx(TransactionCard.TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'zerodev', simulationResult: simulationResult, recipient: recipient })) : (jsxRuntime.jsx(SendBalanceTransactionCard.SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = utils.getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, onFeeUpdate: fetchTransactionFee })), children && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, {}), children: alert && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', buttonPadding: 'medium', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'medium', onClick: onClickSend, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), jsxRuntime.jsx(NeedHelpSection.NeedHelpSection, {}), displayPoweredByDynamicFooter && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'transaction-confirmation__divider' }), jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' })] }))] })] }));
|
|
158
|
+
} })) : (error) }) })), !sendBalanceTransaction ? (jsxRuntime.jsx(TransactionCard.TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'zerodev', simulationResult: simulationResult, recipient: recipient, walletConnector: walletConnector })) : (jsxRuntime.jsx(SendBalanceTransactionCard.SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = utils.getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, onFeeUpdate: fetchTransactionFee })), children && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsxRuntime.jsx(AnimatePresence.AnimatePresence, { animationComponent: jsxRuntime.jsx(VerticalDrawerTransition.VerticalDrawerTransition, {}), children: alert && (jsxRuntime.jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxRuntime.jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'primary', buttonPadding: 'medium', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsxRuntime.jsx(TypographyButton.TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'medium', onClick: onClickSend, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), jsxRuntime.jsx(NeedHelpSection.NeedHelpSection, {}), displayPoweredByDynamicFooter && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx("div", { className: 'transaction-confirmation__divider' }), jsxRuntime.jsx(PoweredByDynamic.PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' })] }))] })] }));
|
|
159
159
|
};
|
|
160
160
|
|
|
161
161
|
exports.TransactionConfirmationPageLayout = TransactionConfirmationPageLayout;
|
package/src/lib/components/TransactionConfirmationPageLayout/TransactionConfirmationPageLayout.js
CHANGED
|
@@ -151,7 +151,7 @@ const TransactionConfirmationPageLayout = ({ onClickClose, isLoading, onClickBac
|
|
|
151
151
|
const totalGasFiatValue = getTotalFiatCost(currentToken, transaction, nativePrice, transactionValue);
|
|
152
152
|
return hideModal ? null : (jsxs(Fragment, { children: [jsx(ModalHeader, { trailing: closeButton, leading: backButton, alignContent: 'bottom', children: jsx("div", { className: 'send-balance-page-layout__header-content', children: jsx(Typography, { variant: 'title', color: 'primary', copykey: 'dyn_send_transaction.data.confirmation_tx', children: t('dyn_send_transaction.data.confirmation_tx') }) }) }), !sendBalanceTransaction && (jsx("div", { className: 'transaction-confirmation__banner', children: jsx(Typography, { variant: 'body_normal', color: 'primary', copykey: 'dyn_send_transaction.data.banner', children: t('dyn_send_transaction.data.banner') }) })), jsx(PasskeyCreatedSuccessBanner, {}), jsxs("div", { className: 'transaction-confirmation__body', children: [jsxs("div", { className: 'transaction-confirmation__content', children: [error && (jsx("div", { className: 'transaction-confirmation__error', children: jsx(ErrorContainer, { children: transactionLink && transactionSignature ? (jsx(Trans, { i18nKey: 'dyn_send_transaction.error_message.confirmation_timeout_with_link', components: {
|
|
153
153
|
link: (jsx(Typography, { as: 'a', href: transactionLink, target: '_blank', rel: 'noreferrer', className: 'transaction-confirmation__error-link', variant: 'body_small' })),
|
|
154
|
-
} })) : (error) }) })), !sendBalanceTransaction ? (jsx(TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'zerodev', simulationResult: simulationResult, recipient: recipient })) : (jsx(SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, onFeeUpdate: fetchTransactionFee })), children && (jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, {}), children: alert && (jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsx(TypographyButton, { buttonVariant: 'primary', buttonPadding: 'medium', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'medium', onClick: onClickSend, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), jsx(NeedHelpSection, {}), displayPoweredByDynamicFooter && (jsxs(Fragment, { children: [jsx("div", { className: 'transaction-confirmation__divider' }), jsx(PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' })] }))] })] }));
|
|
154
|
+
} })) : (error) }) })), !sendBalanceTransaction ? (jsx(TransactionCard, { transaction: transaction, isGasSponsored: isGasSponsored, isAATransaction: (walletConnector === null || walletConnector === void 0 ? void 0 : walletConnector.key) === 'zerodev', simulationResult: simulationResult, recipient: recipient, walletConnector: walletConnector })) : (jsx(SendBalanceTransactionCard, { transaction: transaction, currentToken: currentToken, currencySymbol: currencySymbol, valueRounded: (_a = getValueRounded(Boolean(isNativeToken), transaction)) === null || _a === void 0 ? void 0 : _a.toString(), transactionValue: transactionValue, isGasSponsored: isGasSponsored, gasFiatValue: gasFiatValue || '0', totalGasFiatValue: totalGasFiatValue || '0', currency: currency === null || currency === void 0 ? void 0 : currency.symbol, total: total, t: t, onFeeUpdate: fetchTransactionFee })), children && (jsx("div", { className: 'transaction-confirmation__rows', children: children }))] }), jsx(AnimatePresence, { animationComponent: jsx(VerticalDrawerTransition, {}), children: alert && (jsx("div", { className: 'transaction-confirmation__warning', children: alert })) }), jsxs("div", { className: 'transaction-confirmation__actions', children: [(onClickBack || onClickClose) && (jsx(TypographyButton, { buttonVariant: 'primary', buttonPadding: 'medium', onClick: onClickBack || onClickClose, expanded: true, disabled: isLoading, copykey: 'dyn_send_transaction.confirmation.cancel_button', children: t('dyn_send_transaction.confirmation.cancel_button') })), jsx(TypographyButton, { buttonVariant: 'brand-primary', buttonPadding: 'medium', onClick: onClickSend, expanded: true, loading: isLoading, disabled: disableSendButton, copykey: 'dyn_send_transaction.confirmation.send', dataTestId: 'transaction-confirmation-send', children: t('dyn_send_transaction.confirmation.send') })] }), jsx(NeedHelpSection, {}), displayPoweredByDynamicFooter && (jsxs(Fragment, { children: [jsx("div", { className: 'transaction-confirmation__divider' }), jsx(PoweredByDynamic, { classNameRoot: 'transaction-confirmation__footer' })] }))] })] }));
|
|
155
155
|
};
|
|
156
156
|
|
|
157
157
|
export { TransactionConfirmationPageLayout };
|
|
@@ -76,6 +76,7 @@ export { useAggregateWalletEvents } from './useAggregateWalletEvents';
|
|
|
76
76
|
export { useDeleteUserAccount } from './useDeleteUserAccount';
|
|
77
77
|
export { useDynamicWaas } from './useDynamicWaas';
|
|
78
78
|
export { useBusinessAccounts } from './useBusinessAccounts';
|
|
79
|
+
export { usePolicies } from './usePolicies';
|
|
79
80
|
export { useSyncDynamicWaas } from './useSyncDynamicWaas';
|
|
80
81
|
export { useExchangeAccounts } from './useExchangeAccounts';
|
|
81
82
|
export { useConnectExchangeForFunding } from './useConnectExchangeForFunding';
|
|
@@ -435,13 +435,14 @@ const useDynamicWaas = () => {
|
|
|
435
435
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
436
436
|
enabledChainNames,
|
|
437
437
|
]);
|
|
438
|
-
const importPrivateKey = (_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, }) {
|
|
438
|
+
const importPrivateKey = (_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }) {
|
|
439
439
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
440
440
|
if (!walletConnector)
|
|
441
441
|
return;
|
|
442
442
|
yield walletConnector.importPrivateKey({
|
|
443
443
|
addressType,
|
|
444
444
|
chainName,
|
|
445
|
+
isRawScalarImport,
|
|
445
446
|
legacyWalletId,
|
|
446
447
|
password,
|
|
447
448
|
privateKey,
|
|
@@ -44,12 +44,14 @@ export declare const useDynamicWaas: () => {
|
|
|
44
44
|
getWaasWalletConnector: (chainName: string) => IDynamicWaasConnector | undefined;
|
|
45
45
|
getWaasWallets: () => import("@dynamic-labs/wallet-connector-core").Wallet<import("@dynamic-labs/wallet-connector-core").WalletConnectorCore.WalletConnector>[];
|
|
46
46
|
getWaasWalletsByCredentials: () => import("@dynamic-labs/sdk-api-core").JwtVerifiedCredential[];
|
|
47
|
-
importPrivateKey: ({ chainName, privateKey, addressType, legacyWalletId, password, }: {
|
|
47
|
+
importPrivateKey: ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }: {
|
|
48
48
|
chainName: ChainEnum;
|
|
49
49
|
privateKey: string;
|
|
50
50
|
addressType?: string;
|
|
51
51
|
legacyWalletId?: string;
|
|
52
52
|
password?: string;
|
|
53
|
+
/** ed25519 chains only: `privateKey` is a raw 32-byte scalar (hex). */
|
|
54
|
+
isRawScalarImport?: boolean;
|
|
53
55
|
}) => Promise<void>;
|
|
54
56
|
initializeWaas: ({ forceClientRebuild, }?: {
|
|
55
57
|
forceClientRebuild?: boolean;
|
|
@@ -431,13 +431,14 @@ const useDynamicWaas = () => {
|
|
|
431
431
|
automaticEmbeddedWalletCreationForExternalEnabled,
|
|
432
432
|
enabledChainNames,
|
|
433
433
|
]);
|
|
434
|
-
const importPrivateKey = (_g) => __awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, }) {
|
|
434
|
+
const importPrivateKey = (_g) => __awaiter(void 0, [_g], void 0, function* ({ chainName, privateKey, addressType, legacyWalletId, password, isRawScalarImport, }) {
|
|
435
435
|
const walletConnector = getWaasWalletConnector(chainName);
|
|
436
436
|
if (!walletConnector)
|
|
437
437
|
return;
|
|
438
438
|
yield walletConnector.importPrivateKey({
|
|
439
439
|
addressType,
|
|
440
440
|
chainName,
|
|
441
|
+
isRawScalarImport,
|
|
441
442
|
legacyWalletId,
|
|
442
443
|
password,
|
|
443
444
|
privateKey,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './usePolicies';
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var React = require('react');
|
|
8
|
+
var client$1 = require('@dynamic-labs-sdk/client');
|
|
9
|
+
var waas = require('@dynamic-labs-sdk/client/waas');
|
|
10
|
+
var client = require('../../../client/client.cjs');
|
|
11
|
+
|
|
12
|
+
const usePolicies = () => {
|
|
13
|
+
const dynamicClient = client.useDynamicClient();
|
|
14
|
+
const getWalletAccount = React.useCallback((walletId) => {
|
|
15
|
+
const walletAccount = client$1.getWalletAccounts(dynamicClient).find((account) => account.verifiedCredentialId === walletId || account.id === walletId);
|
|
16
|
+
if (!walletAccount) {
|
|
17
|
+
throw new Error(`Wallet account with id ${walletId} not found`);
|
|
18
|
+
}
|
|
19
|
+
if (walletAccount.verifiedCredentialId === null) {
|
|
20
|
+
throw new Error(`Wallet account with id ${walletId} is not verified`);
|
|
21
|
+
}
|
|
22
|
+
return walletAccount;
|
|
23
|
+
}, [dynamicClient]);
|
|
24
|
+
const createPolicy = React.useCallback((input) => waas.createPolicy(input, dynamicClient), [dynamicClient]);
|
|
25
|
+
const getPolicy = React.useCallback((input) => waas.getPolicy(input, dynamicClient), [dynamicClient]);
|
|
26
|
+
const removePolicyRules = React.useCallback((input) => waas.removePolicyRules(input, dynamicClient), [dynamicClient]);
|
|
27
|
+
const getWalletPolicyLayer = React.useCallback((_a) => _tslib.__awaiter(void 0, [_a], void 0, function* ({ walletId }) {
|
|
28
|
+
return waas.getWalletPolicyLayer({ walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
29
|
+
}), [dynamicClient, getWalletAccount]);
|
|
30
|
+
const getSignerPolicyLayer = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ shareSetId, walletId }) {
|
|
31
|
+
return waas.getSignerPolicyLayer({ shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
32
|
+
}), [dynamicClient, getWalletAccount]);
|
|
33
|
+
const getAccountPolicyLayer = React.useCallback((input) => waas.getAccountPolicyLayer(input, dynamicClient), [dynamicClient]);
|
|
34
|
+
const upsertWalletPolicyRule = React.useCallback((_c) => _tslib.__awaiter(void 0, [_c], void 0, function* ({ rule, walletId }) {
|
|
35
|
+
return waas.upsertWalletPolicyRule({ rule, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
36
|
+
}), [dynamicClient, getWalletAccount]);
|
|
37
|
+
const upsertSignerPolicyRule = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ rule, shareSetId, walletId }) {
|
|
38
|
+
return waas.upsertSignerPolicyRule({ rule, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
39
|
+
}), [dynamicClient, getWalletAccount]);
|
|
40
|
+
const upsertAccountPolicyRule = React.useCallback((input) => waas.upsertAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
41
|
+
const removeWalletPolicyRule = React.useCallback((_e) => _tslib.__awaiter(void 0, [_e], void 0, function* ({ ruleId, walletId }) {
|
|
42
|
+
return waas.removeWalletPolicyRule({ ruleId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
43
|
+
}), [dynamicClient, getWalletAccount]);
|
|
44
|
+
const removeSignerPolicyRule = React.useCallback((_f) => _tslib.__awaiter(void 0, [_f], void 0, function* ({ ruleId, shareSetId, walletId }) {
|
|
45
|
+
return waas.removeSignerPolicyRule({ ruleId, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
46
|
+
}), [dynamicClient, getWalletAccount]);
|
|
47
|
+
const removeAccountPolicyRule = React.useCallback((input) => waas.removeAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
48
|
+
return {
|
|
49
|
+
createPolicy,
|
|
50
|
+
getAccountPolicyLayer,
|
|
51
|
+
getPolicy,
|
|
52
|
+
getSignerPolicyLayer,
|
|
53
|
+
getWalletPolicyLayer,
|
|
54
|
+
removeAccountPolicyRule,
|
|
55
|
+
removePolicyRules,
|
|
56
|
+
removeSignerPolicyRule,
|
|
57
|
+
removeWalletPolicyRule,
|
|
58
|
+
upsertAccountPolicyRule,
|
|
59
|
+
upsertSignerPolicyRule,
|
|
60
|
+
upsertWalletPolicyRule,
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.usePolicies = usePolicies;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { createPolicy as createPolicyFromSDK, getAccountPolicyLayer as getAccountPolicyLayerFromSDK, getPolicy as getPolicyFromSDK, getSignerPolicyLayer as getSignerPolicyLayerFromSDK, getWalletPolicyLayer as getWalletPolicyLayerFromSDK, removeAccountPolicyRule as removeAccountPolicyRuleFromSDK, removePolicyRules as removePolicyRulesFromSDK, removeSignerPolicyRule as removeSignerPolicyRuleFromSDK, removeWalletPolicyRule as removeWalletPolicyRuleFromSDK, upsertAccountPolicyRule as upsertAccountPolicyRuleFromSDK, upsertSignerPolicyRule as upsertSignerPolicyRuleFromSDK, upsertWalletPolicyRule as upsertWalletPolicyRuleFromSDK } from '@dynamic-labs-sdk/client/waas';
|
|
2
|
+
type WithWalletId<T> = Omit<T, 'walletAccount'> & {
|
|
3
|
+
walletId: string;
|
|
4
|
+
};
|
|
5
|
+
export type CreatePolicyInput = Parameters<typeof createPolicyFromSDK>[0];
|
|
6
|
+
export type GetPolicyInput = Parameters<typeof getPolicyFromSDK>[0];
|
|
7
|
+
export type RemovePolicyRulesInput = Parameters<typeof removePolicyRulesFromSDK>[0];
|
|
8
|
+
export type GetWalletPolicyLayerInput = WithWalletId<Parameters<typeof getWalletPolicyLayerFromSDK>[0]>;
|
|
9
|
+
export type GetSignerPolicyLayerInput = WithWalletId<Parameters<typeof getSignerPolicyLayerFromSDK>[0]>;
|
|
10
|
+
export type GetAccountPolicyLayerInput = Parameters<typeof getAccountPolicyLayerFromSDK>[0];
|
|
11
|
+
export type UpsertWalletPolicyRuleInput = WithWalletId<Parameters<typeof upsertWalletPolicyRuleFromSDK>[0]>;
|
|
12
|
+
export type UpsertSignerPolicyRuleInput = WithWalletId<Parameters<typeof upsertSignerPolicyRuleFromSDK>[0]>;
|
|
13
|
+
export type UpsertAccountPolicyRuleInput = Parameters<typeof upsertAccountPolicyRuleFromSDK>[0];
|
|
14
|
+
export type RemoveWalletPolicyRuleInput = WithWalletId<Parameters<typeof removeWalletPolicyRuleFromSDK>[0]>;
|
|
15
|
+
export type RemoveSignerPolicyRuleInput = WithWalletId<Parameters<typeof removeSignerPolicyRuleFromSDK>[0]>;
|
|
16
|
+
export type RemoveAccountPolicyRuleInput = Parameters<typeof removeAccountPolicyRuleFromSDK>[0];
|
|
17
|
+
export declare const usePolicies: () => {
|
|
18
|
+
createPolicy: (input: CreatePolicyInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
19
|
+
getAccountPolicyLayer: (input: GetAccountPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
20
|
+
getPolicy: (input: GetPolicyInput) => Promise<{
|
|
21
|
+
layerId: string;
|
|
22
|
+
rules: import("@dynamic-labs-sdk/client/waas").PolicyRules;
|
|
23
|
+
unmapped: import("@dynamic-labs-sdk/client/waas").WaasPolicyRule[];
|
|
24
|
+
updatedAt: Date;
|
|
25
|
+
}>;
|
|
26
|
+
getSignerPolicyLayer: ({ shareSetId, walletId }: GetSignerPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
27
|
+
getWalletPolicyLayer: ({ walletId }: GetWalletPolicyLayerInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
28
|
+
removeAccountPolicyRule: (input: RemoveAccountPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
29
|
+
removePolicyRules: (input: RemovePolicyRulesInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
30
|
+
removeSignerPolicyRule: ({ ruleId, shareSetId, walletId }: RemoveSignerPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
31
|
+
removeWalletPolicyRule: ({ ruleId, walletId }: RemoveWalletPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
32
|
+
upsertAccountPolicyRule: (input: UpsertAccountPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
33
|
+
upsertSignerPolicyRule: ({ rule, shareSetId, walletId }: UpsertSignerPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
34
|
+
upsertWalletPolicyRule: ({ rule, walletId }: UpsertWalletPolicyRuleInput) => Promise<import("@dynamic-labs-sdk/client/waas").WaasPolicyLayerResponse>;
|
|
35
|
+
};
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
|
+
import { getWalletAccounts } from '@dynamic-labs-sdk/client';
|
|
5
|
+
import { createPolicy, getPolicy, removePolicyRules, getAccountPolicyLayer, upsertAccountPolicyRule, removeAccountPolicyRule, getWalletPolicyLayer, getSignerPolicyLayer, upsertWalletPolicyRule, upsertSignerPolicyRule, removeWalletPolicyRule, removeSignerPolicyRule } from '@dynamic-labs-sdk/client/waas';
|
|
6
|
+
import { useDynamicClient } from '../../../client/client.js';
|
|
7
|
+
|
|
8
|
+
const usePolicies = () => {
|
|
9
|
+
const dynamicClient = useDynamicClient();
|
|
10
|
+
const getWalletAccount = useCallback((walletId) => {
|
|
11
|
+
const walletAccount = getWalletAccounts(dynamicClient).find((account) => account.verifiedCredentialId === walletId || account.id === walletId);
|
|
12
|
+
if (!walletAccount) {
|
|
13
|
+
throw new Error(`Wallet account with id ${walletId} not found`);
|
|
14
|
+
}
|
|
15
|
+
if (walletAccount.verifiedCredentialId === null) {
|
|
16
|
+
throw new Error(`Wallet account with id ${walletId} is not verified`);
|
|
17
|
+
}
|
|
18
|
+
return walletAccount;
|
|
19
|
+
}, [dynamicClient]);
|
|
20
|
+
const createPolicy$1 = useCallback((input) => createPolicy(input, dynamicClient), [dynamicClient]);
|
|
21
|
+
const getPolicy$1 = useCallback((input) => getPolicy(input, dynamicClient), [dynamicClient]);
|
|
22
|
+
const removePolicyRules$1 = useCallback((input) => removePolicyRules(input, dynamicClient), [dynamicClient]);
|
|
23
|
+
const getWalletPolicyLayer$1 = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ walletId }) {
|
|
24
|
+
return getWalletPolicyLayer({ walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
25
|
+
}), [dynamicClient, getWalletAccount]);
|
|
26
|
+
const getSignerPolicyLayer$1 = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ shareSetId, walletId }) {
|
|
27
|
+
return getSignerPolicyLayer({ shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
28
|
+
}), [dynamicClient, getWalletAccount]);
|
|
29
|
+
const getAccountPolicyLayer$1 = useCallback((input) => getAccountPolicyLayer(input, dynamicClient), [dynamicClient]);
|
|
30
|
+
const upsertWalletPolicyRule$1 = useCallback((_c) => __awaiter(void 0, [_c], void 0, function* ({ rule, walletId }) {
|
|
31
|
+
return upsertWalletPolicyRule({ rule, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
32
|
+
}), [dynamicClient, getWalletAccount]);
|
|
33
|
+
const upsertSignerPolicyRule$1 = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ rule, shareSetId, walletId }) {
|
|
34
|
+
return upsertSignerPolicyRule({ rule, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
35
|
+
}), [dynamicClient, getWalletAccount]);
|
|
36
|
+
const upsertAccountPolicyRule$1 = useCallback((input) => upsertAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
37
|
+
const removeWalletPolicyRule$1 = useCallback((_e) => __awaiter(void 0, [_e], void 0, function* ({ ruleId, walletId }) {
|
|
38
|
+
return removeWalletPolicyRule({ ruleId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
39
|
+
}), [dynamicClient, getWalletAccount]);
|
|
40
|
+
const removeSignerPolicyRule$1 = useCallback((_f) => __awaiter(void 0, [_f], void 0, function* ({ ruleId, shareSetId, walletId }) {
|
|
41
|
+
return removeSignerPolicyRule({ ruleId, shareSetId, walletAccount: getWalletAccount(walletId) }, dynamicClient);
|
|
42
|
+
}), [dynamicClient, getWalletAccount]);
|
|
43
|
+
const removeAccountPolicyRule$1 = useCallback((input) => removeAccountPolicyRule(input, dynamicClient), [dynamicClient]);
|
|
44
|
+
return {
|
|
45
|
+
createPolicy: createPolicy$1,
|
|
46
|
+
getAccountPolicyLayer: getAccountPolicyLayer$1,
|
|
47
|
+
getPolicy: getPolicy$1,
|
|
48
|
+
getSignerPolicyLayer: getSignerPolicyLayer$1,
|
|
49
|
+
getWalletPolicyLayer: getWalletPolicyLayer$1,
|
|
50
|
+
removeAccountPolicyRule: removeAccountPolicyRule$1,
|
|
51
|
+
removePolicyRules: removePolicyRules$1,
|
|
52
|
+
removeSignerPolicyRule: removeSignerPolicyRule$1,
|
|
53
|
+
removeWalletPolicyRule: removeWalletPolicyRule$1,
|
|
54
|
+
upsertAccountPolicyRule: upsertAccountPolicyRule$1,
|
|
55
|
+
upsertSignerPolicyRule: upsertSignerPolicyRule$1,
|
|
56
|
+
upsertWalletPolicyRule: upsertWalletPolicyRule$1,
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { usePolicies };
|