@nexuspay/sdk
Version:
🚀 Ultra-simple cross-chain wallet SDK - Initialize with just projectName + apiKey. Bulletproof gasless transactions across EVM/SVM chains with ANY social identifier support
323 lines (322 loc) • 8.62 kB
TypeScript
/**
* NexusSDK Types - Ultimate Flexible Cross-Chain Wallet Infrastructure
* Support for ANY social identifier and comprehensive token/bridging functionality
*/
export type SupportedChain = 'ethereum' | 'arbitrum' | 'solana';
export type SocialType = string;
export declare const COMMON_SOCIAL_TYPES: {
readonly EMAIL: "email";
readonly PHONE: "phone";
readonly USERNAME: "username";
readonly TWITTER: "twitter";
readonly DISCORD: "discord";
readonly TELEGRAM: "telegram";
readonly GITHUB: "github";
readonly INSTAGRAM: "instagram";
readonly TIKTOK: "tiktok";
readonly LINKEDIN: "linkedin";
readonly GAME_ID: "gameId";
readonly PLAYER_TAG: "playerTag";
readonly STEAM_ID: "steamId";
readonly EPIC_ID: "epicId";
readonly XBOX_GAMERTAG: "xboxGamertag";
readonly PSN_ID: "psnId";
readonly EMPLOYEE_ID: "employeeId";
readonly CUSTOMER_ID: "customerId";
readonly MEMBER_ID: "memberId";
readonly SUBSCRIPTION_ID: "subscriptionId";
readonly ENS: "ens";
readonly WALLET_ADDRESS: "walletAddress";
readonly NFT_HOLDER: "nftHolder";
readonly TOKEN_HOLDER: "tokenHolder";
readonly DAO_MEMBER: "daoMember";
readonly USER_UUID: "userUuid";
readonly API_KEY_HASH: "apiKeyHash";
readonly SESSION_ID: "sessionId";
readonly DEVICE_ID: "deviceId";
readonly CUSTOM: "custom";
};
export interface NexusConfig {
apiKey: string;
baseURL?: string;
timeout?: number;
enableBridging?: boolean;
enableGasless?: boolean;
}
export interface NexusError {
code: string;
message: string;
details?: string;
statusCode?: number;
chain?: SupportedChain;
retryable?: boolean;
suggestions?: string[];
}
export interface APIResponse<T> {
success: boolean;
data?: T;
error?: NexusError;
}
export interface Project {
id: string;
name: string;
slug: string;
description?: string;
website?: string;
owner_id: string;
chains: SupportedChain[];
status: 'active' | 'inactive';
created_at: string;
updated_at: string;
settings: {
paymasterEnabled: boolean;
bridgingEnabled: boolean;
webhookUrl?: string;
rateLimit: number;
allowedSocialTypes: string[];
};
}
export interface CreateProjectRequest {
name: string;
description?: string;
website?: string;
chains: SupportedChain[];
allowedSocialTypes?: string[];
}
export interface Wallet {
id: string;
addresses: Record<SupportedChain, string>;
status: 'created' | 'deploying' | 'deployed' | 'failed';
deployment_status: Record<SupportedChain, 'pending' | 'confirmed' | 'failed'>;
socialId: string;
socialType: string;
project_id: string;
created_at: string;
updated_at: string;
metadata?: {
name?: string;
avatar?: string;
customData?: Record<string, any>;
};
balances?: WalletBalances;
gasless_enabled: boolean;
}
export interface CreateWalletRequest {
socialId: string;
socialType: string;
chains: SupportedChain[];
metadata?: {
name?: string;
avatar?: string;
customData?: Record<string, any>;
};
enableGasless?: boolean;
}
export interface TokenBalance {
symbol: string;
name: string;
balance: string;
decimals: number;
usd_value: string;
contract_address?: string;
logo_url?: string;
}
export interface WalletBalances {
[chain: string]: {
native: TokenBalance;
tokens: TokenBalance[];
total_usd: string;
};
}
export interface Token {
symbol: string;
name: string;
decimals: number;
contract_address: string;
chain: SupportedChain;
logo_url?: string;
is_native: boolean;
is_popular: boolean;
}
export interface TransactionRequest {
chain: SupportedChain;
userWalletAddress: string;
transaction: {
to: string;
value?: string;
data?: string;
gasLimit?: string;
};
usePaymaster?: boolean;
token?: {
contract_address?: string;
amount: string;
recipient?: string;
};
}
export interface TransactionResult {
transactionHash: string;
gasUsed: string;
gasCost: string;
paymasterUsed: boolean;
status: 'pending' | 'confirmed' | 'failed';
blockNumber?: number;
timestamp: string;
explorerUrl: string;
}
export interface GasEstimate {
gasLimit: string;
gasPrice: string;
totalCost: string;
usdCost: string;
paymasterCovered: boolean;
}
export interface BridgeRequest {
fromChain: SupportedChain;
toChain: SupportedChain;
token: string;
amount: string;
fromAddress: string;
toAddress: string;
usePaymaster?: boolean;
}
export interface BridgeResult {
bridgeId: string;
fromTx: TransactionResult;
toTx?: TransactionResult;
status: 'initiated' | 'bridging' | 'completed' | 'failed';
estimatedTime: number;
bridgeFee: string;
exchangeRate?: string;
}
export interface BridgeStatus {
bridgeId: string;
status: 'initiated' | 'bridging' | 'completed' | 'failed';
fromTx: TransactionResult;
toTx?: TransactionResult;
progress: number;
estimatedTimeRemaining: number;
}
export interface TokenTransferRequest {
chain: SupportedChain;
fromAddress: string;
toAddress: string;
token: string;
amount: string;
usePaymaster?: boolean;
}
export interface SwapRequest {
chain: SupportedChain;
userAddress: string;
fromToken: string;
toToken: string;
amount: string;
slippage?: number;
usePaymaster?: boolean;
}
export interface SwapResult {
transactionHash: string;
fromToken: Token;
toToken: Token;
fromAmount: string;
toAmount: string;
exchangeRate: string;
slippage: number;
fee: string;
paymasterUsed: boolean;
}
export interface PaymasterBalance {
chain: SupportedChain;
balance: string;
usd_value: string;
is_low_balance: boolean;
funding_address: string;
contract_address?: string;
estimated_transactions_remaining: number;
}
export interface PaymasterAddresses {
addresses: Record<SupportedChain, string>;
qr_codes: Record<SupportedChain, string>;
funding_instructions: Record<SupportedChain, string>;
}
export interface PaymasterTransaction {
id: string;
chain: SupportedChain;
transaction_hash: string;
amount: string;
gas_used: string;
gas_price: string;
usd_cost: string;
wallet_address: string;
transaction_type: 'transfer' | 'swap' | 'bridge' | 'contract_call';
created_at: string;
}
export interface AnalyticsOverview {
total_wallets: number;
total_transactions: number;
total_gas_spent_usd: string;
total_gas_saved_usd: string;
active_users_7d: number;
active_users_30d: number;
paymaster_coverage_pct: number;
bridge_volume_usd: string;
swap_volume_usd: string;
chains: Record<SupportedChain, ChainAnalytics>;
social_types: Record<string, SocialTypeAnalytics>;
}
export interface ChainAnalytics {
chain: SupportedChain;
transactions: number;
gas_spent_usd: string;
gas_saved_usd: string;
active_users: number;
bridge_volume_usd: string;
swap_volume_usd: string;
popular_tokens: Token[];
}
export interface SocialTypeAnalytics {
social_type: string;
wallets_created: number;
transactions: number;
gas_spent_usd: string;
most_active_users: number;
}
export interface UserAnalytics {
user_id: string;
social_type: string;
wallets_created: number;
transactions_sent: number;
bridges_completed: number;
swaps_completed: number;
total_gas_spent_usd: string;
total_gas_saved_usd: string;
favorite_chains: SupportedChain[];
last_activity: string;
}
export interface CostAnalytics {
total_spent_usd: string;
total_saved_usd: string;
average_cost_per_transaction: string;
paymaster_efficiency: number;
by_chain: Record<SupportedChain, {
spent_usd: string;
saved_usd: string;
transaction_count: number;
efficiency: number;
}>;
forecast_30d: string;
break_even_point: string;
}
export interface WalletConnectProps {
onWalletCreated?: (wallet: Wallet) => void;
onError?: (error: NexusError) => void;
chains?: SupportedChain[];
allowedSocialTypes?: string[];
customSocialTypes?: {
type: string;
label: string;
placeholder: string;
}[];
className?: string;
theme?: 'light' | 'dark' | 'auto';
}