@zkp2p/pay-shared
v1.0.0
Published
Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.
Downloads
1,299
Readme
@zkp2p/pay-shared
Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK, and frontend apps.
- Package:
@zkp2p/pay-shared - Module format: ESM
- Contains runtime utilities and compile-time types
Install
npm install @zkp2p/[email protected]Published artifacts
- Includes compiled ESM JavaScript and
.d.tstype declarations. - Does not publish declaration maps (
.d.ts.map) or JavaScript source maps (.js.map).
What This Package Includes
- Checkout API types (
CreateOrderRequest,CheckoutOrder,CheckoutPayment,CheckoutAggregate, etc.) - Canonical constants (
PaymentPlatform,FeePayer,CheckoutOrderStatus,CheckoutPaymentStatus,OrderErrorCode) - Merchant model types and environment constants (
Merchant,MerchantEnvironment) - Central chain/token helpers for supported destination chains and token aliases
Usage
Shared API Types
import type { CreateOrderRequest, CheckoutOrder } from '@zkp2p/pay-shared';
const request: CreateOrderRequest = {
requestedUsdcAmount: '25.00',
destinationChainId: 8453,
destinationToken: 'USDC',
destinationAddress: '0xYourRecipientAddress',
};
function readOrder(order: CheckoutOrder) {
console.log(order.status, order.requestedUsdcAmount, order.remainingUsdcAmount);
}Constants and Enums
import { FeePayer, PaymentPlatform, CheckoutOrderStatus } from '@zkp2p/pay-shared';
console.log(FeePayer.MERCHANT); // "MERCHANT"
console.log(PaymentPlatform.VENMO); // "venmo"
console.log(CheckoutOrderStatus.CREATED); // "CREATED"Chain and Token Utilities
import {
BASE_CHAIN_ID,
getSupportedChainIds,
parseSupportedChainSelection,
resolveDestinationTokenAddress,
getSupportedDestinationTokenAliasesForChain,
} from '@zkp2p/pay-shared';
const chainId = parseSupportedChainSelection('polygon'); // 137
const usdc = resolveDestinationTokenAddress('USDC', 137); // Chain-specific USDC address
const supportedAliases = getSupportedDestinationTokenAliasesForChain(BASE_CHAIN_ID); // ["USDC"]
console.log(getSupportedChainIds(), chainId, usdc, supportedAliases);Key Exports
Core type exports:
CreateOrderRequestCreateOrderResponseCreatePaymentRequestCheckoutOrderCheckoutPaymentCheckoutAggregateCheckoutQuotesMerchantProfile
Core constants:
PaymentPlatformFeePayerCheckoutOrderStatusCheckoutPaymentStatusOrderStatusProofAttemptStatusOrderErrorCodeMerchantEnvironment
Chain constants and helpers:
BASE_CHAIN_IDHYPEREVM_CHAIN_IDSOLANA_CHAIN_IDSUPPORTED_DESTINATION_TOKEN_ALIASESparseSupportedChainSelection(...)resolveDestinationTokenAddress(...)getChainConfig(...)getSupportedChainIds(...)getDestinationChainIds(...)getEvmChainIds(...)getNonEvmChainIds(...)
Notes
- Amount fields are strings to preserve precision across APIs and clients.
- Canonical order/payment amounts are available on
CheckoutOrderandCheckoutPayment(for examplerequestedUsdcAmount,remainingUsdcAmount,netSettledUsdcAmount). - This package is ESM-only.
