@lifi/sdk 3.6.0-beta.3 → 3.6.0-beta.4
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/package.json +4 -4
- package/src/_cjs/core/EVM/EVMStepExecutor.js +250 -220
- package/src/_cjs/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_cjs/core/EVM/parseEVMErrors.js +2 -1
- package/src/_cjs/core/EVM/parseEVMErrors.js.map +1 -1
- package/src/_cjs/core/EVM/typeguards.js +2 -2
- package/src/_cjs/core/EVM/typeguards.js.map +1 -1
- package/src/_cjs/core/Solana/SolanaStepExecutor.js +1 -13
- package/src/_cjs/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_cjs/core/Solana/parseSolanaErrors.js.map +1 -1
- package/src/_cjs/core/StatusManager.js +13 -9
- package/src/_cjs/core/StatusManager.js.map +1 -1
- package/src/_cjs/core/UTXO/UTXOStepExecutor.js +1 -13
- package/src/_cjs/core/UTXO/UTXOStepExecutor.js.map +1 -1
- package/src/_cjs/core/UTXO/parseUTXOErrors.js.map +1 -1
- package/src/_cjs/core/processMessages.js +22 -15
- package/src/_cjs/core/processMessages.js.map +1 -1
- package/src/_cjs/core/waitForDestinationChainTransaction.js +16 -1
- package/src/_cjs/core/waitForDestinationChainTransaction.js.map +1 -1
- package/src/_cjs/core/waitForTransactionStatus.js.map +1 -1
- package/src/_cjs/errors/SDKError.js.map +1 -1
- package/src/_cjs/index.js +2 -2
- package/src/_cjs/index.js.map +1 -1
- package/src/_cjs/utils/getTransactionMessage.js.map +1 -1
- package/src/_cjs/version.js +1 -1
- package/src/_esm/core/EVM/EVMStepExecutor.js +273 -242
- package/src/_esm/core/EVM/EVMStepExecutor.js.map +1 -1
- package/src/_esm/core/EVM/parseEVMErrors.js +2 -1
- package/src/_esm/core/EVM/parseEVMErrors.js.map +1 -1
- package/src/_esm/core/EVM/typeguards.js +1 -1
- package/src/_esm/core/EVM/typeguards.js.map +1 -1
- package/src/_esm/core/Solana/SolanaStepExecutor.js +1 -14
- package/src/_esm/core/Solana/SolanaStepExecutor.js.map +1 -1
- package/src/_esm/core/Solana/parseSolanaErrors.js.map +1 -1
- package/src/_esm/core/StatusManager.js +24 -18
- package/src/_esm/core/StatusManager.js.map +1 -1
- package/src/_esm/core/UTXO/UTXOStepExecutor.js +1 -14
- package/src/_esm/core/UTXO/UTXOStepExecutor.js.map +1 -1
- package/src/_esm/core/UTXO/parseUTXOErrors.js.map +1 -1
- package/src/_esm/core/processMessages.js +22 -15
- package/src/_esm/core/processMessages.js.map +1 -1
- package/src/_esm/core/waitForDestinationChainTransaction.js +17 -1
- package/src/_esm/core/waitForDestinationChainTransaction.js.map +1 -1
- package/src/_esm/core/waitForTransactionStatus.js.map +1 -1
- package/src/_esm/errors/SDKError.js.map +1 -1
- package/src/_esm/index.js +1 -1
- package/src/_esm/index.js.map +1 -1
- package/src/_esm/utils/getTransactionMessage.js.map +1 -1
- package/src/_esm/version.js +1 -1
- package/src/_types/core/EVM/EVMStepExecutor.d.ts +13 -3
- package/src/_types/core/EVM/EVMStepExecutor.d.ts.map +1 -1
- package/src/_types/core/EVM/checkAllowance.d.ts.map +1 -1
- package/src/_types/core/EVM/parseEVMErrors.d.ts +2 -1
- package/src/_types/core/EVM/parseEVMErrors.d.ts.map +1 -1
- package/src/_types/core/EVM/typeguards.d.ts +1 -1
- package/src/_types/core/EVM/typeguards.d.ts.map +1 -1
- package/src/_types/core/Solana/SolanaStepExecutor.d.ts.map +1 -1
- package/src/_types/core/Solana/parseSolanaErrors.d.ts +2 -1
- package/src/_types/core/Solana/parseSolanaErrors.d.ts.map +1 -1
- package/src/_types/core/StatusManager.d.ts +14 -11
- package/src/_types/core/StatusManager.d.ts.map +1 -1
- package/src/_types/core/UTXO/UTXOStepExecutor.d.ts.map +1 -1
- package/src/_types/core/UTXO/parseUTXOErrors.d.ts +2 -1
- package/src/_types/core/UTXO/parseUTXOErrors.d.ts.map +1 -1
- package/src/_types/core/processMessages.d.ts +3 -1
- package/src/_types/core/processMessages.d.ts.map +1 -1
- package/src/_types/core/types.d.ts +32 -1
- package/src/_types/core/types.d.ts.map +1 -1
- package/src/_types/core/waitForDestinationChainTransaction.d.ts +3 -3
- package/src/_types/core/waitForDestinationChainTransaction.d.ts.map +1 -1
- package/src/_types/core/waitForTransactionStatus.d.ts +2 -1
- package/src/_types/core/waitForTransactionStatus.d.ts.map +1 -1
- package/src/_types/errors/SDKError.d.ts +2 -1
- package/src/_types/errors/SDKError.d.ts.map +1 -1
- package/src/_types/index.d.ts +2 -2
- package/src/_types/index.d.ts.map +1 -1
- package/src/_types/utils/getTransactionMessage.d.ts +2 -1
- package/src/_types/utils/getTransactionMessage.d.ts.map +1 -1
- package/src/_types/version.d.ts +1 -1
- package/src/core/EVM/EVMStepExecutor.ts +352 -301
- package/src/core/EVM/checkAllowance.ts +2 -2
- package/src/core/EVM/parseEVMErrors.ts +6 -2
- package/src/core/EVM/typeguards.ts +1 -1
- package/src/core/Solana/SolanaStepExecutor.ts +2 -16
- package/src/core/Solana/parseSolanaErrors.ts +2 -1
- package/src/core/StatusManager.ts +38 -26
- package/src/core/UTXO/UTXOStepExecutor.ts +2 -16
- package/src/core/UTXO/parseUTXOErrors.ts +2 -1
- package/src/core/processMessages.ts +25 -21
- package/src/core/types.ts +54 -1
- package/src/core/waitForDestinationChainTransaction.ts +21 -4
- package/src/core/waitForTransactionStatus.ts +2 -6
- package/src/errors/SDKError.ts +2 -1
- package/src/index.ts +6 -1
- package/src/utils/getTransactionMessage.ts +2 -1
- package/src/version.ts +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ExtendedChain, LiFiStep
|
|
1
|
+
import type { ExtendedChain, LiFiStep } from '@lifi/types'
|
|
2
2
|
import type { Address, Client, Hash } from 'viem'
|
|
3
3
|
import { MaxUint256 } from '../../constants.js'
|
|
4
4
|
import type { StatusManager } from '../StatusManager.js'
|
|
5
|
-
import type { ExecutionOptions } from '../types.js'
|
|
5
|
+
import type { ExecutionOptions, Process, ProcessType } from '../types.js'
|
|
6
6
|
import { getAllowance } from './getAllowance.js'
|
|
7
7
|
import { parseEVMErrors } from './parseEVMErrors.js'
|
|
8
8
|
import { setAllowance } from './setAllowance.js'
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
2
|
import { SDKError } from '../../errors/SDKError.js'
|
|
3
3
|
import { BaseError } from '../../errors/baseError.js'
|
|
4
4
|
import { ErrorMessage, LiFiErrorCode } from '../../errors/constants.js'
|
|
5
5
|
import { TransactionError, UnknownError } from '../../errors/errors.js'
|
|
6
6
|
import { fetchTxErrorDetails } from '../../utils/fetchTxErrorDetails.js'
|
|
7
|
+
import type { Process } from '../types.js'
|
|
7
8
|
|
|
8
9
|
export const parseEVMErrors = async (
|
|
9
10
|
e: Error,
|
|
@@ -26,7 +27,10 @@ const handleSpecificErrors = async (
|
|
|
26
27
|
step?: LiFiStep,
|
|
27
28
|
process?: Process
|
|
28
29
|
) => {
|
|
29
|
-
if (
|
|
30
|
+
if (
|
|
31
|
+
e.name === 'UserRejectedRequestError' ||
|
|
32
|
+
e.cause?.name === 'UserRejectedRequestError'
|
|
33
|
+
) {
|
|
30
34
|
return new TransactionError(LiFiErrorCode.SignatureRejected, e.message, e)
|
|
31
35
|
}
|
|
32
36
|
// Safe Wallet via WalletConnect returns -32000 code when user rejects the signature
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LiFiStepExtended } from '../types.js'
|
|
2
2
|
import type { EVMPermitStep } from './types.js'
|
|
3
3
|
|
|
4
|
-
export function
|
|
4
|
+
export function isRelayerStep(step: LiFiStepExtended): step is EVMPermitStep {
|
|
5
5
|
const evmStep = step as EVMPermitStep
|
|
6
6
|
return 'permit' in evmStep && 'permitData' in evmStep && 'witness' in evmStep
|
|
7
7
|
}
|
|
@@ -217,24 +217,10 @@ export class SolanaStepExecutor extends BaseStepExecutor {
|
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
219
|
|
|
220
|
-
// Wait for the transaction status on the destination chain
|
|
221
|
-
const transactionHash = process.txHash
|
|
222
|
-
if (!transactionHash) {
|
|
223
|
-
throw new Error('Transaction hash is undefined.')
|
|
224
|
-
}
|
|
225
|
-
if (isBridgeExecution) {
|
|
226
|
-
process = this.statusManager.findOrCreateProcess({
|
|
227
|
-
step,
|
|
228
|
-
type: 'RECEIVING_CHAIN',
|
|
229
|
-
status: 'PENDING',
|
|
230
|
-
chainId: toChain.id,
|
|
231
|
-
})
|
|
232
|
-
}
|
|
233
|
-
|
|
234
220
|
await waitForDestinationChainTransaction(
|
|
235
221
|
step,
|
|
236
|
-
process
|
|
237
|
-
|
|
222
|
+
process,
|
|
223
|
+
fromChain,
|
|
238
224
|
toChain,
|
|
239
225
|
this.statusManager
|
|
240
226
|
)
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
2
|
import { SDKError } from '../../errors/SDKError.js'
|
|
3
3
|
import { BaseError } from '../../errors/baseError.js'
|
|
4
4
|
import { ErrorMessage, LiFiErrorCode } from '../../errors/constants.js'
|
|
5
5
|
import { TransactionError, UnknownError } from '../../errors/errors.js'
|
|
6
|
+
import type { Process } from '../types.js'
|
|
6
7
|
|
|
7
8
|
export const parseSolanaErrors = async (
|
|
8
9
|
e: Error,
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
+
import type { ChainId, LiFiStep } from '@lifi/types'
|
|
2
|
+
import { executionState } from './executionState.js'
|
|
3
|
+
import { getProcessMessage } from './processMessages.js'
|
|
1
4
|
import type {
|
|
2
|
-
ChainId,
|
|
3
5
|
Execution,
|
|
4
6
|
ExecutionStatus,
|
|
5
|
-
|
|
7
|
+
LiFiStepExtended,
|
|
6
8
|
Process,
|
|
7
9
|
ProcessStatus,
|
|
8
10
|
ProcessType,
|
|
9
|
-
} from '
|
|
10
|
-
import { executionState } from './executionState.js'
|
|
11
|
-
import { getProcessMessage } from './processMessages.js'
|
|
12
|
-
import type { LiFiStepExtended } from './types.js'
|
|
11
|
+
} from './types.js'
|
|
13
12
|
|
|
14
13
|
export type FindOrCreateProcessProps = {
|
|
15
14
|
step: LiFiStepExtended
|
|
@@ -80,17 +79,38 @@ export class StatusManager {
|
|
|
80
79
|
return step
|
|
81
80
|
}
|
|
82
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Finds a process of the specified type in the step's execution
|
|
84
|
+
* @param step The step to search in
|
|
85
|
+
* @param type The process type to find
|
|
86
|
+
* @param status Optional status to update the process with if found
|
|
87
|
+
* @returns The found process or undefined if not found
|
|
88
|
+
*/
|
|
89
|
+
findProcess(
|
|
90
|
+
step: LiFiStepExtended,
|
|
91
|
+
type: ProcessType,
|
|
92
|
+
status?: ProcessStatus
|
|
93
|
+
): Process | undefined {
|
|
94
|
+
if (!step.execution?.process) {
|
|
95
|
+
throw new Error("Execution hasn't been initialized.")
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const process = step.execution.process.find((p) => p.type === type)
|
|
99
|
+
|
|
100
|
+
if (process && status && process.status !== status) {
|
|
101
|
+
process.status = status
|
|
102
|
+
this.updateStepInRoute(step)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return process
|
|
106
|
+
}
|
|
107
|
+
|
|
83
108
|
/**
|
|
84
109
|
* Create and push a new process into the execution.
|
|
85
|
-
* @param step
|
|
86
|
-
* @param
|
|
87
|
-
* @param
|
|
88
|
-
* @param
|
|
89
|
-
* @param root0
|
|
90
|
-
* @param root0.step
|
|
91
|
-
* @param root0.type
|
|
92
|
-
* @param root0.chainId
|
|
93
|
-
* @param root0.status
|
|
110
|
+
* @param step The step that should contain the new process.
|
|
111
|
+
* @param type Type of the process. Used to identify already existing processes.
|
|
112
|
+
* @param chainId Chain Id of the process.
|
|
113
|
+
* @param status By default created procces is set to the STARTED status. We can override new process with the needed status.
|
|
94
114
|
* @returns Returns process.
|
|
95
115
|
*/
|
|
96
116
|
findOrCreateProcess = ({
|
|
@@ -99,17 +119,9 @@ export class StatusManager {
|
|
|
99
119
|
chainId,
|
|
100
120
|
status,
|
|
101
121
|
}: FindOrCreateProcessProps): Process => {
|
|
102
|
-
|
|
103
|
-
throw new Error("Execution hasn't been initialized.")
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const process = step.execution.process.find((p) => p.type === type)
|
|
122
|
+
const process = this.findProcess(step, type, status)
|
|
107
123
|
|
|
108
124
|
if (process) {
|
|
109
|
-
if (status && process.status !== status) {
|
|
110
|
-
process.status = status
|
|
111
|
-
this.updateStepInRoute(step)
|
|
112
|
-
}
|
|
113
125
|
return process
|
|
114
126
|
}
|
|
115
127
|
|
|
@@ -121,7 +133,7 @@ export class StatusManager {
|
|
|
121
133
|
chainId: chainId,
|
|
122
134
|
}
|
|
123
135
|
|
|
124
|
-
step.execution
|
|
136
|
+
step.execution!.process.push(newProcess)
|
|
125
137
|
this.updateStepInRoute(step)
|
|
126
138
|
return newProcess
|
|
127
139
|
}
|
|
@@ -143,7 +155,7 @@ export class StatusManager {
|
|
|
143
155
|
if (!step.execution) {
|
|
144
156
|
throw new Error("Can't update an empty step execution.")
|
|
145
157
|
}
|
|
146
|
-
const currentProcess =
|
|
158
|
+
const currentProcess = this.findProcess(step, type)
|
|
147
159
|
|
|
148
160
|
if (!currentProcess) {
|
|
149
161
|
throw new Error("Can't find a process for the given type.")
|
|
@@ -263,24 +263,10 @@ export class UTXOStepExecutor extends BaseStepExecutor {
|
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
|
|
266
|
-
// Wait for the transaction status on the destination chain
|
|
267
|
-
const transactionHash = process.txHash
|
|
268
|
-
if (!transactionHash) {
|
|
269
|
-
throw new Error('Transaction hash is undefined.')
|
|
270
|
-
}
|
|
271
|
-
if (isBridgeExecution) {
|
|
272
|
-
process = this.statusManager.findOrCreateProcess({
|
|
273
|
-
step,
|
|
274
|
-
type: 'RECEIVING_CHAIN',
|
|
275
|
-
status: 'PENDING',
|
|
276
|
-
chainId: toChain.id,
|
|
277
|
-
})
|
|
278
|
-
}
|
|
279
|
-
|
|
280
266
|
await waitForDestinationChainTransaction(
|
|
281
267
|
step,
|
|
282
|
-
process
|
|
283
|
-
|
|
268
|
+
process,
|
|
269
|
+
fromChain,
|
|
284
270
|
toChain,
|
|
285
271
|
this.statusManager,
|
|
286
272
|
10_000
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
2
|
import { SDKError } from '../../errors/SDKError.js'
|
|
3
3
|
import { BaseError } from '../../errors/baseError.js'
|
|
4
4
|
import { ErrorMessage, LiFiErrorCode } from '../../errors/constants.js'
|
|
5
5
|
import { TransactionError, UnknownError } from '../../errors/errors.js'
|
|
6
|
+
import type { Process } from '../types.js'
|
|
6
7
|
|
|
7
8
|
export const parseUTXOErrors = async (
|
|
8
9
|
e: Error,
|
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
StatusMessage,
|
|
5
|
-
Substatus,
|
|
6
|
-
} from '@lifi/types'
|
|
1
|
+
import type { StatusMessage, Substatus } from '@lifi/types'
|
|
2
|
+
import type { ProcessStatus } from './types.js'
|
|
3
|
+
import type { ProcessType } from './types.js'
|
|
7
4
|
|
|
8
5
|
const processMessages: Record<
|
|
9
6
|
ProcessType,
|
|
10
7
|
Partial<Record<ProcessStatus, string>>
|
|
11
8
|
> = {
|
|
12
9
|
TOKEN_ALLOWANCE: {
|
|
13
|
-
STARTED: 'Setting token allowance
|
|
14
|
-
PENDING: 'Waiting for token allowance
|
|
15
|
-
DONE: 'Token allowance set
|
|
10
|
+
STARTED: 'Setting token allowance',
|
|
11
|
+
PENDING: 'Waiting for token allowance',
|
|
12
|
+
DONE: 'Token allowance set',
|
|
16
13
|
},
|
|
17
14
|
SWITCH_CHAIN: {
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
ACTION_REQUIRED: 'Chain switch required',
|
|
16
|
+
PENDING: 'Waiting for chain switch',
|
|
17
|
+
DONE: 'Chain switched',
|
|
20
18
|
},
|
|
21
19
|
SWAP: {
|
|
22
|
-
STARTED: 'Preparing swap transaction
|
|
23
|
-
ACTION_REQUIRED: 'Please sign the transaction
|
|
24
|
-
PENDING: 'Waiting for swap transaction
|
|
25
|
-
DONE: 'Swap completed
|
|
20
|
+
STARTED: 'Preparing swap transaction',
|
|
21
|
+
ACTION_REQUIRED: 'Please sign the transaction',
|
|
22
|
+
PENDING: 'Waiting for swap transaction',
|
|
23
|
+
DONE: 'Swap completed',
|
|
26
24
|
},
|
|
27
25
|
CROSS_CHAIN: {
|
|
28
|
-
STARTED: 'Preparing bridge transaction
|
|
29
|
-
ACTION_REQUIRED: 'Please sign the transaction
|
|
30
|
-
PENDING: 'Waiting for bridge transaction
|
|
31
|
-
DONE: 'Bridge transaction confirmed
|
|
26
|
+
STARTED: 'Preparing bridge transaction',
|
|
27
|
+
ACTION_REQUIRED: 'Please sign the transaction',
|
|
28
|
+
PENDING: 'Waiting for bridge transaction',
|
|
29
|
+
DONE: 'Bridge transaction confirmed',
|
|
32
30
|
},
|
|
33
31
|
RECEIVING_CHAIN: {
|
|
34
|
-
PENDING: 'Waiting for destination chain
|
|
35
|
-
DONE: 'Bridge completed
|
|
32
|
+
PENDING: 'Waiting for destination chain',
|
|
33
|
+
DONE: 'Bridge completed',
|
|
34
|
+
},
|
|
35
|
+
PERMIT: {
|
|
36
|
+
STARTED: 'Preparing transaction',
|
|
37
|
+
ACTION_REQUIRED: 'Sign permit message',
|
|
38
|
+
PENDING: 'Waiting for permit message',
|
|
39
|
+
DONE: 'Permit message signed',
|
|
36
40
|
},
|
|
37
41
|
TRANSACTION: {},
|
|
38
42
|
}
|
package/src/core/types.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ChainType,
|
|
3
|
-
|
|
3
|
+
FeeCost,
|
|
4
|
+
GasCost,
|
|
4
5
|
LiFiStep,
|
|
5
6
|
Route,
|
|
6
7
|
Step,
|
|
8
|
+
Substatus,
|
|
7
9
|
Token,
|
|
8
10
|
TokenAmount,
|
|
9
11
|
} from '@lifi/types'
|
|
@@ -117,3 +119,54 @@ export interface ExecutionOptions {
|
|
|
117
119
|
*/
|
|
118
120
|
infiniteApproval?: boolean
|
|
119
121
|
}
|
|
122
|
+
|
|
123
|
+
export type ExecutionStatus = 'ACTION_REQUIRED' | 'PENDING' | 'FAILED' | 'DONE'
|
|
124
|
+
|
|
125
|
+
export type ProcessStatus =
|
|
126
|
+
| 'STARTED'
|
|
127
|
+
| 'ACTION_REQUIRED'
|
|
128
|
+
| 'PENDING'
|
|
129
|
+
| 'FAILED'
|
|
130
|
+
| 'DONE'
|
|
131
|
+
| 'CANCELLED'
|
|
132
|
+
|
|
133
|
+
export type ProcessType =
|
|
134
|
+
| 'TOKEN_ALLOWANCE'
|
|
135
|
+
| 'PERMIT'
|
|
136
|
+
| 'SWITCH_CHAIN'
|
|
137
|
+
| 'SWAP'
|
|
138
|
+
| 'CROSS_CHAIN'
|
|
139
|
+
| 'RECEIVING_CHAIN'
|
|
140
|
+
| 'TRANSACTION'
|
|
141
|
+
|
|
142
|
+
export type Process = {
|
|
143
|
+
type: ProcessType
|
|
144
|
+
status: ProcessStatus
|
|
145
|
+
substatus?: Substatus
|
|
146
|
+
chainId?: number
|
|
147
|
+
txHash?: string
|
|
148
|
+
multisigTxHash?: string
|
|
149
|
+
txLink?: string
|
|
150
|
+
startedAt: number
|
|
151
|
+
doneAt?: number
|
|
152
|
+
failedAt?: number
|
|
153
|
+
message?: string
|
|
154
|
+
error?: {
|
|
155
|
+
code: string | number
|
|
156
|
+
message: string
|
|
157
|
+
htmlMessage?: string
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// additional information
|
|
161
|
+
[key: string]: any
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export interface Execution {
|
|
165
|
+
status: ExecutionStatus
|
|
166
|
+
process: Array<Process>
|
|
167
|
+
fromAmount?: string
|
|
168
|
+
toAmount?: string
|
|
169
|
+
toToken?: Token
|
|
170
|
+
feeCosts?: FeeCost[]
|
|
171
|
+
gasCosts?: GasCost[]
|
|
172
|
+
}
|
|
@@ -2,23 +2,40 @@ import type {
|
|
|
2
2
|
ExtendedChain,
|
|
3
3
|
ExtendedTransactionInfo,
|
|
4
4
|
FullStatusData,
|
|
5
|
-
ProcessType,
|
|
6
5
|
} from '@lifi/types'
|
|
7
6
|
import { LiFiErrorCode } from '../errors/constants.js'
|
|
8
7
|
import { getTransactionFailedMessage } from '../utils/getTransactionMessage.js'
|
|
9
8
|
import type { StatusManager } from './StatusManager.js'
|
|
10
|
-
import type { LiFiStepExtended } from './types.js'
|
|
9
|
+
import type { LiFiStepExtended, Process } from './types.js'
|
|
11
10
|
import { waitForTransactionStatus } from './waitForTransactionStatus.js'
|
|
12
11
|
|
|
13
12
|
export async function waitForDestinationChainTransaction(
|
|
14
13
|
step: LiFiStepExtended,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
process: Process,
|
|
15
|
+
fromChain: ExtendedChain,
|
|
17
16
|
toChain: ExtendedChain,
|
|
18
17
|
statusManager: StatusManager,
|
|
19
18
|
pollingInterval?: number
|
|
20
19
|
): Promise<LiFiStepExtended> {
|
|
20
|
+
const transactionHash = process.txHash
|
|
21
|
+
let processType = process.type
|
|
21
22
|
try {
|
|
23
|
+
// Wait for the transaction status on the destination chain
|
|
24
|
+
if (!transactionHash) {
|
|
25
|
+
throw new Error('Transaction hash is undefined.')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const isBridgeExecution = fromChain.id !== toChain.id
|
|
29
|
+
if (isBridgeExecution) {
|
|
30
|
+
const receivingChainProcess = statusManager.findOrCreateProcess({
|
|
31
|
+
step,
|
|
32
|
+
type: 'RECEIVING_CHAIN',
|
|
33
|
+
status: 'PENDING',
|
|
34
|
+
chainId: toChain.id,
|
|
35
|
+
})
|
|
36
|
+
processType = receivingChainProcess.type
|
|
37
|
+
}
|
|
38
|
+
|
|
22
39
|
const statusResponse = (await waitForTransactionStatus(
|
|
23
40
|
transactionHash,
|
|
24
41
|
statusManager,
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FullStatusData,
|
|
3
|
-
LiFiStep,
|
|
4
|
-
ProcessType,
|
|
5
|
-
StatusResponse,
|
|
6
|
-
} from '@lifi/types'
|
|
1
|
+
import type { FullStatusData, LiFiStep, StatusResponse } from '@lifi/types'
|
|
7
2
|
import { ServerError } from '../errors/errors.js'
|
|
8
3
|
import { getStatus } from '../services/api.js'
|
|
9
4
|
import { waitForResult } from '../utils/waitForResult.js'
|
|
10
5
|
import type { StatusManager } from './StatusManager.js'
|
|
11
6
|
import { getSubstatusMessage } from './processMessages.js'
|
|
7
|
+
import type { ProcessType } from './types.js'
|
|
12
8
|
|
|
13
9
|
const TRANSACTION_HASH_OBSERVERS: Record<string, Promise<StatusResponse>> = {}
|
|
14
10
|
|
package/src/errors/SDKError.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
|
+
import type { Process } from '../core/types.js'
|
|
2
3
|
import { version } from '../version.js'
|
|
3
4
|
import type { BaseError } from './baseError.js'
|
|
4
5
|
import type { ErrorCode } from './constants.js'
|
package/src/index.ts
CHANGED
|
@@ -12,7 +12,7 @@ export {
|
|
|
12
12
|
setTokenAllowance,
|
|
13
13
|
} from './core/EVM/setAllowance.js'
|
|
14
14
|
export { isEVM } from './core/EVM/types.js'
|
|
15
|
-
export {
|
|
15
|
+
export { isRelayerStep } from './core/EVM/typeguards.js'
|
|
16
16
|
export type {
|
|
17
17
|
EVMProvider,
|
|
18
18
|
EVMProviderOptions,
|
|
@@ -31,9 +31,14 @@ export type {
|
|
|
31
31
|
AcceptSlippageUpdateHook,
|
|
32
32
|
AcceptSlippageUpdateHookParams,
|
|
33
33
|
ExchangeRateUpdateParams,
|
|
34
|
+
Execution,
|
|
34
35
|
ExecutionOptions,
|
|
36
|
+
ExecutionStatus,
|
|
35
37
|
InteractionSettings,
|
|
36
38
|
LiFiStepExtended,
|
|
39
|
+
Process,
|
|
40
|
+
ProcessStatus,
|
|
41
|
+
ProcessType,
|
|
37
42
|
RouteExecutionData,
|
|
38
43
|
RouteExecutionDataDictionary,
|
|
39
44
|
RouteExecutionDictionary,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { LiFiStep
|
|
1
|
+
import type { LiFiStep } from '@lifi/types'
|
|
2
2
|
import { formatUnits } from 'viem'
|
|
3
3
|
import { config } from '../config.js'
|
|
4
|
+
import type { Process } from '../core/types.js'
|
|
4
5
|
|
|
5
6
|
export const getTransactionNotSentMessage = async (
|
|
6
7
|
step?: LiFiStep,
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk'
|
|
2
|
-
export const version = '3.6.0-beta.
|
|
2
|
+
export const version = '3.6.0-beta.4'
|