-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CoW AMM Deployer] Add page to waiting transaction being indexed (#611)
* chore: add stop tx procssing page * chore: add create tx processing page
- Loading branch information
1 parent
c390668
commit 47c8a53
Showing
7 changed files
with
154 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
apps/cow-amm-deployer/src/app/amm/createtxprocessing/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return children; | ||
} |
46 changes: 46 additions & 0 deletions
46
apps/cow-amm-deployer/src/app/amm/createtxprocessing/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use client"; | ||
|
||
import { useSafeAppsSDK } from "@gnosis.pm/safe-apps-react-sdk"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { Address } from "viem"; | ||
|
||
import { Spinner } from "#/components/Spinner"; | ||
import { checkIsAmmRunning, fetchLastAmmInfo } from "#/hooks/useRunningAmmInfo"; | ||
import { ChainId } from "#/utils/chainsPublicClients"; | ||
|
||
export default function Page() { | ||
const { | ||
safe: { safeAddress, chainId }, | ||
} = useSafeAppsSDK(); | ||
const router = useRouter(); | ||
|
||
async function redirectToHomeIfAmmIsRunningAndIndexed() { | ||
const [isAmmRunning, cowAmmDataIndexed] = await Promise.all([ | ||
checkIsAmmRunning(chainId as ChainId, safeAddress as Address), | ||
fetchLastAmmInfo({ | ||
chainId: chainId as ChainId, | ||
safeAddress: safeAddress as Address, | ||
}), | ||
]); | ||
if (isAmmRunning && cowAmmDataIndexed) { | ||
router.push("/amm"); | ||
} | ||
} | ||
useEffect(() => { | ||
const intervalId = setInterval( | ||
redirectToHomeIfAmmIsRunningAndIndexed, | ||
1000, | ||
); | ||
return () => clearInterval(intervalId); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col items-center rounded-3xl px-12 py-16 md:py-20"> | ||
<div className="text-center text-3xl text-amber9"> | ||
The transaction is being processed | ||
</div> | ||
<Spinner /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
apps/cow-amm-deployer/src/app/amm/stoptxprocessing/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Layout({ children }: { children: React.ReactNode }) { | ||
return children; | ||
} |
40 changes: 40 additions & 0 deletions
40
apps/cow-amm-deployer/src/app/amm/stoptxprocessing/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"use client"; | ||
|
||
import { useSafeAppsSDK } from "@gnosis.pm/safe-apps-react-sdk"; | ||
import { useRouter } from "next/navigation"; | ||
import { useEffect } from "react"; | ||
import { Address } from "viem"; | ||
|
||
import { Spinner } from "#/components/Spinner"; | ||
import { checkIsAmmRunning } from "#/hooks/useRunningAmmInfo"; | ||
import { ChainId } from "#/utils/chainsPublicClients"; | ||
|
||
export default function Page() { | ||
const { | ||
safe: { safeAddress, chainId }, | ||
} = useSafeAppsSDK(); | ||
const router = useRouter(); | ||
|
||
async function redirectToHomeIfAmmIsNotRunning() { | ||
const isAmmRunning = await checkIsAmmRunning( | ||
chainId as ChainId, | ||
safeAddress as Address, | ||
); | ||
if (!isAmmRunning) { | ||
router.push("/amm"); | ||
} | ||
} | ||
useEffect(() => { | ||
const intervalId = setInterval(redirectToHomeIfAmmIsNotRunning, 1000); | ||
return () => clearInterval(intervalId); | ||
}, []); | ||
|
||
return ( | ||
<div className="flex h-full w-full flex-col items-center rounded-3xl px-12 py-16 md:py-20"> | ||
<div className="text-center text-3xl text-amber9"> | ||
The transaction is being processed | ||
</div> | ||
<Spinner /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters