Skip to content

Commit

Permalink
chore: update execution to include fees
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Dec 19, 2023
1 parent 73c6acc commit 1d4b436
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 297 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,23 +93,23 @@
]
},
"dependencies": {
"@lifi/types": "10.0.0-beta.0",
"@lifi/types": "10.0.0-beta.1",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/web3.js": "^1.87.6",
"eth-rpc-errors": "^4.0.3",
"viem": "^2.0.0-beta.15"
"viem": "^2.0.0-beta.16"
},
"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^6.14.0",
"@typescript-eslint/parser": "^6.14.0",
"@typescript-eslint/eslint-plugin": "^6.15.0",
"@typescript-eslint/parser": "^6.15.0",
"@vitest/coverage-v8": "^1.0.4",
"bs58": "^5.0.0",
"eslint": "^8.55.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jsdoc": "^46.9.0",
"eslint-plugin-jsdoc": "^46.9.1",
"eslint-plugin-prettier": "^5.0.1",
"husky": "^8.0.3",
"lint-staged": "^15.2.0",
Expand Down
16 changes: 11 additions & 5 deletions src/core/EVM/EVMStepExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,17 @@ export class EVMStepExecutor extends BaseStepExecutor {
fromAmount: statusResponse.sending.amount,
toAmount: statusReceiving?.amount,
toToken: statusReceiving?.token,
gasAmount: statusResponse.sending.gasAmount,
gasAmountUSD: statusResponse.sending.gasAmountUSD,
gasPrice: statusResponse.sending.gasPrice,
gasToken: statusResponse.sending.gasToken,
gasUsed: statusResponse.sending.gasUsed,
gasCosts: [
{
amount: statusResponse.sending.gasAmount,
amountUSD: statusResponse.sending.gasAmountUSD,
token: statusResponse.sending.gasToken,
estimate: statusResponse.sending.gasUsed,
limit: statusResponse.sending.gasUsed,
price: statusResponse.sending.gasPrice,
type: 'SEND',
},
],
})
} catch (e: unknown) {
const htmlMessage = await getTransactionFailedMessage(
Expand Down
16 changes: 11 additions & 5 deletions src/core/Solana/SolanaStepExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,17 @@ export class SolanaStepExecutor extends BaseStepExecutor {
fromAmount: statusResponse.sending.amount,
toAmount: statusReceiving?.amount,
toToken: statusReceiving?.token,
gasAmount: statusResponse.sending.gasAmount,
gasAmountUSD: statusResponse.sending.gasAmountUSD,
gasPrice: statusResponse.sending.gasPrice,
gasToken: statusResponse.sending.gasToken,
gasUsed: statusResponse.sending.gasUsed,
gasCosts: [
{
amount: statusResponse.sending.gasAmount,
amountUSD: statusResponse.sending.gasAmountUSD,
token: statusResponse.sending.gasToken,
estimate: statusResponse.sending.gasUsed,
limit: statusResponse.sending.gasUsed,
price: statusResponse.sending.gasPrice,
type: 'SEND',
},
],
})
} catch (e: unknown) {
const htmlMessage = await getTransactionFailedMessage(
Expand Down
20 changes: 4 additions & 16 deletions src/core/StatusManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,12 @@ import type {
Process,
ProcessType,
Status,
Token,
} from '@lifi/types'
import { emptyExecution } from '@lifi/types'
import { executionState } from './executionState.js'
import type { LiFiStepExtended } from './types.js'
import { getProcessMessage } from './utils.js'

interface Receipt {
fromAmount?: string
toAmount?: string
toToken?: Token
gasPrice?: string
gasUsed?: string
gasToken?: Token
gasAmount?: string
gasAmountUSD?: string
}

type OptionalParameters = Partial<
Pick<
Process,
Expand Down Expand Up @@ -74,22 +62,22 @@ export class StatusManager {
* Updates the execution object of a Step.
* @param step The current step in execution
* @param status The status for the execution
* @param receipt Optional. Information about received tokens
* @param execution Optional. Information about received tokens
* @returns The step with the updated execution object
*/
updateExecution(
step: LiFiStepExtended,
status: Status,
receipt?: Receipt
execution?: Partial<Execution>
): LiFiStep {
if (!step.execution) {
throw Error("Can't update empty execution.")
}
step.execution.status = status
if (receipt) {
if (execution) {
step.execution = {
...step.execution,
...receipt,
...execution,
}
}
this.updateStepInRoute(step)
Expand Down
Loading

0 comments on commit 1d4b436

Please sign in to comment.