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