Remove explicit any
This commit is contained in:
parent
f7fd972516
commit
d3d6c2c24d
@ -16,9 +16,9 @@ NEXT_PUBLIC_EXAMPLE_URL=https://git.vdb.to/cerc-io/test-progressive-web-app
|
||||
# Server-side environment variables
|
||||
|
||||
# Laconic Registry Configuration
|
||||
REGISTRY_CHAIN_ID=
|
||||
REGISTRY_GQL_ENDPOINT=
|
||||
REGISTRY_RPC_ENDPOINT=
|
||||
REGISTRY_CHAIN_ID=laconic-mainnet
|
||||
REGISTRY_RPC_ENDPOINT=https://laconicd-mainnet-1.laconic.com
|
||||
REGISTRY_GQL_ENDPOINT=https://laconicd-mainnet-1.laconic.com/graphql
|
||||
REGISTRY_BOND_ID=
|
||||
REGISTRY_AUTHORITY=
|
||||
REGISTRY_USER_KEY=
|
||||
|
@ -49,7 +49,6 @@ Server-side:
|
||||
- `REGISTRY_USER_KEY` - The private key for Laconic Registry transactions (also used for LNT transfers)
|
||||
- `APP_NAME` - The name of the application (used in record creation, defaults to "gor-deploy")
|
||||
- `DEPLOYER_LRN` - The LRN of the deployer
|
||||
- `LACONIC_TRANSFER_AMOUNT` - The amount of LNT to transfer (e.g., "1000000alnt")
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -107,10 +107,10 @@ const fetchLatestCommitHash = async (repoUrl: string, provider: string): Promise
|
||||
|
||||
// Registry transaction retry helper
|
||||
export const registryTransactionWithRetry = async (
|
||||
txFn: () => Promise<any>,
|
||||
txFn: () => Promise<unknown>,
|
||||
maxRetries = 3,
|
||||
delay = 1000
|
||||
): Promise<any> => {
|
||||
): Promise<unknown> => {
|
||||
let lastError;
|
||||
|
||||
for (let attempt = 0; attempt < maxRetries; attempt++) {
|
||||
@ -161,7 +161,7 @@ export async function POST(request: NextRequest) {
|
||||
|
||||
// Verify Solana payment
|
||||
console.log('Step 0: Verifying Solana token payment...');
|
||||
const paymentAmount = parseInt(process.env.NEXT_PUBLIC_MIN_SOLANA_PAYMENT_AMOUNT || '400000000');
|
||||
const paymentAmount = parseInt(process.env.NEXT_PUBLIC_MIN_SOLANA_PAYMENT_AMOUNT!);
|
||||
const tokenAmount = new BN(paymentAmount);
|
||||
const solanaPaymentResult = await verifyUnusedSolanaPayment(connection, txHash, tokenAmount);
|
||||
|
||||
@ -202,10 +202,6 @@ export async function POST(request: NextRequest) {
|
||||
'REGISTRY_AUTHORITY',
|
||||
'REGISTRY_USER_KEY', // This is the same as the prefilled account for LNT transfers
|
||||
'DEPLOYER_LRN',
|
||||
// LNT transfer variables
|
||||
'LACONIC_TRANSFER_AMOUNT',
|
||||
// Solana specific variables
|
||||
'NEXT_PUBLIC_SOLANA_RPC_URL',
|
||||
'NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS',
|
||||
'NEXT_PUBLIC_SOLANA_TOKEN_RECIPIENT_ADDRESS'
|
||||
];
|
||||
|
@ -54,6 +54,7 @@ export default function Home() {
|
||||
try {
|
||||
// Create the Laconic Registry record (payment verification is done in the API)
|
||||
const result = await createApplicationDeploymentRequest(url, hash, solanaWalletState.publicKey);
|
||||
|
||||
if (result.status === 'success') {
|
||||
setRecordId(result.id);
|
||||
if (result.applicationRecordId) {
|
||||
@ -110,7 +111,7 @@ export default function Home() {
|
||||
<div className="text-center">
|
||||
<p className="mb-4" style={{ color: 'var(--muted-foreground)' }}>
|
||||
Payment method: <span className="font-semibold" style={{ color: 'var(--foreground)' }}>
|
||||
GOR (Solana)
|
||||
{process.env.NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL} (Solana)
|
||||
</span>
|
||||
</p>
|
||||
<button
|
||||
|
@ -25,7 +25,17 @@ export default function PaymentModal({
|
||||
const connection = useMemo(() => new Connection(SOLANA_RPC_URL), [])
|
||||
|
||||
// Get configuration from environment variables directly
|
||||
const amount = parseInt(process.env.NEXT_PUBLIC_MIN_SOLANA_PAYMENT_AMOUNT || '400000000');
|
||||
const amount = parseInt(process.env.NEXT_PUBLIC_MIN_SOLANA_PAYMENT_AMOUNT!);
|
||||
|
||||
const divisor = useMemo(() => {
|
||||
const decimalsEnv = process.env.NEXT_PUBLIC_MIN_SOLANA_TOKEN_DECIMALS;
|
||||
const decimals = parseInt(decimalsEnv!, 10);
|
||||
if (isNaN(decimals)) {
|
||||
console.warn("Invalid NEXT_PUBLIC_MIN_SOLANA_TOKEN_DECIMALS; defaulting to 6.");
|
||||
return 1e6;
|
||||
}
|
||||
return 10 ** decimals;
|
||||
}, []);
|
||||
|
||||
const recipientAddress = process.env.NEXT_PUBLIC_SOLANA_TOKEN_RECIPIENT_ADDRESS;
|
||||
|
||||
@ -84,7 +94,7 @@ export default function PaymentModal({
|
||||
<input
|
||||
id="amount"
|
||||
type="number"
|
||||
value={amount / 1e6} // Token decimals for GOR token
|
||||
value={amount / divisor}
|
||||
disabled={true} // Fixed amount for Solana tokens
|
||||
className="w-full p-3 pr-12 rounded-md"
|
||||
style={{
|
||||
|
@ -49,7 +49,8 @@ export default function URLForm({ onSubmit, disabled }: URLFormProps) {
|
||||
// All validations passed
|
||||
setError('');
|
||||
onSubmit(trimmedUrl);
|
||||
} catch (_) {
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
setError('Please enter a valid URL (e.g., https://example.com)');
|
||||
}
|
||||
};
|
||||
|
@ -57,7 +57,7 @@ export const transferLNTTokens = async (): Promise<LaconicTransferResult> => {
|
||||
|
||||
console.log('LNT transfer result:', transferResult);
|
||||
|
||||
if (!transferResult || !(transferResult as any).transactionHash) {
|
||||
if (!transferResult.transactionHash) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'LNT transfer failed - no transaction hash returned'
|
||||
@ -66,7 +66,7 @@ export const transferLNTTokens = async (): Promise<LaconicTransferResult> => {
|
||||
|
||||
return {
|
||||
success: true,
|
||||
transactionHash: (transferResult as any).transactionHash
|
||||
transactionHash: transferResult.transactionHash
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Failed to transfer LNT tokens:', error);
|
||||
|
@ -53,7 +53,7 @@ export const connectSolanaWallet = async (walletType: SolanaWalletType): Promise
|
||||
|
||||
export const disconnectSolanaWallet = async (walletType: SolanaWalletType): Promise<void> => {
|
||||
try {
|
||||
let wallet: any = null;
|
||||
let wallet = null;
|
||||
|
||||
if (walletType === 'phantom') {
|
||||
wallet = window.phantom?.solana;
|
||||
|
@ -1,16 +1,18 @@
|
||||
import { Transaction } from "@solana/web3.js";
|
||||
|
||||
// extend the global Window interface to include Solana wallets
|
||||
declare global {
|
||||
interface Window {
|
||||
phantom?: {
|
||||
solana?: {
|
||||
signAndSendTransaction(transaction: any): Promise<{ signature: string }>;
|
||||
signAndSendTransaction(transaction: Transaction): Promise<{ signature: string }>;
|
||||
connect(): Promise<{ publicKey: { toString(): string } }>;
|
||||
disconnect(): Promise<void>;
|
||||
isConnected: boolean;
|
||||
};
|
||||
};
|
||||
solflare?: {
|
||||
signAndSendTransaction(transaction: any): Promise<{ signature: string }>;
|
||||
signAndSendTransaction(transaction: Transaction): Promise<{ signature: string }>;
|
||||
connect(): Promise<{ publicKey: { toString(): string } }>;
|
||||
disconnect(): Promise<void>;
|
||||
isConnected: boolean;
|
||||
|
Loading…
Reference in New Issue
Block a user