Rename SOL native to GOR native
This commit is contained in:
parent
b47103bafa
commit
75c0e146c8
@ -2,7 +2,7 @@
|
||||
|
||||
# Solana Payment Configuration
|
||||
NEXT_PUBLIC_SOLANA_RPC_URL=https://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158
|
||||
NEXT_PUBLIC_SOLANA_SOL_RPC_URL=https://rpc.gorbagana.wtf
|
||||
NEXT_PUBLIC_GORBAGANA_RPC_URL=https://rpc.gorbagana.wtf
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS=71Jvq4Epe2FCJ7JFSF7jLXdNk1Wy4Bhqd9iL6bEFELvg
|
||||
|
||||
# Multisig address
|
||||
|
123
CLAUDE.md
123
CLAUDE.md
@ -2,7 +2,7 @@
|
||||
|
||||
## Project Overview
|
||||
|
||||
**GOR Deploy** is a Next.js application that bridges Solana blockchain token payments with Laconic Registry deployments. Users pay with GOR tokens (or any configurable Solana SPL token) and the app creates deployment records in the Laconic Registry for frontend applications.
|
||||
**GOR Deploy** is a Next.js application that bridges Solana blockchain token payments with Laconic Registry deployments. Users pay with native GOR tokens or GOR SPL tokens and the app creates deployment records in the Laconic Registry for frontend applications.
|
||||
|
||||
## Quick Commands
|
||||
|
||||
@ -26,12 +26,16 @@ npm run lint # Run ESLint
|
||||
- Solana Web3.js for payments
|
||||
- @cerc-io/registry-sdk for Laconic Registry
|
||||
- CosmJS for Cosmos blockchain interactions
|
||||
- **Wallet Integration**: Phantom & Solflare
|
||||
- **Wallet Integration**: Phantom, Solflare & Backpack with context-based filtering
|
||||
- **Language**: TypeScript
|
||||
|
||||
### Key Dependencies
|
||||
- `@solana/web3.js` - Solana blockchain interactions
|
||||
- `@solana/spl-token` - SPL token handling
|
||||
- `@solana/wallet-adapter-react` - Unified wallet adapter integration
|
||||
- `@solana/wallet-adapter-phantom` - Phantom wallet adapter
|
||||
- `@solana/wallet-adapter-solflare` - Solflare wallet adapter
|
||||
- `@solana/wallet-adapter-backpack` - Backpack wallet adapter
|
||||
- `@cerc-io/registry-sdk` - Laconic Registry operations
|
||||
- `@cosmjs/stargate` - Cosmos blockchain operations
|
||||
- `axios` - HTTP requests for GitHub API
|
||||
@ -40,38 +44,58 @@ npm run lint # Run ESLint
|
||||
|
||||
## Application Flow
|
||||
|
||||
1. **Wallet Connection**: User connects Phantom or Solflare wallet
|
||||
2. **URL Input**: User enters repository URL to deploy
|
||||
3. **Payment**: Fixed amount payment in GOR/SPL tokens to configured recipient
|
||||
4. **Verification**: Server verifies Solana transaction (5-minute window)
|
||||
5. **LNT Transfer**: Server transfers LNT tokens for registry fees
|
||||
6. **Registry Records**: Creates ApplicationRecord and ApplicationDeploymentRequest
|
||||
7. **Name Mapping**: Sets LRN mappings in Laconic Registry
|
||||
1. **Payment Method Selection**: User chooses between native GOR or SPL token payment
|
||||
2. **Wallet Connection**: Compatible wallets are filtered based on payment method
|
||||
3. **URL Input**: User enters repository URL to deploy (enabled after wallet connection)
|
||||
4. **Payment**: Fixed amount payment in native GOR or GOR SPL tokens to configured recipient
|
||||
5. **Verification**: Server verifies Solana transaction (5-minute window)
|
||||
6. **LNT Transfer**: Server transfers LNT tokens for registry fees
|
||||
7. **Registry Records**: Creates ApplicationRecord and ApplicationDeploymentRequest
|
||||
8. **Name Mapping**: Sets LRN mappings in Laconic Registry
|
||||
|
||||
## Payment Method & Wallet Compatibility
|
||||
|
||||
### Native GOR Payments (`nat-gor`)
|
||||
- **Amount**: 0.01 GOR (10,000,000 lamports)
|
||||
- **Compatible Wallets**: Backpack only
|
||||
- **RPC Endpoint**: Uses `NEXT_PUBLIC_GORBAGANA_RPC_URL` for native transactions
|
||||
|
||||
### SPL Token Payments (`spl-token`)
|
||||
- **Amount**: $5 USD worth of GOR SPL tokens (dynamic pricing via Jupiter)
|
||||
- **Compatible Wallets**: Phantom, Solflare (Backpack excluded)
|
||||
- **RPC Endpoint**: Uses `NEXT_PUBLIC_SOLANA_RPC_URL` for token transactions
|
||||
|
||||
## Key Files and Components
|
||||
|
||||
### Frontend Components
|
||||
- `src/app/page.tsx` - Main application page with 3-step flow
|
||||
- `src/components/PaymentModal.tsx` - Solana payment interface
|
||||
- `src/components/SolanaConnect.tsx` - Wallet connection UI
|
||||
- `src/app/page.tsx` - Main application page with 4-step flow (Payment Method → Wallet → URL → Status)
|
||||
- `src/components/PaymentModal.tsx` - Solana payment interface with pre-selected payment method
|
||||
- `src/components/WalletProviders.tsx` - Context-aware wallet provider with filtering
|
||||
- `src/components/URLForm.tsx` - URL input form
|
||||
- `src/components/StatusDisplay.tsx` - Deployment status display
|
||||
|
||||
### Context & State Management
|
||||
- `src/contexts/PaymentMethodContext.tsx` - Global payment method state management
|
||||
- Uses React Context for payment method selection
|
||||
- Wallet filtering based on payment method context
|
||||
|
||||
### Services and Utils
|
||||
- `src/services/solana.ts` - Solana wallet and payment operations
|
||||
- `src/services/solana.ts` - Unified wallet adapter integration for payments
|
||||
- `src/services/registry.ts` - Client-side registry service wrapper
|
||||
- `src/services/laconic-transfer.ts` - LNT token transfer logic
|
||||
- `src/utils/solana-verify.ts` - Payment verification with replay protection
|
||||
- `src/config/index.ts` - Registry configuration management
|
||||
- `src/constants/payments.ts` - Payment method types and configuration
|
||||
|
||||
### API Routes
|
||||
- `src/app/api/registry/route.ts` - Main server-side registry operations
|
||||
- `src/app/api/registry/route.ts` - Main server-side registry operations with dual payment support
|
||||
|
||||
## Environment Configuration
|
||||
|
||||
### Client-side Variables (NEXT_PUBLIC_*)
|
||||
```bash
|
||||
NEXT_PUBLIC_SOLANA_RPC_URL=https://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158
|
||||
NEXT_PUBLIC_GORBAGANA_RPC_URL=https://rpc.gorbagana.wtf
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS=<SPL_TOKEN_MINT>
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_RECIPIENT_ADDRESS=<RECIPIENT_WALLET>
|
||||
NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL=GOR
|
||||
@ -95,20 +119,29 @@ DEPLOYER_LRN=<DEPLOYER_LRN>
|
||||
## Code Patterns and Conventions
|
||||
|
||||
### State Management
|
||||
- Uses React `useState` for component state
|
||||
- No global state management library
|
||||
- Uses React Context (`PaymentMethodContext`) for global payment method state
|
||||
- React `useState` for component-level state
|
||||
- Dynamic imports to avoid SSR issues with browser APIs
|
||||
- Context-driven wallet filtering
|
||||
|
||||
### Payment Architecture
|
||||
- Unified wallet adapter pattern for all three wallets
|
||||
- Payment method determines wallet availability
|
||||
- Separate RPC endpoints for native vs SPL token transactions
|
||||
- Dynamic pricing via Jupiter API for SPL tokens
|
||||
|
||||
### Error Handling
|
||||
- Comprehensive try-catch blocks in all async operations
|
||||
- User-friendly error messages in UI
|
||||
- Server-side error logging with detailed context
|
||||
- Wallet compatibility validation with clear feedback
|
||||
|
||||
### Security Best Practices
|
||||
- Environment variables for sensitive data
|
||||
- Transaction verification with replay protection
|
||||
- Proper SPL token account creation and validation
|
||||
- Private key never exposed to client-side
|
||||
- Wallet signature verification via adapters
|
||||
|
||||
## Development Workflow
|
||||
|
||||
@ -117,11 +150,18 @@ DEPLOYER_LRN=<DEPLOYER_LRN>
|
||||
2. **Services**: Add to `src/services/`
|
||||
3. **API Routes**: Add to `src/app/api/`
|
||||
4. **Types**: Update `src/types/index.ts`
|
||||
5. **Payment Methods**: Update `src/constants/payments.ts`
|
||||
|
||||
### Payment Integration
|
||||
- All payment logic in `src/services/solana.ts`
|
||||
- All payment logic unified in `src/services/solana.ts`
|
||||
- Verification logic in `src/utils/solana-verify.ts`
|
||||
- Transaction signing via wallet adapters
|
||||
- Payment method context drives wallet selection
|
||||
|
||||
### Wallet Integration
|
||||
- Add new wallet adapters to `src/components/WalletProviders.tsx`
|
||||
- Update wallet filtering logic based on payment method compatibility
|
||||
- Use `@solana/wallet-adapter-*` packages for consistent integration
|
||||
|
||||
### Registry Integration
|
||||
- Registry operations in `src/app/api/registry/route.ts`
|
||||
@ -147,8 +187,9 @@ Format: `lrn://{authority}/applications/{app-name}-{commit-hash}`
|
||||
### Solana Payment Verification
|
||||
- 5-minute transaction window
|
||||
- Amount verification against configured payment
|
||||
- Recipient address validation
|
||||
- Recipient address validation (different for native vs SPL)
|
||||
- Replay attack protection (TODO: implement used transaction tracking)
|
||||
- Payment method-specific validation logic
|
||||
|
||||
### Laconic Registry Operations
|
||||
1. **ApplicationRecord**: Repository metadata and commit info
|
||||
@ -158,20 +199,45 @@ Format: `lrn://{authority}/applications/{app-name}-{commit-hash}`
|
||||
## Common Development Tasks
|
||||
|
||||
### Adding New Wallet Support
|
||||
1. Update `SolanaWalletType` in `src/types/index.ts`
|
||||
2. Add wallet logic to `src/services/solana.ts`
|
||||
3. Update `SolanaConnect.tsx` component
|
||||
1. Install wallet adapter package: `npm install @solana/wallet-adapter-{wallet-name}`
|
||||
2. Add to `src/components/WalletProviders.tsx` wallets array
|
||||
3. Update wallet filtering logic based on payment method compatibility
|
||||
4. Test with both payment methods
|
||||
|
||||
### Adding New Payment Methods
|
||||
1. Update `PaymentMethod` type in `src/constants/payments.ts`
|
||||
2. Add payment method label to `PAYMENT_METHOD_LABELS`
|
||||
3. Update wallet filtering logic in `WalletProviders.tsx`
|
||||
4. Add payment processing logic in `src/services/solana.ts`
|
||||
5. Update verification logic in `src/utils/solana-verify.ts`
|
||||
|
||||
### Modifying Payment Verification
|
||||
- Update logic in `src/utils/solana-verify.ts`
|
||||
- Consider replay protection requirements
|
||||
- Test with various transaction types
|
||||
- Handle both native GOR and SPL token verification
|
||||
|
||||
### Registry Schema Changes
|
||||
- Update record structures in `src/app/api/registry/route.ts`
|
||||
- Ensure compatibility with Laconic Registry schema
|
||||
- Test with registry validation
|
||||
|
||||
## Payment Method Context Usage
|
||||
|
||||
The `PaymentMethodContext` drives wallet filtering:
|
||||
|
||||
```typescript
|
||||
// In components
|
||||
const { selectedPaymentMethod, setSelectedPaymentMethod } = usePaymentMethod();
|
||||
|
||||
// Wallet filtering logic
|
||||
if (selectedPaymentMethod === 'nat-gor') {
|
||||
// Show only Backpack wallet
|
||||
} else if (selectedPaymentMethod === 'spl-token') {
|
||||
// Show only Phantom and Solflare wallets
|
||||
}
|
||||
```
|
||||
|
||||
## Deployment Considerations
|
||||
|
||||
### Production Setup
|
||||
@ -179,6 +245,7 @@ Format: `lrn://{authority}/applications/{app-name}-{commit-hash}`
|
||||
- HTTPS required for wallet connections
|
||||
- Consider rate limiting for API routes
|
||||
- Monitor gas fees and LNT transfer costs
|
||||
- Ensure both RPC endpoints are reliable
|
||||
|
||||
### Docker Deployment
|
||||
- Dockerfile provided in project root
|
||||
@ -189,15 +256,18 @@ Format: `lrn://{authority}/applications/{app-name}-{commit-hash}`
|
||||
|
||||
### Common Issues
|
||||
- **Wallet connection fails**: Check HTTPS and wallet extension
|
||||
- **Transaction verification fails**: Check RPC URL and transaction timing
|
||||
- **Wrong wallet shown**: Verify payment method context is set correctly
|
||||
- **Transaction verification fails**: Check appropriate RPC URL and transaction timing
|
||||
- **Registry errors**: Verify all REGISTRY_* environment variables
|
||||
- **LNT transfer fails**: Check private key balance and permissions
|
||||
- **SPL token price errors**: Verify Jupiter API connectivity
|
||||
|
||||
### Debug Tools
|
||||
- Browser console for client-side debugging
|
||||
- Server logs for API route debugging
|
||||
- Solana Explorer for transaction verification
|
||||
- Registry CLI for direct registry interactions
|
||||
- Payment method context state in React DevTools
|
||||
|
||||
## Testing Strategy
|
||||
|
||||
@ -205,6 +275,8 @@ Format: `lrn://{authority}/applications/{app-name}-{commit-hash}`
|
||||
- Use testnet/devnet for development
|
||||
- Test transaction verification edge cases
|
||||
- Verify registry record creation and name mappings
|
||||
- Test wallet filtering with different payment methods
|
||||
- Test both native GOR and SPL token payment flows
|
||||
|
||||
## Related Projects
|
||||
|
||||
@ -219,7 +291,8 @@ This application references:
|
||||
- Transaction replay protection implemented
|
||||
- Input validation on all user inputs
|
||||
- Secure RPC endpoint usage
|
||||
- Wallet signature verification
|
||||
- Wallet signature verification via adapters
|
||||
- Payment method validation before processing
|
||||
|
||||
## Future Enhancements
|
||||
|
||||
@ -227,4 +300,6 @@ This application references:
|
||||
- Add support for custom deployment configurations
|
||||
- Enhanced error recovery and retry logic
|
||||
- Monitoring and analytics integration
|
||||
- Multi-chain payment support
|
||||
- Multi-chain payment support
|
||||
- Additional wallet adapter integrations
|
||||
- Advanced payment method configurations
|
@ -15,10 +15,10 @@ import { PaymentMethod, SOL_PAYMENT_AMOUNT_LAMPORTS } from '@/constants/payments
|
||||
import { getRecipientAddress } from '@/services/solana';
|
||||
|
||||
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required');
|
||||
assert(process.env.NEXT_PUBLIC_SOLANA_SOL_RPC_URL, 'SOLANA_SOL_RPC_URL is required');
|
||||
assert(process.env.NEXT_PUBLIC_GORBAGANA_RPC_URL, 'GORBAGANA_RPC_URL is required');
|
||||
|
||||
const SOLANA_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_RPC_URL;
|
||||
const SOLANA_SOL_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_SOL_RPC_URL;
|
||||
const SOLANA_SOL_RPC_URL = process.env.NEXT_PUBLIC_GORBAGANA_RPC_URL;
|
||||
|
||||
// Allow 20% slippage due to price fluctuations
|
||||
const ALLOWED_SLIPPAGE_FACTOR = 0.2
|
||||
@ -141,7 +141,7 @@ export const registryTransactionWithRetry = async (
|
||||
|
||||
// Helper function to get the appropriate connection based on payment method
|
||||
const getConnection = (paymentMethod: PaymentMethod): Connection => {
|
||||
if (paymentMethod === 'sol' && SOLANA_SOL_RPC_URL) {
|
||||
if (paymentMethod === 'nat-gor' && SOLANA_SOL_RPC_URL) {
|
||||
return new Connection(SOLANA_SOL_RPC_URL);
|
||||
}
|
||||
return new Connection(SOLANA_RPC_URL);
|
||||
@ -185,10 +185,10 @@ export async function POST(request: NextRequest) {
|
||||
}
|
||||
|
||||
// Validate payment method
|
||||
if (paymentMethod !== 'sol' && paymentMethod !== 'spl-token') {
|
||||
if (paymentMethod !== 'nat-gor' && paymentMethod !== 'spl-token') {
|
||||
return NextResponse.json({
|
||||
status: 'error',
|
||||
message: 'Invalid payment method. Must be "sol" or "spl-token".'
|
||||
message: 'Invalid payment method. Must be "nat-gor" or "spl-token".'
|
||||
}, { status: 400 });
|
||||
}
|
||||
} catch (error) {
|
||||
@ -206,9 +206,9 @@ export async function POST(request: NextRequest) {
|
||||
let expectedAmount: BN;
|
||||
let expectedRecipientAddress: string;
|
||||
|
||||
if (paymentMethod === 'sol') {
|
||||
if (paymentMethod === 'nat-gor') {
|
||||
expectedAmount = new BN(SOL_PAYMENT_AMOUNT_LAMPORTS);
|
||||
expectedRecipientAddress = getRecipientAddress('sol');
|
||||
expectedRecipientAddress = getRecipientAddress('nat-gor');
|
||||
} else if (paymentMethod === 'spl-token') {
|
||||
const targetUsdAmount = parseFloat(process.env.NEXT_PUBLIC_SOLANA_PAYMENT_AMOUNT_USD!);
|
||||
const mintAddress = process.env.NEXT_PUBLIC_SOLANA_TOKEN_MINT_ADDRESS!;
|
||||
|
@ -42,8 +42,8 @@ export default function Home() {
|
||||
const walletName = wallet.adapter.name.toLowerCase();
|
||||
const isBackpack = walletName.includes('backpack');
|
||||
|
||||
if (selectedPaymentMethod === 'sol') {
|
||||
return isBackpack; // Only Backpack for SOL
|
||||
if (selectedPaymentMethod === 'nat-gor') {
|
||||
return isBackpack; // Only Backpack for native GOR
|
||||
} else {
|
||||
return !isBackpack; // Only non-Backpack wallets for SPL tokens
|
||||
}
|
||||
@ -111,19 +111,19 @@ export default function Home() {
|
||||
</h2>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<button
|
||||
onClick={() => setSelectedPaymentMethod('sol')}
|
||||
onClick={() => setSelectedPaymentMethod('nat-gor')}
|
||||
className={`p-4 rounded-lg border-2 transition-colors ${
|
||||
selectedPaymentMethod === 'sol' ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'
|
||||
selectedPaymentMethod === 'nat-gor' ? 'border-blue-500 bg-blue-50' : 'border-gray-300 hover:border-gray-400'
|
||||
}`}
|
||||
style={{
|
||||
backgroundColor: selectedPaymentMethod === 'sol' ? 'var(--accent)' : 'var(--card-bg)',
|
||||
borderColor: selectedPaymentMethod === 'sol' ? 'var(--primary)' : 'var(--card-border)'
|
||||
backgroundColor: selectedPaymentMethod === 'nat-gor' ? 'var(--accent)' : 'var(--card-bg)',
|
||||
borderColor: selectedPaymentMethod === 'nat-gor' ? 'var(--primary)' : 'var(--card-border)'
|
||||
}}
|
||||
>
|
||||
<div className="text-left">
|
||||
<h3 className="font-semibold text-lg mb-2">Native SOL</h3>
|
||||
<h3 className="font-semibold text-lg mb-2">GOR (Native)</h3>
|
||||
<p className="text-sm" style={{ color: 'var(--muted-foreground)' }}>
|
||||
Pay 0.01 SOL (~$2-5 USD)
|
||||
Pay 0.01 GOR (~$2-5 USD)
|
||||
</p>
|
||||
<p className="text-xs mt-1" style={{ color: 'var(--muted-foreground)' }}>
|
||||
Compatible with: Backpack
|
||||
@ -208,8 +208,8 @@ export default function Home() {
|
||||
) : (
|
||||
<div>
|
||||
<p className="mb-4 text-sm" style={{ color: 'var(--muted-foreground)' }}>
|
||||
{selectedPaymentMethod === 'sol'
|
||||
? 'Only Backpack wallet supports SOL payments'
|
||||
{selectedPaymentMethod === 'nat-gor'
|
||||
? 'Only Backpack wallet supports native GOR payments'
|
||||
: 'Phantom and Solflare wallets support SPL token payments'
|
||||
}
|
||||
</p>
|
||||
|
@ -14,7 +14,7 @@ import { usePaymentMethod } from '@/contexts/PaymentMethodContext';
|
||||
|
||||
assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL, 'SOLANA_RPC_URL is required');
|
||||
const SOLANA_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_RPC_URL;
|
||||
const SOLANA_SOL_RPC_URL = process.env.NEXT_PUBLIC_SOLANA_SOL_RPC_URL;
|
||||
const SOLANA_SOL_RPC_URL = process.env.NEXT_PUBLIC_GORBAGANA_RPC_URL;
|
||||
|
||||
export default function PaymentModal({
|
||||
isOpen,
|
||||
@ -75,8 +75,8 @@ export default function PaymentModal({
|
||||
setError('');
|
||||
setLoadingPrice(false);
|
||||
|
||||
// Set tokenAmount for SOL payments to maintain consistency
|
||||
if (paymentMethod === 'sol') {
|
||||
// Set tokenAmount for native GOR payments to maintain consistency
|
||||
if (paymentMethod === 'nat-gor') {
|
||||
setTokenAmount(SOL_PAYMENT_AMOUNT_LAMPORTS);
|
||||
} else {
|
||||
setTokenAmount(0);
|
||||
@ -111,7 +111,7 @@ export default function PaymentModal({
|
||||
};
|
||||
|
||||
// Use different RPC connection based on payment method
|
||||
const connectionToUse = paymentMethod === 'sol' ? solConnection : directConnection;
|
||||
const connectionToUse = paymentMethod === 'nat-gor' ? solConnection : directConnection;
|
||||
|
||||
const result = await sendSolanaPayment(
|
||||
wallet.adapter,
|
||||
@ -134,8 +134,8 @@ export default function PaymentModal({
|
||||
|
||||
const getPaymentAmountDisplay = () => {
|
||||
switch (paymentMethod) {
|
||||
case 'sol':
|
||||
return `${SOL_PAYMENT_AMOUNT_LAMPORTS / LAMPORTS_PER_SOL} SOL`;
|
||||
case 'nat-gor':
|
||||
return `${SOL_PAYMENT_AMOUNT_LAMPORTS / LAMPORTS_PER_SOL} GOR`;
|
||||
case 'spl-token':
|
||||
if (loadingPrice) return 'Loading...';
|
||||
return tokenAmount > 0 ? `${(tokenAmount / Math.pow(10, tokenDecimals)).toFixed(6)} ${tokenSymbol}` : '0';
|
||||
@ -239,7 +239,7 @@ export default function PaymentModal({
|
||||
{!(paymentMethod === 'spl-token' && loadingPrice) && (
|
||||
<div className="absolute inset-y-0 right-0 flex items-center pr-3 pointer-events-none">
|
||||
<span className="text-sm font-medium" style={{ color: 'var(--muted)' }}>
|
||||
{paymentMethod === 'sol' ? 'SOL' : tokenSymbol}
|
||||
{paymentMethod === 'nat-gor' ? 'GOR (native)' : tokenSymbol}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
@ -47,8 +47,8 @@ export default function WalletProviders({ children }: WalletProvidersProps) {
|
||||
return allWallets.filter(wallet => {
|
||||
const isBackpack = wallet.name.toLowerCase().includes('backpack');
|
||||
|
||||
if (selectedPaymentMethod === 'sol') {
|
||||
return isBackpack; // Only Backpack for SOL
|
||||
if (selectedPaymentMethod === 'nat-gor') {
|
||||
return isBackpack; // Only Backpack for native GOR
|
||||
} else {
|
||||
return !isBackpack; // Only non-Backpack wallets for SPL tokens
|
||||
}
|
||||
|
@ -1,14 +1,14 @@
|
||||
// Payment configuration constants
|
||||
|
||||
// SOL payment amount in lamports (1 SOL = 1,000,000,000 lamports)
|
||||
export const SOL_PAYMENT_AMOUNT_LAMPORTS = 10000000; // 0.01 SOL
|
||||
// Native GOR payment amount in lamports (1 GOR = 1,000,000,000 lamports)
|
||||
export const SOL_PAYMENT_AMOUNT_LAMPORTS = 10000000; // 0.01 GOR native
|
||||
|
||||
// Payment method types
|
||||
export type PaymentMethod = 'sol' | 'spl-token';
|
||||
export type PaymentMethod = 'nat-gor' | 'spl-token';
|
||||
|
||||
// Payment method labels for UI
|
||||
export const PAYMENT_METHOD_LABELS: Record<PaymentMethod, string> = {
|
||||
'sol': 'SOL (Native)',
|
||||
'nat-gor': 'GOR (Native)',
|
||||
'spl-token': process.env.NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL || 'SPL Token'
|
||||
};
|
||||
|
||||
|
@ -34,7 +34,7 @@ async function findAssociatedTokenAddress(
|
||||
)[0];
|
||||
}
|
||||
|
||||
// Send SOL (native token) payment
|
||||
// Send native GOR payment
|
||||
export async function sendSolPayment(
|
||||
wallet: WalletAdapter,
|
||||
connection: Connection,
|
||||
@ -48,7 +48,7 @@ export async function sendSolPayment(
|
||||
const senderPublicKey = new PublicKey(walletPublicKey);
|
||||
const receiverPublicKey = new PublicKey(PAYMENT_RECEIVER_ADDRESS);
|
||||
|
||||
console.log('Processing SOL payment:', {
|
||||
console.log('Processing native GOR payment:', {
|
||||
sender: senderPublicKey.toBase58(),
|
||||
receiver: receiverPublicKey.toBase58(),
|
||||
amount: SOL_PAYMENT_AMOUNT_LAMPORTS
|
||||
@ -67,9 +67,9 @@ export async function sendSolPayment(
|
||||
transaction.recentBlockhash = latestBlockhash.blockhash;
|
||||
transaction.feePayer = senderPublicKey;
|
||||
|
||||
console.log('Sending SOL transaction...');
|
||||
console.log('Sending native GOR transaction...');
|
||||
const signature = await wallet.sendTransaction(transaction, connection);
|
||||
console.log('SOL transaction sent:', signature);
|
||||
console.log('Native GOR transaction sent:', signature);
|
||||
|
||||
// Confirm transaction
|
||||
const confirmation = await connection.confirmTransaction({
|
||||
@ -88,10 +88,10 @@ export async function sendSolPayment(
|
||||
transactionSignature: signature
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('SOL payment error:', error);
|
||||
console.error('Native GOR payment error:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error instanceof Error ? error.message : 'SOL payment failed'
|
||||
error: error instanceof Error ? error.message : 'Native GOR payment failed'
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -227,7 +227,7 @@ export async function sendSolanaPayment(
|
||||
}
|
||||
|
||||
switch (paymentRequest.paymentMethod) {
|
||||
case 'sol':
|
||||
case 'nat-gor':
|
||||
return await sendSolPayment(wallet, connection, walletPublicKey);
|
||||
case 'spl-token':
|
||||
const tokenAmount = new BN(paymentRequest.amount);
|
||||
@ -247,8 +247,8 @@ export async function sendSolanaPayment(
|
||||
// Helper function to get recipient address based on payment method
|
||||
export function getRecipientAddress(paymentMethod: PaymentMethod): string {
|
||||
switch (paymentMethod) {
|
||||
case 'sol':
|
||||
// For SOL payments, use the direct recipient address
|
||||
case 'nat-gor':
|
||||
// For native GOR payments, use the direct recipient address
|
||||
return PAYMENT_RECEIVER_ADDRESS;
|
||||
case 'spl-token':
|
||||
// For SPL token payments, use the associated token account
|
||||
|
@ -42,7 +42,7 @@ export interface PaymentModalProps {
|
||||
|
||||
export interface PaymentRequest {
|
||||
paymentMethod: PaymentMethod;
|
||||
amount: number; // in base units (lamports for SOL, token base units for SPL)
|
||||
amount: number; // in base units (lamports for native GOR, token base units for SPL)
|
||||
recipientAddress: string;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { Connection, PublicKey } from '@solana/web3.js';
|
||||
import { getAssociatedTokenAddressSync, TOKEN_PROGRAM_ID } from '@solana/spl-token';
|
||||
import { PaymentMethod } from '../constants/payments';
|
||||
|
||||
// Extract transaction info for SOL transfers
|
||||
// Extract transaction info for native GOR transfers
|
||||
const extractSolTransferInfo = async (
|
||||
connection: Connection,
|
||||
transactionSignature: string
|
||||
@ -20,7 +20,7 @@ const extractSolTransferInfo = async (
|
||||
);
|
||||
|
||||
if (!transferInstruction || !('parsed' in transferInstruction)) {
|
||||
throw new Error('SOL transfer instruction not found');
|
||||
throw new Error('Native GOR transfer instruction not found');
|
||||
}
|
||||
|
||||
const { info: { lamports, source, destination } } = transferInstruction.parsed;
|
||||
@ -125,7 +125,7 @@ export const verifyUnusedSolanaPayment = async (
|
||||
let authority: string;
|
||||
let destination: string;
|
||||
|
||||
if (paymentMethod === 'sol') {
|
||||
if (paymentMethod === 'nat-gor') {
|
||||
const transferInfo = await extractSolTransferInfo(connection, transactionSignature);
|
||||
amount = transferInfo.amount;
|
||||
authority = transferInfo.authority;
|
||||
@ -154,8 +154,8 @@ export const verifyUnusedSolanaPayment = async (
|
||||
// Verify recipient address
|
||||
let validRecipient = false;
|
||||
|
||||
if (paymentMethod === 'sol') {
|
||||
// For SOL payments, check direct recipient address
|
||||
if (paymentMethod === 'nat-gor') {
|
||||
// For native GOR payments, check direct recipient address
|
||||
validRecipient = destination === expectedRecipientAddress;
|
||||
} else if (paymentMethod === 'spl-token') {
|
||||
// For SPL token payments, destination should be the associated token account
|
||||
|
Loading…
Reference in New Issue
Block a user