|
1 | 1 | import { Value } from "ox"; |
| 2 | +import * as ox__AbiFunction from "ox/AbiFunction"; |
2 | 3 | import * as Bridge from "../../bridge/index.js"; |
3 | 4 | import { getCachedChain } from "../../chains/utils.js"; |
4 | 5 | import type { ThirdwebClient } from "../../client/client.js"; |
@@ -260,14 +261,22 @@ export async function getBuyWithCryptoQuote( |
260 | 261 | ); |
261 | 262 | } |
262 | 263 |
|
263 | | - const approvalData: QuoteApprovalInfo | undefined = approvalTx |
264 | | - ? { |
265 | | - chainId: firstStep.originToken.chainId, |
266 | | - tokenAddress: firstStep.originToken.address, |
267 | | - spenderAddress: approvalTx.to, |
268 | | - amountWei: quote.originAmount.toString(), |
269 | | - } |
270 | | - : undefined; |
| 264 | + let approvalData: QuoteApprovalInfo | undefined; |
| 265 | + if (approvalTx) { |
| 266 | + const abiFunction = ox__AbiFunction.from([ |
| 267 | + "function approve(address spender, uint256 amount)", |
| 268 | + ]); |
| 269 | + const [spender, amount] = ox__AbiFunction.decodeData( |
| 270 | + abiFunction, |
| 271 | + approvalTx.data, |
| 272 | + ); |
| 273 | + approvalData = { |
| 274 | + chainId: firstStep.originToken.chainId, |
| 275 | + tokenAddress: firstStep.originToken.address, |
| 276 | + spenderAddress: spender, |
| 277 | + amountWei: amount.toString(), |
| 278 | + }; |
| 279 | + } |
271 | 280 |
|
272 | 281 | const swapRoute: BuyWithCryptoQuote = { |
273 | 282 | transactionRequest: { |
@@ -341,7 +350,7 @@ export async function getBuyWithCryptoQuote( |
341 | 350 | slippageBPS: 0, |
342 | 351 | feesUSDCents: 0, |
343 | 352 | gasCostUSDCents: 0, |
344 | | - durationSeconds: 0, |
| 353 | + durationSeconds: firstStep.estimatedExecutionTimeMs / 1000, |
345 | 354 | }, |
346 | 355 |
|
347 | 356 | maxSlippageBPS: 0, |
|
0 commit comments