Repository navigation
Fix Polygon Amoy RPC, Gas Estimation, and ABI Integration #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,24 +9,25 @@ | |
| import { DEPLOYMENTS } from "@/lib/deployments-data"; | ||
| import type { Deployment } from "@/lib/deployments-data"; | ||
| import { useTranslations } from "@/lib/i18n"; | ||
| import { parseEther, formatEther } from "viem"; | ||
| import { parseEther, formatEther, parseGwei } from "viem"; | ||
| import { | ||
| useReadContract, | ||
| useWriteContract, | ||
| useWaitForTransactionReceipt, | ||
| useChainId, | ||
| useAccount, | ||
| } from "wagmi"; | ||
| import { tectonicAbi } from "@/lib/abi/Tectonic"; | ||
|
|
||
| // Mappings for different networks | ||
| const CONTRACT_ADDRESSES: Record<number, `0x${string}`> = { | ||
| 31337: "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512", // Anvil | ||
| 11155111: "0x016eed9c27848d9ba152fe2d45dd2949f3f4780d", // Sepolia | ||
| 80002: "0x016eed9c27848d9ba152fe2d45dd2949f3f4780d", // Amoy (Placeholder) | ||
| 80002: "0xfD14ac4867954173552dFB72be1321Ce1AC35834", // Amoy | ||
| 61: "0x016eed9c27848d9ba152fe2d45dd2949f3f4780d", // Ethereum Classic (Placeholder) | ||
| 8453: "0x016eed9c27848d9ba152fe2d45dd2949f3f4780d", // Base Mainnet (Placeholder) | ||
| }; | ||
| const FALLBACK_ADDRESS = "0xe7f1725e7734ce288f8367e1bb143e90bb3f0512"; | ||
|
|
||
| function getContractAddress(chainId?: number): `0x${string}` | undefined { | ||
| if (!chainId) return undefined; | ||
|
|
@@ -88,41 +89,54 @@ | |
| estimateNum = estimateNum * (1 - feePct); | ||
|
|
||
| // Wagmi hooks | ||
| const { data: hash, writeContract, isPending } = useWriteContract(); | ||
| const { isLoading: isConfirming, isSuccess } = useWaitForTransactionReceipt({ hash }); | ||
| const { address: userAddress } = useAccount(); | ||
| const { data: hash, writeContract, isPending, error: writeError } = useWriteContract(); | ||
| const { isLoading: isConfirming, isSuccess, error: receiptError } = useWaitForTransactionReceipt({ hash }); | ||
| const currentChainId = useChainId(); | ||
|
|
||
| const handleSubmit = (e: React.FormEvent) => { | ||
| e.preventDefault(); | ||
| if (!amount || isNaN(valNum) || valNum <= 0 || !contractAddress) return; | ||
| if (!amount || isNaN(valNum) || valNum <= 0 || !contractAddress || !userAddress) return; | ||
|
Comment on lines
97
to
+99
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Disable submission when no wallet is connected. When Also applies to: 200-203 🤖 Prompt for AI Agents |
||
| const weiAmount = parseEther(amount); | ||
|
Comment on lines
97
to
100
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🌐 Web query:
💡 Result: In viem version 2.55.2, calling Citations:
🏁 Script executed: #!/bin/bash
set -eu
file="app/deployments/[id]/DeploymentDetailClient.tsx"
printf '%s\n' '--- relevant component code ---'
sed -n '85,150p' "$file"
printf '%s\n' '--- input and submit wiring ---'
rg -n -C 3 'amount|valNum|handleSubmit|parseEther|writeContract|type="number"' "$file"
printf '%s\n' '--- viem version declarations ---'
rg -n '"viem"|"wagmi"' package.json package-lock.json pnpm-lock.yaml yarn.lock 2>/dev/null || true
python3 - <<'PY'
import re
pattern = re.compile(r'^(-?)([0-9]*)\.?([0-9]*)$')
for value in ("1e3", "1000", "1.5", "1E3"):
print(f"{value!r}: {'accepted by viem parseUnits validation' if pattern.fullmatch(value) else 'rejected by viem parseUnits validation'}")
PYRepository: StabilityNexus/Tectonic-EVM-WebUI Length of output: 7373 Handle numeric formats that When 🤖 Prompt for AI Agents |
||
|
|
||
| const txOptions = currentChainId === 80002 ? { | ||
| maxPriorityFeePerGas: parseGwei("30"), | ||
| maxFeePerGas: parseGwei("30") | ||
| } : {}; | ||
|
|
||
| if (isMint && !isEquity) { | ||
| writeContract({ | ||
| address: contractAddress, | ||
| abi: tectonicAbi, | ||
| functionName: "mint", | ||
| args: [userAddress], | ||
| value: weiAmount, | ||
| ...txOptions | ||
| }); | ||
| } else if (isMint && isEquity) { | ||
| writeContract({ | ||
| address: contractAddress, | ||
| abi: tectonicAbi, | ||
| functionName: "mintEquityCoins", | ||
| args: [userAddress], | ||
| value: weiAmount, | ||
| ...txOptions | ||
| }); | ||
| } else if (!isMint && !isEquity) { | ||
| writeContract({ | ||
| address: contractAddress, | ||
| abi: tectonicAbi, | ||
| functionName: "redeem", | ||
| args: [weiAmount], | ||
| args: [weiAmount, userAddress], | ||
| ...txOptions | ||
| }); | ||
| } else if (!isMint && isEquity) { | ||
| writeContract({ | ||
| address: contractAddress, | ||
| abi: tectonicAbi, | ||
| functionName: "redeemEquityCoins", | ||
| args: [weiAmount], | ||
| args: [weiAmount, userAddress], | ||
| ...txOptions | ||
| }); | ||
| } | ||
| }; | ||
|
|
@@ -201,6 +215,11 @@ | |
| {t("transactionConfirmed", { defaultValue: "Transaction confirmed!" })} | ||
| </div> | ||
| )} | ||
| {(writeError || receiptError) && ( | ||
| <div className="mt-2 text-center text-xs font-bold text-red-600 bg-red-50 py-2 px-3 rounded-lg border border-red-200 break-words"> | ||
| {writeError?.message || receiptError?.message} | ||
| </div> | ||
| )} | ||
| </form> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,18 @@ | ||
| import { getDefaultConfig } from '@rainbow-me/rainbowkit'; | ||
| import { classic, sepolia, hardhat, polygonAmoy, base } from 'wagmi/chains'; | ||
|
|
||
| import { http } from 'wagmi'; | ||
|
|
||
| export const config = getDefaultConfig({ | ||
| appName: 'Tectonic-EVM-WebUI', | ||
| projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID || 'c4a4f8d9b1dbbb3d5006b9ef2db5c4a7', // Fallback to public demo ID without localhost restrictions | ||
| projectId: process.env.NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID || 'b56e18d47c72ab683b10814fe9495694', // Fallback to public demo ID without localhost restrictions | ||
| chains: [classic, base, sepolia, polygonAmoy, hardhat], | ||
| transports: { | ||
| [classic.id]: http(), | ||
| [base.id]: http(), | ||
| [sepolia.id]: http(), | ||
| [polygonAmoy.id]: http('https://polygon-amoy.drpc.org'), | ||
| [hardhat.id]: http('http://127.0.0.1:8545'), | ||
| }, | ||
| ssr: true, | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 171
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 9792
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 414
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 14182
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 290
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 2531
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 828
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 16059
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 347
🏁 Script executed:
Repository: StabilityNexus/Tectonic-EVM-WebUI
Length of output: 1399
Gate the Amoy equity flow until the deployment ABI matches.
The contract exposes the receiver-aware mint and redeem selectors, but
ecPriceMint()andecPriceRedeem()are absent and both calls revert. The page must not enable equity writes against this address.🤖 Prompt for AI Agents