Organize shared code across web, mobile, and SDK UI projects

Centralized common code into shared/ folder to eliminate duplication and
improve maintainability across all three frontend projects (web, mobile,
pezkuwi-sdk-ui).

Changes:
- Added token types and constants to shared/types/tokens.ts
  - TokenInfo, PoolInfo, SwapQuote, and other DEX types
  - KNOWN_TOKENS with HEZ, PEZ, wUSDT definitions
  - Token logos (🟡🟣💵)

- Added Kurdistan color palette to shared/constants/
  - Kesk, Sor, Zer, Spî, Reş color definitions

- Added TOKEN_DISPLAY_SYMBOLS mapping (USDT vs wUSDT)

- Updated blockchain configuration in shared/blockchain/polkadot.ts
  - Added beta testnet endpoint (wss://beta-rpc.pezkuwi.art)
  - Defined DEFAULT_ENDPOINT constant

- Moved i18n to shared/i18n/
  - Centralized translation files for 6 languages (EN, TR, KMR, CKB, AR, FA)
  - Added LANGUAGES configuration with RTL support
  - Created isRTL() helper function

- Updated web and mobile to import from shared
  - web/src/types/dex.ts now re-exports from shared
  - web/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT
  - mobile/src/i18n/index.ts uses shared translations
  - mobile/src/contexts/PolkadotContext.tsx uses DEFAULT_ENDPOINT

- Updated shared/README.md with comprehensive documentation

This architecture reduces code duplication and ensures consistency across
all frontend projects.
This commit is contained in:
Claude
2025-11-14 19:48:43 +00:00
parent 2dc0696900
commit 31a0f86382
17 changed files with 684 additions and 147 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import React, { createContext, useContext, useEffect, useState, ReactNode } from
import { ApiPromise, WsProvider } from '@polkadot/api';
import { web3Accounts, web3Enable, web3FromAddress } from '@polkadot/extension-dapp';
import type { InjectedAccountWithMeta } from '@polkadot/extension-inject/types';
import { DEFAULT_ENDPOINT } from '../../../shared/blockchain/polkadot';
interface PolkadotContextType {
api: ApiPromise | null;
@@ -24,7 +25,7 @@ interface PolkadotProviderProps {
export const PolkadotProvider: React.FC<PolkadotProviderProps> = ({
children,
endpoint = 'wss://beta-rpc.pezkuwi.art' // Beta testnet RPC
endpoint = DEFAULT_ENDPOINT // Beta testnet RPC from shared config
}) => {
const [api, setApi] = useState<ApiPromise | null>(null);
const [isApiReady, setIsApiReady] = useState(false);