Skip to content

Commit

Permalink
remove modifyOrPlaceOrder
Browse files Browse the repository at this point in the history
  • Loading branch information
sehyunc committed Feb 15, 2024
1 parent 25f57ff commit 4153449
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 70 deletions.
124 changes: 61 additions & 63 deletions trade.renegade.fi/components/panels/wallets-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,74 +298,72 @@ function HistorySection() {
return type
}
}
const TASK_TO_NAME = {
// [TaskState.Queued]: "Queued",
[TaskState.Proving]: "Proving",
[TaskState.SubmittingTx]: "Submitting Transaction",
[TaskState.FindingOpening]: "Validating",
[TaskState.UpdatingValidityProofs]: "Validating",
[TaskState.Completed]: "Completed",
}

const Content = useMemo(() => {
if (true) {
return (
<SimpleBar
style={{
minHeight: "30vh",
width: "100%",
}}
>
{tasks.map((task) => {
const textColor =
task.status?.state === "Completed" ? "green" : "white"
const TASK_TO_NAME = {
// [TaskState.Queued]: "Queued",
[TaskState.Proving]: "Proving",
[TaskState.SubmittingTx]: "Submitting Transaction",
[TaskState.FindingOpening]: "Validating",
[TaskState.UpdatingValidityProofs]: "Validating",
[TaskState.Completed]: "Completed",
}
return (
<SimpleBar
style={{
minHeight: "30vh",
width: "100%",
}}
>
{tasks.map((task) => {
const textColor =
task.status?.state === "Completed" ? "green" : "white"

const rightIcon =
task.status?.state === "Completed" ? (
<CheckIcon color="white.60" height="4" />
) : (
<Spinner color="white.60" size="xs" />
)
return (
<Flex
key={task.id}
alignItems="center"
flexDirection="row"
width="100%"
padding="4%"
borderBottom="var(--secondary-border)"
>
<Flex flexDirection="column">
<Flex alignItems="center" gap="2">
<Text
color={textColor}
fontFamily="Favorit Extended"
fontWeight="500"
>
{formatTask(task.status?.task_type)}
</Text>
<Text
color="white.60"
fontFamily="Favorit Expanded"
fontSize="0.7em"
fontWeight="500"
>
a few seconds ago
</Text>
</Flex>
<Flex alignItems="center" gap="2">
{task.status?.state !== "Completed" && <>{rightIcon}</>}
<Text color="white.80" fontSize="0.8em">
{TASK_TO_NAME[task.status?.state as TaskState]}
</Text>
</Flex>
const rightIcon =
task.status?.state === "Completed" ? (
<CheckIcon color="white.60" height="4" />
) : (
<Spinner color="white.60" size="xs" />
)
return (
<Flex
key={task.id}
alignItems="center"
flexDirection="row"
width="100%"
padding="4%"
borderBottom="var(--secondary-border)"
>
<Flex flexDirection="column">
<Flex alignItems="center" gap="2">
<Text
color={textColor}
fontFamily="Favorit Extended"
fontWeight="500"
>
{formatTask(task.status?.task_type)}
</Text>
<Text
color="white.60"
fontFamily="Favorit Expanded"
fontSize="0.7em"
fontWeight="500"
>
a few seconds ago
</Text>
</Flex>
<Flex alignItems="center" gap="2">
{task.status?.state !== "Completed" && <>{rightIcon}</>}
<Text color="white.80" fontSize="0.8em">
{TASK_TO_NAME[task.status?.state as TaskState]}
</Text>
</Flex>
</Flex>
)
})}
</SimpleBar>
)
}
</Flex>
)
})}
</SimpleBar>
)
}, [tasks])

if (!accountId) return null
Expand Down
2 changes: 1 addition & 1 deletion trade.renegade.fi/components/place-order-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function PlaceOrderButton() {
amount: BigInt(baseTokenAmount),
})
renegade.task
.modifyOrPlaceOrder(accountId, order)
.placeOrder(accountId, order)
.then(() => toast.info("Order task added to queue"))
.catch(() => toast.error("Error placing order, please try again"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export function ConfirmStep() {
amount: BigInt(baseTokenAmount),
})
renegade.task
.modifyOrPlaceOrder(accountId, order)
.placeOrder(accountId, order)
.then(([taskId]) => setTask(taskId, TaskType.PlaceOrder))
.then(() => {
const o = safeLocalStorageGetItem(`order-details-${accountId}`)
Expand Down
4 changes: 2 additions & 2 deletions trade.renegade.fi/hooks/use-balance.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { renegade } from "@/app/providers"
import { useEffect, useState } from "react"
import { useRenegade } from "@/contexts/Renegade/renegade-context"
import { Balance, BalanceId } from "@renegade-fi/renegade-js"
import { useEffect, useState } from "react"

import { renegade } from "@/app/providers"

export const useBalance = () => {
const [balances, setBalances] = useState<Record<BalanceId, Balance>>({})
Expand Down
6 changes: 3 additions & 3 deletions trade.renegade.fi/hooks/use-order.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { renegade } from "@/app/providers"
import { useEffect, useState } from "react"
import { useRenegade } from "@/contexts/Renegade/renegade-context"
import { safeLocalStorageGetItem, safeLocalStorageSetItem } from "@/lib/utils"
import { Order, OrderId } from "@renegade-fi/renegade-js"
import { useEffect, useState } from "react"

import { safeLocalStorageGetItem, safeLocalStorageSetItem } from "@/lib/utils"
import { renegade } from "@/app/providers"

export const useOrders = () => {
const { accountId } = useRenegade()
Expand Down

0 comments on commit 4153449

Please sign in to comment.