diff --git a/app/bridge/src/components/lux/utila/swap/progress/TokenDepositor.tsx b/app/bridge/src/components/lux/utila/swap/progress/TokenDepositor.tsx index 581aa76e..f3770297 100644 --- a/app/bridge/src/components/lux/utila/swap/progress/TokenDepositor.tsx +++ b/app/bridge/src/components/lux/utila/swap/progress/TokenDepositor.tsx @@ -15,7 +15,6 @@ import SwapItems from "./SwapItems"; import { useAtom } from "jotai"; import { useEthersSigner } from "@/lib/ethersToViem/ethers"; import { useServerAPI } from "@/hooks/useServerAPI"; -import { swap } from "formik"; interface IProps { className?: string @@ -125,6 +124,10 @@ const UserTokenDepositor: React.FC = ({ + + { + + } (undefined); -export const timeToExpireAtom = atom(0); -export const sourceAssetAtom = atom(undefined); -export const destinationNetworkAtom = atom(undefined); -export const destinationAssetAtom = atom(undefined); -export const destinationAddressAtom = atom(""); -export const sourceAmountAtom = atom(""); -export const ethPriceAtom = atom(0); -export const swapStatusAtom = atom(""); -export const swapIdAtom = atom(""); -export const userTransferTransactionAtom = atom(""); -export const bridgeMintTransactionAtom = atom(""); -export const mpcSignatureAtom = atom(""); -export const useTelepoterAtom = atom(true); +export const sourceNetworkAtom = atom(undefined) +export const timeToExpireAtom = atom(0) +export const sourceAssetAtom = atom(undefined) +export const destinationNetworkAtom = atom(undefined) +export const destinationAssetAtom = atom(undefined) +export const destinationAddressAtom = atom('') +export const sourceAmountAtom = atom('') +export const ethPriceAtom = atom(0) +export const swapStatusAtom = atom('') +export const swapIdAtom = atom('') +export const userTransferTransactionAtom = atom('') +export const bridgeMintTransactionAtom = atom('') +export const mpcSignatureAtom = atom('') +export const useTelepoterAtom = atom(true) +export const depositActionsAtom = atom([]) -export const depositAddressAtom = atom(undefined); +export const depositAddressAtom = atom(undefined) diff --git a/app/bridge/src/types/utila.ts b/app/bridge/src/types/utila.ts index 93f9b67b..829d8a86 100644 --- a/app/bridge/src/types/utila.ts +++ b/app/bridge/src/types/utila.ts @@ -1,41 +1,55 @@ export type Desposit = { - address: string, + address: string memo?: string } export type Network = { - display_name: string, - internal_name: string, - native_currency: string, - logo: string, - is_testnet: boolean, - is_featured: boolean, - average_completion_time: string, - chain_id: number | null, - status: string, - type: string, - deposit_address?: Desposit, - refuel_amount_in_usd: number, - transaction_explorer_template: string, - account_explorer_template: string, - node: string, - currencies: Token[], + display_name: string + internal_name: string + native_currency: string + logo: string + is_testnet: boolean + is_featured: boolean + average_completion_time: string + chain_id: number | null + status: string + type: string + deposit_address?: Desposit + refuel_amount_in_usd: number + transaction_explorer_template: string + account_explorer_template: string + node: string + currencies: Token[] } export type Token = { - name: string, - asset: string, - logo: string, - contract_address: string | null, - decimals: number, - status: string, - is_deposit_enabled: boolean, - is_withdrawal_enabled: boolean, - is_refuel_enabled: boolean, - max_withdrawal_amount: number, - deposit_fee: number, - withdrawal_fee: number, - source_base_fee: number, - destination_base_fee: number, + name: string + asset: string + logo: string + contract_address: string | null + decimals: number + status: string + is_deposit_enabled: boolean + is_withdrawal_enabled: boolean + is_refuel_enabled: boolean + max_withdrawal_amount: number + deposit_fee: number + withdrawal_fee: number + source_base_fee: number + destination_base_fee: number is_native: boolean +} + +export type DepositAction = { + id: number + type: string + status: string + from: string + to: string + amount: number + transaction_hash: string + max_confirmations: number + confirmations: number + created_date: Date + timestamp: Date } \ No newline at end of file diff --git a/app/server/src/lib/swaps.ts b/app/server/src/lib/swaps.ts index 01e29840..755504f5 100644 --- a/app/server/src/lib/swaps.ts +++ b/app/server/src/lib/swaps.ts @@ -399,13 +399,14 @@ export async function handlerUpdatePayoutAction(id: string, txHash: string, amou * @param destinationAddress * @returns */ -export async function handlerDepositAction(state: number, hash: string, amount: number, asset: string, sourceAddress: string, destinationAddress: string, type: string) { +export async function handlerDepositAction(state: number, hash: string, amount: number, asset: string, sourceAddress: string, destinationAddress: string, created: Date, type: string) { console.log({ sourceAddress, destinationAddress, amount, hash, status: UtilaTransactionStateMapping[state], + created, type }) const swap = await prisma.swap.findFirst({ @@ -439,7 +440,8 @@ export async function handlerDepositAction(state: number, hash: string, amount: data: { status: UtilaTransactionStateMapping[state], confirmations: state === 13 ? 10 : 0, - max_confirmations: 10 + max_confirmations: 10, + created_date: created } }) console.log(`>> Successfully Updated Deposit Action for Swap [${swap.id}]`) @@ -453,6 +455,7 @@ export async function handlerDepositAction(state: number, hash: string, amount: transaction_hash: hash, confirmations: state === 13 ? 10 : 0, max_confirmations: 10, + created_date: created, swap: { connect: { id: swap.id diff --git a/app/server/src/lib/utila.ts b/app/server/src/lib/utila.ts index 91781974..10c0c23e 100644 --- a/app/server/src/lib/utila.ts +++ b/app/server/src/lib/utila.ts @@ -209,7 +209,7 @@ export const handleTransactionCreated = async (payload: UTILA_TRANSACTION_CREATE const transfers = transaction.transfers || [] if (transfers.length === 0) throw "No transfers" - const { state, hash } = transaction + const { state, hash, createTime } = transaction const { amount, asset, sourceAddress, destinationAddress } = transfers [0]; await handlerDepositAction ( @@ -219,6 +219,7 @@ export const handleTransactionCreated = async (payload: UTILA_TRANSACTION_CREATE asset, sourceAddress?.value as string, destinationAddress?.value as string, + new Date(createTime ? Number(createTime.seconds) * 1000 : new Date()), "TRANSACTION_CREATED" ) } catch (err) { @@ -236,7 +237,9 @@ export const handleTransactionStateUpdated = async (payload: UTILA_TRANSACTION_S const transfers = transaction.transfers || [] if (transfers.length === 0) throw "No transfers" - const { state, hash } = transaction + console.log(transaction) + + const { state, hash, createTime } = transaction const { amount, asset, sourceAddress, destinationAddress } = transfers [0]; await handlerDepositAction ( @@ -246,6 +249,7 @@ export const handleTransactionStateUpdated = async (payload: UTILA_TRANSACTION_S asset, sourceAddress?.value as string, destinationAddress?.value as string, + new Date(createTime ? Number(createTime.seconds) * 1000 : new Date()), "TRANSACTION_STATE_UPDATED" ) } catch (err) {