diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..00b3725e Binary files /dev/null and b/.DS_Store differ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..983a913e --- /dev/null +++ b/.gitmodules @@ -0,0 +1,4 @@ +[submodule "smart_contract/lib/forge-std"] + path = smart_contract/lib/forge-std + url = https://github.com/foundry-rs/forge-std.git + diff --git a/discord-bot/.DS_Store b/discord-bot/.DS_Store new file mode 100644 index 00000000..92db3611 Binary files /dev/null and b/discord-bot/.DS_Store differ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..a65a59bb --- /dev/null +++ b/package-lock.json @@ -0,0 +1,17 @@ +{ + "name": "faucet", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "foundry-test-utility": "^0.1.1" + } + }, + "node_modules/foundry-test-utility": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/foundry-test-utility/-/foundry-test-utility-0.1.1.tgz", + "integrity": "sha512-dGUAF5U02bkTgRoIYJDvxAHC+J28jtXZqeDcDgPD0pNU/xnJCxmkLfCJU8QCncRwXDIAu3ONZDO+NaZfoyjcYQ==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..1798adbf --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "foundry-test-utility": "^0.1.1" + } +} diff --git a/smart_contract/.DS_Store b/smart_contract/.DS_Store new file mode 100644 index 00000000..322f4cb6 Binary files /dev/null and b/smart_contract/.DS_Store differ diff --git a/smart_contract/contracts/test/Faucet.t.sol b/smart_contract/contracts/test/Faucet.t.sol index 12272e04..00a4dc28 100644 --- a/smart_contract/contracts/test/Faucet.t.sol +++ b/smart_contract/contracts/test/Faucet.t.sol @@ -5,7 +5,7 @@ pragma solidity ^0.8.0; * @title Faucet - Test */ -import { CheatCodes } from 'foundry-test-utility/contracts/utils/cheatcodes.sol'; +// forge-std provides Vm via Test base; explicit CheatCodes import not needed import { Constants } from "./utils/constants.t.sol"; import { Faucet } from "../Faucet.sol"; diff --git a/smart_contract/contracts/test/utils/constants.t.sol b/smart_contract/contracts/test/utils/constants.t.sol index 86b7dfe1..9b03ba7d 100644 --- a/smart_contract/contracts/test/utils/constants.t.sol +++ b/smart_contract/contracts/test/utils/constants.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import 'foundry-test-utility/contracts/utils/console.sol'; +import 'forge-std/console.sol'; import { Errors } from './errors.t.sol'; contract Constants is Errors { diff --git a/smart_contract/contracts/test/utils/errors.t.sol b/smart_contract/contracts/test/utils/errors.t.sol index ccf010da..76f43c74 100644 --- a/smart_contract/contracts/test/utils/errors.t.sol +++ b/smart_contract/contracts/test/utils/errors.t.sol @@ -1,18 +1,14 @@ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; -import { stdJson } from 'foundry-test-utility/contracts/utils/stdJson.sol'; -import { Vm } from 'foundry-test-utility/contracts/utils/vm.sol'; -import { DSTest } from 'foundry-test-utility/contracts/utils/test.sol'; +import { stdJson } from 'forge-std/StdJson.sol'; +import { Test } from 'forge-std/Test.sol'; -contract Errors is DSTest { +contract Errors is Test { using stdJson for string; - Vm public constant vm = Vm(address(uint160(uint256(keccak256('hevm cheat code'))))); - mapping(RevertStatus => string) private _errors; - // Add a revert error to the enum of errors. enum RevertStatus { SUCCESS, SKIP_VALIDATION, @@ -25,7 +21,10 @@ contract Errors is DSTest { // Associate your error with a revert message and add it to the mapping. constructor() { - string memory json = vm.readFile('./constants/errors.json'); + // Resolve path from the Foundry project root to avoid CI working-directory issues + string memory root = vm.projectRoot(); + string memory path = string.concat(root, '/constants/errors.json'); + string memory json = vm.readFile(path); // Faucet _errors[RevertStatus.Faucet_FailSendingNativeToken] = json.readString('.Faucet.FailSendingNativeToken'); diff --git a/smart_contract/lib/forge-std b/smart_contract/lib/forge-std new file mode 160000 index 00000000..8bbcf6e3 --- /dev/null +++ b/smart_contract/lib/forge-std @@ -0,0 +1 @@ +Subproject commit 8bbcf6e3f8f62f419e5429a0bd89331c85c37824 diff --git a/smart_contract/remappings.txt b/smart_contract/remappings.txt index 0f2b00a6..e9d04c8f 100644 --- a/smart_contract/remappings.txt +++ b/smart_contract/remappings.txt @@ -1,3 +1,3 @@ hardhat/=node_modules/hardhat/ @openzeppelin/contracts/=node_modules/@openzeppelin/contracts -foundry-test-utility/contracts/=node_modules/foundry-test-utility/contracts \ No newline at end of file +forge-std/=lib/forge-std/src/ \ No newline at end of file diff --git a/web-app/app/api/request-tokens/[...params]/route.ts b/web-app/app/api/request-tokens/[...params]/route.ts index 726db36c..72a1b768 100644 --- a/web-app/app/api/request-tokens/[...params]/route.ts +++ b/web-app/app/api/request-tokens/[...params]/route.ts @@ -1,59 +1,2 @@ -import { indexers, REQUEST_TYPES } from '@/constants' -import { walletBalanceLowSlackMessage } from '@/utils/slack' -import { balance, transfer } from '@autonomys/auto-consensus' -import { activateWallet, ActivateWalletParams, ApiPromise } from '@autonomys/auto-utils' -import { NextRequest, NextResponse } from 'next/server' - -export const POST = async (req: NextRequest) => { - try { - if (!process.env.WALLET_CONSENSUS_URI) throw new Error('Missing WALLET_CONSENSUS_URI') - if (!process.env.CONSENSUS_AMOUNT && process.env.CONSENSUS_AMOUNT !== '0') - throw new Error('Missing CONSENSUS_AMOUNT') - - const pathname = req.nextUrl.pathname - const chain = pathname.split('/').slice(3)[0] - const requestType = pathname.split('/').slice(4)[0] - if (requestType !== REQUEST_TYPES.Consensus) - return NextResponse.json({ error: 'Invalid request type' }, { status: 400 }) - - const chainMatch = indexers.find((c) => c.network === chain) - if (!chainMatch) return NextResponse.json({ error: 'Invalid chain' }, { status: 400 }) - - const request = await req.json() - const { address } = request - - const { - api, - accounts: [wallet] - } = await activateWallet({ - uri: process.env.WALLET_CONSENSUS_URI, - networkId: chainMatch.network - } as ActivateWalletParams) - - // Get wallet free balance - const { free } = await balance(api as unknown as ApiPromise, wallet.address) - if ( - BigInt(free) < - BigInt((Number(process.env.SLACK_BALANCE_NOTIFICATION_THRESHOLD) * Number(process.env.CONSENSUS_AMOUNT)) / 100) - ) { - await walletBalanceLowSlackMessage(free.toString(), wallet.address) - } - - if (BigInt(free) <= BigInt(process.env.CONSENSUS_AMOUNT)) - return NextResponse.json({ error: 'Insufficient funds' }, { status: 400 }) - - // Create and sign the transfer transaction - const tx = await transfer(api as unknown as ApiPromise, address, process.env.CONSENSUS_AMOUNT) - const txResponse = await tx.signAndSend(wallet) - - await api.disconnect() - - return NextResponse.json({ - message: 'Token requested successfully', - txResponse: { hash: txResponse.toString() } - }) - } catch (error) { - console.error('Error processing token request:', error) - return NextResponse.json({ error: 'Failed to request token' }, { status: 500 }) - } -} +// Removed: consensus chain request handler (single-chain EVM only) +export {} diff --git a/web-app/components/ConnectConsensusWallet/index.tsx b/web-app/components/ConnectConsensusWallet/index.tsx index d443fcc7..ee316e08 100644 --- a/web-app/components/ConnectConsensusWallet/index.tsx +++ b/web-app/components/ConnectConsensusWallet/index.tsx @@ -1,33 +1,2 @@ -'use client' - -import { cn } from '@/utils/cn' -import React, { useCallback, useState } from 'react' -import { PreferredExtensionModal } from './PreferredExtensionModal' - -type ConnectConsensusWalletProps = { - className?: string -} - -export const ConnectConsensusWallet: React.FC = ({ className }) => { - const [isOpen, setIsOpen] = useState(false) - - const onClick = useCallback((e: React.MouseEvent) => { - e.preventDefault() - setIsOpen(true) - }, []) - const onClose = useCallback(() => setIsOpen(false), []) - - return ( - <> - - - - ) -} +// Removed in single-chain mode +export {} diff --git a/web-app/components/ConnectWalletButton.tsx b/web-app/components/ConnectWalletButton.tsx index a77db525..8b137bbc 100644 --- a/web-app/components/ConnectWalletButton.tsx +++ b/web-app/components/ConnectWalletButton.tsx @@ -1,12 +1,9 @@ -import { NetworkOptions, useNetworkStore } from '@/store/useStore' import { useConnectModal } from '@rainbow-me/rainbowkit' import { useEffect, useState } from 'react' -import { ConnectConsensusWallet } from './ConnectConsensusWallet' export const ConnectWalletButton: React.FC = () => { const [clientSide, setClientSide] = useState(false) const { openConnectModal } = useConnectModal() - const { network } = useNetworkStore() useEffect(() => { setClientSide(true) @@ -14,10 +11,6 @@ export const ConnectWalletButton: React.FC = () => { if (!clientSide) return null - if (network === NetworkOptions.CONSENSUS) { - return - } - return ( )} diff --git a/web-app/constants/networks.ts b/web-app/constants/networks.ts index e5b1f9ca..e7ae0a02 100644 --- a/web-app/constants/networks.ts +++ b/web-app/constants/networks.ts @@ -1,9 +1,9 @@ import { Chain, hardhat, mainnet } from 'wagmi/chains' export const autoEVM: Chain = { - id: 490000, - name: 'Auto-EVM - Autonomys Taurus Testnet', - network: 'auto-evm-taurus', + id: Number(process.env.NEXT_PUBLIC_FAUCET_CHAIN_ID || 0), + name: 'Auto-EVM Testnet', + network: 'auto-evm-chronos', nativeCurrency: { decimals: 18, name: 'tAI3', @@ -19,62 +19,11 @@ export const autoEVM: Chain = { }, blockExplorers: { default: { - name: 'Autonomys Taurus Blockscout Explorer', - url: 'https://blockscout.taurus.autonomys.xyz/' - } - } -} - -type ConsensusChain = { - id: string - name: string - network: string - nativeCurrency: { - decimals: number - name: string - symbol: string - } - rpcUrls: { - default: { - http: string[] - } - public: { - http: string[] - } - } - blockExplorers: { - default: { - name: string - url: string - } - } -} - -export const consensus: ConsensusChain = { - id: '-', - name: 'Consensus - Autonomys Taurus Testnet', - network: 'consensus-taurus', - nativeCurrency: { - decimals: 18, - name: 'tAI3', - symbol: 'tAI3' - }, - rpcUrls: { - default: { - http: ['wss://rpc-0.taurus.autonomys.xyz/ws'] - }, - public: { - http: ['wss://rpc-0.taurus.autonomys.xyz/ws'] - } - }, - blockExplorers: { - default: { - name: 'Autonomys Astral Explorer', - url: 'https://explorer.autonomys.xyz/taurus/consensus/' + name: 'Block Explorer', + url: process.env.NEXT_PUBLIC_EXPLORER_URL || '' } } } export const evmNetworks: Chain[] = [autoEVM, mainnet, hardhat] -export const consensusNetworks: ConsensusChain[] = [consensus] -export const networks: (Chain | ConsensusChain)[] = [...evmNetworks, ...consensusNetworks] +export const networks: Chain[] = [...evmNetworks] diff --git a/web-app/constants/routes.ts b/web-app/constants/routes.ts index 914a47f2..336ce12b 100644 --- a/web-app/constants/routes.ts +++ b/web-app/constants/routes.ts @@ -1,3 +1 @@ -export enum REQUEST_TYPES { - Consensus = 'consensus' -} +export {} diff --git a/web-app/constants/serverNetworks.ts b/web-app/constants/serverNetworks.ts index 60f0ae83..1d21445e 100644 --- a/web-app/constants/serverNetworks.ts +++ b/web-app/constants/serverNetworks.ts @@ -1,7 +1,7 @@ // constants/serverNetworks.ts export const autoEVM = { - id: 490000, - name: 'Auto-EVM - Autonomys Taurus Testnet', + id: Number(process.env.NEXT_PUBLIC_FAUCET_CHAIN_ID || 0), + name: 'Auto-EVM Testnet', network: 'auto-evm-taurus', nativeCurrency: { decimals: 18, @@ -18,8 +18,8 @@ export const autoEVM = { }, blockExplorers: { default: { - name: 'Autonomys Taurus Blockscout Explorer', - url: 'https://blockscout.taurus.autonomys.xyz/' + name: 'Block Explorer', + url: process.env.NEXT_PUBLIC_EXPLORER_URL || '' } } } diff --git a/web-app/store/useStore.ts b/web-app/store/useStore.ts index 65b6e10d..d052f4dd 100644 --- a/web-app/store/useStore.ts +++ b/web-app/store/useStore.ts @@ -4,8 +4,7 @@ import { create } from 'zustand' import { createJSONStorage, persist } from 'zustand/middleware' export enum NetworkOptions { - AUTO_EVM = 'auto-evm-taurus', - CONSENSUS = 'consensus-taurus' + AUTO_EVM = 'auto-evm-taurus' } interface NetworkState {