0xtrails 0.13.0 → 0.13.2
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/dist/{ccip-Cg9-lJ6K.js → ccip-CT_An6eM.js} +39 -39
- package/dist/chains.d.ts +4 -3
- package/dist/chains.d.ts.map +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/customTokens.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/gasless.d.ts +1 -2
- package/dist/gasless.d.ts.map +1 -1
- package/dist/{index-DEojZg7b.js → index-RfqL5Foz.js} +56672 -43550
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +385 -333
- package/dist/intents.d.ts +8 -2
- package/dist/intents.d.ts.map +1 -1
- package/dist/keyMachineClient.d.ts +9 -0
- package/dist/keyMachineClient.d.ts.map +1 -0
- package/dist/keymachine/index.d.ts +14 -0
- package/dist/keymachine/index.d.ts.map +1 -0
- package/dist/keymachine/key-machine.gen.d.ts +461 -0
- package/dist/keymachine/key-machine.gen.d.ts.map +1 -0
- package/dist/onramp/MeshConnectFlow.d.ts +18 -0
- package/dist/onramp/MeshConnectFlow.d.ts.map +1 -0
- package/dist/onramp/MeshConnectIframe.d.ts +13 -0
- package/dist/onramp/MeshConnectIframe.d.ts.map +1 -0
- package/dist/onramp/SendFromExchangeButton.d.ts +16 -0
- package/dist/onramp/SendFromExchangeButton.d.ts.map +1 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts +31 -0
- package/dist/onramp/TrailsOnRampProvider.d.ts.map +1 -0
- package/dist/onramp/index.d.ts +13 -0
- package/dist/onramp/index.d.ts.map +1 -0
- package/dist/onramp/meshconnect.d.ts +30 -0
- package/dist/onramp/meshconnect.d.ts.map +1 -0
- package/dist/onramp/trailsOnramp.d.ts +24 -0
- package/dist/onramp/trailsOnramp.d.ts.map +1 -0
- package/dist/onramp-client/index.d.ts +3 -3
- package/dist/onramp-client/index.d.ts.map +1 -1
- package/dist/paymasterSend.d.ts.map +1 -1
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/query/balance.fetchers.d.ts +31 -2
- package/dist/query/balance.fetchers.d.ts.map +1 -1
- package/dist/query/balance.hooks.d.ts +21 -2
- package/dist/query/balance.hooks.d.ts.map +1 -1
- package/dist/query/balance.queries.d.ts +18 -1
- package/dist/query/balance.queries.d.ts.map +1 -1
- package/dist/query/chains.queries.d.ts.map +1 -1
- package/dist/query/meld.fetchers.d.ts +1 -1
- package/dist/query/meld.fetchers.d.ts.map +1 -1
- package/dist/query/meld.hooks.d.ts +3 -3
- package/dist/query/meld.hooks.d.ts.map +1 -1
- package/dist/query/meld.queries.d.ts +1 -1
- package/dist/query/meld.queries.d.ts.map +1 -1
- package/dist/query/price.fetchers.d.ts +15 -0
- package/dist/query/price.fetchers.d.ts.map +1 -0
- package/dist/query/price.hooks.d.ts +352 -0
- package/dist/query/price.hooks.d.ts.map +1 -0
- package/dist/query/price.queries.d.ts +34 -0
- package/dist/query/price.queries.d.ts.map +1 -0
- package/dist/query/tokenList.queries.d.ts +54 -0
- package/dist/query/tokenList.queries.d.ts.map +1 -0
- package/dist/recover.d.ts +6 -4
- package/dist/recover.d.ts.map +1 -1
- package/dist/tokens.d.ts +13 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts +2 -2
- package/dist/transactionIntent/deposits/depositOrchestrator.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts +2 -2
- package/dist/transactionIntent/deposits/gaslessDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts +1 -1
- package/dist/transactionIntent/deposits/standardDeposit.d.ts.map +1 -1
- package/dist/transactionIntent/handlers/intentHandler.d.ts.map +1 -1
- package/dist/transactionIntent/helpers/transactionStateHelpers.d.ts.map +1 -1
- package/dist/transactionIntent/quote/normalizeQuote.d.ts.map +1 -1
- package/dist/transactionIntent/types.d.ts +1 -1
- package/dist/transactionIntent/types.d.ts.map +1 -1
- package/dist/transactions.d.ts +4 -0
- package/dist/transactions.d.ts.map +1 -1
- package/dist/umd/trails.min.js +291 -202
- package/dist/utils/format.d.ts +7 -0
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/walletUtils.d.ts +2 -1
- package/dist/walletUtils.d.ts.map +1 -1
- package/dist/wallets.d.ts +13 -54
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts.map +1 -1
- package/dist/widget/components/ConnectWallet.d.ts.map +1 -1
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/DirectTransfer.d.ts +1 -1
- package/dist/widget/components/DirectTransfer.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/ExecutionStatusBadge.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/HighPriceImpactBlock.d.ts +7 -0
- package/dist/widget/components/HighPriceImpactBlock.d.ts.map +1 -0
- package/dist/widget/components/MeldHistory.d.ts.map +1 -1
- package/dist/widget/components/MeshExchangeSelection.d.ts +11 -0
- package/dist/widget/components/MeshExchangeSelection.d.ts.map +1 -0
- package/dist/widget/components/OnrampHistoryRow.d.ts +1 -1
- package/dist/widget/components/OnrampHistoryRow.d.ts.map +1 -1
- package/dist/widget/components/OnrampProviderConfirmation.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -1
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts +1 -1
- package/dist/widget/components/QRCodeWalletSelect.d.ts.map +1 -1
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receipt.d.ts.map +1 -1
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TransactionDetails.d.ts.map +1 -1
- package/dist/widget/components/TransactionHistoryItem.d.ts +2 -0
- package/dist/widget/components/TransactionHistoryItem.d.ts.map +1 -1
- package/dist/widget/components/TransferPendingVertical.d.ts +1 -0
- package/dist/widget/components/TransferPendingVertical.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -1
- package/dist/widget/components/WalletConnect.d.ts.map +1 -1
- package/dist/widget/components/WalletImage.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/components/Withdraw.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +1 -1
- package/dist/widget/hooks/useAddressWalletIcon.d.ts.map +1 -1
- package/dist/widget/hooks/useCombinedHistory.d.ts +6 -5
- package/dist/widget/hooks/useCombinedHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts +6 -1
- package/dist/widget/hooks/useCustomTokenSearch.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultDestinationToken.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultOriginToken.d.ts.map +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts +1 -1
- package/dist/widget/hooks/useFiatOnRampCurrencies.d.ts.map +1 -1
- package/dist/widget/hooks/useGetIntent.d.ts +3 -2
- package/dist/widget/hooks/useGetIntent.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts +1 -1
- package/dist/widget/hooks/useIntentReceiptBalances.d.ts.map +1 -1
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts +3 -2
- package/dist/widget/hooks/useIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionHistory.d.ts.map +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useMeldTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts +1 -1
- package/dist/widget/hooks/useOnRampQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts +1 -1
- package/dist/widget/hooks/useOnRampTransactionStatus.d.ts.map +1 -1
- package/dist/widget/hooks/useQuote.d.ts +2 -2
- package/dist/widget/hooks/useQuote.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +7 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts +0 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/hooks/useTokenList.d.ts +7 -1
- package/dist/widget/hooks/useTokenList.d.ts.map +1 -1
- package/dist/widget/hooks/useViewManager.d.ts +1 -1
- package/dist/widget/hooks/useViewManager.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/providers/TrailsProvider.d.ts +2 -0
- package/dist/widget/providers/TrailsProvider.d.ts.map +1 -1
- package/dist/widget/utils/createWagmiConfig.d.ts +2 -2
- package/dist/widget/utils/createWagmiConfig.d.ts.map +1 -1
- package/dist/widget/utils/fundMethodSwitchState.d.ts +1 -0
- package/dist/widget/utils/fundMethodSwitchState.d.ts.map +1 -1
- package/dist/widget/utils/historyFilters.d.ts +13 -0
- package/dist/widget/utils/historyFilters.d.ts.map +1 -0
- package/dist/widget/utils/meldProviderUtils.d.ts +1 -1
- package/dist/widget/utils/meldProviderUtils.d.ts.map +1 -1
- package/dist/widget/utils/meshSupportedTokens.d.ts +4 -0
- package/dist/widget/utils/meshSupportedTokens.d.ts.map +1 -0
- package/dist/widget/utils/onrampConfig.d.ts +11 -0
- package/dist/widget/utils/onrampConfig.d.ts.map +1 -0
- package/dist/widget/utils/statusLabel.d.ts +2 -0
- package/dist/widget/utils/statusLabel.d.ts.map +1 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts +18 -0
- package/dist/widget/utils/trailsOnrampConfig.d.ts.map +1 -0
- package/dist/widget/widget.d.ts +24 -8
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +9 -7
- package/src/chains.ts +26 -9
- package/src/constants.ts +2 -0
- package/src/customTokens.ts +22 -7
- package/src/error.ts +7 -0
- package/src/gasless.ts +5 -2
- package/src/index.ts +8 -5
- package/src/intents.ts +56 -60
- package/src/keyMachineClient.ts +29 -0
- package/src/keymachine/index.ts +175 -0
- package/src/keymachine/key-machine.gen.ts +993 -0
- package/src/onramp/MeshConnectFlow.tsx +86 -0
- package/src/onramp/MeshConnectIframe.tsx +661 -0
- package/src/onramp/SendFromExchangeButton.tsx +81 -0
- package/src/onramp/TrailsOnRampProvider.tsx +59 -0
- package/src/onramp/index.ts +31 -0
- package/src/onramp/meshconnect.ts +277 -0
- package/src/onramp/trailsOnramp.tsx +130 -0
- package/src/onramp-client/index.ts +4 -6
- package/src/paymasterSend.ts +0 -5
- package/src/prepareSend.ts +45 -44
- package/src/query/balance.fetchers.ts +172 -17
- package/src/query/balance.hooks.ts +69 -6
- package/src/query/balance.queries.ts +63 -0
- package/src/query/chains.queries.ts +1 -6
- package/src/query/meld.fetchers.ts +1 -1
- package/src/query/meld.hooks.ts +1 -1
- package/src/query/meld.queries.ts +1 -1
- package/src/query/price.fetchers.ts +53 -0
- package/src/query/price.hooks.ts +46 -0
- package/src/query/price.queries.ts +364 -0
- package/src/query/tokenList.queries.ts +118 -0
- package/src/recover.ts +89 -26
- package/src/tokens.ts +108 -26
- package/src/transactionIntent/deposits/depositOrchestrator.ts +11 -11
- package/src/transactionIntent/deposits/gaslessDeposit.ts +38 -39
- package/src/transactionIntent/deposits/standardDeposit.ts +5 -30
- package/src/transactionIntent/handlers/intentHandler.ts +29 -12
- package/src/transactionIntent/helpers/transactionStateHelpers.ts +5 -2
- package/src/transactionIntent/quote/normalizeQuote.ts +11 -5
- package/src/transactionIntent/types.ts +1 -1
- package/src/transactions.ts +5 -1
- package/src/utils/format.ts +85 -1
- package/src/walletUtils.ts +2 -1
- package/src/wallets.ts +184 -380
- package/src/widget/compiled.css +1 -1
- package/src/widget/components/AccountIntentTransactionHistory.tsx +134 -109
- package/src/widget/components/ClassicSwap.tsx +26 -24
- package/src/widget/components/ConnectWallet.tsx +4 -2
- package/src/widget/components/ConnectedWallets.tsx +2 -5
- package/src/widget/components/DirectTransfer.tsx +5 -2
- package/src/widget/components/EarnPools.tsx +1 -2
- package/src/widget/components/ExecutionStatusBadge.tsx +10 -4
- package/src/widget/components/Fund.tsx +169 -110
- package/src/widget/components/FundMethods.tsx +5 -9
- package/src/widget/components/HighPriceImpactBlock.tsx +44 -0
- package/src/widget/components/MeldHistory.tsx +4 -28
- package/src/widget/components/MeshExchangeSelection.tsx +218 -0
- package/src/widget/components/OnrampHistoryRow.tsx +3 -27
- package/src/widget/components/OnrampProviderConfirmation.tsx +0 -25
- package/src/widget/components/Pay.tsx +20 -36
- package/src/widget/components/PoolDeposit.tsx +14 -24
- package/src/widget/components/PoolWithdraw.tsx +1 -63
- package/src/widget/components/QRCodeWalletSelect.tsx +5 -2
- package/src/widget/components/QuoteDetails.tsx +113 -106
- package/src/widget/components/Receipt.tsx +0 -11
- package/src/widget/components/Recipients.tsx +2 -1
- package/src/widget/components/RefundWarning.tsx +5 -10
- package/src/widget/components/ThemeProvider.tsx +4 -4
- package/src/widget/components/TokenSelector.tsx +85 -16
- package/src/widget/components/TransactionDetails.tsx +46 -0
- package/src/widget/components/TransactionHistoryItem.tsx +14 -23
- package/src/widget/components/TransferPendingVertical.tsx +17 -11
- package/src/widget/components/WaasFeeOptions.tsx +4 -42
- package/src/widget/components/WalletConnect.tsx +2 -5
- package/src/widget/components/WalletImage.tsx +6 -18
- package/src/widget/components/WalletList.tsx +1 -1
- package/src/widget/components/Withdraw.tsx +22 -23
- package/src/widget/hooks/useAddressWalletIcon.ts +2 -1
- package/src/widget/hooks/useAmountUsd.ts +1 -1
- package/src/widget/hooks/useCombinedHistory.ts +37 -93
- package/src/widget/hooks/useCustomTokenSearch.tsx +63 -33
- package/src/widget/hooks/useDefaultDestinationToken.tsx +2 -5
- package/src/widget/hooks/useDefaultOriginToken.tsx +2 -5
- package/src/widget/hooks/useFiatOnRampCurrencies.ts +1 -1
- package/src/widget/hooks/useGetIntent.ts +5 -4
- package/src/widget/hooks/useIntentReceiptBalances.ts +3 -3
- package/src/widget/hooks/useIntentTransactionHistory.ts +24 -47
- package/src/widget/hooks/useMeldTransactionHistory.ts +4 -2
- package/src/widget/hooks/useMeldTransactionStatus.ts +13 -11
- package/src/widget/hooks/useOnRampQuote.ts +3 -3
- package/src/widget/hooks/useOnRampTransactionStatus.ts +8 -6
- package/src/widget/hooks/useQuote.ts +56 -48
- package/src/widget/hooks/useSelectedFundMethod.tsx +14 -1
- package/src/widget/hooks/useSendForm.ts +52 -31
- package/src/widget/hooks/useTokenList.ts +209 -140
- package/src/widget/hooks/useTrailsSendTransaction.ts +1 -1
- package/src/widget/hooks/useViewManager.tsx +1 -0
- package/src/widget/providers/TrailsProvider.tsx +5 -0
- package/src/widget/styles.ts +1 -1
- package/src/widget/utils/createWagmiConfig.ts +7 -2
- package/src/widget/utils/fundMethodSwitchState.ts +2 -0
- package/src/widget/utils/historyFilters.ts +157 -0
- package/src/widget/utils/meldProviderUtils.ts +8 -2
- package/src/widget/utils/meshSupportedTokens.ts +28 -0
- package/src/widget/utils/onrampConfig.ts +15 -0
- package/src/widget/utils/statusLabel.ts +3 -0
- package/src/widget/utils/trailsOnrampConfig.ts +39 -0
- package/src/widget/widget.tsx +235 -185
- package/dist/onramp-client/trails-onramp.gen.d.ts +0 -570
- package/dist/onramp-client/trails-onramp.gen.d.ts.map +0 -1
- package/dist/prices.d.ts +0 -34
- package/dist/prices.d.ts.map +0 -1
- package/dist/useGasEstimation.d.ts +0 -34
- package/dist/useGasEstimation.d.ts.map +0 -1
- package/dist/widget/hooks/useCustomTokenFetch.d.ts +0 -19
- package/dist/widget/hooks/useCustomTokenFetch.d.ts.map +0 -1
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts +0 -18
- package/dist/widget/hooks/useTokenWithFreshBalance.d.ts.map +0 -1
- package/src/onramp-client/trails-onramp.gen.ts +0 -1320
- package/src/prices.ts +0 -528
- package/src/useGasEstimation.ts +0 -147
- package/src/widget/assets/Binance_Icon_Logo.svg +0 -14
- package/src/widget/assets/Bitfinex_Icon_Logo.svg +0 -5
- package/src/widget/assets/Coinbase_Icon_Logo.svg +0 -1
- package/src/widget/assets/WalletConnect-logo-blue-bg.svg +0 -11
- package/src/widget/assets/sequence-logo.svg +0 -15
- package/src/widget/hooks/useCustomTokenFetch.tsx +0 -74
- package/src/widget/hooks/useTokenWithFreshBalance.ts +0 -246
|
@@ -11,11 +11,6 @@ import type { CheckoutOnHandlers } from "../../widget/hooks/useCheckout.js"
|
|
|
11
11
|
import { logger } from "../../logger.js"
|
|
12
12
|
import { sendOriginTransaction } from "../../intents.js"
|
|
13
13
|
import { getIsCustomCalldata } from "../../contractUtils.js"
|
|
14
|
-
import {
|
|
15
|
-
fetchCachedGasLimit,
|
|
16
|
-
createGasEstimationParams,
|
|
17
|
-
} from "../../useGasEstimation.js"
|
|
18
|
-
import { queryClient as defaultQueryClient } from "../../query/client.js"
|
|
19
14
|
import type { QueryClient } from "@tanstack/react-query"
|
|
20
15
|
import { attemptSwitchChain } from "../../chainSwitch.js"
|
|
21
16
|
import { requestWithTimeout } from "../../utils.js"
|
|
@@ -44,7 +39,6 @@ import { ensureErc20Approval } from "../utils/erc20Approval.js"
|
|
|
44
39
|
* (executePassthrough in intentHandler.ts) is used instead.
|
|
45
40
|
*/
|
|
46
41
|
export async function attemptStandardDeposit({
|
|
47
|
-
queryClient: paramQueryClient,
|
|
48
42
|
originTokenAddress,
|
|
49
43
|
depositAmount,
|
|
50
44
|
onOriginSend,
|
|
@@ -173,25 +167,6 @@ export async function attemptStandardDeposit({
|
|
|
173
167
|
})
|
|
174
168
|
}
|
|
175
169
|
|
|
176
|
-
const effectiveQueryClient = paramQueryClient ?? defaultQueryClient
|
|
177
|
-
|
|
178
|
-
const gasLimit = await fetchCachedGasLimit(
|
|
179
|
-
effectiveQueryClient,
|
|
180
|
-
publicClient,
|
|
181
|
-
createGasEstimationParams(
|
|
182
|
-
account.address,
|
|
183
|
-
originCallParamsBase.to,
|
|
184
|
-
originCallParamsBase.data,
|
|
185
|
-
BigInt(originCallParamsBase.value),
|
|
186
|
-
),
|
|
187
|
-
"standard-deposit",
|
|
188
|
-
)
|
|
189
|
-
|
|
190
|
-
const originCallParams = {
|
|
191
|
-
...originCallParamsBase,
|
|
192
|
-
gasLimit,
|
|
193
|
-
}
|
|
194
|
-
|
|
195
170
|
await attemptSwitchChain({
|
|
196
171
|
walletClient,
|
|
197
172
|
desiredChainId: originChainId,
|
|
@@ -248,10 +223,10 @@ export async function attemptStandardDeposit({
|
|
|
248
223
|
|
|
249
224
|
// Add the origin call
|
|
250
225
|
calls.push({
|
|
251
|
-
to:
|
|
252
|
-
data:
|
|
253
|
-
value:
|
|
254
|
-
? `0x${BigInt(
|
|
226
|
+
to: originCallParamsBase.to as `0x${string}`,
|
|
227
|
+
data: originCallParamsBase.data as `0x${string}`,
|
|
228
|
+
value: originCallParamsBase.value
|
|
229
|
+
? `0x${BigInt(originCallParamsBase.value).toString(16)}`
|
|
255
230
|
: "0x0",
|
|
256
231
|
})
|
|
257
232
|
|
|
@@ -403,7 +378,7 @@ export async function attemptStandardDeposit({
|
|
|
403
378
|
txHash = await sendOriginTransaction(
|
|
404
379
|
account,
|
|
405
380
|
walletClient,
|
|
406
|
-
|
|
381
|
+
originCallParamsBase as any,
|
|
407
382
|
{
|
|
408
383
|
depositTokenAmountUsd: depositAmountUsd?.toString(),
|
|
409
384
|
},
|
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
import { updatePersistentToast } from "../../toast.js"
|
|
49
49
|
import { formatRawAmount, rawAmountToNumber } from "../../utils/format.js"
|
|
50
50
|
import { invalidateTokenBalancesCache } from "../../query/balance.queries.js"
|
|
51
|
-
import { calcAmountUsdPrice } from "../../
|
|
51
|
+
import { calcAmountUsdPrice } from "../../utils/format.js"
|
|
52
52
|
import { checkAccountBalance } from "../utils/balanceChecker.js"
|
|
53
53
|
import { queryClient as defaultQueryClient } from "../../query/client.js"
|
|
54
54
|
import {
|
|
@@ -78,7 +78,10 @@ import {
|
|
|
78
78
|
updateTransactionStateWithDecodedEvents,
|
|
79
79
|
} from "../helpers/transactionStateHelpers.js"
|
|
80
80
|
import { isSameChain, isSameToken } from "../validators.js"
|
|
81
|
-
import {
|
|
81
|
+
import {
|
|
82
|
+
isSyntheticTransactionHash,
|
|
83
|
+
isDisplayableTransactionHash,
|
|
84
|
+
} from "../../transactions.js"
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
87
|
* Parameters for the unified intent handler.
|
|
@@ -588,20 +591,25 @@ async function executeIntent(
|
|
|
588
591
|
// Set up transaction state tracking
|
|
589
592
|
publishTransactionStates(localTransactionStates)
|
|
590
593
|
|
|
591
|
-
|
|
594
|
+
const rawIntentProtocol = (intent as { intentProtocol?: string })
|
|
595
|
+
.intentProtocol
|
|
596
|
+
|
|
597
|
+
if (!rawIntentProtocol) {
|
|
592
598
|
logger.console.log(
|
|
593
599
|
"[trails-sdk] [intent-protocol] Intent protocol version not found in response, defaulting to v1",
|
|
594
600
|
)
|
|
595
601
|
}
|
|
596
|
-
const
|
|
597
|
-
|
|
602
|
+
const intentProtocol =
|
|
603
|
+
rawIntentProtocol === "v1.5"
|
|
604
|
+
? IntentProtocolVersion.v1_5
|
|
605
|
+
: IntentProtocolVersion.v1
|
|
598
606
|
|
|
599
607
|
logger.console.log(
|
|
600
608
|
"[trails-sdk] [intent-protocol] === Intent Protocol Version ===",
|
|
601
609
|
{
|
|
602
|
-
version:
|
|
603
|
-
isV1:
|
|
604
|
-
isV1_5:
|
|
610
|
+
version: intentProtocol,
|
|
611
|
+
isV1: intentProtocol === IntentProtocolVersion.v1,
|
|
612
|
+
isV1_5: intentProtocol === IntentProtocolVersion.v1_5,
|
|
605
613
|
intentId: intent.intentId,
|
|
606
614
|
fundMethod,
|
|
607
615
|
},
|
|
@@ -718,7 +726,7 @@ async function executeIntent(
|
|
|
718
726
|
isSameChainSameToken,
|
|
719
727
|
destinationCalldata,
|
|
720
728
|
depositTransaction: intent.depositTransaction,
|
|
721
|
-
|
|
729
|
+
intentProtocol,
|
|
722
730
|
})
|
|
723
731
|
|
|
724
732
|
// Update state and call executeIntent
|
|
@@ -788,11 +796,17 @@ async function executeIntent(
|
|
|
788
796
|
)
|
|
789
797
|
|
|
790
798
|
if (receipt.depositTransaction?.status === "SUCCEEDED") {
|
|
799
|
+
const existingHash = localTransactionStates[0].transactionHash
|
|
800
|
+
const existingExplorerUrl =
|
|
801
|
+
localTransactionStates[0].explorerUrl
|
|
802
|
+
const hasClientSideHash =
|
|
803
|
+
isDisplayableTransactionHash(existingHash)
|
|
804
|
+
|
|
791
805
|
localTransactionStates[0] = {
|
|
792
806
|
...localTransactionStates[0],
|
|
793
807
|
state: "confirmed",
|
|
794
|
-
transactionHash: "",
|
|
795
|
-
explorerUrl: "",
|
|
808
|
+
transactionHash: hasClientSideHash ? existingHash : "",
|
|
809
|
+
explorerUrl: hasClientSideHash ? existingExplorerUrl : "",
|
|
796
810
|
txnMinedAt:
|
|
797
811
|
receipt.depositTransaction?.txnMinedAt || undefined,
|
|
798
812
|
}
|
|
@@ -1406,7 +1420,10 @@ export async function handleIntent(
|
|
|
1406
1420
|
tokenAddress: originTokenAddress,
|
|
1407
1421
|
depositAmount: depositAmount,
|
|
1408
1422
|
publicClient: effectivePublicClient,
|
|
1409
|
-
knownBalance:
|
|
1423
|
+
knownBalance:
|
|
1424
|
+
originTokenBalance && originTokenBalance !== "0"
|
|
1425
|
+
? originTokenBalance
|
|
1426
|
+
: undefined,
|
|
1410
1427
|
decimals: originTokenDecimals,
|
|
1411
1428
|
})
|
|
1412
1429
|
: Promise.resolve({ hasEnoughBalance: true }),
|
|
@@ -233,13 +233,16 @@ export function applyIntentReceiptToTransactionStates(params: {
|
|
|
233
233
|
return
|
|
234
234
|
}
|
|
235
235
|
|
|
236
|
-
const
|
|
236
|
+
const hasNewDisplayableHash = isDisplayableTransactionHash(txnHash)
|
|
237
|
+
const displayableHash = hasNewDisplayableHash
|
|
238
|
+
? txnHash
|
|
239
|
+
: targetState.transactionHash || ""
|
|
237
240
|
const nextExplorerUrl = displayableHash
|
|
238
241
|
? getExplorerUrl({
|
|
239
242
|
txHash: displayableHash,
|
|
240
243
|
chainId: targetState.chainId,
|
|
241
244
|
})
|
|
242
|
-
: ""
|
|
245
|
+
: targetState.explorerUrl || ""
|
|
243
246
|
|
|
244
247
|
const stateChanged =
|
|
245
248
|
targetState.state !== mappedState ||
|
|
@@ -405,18 +405,24 @@ export async function getNormalizedQuoteObject({
|
|
|
405
405
|
totalProviderFeesUsdDisplay: "$0.00",
|
|
406
406
|
}
|
|
407
407
|
|
|
408
|
-
|
|
408
|
+
const rawIntentProtocol = (
|
|
409
|
+
intent as { intentProtocol?: string } | null | undefined
|
|
410
|
+
)?.intentProtocol
|
|
411
|
+
|
|
412
|
+
if (!rawIntentProtocol) {
|
|
409
413
|
logger.console.log(
|
|
410
414
|
"[trails-sdk] [intent-protocol] Intent protocol version not in API response, defaulting to v1",
|
|
411
415
|
)
|
|
412
416
|
}
|
|
413
|
-
const
|
|
414
|
-
|
|
417
|
+
const intentProtocol =
|
|
418
|
+
rawIntentProtocol === "v1.5"
|
|
419
|
+
? IntentProtocolVersion.v1_5
|
|
420
|
+
: IntentProtocolVersion.v1
|
|
415
421
|
|
|
416
422
|
logger.console.log(
|
|
417
423
|
"[trails-sdk] [intent-protocol] Quote normalized with version",
|
|
418
424
|
{
|
|
419
|
-
|
|
425
|
+
intentProtocol,
|
|
420
426
|
intentId: intent?.intentId,
|
|
421
427
|
},
|
|
422
428
|
)
|
|
@@ -430,7 +436,7 @@ export async function getNormalizedQuoteObject({
|
|
|
430
436
|
})
|
|
431
437
|
|
|
432
438
|
return {
|
|
433
|
-
|
|
439
|
+
intentProtocol,
|
|
434
440
|
originDepositAddress: originDepositAddress || "",
|
|
435
441
|
destinationDepositAddress: destinationDepositAddress || "",
|
|
436
442
|
destinationAddress: destinationAddress || "",
|
|
@@ -130,7 +130,7 @@ export type PrepareSendFees = {
|
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
export type PrepareSendQuote = {
|
|
133
|
-
|
|
133
|
+
intentProtocol: IntentProtocolVersion
|
|
134
134
|
originDepositAddress: string
|
|
135
135
|
destinationDepositAddress: string
|
|
136
136
|
destinationAddress: string
|
package/src/transactions.ts
CHANGED
|
@@ -289,7 +289,8 @@ export type IntentTransaction = {
|
|
|
289
289
|
intentId?: string
|
|
290
290
|
metaTxnId?: string
|
|
291
291
|
txnHash?: string
|
|
292
|
-
|
|
292
|
+
intentStatus?: string // Top-level intent status returned by Trails API history
|
|
293
|
+
executionStatus?: string // Derived transaction-level status used for detailed progress states
|
|
293
294
|
originChainId?: number
|
|
294
295
|
destinationChainId?: number
|
|
295
296
|
originTokenAddress?: string
|
|
@@ -306,6 +307,9 @@ export type IntentTransaction = {
|
|
|
306
307
|
depositTransactionStatus?: string // Deposit transaction status from API
|
|
307
308
|
originTransactionStatus?: string // Origin transaction status from API
|
|
308
309
|
destinationTransactionStatus?: string // Destination transaction status from API
|
|
310
|
+
refundTransactionHash?: string // Refund transaction hash from API
|
|
311
|
+
refundTransactionStatus?: string // Refund transaction status from API
|
|
312
|
+
refundTransactionChainId?: number // Refund transaction chain ID from API
|
|
309
313
|
// Enriched token information
|
|
310
314
|
originToken?: {
|
|
311
315
|
symbol: string
|
package/src/utils/format.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { NativeTokenBalance, TokenBalance } from "@0xsequence/indexer"
|
|
2
2
|
import { formatUnits, zeroAddress } from "viem"
|
|
3
3
|
import { logger } from "../logger.js"
|
|
4
|
+
import { parseLocaleNumber } from "../localeUtils.js"
|
|
5
|
+
import { isNonNegativeNumber, isValidNumber } from "./validation.js"
|
|
4
6
|
import { forexRateStore } from "../widget/utils/forexRateStore.js"
|
|
5
7
|
|
|
6
8
|
// ============================================================================
|
|
@@ -18,6 +20,7 @@ export type Price = {
|
|
|
18
20
|
|
|
19
21
|
/** Cap used across all USD formatters to prevent display issues */
|
|
20
22
|
const MAX_DISPLAY_VALUE = 100_000_000_000_000
|
|
23
|
+
const MAX_SUPPORTED_TOKEN_DECIMALS = 255
|
|
21
24
|
|
|
22
25
|
// navigator.language provides the browser's UI language (e.g., 'es-ES', 'en-US')
|
|
23
26
|
// Currently hardcoded to en-US until entire app is updated with locale display values
|
|
@@ -80,7 +83,11 @@ function parseRawBalance(
|
|
|
80
83
|
return null
|
|
81
84
|
}
|
|
82
85
|
|
|
83
|
-
if (
|
|
86
|
+
if (
|
|
87
|
+
!Number.isInteger(decimals) ||
|
|
88
|
+
decimals < 0 ||
|
|
89
|
+
decimals > MAX_SUPPORTED_TOKEN_DECIMALS
|
|
90
|
+
) {
|
|
84
91
|
throw new Error("Invalid decimals")
|
|
85
92
|
}
|
|
86
93
|
|
|
@@ -539,3 +546,80 @@ export function formatPriceFields(price: number | string | null | undefined): {
|
|
|
539
546
|
priceUsdDisplay: usdFields.balanceUsdDisplay,
|
|
540
547
|
}
|
|
541
548
|
}
|
|
549
|
+
|
|
550
|
+
export function normalizeNumber(
|
|
551
|
+
number: number | string | null | undefined,
|
|
552
|
+
): number {
|
|
553
|
+
if (number === null || number === undefined) {
|
|
554
|
+
return 0
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
// If already a number, return it directly
|
|
558
|
+
if (typeof number === "number") {
|
|
559
|
+
// Validate the number
|
|
560
|
+
if (!isValidNumber(number)) {
|
|
561
|
+
logger.console.error("[trails-sdk] Invalid number value:", number)
|
|
562
|
+
return 0
|
|
563
|
+
}
|
|
564
|
+
return number
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// Only parse strings that might be locale-formatted
|
|
568
|
+
// This should ideally only be used for user input, not internal calculations
|
|
569
|
+
const normalized = parseLocaleNumber(number)
|
|
570
|
+
|
|
571
|
+
// Return 0 for invalid numbers
|
|
572
|
+
if (!isValidNumber(normalized)) {
|
|
573
|
+
logger.console.error("[trails-sdk] Error normalizing number string:", {
|
|
574
|
+
number,
|
|
575
|
+
normalized,
|
|
576
|
+
})
|
|
577
|
+
return 0
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
return normalized
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
export function calcAmountUsdPrice({
|
|
584
|
+
amount,
|
|
585
|
+
usdPrice,
|
|
586
|
+
}: {
|
|
587
|
+
amount: number | string
|
|
588
|
+
usdPrice: string | number | null | undefined
|
|
589
|
+
}) {
|
|
590
|
+
const sanitizedAmount = normalizeNumber(amount)
|
|
591
|
+
const sanitizedPrice = normalizeNumber(usdPrice)
|
|
592
|
+
|
|
593
|
+
// Validate inputs
|
|
594
|
+
if (!isNonNegativeNumber(sanitizedAmount)) {
|
|
595
|
+
return 0
|
|
596
|
+
}
|
|
597
|
+
if (!isNonNegativeNumber(sanitizedPrice)) {
|
|
598
|
+
return 0
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
const result = sanitizedAmount * sanitizedPrice
|
|
602
|
+
|
|
603
|
+
// Validate result
|
|
604
|
+
if (!isValidNumber(result)) {
|
|
605
|
+
logger.console.error("[trails-sdk] Error calculating amount USD:", {
|
|
606
|
+
sanitizedAmount,
|
|
607
|
+
sanitizedPrice,
|
|
608
|
+
result,
|
|
609
|
+
amount,
|
|
610
|
+
usdPrice,
|
|
611
|
+
})
|
|
612
|
+
return 0
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return result
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
export function formatTvl(tvl: number): string {
|
|
619
|
+
if (tvl >= 1e9) return `$${(tvl / 1e9).toFixed(1)}B`
|
|
620
|
+
if (tvl >= 1e6) return `$${(tvl / 1e6).toFixed(1)}M`
|
|
621
|
+
if (tvl >= 1e3) return `$${(tvl / 1e3).toFixed(1)}K`
|
|
622
|
+
return `$${tvl.toFixed(0)}`
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
export { isValidInteger, isValidNumeric } from "./validation.js"
|
package/src/walletUtils.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Connector } from "wagmi"
|
|
2
|
+
import type { WalletConnector } from "./wallets.js"
|
|
2
3
|
import {
|
|
3
4
|
BaseError,
|
|
4
5
|
formatTransactionRequest,
|
|
@@ -202,7 +203,7 @@ export function isSequenceWalletById(walletId: string | undefined): boolean {
|
|
|
202
203
|
}
|
|
203
204
|
|
|
204
205
|
export function isWalletConnectConnector(
|
|
205
|
-
connector: Connector | undefined,
|
|
206
|
+
connector: Connector | Pick<WalletConnector, "id" | "name"> | undefined,
|
|
206
207
|
): boolean {
|
|
207
208
|
if (!connector) return false
|
|
208
209
|
const connectorName = connector.name?.toLowerCase() || ""
|