@dynamic-labs/sdk-react-core 0.17.26 → 0.17.28
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 +15 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.cjs +1 -1
- package/src/lib/components/TransactionStatusLayout/TransactionStatusLayout.js +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.cjs +4 -4
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -2
- package/src/lib/context/DynamicContext/DynamicContext.js +4 -4
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +3 -3
- package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +3 -3
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.cjs +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.js +10 -2
- package/src/lib/modals/TransactionConfirmationModal/TransactionConfirmationModal.types.d.ts +2 -0
- package/src/lib/utils/functions/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/index.d.ts +1 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.cjs +10 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.d.ts +2 -0
- package/src/lib/utils/functions/isMagicConnector/isMagicConnector.js +6 -0
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.cjs +2 -2
- package/src/lib/utils/hooks/authenticationHooks/useConnectAndSign/useConnectAndSign.js +2 -2
- package/src/lib/utils/hooks/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/index.d.ts +1 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.cjs +41 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.d.ts +32 -0
- package/src/lib/utils/hooks/useTransactionWithGasPrice/useTransactionWithGasPrice.js +37 -0
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.cjs +21 -5
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.d.ts +8 -4
- package/src/lib/utils/hooks/useUserUpdateRequest/useUserUpdateRequest.js +21 -5
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.cjs +20 -19
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.d.ts +4 -1
- package/src/lib/utils/hooks/useWalletUiUtils/useWalletUiUtils.js +20 -19
- package/src/lib/utils/hooks/useWallets/useWallets.cjs +3 -3
- package/src/lib/utils/hooks/useWallets/useWallets.d.ts +3 -3
- package/src/lib/utils/hooks/useWallets/useWallets.js +3 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.cjs +10 -3
- package/src/lib/views/CollectUserDataView/OnboardingUserDataForm/OnboardingUserDataForm.js +10 -3
- package/src/lib/views/SendBalanceView/SendBalanceView.cjs +9 -16
- package/src/lib/views/SendBalanceView/SendBalanceView.js +9 -16
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.cjs +63 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.d.ts +8 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/TransactionStage.js +59 -0
- package/src/lib/views/SendBalanceView/components/TransactionStage/index.d.ts +1 -0
- package/src/lib/views/SendBalanceView/components/index.d.ts +1 -0
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.cjs +2 -2
- package/src/lib/views/TransactionConfirmationView/TransactionConfirmationView.js +2 -2
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs +21 -8
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts +4 -0
- package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js +21 -8
|
@@ -65,7 +65,7 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
65
65
|
onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
|
|
66
66
|
onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
|
|
67
67
|
});
|
|
68
|
-
const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData.useTransactionData({
|
|
68
|
+
const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionGas, transactionValue, isGasLoading, gasEstimate, isGasPriceLoading, total, } = useTransactionData.useTransactionData({
|
|
69
69
|
provider,
|
|
70
70
|
transaction,
|
|
71
71
|
});
|
|
@@ -90,7 +90,7 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
90
90
|
return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
|
|
91
91
|
}, [currencySymbol, hasInsufficientFunds, missingFunds]);
|
|
92
92
|
return (jsxRuntime.jsxs(TransactionConfirmationPageLayout.TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isLoadingTransaction || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage }, { children: [jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress.shortenWalletAddress(transactionFromAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
|
|
93
|
-
shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber.formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Gas (
|
|
93
|
+
shortenWalletAddress.shortenWalletAddress(transactionToAddress, 4, 4) })), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber.formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber.formatBigNumber(transactionValue, 10) : 0 })), transactionGas ? (jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Gas', isEmpty: !transactionGas, isLoading: isGasLoading, title: transactionGas && formatBigNumber.formatBigNumber(transactionGas), suffix: transactionGas && currencySymbol, icon: transactionGas && chainIcon, dataTestId: 'transaction-gas-fee' }, { children: transactionGas ? formatBigNumber.formatBigNumber(transactionGas, 10) : 'N/A' }))) : (jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Gas (estimate)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate && formatBigNumber.formatBigNumber(gasEstimate), suffix: gasEstimate && currencySymbol, icon: gasEstimate && chainIcon, dataTestId: 'transaction-estimated-gas-fee' }, { children: gasEstimate ? formatBigNumber.formatBigNumber(gasEstimate, 10) : 'N/A' }))), jsxRuntime.jsx(TransactionRow.TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber.formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber.formatBigNumber(total, 10) : 'N/A' }))] })));
|
|
94
94
|
};
|
|
95
95
|
|
|
96
96
|
exports.TransactionConfirmationView = TransactionConfirmationView;
|
|
@@ -61,7 +61,7 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
61
61
|
onFailure: (error) => onError === null || onError === void 0 ? void 0 : onError(error),
|
|
62
62
|
onSuccess: (tx) => onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(tx),
|
|
63
63
|
});
|
|
64
|
-
const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionValue, gasEstimate, isGasPriceLoading, total, } = useTransactionData({
|
|
64
|
+
const { isLoading: isLoadingTransaction, isTransactionFromAddressLoading, isTransactionToAddressLoading, transactionFromAddress, transactionToAddress, isEffectiveValueLoading, transactionGas, transactionValue, isGasLoading, gasEstimate, isGasPriceLoading, total, } = useTransactionData({
|
|
65
65
|
provider,
|
|
66
66
|
transaction,
|
|
67
67
|
});
|
|
@@ -86,7 +86,7 @@ const TransactionConfirmationView = ({ provider, transaction, mutation, onError,
|
|
|
86
86
|
return `Insufficient funds due to gas price increase from estimate. Please add ${amountLeft} ${currencySymbol} to continue.`;
|
|
87
87
|
}, [currencySymbol, hasInsufficientFunds, missingFunds]);
|
|
88
88
|
return (jsxs(TransactionConfirmationPageLayout, Object.assign({ onClickBack: onClickBack, onClickClose: onClickClose, title: title, appOrigin: appOrigin, appName: appName, appLogoUrl: appLogoUrl, isLoading: isLoading, onClickSend: () => send(), displayPoweredByDynamicFooter: displayPoweredByDynamicFooter, disableSendButton: isLoadingTransaction || hasInsufficientFunds, error: errorMessage, warningMessage: warningMessage }, { children: [jsx(TransactionRow, Object.assign({ label: 'From (You)', isLoading: isTransactionFromAddressLoading, title: transactionFromAddress }, { children: shortenWalletAddress(transactionFromAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'To', isLoading: isTransactionToAddressLoading, title: transactionToAddress }, { children: transactionToAddress &&
|
|
89
|
-
shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 })), jsx(TransactionRow, Object.assign({ label: 'Gas (
|
|
89
|
+
shortenWalletAddress(transactionToAddress, 4, 4) })), jsx(TransactionRow, Object.assign({ label: 'Amount', isLoading: isEffectiveValueLoading, isEmpty: !transactionValue, title: transactionValue && formatBigNumber(transactionValue), suffix: currencySymbol, icon: chainIcon, dataTestId: 'transaction-amount' }, { children: transactionValue ? formatBigNumber(transactionValue, 10) : 0 })), transactionGas ? (jsx(TransactionRow, Object.assign({ label: 'Gas', isEmpty: !transactionGas, isLoading: isGasLoading, title: transactionGas && formatBigNumber(transactionGas), suffix: transactionGas && currencySymbol, icon: transactionGas && chainIcon, dataTestId: 'transaction-gas-fee' }, { children: transactionGas ? formatBigNumber(transactionGas, 10) : 'N/A' }))) : (jsx(TransactionRow, Object.assign({ label: 'Gas (estimate)', isEmpty: !gasEstimate, isLoading: isGasPriceLoading, title: gasEstimate && formatBigNumber(gasEstimate), suffix: gasEstimate && currencySymbol, icon: gasEstimate && chainIcon, dataTestId: 'transaction-estimated-gas-fee' }, { children: gasEstimate ? formatBigNumber(gasEstimate, 10) : 'N/A' }))), jsx(TransactionRow, Object.assign({ label: 'Total', isEmpty: !total, title: total && formatBigNumber(total), suffix: total && currencySymbol, icon: total && chainIcon, dataTestId: 'transaction-total' }, { children: total ? formatBigNumber(total, 10) : 'N/A' }))] })));
|
|
90
90
|
};
|
|
91
91
|
|
|
92
92
|
export { TransactionConfirmationView };
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.cjs
CHANGED
|
@@ -54,19 +54,28 @@ const useTransactionData = ({ provider, transaction, }) => {
|
|
|
54
54
|
const { from } = transaction, transactionWithNoOrigin = _tslib.__rest(transaction, ["from"]);
|
|
55
55
|
return provider.estimateGas(transactionWithNoOrigin);
|
|
56
56
|
});
|
|
57
|
-
const { data:
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
? ethers.ethers.BigNumber.from(gasPrice)
|
|
61
|
-
|
|
57
|
+
const { data: providerGasPrice, isLoading: isProviderGasPrice } = usePromise.usePromise(() => provider.getGasPrice(), []);
|
|
58
|
+
const { data: transactionGasPrice, isLoading: isTransactionGasPriceLoading } = usePromise.usePromise(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
59
|
+
const gasPrice = yield transaction.gasPrice;
|
|
60
|
+
return gasPrice ? ethers.ethers.BigNumber.from(gasPrice) : undefined;
|
|
61
|
+
}), [transaction.gasPrice]);
|
|
62
|
+
const isGasPriceLoading = isEstimatedGasLoading || isProviderGasPrice || isTransactionGasPriceLoading;
|
|
63
|
+
const isGasLoading = isProviderGasPrice || isTransactionGasPriceLoading;
|
|
64
|
+
const transactionGas = React.useMemo(() => transactionGasPrice && estimatedGas
|
|
65
|
+
? ethers.ethers.BigNumber.from(transactionGasPrice).mul(estimatedGas)
|
|
66
|
+
: undefined, [estimatedGas, transactionGasPrice]);
|
|
67
|
+
const gasEstimate = React.useMemo(() => !transactionGasPrice && providerGasPrice && estimatedGas
|
|
68
|
+
? ethers.ethers.BigNumber.from(providerGasPrice).mul(estimatedGas)
|
|
69
|
+
: undefined, [transactionGasPrice, estimatedGas, providerGasPrice]);
|
|
62
70
|
const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise.usePromise(() => transaction.to);
|
|
63
71
|
const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise.usePromise(() => transaction.from);
|
|
64
72
|
const total = React.useMemo(() => {
|
|
65
|
-
|
|
66
|
-
|
|
73
|
+
const transactionGasFee = transactionGas || gasEstimate;
|
|
74
|
+
if (transactionGasFee !== undefined && transactionValue !== undefined) {
|
|
75
|
+
return transactionGasFee.add(transactionValue);
|
|
67
76
|
}
|
|
68
77
|
return transactionValue || gasEstimate;
|
|
69
|
-
}, [gasEstimate, transactionValue]);
|
|
78
|
+
}, [gasEstimate, transactionGas, transactionValue]);
|
|
70
79
|
const isLoading = React.useMemo(() => isEffectiveValueLoading ||
|
|
71
80
|
isGasPriceLoading ||
|
|
72
81
|
isTransactionToAddressLoading ||
|
|
@@ -79,12 +88,16 @@ const useTransactionData = ({ provider, transaction, }) => {
|
|
|
79
88
|
return {
|
|
80
89
|
gasEstimate,
|
|
81
90
|
isEffectiveValueLoading,
|
|
91
|
+
isGasLoading,
|
|
82
92
|
isGasPriceLoading,
|
|
83
93
|
isLoading,
|
|
84
94
|
isTransactionFromAddressLoading,
|
|
95
|
+
isTransactionGasPriceLoading,
|
|
85
96
|
isTransactionToAddressLoading,
|
|
86
97
|
total,
|
|
87
98
|
transactionFromAddress,
|
|
99
|
+
transactionGas,
|
|
100
|
+
transactionGasPrice,
|
|
88
101
|
transactionToAddress,
|
|
89
102
|
transactionValue,
|
|
90
103
|
};
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.d.ts
CHANGED
|
@@ -6,12 +6,16 @@ type TransactionDataHookProps = {
|
|
|
6
6
|
export declare const useTransactionData: ({ provider, transaction, }: TransactionDataHookProps) => {
|
|
7
7
|
gasEstimate: ethers.BigNumber | undefined;
|
|
8
8
|
isEffectiveValueLoading: boolean;
|
|
9
|
+
isGasLoading: boolean;
|
|
9
10
|
isGasPriceLoading: boolean;
|
|
10
11
|
isLoading: boolean;
|
|
11
12
|
isTransactionFromAddressLoading: boolean;
|
|
13
|
+
isTransactionGasPriceLoading: boolean;
|
|
12
14
|
isTransactionToAddressLoading: boolean;
|
|
13
15
|
total: ethers.BigNumber | undefined;
|
|
14
16
|
transactionFromAddress: string | undefined;
|
|
17
|
+
transactionGas: ethers.BigNumber | undefined;
|
|
18
|
+
transactionGasPrice: ethers.BigNumber | undefined;
|
|
15
19
|
transactionToAddress: string | undefined;
|
|
16
20
|
transactionValue: ethers.BigNumber | undefined;
|
|
17
21
|
};
|
package/src/lib/views/TransactionConfirmationView/hooks/useTransactionData/useTransactionData.js
CHANGED
|
@@ -50,19 +50,28 @@ const useTransactionData = ({ provider, transaction, }) => {
|
|
|
50
50
|
const { from } = transaction, transactionWithNoOrigin = __rest(transaction, ["from"]);
|
|
51
51
|
return provider.estimateGas(transactionWithNoOrigin);
|
|
52
52
|
});
|
|
53
|
-
const { data:
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
? ethers.BigNumber.from(gasPrice)
|
|
57
|
-
|
|
53
|
+
const { data: providerGasPrice, isLoading: isProviderGasPrice } = usePromise(() => provider.getGasPrice(), []);
|
|
54
|
+
const { data: transactionGasPrice, isLoading: isTransactionGasPriceLoading } = usePromise(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
const gasPrice = yield transaction.gasPrice;
|
|
56
|
+
return gasPrice ? ethers.BigNumber.from(gasPrice) : undefined;
|
|
57
|
+
}), [transaction.gasPrice]);
|
|
58
|
+
const isGasPriceLoading = isEstimatedGasLoading || isProviderGasPrice || isTransactionGasPriceLoading;
|
|
59
|
+
const isGasLoading = isProviderGasPrice || isTransactionGasPriceLoading;
|
|
60
|
+
const transactionGas = useMemo(() => transactionGasPrice && estimatedGas
|
|
61
|
+
? ethers.BigNumber.from(transactionGasPrice).mul(estimatedGas)
|
|
62
|
+
: undefined, [estimatedGas, transactionGasPrice]);
|
|
63
|
+
const gasEstimate = useMemo(() => !transactionGasPrice && providerGasPrice && estimatedGas
|
|
64
|
+
? ethers.BigNumber.from(providerGasPrice).mul(estimatedGas)
|
|
65
|
+
: undefined, [transactionGasPrice, estimatedGas, providerGasPrice]);
|
|
58
66
|
const { data: transactionToAddress, isLoading: isTransactionToAddressLoading, } = usePromise(() => transaction.to);
|
|
59
67
|
const { data: transactionFromAddress, isLoading: isTransactionFromAddressLoading, } = usePromise(() => transaction.from);
|
|
60
68
|
const total = useMemo(() => {
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
const transactionGasFee = transactionGas || gasEstimate;
|
|
70
|
+
if (transactionGasFee !== undefined && transactionValue !== undefined) {
|
|
71
|
+
return transactionGasFee.add(transactionValue);
|
|
63
72
|
}
|
|
64
73
|
return transactionValue || gasEstimate;
|
|
65
|
-
}, [gasEstimate, transactionValue]);
|
|
74
|
+
}, [gasEstimate, transactionGas, transactionValue]);
|
|
66
75
|
const isLoading = useMemo(() => isEffectiveValueLoading ||
|
|
67
76
|
isGasPriceLoading ||
|
|
68
77
|
isTransactionToAddressLoading ||
|
|
@@ -75,12 +84,16 @@ const useTransactionData = ({ provider, transaction, }) => {
|
|
|
75
84
|
return {
|
|
76
85
|
gasEstimate,
|
|
77
86
|
isEffectiveValueLoading,
|
|
87
|
+
isGasLoading,
|
|
78
88
|
isGasPriceLoading,
|
|
79
89
|
isLoading,
|
|
80
90
|
isTransactionFromAddressLoading,
|
|
91
|
+
isTransactionGasPriceLoading,
|
|
81
92
|
isTransactionToAddressLoading,
|
|
82
93
|
total,
|
|
83
94
|
transactionFromAddress,
|
|
95
|
+
transactionGas,
|
|
96
|
+
transactionGasPrice,
|
|
84
97
|
transactionToAddress,
|
|
85
98
|
transactionValue,
|
|
86
99
|
};
|