0xtrails 0.2.2 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aave.d.ts +8 -0
- package/dist/aave.d.ts.map +1 -1
- package/dist/{ccip-ConT1gDe.js → ccip-CXlshvBY.js} +1 -1
- package/dist/chains.d.ts +5 -1
- package/dist/chains.d.ts.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.d.ts.map +1 -1
- package/dist/constants.d.ts +5 -4
- package/dist/constants.d.ts.map +1 -1
- package/dist/error.d.ts +1 -0
- package/dist/error.d.ts.map +1 -1
- package/dist/estimate.d.ts +52 -0
- package/dist/estimate.d.ts.map +1 -1
- package/dist/{index-CMh8uEbV.js → index-_QuyGrjU.js} +86304 -83380
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/intentEntrypoint.d.ts +0 -8
- package/dist/intentEntrypoint.d.ts.map +1 -1
- package/dist/intents.d.ts +40 -0
- package/dist/intents.d.ts.map +1 -1
- package/dist/metaTxnMonitor.d.ts +5 -4
- package/dist/metaTxnMonitor.d.ts.map +1 -1
- package/dist/metaTxns.d.ts +3 -3
- package/dist/metaTxns.d.ts.map +1 -1
- package/dist/morpho.d.ts +8 -0
- package/dist/morpho.d.ts.map +1 -1
- package/dist/prepareSend.d.ts +16 -6
- package/dist/prepareSend.d.ts.map +1 -1
- package/dist/queryParams.d.ts.map +1 -1
- package/dist/relayer.d.ts +10 -7
- package/dist/relayer.d.ts.map +1 -1
- package/dist/sequenceWallet.d.ts +3 -2
- package/dist/sequenceWallet.d.ts.map +1 -1
- package/dist/tokenBalances.d.ts +7 -0
- package/dist/tokenBalances.d.ts.map +1 -1
- package/dist/tokens.d.ts +2 -1
- package/dist/tokens.d.ts.map +1 -1
- package/dist/trails.d.ts +2 -2
- package/dist/trails.d.ts.map +1 -1
- package/dist/wallets.d.ts.map +1 -1
- package/dist/widget/components/AccountActionsDropdown.d.ts.map +1 -1
- package/dist/widget/components/AccountSettings.d.ts.map +1 -1
- package/dist/widget/components/ClassicSwap.d.ts +2 -0
- 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 +4 -0
- package/dist/widget/components/ConnectedWallets.d.ts.map +1 -1
- package/dist/widget/components/Earn.d.ts.map +1 -1
- package/dist/widget/components/EarnPools.d.ts.map +1 -1
- package/dist/widget/components/Fund.d.ts +1 -0
- package/dist/widget/components/Fund.d.ts.map +1 -1
- package/dist/widget/components/FundMethods.d.ts.map +1 -1
- package/dist/widget/components/{FundSendForm.d.ts → FundSwap.d.ts} +11 -5
- package/dist/widget/components/FundSwap.d.ts.map +1 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts +4 -0
- package/dist/widget/components/FundingMethodSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Modal.d.ts.map +1 -1
- package/dist/widget/components/Pay.d.ts +1 -0
- package/dist/widget/components/Pay.d.ts.map +1 -1
- package/dist/widget/components/PercentageMaxButtons.d.ts +12 -0
- package/dist/widget/components/PercentageMaxButtons.d.ts.map +1 -0
- package/dist/widget/components/{PaySendForm.d.ts → PoolDeposit.d.ts} +11 -34
- package/dist/widget/components/PoolDeposit.d.ts.map +1 -0
- package/dist/widget/components/{SimpleSwap.d.ts → PoolWithdraw.d.ts} +16 -8
- package/dist/widget/components/PoolWithdraw.d.ts.map +1 -0
- package/dist/widget/components/QuoteDetails.d.ts.map +1 -1
- package/dist/widget/components/Receive.d.ts.map +1 -1
- package/dist/widget/components/RecipientSelectorButton.d.ts +4 -0
- package/dist/widget/components/RecipientSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/Recipients.d.ts.map +1 -1
- package/dist/widget/components/RefundWarning.d.ts +1 -0
- package/dist/widget/components/RefundWarning.d.ts.map +1 -1
- package/dist/widget/components/RequiredPropsError.d.ts +8 -0
- package/dist/widget/components/RequiredPropsError.d.ts.map +1 -0
- package/dist/widget/components/ScreenHeader.d.ts.map +1 -1
- package/dist/widget/components/SlippageToleranceSettings.d.ts.map +1 -1
- package/dist/widget/components/Swap.d.ts +1 -0
- package/dist/widget/components/Swap.d.ts.map +1 -1
- package/dist/widget/components/SwapSettings.d.ts.map +1 -1
- package/dist/widget/components/TokenImage.d.ts +1 -0
- package/dist/widget/components/TokenImage.d.ts.map +1 -1
- package/dist/widget/components/TokenList.d.ts.map +1 -1
- package/dist/widget/components/TokenSelector.d.ts.map +1 -1
- package/dist/widget/components/TokenSelectorButton.d.ts +16 -0
- package/dist/widget/components/TokenSelectorButton.d.ts.map +1 -0
- package/dist/widget/components/UserPreferences.d.ts.map +1 -1
- package/dist/widget/components/WaasFeeOptions.d.ts +8 -0
- package/dist/widget/components/WaasFeeOptions.d.ts.map +1 -0
- package/dist/widget/components/WalletConfirmation.d.ts.map +1 -1
- package/dist/widget/components/WalletList.d.ts.map +1 -1
- package/dist/widget/css/compiled.css +2 -0
- package/dist/widget/css/index.css +554 -0
- package/dist/widget/hooks/useBack.d.ts +6 -0
- package/dist/widget/hooks/useBack.d.ts.map +1 -1
- package/dist/widget/hooks/useCheckout.d.ts +1 -1
- package/dist/widget/hooks/useCheckout.d.ts.map +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts +1 -1
- package/dist/widget/hooks/useCurrentScreen.d.ts.map +1 -1
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts +3 -3
- package/dist/widget/hooks/useDefaultTokenSelection.d.ts.map +1 -1
- package/dist/widget/hooks/useInitialRedirect.d.ts +7 -0
- package/dist/widget/hooks/useInitialRedirect.d.ts.map +1 -0
- package/dist/widget/hooks/usePayMessage.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFeeToken.d.ts.map +1 -1
- package/dist/widget/hooks/useSelectedFundMethod.d.ts +12 -0
- package/dist/widget/hooks/useSelectedFundMethod.d.ts.map +1 -0
- package/dist/widget/hooks/useSelectedRecipient.d.ts.map +1 -1
- package/dist/widget/hooks/useSendForm.d.ts.map +1 -1
- package/dist/widget/index.js +1 -1
- package/dist/widget/widget.d.ts +4 -4
- package/dist/widget/widget.d.ts.map +1 -1
- package/package.json +30 -23
- package/src/aave.ts +32 -0
- package/src/chains.ts +23 -3
- package/src/config.ts +12 -4
- package/src/constants.ts +11 -16
- package/src/error.ts +20 -2
- package/src/estimate.ts +416 -5
- package/src/index.ts +8 -3
- package/src/intentEntrypoint.ts +0 -15
- package/src/intents.ts +161 -11
- package/src/metaTxnMonitor.ts +28 -22
- package/src/metaTxns.ts +3 -3
- package/src/morpho.ts +32 -0
- package/src/prepareSend.ts +710 -458
- package/src/queryParams.ts +2 -1
- package/src/relayer.ts +15 -16
- package/src/sequenceWallet.ts +7 -3
- package/src/tokenBalances.ts +47 -0
- package/src/tokens.ts +17 -1
- package/src/trails.ts +2 -2
- package/src/wallets.ts +8 -0
- package/src/widget/compiled.css +2 -2
- package/src/widget/components/AccountActionsDropdown.tsx +9 -15
- package/src/widget/components/AccountIntentTransactionHistory.tsx +1 -1
- package/src/widget/components/AccountSettings.tsx +10 -27
- package/src/widget/components/ChainFilterDropdown.tsx +1 -1
- package/src/widget/components/ChainList.tsx +1 -1
- package/src/widget/components/ClassicSwap.tsx +111 -155
- package/src/widget/components/ConnectWallet.tsx +10 -39
- package/src/widget/components/ConnectedWallets.tsx +113 -58
- package/src/widget/components/Earn.tsx +73 -589
- package/src/widget/components/EarnPools.tsx +2 -1
- package/src/widget/components/Fund.tsx +81 -109
- package/src/widget/components/FundMethods.tsx +82 -159
- package/src/widget/components/FundSwap.tsx +52 -0
- package/src/widget/components/FundingMethodSelectorButton.tsx +60 -0
- package/src/widget/components/Modal.tsx +6 -2
- package/src/widget/components/Pay.tsx +198 -200
- package/src/widget/components/PercentageMaxButtons.tsx +77 -0
- package/src/widget/components/PoolDeposit.tsx +593 -0
- package/src/widget/components/PoolWithdraw.tsx +903 -0
- package/src/widget/components/QuoteDetails.tsx +22 -8
- package/src/widget/components/Receive.tsx +1 -3
- package/src/widget/components/RecipientSelectorButton.tsx +42 -0
- package/src/widget/components/Recipients.tsx +64 -156
- package/src/widget/components/RefundWarning.tsx +5 -1
- package/src/widget/components/RequiredPropsError.tsx +33 -0
- package/src/widget/components/ScreenHeader.tsx +5 -1
- package/src/widget/components/SlippageToleranceSettings.tsx +2 -1
- package/src/widget/components/Swap.tsx +2 -43
- package/src/widget/components/SwapSettings.tsx +3 -15
- package/src/widget/components/TokenImage.tsx +21 -4
- package/src/widget/components/TokenList.tsx +0 -1
- package/src/widget/components/TokenSelector.tsx +2 -1
- package/src/widget/components/TokenSelectorButton.tsx +75 -0
- package/src/widget/components/UserPreferences.tsx +6 -24
- package/src/widget/components/WaasFeeOptions.tsx +331 -0
- package/src/widget/components/WalletConfirmation.tsx +55 -3
- package/src/widget/components/WalletList.tsx +7 -5
- package/src/widget/hooks/useBack.tsx +113 -9
- package/src/widget/hooks/useCheckout.ts +36 -20
- package/src/widget/hooks/useCurrentScreen.tsx +1 -0
- package/src/widget/hooks/useDefaultTokenSelection.tsx +104 -28
- package/src/widget/hooks/useInitialRedirect.tsx +70 -0
- package/src/widget/hooks/usePayMessage.tsx +86 -11
- package/src/widget/hooks/useSelectedFeeToken.tsx +10 -16
- package/src/widget/hooks/useSelectedFundMethod.tsx +41 -0
- package/src/widget/hooks/useSelectedRecipient.tsx +10 -0
- package/src/widget/hooks/useSendForm.ts +34 -12
- package/src/widget/hooks/useTokenList.ts +1 -1
- package/src/widget/index.css +27 -0
- package/src/widget/widget.tsx +245 -208
- package/dist/widget/components/FundSendForm.d.ts.map +0 -1
- package/dist/widget/components/PaySendForm.d.ts.map +0 -1
- package/dist/widget/components/SimpleSwap.d.ts.map +0 -1
- package/dist/widget/hooks/useSwapSettings.d.ts +0 -16
- package/dist/widget/hooks/useSwapSettings.d.ts.map +0 -1
- package/src/widget/components/FundSendForm.tsx +0 -903
- package/src/widget/components/PaySendForm.tsx +0 -869
- package/src/widget/components/SimpleSwap.tsx +0 -983
- package/src/widget/hooks/useSwapSettings.tsx +0 -100
- /package/dist/{style.css → 0xtrails.css} +0 -0
package/src/metaTxnMonitor.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
RelayerOperationConfirmedStatus,
|
|
3
|
+
RelayerOperationFailedStatus,
|
|
4
|
+
RelayerOperationPendingStatus,
|
|
5
|
+
RelayerOperationStatus,
|
|
6
|
+
RelayerOperationUnknownStatus,
|
|
7
|
+
} from "./relayer.js"
|
|
8
|
+
import type { Relayer } from "@0xsequence/relayer"
|
|
2
9
|
import { type Query, useQueries } from "@tanstack/react-query"
|
|
3
10
|
import { useMemo } from "react"
|
|
4
11
|
import type { Hex } from "viem"
|
|
@@ -13,22 +20,22 @@ export type MetaTxn = {
|
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
export type MetaTxnStatus = {
|
|
16
|
-
[key: string]:
|
|
23
|
+
[key: string]: RelayerOperationStatus
|
|
17
24
|
}
|
|
18
25
|
|
|
19
26
|
const POLL_INTERVAL = 3_000 // 3 seconds
|
|
20
27
|
|
|
21
28
|
export const getMetaTxStatus = async (
|
|
22
|
-
relayer: Relayer.
|
|
29
|
+
relayer: Relayer.RpcRelayer,
|
|
23
30
|
metaTxId: string,
|
|
24
31
|
chainId: number,
|
|
25
|
-
): Promise<
|
|
32
|
+
): Promise<RelayerOperationStatus> => {
|
|
26
33
|
return relayer.status(metaTxId as `0x${string}`, chainId)
|
|
27
34
|
}
|
|
28
35
|
|
|
29
36
|
export const useMetaTxnsMonitor = (
|
|
30
37
|
metaTxns: MetaTxn[] | undefined,
|
|
31
|
-
getRelayer: (chainId: number) => Relayer.
|
|
38
|
+
getRelayer: (chainId: number) => Relayer.RpcRelayer,
|
|
32
39
|
) => {
|
|
33
40
|
const results = useQueries({
|
|
34
41
|
queries: (metaTxns || []).map((metaTxn) => {
|
|
@@ -36,21 +43,21 @@ export const useMetaTxnsMonitor = (
|
|
|
36
43
|
|
|
37
44
|
return {
|
|
38
45
|
queryKey: ["metaTxnStatus", metaTxn.chainId, metaTxn.id],
|
|
39
|
-
queryFn: async (): Promise<
|
|
46
|
+
queryFn: async (): Promise<RelayerOperationStatus> => {
|
|
40
47
|
const relayer = getRelayer(parseInt(metaTxn.chainId, 10))
|
|
41
48
|
|
|
42
49
|
if (!opHashToPoll) {
|
|
43
50
|
return {
|
|
44
51
|
status: "failed",
|
|
45
52
|
reason: "Missing operation hash for monitoring.",
|
|
46
|
-
} as
|
|
53
|
+
} as RelayerOperationFailedStatus
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
if (!relayer) {
|
|
50
57
|
return {
|
|
51
58
|
status: "failed",
|
|
52
59
|
reason: `Relayer not available for chain ${metaTxn.chainId}.`,
|
|
53
|
-
} as
|
|
60
|
+
} as RelayerOperationFailedStatus
|
|
54
61
|
}
|
|
55
62
|
|
|
56
63
|
const opStatus = await relayer.status(
|
|
@@ -58,28 +65,28 @@ export const useMetaTxnsMonitor = (
|
|
|
58
65
|
Number(metaTxn.chainId),
|
|
59
66
|
)
|
|
60
67
|
|
|
61
|
-
let newStatusEntry:
|
|
68
|
+
let newStatusEntry: RelayerOperationStatus
|
|
62
69
|
|
|
63
70
|
if (opStatus.status === "confirmed") {
|
|
64
71
|
newStatusEntry = {
|
|
65
72
|
status: "confirmed",
|
|
66
73
|
transactionHash: opStatus.transactionHash,
|
|
67
74
|
data: opStatus.data,
|
|
68
|
-
} as
|
|
75
|
+
} as RelayerOperationConfirmedStatus
|
|
69
76
|
} else if (opStatus.status === "failed") {
|
|
70
77
|
newStatusEntry = {
|
|
71
78
|
status: "failed",
|
|
72
79
|
reason: opStatus.reason,
|
|
73
80
|
data: opStatus.data,
|
|
74
|
-
} as
|
|
81
|
+
} as RelayerOperationFailedStatus
|
|
75
82
|
} else if (opStatus.status === "pending") {
|
|
76
83
|
newStatusEntry = {
|
|
77
84
|
status: "pending",
|
|
78
|
-
} as
|
|
85
|
+
} as RelayerOperationPendingStatus
|
|
79
86
|
} else if (opStatus.status === "unknown") {
|
|
80
87
|
newStatusEntry = {
|
|
81
88
|
status: "unknown",
|
|
82
|
-
} as
|
|
89
|
+
} as RelayerOperationUnknownStatus
|
|
83
90
|
} else {
|
|
84
91
|
const originalStatus = (opStatus as any).status as string
|
|
85
92
|
logger.console.warn(
|
|
@@ -88,16 +95,16 @@ export const useMetaTxnsMonitor = (
|
|
|
88
95
|
)
|
|
89
96
|
newStatusEntry = {
|
|
90
97
|
status: "unknown",
|
|
91
|
-
} as
|
|
98
|
+
} as RelayerOperationUnknownStatus
|
|
92
99
|
}
|
|
93
100
|
return newStatusEntry
|
|
94
101
|
},
|
|
95
102
|
refetchIntervalInBackground: true,
|
|
96
103
|
refetchInterval: (
|
|
97
104
|
query: Query<
|
|
98
|
-
|
|
105
|
+
RelayerOperationStatus,
|
|
99
106
|
Error,
|
|
100
|
-
|
|
107
|
+
RelayerOperationStatus,
|
|
101
108
|
ReadonlyArray<unknown>
|
|
102
109
|
>,
|
|
103
110
|
) => {
|
|
@@ -135,27 +142,26 @@ export const useMetaTxnsMonitor = (
|
|
|
135
142
|
) {
|
|
136
143
|
newStatuses[operationKey] = {
|
|
137
144
|
status: "pending",
|
|
138
|
-
} as
|
|
145
|
+
} as RelayerOperationPendingStatus
|
|
139
146
|
} else if (queryResult.isError) {
|
|
140
147
|
newStatuses[operationKey] = {
|
|
141
148
|
status: "failed",
|
|
142
149
|
reason:
|
|
143
150
|
(queryResult.error as Error)?.message ||
|
|
144
151
|
"An unknown error occurred",
|
|
145
|
-
} as
|
|
152
|
+
} as RelayerOperationFailedStatus
|
|
146
153
|
} else if (queryResult.data) {
|
|
147
|
-
newStatuses[operationKey] =
|
|
148
|
-
queryResult.data as Relayer.OperationStatus
|
|
154
|
+
newStatuses[operationKey] = queryResult.data as RelayerOperationStatus
|
|
149
155
|
} else {
|
|
150
156
|
newStatuses[operationKey] = {
|
|
151
157
|
status: "unknown",
|
|
152
|
-
} as
|
|
158
|
+
} as RelayerOperationUnknownStatus
|
|
153
159
|
}
|
|
154
160
|
} else {
|
|
155
161
|
newStatuses[operationKey] = {
|
|
156
162
|
status: "failed",
|
|
157
163
|
reason: "Query result unexpectedly missing",
|
|
158
|
-
} as
|
|
164
|
+
} as RelayerOperationFailedStatus
|
|
159
165
|
}
|
|
160
166
|
})
|
|
161
167
|
return newStatuses
|
package/src/metaTxns.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import type { Relayer } from "@0xsequence/relayer"
|
|
1
2
|
import type { IntentPrecondition } from "@0xsequence/trails-api"
|
|
2
|
-
import type { Relayer } from "@0xsequence/wallet-core"
|
|
3
3
|
import type { Hex } from "viem"
|
|
4
4
|
import type { MetaTxn } from "./metaTxnMonitor.js"
|
|
5
5
|
import { logger } from "./logger.js"
|
|
6
6
|
|
|
7
7
|
export async function relayerSendMetaTx(
|
|
8
|
-
relayer: Relayer.
|
|
8
|
+
relayer: Relayer.RpcRelayer,
|
|
9
9
|
metaTx: MetaTxn,
|
|
10
10
|
preconditions: IntentPrecondition[],
|
|
11
11
|
feeQuote?: Relayer.FeeQuote,
|
|
@@ -23,7 +23,7 @@ export async function relayerSendMetaTx(
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export async function getMetaTxnReceipt(
|
|
26
|
-
relayer: Relayer.
|
|
26
|
+
relayer: Relayer.RpcRelayer,
|
|
27
27
|
metaTxId: string,
|
|
28
28
|
chainId: number,
|
|
29
29
|
): Promise<{ receipt: { status: "confirmed" | "failed" | "pending" } }> {
|
package/src/morpho.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useMemo, useState, useEffect } from "react"
|
|
2
2
|
import type { Address, PublicClient } from "viem"
|
|
3
|
+
import { encodeFunctionData } from "viem"
|
|
3
4
|
import { logger } from "./logger.js"
|
|
4
5
|
|
|
5
6
|
type AccrualPosition = any
|
|
@@ -425,4 +426,35 @@ export async function getAllVaults(
|
|
|
425
426
|
return transformedVaults
|
|
426
427
|
}
|
|
427
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Generate Morpho vault withdraw calldata
|
|
431
|
+
* @param asset - The address of the underlying asset to withdraw
|
|
432
|
+
* @param amount - The amount to withdraw in wei (or max uint256 for full balance)
|
|
433
|
+
* @param to - The address that will receive the underlying tokens
|
|
434
|
+
* @returns Encoded calldata for Morpho withdraw function
|
|
435
|
+
*/
|
|
436
|
+
export function generateMorphoWithdrawCalldata(
|
|
437
|
+
asset: string,
|
|
438
|
+
amount: bigint,
|
|
439
|
+
to: string,
|
|
440
|
+
): `0x${string}` {
|
|
441
|
+
return encodeFunctionData({
|
|
442
|
+
abi: [
|
|
443
|
+
{
|
|
444
|
+
name: "withdraw",
|
|
445
|
+
type: "function",
|
|
446
|
+
stateMutability: "nonpayable",
|
|
447
|
+
inputs: [
|
|
448
|
+
{ name: "asset", type: "address" },
|
|
449
|
+
{ name: "amount", type: "uint256" },
|
|
450
|
+
{ name: "to", type: "address" },
|
|
451
|
+
],
|
|
452
|
+
outputs: [{ type: "uint256" }],
|
|
453
|
+
},
|
|
454
|
+
],
|
|
455
|
+
functionName: "withdraw",
|
|
456
|
+
args: [asset as `0x${string}`, amount, to as `0x${string}`],
|
|
457
|
+
})
|
|
458
|
+
}
|
|
459
|
+
|
|
428
460
|
export default useMorphoVaults
|