0xtrails 0.8.0 → 0.8.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-uMWNlvmJ.js → ccip-ru_Yzdas.js} +5 -5
- package/dist/chains.d.ts.map +1 -1
- package/dist/{index-BiPwqVkZ.js → index-Si7cO9V7.js} +10080 -9842
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +116 -117
- package/dist/intents.d.ts.map +1 -1
- package/dist/mutations.d.ts.map +1 -1
- package/dist/{refund.d.ts → recover.d.ts} +27 -11
- package/dist/recover.d.ts.map +1 -0
- package/dist/widget/components/AccountIntentTransactionHistory.d.ts.map +1 -1
- package/dist/widget/index.js +3 -3
- package/package.json +2 -2
- package/src/chains.ts +25 -12
- package/src/index.ts +5 -5
- package/src/intents.ts +1 -5
- package/src/mutations.ts +0 -2
- package/src/{refund.ts → recover.ts} +564 -58
- package/src/widget/components/AccountIntentTransactionHistory.tsx +15 -54
- package/dist/refund.d.ts.map +0 -1
|
@@ -14,9 +14,8 @@ import { useConnections, useAccount, useWalletClient } from "wagmi"
|
|
|
14
14
|
import { ChevronDown } from "lucide-react"
|
|
15
15
|
import { getExplorerUrl } from "../../explorer.js"
|
|
16
16
|
import { ErrorDisplay } from "./ErrorDisplay.js"
|
|
17
|
-
import { attemptSwitchChain } from "../../chainSwitch.js"
|
|
18
17
|
import { logger } from "../../logger.js"
|
|
19
|
-
import {
|
|
18
|
+
import { useIntentRecover } from "../../recover.js"
|
|
20
19
|
|
|
21
20
|
interface AccountIntentTransactionHistoryProps {
|
|
22
21
|
accountAddress?: string
|
|
@@ -71,27 +70,18 @@ const TransactionItem: React.FC<{
|
|
|
71
70
|
// Track refund transaction hash per intent
|
|
72
71
|
const [refundTxHash, setRefundTxHash] = useState<`0x${string}` | null>(null)
|
|
73
72
|
|
|
74
|
-
//
|
|
75
|
-
|
|
76
|
-
transaction.executionStatus === "executed" ||
|
|
77
|
-
transaction.executionStatus === "completed" ||
|
|
78
|
-
transaction.executionStatus === "succeeded"
|
|
79
|
-
|
|
80
|
-
// Hook for refunding intents (recover) - call early to get hasIntentBalance
|
|
73
|
+
// Hook for recovering intents - call early to get hasIntentBalance
|
|
74
|
+
// Always check balances regardless of execution status, but skip if already refunded
|
|
81
75
|
const {
|
|
82
|
-
|
|
83
|
-
getRefundTx,
|
|
76
|
+
recover,
|
|
84
77
|
isLoadingIntent,
|
|
85
78
|
isLoadingBalances,
|
|
86
79
|
intentError,
|
|
87
80
|
balancesError,
|
|
88
81
|
hasIntentBalance,
|
|
89
82
|
refetchIntent,
|
|
90
|
-
} =
|
|
91
|
-
intentId:
|
|
92
|
-
!isCompleted && transaction.intentId && !refundTxHash
|
|
93
|
-
? transaction.intentId
|
|
94
|
-
: "",
|
|
83
|
+
} = useIntentRecover({
|
|
84
|
+
intentId: transaction.intentId && !refundTxHash ? transaction.intentId : "",
|
|
95
85
|
walletClient: walletClient || undefined,
|
|
96
86
|
})
|
|
97
87
|
|
|
@@ -102,24 +92,15 @@ const TransactionItem: React.FC<{
|
|
|
102
92
|
return () => {
|
|
103
93
|
onRefetch()
|
|
104
94
|
// Refetch intent data and balances to update recover button state
|
|
105
|
-
if (
|
|
95
|
+
if (transaction.intentId && !refundTxHash) {
|
|
106
96
|
refetchIntent()
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
|
-
}, [
|
|
110
|
-
onRefetch,
|
|
111
|
-
isCompleted,
|
|
112
|
-
transaction.intentId,
|
|
113
|
-
refundTxHash,
|
|
114
|
-
refetchIntent,
|
|
115
|
-
])
|
|
99
|
+
}, [onRefetch, transaction.intentId, refundTxHash, refetchIntent])
|
|
116
100
|
|
|
101
|
+
// Allow recovery for any intent with balances, regardless of execution status
|
|
117
102
|
const canRecover =
|
|
118
|
-
!
|
|
119
|
-
transaction.intentId &&
|
|
120
|
-
walletClient &&
|
|
121
|
-
!refundTxHash &&
|
|
122
|
-
hasIntentBalance
|
|
103
|
+
transaction.intentId && walletClient && !refundTxHash && hasIntentBalance
|
|
123
104
|
|
|
124
105
|
const [isRecovering, setIsRecovering] = useState(false)
|
|
125
106
|
const [recoverError, setRecoverError] = useState<string | null>(null)
|
|
@@ -136,36 +117,16 @@ const TransactionItem: React.FC<{
|
|
|
136
117
|
setIsRecovering(true)
|
|
137
118
|
setRecoverError(null)
|
|
138
119
|
|
|
139
|
-
//
|
|
140
|
-
const {
|
|
141
|
-
|
|
142
|
-
// Get the refund transaction
|
|
143
|
-
const refundTx = await getRefundTx({
|
|
144
|
-
signedHash: signature,
|
|
145
|
-
payload,
|
|
146
|
-
})
|
|
147
|
-
|
|
148
|
-
// Ensure we're on the correct chain before sending
|
|
149
|
-
// attemptSwitchChain already checks if we're on the correct chain
|
|
150
|
-
await attemptSwitchChain({
|
|
151
|
-
walletClient,
|
|
152
|
-
desiredChainId: refundTx.chainId,
|
|
153
|
-
})
|
|
154
|
-
|
|
155
|
-
// Send the refund transaction with explicit chain
|
|
156
|
-
const hash = await walletClient.sendTransaction({
|
|
157
|
-
to: refundTx.to,
|
|
158
|
-
data: refundTx.data,
|
|
159
|
-
chain: refundTx.chain,
|
|
160
|
-
})
|
|
120
|
+
// Use the recover method which handles everything automatically
|
|
121
|
+
const { txHash } = await recover()
|
|
161
122
|
|
|
162
123
|
logger.console.log(
|
|
163
|
-
"[AccountIntentTransactionHistory]
|
|
164
|
-
{ intentId: transaction.intentId,
|
|
124
|
+
"[AccountIntentTransactionHistory] Recover transaction sent",
|
|
125
|
+
{ intentId: transaction.intentId, txHash },
|
|
165
126
|
)
|
|
166
127
|
|
|
167
128
|
// Store the transaction hash to show explorer link
|
|
168
|
-
setRefundTxHash(
|
|
129
|
+
setRefundTxHash(txHash)
|
|
169
130
|
setRecoverError(null)
|
|
170
131
|
|
|
171
132
|
// Refetch history after recovery
|
package/dist/refund.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"refund.d.ts","sourceR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