diff --git a/DEPLOY.md b/DEPLOY.md new file mode 100644 index 00000000..ccaf1077 --- /dev/null +++ b/DEPLOY.md @@ -0,0 +1,53 @@ +# Deploying Axis to a new chain + +## Order of ceremony + +The following actions need to be carried out in order to add a new chain to Axis: + +1. Deploy the smart contracts to the new chain +2. [Add the new chain config](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#adding-a-new-chain) to the subgraph repo +3. [Deploy](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#deploy-guide) the subgraph +4. Obtain an RPC URL for the new chain from your RPC provider (e.g. Alchemy) +5. Add the new chain and deployment configuration to the [deployments](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/README.md#adding-a-new-chain-deployment) package +6. Add a cloak watcher to the [cloak](https://github.com/Axis-Fi/cloak) package +7. Confirm the new [deployments](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/README.md#adding-a-new-chain-deployment) package has been published to NPM +8. Consume the new [deployments package version](https://github.com/Axis-Fi/ui-libs/blob/main/packages/deployments/package.json) inside [launchpad](./apps/dapp/package.json) and [standalone](https://github.com/Axis-Fi/standalone-ui/blob/main/apps/dapp/package.json) +9. Test the `launchpad` and `standalone` dapp using the new chain: `pnpm dev` + +## Deploy the smart contracts + +Each chain requires the Axis smart contracts to be deployed. This is handled from the respective contract repos: + +- [axis-core](https://github.com/Axis-Fi/axis-core) +- [axis-periphery](https://github.com/Axis-Fi/axis-periphery/) +- [axis-registry](https://github.com/Axis-Fi/axis-registry) + +## Add the new chain to the subgraph + +The subgraph needs to be updated to include the new chain. This is achieved by updating the `networks.json` file in the [subgraph](https://github.com/Axis-Fi/subgraph) package. + +See the subgraph [README](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#adding-a-new-chain) for more information. + +## Deploy the subgraph + +Once the the new chain config has been added to the subgraph repo, the new subgraph can be deployed. This is done by following the subgraph [README](https://github.com/Axis-Fi/subgraph/?tab=readme-ov-file#deploy-guide). + +## Obtain an RPC URL for the new chain + +This is a manual process. The RPC URL for the new chain needs to be obtained from your RPC provider (Alchemy, Infura, etc.). Axis currently uses Alchemy. + +## Add the new chain to the deployments package + +The [deployments package](https://github.com/Axis-Fi/deployments) needs to be updated to include the new chain. + +See the deployments [README](https://github.com/Axis-Fi/deployments/?tab=readme-ov-file#adding-a-new-chain) for how to do this. + +## Add a cloak watcher to the cloak package + +The cloak package needs to be updated to include the new chain. This is achieved by updating the `cloak.json` file in the [cloak](https://github.com/Axis-Fi/cloak) package. + +See the cloak [README](https://github.com/Axis-Fi/cloak/?tab=readme-ov-file#adding-a-new-chain) for more information. + +## Update and test + +Make sure you've updated `launchpad` and `standalone` `@axis-finance/deployments` dependency to the new published version, then run `pnpm i` to install the new dependencies, and `pnpm dev` to test the dapp using the new chain. diff --git a/README.md b/README.md index 6cf246d1..14403c08 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ This Turborepo includes the following packages and applications: - `packages/ui`: Axis UI component library (shadcn + tailwind) - `config/tailwind-config`: Shared TailwindCSS configs +# Deploying Axis to a new chain + +To deploy Axis to a new chain, please follow the instructions in the [DEPLOY.md](./DEPLOY.md) file. + ## Contributing Thank you for your interest in contributing to Axis `launchpad`! Please read our [CONTRIBUTION.md](./CONTRIBUTING.md) guide to understand our development process and how to contribute effectively. diff --git a/apps/dapp/package.json b/apps/dapp/package.json index 95d0ed59..2a25fe8c 100644 --- a/apps/dapp/package.json +++ b/apps/dapp/package.json @@ -33,13 +33,13 @@ "dependencies": { "@axis-finance/abis": "0.0.3", "@axis-finance/auto-signer-provider": "^0.0.1", - "@axis-finance/cloak": "0.0.19", - "@axis-finance/curator-api": "0.0.32", - "@axis-finance/deployments": "0.0.15", - "@axis-finance/env": "0.0.19", - "@axis-finance/sdk": "0.0.42", - "@axis-finance/subgraph-client": "0.0.11", - "@axis-finance/types": "0.0.22", + "@axis-finance/cloak": "0.0.20", + "@axis-finance/curator-api": "0.0.33", + "@axis-finance/deployments": "0.0.16", + "@axis-finance/env": "0.0.20", + "@axis-finance/sdk": "0.0.43", + "@axis-finance/subgraph-client": "0.0.12", + "@axis-finance/types": "0.0.23", "@fleek-platform/sdk": "^3.5.1", "@helia/verified-fetch": "^2.3.1", "@openzeppelin/merkle-tree": "^1.0.6", diff --git a/apps/dapp/public/bsc.webp b/apps/dapp/public/bsc.webp new file mode 100644 index 00000000..fcbb0044 Binary files /dev/null and b/apps/dapp/public/bsc.webp differ diff --git a/apps/dapp/public/monad.svg b/apps/dapp/public/monad.svg new file mode 100644 index 00000000..b37e16be --- /dev/null +++ b/apps/dapp/public/monad.svg @@ -0,0 +1,4 @@ + + + + diff --git a/apps/dapp/public/sonic-logo.png b/apps/dapp/public/sonic-logo.png new file mode 100644 index 00000000..b69ef167 Binary files /dev/null and b/apps/dapp/public/sonic-logo.png differ diff --git a/apps/dapp/src/modules/auction/bid-list.tsx b/apps/dapp/src/modules/auction/bid-list.tsx index b6e081c2..e4d67722 100644 --- a/apps/dapp/src/modules/auction/bid-list.tsx +++ b/apps/dapp/src/modules/auction/bid-list.tsx @@ -150,7 +150,7 @@ export function BidList(props: BidListProps) { const [onlyUserBids, setOnlyUserBids] = React.useState(false); const { index: bidIndex } = useBidIndex( props.auction, - BigInt(bidToRefund?.bidId ?? -1), + bidToRefund?.bidId ? BigInt(bidToRefund.bidId) : undefined, ); const mappedBids = React.useMemo( @@ -181,9 +181,9 @@ export function BidList(props: BidListProps) { const isLoading = refund.isPending || refundReceipt.isLoading; const handleRefund = (bidId?: string) => { - if (bidId === undefined || bidIndex === undefined) + if (bidId === undefined || bidIndex === undefined) { throw new Error("Unable to get bidId for refund"); - + } refund.writeContract({ abi: auctionHouse.abi, address: auctionHouse.address, @@ -200,7 +200,7 @@ export function BidList(props: BidListProps) { id: "actions", cell: (info) => { const bid = info.row.original; - const isLive = props.auction.status === "live"; + const isLive = true; if (!address || !isLive) return; if (bid.bidder.toLowerCase() !== address.toLowerCase()) return; if (bid.status === "claimed" && !bid.settledAmountOut) return; diff --git a/apps/dapp/src/modules/auction/hooks/use-bid-index.ts b/apps/dapp/src/modules/auction/hooks/use-bid-index.ts index 344c3345..12d4a489 100644 --- a/apps/dapp/src/modules/auction/hooks/use-bid-index.ts +++ b/apps/dapp/src/modules/auction/hooks/use-bid-index.ts @@ -3,17 +3,21 @@ import { Auction } from "@axis-finance/types"; import React from "react"; import { useReadContract } from "wagmi"; -export function useBidIndex(auction: Auction, bidId: bigint = -1n) { +const abi = axisContracts.abis.batchCatalogue; +const BID_COUNT = 500n; + +export function useBidIndex(auction: Auction, bidId?: bigint) { const address = axisContracts.addresses[auction.chainId].batchCatalogue; - const abi = axisContracts.abis.batchCatalogue; const [startingIndex, setStartingIndex] = React.useState(0n); - const BID_COUNT = 100n; const numBidsQuery = useReadContract({ address, abi, functionName: "getNumBids", args: [BigInt(auction.lotId)], + query: { + enabled: bidId !== undefined, + }, }); const bidsQuery = useReadContract({ @@ -27,17 +31,33 @@ export function useBidIndex(auction: Auction, bidId: bigint = -1n) { }); React.useEffect(() => { - if ( - bidsQuery.isSuccess && - startingIndex + BID_COUNT < (numBidsQuery.data ?? 0n) - ) { - // Update query args to trigger a re-read - setStartingIndex((index) => index + BID_COUNT); - } - }, [bidsQuery.isSuccess]); + if (!bidsQuery.isSuccess) return; + + const isBidIdFound = + bidsQuery.data.findIndex((b: bigint) => b === bidId) !== -1; + + const noMoreBidsToSearch = startingIndex + BID_COUNT >= numBidsQuery.data!; + + if (isBidIdFound || noMoreBidsToSearch) return; + + // Update query args to trigger a re-read + setStartingIndex((index) => index + BID_COUNT); + }, [ + bidId, + bidsQuery.data, + bidsQuery.isSuccess, + numBidsQuery.data, + startingIndex, + ]); + + const batchIndex = + bidId !== undefined && bidsQuery.data ? bidsQuery.data.indexOf(bidId) : -1; + + const index = + batchIndex !== -1 ? startingIndex + BigInt(batchIndex) : undefined; return { - index: bidsQuery.data?.findIndex((b: bigint) => b === bidId), + index, ...bidsQuery, }; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33ebfb21..391949bb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -39,26 +39,26 @@ importers: specifier: ^0.0.1 version: 0.0.1(typescript@5.2.2)(viem@2.17.3) "@axis-finance/cloak": - specifier: 0.0.19 - version: 0.0.19(viem@2.17.3) + specifier: 0.0.20 + version: 0.0.20(viem@2.17.3) "@axis-finance/curator-api": - specifier: 0.0.32 - version: 0.0.32(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(wagmi@2.5.2) + specifier: 0.0.33 + version: 0.0.33(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(wagmi@2.5.2) "@axis-finance/deployments": - specifier: 0.0.15 - version: 0.0.15 + specifier: 0.0.16 + version: 0.0.16 "@axis-finance/env": - specifier: 0.0.19 - version: 0.0.19(viem@2.17.3) + specifier: 0.0.20 + version: 0.0.20(viem@2.17.3) "@axis-finance/sdk": - specifier: 0.0.42 - version: 0.0.42(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2) + specifier: 0.0.43 + version: 0.0.43(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2) "@axis-finance/subgraph-client": - specifier: 0.0.11 - version: 0.0.11(@tanstack/react-query@5.18.1)(react@18.3.1) + specifier: 0.0.12 + version: 0.0.12(@tanstack/react-query@5.18.1)(react@18.3.1) "@axis-finance/types": - specifier: 0.0.22 - version: 0.0.22(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2) + specifier: 0.0.23 + version: 0.0.23(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2) "@fleek-platform/sdk": specifier: ^3.5.1 version: 3.6.2 @@ -525,24 +525,24 @@ packages: viem: 2.17.3(typescript@5.2.2)(zod@3.24.2) dev: false - /@axis-finance/cloak@0.0.19(viem@2.17.3): + /@axis-finance/cloak@0.0.20(viem@2.17.3): resolution: { - integrity: sha512-3ANgOBaeThX2hFzzoxKONWb8h6c0X9kFXRn9IYB1Q2T6wiU184DjeYkYH1VbK6ryKJbO1JAYRYRpBo/FXepOgA==, + integrity: sha512-haRVrmao9wTAerYu6ONr3OWLaxiUAEFrJo98MxZ/cLiAi6Knarqdd665Y830xvNk/iFI1m7GqK9ekGqXYWzrXw==, } dependencies: - "@axis-finance/env": 0.0.19(viem@2.17.3) + "@axis-finance/env": 0.0.20(viem@2.17.3) transitivePeerDependencies: - viem dev: false - /@axis-finance/curator-api@0.0.32(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(wagmi@2.5.2): + /@axis-finance/curator-api@0.0.33(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(wagmi@2.5.2): resolution: { - integrity: sha512-MmL+f+LwoJq3aZvdf/GKq1GwlErkRNuX5eKWrMUWS+WlgIrU9MHSzQZIrW0SDlyVHjTl8eYw1yDxx4DSvcUsJw==, + integrity: sha512-UCga4dkd4xRIErXWwhepTy+6bRJY3xad6JBu10jMagzsoxQ6xoUIALata4N6X8tYl0vlwiO1scgpX8UHb5tKtg==, } dependencies: - "@axis-finance/sdk": 0.0.42(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2) + "@axis-finance/sdk": 0.0.43(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2) "@trpc/server": 10.45.2 cors: 2.8.5 dotenv: 16.4.7 @@ -571,24 +571,24 @@ packages: - yaml dev: false - /@axis-finance/deployments@0.0.15: + /@axis-finance/deployments@0.0.16: resolution: { - integrity: sha512-5n8n2zoYW7KCeKxw/fgdwcjpSxnURTUi2+4BI0TgnbbnCZQquyaJchAGEhxFhKw02O283YtbtOSmzH4lgvWQYw==, + integrity: sha512-fjK0l3y2T9+nXpKxwHrmWKG7e8NGAlxUcgo1QiepToLnCHOnpJsZobYY41cq87FRhgRNYRr+he/z5+P9p31mIw==, } dependencies: "@axis-finance/abis": 0.0.3 dev: false - /@axis-finance/env@0.0.19(viem@2.17.3): + /@axis-finance/env@0.0.20(viem@2.17.3): resolution: { - integrity: sha512-ZbbfqOELeJfjngMwJIMbmU/0DhNkKy1aGi2rw6HOtucT/Iqm0umV6gxH4l9kiJ6epH05fTFksp8A1Q8snVzv3A==, + integrity: sha512-OCLdLoApj1cfJOOcddIckFJOZEkNcjXhByv5WvpFAbA162O+b0Wb9tmjgDXE+9vwNDOO/PJU66eK0sONyh0ghA==, } peerDependencies: viem: 2.17.3 dependencies: - "@axis-finance/deployments": 0.0.15 + "@axis-finance/deployments": 0.0.16 viem: 2.17.3(typescript@5.2.2)(zod@3.24.2) dev: false @@ -598,10 +598,10 @@ packages: integrity: sha512-xH6l+o3u+QxBqJRQeO7jQeetQhGSSgqS2VZ0+I5caDVSuMWk0S2w5xUb8qqz7VrAlEmDvoR3MJqC8xzXRPcQZg==, } - /@axis-finance/sdk@0.0.42(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2): + /@axis-finance/sdk@0.0.43(@tanstack/react-query@5.18.1)(@trpc/server@10.45.2)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2)(viem@2.17.3)(wagmi@2.5.2)(zod@3.24.2): resolution: { - integrity: sha512-GCGo2EFy8igqL/ECrhKxifIWKVKi4w0iFFG12JNAye9PNy0o3140Bo7grp8w5rWoMUsv8X6YSKXnltOi0ntMyw==, + integrity: sha512-1LHydpAbGsjyV7zWqoXfqRtcf74zQQvxpnyLqExNqZQwp8Hyq9i2cQl1D1uh9xrpbG0KJ+iy3U9wkrcx7zH0fw==, } peerDependencies: "@tanstack/react-query": 5.18.1 @@ -610,11 +610,11 @@ packages: wagmi: 2.5.2 dependencies: "@axis-finance/abis": 0.0.3 - "@axis-finance/cloak": 0.0.19(viem@2.17.3) - "@axis-finance/deployments": 0.0.15 - "@axis-finance/env": 0.0.19(viem@2.17.3) - "@axis-finance/subgraph-client": 0.0.11(@tanstack/react-query@5.18.1)(react@18.3.1) - "@axis-finance/types": 0.0.22(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2) + "@axis-finance/cloak": 0.0.20(viem@2.17.3) + "@axis-finance/deployments": 0.0.16 + "@axis-finance/env": 0.0.20(viem@2.17.3) + "@axis-finance/subgraph-client": 0.0.12(@tanstack/react-query@5.18.1)(react@18.3.1) + "@axis-finance/types": 0.0.23(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2) "@fleek-platform/sdk": 3.6.2 "@openzeppelin/merkle-tree": 1.0.8 "@tanstack/react-query": 5.18.1(react@18.3.1) @@ -639,10 +639,10 @@ packages: - zod dev: false - /@axis-finance/subgraph-client@0.0.11(@tanstack/react-query@5.18.1)(react@18.3.1): + /@axis-finance/subgraph-client@0.0.12(@tanstack/react-query@5.18.1)(react@18.3.1): resolution: { - integrity: sha512-Bdukk3zINalLJSui26jSZaz6IZmtWi/HBlcksZe3u2gzkPoEcnw/Q7LO0xqSGKDEa4gVIokulQdt1v44a/4k1Q==, + integrity: sha512-2YqobvMMBe5Grifi2SI+D1hyyCwvgibDUw4WdsSJzM6dGTUlHUIIsmMPcE52tCOpVJc/0kExHIR8l1yIfWupAA==, } peerDependencies: "@tanstack/react-query": 5.18.1 @@ -675,14 +675,14 @@ packages: - yaml dev: false - /@axis-finance/types@0.0.22(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2): + /@axis-finance/types@0.0.23(@tanstack/react-query@5.18.1)(postcss@8.5.3)(react@18.3.1)(typescript@5.2.2): resolution: { - integrity: sha512-Rb7ql0neNaOt6/M6akQ4rfAunwblAruWfMyNSKSIprTYzRzUPMQo9Mre48MAngx6PeVPrd51lcwvsra2ZkT33A==, + integrity: sha512-BVemW6BE2eQfK6Jl9e9+FYqdWdrzbIl422vCPORUbd5KyzvTZ1Y0LbTr34o2CQbHInm/rQQKmH9CGpVaivGhpQ==, } dependencies: "@axis-finance/eslint-config": 0.0.2 - "@axis-finance/subgraph-client": 0.0.11(@tanstack/react-query@5.18.1)(react@18.3.1) + "@axis-finance/subgraph-client": 0.0.12(@tanstack/react-query@5.18.1)(react@18.3.1) "@axis-finance/tsup-config": 0.0.2(postcss@8.5.3)(typescript@5.2.2) "@axis-finance/typescript-config": 0.0.2 transitivePeerDependencies: @@ -17412,7 +17412,7 @@ packages: engines: { node: ">=12.0.0" } dependencies: readable-stream: 3.6.2 - webextension-polyfill: 0.10.0 + webextension-polyfill: 0.12.0 dev: false /external-editor@3.1.0: