@lifi/widget 3.13.2 → 3.14.0-beta.0
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/esm/AppDrawer.style.d.ts +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js +1 -0
- package/dist/esm/components/ActiveTransactions/ActiveTransactionItem.js.map +1 -1
- package/dist/esm/components/ActiveTransactions/ActiveTransactions.style.d.ts +1 -1
- package/dist/esm/components/AmountInput/AmountInputAdornment.style.d.ts +1 -1
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js +2 -2
- package/dist/esm/components/BaseTransactionButton/BaseTransactionButton.js.map +1 -1
- package/dist/esm/components/ButtonTertiary.d.ts +1 -1
- package/dist/esm/components/ButtonTertiary.js +4 -5
- package/dist/esm/components/ButtonTertiary.js.map +1 -1
- package/dist/esm/components/Card/CardHeader.d.ts +1 -1
- package/dist/esm/components/Card/CardIconButton.d.ts +1 -1
- package/dist/esm/components/Card/CardLabel.js +0 -1
- package/dist/esm/components/Card/CardLabel.js.map +1 -1
- package/dist/esm/components/Header/Header.style.d.ts +1 -1
- package/dist/esm/components/Header/SettingsButton.style.d.ts +1 -1
- package/dist/esm/components/RouteCard/RouteCard.js +13 -4
- package/dist/esm/components/RouteCard/RouteCard.js.map +1 -1
- package/dist/esm/components/RouteCard/getMatchingLabels.d.ts +3 -0
- package/dist/esm/components/RouteCard/getMatchingLabels.js +34 -0
- package/dist/esm/components/RouteCard/getMatchingLabels.js.map +1 -0
- package/dist/esm/components/SelectTokenButton/SelectTokenButton.style.d.ts +1 -1
- package/dist/esm/components/SendToWallet/SendToWallet.style.d.ts +1 -1
- package/dist/esm/components/Skeleton/WidgetSkeleton.style.d.ts +2 -2
- package/dist/esm/components/Step/CircularProgress.js +2 -1
- package/dist/esm/components/Step/CircularProgress.js.map +1 -1
- package/dist/esm/components/Step/CircularProgress.style.js +13 -2
- package/dist/esm/components/Step/CircularProgress.style.js.map +1 -1
- package/dist/esm/components/Step/Step.js +17 -8
- package/dist/esm/components/Step/Step.js.map +1 -1
- package/dist/esm/components/Step/StepProcess.js +2 -1
- package/dist/esm/components/Step/StepProcess.js.map +1 -1
- package/dist/esm/components/Step/StepTimer.js +2 -1
- package/dist/esm/components/Step/StepTimer.js.map +1 -1
- package/dist/esm/components/TokenList/TokenList.style.d.ts +1 -1
- package/dist/esm/config/version.d.ts +1 -1
- package/dist/esm/config/version.js +1 -1
- package/dist/esm/config/version.js.map +1 -1
- package/dist/esm/hooks/useProcessMessage.js +18 -6
- package/dist/esm/hooks/useProcessMessage.js.map +1 -1
- package/dist/esm/hooks/useRoutes.d.ts +2 -2
- package/dist/esm/hooks/useRoutes.js +99 -58
- package/dist/esm/hooks/useRoutes.js.map +1 -1
- package/dist/esm/i18n/en.json +14 -10
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js +1 -2
- package/dist/esm/pages/SendToWallet/BookmarkAddressSheet.js.map +1 -1
- package/dist/esm/pages/SendToWallet/SendToWalletPage.style.d.ts +2 -2
- package/dist/esm/providers/WalletProvider/SDKProviders.js +2 -15
- package/dist/esm/providers/WalletProvider/SDKProviders.js.map +1 -1
- package/dist/esm/stores/routes/useExecutingRoutesIds.js +2 -2
- package/dist/esm/stores/routes/useExecutingRoutesIds.js.map +1 -1
- package/dist/esm/themes/createTheme.js +4 -5
- package/dist/esm/themes/createTheme.js.map +1 -1
- package/dist/esm/types/widget.d.ts +19 -1
- package/dist/esm/types/widget.js.map +1 -1
- package/package.json +12 -13
- package/src/components/ActiveTransactions/ActiveTransactionItem.tsx +1 -0
- package/src/components/BaseTransactionButton/BaseTransactionButton.tsx +3 -3
- package/src/components/ButtonTertiary.tsx +4 -5
- package/src/components/Card/CardLabel.tsx +0 -1
- package/src/components/RouteCard/RouteCard.tsx +19 -6
- package/src/components/RouteCard/getMatchingLabels.ts +53 -0
- package/src/components/Step/CircularProgress.style.tsx +13 -2
- package/src/components/Step/CircularProgress.tsx +2 -1
- package/src/components/Step/Step.tsx +23 -12
- package/src/components/Step/StepProcess.tsx +2 -1
- package/src/components/Step/StepTimer.tsx +3 -1
- package/src/config/version.ts +1 -1
- package/src/hooks/useProcessMessage.ts +24 -5
- package/src/hooks/useRoutes.ts +127 -66
- package/src/i18n/en.json +14 -10
- package/src/pages/SendToWallet/BookmarkAddressSheet.tsx +2 -3
- package/src/providers/WalletProvider/SDKProviders.tsx +2 -16
- package/src/stores/routes/useExecutingRoutesIds.ts +2 -2
- package/src/themes/createTheme.ts +6 -8
- package/src/themes/types.ts +0 -1
- package/src/types/widget.ts +23 -0
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.d.ts +0 -8
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js +0 -95
- package/dist/esm/providers/WalletProvider/getSafeMultisigConfig.js.map +0 -1
- package/src/providers/WalletProvider/getSafeMultisigConfig.ts +0 -144
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type { MultisigTransaction, MultisigTxDetails } from '@lifi/sdk'
|
|
3
|
-
import type { Connector } from 'wagmi'
|
|
4
|
-
|
|
5
|
-
enum TransactionStatus {
|
|
6
|
-
AWAITING_CONFIRMATIONS = 'AWAITING_CONFIRMATIONS',
|
|
7
|
-
AWAITING_EXECUTION = 'AWAITING_EXECUTION',
|
|
8
|
-
CANCELLED = 'CANCELLED',
|
|
9
|
-
FAILED = 'FAILED',
|
|
10
|
-
SUCCESS = 'SUCCESS',
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type GatewayTransactionDetails = {
|
|
14
|
-
safeAddress: string
|
|
15
|
-
txId: string
|
|
16
|
-
executedAt?: number
|
|
17
|
-
txStatus: TransactionStatus
|
|
18
|
-
txHash?: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const getSafeMultisigConfig = (connector: Connector) => {
|
|
22
|
-
const getMultisigTransactionDetails = async (
|
|
23
|
-
txHash: string,
|
|
24
|
-
chainId: number,
|
|
25
|
-
updateIntermediateStatus?: () => void
|
|
26
|
-
): Promise<MultisigTxDetails> => {
|
|
27
|
-
const safeAppProvider = (await connector.getProvider()) as any
|
|
28
|
-
const safeProviderSDK = safeAppProvider.sdk
|
|
29
|
-
|
|
30
|
-
const safeTransactionDetails: GatewayTransactionDetails =
|
|
31
|
-
await safeProviderSDK.txs.getBySafeTxHash(txHash)
|
|
32
|
-
|
|
33
|
-
const safeTxHash = safeTransactionDetails.txId
|
|
34
|
-
|
|
35
|
-
const safeApiTransactionResponse = await fetch(
|
|
36
|
-
`https://safe-client.safe.global/v1/chains/${chainId}/transactions/${safeTxHash}`
|
|
37
|
-
)
|
|
38
|
-
|
|
39
|
-
const safeApiTransactionDetails = await safeApiTransactionResponse.json()
|
|
40
|
-
|
|
41
|
-
const nonTerminalStatus = [
|
|
42
|
-
TransactionStatus.SUCCESS,
|
|
43
|
-
TransactionStatus.CANCELLED,
|
|
44
|
-
TransactionStatus.FAILED,
|
|
45
|
-
]
|
|
46
|
-
|
|
47
|
-
const isSafeStatusPending =
|
|
48
|
-
!nonTerminalStatus.includes(safeTransactionDetails.txStatus) &&
|
|
49
|
-
!nonTerminalStatus.includes(safeApiTransactionDetails.txStatus)
|
|
50
|
-
|
|
51
|
-
const isAwaitingExecution = [
|
|
52
|
-
safeTransactionDetails.txStatus,
|
|
53
|
-
safeApiTransactionDetails.txStatus,
|
|
54
|
-
].includes(TransactionStatus.AWAITING_EXECUTION)
|
|
55
|
-
|
|
56
|
-
if (isAwaitingExecution) {
|
|
57
|
-
updateIntermediateStatus?.()
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isSafeStatusPending) {
|
|
61
|
-
await new Promise((resolve) => {
|
|
62
|
-
setTimeout(resolve, 5000)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
return await getMultisigTransactionDetails(
|
|
66
|
-
txHash,
|
|
67
|
-
chainId,
|
|
68
|
-
updateIntermediateStatus
|
|
69
|
-
)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (
|
|
73
|
-
[
|
|
74
|
-
safeTransactionDetails.txStatus,
|
|
75
|
-
safeApiTransactionDetails.txStatus,
|
|
76
|
-
].includes(TransactionStatus.SUCCESS)
|
|
77
|
-
) {
|
|
78
|
-
return {
|
|
79
|
-
status: 'DONE',
|
|
80
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
if (
|
|
85
|
-
[
|
|
86
|
-
safeTransactionDetails.txStatus,
|
|
87
|
-
safeApiTransactionDetails.txStatus,
|
|
88
|
-
].includes(TransactionStatus.FAILED)
|
|
89
|
-
) {
|
|
90
|
-
return {
|
|
91
|
-
status: 'FAILED',
|
|
92
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
[
|
|
98
|
-
safeTransactionDetails.txStatus,
|
|
99
|
-
safeApiTransactionDetails.txStatus,
|
|
100
|
-
].includes(TransactionStatus.CANCELLED)
|
|
101
|
-
) {
|
|
102
|
-
return {
|
|
103
|
-
status: 'CANCELLED',
|
|
104
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (isSafeStatusPending) {
|
|
109
|
-
return {
|
|
110
|
-
status: 'PENDING',
|
|
111
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
status: 'PENDING',
|
|
117
|
-
txHash: `0x${safeTransactionDetails.txHash?.slice(2)}`,
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const sendBatchTransaction = async (
|
|
122
|
-
batchTransactions: MultisigTransaction[]
|
|
123
|
-
): Promise<`0x${string}`> => {
|
|
124
|
-
const safeAppProvider = (await connector.getProvider()) as any
|
|
125
|
-
const safeProviderSDK = safeAppProvider.sdk
|
|
126
|
-
|
|
127
|
-
try {
|
|
128
|
-
const { safeTxHash } = await safeProviderSDK.txs.send({
|
|
129
|
-
txs: batchTransactions,
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
return `0x${safeTxHash.slice(2)}`
|
|
133
|
-
} catch (error) {
|
|
134
|
-
throw new Error(error as string)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return {
|
|
139
|
-
isMultisigWalletClient: connector?.id === 'safe',
|
|
140
|
-
shouldBatchTransactions: connector?.id === 'safe',
|
|
141
|
-
sendBatchTransaction,
|
|
142
|
-
getMultisigTransactionDetails,
|
|
143
|
-
}
|
|
144
|
-
}
|