@lifi/sdk-provider-solana 4.3.2 → 4.3.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/CHANGELOG.md +14 -0
- package/README.md +9 -0
- package/dist/cjs/actions/lookupSignatureStatus.d.ts +66 -0
- package/dist/cjs/actions/lookupSignatureStatus.js +258 -0
- package/dist/cjs/actions/lookupSignatureStatus.js.map +1 -0
- package/dist/cjs/actions/sendAndConfirmTransaction.d.ts +7 -0
- package/dist/cjs/actions/sendAndConfirmTransaction.js +1 -0
- package/dist/cjs/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/cjs/confirmation/confirmBundle.d.ts +1 -1
- package/dist/cjs/confirmation/confirmSignature.d.ts +1 -1
- package/dist/cjs/confirmation/createConfirmationDeadline.d.ts +6 -0
- package/dist/cjs/confirmation/createConfirmationDeadline.js +24 -8
- package/dist/cjs/confirmation/createConfirmationDeadline.js.map +1 -1
- package/dist/cjs/confirmation/pollUntilDeadline.js +9 -1
- package/dist/cjs/confirmation/pollUntilDeadline.js.map +1 -1
- package/dist/cjs/confirmation/raceRpcs.d.ts +8 -0
- package/dist/cjs/confirmation/raceRpcs.js +9 -1
- package/dist/cjs/confirmation/raceRpcs.js.map +1 -1
- package/dist/cjs/confirmation/types.d.ts +3 -0
- package/dist/cjs/confirmation/types.js.map +1 -1
- package/dist/cjs/core/SolanaStepExecutor.js +4 -5
- package/dist/cjs/core/SolanaStepExecutor.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js +69 -33
- package/dist/cjs/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js +13 -5
- package/dist/cjs/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js +71 -38
- package/dist/cjs/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js +13 -1
- package/dist/cjs/core/tasks/SolanaWaitForTransactionTask.js.map +1 -1
- package/dist/cjs/core/tasks/confirmationError.d.ts +29 -0
- package/dist/cjs/core/tasks/confirmationError.js +26 -0
- package/dist/cjs/core/tasks/confirmationError.js.map +1 -0
- package/dist/cjs/core/tasks/resumeFromStore.d.ts +31 -0
- package/dist/cjs/core/tasks/resumeFromStore.js +81 -0
- package/dist/cjs/core/tasks/resumeFromStore.js.map +1 -0
- package/dist/cjs/core/tasks/transactionOutcome.d.ts +107 -0
- package/dist/cjs/core/tasks/transactionOutcome.js +158 -0
- package/dist/cjs/core/tasks/transactionOutcome.js.map +1 -0
- package/dist/cjs/types.d.ts +13 -2
- package/dist/cjs/types.js.map +1 -1
- package/dist/cjs/utils/storedTransactions.d.ts +36 -0
- package/dist/cjs/utils/storedTransactions.js +57 -0
- package/dist/cjs/utils/storedTransactions.js.map +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/version.js.map +1 -1
- package/dist/esm/actions/lookupSignatureStatus.d.ts +66 -0
- package/dist/esm/actions/lookupSignatureStatus.d.ts.map +1 -0
- package/dist/esm/actions/lookupSignatureStatus.js +252 -0
- package/dist/esm/actions/lookupSignatureStatus.js.map +1 -0
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts +7 -0
- package/dist/esm/actions/sendAndConfirmTransaction.d.ts.map +1 -1
- package/dist/esm/actions/sendAndConfirmTransaction.js +1 -0
- package/dist/esm/actions/sendAndConfirmTransaction.js.map +1 -1
- package/dist/esm/confirmation/confirmBundle.d.ts +1 -1
- package/dist/esm/confirmation/confirmSignature.d.ts +1 -1
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts +6 -0
- package/dist/esm/confirmation/createConfirmationDeadline.d.ts.map +1 -1
- package/dist/esm/confirmation/createConfirmationDeadline.js +24 -8
- package/dist/esm/confirmation/createConfirmationDeadline.js.map +1 -1
- package/dist/esm/confirmation/pollUntilDeadline.js +9 -1
- package/dist/esm/confirmation/pollUntilDeadline.js.map +1 -1
- package/dist/esm/confirmation/raceRpcs.d.ts +8 -0
- package/dist/esm/confirmation/raceRpcs.d.ts.map +1 -1
- package/dist/esm/confirmation/raceRpcs.js +9 -1
- package/dist/esm/confirmation/raceRpcs.js.map +1 -1
- package/dist/esm/confirmation/types.d.ts +3 -0
- package/dist/esm/confirmation/types.d.ts.map +1 -1
- package/dist/esm/confirmation/types.js.map +1 -1
- package/dist/esm/core/SolanaStepExecutor.d.ts.map +1 -1
- package/dist/esm/core/SolanaStepExecutor.js +5 -6
- package/dist/esm/core/SolanaStepExecutor.js.map +1 -1
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js +69 -33
- package/dist/esm/core/tasks/SolanaJitoWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js +14 -6
- package/dist/esm/core/tasks/SolanaSignAndExecuteTask.js.map +1 -1
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js +71 -38
- package/dist/esm/core/tasks/SolanaStandardWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.d.ts.map +1 -1
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js +13 -1
- package/dist/esm/core/tasks/SolanaWaitForTransactionTask.js.map +1 -1
- package/dist/esm/core/tasks/confirmationError.d.ts +29 -0
- package/dist/esm/core/tasks/confirmationError.d.ts.map +1 -0
- package/dist/esm/core/tasks/confirmationError.js +25 -0
- package/dist/esm/core/tasks/confirmationError.js.map +1 -0
- package/dist/esm/core/tasks/resumeFromStore.d.ts +31 -0
- package/dist/esm/core/tasks/resumeFromStore.d.ts.map +1 -0
- package/dist/esm/core/tasks/resumeFromStore.js +80 -0
- package/dist/esm/core/tasks/resumeFromStore.js.map +1 -0
- package/dist/esm/core/tasks/transactionOutcome.d.ts +107 -0
- package/dist/esm/core/tasks/transactionOutcome.d.ts.map +1 -0
- package/dist/esm/core/tasks/transactionOutcome.js +150 -0
- package/dist/esm/core/tasks/transactionOutcome.js.map +1 -0
- package/dist/esm/types.d.ts +13 -2
- package/dist/esm/types.d.ts.map +1 -1
- package/dist/esm/types.js.map +1 -1
- package/dist/esm/utils/storedTransactions.d.ts +36 -0
- package/dist/esm/utils/storedTransactions.d.ts.map +1 -0
- package/dist/esm/utils/storedTransactions.js +54 -0
- package/dist/esm/utils/storedTransactions.js.map +1 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/version.js.map +1 -1
- package/package.json +2 -2
- package/src/actions/lookupSignatureStatus.ts +444 -0
- package/src/actions/sendAndConfirmTransaction.ts +18 -0
- package/src/confirmation/createConfirmationDeadline.ts +43 -11
- package/src/confirmation/pollUntilDeadline.ts +14 -1
- package/src/confirmation/raceRpcs.ts +27 -1
- package/src/confirmation/types.ts +5 -0
- package/src/core/SolanaStepExecutor.ts +26 -11
- package/src/core/tasks/SolanaJitoWaitForTransactionTask.ts +133 -71
- package/src/core/tasks/SolanaSignAndExecuteTask.ts +51 -10
- package/src/core/tasks/SolanaStandardWaitForTransactionTask.ts +130 -76
- package/src/core/tasks/SolanaWaitForTransactionTask.ts +19 -1
- package/src/core/tasks/confirmationError.ts +60 -0
- package/src/core/tasks/resumeFromStore.ts +160 -0
- package/src/core/tasks/transactionOutcome.ts +273 -0
- package/src/types.ts +13 -1
- package/src/utils/storedTransactions.ts +88 -0
- package/src/version.ts +1 -1
- package/dist/cjs/core/tasks/unwrapConfirmation.d.ts +0 -24
- package/dist/cjs/core/tasks/unwrapConfirmation.js +0 -24
- package/dist/cjs/core/tasks/unwrapConfirmation.js.map +0 -1
- package/dist/esm/core/tasks/unwrapConfirmation.d.ts +0 -24
- package/dist/esm/core/tasks/unwrapConfirmation.d.ts.map +0 -1
- package/dist/esm/core/tasks/unwrapConfirmation.js +0 -23
- package/dist/esm/core/tasks/unwrapConfirmation.js.map +0 -1
- package/src/core/tasks/unwrapConfirmation.ts +0 -59
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CLOCK_SKEW_MARGIN_MS,
|
|
3
|
+
type ExecutionAction,
|
|
4
|
+
isKnownToStatusApi,
|
|
5
|
+
isOldEnoughToDrop,
|
|
6
|
+
isResendAllowed,
|
|
7
|
+
LiFiErrorCode,
|
|
8
|
+
type TaskResult,
|
|
9
|
+
TransactionError,
|
|
10
|
+
} from '@lifi/sdk'
|
|
11
|
+
import type { Signature } from '@solana/kit'
|
|
12
|
+
import { lookupSignatureStatus } from '../../actions/lookupSignatureStatus.js'
|
|
13
|
+
import type { RaceResult } from '../../confirmation/raceRpcs.js'
|
|
14
|
+
import {
|
|
15
|
+
isConfirmedCommitment,
|
|
16
|
+
type SignatureStatus,
|
|
17
|
+
} from '../../confirmation/types.js'
|
|
18
|
+
import type { SolanaStepExecutorContext } from '../../types.js'
|
|
19
|
+
import type { TransactionLifetime } from '../../utils/getTransactionLifetime.js'
|
|
20
|
+
import { SolanaTransactionDetailsError } from '../../utils/solanaErrorCause.js'
|
|
21
|
+
import {
|
|
22
|
+
type ConfirmationMessages,
|
|
23
|
+
confirmationError,
|
|
24
|
+
} from './confirmationError.js'
|
|
25
|
+
|
|
26
|
+
/** Explorer link for a signature, as both wait tasks write it. */
|
|
27
|
+
export function getTxLink(
|
|
28
|
+
context: Pick<SolanaStepExecutorContext, 'fromChain'>,
|
|
29
|
+
signature: string
|
|
30
|
+
): string {
|
|
31
|
+
return `${context.fromChain.metamask.blockExplorerUrls[0]}tx/${signature}`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* May stored bytes be sent (again)? A blockhash transaction always: the
|
|
36
|
+
* chain rejects it once the blockhash dies, and the deadline's probe tells
|
|
37
|
+
* when. Anything else - a durable nonce, a lifetime that did not decode -
|
|
38
|
+
* only inside the resend age cap, so a page load hours later cannot execute
|
|
39
|
+
* a swap on an old quote.
|
|
40
|
+
*/
|
|
41
|
+
export function canResendStored(
|
|
42
|
+
lifetimes: TransactionLifetime[],
|
|
43
|
+
signedAt: number | undefined,
|
|
44
|
+
now?: number
|
|
45
|
+
): boolean {
|
|
46
|
+
const expiresOnItsOwn =
|
|
47
|
+
lifetimes.length > 0 &&
|
|
48
|
+
lifetimes.every((lifetime) => lifetime.kind === 'blockhash')
|
|
49
|
+
return expiresOnItsOwn || isResendAllowed(signedAt, now)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Condition (a) of the dropped rule in `resolveUnconfirmed`: the chain says
|
|
54
|
+
* the transaction can no longer land.
|
|
55
|
+
*
|
|
56
|
+
* - An `expired` verdict: the blockhash probe saw it dead.
|
|
57
|
+
* - Without a verdict, `isOldEnoughToDrop` for every lifetime. For a
|
|
58
|
+
* blockhash transaction that is the five-minute time fallback. For a
|
|
59
|
+
* durable nonce or an undecodable lifetime it is the age cap passed plus a
|
|
60
|
+
* margin: sends stop at the cap, and the three minutes after it put the
|
|
61
|
+
* lookup's current-slot head safely past any slot the transaction could
|
|
62
|
+
* still land in.
|
|
63
|
+
*
|
|
64
|
+
* An unknown signing time never holds by time.
|
|
65
|
+
*/
|
|
66
|
+
export function cannotLandAnymore(options: {
|
|
67
|
+
expired: boolean
|
|
68
|
+
signedAt: number | undefined
|
|
69
|
+
now?: number
|
|
70
|
+
}): boolean {
|
|
71
|
+
return options.expired || isOldEnoughToDrop(options.signedAt, options.now)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Drops the stored bytes: never sent, landed, or final. */
|
|
75
|
+
export function clearStoredTransactions(
|
|
76
|
+
context: SolanaStepExecutorContext,
|
|
77
|
+
action: ExecutionAction
|
|
78
|
+
): void {
|
|
79
|
+
context.statusManager.updateAction(context.step, action.type, 'PENDING', {
|
|
80
|
+
txHex: undefined,
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** A signature status's `err` as the failure `recordLanded` takes. */
|
|
85
|
+
export function failureOf(
|
|
86
|
+
status: Pick<SignatureStatus, 'err'>
|
|
87
|
+
): { err: unknown } | undefined {
|
|
88
|
+
return status.err ? { err: status.err } : undefined
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Result rule for a transaction the chain has: writes `txHash` and `txLink`,
|
|
93
|
+
* clears the stored bytes, then completes - or throws the final
|
|
94
|
+
* `TransactionFailed` for one that failed on chain.
|
|
95
|
+
*
|
|
96
|
+
* The hash is written for a failed transaction too: it exists on chain, and
|
|
97
|
+
* a resume that found it by lookup has no `txHash` yet.
|
|
98
|
+
*/
|
|
99
|
+
export function recordLanded(
|
|
100
|
+
context: SolanaStepExecutorContext,
|
|
101
|
+
action: ExecutionAction,
|
|
102
|
+
options: { signature: Signature; failure: { err: unknown } | undefined }
|
|
103
|
+
): TaskResult {
|
|
104
|
+
const { step, statusManager, isBridgeExecution } = context
|
|
105
|
+
const { signature, failure } = options
|
|
106
|
+
|
|
107
|
+
statusManager.updateAction(step, action.type, 'PENDING', {
|
|
108
|
+
txHash: signature,
|
|
109
|
+
txLink: getTxLink(context, signature),
|
|
110
|
+
txHex: undefined,
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
if (failure) {
|
|
114
|
+
const cause = new SolanaTransactionDetailsError(failure.err)
|
|
115
|
+
throw new TransactionError(
|
|
116
|
+
LiFiErrorCode.TransactionFailed,
|
|
117
|
+
`Transaction failed: ${cause.message}`,
|
|
118
|
+
cause,
|
|
119
|
+
{ final: true }
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (isBridgeExecution) {
|
|
124
|
+
statusManager.updateAction(step, action.type, 'DONE')
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return { status: 'COMPLETED' }
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Decides what a transaction that did not confirm is: landed after all
|
|
132
|
+
* (returns its status), dropped (throws a final `TransactionExpired`), or
|
|
133
|
+
* unknown (rethrows `error`, the error the task built for today's outcome).
|
|
134
|
+
*
|
|
135
|
+
* Dropped (see the resume rules in `transactionState.ts`) = (a)
|
|
136
|
+
* `cannotLandAnymore`, AND (b) a lookup that proves the absence - a covering
|
|
137
|
+
* RPC whose head is past the landing window answered `null` in the same
|
|
138
|
+
* response, and no RPC has the transaction - AND (c) the status API does not
|
|
139
|
+
* know the hash. The status API only vetoes: it answers 404 for landed
|
|
140
|
+
* transactions it does not index too, so a miss there proves nothing.
|
|
141
|
+
*/
|
|
142
|
+
export async function resolveUnconfirmed(
|
|
143
|
+
context: SolanaStepExecutorContext,
|
|
144
|
+
action: ExecutionAction,
|
|
145
|
+
options: {
|
|
146
|
+
signature: Signature
|
|
147
|
+
/** What the integrator sees when the outcome stays unknown. */
|
|
148
|
+
error: unknown
|
|
149
|
+
/** The slot of the `expired` verdict; `undefined` without one. */
|
|
150
|
+
expiredAtSlot: bigint | undefined
|
|
151
|
+
messages: ConfirmationMessages
|
|
152
|
+
}
|
|
153
|
+
): Promise<SignatureStatus> {
|
|
154
|
+
const { client, step } = context
|
|
155
|
+
const { signature, error, expiredAtSlot } = options
|
|
156
|
+
const signedAt = step.execution?.signedAt
|
|
157
|
+
|
|
158
|
+
// (a) The local check runs first, so a young transaction costs no request.
|
|
159
|
+
if (!cannotLandAnymore({ expired: expiredAtSlot !== undefined, signedAt })) {
|
|
160
|
+
throw error
|
|
161
|
+
}
|
|
162
|
+
// Without a signing time there is no anchor, so no canary can prove that a
|
|
163
|
+
// node's history covers the transaction.
|
|
164
|
+
if (signedAt === undefined) {
|
|
165
|
+
throw error
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// (b) Absence, proven by the same response that proves coverage and head.
|
|
169
|
+
// Every other lookup result - also `unknown` with `answered: false`, an
|
|
170
|
+
// outage - keeps the outcome unknown.
|
|
171
|
+
const lookup = await lookupSignatureStatus(client, signature, {
|
|
172
|
+
anchor: signedAt - CLOCK_SKEW_MARGIN_MS,
|
|
173
|
+
expiredAtSlot,
|
|
174
|
+
})
|
|
175
|
+
if (
|
|
176
|
+
lookup.kind === 'found' &&
|
|
177
|
+
isConfirmedCommitment(lookup.status.confirmationStatus)
|
|
178
|
+
) {
|
|
179
|
+
return lookup.status
|
|
180
|
+
}
|
|
181
|
+
if (lookup.kind !== 'not-found') {
|
|
182
|
+
throw error
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// (c) The veto.
|
|
186
|
+
if (await isKnownToStatusApi(client, step, signature)) {
|
|
187
|
+
throw error
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
clearStoredTransactions(context, action)
|
|
191
|
+
// Today's expiry code and text: only the marker is new.
|
|
192
|
+
throw new TransactionError(
|
|
193
|
+
LiFiErrorCode.TransactionExpired,
|
|
194
|
+
options.messages.notConfirmed,
|
|
195
|
+
error instanceof Error ? error : undefined,
|
|
196
|
+
{ final: true }
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The send-and-settle tail both wait tasks share: runs `send`, then applies
|
|
202
|
+
* the result rules to what it reports.
|
|
203
|
+
*
|
|
204
|
+
* - A confirmation goes to `recordLanded`, with `confirmedFailure` reading
|
|
205
|
+
* its on-chain failure.
|
|
206
|
+
* - Every other result - `rpc-unavailable` included - goes to
|
|
207
|
+
* `resolveUnconfirmed`. Only an `expired` verdict passes its slot: the
|
|
208
|
+
* dropped check reads any defined slot as a verdict.
|
|
209
|
+
* - A rejection comes before the first send of this run. On the first run
|
|
210
|
+
* nothing ever left the SDK, so the bytes are cleared and the error is
|
|
211
|
+
* rethrown: "Try again" signs again. On a resume an earlier run may have
|
|
212
|
+
* sent the same bytes: they stay, and only the chain can make the outcome
|
|
213
|
+
* final.
|
|
214
|
+
*/
|
|
215
|
+
export async function sendAndSettle<T>(
|
|
216
|
+
context: SolanaStepExecutorContext,
|
|
217
|
+
action: ExecutionAction,
|
|
218
|
+
options: {
|
|
219
|
+
signature: Signature
|
|
220
|
+
/** Sends and races the confirmation. Rejects only before its first
|
|
221
|
+
* send; the race itself never rejects. */
|
|
222
|
+
send: () => Promise<RaceResult<T>>
|
|
223
|
+
/** The on-chain failure of a confirmed value. */
|
|
224
|
+
confirmedFailure: (value: T) => { err: unknown } | undefined
|
|
225
|
+
/** An earlier run may already have sent these bytes. */
|
|
226
|
+
resuming: boolean
|
|
227
|
+
messages: ConfirmationMessages
|
|
228
|
+
}
|
|
229
|
+
): Promise<TaskResult> {
|
|
230
|
+
const { signature, messages } = options
|
|
231
|
+
|
|
232
|
+
/** `resolveUnconfirmed` throws for an unknown or dropped outcome, so only
|
|
233
|
+
* a confirmed status reaches `recordLanded`. */
|
|
234
|
+
const settleUnconfirmed = async (
|
|
235
|
+
error: unknown,
|
|
236
|
+
expiredAtSlot: bigint | undefined
|
|
237
|
+
): Promise<TaskResult> => {
|
|
238
|
+
const status = await resolveUnconfirmed(context, action, {
|
|
239
|
+
signature,
|
|
240
|
+
error,
|
|
241
|
+
expiredAtSlot,
|
|
242
|
+
messages,
|
|
243
|
+
})
|
|
244
|
+
return recordLanded(context, action, {
|
|
245
|
+
signature,
|
|
246
|
+
failure: failureOf(status),
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
let result: RaceResult<T>
|
|
251
|
+
try {
|
|
252
|
+
result = await options.send()
|
|
253
|
+
} catch (error) {
|
|
254
|
+
if (!options.resuming) {
|
|
255
|
+
clearStoredTransactions(context, action)
|
|
256
|
+
throw error
|
|
257
|
+
}
|
|
258
|
+
return settleUnconfirmed(error, undefined)
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
if (result.kind === 'confirmed') {
|
|
262
|
+
return recordLanded(context, action, {
|
|
263
|
+
signature,
|
|
264
|
+
failure: options.confirmedFailure(result.value),
|
|
265
|
+
})
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return settleUnconfirmed(
|
|
269
|
+
confirmationError(result, messages),
|
|
270
|
+
// The head a covering RPC has to reach before its `null` counts.
|
|
271
|
+
result.kind === 'expired' ? result.slot : undefined
|
|
272
|
+
)
|
|
273
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChainType,
|
|
3
|
+
type LiFiStepExtended,
|
|
3
4
|
type SDKProvider,
|
|
4
5
|
type StepExecutorContext,
|
|
5
6
|
type StepExecutorOptions,
|
|
@@ -13,10 +14,15 @@ export interface SolanaProviderOptions {
|
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
export interface SolanaTaskContext {
|
|
17
|
+
/**
|
|
18
|
+
* Set by the sign task. Absent on a resume: the wait tasks then read the
|
|
19
|
+
* signed bytes from the action's `txHex`.
|
|
20
|
+
*/
|
|
16
21
|
signedTransactions?: Transaction[]
|
|
17
22
|
/**
|
|
18
23
|
* Whether the backend returned a Jito bundle (array `transactionRequest.data`)
|
|
19
24
|
* that must be submitted via `sendBundle` instead of `sendTransaction`.
|
|
25
|
+
* Absent on a resume: a leading `[` in `txHex` marks a bundle then.
|
|
20
26
|
*/
|
|
21
27
|
isBundleExecution?: boolean
|
|
22
28
|
}
|
|
@@ -25,7 +31,13 @@ export interface SolanaStepExecutorContext
|
|
|
25
31
|
extends StepExecutorContext,
|
|
26
32
|
SolanaTaskContext {
|
|
27
33
|
wallet: Wallet
|
|
28
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Resolves the account that requested the quote. Only the sign task calls
|
|
36
|
+
* it, so a resume that only waits does not need the wallet to have
|
|
37
|
+
* reconnected. Throws `WalletChangedDuringExecution` when the account is
|
|
38
|
+
* gone.
|
|
39
|
+
*/
|
|
40
|
+
getWalletAccount: (step: LiFiStepExtended) => WalletAccount
|
|
29
41
|
skipSimulation: boolean
|
|
30
42
|
}
|
|
31
43
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getBase64Decoder,
|
|
3
|
+
getSignatureFromTransaction,
|
|
4
|
+
getTransactionCodec,
|
|
5
|
+
type Signature,
|
|
6
|
+
type Transaction,
|
|
7
|
+
} from '@solana/kit'
|
|
8
|
+
import { base64ToUint8Array } from './base64ToUint8Array.js'
|
|
9
|
+
|
|
10
|
+
/** Signed transactions decoded from `action.txHex`. */
|
|
11
|
+
export type StoredTransactions = {
|
|
12
|
+
transactions: Transaction[]
|
|
13
|
+
/** A Jito bundle: submitted with `sendBundle`, never one by one. */
|
|
14
|
+
isBundle: boolean
|
|
15
|
+
/** The first transaction's signature: the action's `txHash` once sent. */
|
|
16
|
+
signature: Signature
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Serializes signed wire transactions for `action.txHex`: the base64 wire
|
|
21
|
+
* transaction for a single one, a JSON array of them for a bundle.
|
|
22
|
+
*
|
|
23
|
+
* The array stays for a one-element bundle too: the leading `[` is the only
|
|
24
|
+
* record of `isBundleExecution` a resume gets.
|
|
25
|
+
*
|
|
26
|
+
* Throws for an empty list, which would store a value
|
|
27
|
+
* `decodeStoredTransactions` rejects, and for more than one transaction
|
|
28
|
+
* outside a bundle, of which the base64 would keep only the first.
|
|
29
|
+
*/
|
|
30
|
+
export function encodeStoredTransactions(
|
|
31
|
+
wireTransactions: readonly Uint8Array[],
|
|
32
|
+
isBundle: boolean
|
|
33
|
+
): string {
|
|
34
|
+
if (wireTransactions.length === 0) {
|
|
35
|
+
throw new Error('No signed transactions to store.')
|
|
36
|
+
}
|
|
37
|
+
if (!isBundle && wireTransactions.length !== 1) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`Expected one signed transaction outside a bundle, got ${wireTransactions.length}.`
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
const base64 = getBase64Decoder()
|
|
43
|
+
const encoded = wireTransactions.map((bytes) => base64.decode(bytes))
|
|
44
|
+
return isBundle ? JSON.stringify(encoded) : encoded[0]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** A leading `[` marks a bundle; base64 never starts with one. */
|
|
48
|
+
export function isStoredBundle(txHex: string): boolean {
|
|
49
|
+
return txHex.startsWith('[')
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Decodes `action.txHex` back into signed transactions.
|
|
54
|
+
*
|
|
55
|
+
* Returns `undefined` for anything a resume cannot send: a value that is not
|
|
56
|
+
* base64 or JSON, an empty bundle, bytes that do not decode, or a
|
|
57
|
+
* transaction without its fee payer signature. The sign task stores only
|
|
58
|
+
* values that pass these checks, so `undefined` means the stored value was
|
|
59
|
+
* damaged after it was written.
|
|
60
|
+
*/
|
|
61
|
+
export function decodeStoredTransactions(
|
|
62
|
+
txHex: string
|
|
63
|
+
): StoredTransactions | undefined {
|
|
64
|
+
try {
|
|
65
|
+
const isBundle = isStoredBundle(txHex)
|
|
66
|
+
const encoded: unknown = isBundle ? JSON.parse(txHex) : [txHex]
|
|
67
|
+
if (
|
|
68
|
+
!Array.isArray(encoded) ||
|
|
69
|
+
encoded.length === 0 ||
|
|
70
|
+
!encoded.every((entry) => typeof entry === 'string')
|
|
71
|
+
) {
|
|
72
|
+
return undefined
|
|
73
|
+
}
|
|
74
|
+
const codec = getTransactionCodec()
|
|
75
|
+
const transactions = encoded.map((entry: string) =>
|
|
76
|
+
codec.decode(base64ToUint8Array(entry))
|
|
77
|
+
)
|
|
78
|
+
// Every entry must carry its fee payer signature, as the sign task
|
|
79
|
+
// checked before it stored them. `getSignatureFromTransaction` throws
|
|
80
|
+
// when one does not.
|
|
81
|
+
const signatures = transactions.map((transaction) =>
|
|
82
|
+
getSignatureFromTransaction(transaction)
|
|
83
|
+
)
|
|
84
|
+
return { transactions, isBundle, signature: signatures[0] }
|
|
85
|
+
} catch (_) {
|
|
86
|
+
return undefined
|
|
87
|
+
}
|
|
88
|
+
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = '@lifi/sdk-provider-solana'
|
|
2
|
-
export const version = '4.3.
|
|
2
|
+
export const version = '4.3.4'
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RaceResult } from "../../confirmation/raceRpcs.js";
|
|
2
|
-
//#region src/core/tasks/unwrapConfirmation.d.ts
|
|
3
|
-
/** Only the nouns differ between the standard and bundle paths. */
|
|
4
|
-
export type ConfirmationMessages = {
|
|
5
|
-
/** Every branch failed: an outage, not a verdict about the transaction. */
|
|
6
|
-
rpcUnavailable: string;
|
|
7
|
-
/** A branch polled to its deadline and saw nothing. */
|
|
8
|
-
notConfirmed: string;
|
|
9
|
-
/** Heading of the `AggregateError` chained onto `rpcUnavailable`. */
|
|
10
|
-
allRpcsFailed: string;
|
|
11
|
-
/** Heading of the `AggregateError` chained onto `notConfirmed`. */
|
|
12
|
-
someRpcsFailed: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Returns the confirmed value, or throws the error the integrator sees.
|
|
16
|
-
*
|
|
17
|
-
* Both wait tasks map the same three outcomes onto the same two error classes,
|
|
18
|
-
* so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must
|
|
19
|
-
* stay distinct: collapsing them reported a live RPC defect as an expired
|
|
20
|
-
* transaction.
|
|
21
|
-
*/
|
|
22
|
-
export declare function unwrapConfirmation<T>(result: RaceResult<T>, messages: ConfirmationMessages): T;
|
|
23
|
-
//#endregion
|
|
24
|
-
//# sourceMappingURL=unwrapConfirmation.d.ts.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
let _lifi_sdk = require("@lifi/sdk");
|
|
3
|
-
//#region src/core/tasks/unwrapConfirmation.ts
|
|
4
|
-
/** `cause` is the first collected error on purpose: `BaseError` overwrites its
|
|
5
|
-
* stack with `getRootCause(cause).stack`, and an `AggregateError` has no
|
|
6
|
-
* `cause`, so without it the stack would point at this file. */
|
|
7
|
-
const chainErrors = (errors, message) => errors.length ? new AggregateError(errors, message, { cause: errors[0] }) : void 0;
|
|
8
|
-
/**
|
|
9
|
-
* Returns the confirmed value, or throws the error the integrator sees.
|
|
10
|
-
*
|
|
11
|
-
* Both wait tasks map the same three outcomes onto the same two error classes,
|
|
12
|
-
* so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must
|
|
13
|
-
* stay distinct: collapsing them reported a live RPC defect as an expired
|
|
14
|
-
* transaction.
|
|
15
|
-
*/
|
|
16
|
-
function unwrapConfirmation(result, messages) {
|
|
17
|
-
if (result.kind === "rpc-unavailable") throw new _lifi_sdk.RPCError(_lifi_sdk.LiFiErrorCode.RpcUnavailable, messages.rpcUnavailable, chainErrors(result.errors, messages.allRpcsFailed));
|
|
18
|
-
if (result.kind === "not-confirmed") throw new _lifi_sdk.TransactionError(_lifi_sdk.LiFiErrorCode.TransactionExpired, messages.notConfirmed, chainErrors(result.errors, messages.someRpcsFailed));
|
|
19
|
-
return result.value;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.unwrapConfirmation = unwrapConfirmation;
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=unwrapConfirmation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapConfirmation.js","names":["RPCError","LiFiErrorCode","TransactionError"],"sources":["../../../../src/core/tasks/unwrapConfirmation.ts"],"sourcesContent":["import { LiFiErrorCode, RPCError, TransactionError } from '@lifi/sdk'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\n\n/** Only the nouns differ between the standard and bundle paths. */\nexport type ConfirmationMessages = {\n /** Every branch failed: an outage, not a verdict about the transaction. */\n rpcUnavailable: string\n /** A branch polled to its deadline and saw nothing. */\n notConfirmed: string\n /** Heading of the `AggregateError` chained onto `rpcUnavailable`. */\n allRpcsFailed: string\n /** Heading of the `AggregateError` chained onto `notConfirmed`. */\n someRpcsFailed: string\n}\n\n/** `cause` is the first collected error on purpose: `BaseError` overwrites its\n * stack with `getRootCause(cause).stack`, and an `AggregateError` has no\n * `cause`, so without it the stack would point at this file. */\nconst chainErrors = (\n errors: Error[],\n message: string\n): AggregateError | undefined =>\n errors.length\n ? new AggregateError(errors, message, { cause: errors[0] })\n : undefined\n\n/**\n * Returns the confirmed value, or throws the error the integrator sees.\n *\n * Both wait tasks map the same three outcomes onto the same two error classes,\n * so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must\n * stay distinct: collapsing them reported a live RPC defect as an expired\n * transaction.\n */\nexport function unwrapConfirmation<T>(\n result: RaceResult<T>,\n messages: ConfirmationMessages\n): T {\n if (result.kind === 'rpc-unavailable') {\n throw new RPCError(\n LiFiErrorCode.RpcUnavailable,\n messages.rpcUnavailable,\n chainErrors(result.errors, messages.allRpcsFailed)\n )\n }\n\n if (result.kind === 'not-confirmed') {\n // The verdict came from a branch that polled to its deadline and saw\n // nothing, but other branches may have died trying - and their errors are\n // the only trail explaining, say, an endpoint that never answered.\n throw new TransactionError(\n LiFiErrorCode.TransactionExpired,\n messages.notConfirmed,\n chainErrors(result.errors, messages.someRpcsFailed)\n )\n }\n\n return result.value\n}\n"],"mappings":";;;;;;AAkBA,MAAM,eACJ,QACA,YAEA,OAAO,SACH,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,OAAO,GAAG,CAAC,IACxD,KAAA;;;;;;;;;AAUN,SAAgB,mBACd,QACA,UACG;CACH,IAAI,OAAO,SAAS,mBAClB,MAAM,IAAIA,UAAAA,SACRC,UAAAA,cAAc,gBACd,SAAS,gBACT,YAAY,OAAO,QAAQ,SAAS,aAAa,CACnD;CAGF,IAAI,OAAO,SAAS,iBAIlB,MAAM,IAAIC,UAAAA,iBACRD,UAAAA,cAAc,oBACd,SAAS,cACT,YAAY,OAAO,QAAQ,SAAS,cAAc,CACpD;CAGF,OAAO,OAAO;AAChB"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RaceResult } from "../../confirmation/raceRpcs.js";
|
|
2
|
-
//#region src/core/tasks/unwrapConfirmation.d.ts
|
|
3
|
-
/** Only the nouns differ between the standard and bundle paths. */
|
|
4
|
-
export type ConfirmationMessages = {
|
|
5
|
-
/** Every branch failed: an outage, not a verdict about the transaction. */
|
|
6
|
-
rpcUnavailable: string;
|
|
7
|
-
/** A branch polled to its deadline and saw nothing. */
|
|
8
|
-
notConfirmed: string;
|
|
9
|
-
/** Heading of the `AggregateError` chained onto `rpcUnavailable`. */
|
|
10
|
-
allRpcsFailed: string;
|
|
11
|
-
/** Heading of the `AggregateError` chained onto `notConfirmed`. */
|
|
12
|
-
someRpcsFailed: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Returns the confirmed value, or throws the error the integrator sees.
|
|
16
|
-
*
|
|
17
|
-
* Both wait tasks map the same three outcomes onto the same two error classes,
|
|
18
|
-
* so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must
|
|
19
|
-
* stay distinct: collapsing them reported a live RPC defect as an expired
|
|
20
|
-
* transaction.
|
|
21
|
-
*/
|
|
22
|
-
export declare function unwrapConfirmation<T>(result: RaceResult<T>, messages: ConfirmationMessages): T;
|
|
23
|
-
//#endregion
|
|
24
|
-
//# sourceMappingURL=unwrapConfirmation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapConfirmation.d.ts","names":[],"sources":["../../../../src/core/tasks/unwrapConfirmation.ts"],"mappings":";;;YAIY;;EAEV;;EAEA;;EAEA;;EAEA;;;;;;;;;;wBAsBc,mBAAmB,GACjC,QAAQ,WAAW,IACnB,UAAU,uBACT"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { LiFiErrorCode, RPCError, TransactionError } from "@lifi/sdk";
|
|
2
|
-
//#region src/core/tasks/unwrapConfirmation.ts
|
|
3
|
-
/** `cause` is the first collected error on purpose: `BaseError` overwrites its
|
|
4
|
-
* stack with `getRootCause(cause).stack`, and an `AggregateError` has no
|
|
5
|
-
* `cause`, so without it the stack would point at this file. */
|
|
6
|
-
const chainErrors = (errors, message) => errors.length ? new AggregateError(errors, message, { cause: errors[0] }) : void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Returns the confirmed value, or throws the error the integrator sees.
|
|
9
|
-
*
|
|
10
|
-
* Both wait tasks map the same three outcomes onto the same two error classes,
|
|
11
|
-
* so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must
|
|
12
|
-
* stay distinct: collapsing them reported a live RPC defect as an expired
|
|
13
|
-
* transaction.
|
|
14
|
-
*/
|
|
15
|
-
function unwrapConfirmation(result, messages) {
|
|
16
|
-
if (result.kind === "rpc-unavailable") throw new RPCError(LiFiErrorCode.RpcUnavailable, messages.rpcUnavailable, chainErrors(result.errors, messages.allRpcsFailed));
|
|
17
|
-
if (result.kind === "not-confirmed") throw new TransactionError(LiFiErrorCode.TransactionExpired, messages.notConfirmed, chainErrors(result.errors, messages.someRpcsFailed));
|
|
18
|
-
return result.value;
|
|
19
|
-
}
|
|
20
|
-
//#endregion
|
|
21
|
-
export { unwrapConfirmation };
|
|
22
|
-
|
|
23
|
-
//# sourceMappingURL=unwrapConfirmation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"unwrapConfirmation.js","names":[],"sources":["../../../../src/core/tasks/unwrapConfirmation.ts"],"sourcesContent":["import { LiFiErrorCode, RPCError, TransactionError } from '@lifi/sdk'\nimport type { RaceResult } from '../../confirmation/raceRpcs.js'\n\n/** Only the nouns differ between the standard and bundle paths. */\nexport type ConfirmationMessages = {\n /** Every branch failed: an outage, not a verdict about the transaction. */\n rpcUnavailable: string\n /** A branch polled to its deadline and saw nothing. */\n notConfirmed: string\n /** Heading of the `AggregateError` chained onto `rpcUnavailable`. */\n allRpcsFailed: string\n /** Heading of the `AggregateError` chained onto `notConfirmed`. */\n someRpcsFailed: string\n}\n\n/** `cause` is the first collected error on purpose: `BaseError` overwrites its\n * stack with `getRootCause(cause).stack`, and an `AggregateError` has no\n * `cause`, so without it the stack would point at this file. */\nconst chainErrors = (\n errors: Error[],\n message: string\n): AggregateError | undefined =>\n errors.length\n ? new AggregateError(errors, message, { cause: errors[0] })\n : undefined\n\n/**\n * Returns the confirmed value, or throws the error the integrator sees.\n *\n * Both wait tasks map the same three outcomes onto the same two error classes,\n * so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must\n * stay distinct: collapsing them reported a live RPC defect as an expired\n * transaction.\n */\nexport function unwrapConfirmation<T>(\n result: RaceResult<T>,\n messages: ConfirmationMessages\n): T {\n if (result.kind === 'rpc-unavailable') {\n throw new RPCError(\n LiFiErrorCode.RpcUnavailable,\n messages.rpcUnavailable,\n chainErrors(result.errors, messages.allRpcsFailed)\n )\n }\n\n if (result.kind === 'not-confirmed') {\n // The verdict came from a branch that polled to its deadline and saw\n // nothing, but other branches may have died trying - and their errors are\n // the only trail explaining, say, an endpoint that never answered.\n throw new TransactionError(\n LiFiErrorCode.TransactionExpired,\n messages.notConfirmed,\n chainErrors(result.errors, messages.someRpcsFailed)\n )\n }\n\n return result.value\n}\n"],"mappings":";;;;;AAkBA,MAAM,eACJ,QACA,YAEA,OAAO,SACH,IAAI,eAAe,QAAQ,SAAS,EAAE,OAAO,OAAO,GAAG,CAAC,IACxD,KAAA;;;;;;;;;AAUN,SAAgB,mBACd,QACA,UACG;CACH,IAAI,OAAO,SAAS,mBAClB,MAAM,IAAI,SACR,cAAc,gBACd,SAAS,gBACT,YAAY,OAAO,QAAQ,SAAS,aAAa,CACnD;CAGF,IAAI,OAAO,SAAS,iBAIlB,MAAM,IAAI,iBACR,cAAc,oBACd,SAAS,cACT,YAAY,OAAO,QAAQ,SAAS,cAAc,CACpD;CAGF,OAAO,OAAO;AAChB"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { LiFiErrorCode, RPCError, TransactionError } from '@lifi/sdk'
|
|
2
|
-
import type { RaceResult } from '../../confirmation/raceRpcs.js'
|
|
3
|
-
|
|
4
|
-
/** Only the nouns differ between the standard and bundle paths. */
|
|
5
|
-
export type ConfirmationMessages = {
|
|
6
|
-
/** Every branch failed: an outage, not a verdict about the transaction. */
|
|
7
|
-
rpcUnavailable: string
|
|
8
|
-
/** A branch polled to its deadline and saw nothing. */
|
|
9
|
-
notConfirmed: string
|
|
10
|
-
/** Heading of the `AggregateError` chained onto `rpcUnavailable`. */
|
|
11
|
-
allRpcsFailed: string
|
|
12
|
-
/** Heading of the `AggregateError` chained onto `notConfirmed`. */
|
|
13
|
-
someRpcsFailed: string
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** `cause` is the first collected error on purpose: `BaseError` overwrites its
|
|
17
|
-
* stack with `getRootCause(cause).stack`, and an `AggregateError` has no
|
|
18
|
-
* `cause`, so without it the stack would point at this file. */
|
|
19
|
-
const chainErrors = (
|
|
20
|
-
errors: Error[],
|
|
21
|
-
message: string
|
|
22
|
-
): AggregateError | undefined =>
|
|
23
|
-
errors.length
|
|
24
|
-
? new AggregateError(errors, message, { cause: errors[0] })
|
|
25
|
-
: undefined
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Returns the confirmed value, or throws the error the integrator sees.
|
|
29
|
-
*
|
|
30
|
-
* Both wait tasks map the same three outcomes onto the same two error classes,
|
|
31
|
-
* so the mapping lives here once. `rpc-unavailable` and `not-confirmed` must
|
|
32
|
-
* stay distinct: collapsing them reported a live RPC defect as an expired
|
|
33
|
-
* transaction.
|
|
34
|
-
*/
|
|
35
|
-
export function unwrapConfirmation<T>(
|
|
36
|
-
result: RaceResult<T>,
|
|
37
|
-
messages: ConfirmationMessages
|
|
38
|
-
): T {
|
|
39
|
-
if (result.kind === 'rpc-unavailable') {
|
|
40
|
-
throw new RPCError(
|
|
41
|
-
LiFiErrorCode.RpcUnavailable,
|
|
42
|
-
messages.rpcUnavailable,
|
|
43
|
-
chainErrors(result.errors, messages.allRpcsFailed)
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (result.kind === 'not-confirmed') {
|
|
48
|
-
// The verdict came from a branch that polled to its deadline and saw
|
|
49
|
-
// nothing, but other branches may have died trying - and their errors are
|
|
50
|
-
// the only trail explaining, say, an endpoint that never answered.
|
|
51
|
-
throw new TransactionError(
|
|
52
|
-
LiFiErrorCode.TransactionExpired,
|
|
53
|
-
messages.notConfirmed,
|
|
54
|
-
chainErrors(result.errors, messages.someRpcsFailed)
|
|
55
|
-
)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
return result.value
|
|
59
|
-
}
|