Skip to content

Commit

Permalink
Merge pull request #340 from luxfi/feat/bridge2
Browse files Browse the repository at this point in the history
fixed: bridge2 notification issue
  • Loading branch information
venuswhispers authored Jan 11, 2025
2 parents e0d8b51 + 8f4fed9 commit 872f5e2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/bridge/src/components/lux/teleport/swap/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SWAP_PAIRS } from '@/components/lux/teleport/constants/settings'
import useWallet from '@/hooks/useWallet'
import useAsyncEffect from 'use-async-effect'
import { useAtom } from 'jotai'
import { useNotify } from '@/context/toast-provider'
import { useRouter } from 'next/navigation'
import { useSettings } from '@/context/settings'
import { useServerAPI } from '@/hooks/useServerAPI'
Expand Down Expand Up @@ -57,6 +58,8 @@ const Swap: FC = () => {
const [tokenPrice, setTokenPrice] = React.useState<number>(0)
const [flipInProgress, setFlipInProgress] = React.useState<boolean>(false)

const { notify } = useNotify()

// hooks
const router = useRouter()
const { serverAPI } = useServerAPI()
Expand Down Expand Up @@ -186,14 +189,15 @@ const Swap: FC = () => {
console.log('::swap creation response:', response.data.data)
router.push(`/swap/teleporter/${response.data?.data?.swap_id}`)
} catch (err) {
notify(String(err), 'warn')
console.log(err)
} finally {
setIsSubmitting(false)
}
}

const handleSwap = () => {
if (sourceNetwork && sourceAsset && destinationNetwork && destinationNetwork && destinationAddress && Number(sourceAmount) > 0) {
if (sourceNetwork && sourceAsset && destinationNetwork && destinationNetwork && destinationAddress && Number(sourceAmount) > 0 && warningMessage === 'Create Swap') {
createSwap()
setIsSubmitting(true)
}
Expand Down Expand Up @@ -317,7 +321,8 @@ const Swap: FC = () => {
!sourceAmount ||
Number(sourceAmount) <= 0 ||
isSubmitting ||
!address
!address ||
warningMessage !== 'Create Swap'
}
className="border -mb-3 border-muted-3 disabled:border-[#404040] items-center space-x-1 disabled:opacity-80 disabled:cursor-not-allowed relative w-full flex justify-center font-semibold rounded-md transform transition duration-200 ease-in-out hover:bg-primary-hover bg-primary-lux text-primary-fg disabled:hover:bg-primary-lux py-3 px-2 md:px-3 plausible-event-name=Swap+initiated"
>
Expand Down
1 change: 1 addition & 0 deletions app/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"scripts": {
"dev": "nodemon",
"db": "node dist/db.js",
"rm": "node dist/delete.js",
"nodes": "node dist/nodes.js",
"tc": "tsc",
"typecheck": "tsc",
Expand Down
29 changes: 29 additions & 0 deletions app/server/src/delete.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { prisma } from "./prisma-instance"

const main = async () => {
try {
const arvs = process.argv.slice(2)
const swapId = arvs[0]
if (swapId) {
await prisma.depositAction.deleteMany({
where: { swap_id: swapId }
})
// Delete related Transactions
await prisma.transaction.deleteMany({
where: { swap_id: swapId }
})
// Delete related Quote
await prisma.quote.deleteMany({
where: { swap_id: swapId }
})
// Finally, delete the Swap
const deletedSwap = await prisma.swap.delete({
where: { id: swapId }
})
}
} catch (err) {
//
}
}

main()

0 comments on commit 872f5e2

Please sign in to comment.