p-sdk-wallet
Version:
A comprehensive wallet SDK for React Native (pwc), supporting multi-chain and multi-account features.
108 lines (107 loc) • 3.34 kB
TypeScript
/**
* Gas configuration constants to avoid hardcoded values
*/
export declare const GAS_CONFIG: {
/** Default gas limit for ERC-20 token transfers */
readonly ERC20_TRANSFER: 65000;
/** Default gas limit for native token transfers */
readonly NATIVE_TRANSFER: 21000;
/** Default gas limit for token approvals */
readonly TOKEN_APPROVAL: 46000;
/** Default gas limit for contract interactions */
readonly CONTRACT_INTERACTION: 100000;
/** Maximum gas limit for safety */
readonly MAX_GAS_LIMIT: 500000;
/** Gas multiplier for batch operations */
readonly BATCH_MULTIPLIER: 1.1;
/** Priority fee (tip) in wei for EIP-1559 transactions */
readonly DEFAULT_PRIORITY_FEE: 1500000000n;
/** Base fee buffer for EIP-1559 transactions */
readonly BASE_FEE_BUFFER: 1.2;
};
/**
* Set global gas configuration from mobile app (highest priority)
*/
export declare function setGlobalGasConfig(config: Partial<typeof GAS_CONFIG>): void;
/**
* Set global network gas configuration from mobile app (highest priority)
*/
export declare function setGlobalNetworkGasConfig(config: Record<string, Partial<{
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
}>>): void;
/**
* Clear all global gas configurations (reset to defaults)
*/
export declare function clearGlobalGasConfigs(): void;
/**
* Get merged gas config (Mobile App > Env > SDK Defaults)
*/
export declare function getGasConfig(): {
ERC20_TRANSFER: number;
NATIVE_TRANSFER: number;
TOKEN_APPROVAL: number;
CONTRACT_INTERACTION: number;
MAX_GAS_LIMIT: number;
BATCH_MULTIPLIER: number;
DEFAULT_PRIORITY_FEE: bigint;
BASE_FEE_BUFFER: number;
};
/**
* Network-specific gas configurations
*/
export declare const NETWORK_GAS_CONFIG: {
readonly '1': {
readonly maxFeePerGas: 50000000000n;
readonly maxPriorityFeePerGas: 2000000000n;
};
readonly '56': {
readonly maxFeePerGas: 5000000000n;
readonly maxPriorityFeePerGas: 1000000000n;
};
readonly '137': {
readonly maxFeePerGas: 30000000000n;
readonly maxPriorityFeePerGas: 1000000000n;
};
readonly '42161': {
readonly maxFeePerGas: 100000000n;
readonly maxPriorityFeePerGas: 100000000n;
};
readonly '10': {
readonly maxFeePerGas: 1000000000n;
readonly maxPriorityFeePerGas: 100000000n;
};
readonly '8453': {
readonly maxFeePerGas: 1000000000n;
readonly maxPriorityFeePerGas: 100000000n;
};
};
/**
* Get gas configuration for a specific network with priority: Mobile App > Env > SDK Defaults
*/
export declare function getNetworkGasConfig(chainId: string): {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
} | {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
} | {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
} | {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
} | {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
} | {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
};
/**
* Calculate optimal gas price for EIP-1559 transactions using dynamic config
*/
export declare function calculateOptimalGasPrice(baseFee: bigint, chainId: string): {
maxFeePerGas: bigint;
maxPriorityFeePerGas: bigint;
};