@lifi/sdk-provider-ethereum 4.2.5 → 4.2.7

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.
Files changed (166) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +9 -0
  3. package/dist/cjs/EthereumProvider.js +5 -1
  4. package/dist/cjs/EthereumProvider.js.map +1 -1
  5. package/dist/cjs/actions/waitForBatchTransactionReceipt.js +7 -2
  6. package/dist/cjs/actions/waitForBatchTransactionReceipt.js.map +1 -1
  7. package/dist/cjs/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
  8. package/dist/cjs/actions/waitForRelayedTransactionReceipt.js +19 -5
  9. package/dist/cjs/actions/waitForRelayedTransactionReceipt.js.map +1 -1
  10. package/dist/cjs/actions/waitForSafeTransactionExecution.js +2 -2
  11. package/dist/cjs/actions/waitForSafeTransactionExecution.js.map +1 -1
  12. package/dist/cjs/actions/waitForTransactionReceipt.js +2 -2
  13. package/dist/cjs/actions/waitForTransactionReceipt.js.map +1 -1
  14. package/dist/cjs/client/publicClient.js +14 -5
  15. package/dist/cjs/client/publicClient.js.map +1 -1
  16. package/dist/cjs/core/EthereumStepExecutor.js +5 -4
  17. package/dist/cjs/core/EthereumStepExecutor.js.map +1 -1
  18. package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js +2 -0
  19. package/dist/cjs/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
  20. package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js +5 -4
  21. package/dist/cjs/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
  22. package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js +10 -1
  23. package/dist/cjs/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
  24. package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js +5 -2
  25. package/dist/cjs/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
  26. package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
  27. package/dist/cjs/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
  28. package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js +2 -2
  29. package/dist/cjs/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
  30. package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js +2 -3
  31. package/dist/cjs/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
  32. package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js +1 -0
  33. package/dist/cjs/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
  34. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js +2 -0
  35. package/dist/cjs/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  36. package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js +8 -1
  37. package/dist/cjs/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
  38. package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
  39. package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -0
  40. package/dist/cjs/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
  41. package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
  42. package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +27 -0
  43. package/dist/cjs/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
  44. package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
  45. package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js +21 -0
  46. package/dist/cjs/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
  47. package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
  48. package/dist/cjs/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
  49. package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
  50. package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
  51. package/dist/cjs/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
  52. package/dist/cjs/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
  53. package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js +7 -2
  54. package/dist/cjs/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
  55. package/dist/cjs/errors/parseEthereumErrors.js +2 -1
  56. package/dist/cjs/errors/parseEthereumErrors.js.map +1 -1
  57. package/dist/cjs/types.d.ts +6 -0
  58. package/dist/cjs/types.js.map +1 -1
  59. package/dist/cjs/version.d.ts +1 -1
  60. package/dist/cjs/version.js +1 -1
  61. package/dist/cjs/version.js.map +1 -1
  62. package/dist/esm/EthereumProvider.d.ts.map +1 -1
  63. package/dist/esm/EthereumProvider.js +5 -1
  64. package/dist/esm/EthereumProvider.js.map +1 -1
  65. package/dist/esm/actions/waitForBatchTransactionReceipt.js +7 -2
  66. package/dist/esm/actions/waitForBatchTransactionReceipt.js.map +1 -1
  67. package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts +13 -1
  68. package/dist/esm/actions/waitForRelayedTransactionReceipt.d.ts.map +1 -1
  69. package/dist/esm/actions/waitForRelayedTransactionReceipt.js +19 -5
  70. package/dist/esm/actions/waitForRelayedTransactionReceipt.js.map +1 -1
  71. package/dist/esm/actions/waitForSafeTransactionExecution.js +2 -2
  72. package/dist/esm/actions/waitForSafeTransactionExecution.js.map +1 -1
  73. package/dist/esm/actions/waitForTransactionReceipt.js +2 -2
  74. package/dist/esm/actions/waitForTransactionReceipt.js.map +1 -1
  75. package/dist/esm/client/publicClient.d.ts.map +1 -1
  76. package/dist/esm/client/publicClient.js +14 -5
  77. package/dist/esm/client/publicClient.js.map +1 -1
  78. package/dist/esm/core/EthereumStepExecutor.d.ts.map +1 -1
  79. package/dist/esm/core/EthereumStepExecutor.js +6 -5
  80. package/dist/esm/core/EthereumStepExecutor.js.map +1 -1
  81. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.d.ts.map +1 -1
  82. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js +3 -1
  83. package/dist/esm/core/tasks/EthereumBatchedSignAndExecuteTask.js.map +1 -1
  84. package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js +5 -4
  85. package/dist/esm/core/tasks/EthereumCheckAllowanceTask.js.map +1 -1
  86. package/dist/esm/core/tasks/EthereumPrepareTransactionTask.d.ts.map +1 -1
  87. package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js +12 -3
  88. package/dist/esm/core/tasks/EthereumPrepareTransactionTask.js.map +1 -1
  89. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.d.ts.map +1 -1
  90. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js +6 -3
  91. package/dist/esm/core/tasks/EthereumRelayedSignAndExecuteTask.js.map +1 -1
  92. package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.d.ts.map +1 -1
  93. package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js +10 -2
  94. package/dist/esm/core/tasks/EthereumRelayedWaitForTransactionTask.js.map +1 -1
  95. package/dist/esm/core/tasks/EthereumResetAllowanceTask.js +2 -2
  96. package/dist/esm/core/tasks/EthereumResetAllowanceTask.js.map +1 -1
  97. package/dist/esm/core/tasks/EthereumSetAllowanceTask.js +2 -3
  98. package/dist/esm/core/tasks/EthereumSetAllowanceTask.js.map +1 -1
  99. package/dist/esm/core/tasks/EthereumSignAndExecuteTask.d.ts.map +1 -1
  100. package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js +2 -1
  101. package/dist/esm/core/tasks/EthereumSignAndExecuteTask.js.map +1 -1
  102. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.d.ts.map +1 -1
  103. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js +3 -1
  104. package/dist/esm/core/tasks/EthereumStandardSignAndExecuteTask.js.map +1 -1
  105. package/dist/esm/core/tasks/EthereumWaitForTransactionTask.d.ts.map +1 -1
  106. package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js +9 -2
  107. package/dist/esm/core/tasks/EthereumWaitForTransactionTask.js.map +1 -1
  108. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts +6 -0
  109. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.d.ts.map +1 -1
  110. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js +15 -1
  111. package/dist/esm/core/tasks/helpers/getEthereumExecutionStrategy.js.map +1 -1
  112. package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts +17 -0
  113. package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.d.ts.map +1 -0
  114. package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js +26 -0
  115. package/dist/esm/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.js.map +1 -0
  116. package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts +16 -0
  117. package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.d.ts.map +1 -0
  118. package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js +20 -0
  119. package/dist/esm/core/tasks/helpers/resolveAllowanceSpender.js.map +1 -0
  120. package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.d.ts.map +1 -1
  121. package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js +2 -1
  122. package/dist/esm/core/tasks/helpers/shouldCheckForAllowance.js.map +1 -1
  123. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts +5 -1
  124. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.d.ts.map +1 -1
  125. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js +8 -1
  126. package/dist/esm/core/tasks/helpers/signHyperliquidTypedData.js.map +1 -1
  127. package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts +6 -2
  128. package/dist/esm/core/tasks/helpers/signTypedDataEntries.d.ts.map +1 -1
  129. package/dist/esm/core/tasks/helpers/signTypedDataEntries.js +7 -2
  130. package/dist/esm/core/tasks/helpers/signTypedDataEntries.js.map +1 -1
  131. package/dist/esm/errors/parseEthereumErrors.d.ts.map +1 -1
  132. package/dist/esm/errors/parseEthereumErrors.js +2 -1
  133. package/dist/esm/errors/parseEthereumErrors.js.map +1 -1
  134. package/dist/esm/types.d.ts +6 -0
  135. package/dist/esm/types.d.ts.map +1 -1
  136. package/dist/esm/types.js.map +1 -1
  137. package/dist/esm/version.d.ts +1 -1
  138. package/dist/esm/version.js +1 -1
  139. package/dist/esm/version.js.map +1 -1
  140. package/package.json +3 -3
  141. package/src/EthereumProvider.ts +6 -1
  142. package/src/actions/waitForBatchTransactionReceipt.ts +25 -3
  143. package/src/actions/waitForRelayedTransactionReceipt.ts +45 -10
  144. package/src/actions/waitForSafeTransactionExecution.ts +6 -2
  145. package/src/actions/waitForTransactionReceipt.ts +6 -2
  146. package/src/client/publicClient.ts +20 -8
  147. package/src/core/EthereumStepExecutor.ts +23 -9
  148. package/src/core/tasks/EthereumBatchedSignAndExecuteTask.ts +10 -0
  149. package/src/core/tasks/EthereumCheckAllowanceTask.ts +5 -7
  150. package/src/core/tasks/EthereumPrepareTransactionTask.ts +47 -4
  151. package/src/core/tasks/EthereumRelayedSignAndExecuteTask.ts +22 -2
  152. package/src/core/tasks/EthereumRelayedWaitForTransactionTask.ts +40 -8
  153. package/src/core/tasks/EthereumResetAllowanceTask.ts +3 -6
  154. package/src/core/tasks/EthereumSetAllowanceTask.ts +4 -8
  155. package/src/core/tasks/EthereumSignAndExecuteTask.ts +5 -0
  156. package/src/core/tasks/EthereumStandardSignAndExecuteTask.ts +10 -0
  157. package/src/core/tasks/EthereumWaitForTransactionTask.ts +33 -2
  158. package/src/core/tasks/helpers/getEthereumExecutionStrategy.ts +28 -0
  159. package/src/core/tasks/helpers/isAllowancePreparedForAnotherStrategy.ts +37 -0
  160. package/src/core/tasks/helpers/resolveAllowanceSpender.ts +24 -0
  161. package/src/core/tasks/helpers/shouldCheckForAllowance.ts +9 -5
  162. package/src/core/tasks/helpers/signHyperliquidTypedData.ts +9 -1
  163. package/src/core/tasks/helpers/signTypedDataEntries.ts +8 -2
  164. package/src/errors/parseEthereumErrors.ts +8 -4
  165. package/src/types.ts +6 -0
  166. package/src/version.ts +1 -1
@@ -1,13 +1,44 @@
1
- import { BaseStepExecutionTask, type TaskResult } from '@lifi/sdk'
1
+ import {
2
+ BaseStepExecutionTask,
3
+ hasOpenTransaction,
4
+ type TaskResult,
5
+ type TransactionMethodType,
6
+ } from '@lifi/sdk'
2
7
  import type { EthereumStepExecutorContext } from '../../types.js'
3
8
  import { EthereumBatchedWaitForTransactionTask } from './EthereumBatchedWaitForTransactionTask.js'
4
9
  import { EthereumRelayedWaitForTransactionTask } from './EthereumRelayedWaitForTransactionTask.js'
5
10
  import { EthereumStandardWaitForTransactionTask } from './EthereumStandardWaitForTransactionTask.js'
6
11
  import { getEthereumExecutionStrategy } from './helpers/getEthereumExecutionStrategy.js'
7
12
 
13
+ const TRANSACTION_METHOD_TYPES: readonly TransactionMethodType[] = [
14
+ 'standard',
15
+ 'batched',
16
+ 'relayed',
17
+ ]
18
+
8
19
  export class EthereumWaitForTransactionTask extends BaseStepExecutionTask {
9
20
  async run(context: EthereumStepExecutorContext): Promise<TaskResult> {
10
- const executionStrategy = await getEthereumExecutionStrategy(context)
21
+ const { step, statusManager, isBridgeExecution } = context
22
+
23
+ const action = statusManager.findAction(
24
+ step,
25
+ isBridgeExecution ? 'CROSS_CHAIN' : 'SWAP'
26
+ )
27
+ // The lane that sent the open transaction waits for it. The sign task
28
+ // stores that lane in `txType`, and a resume keeps it. The step content
29
+ // cannot always tell it again: a step that prepare sent to the relayer
30
+ // only because it had no `transactionRequest` reads as a standard or a
31
+ // batched step on resume. The guard skips a `txType` left on an action
32
+ // without an open transaction. Routes stored without `txType` derive the
33
+ // lane from the step.
34
+ const storedStrategy =
35
+ hasOpenTransaction(action) &&
36
+ action?.txType &&
37
+ TRANSACTION_METHOD_TYPES.includes(action.txType)
38
+ ? action.txType
39
+ : undefined
40
+ const executionStrategy =
41
+ storedStrategy ?? (await getEthereumExecutionStrategy(context))
11
42
  if (executionStrategy === 'batched') {
12
43
  return new EthereumBatchedWaitForTransactionTask().run(context)
13
44
  }
@@ -3,6 +3,26 @@ import { isBatchingSupported } from '../../../actions/isBatchingSupported.js'
3
3
  import type { EthereumStepExecutorContext } from '../../../types.js'
4
4
  import { isPermit2AllowanceLane } from '../../../utils/getTypedDataLane.js'
5
5
 
6
+ /**
7
+ * Retry param set by `EthereumPrepareTransactionTask`: the strategy prepare
8
+ * established when the allowance work done for `batched` did not fit it. The
9
+ * replay starts in this strategy.
10
+ */
11
+ export const STRATEGY_AFTER_PREPARE = 'strategyAfterPrepare'
12
+
13
+ // A `Record` over the union, so a new strategy fails to compile here instead of
14
+ // being ignored by the replay.
15
+ const TRANSACTION_METHOD_TYPES: Record<TransactionMethodType, true> = {
16
+ standard: true,
17
+ relayed: true,
18
+ batched: true,
19
+ }
20
+
21
+ const isTransactionMethodType = (
22
+ value: unknown
23
+ ): value is TransactionMethodType =>
24
+ typeof value === 'string' && Object.hasOwn(TRANSACTION_METHOD_TYPES, value)
25
+
6
26
  /**
7
27
  * Determines the execution strategy: 'relayed', 'batched', or 'standard'.
8
28
  * Falls back to 'standard' when EIP-5792 batching is unavailable,
@@ -32,6 +52,14 @@ export async function getEthereumExecutionStrategy(
32
52
  return executionStrategyContext
33
53
  }
34
54
 
55
+ // A replay starts in the strategy its first prepare established. Prepare
56
+ // restored the step's typed data before the replay, so nothing on the step
57
+ // shows that strategy yet.
58
+ const strategyAfterPrepare = retryParams?.[STRATEGY_AFTER_PREPARE]
59
+ if (!afterPrepare && isTransactionMethodType(strategyAfterPrepare)) {
60
+ return strategyAfterPrepare
61
+ }
62
+
35
63
  const atomicityNotReady = !!retryParams?.atomicityNotReady
36
64
  // Declared by the backend. It is the only signal that reaches the allowance
37
65
  // tasks, which run before a `transactionRequest` can exist.
@@ -0,0 +1,37 @@
1
+ import type { TransactionMethodType } from '@lifi/sdk'
2
+ import type { EthereumStepExecutorContext } from '../../../types.js'
3
+ import { resolveAllowanceSpender } from './resolveAllowanceSpender.js'
4
+
5
+ /**
6
+ * Whether the allowance work done in `preparedFor` does not fit `needed`, the
7
+ * strategy prepare established. Two things can break:
8
+ * - Calls queued for a batch are sent only by the batched task.
9
+ * - The spender: `resolvePermit2Support` never picks Permit2 for `batched`, but
10
+ * can for the other strategies. An allowance that is sufficient for the wrong
11
+ * spender queues nothing, so the calls alone do not show it.
12
+ *
13
+ * The spender recorded by `EthereumCheckAllowanceTask` is compared, because
14
+ * prepare has already replaced the step with the re-quote.
15
+ */
16
+ export const isAllowancePreparedForAnotherStrategy = async (
17
+ context: EthereumStepExecutorContext,
18
+ preparedFor: TransactionMethodType,
19
+ needed: TransactionMethodType
20
+ ): Promise<boolean> => {
21
+ if (preparedFor === needed) {
22
+ return false
23
+ }
24
+ if (preparedFor === 'batched' && context.calls.length) {
25
+ return true
26
+ }
27
+ // A signed native permit covers the allowance, and the re-quote carries it.
28
+ if (context.hasMatchingPermit) {
29
+ return false
30
+ }
31
+ const { allowanceSpender } = context
32
+ if (!allowanceSpender) {
33
+ return false
34
+ }
35
+ const { spenderAddress } = await resolveAllowanceSpender(context, needed)
36
+ return allowanceSpender.toLowerCase() !== spenderAddress?.toLowerCase()
37
+ }
@@ -0,0 +1,24 @@
1
+ import type { TransactionMethodType } from '@lifi/sdk'
2
+ import type { Address } from 'viem'
3
+ import type { EthereumStepExecutorContext } from '../../../types.js'
4
+ import { resolvePermit2Support } from './resolvePermit2Support.js'
5
+
6
+ /**
7
+ * The spender the allowance tasks check and approve in `strategy`: canonical
8
+ * Permit2 when the step takes the Permit2 flow there, `approvalAddress`
9
+ * otherwise. Every allowance task and the prepare-time check use this one
10
+ * derivation, so they cannot disagree.
11
+ */
12
+ export const resolveAllowanceSpender = async (
13
+ context: EthereumStepExecutorContext,
14
+ strategy: TransactionMethodType
15
+ ): Promise<{ permit2Supported: boolean; spenderAddress: Address }> => {
16
+ const permit2Supported = await resolvePermit2Support(context, strategy)
17
+ const { fromChain, step } = context
18
+ return {
19
+ permit2Supported,
20
+ spenderAddress: (permit2Supported
21
+ ? fromChain.permit2
22
+ : step.estimate.approvalAddress) as Address,
23
+ }
24
+ }
@@ -1,4 +1,8 @@
1
- import type { LiFiStepExtended, StatusManager } from '@lifi/sdk'
1
+ import {
2
+ hasOpenTransaction,
3
+ type LiFiStepExtended,
4
+ type StatusManager,
5
+ } from '@lifi/sdk'
2
6
 
3
7
  export const shouldCheckForAllowance = (
4
8
  step: LiFiStepExtended,
@@ -11,10 +15,10 @@ export const shouldCheckForAllowance = (
11
15
  const swapOrBridgeAction = statusManager.findAction(step, exchangeActionType)
12
16
 
13
17
  return (
14
- // No existing swap/bridge transaction is pending
15
- !swapOrBridgeAction?.txHash &&
16
- // No existing swap/bridge batch/order is pending
17
- !swapOrBridgeAction?.taskId &&
18
+ // No swap/bridge transaction (hash, batch/relay id or stored bytes) that may
19
+ // still land. A FAILED action with a final outcome does not count, so the
20
+ // allowance is checked again before the new transaction.
21
+ !hasOpenTransaction(swapOrBridgeAction) &&
18
22
  // Token is not native (address is not zero)
19
23
  !isFromNativeToken &&
20
24
  // Approval address is required for allowance checks, but may be null in special cases (e.g. direct transfers)
@@ -11,9 +11,14 @@ import type { EthereumStepExecutorContext } from '../../../types.js'
11
11
  import { getDomainChainId } from '../../../utils/getDomainChainId.js'
12
12
  import { assertValidSignature } from '../../../utils/isValidSignature.js'
13
13
 
14
+ /**
15
+ * `beforeSignature` runs right before each signature, the agent's included,
16
+ * after every await before it; it throws to stop the signing.
17
+ */
14
18
  export const signHyperliquidTypedData = async (
15
19
  context: EthereumStepExecutorContext,
16
- allowanceTypedData: TypedData[]
20
+ allowanceTypedData: TypedData[],
21
+ beforeSignature?: () => void
17
22
  ): Promise<SignedTypedData[] | undefined> => {
18
23
  const {
19
24
  step,
@@ -63,6 +68,7 @@ export const signHyperliquidTypedData = async (
63
68
  return
64
69
  }
65
70
 
71
+ beforeSignature?.()
66
72
  const signature = await getAction(
67
73
  updatedClient,
68
74
  signTypedData,
@@ -85,6 +91,7 @@ export const signHyperliquidTypedData = async (
85
91
  return
86
92
  }
87
93
 
94
+ beforeSignature?.()
88
95
  const signature = await getAction(
89
96
  updatedClient,
90
97
  signTypedData,
@@ -99,6 +106,7 @@ export const signHyperliquidTypedData = async (
99
106
  assertValidSignature(signature)
100
107
  signedResults.push({ ...typedData, signature })
101
108
  } else if (isHyperliquidOrderMessage(typedData)) {
109
+ beforeSignature?.()
102
110
  const signature = await agentAccount.signTypedData({
103
111
  domain: typedData.domain,
104
112
  types: typedData.types,
@@ -14,12 +14,17 @@ export type SignTypedDataEntriesResult =
14
14
  | { status: 'PAUSED' }
15
15
  | { status: 'COMPLETED'; signedTypedData: SignedTypedData[] }
16
16
 
17
- /** Signs the entries in order, switching chains per entry, and appends the signatures. */
17
+ /**
18
+ * Signs the entries in order, switching chains per entry, and appends the
19
+ * signatures. `beforeSignature` runs right before each wallet call, after the
20
+ * chain switch; it throws to stop the signing.
21
+ */
18
22
  export async function signTypedDataEntries(
19
23
  context: EthereumStepExecutorContext,
20
24
  entries: TypedData[],
21
25
  actionType: ExecutionActionType,
22
- actionStatus: ExecutionActionStatus = 'ACTION_REQUIRED'
26
+ actionStatus: ExecutionActionStatus = 'ACTION_REQUIRED',
27
+ beforeSignature?: () => void
23
28
  ): Promise<SignTypedDataEntriesResult> {
24
29
  const {
25
30
  step,
@@ -50,6 +55,7 @@ export async function signTypedDataEntries(
50
55
  return { status: 'PAUSED' }
51
56
  }
52
57
 
58
+ beforeSignature?.()
53
59
  const signature = await getAction(
54
60
  client,
55
61
  signTypedData,
@@ -19,10 +19,14 @@ export const parseEthereumErrors = async (
19
19
  action?: ExecutionAction,
20
20
  retryParams?: ExecuteStepRetryParams
21
21
  ): Promise<SDKError | ExecuteStepRetryError> => {
22
- if (
23
- isAtomicReadyWalletRejectedUpgradeError(e) &&
24
- !retryParams?.atomicityNotReady
25
- ) {
22
+ // A task raised it to request a replay; it is not an error to classify.
23
+ if (e instanceof ExecuteStepRetryError) {
24
+ return e
25
+ }
26
+
27
+ // `executeRoute` replays a step only once, so only the first attempt asks for
28
+ // this retry.
29
+ if (isAtomicReadyWalletRejectedUpgradeError(e) && !retryParams) {
26
30
  return new ExecuteStepRetryError(
27
31
  'Wallet rejected 7702 upgrade based on the EIP-5792 capabilities; retry with atomicityNotReady',
28
32
  { atomicityNotReady: true },
package/src/types.ts CHANGED
@@ -36,6 +36,12 @@ export interface EthereumTaskContext {
36
36
  hasMatchingPermit?: boolean
37
37
  hasAllowance?: boolean
38
38
  hasSufficientAllowance?: boolean
39
+ /**
40
+ * The spender `EthereumCheckAllowanceTask` checked the allowance against. The
41
+ * other allowance tasks approve the same one. Prepare compares it with the
42
+ * spender of the strategy it establishes.
43
+ */
44
+ allowanceSpender?: Address
39
45
  /**
40
46
  * Whether the signer can produce a Permit2-verifiable signature — the
41
47
  * in-flight or settled lookup, memoized per execution by
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export const name = '@lifi/sdk-provider-ethereum'
2
- export const version = '4.2.5'
2
+ export const version = '4.2.7'