mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-04-28 08:27:59 +00:00
Reorganize repository into monorepo structure
Restructured the project to support multiple frontend applications: - Move web app to web/ directory - Create pezkuwi-sdk-ui/ for Polkadot SDK clone (planned) - Create mobile/ directory for mobile app development - Add shared/ directory with common utilities, types, and blockchain code - Update README.md with comprehensive documentation - Remove obsolete DKSweb/ directory This monorepo structure enables better code sharing and organized development across web, mobile, and SDK UI projects.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
# Shared Code
|
||||
|
||||
This directory contains code shared between web and mobile applications.
|
||||
|
||||
## Structure
|
||||
|
||||
- **types/** - TypeScript type definitions and interfaces
|
||||
- **utils/** - Utility functions and helpers
|
||||
- **blockchain/** - Blockchain-related utilities (Polkadot API wrappers, transaction helpers)
|
||||
- **constants/** - Shared constants and configuration values
|
||||
|
||||
## Usage
|
||||
|
||||
Import shared code in your projects:
|
||||
|
||||
```typescript
|
||||
// Web project
|
||||
import { SomeType } from '../shared/types';
|
||||
import { someUtil } from '../shared/utils';
|
||||
|
||||
// Mobile project
|
||||
import { SomeType } from '../shared/types';
|
||||
```
|
||||
|
||||
## Guidelines
|
||||
|
||||
- Keep code framework-agnostic when possible
|
||||
- Add comprehensive JSDoc comments
|
||||
- Write unit tests for utilities
|
||||
- Avoid platform-specific dependencies
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Blockchain utilities and helpers
|
||||
*
|
||||
* This module provides common blockchain interaction utilities
|
||||
* that can be used across web and mobile applications.
|
||||
*/
|
||||
|
||||
export * from './polkadot';
|
||||
|
||||
// Add more blockchain utility exports as needed
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Polkadot/Substrate blockchain utilities
|
||||
*/
|
||||
|
||||
import type { BlockchainNetwork } from '../types/blockchain';
|
||||
|
||||
/**
|
||||
* Pezkuwi blockchain network configuration
|
||||
*/
|
||||
export const PEZKUWI_NETWORK: BlockchainNetwork = {
|
||||
name: 'Pezkuwi',
|
||||
endpoint: 'wss://pezkuwichain.app:9944',
|
||||
chainId: 'pezkuwi',
|
||||
};
|
||||
|
||||
/**
|
||||
* Common blockchain endpoints
|
||||
*/
|
||||
export const BLOCKCHAIN_ENDPOINTS = {
|
||||
pezkuwi: 'wss://pezkuwichain.app:9944',
|
||||
local: 'ws://127.0.0.1:9944',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Get block explorer URL for a transaction
|
||||
* @param txHash - Transaction hash
|
||||
* @returns Block explorer URL
|
||||
*/
|
||||
export function getExplorerUrl(txHash: string): string {
|
||||
// Update with your actual block explorer URL
|
||||
return `https://explorer.pezkuwichain.app/tx/${txHash}`;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Shared constants for Pezkuwi Web App Projects
|
||||
*/
|
||||
|
||||
/**
|
||||
* Application version
|
||||
*/
|
||||
export const APP_VERSION = '1.0.0';
|
||||
|
||||
/**
|
||||
* Supported languages
|
||||
*/
|
||||
export const SUPPORTED_LANGUAGES = [
|
||||
{ code: 'en', name: 'English' },
|
||||
{ code: 'tr', name: 'Türkçe' },
|
||||
{ code: 'kmr', name: 'Kurdî' },
|
||||
{ code: 'ckb', name: 'سۆرانی' },
|
||||
{ code: 'ar', name: 'العربية' },
|
||||
{ code: 'fa', name: 'فارسی' },
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* Default language
|
||||
*/
|
||||
export const DEFAULT_LANGUAGE = 'en';
|
||||
|
||||
/**
|
||||
* API timeouts (in milliseconds)
|
||||
*/
|
||||
export const TIMEOUTS = {
|
||||
API_REQUEST: 30000,
|
||||
BLOCKCHAIN_QUERY: 60000,
|
||||
TRANSACTION: 120000,
|
||||
} as const;
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Blockchain-related type definitions
|
||||
*/
|
||||
|
||||
export interface WalletAccount {
|
||||
address: string;
|
||||
name?: string;
|
||||
source?: string;
|
||||
}
|
||||
|
||||
export interface BlockchainNetwork {
|
||||
name: string;
|
||||
endpoint: string;
|
||||
chainId?: string;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
hash: string;
|
||||
from: string;
|
||||
to: string;
|
||||
amount: string;
|
||||
timestamp: number;
|
||||
status: 'pending' | 'success' | 'failed';
|
||||
}
|
||||
|
||||
// Add more blockchain types as needed
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Shared TypeScript types for Pezkuwi Web App Projects
|
||||
*
|
||||
* This file contains common type definitions used across
|
||||
* web and mobile applications.
|
||||
*/
|
||||
|
||||
// Export blockchain-related types here
|
||||
export * from './blockchain';
|
||||
|
||||
// Add more type exports as needed
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* Formatting utilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format a blockchain address for display
|
||||
* @param address - Full blockchain address
|
||||
* @param chars - Number of characters to show at start and end
|
||||
* @returns Formatted address (e.g., "0x1234...5678")
|
||||
*/
|
||||
export function formatAddress(address: string, chars = 4): string {
|
||||
if (!address) return '';
|
||||
if (address.length <= chars * 2) return address;
|
||||
return `${address.slice(0, chars)}...${address.slice(-chars)}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a number with thousand separators
|
||||
* @param value - Number to format
|
||||
* @param decimals - Number of decimal places
|
||||
* @returns Formatted number string
|
||||
*/
|
||||
export function formatNumber(value: number, decimals = 2): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
minimumFractionDigits: decimals,
|
||||
maximumFractionDigits: decimals,
|
||||
}).format(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a token amount with proper decimals
|
||||
* @param amount - Amount in smallest unit
|
||||
* @param decimals - Token decimals (e.g., 18 for most tokens)
|
||||
* @returns Formatted token amount
|
||||
*/
|
||||
export function formatTokenAmount(amount: string | number, decimals = 18): string {
|
||||
const value = typeof amount === 'string' ? parseFloat(amount) : amount;
|
||||
return formatNumber(value / Math.pow(10, decimals), 4);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Shared utility functions for Pezkuwi Web App Projects
|
||||
*/
|
||||
|
||||
export * from './formatting';
|
||||
export * from './validation';
|
||||
|
||||
// Add more utility exports as needed
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Validation utilities
|
||||
*/
|
||||
|
||||
/**
|
||||
* Validate if a string is a valid blockchain address
|
||||
* @param address - Address to validate
|
||||
* @returns True if valid, false otherwise
|
||||
*/
|
||||
export function isValidAddress(address: string): boolean {
|
||||
// Basic validation - extend based on your blockchain requirements
|
||||
if (!address) return false;
|
||||
|
||||
// Substrate/Polkadot addresses typically start with specific characters
|
||||
// and have a specific length
|
||||
return address.length >= 47 && address.length <= 48;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate if a string is a valid amount
|
||||
* @param amount - Amount to validate
|
||||
* @returns True if valid, false otherwise
|
||||
*/
|
||||
export function isValidAmount(amount: string): boolean {
|
||||
if (!amount) return false;
|
||||
const num = parseFloat(amount);
|
||||
return !isNaN(num) && num > 0;
|
||||
}
|
||||
Reference in New Issue
Block a user