Fix ts file names
This commit is contained in:
parent
fb78e67633
commit
4ea8e6b620
@ -22,7 +22,7 @@ npm run lint # Run ESLint
|
||||
### Tech Stack
|
||||
- **Frontend**: Next.js 15.3.1 with React 19
|
||||
- **Styling**: TailwindCSS 4
|
||||
- **Blockchain**:
|
||||
- **Blockchain**:
|
||||
- Solana Web3.js for payments
|
||||
- @cerc-io/registry-sdk for Laconic Registry
|
||||
- CosmJS for Cosmos blockchain interactions
|
||||
@ -71,13 +71,13 @@ npm run lint # Run ESLint
|
||||
|
||||
### Client-side Variables (NEXT_PUBLIC_*)
|
||||
```bash
|
||||
NEXT_PUBLIC_SOLANA_RPC_URL=https://api.mainnet-beta.solana.com
|
||||
NEXT_PUBLIC_SOLANA_RPC_URL=https://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS=<SPL_TOKEN_MINT>
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_RECIPIENT_ADDRESS=<RECIPIENT_WALLET>
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL=GOR
|
||||
NEXT_PUBLIC_SOLANA_PAYMENT_AMOUNT_USD=5
|
||||
NEXT_PUBLIC_DOMAIN_SUFFIX=.example.com
|
||||
NEXT_PUBLIC_EXAMPLE_URL=https://github.com/cerc-io/laconic-registry-cli
|
||||
NEXT_PUBLIC_EXAMPLE_URL=https://git.vdb.to/cerc-io/test-progressive-web-app
|
||||
```
|
||||
|
||||
### Server-side Variables
|
||||
|
@ -10,11 +10,14 @@ import { DENOM as ALNT_DENOM } from '@cerc-io/registry-sdk';
|
||||
import { verifyUnusedSolanaPayment } from '@/utils/solanaVerify';
|
||||
import { transferLNTTokens } from '@/services/laconicTransfer';
|
||||
import { getRegistry, getRegistryConfig } from '@/config';
|
||||
import { GetRequiredTokenInfo } from '@/services/jupiterPrice';
|
||||
import { getRequiredTokenInfo } from '@/services/jupiter-price';
|
||||
|
||||
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required');
|
||||
const SOLANA_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_RPC_URL;
|
||||
|
||||
// Allow 20% slippage due to price fluctuations
|
||||
const ALLOWED_SLIPPAGE_FACTOR = 0.2
|
||||
|
||||
// Use CAIP convention for chain ID: namespace + reference
|
||||
const SOLANA_CHAIN_ID = 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'; // Solana mainnet
|
||||
|
||||
@ -185,8 +188,8 @@ export async function POST(request: NextRequest) {
|
||||
// Calculate expected token amount based on current price
|
||||
let expectedTokenAmount: number;
|
||||
try {
|
||||
const { requiredAmount } = await GetRequiredTokenInfo(targetUsdAmount, mintAddress);
|
||||
expectedTokenAmount = Math.round(requiredAmount - 0.2 * requiredAmount); // Allow 20% slippage due to price fluctuations
|
||||
const { requiredAmountInBaseUnits } = await getRequiredTokenInfo(targetUsdAmount, mintAddress);
|
||||
expectedTokenAmount = Math.round(requiredAmountInBaseUnits - ALLOWED_SLIPPAGE_FACTOR * requiredAmountInBaseUnits);
|
||||
} catch (error) {
|
||||
console.error('Error calculating token amount:', error);
|
||||
return NextResponse.json({
|
||||
|
@ -7,7 +7,7 @@ import assert from 'assert';
|
||||
import { Connection } from '@solana/web3.js';
|
||||
|
||||
import { sendSolanaTokenPayment } from '@/services/solana';
|
||||
import { GetRequiredTokenInfo } from '@/services/jupiterPrice';
|
||||
import { getRequiredTokenInfo } from '@/services/jupiter-price';
|
||||
import { PaymentModalProps } from '@/types';
|
||||
|
||||
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required');
|
||||
@ -42,8 +42,8 @@ export default function PaymentModal({
|
||||
setError('');
|
||||
|
||||
try {
|
||||
const {requiredAmount, decimals} = await GetRequiredTokenInfo(targetUsdAmount, mintAddress)
|
||||
setTokenAmount(requiredAmount);
|
||||
const {requiredAmountInBaseUnits, decimals} = await getRequiredTokenInfo(targetUsdAmount, mintAddress)
|
||||
setTokenAmount(requiredAmountInBaseUnits);
|
||||
setTokenDecimals(decimals);
|
||||
} catch (error) {
|
||||
console.error('Error fetching token price:', error);
|
||||
|
@ -13,7 +13,7 @@ interface TokenPriceInfo {
|
||||
}
|
||||
|
||||
interface RequiredTokenInfo {
|
||||
requiredAmount: number;
|
||||
requiredAmountInBaseUnits: number;
|
||||
decimals: number;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ export async function getTokenInfo(mintAddress: string): Promise<TokenPriceInfo>
|
||||
* @param mintAddress The Solana token mint address
|
||||
* @returns The token amount (in smallest units) needed and token decimals
|
||||
*/
|
||||
export async function GetRequiredTokenInfo(targetUsdAmount: number, mintAddress: string): Promise<RequiredTokenInfo> {
|
||||
export async function getRequiredTokenInfo(targetUsdAmount: number, mintAddress: string): Promise<RequiredTokenInfo> {
|
||||
const priceInfo = await getTokenInfo(mintAddress);
|
||||
|
||||
// Calculate token amount needed
|
||||
@ -63,5 +63,5 @@ export async function GetRequiredTokenInfo(targetUsdAmount: number, mintAddress:
|
||||
// Convert to smallest units (considering decimals)
|
||||
const amountInSmallestUnits = Math.round(tokenAmount * Math.pow(10, priceInfo.decimals));
|
||||
|
||||
return {requiredAmount: amountInSmallestUnits, decimals: priceInfo.decimals};
|
||||
return {requiredAmountInBaseUnits: amountInSmallestUnits, decimals: priceInfo.decimals};
|
||||
}
|
Loading…
Reference in New Issue
Block a user