@zkp2p/pay-shared 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/cashoutCurrencies.d.ts +109 -0
- package/dist/cashoutCurrencies.js +94 -0
- package/dist/cashoutRails.d.ts +10 -10
- package/dist/cashoutRails.js +21 -21
- package/dist/crypto.d.ts +4 -4
- package/dist/crypto.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/types.d.ts +190 -155
- package/dist/types.js +43 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Shared TypeScript types, enums, and chain utilities used by ZKP2P Pay API, SDK,
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install @zkp2p/pay-shared@
|
|
12
|
+
npm install @zkp2p/pay-shared@7.0.0
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
## Published artifacts
|
|
@@ -85,10 +85,10 @@ Core type exports:
|
|
|
85
85
|
- `CheckoutAggregate`
|
|
86
86
|
- `CheckoutQuotes`
|
|
87
87
|
- `MerchantProfile`
|
|
88
|
-
- `
|
|
89
|
-
- `
|
|
88
|
+
- `PayoutView`
|
|
89
|
+
- `PayoutRailType`
|
|
90
90
|
- `WebhookPayload`
|
|
91
|
-
- `
|
|
91
|
+
- `PayoutWebhookPayload`
|
|
92
92
|
|
|
93
93
|
Core constants:
|
|
94
94
|
|
|
@@ -100,15 +100,15 @@ Core constants:
|
|
|
100
100
|
- `ProofAttemptStatus`
|
|
101
101
|
- `OrderErrorCode`
|
|
102
102
|
- `MerchantEnvironment`
|
|
103
|
-
- `
|
|
104
|
-
- `
|
|
105
|
-
- `
|
|
106
|
-
- `
|
|
103
|
+
- `PayoutStatus`
|
|
104
|
+
- `PayoutRail`
|
|
105
|
+
- `PayoutCryptoRail`
|
|
106
|
+
- `PayoutProvider`
|
|
107
107
|
- `PAY_CRYPTO_TOKEN_SYMBOLS`
|
|
108
108
|
|
|
109
109
|
Webhook helpers:
|
|
110
110
|
|
|
111
|
-
- `
|
|
111
|
+
- `isPayoutWebhook(...)` — narrows `WebhookPayload` to `PayoutWebhookPayload`
|
|
112
112
|
|
|
113
113
|
Chain constants and helpers:
|
|
114
114
|
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type PayoutFiatRailType } from './types.js';
|
|
2
|
+
/** Currency metadata in selector order. Names follow the SDK's currencyInfo. */
|
|
3
|
+
export declare const PAYOUT_CURRENCY_INFO: {
|
|
4
|
+
readonly USD: {
|
|
5
|
+
readonly name: "United States Dollar";
|
|
6
|
+
readonly prefix: "$";
|
|
7
|
+
readonly minorUnits: 2;
|
|
8
|
+
};
|
|
9
|
+
readonly EUR: {
|
|
10
|
+
readonly name: "Euro";
|
|
11
|
+
readonly prefix: "€";
|
|
12
|
+
readonly minorUnits: 2;
|
|
13
|
+
};
|
|
14
|
+
readonly GBP: {
|
|
15
|
+
readonly name: "British Pound";
|
|
16
|
+
readonly prefix: "£";
|
|
17
|
+
readonly minorUnits: 2;
|
|
18
|
+
};
|
|
19
|
+
readonly AUD: {
|
|
20
|
+
readonly name: "Australian Dollar";
|
|
21
|
+
readonly prefix: "A$";
|
|
22
|
+
readonly minorUnits: 2;
|
|
23
|
+
};
|
|
24
|
+
readonly CAD: {
|
|
25
|
+
readonly name: "Canadian Dollar";
|
|
26
|
+
readonly prefix: "C$";
|
|
27
|
+
readonly minorUnits: 2;
|
|
28
|
+
};
|
|
29
|
+
readonly CHF: {
|
|
30
|
+
readonly name: "Swiss Franc";
|
|
31
|
+
readonly prefix: "CHF ";
|
|
32
|
+
readonly minorUnits: 2;
|
|
33
|
+
};
|
|
34
|
+
readonly CNY: {
|
|
35
|
+
readonly name: "Chinese Yuan";
|
|
36
|
+
readonly prefix: "CN¥";
|
|
37
|
+
readonly minorUnits: 2;
|
|
38
|
+
};
|
|
39
|
+
readonly MXN: {
|
|
40
|
+
readonly name: "Mexican Peso";
|
|
41
|
+
readonly prefix: "MX$";
|
|
42
|
+
readonly minorUnits: 2;
|
|
43
|
+
};
|
|
44
|
+
readonly NZD: {
|
|
45
|
+
readonly name: "New Zealand Dollar";
|
|
46
|
+
readonly prefix: "NZ$";
|
|
47
|
+
readonly minorUnits: 2;
|
|
48
|
+
};
|
|
49
|
+
readonly SGD: {
|
|
50
|
+
readonly name: "Singapore Dollar";
|
|
51
|
+
readonly prefix: "S$";
|
|
52
|
+
readonly minorUnits: 2;
|
|
53
|
+
};
|
|
54
|
+
readonly TRY: {
|
|
55
|
+
readonly name: "Turkish Lira";
|
|
56
|
+
readonly prefix: "₺";
|
|
57
|
+
readonly minorUnits: 2;
|
|
58
|
+
};
|
|
59
|
+
readonly ZAR: {
|
|
60
|
+
readonly name: "South African Rand";
|
|
61
|
+
readonly prefix: "R";
|
|
62
|
+
readonly minorUnits: 2;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export type PayoutCurrencyType = keyof typeof PAYOUT_CURRENCY_INFO;
|
|
66
|
+
/** Every currency but USD: priced by the protocol oracle at zero spread, bound when a buyer signals. */
|
|
67
|
+
export type PayoutOracleCurrencyType = Exclude<PayoutCurrencyType, 'USD'>;
|
|
68
|
+
export declare const PayoutCurrency: { readonly [K in PayoutCurrencyType]: K; };
|
|
69
|
+
/** Oracle currencies in catalog order; payoutCurrencies follows it. */
|
|
70
|
+
export declare const PAYOUT_ORACLE_CURRENCIES: PayoutOracleCurrencyType[];
|
|
71
|
+
/** Each rail's supported currencies, USD first then selector order. The API validates every pair against the SDK at boot. */
|
|
72
|
+
export declare const PAYOUT_RAIL_CURRENCIES: {
|
|
73
|
+
readonly venmo: readonly ["USD"];
|
|
74
|
+
readonly cashapp: readonly ["USD"];
|
|
75
|
+
readonly paypal: readonly ["USD", "EUR", "GBP", "AUD", "CAD", "NZD", "SGD"];
|
|
76
|
+
readonly zelle: readonly ["USD"];
|
|
77
|
+
readonly revolut: readonly ["USD", "EUR", "GBP", "AUD", "CAD", "CHF", "CNY", "MXN", "NZD", "SGD", "TRY", "ZAR"];
|
|
78
|
+
readonly chime: readonly ["USD"];
|
|
79
|
+
};
|
|
80
|
+
export declare const PAYOUT_CURRENCY_NAMES: Readonly<Record<"USD" | "EUR" | "GBP" | "AUD" | "CAD" | "CHF" | "CNY" | "MXN" | "NZD" | "SGD" | "TRY" | "ZAR", string>>;
|
|
81
|
+
export declare const PAYOUT_CURRENCY_SYMBOLS: Readonly<Record<"USD" | "EUR" | "GBP" | "AUD" | "CAD" | "CHF" | "CNY" | "MXN" | "NZD" | "SGD" | "TRY" | "ZAR", string>>;
|
|
82
|
+
/** A USD listing's rate: exactly 1.00 USD per USDC in 18-decimal units; USD never uses an oracle. */
|
|
83
|
+
export declare const CASHOUT_FIXED_USD_RATE: bigint;
|
|
84
|
+
/** An oracle listing's fixed floor; below any market rate, so the escrow's effective rate is the oracle's (cash's ORACLE_MIN_CONVERSION_RATE_SENTINEL). */
|
|
85
|
+
export declare const CASHOUT_ORACLE_MIN_RATE_SENTINEL = 1n;
|
|
86
|
+
/** A fiat amount: `amount` is a decimal string with exactly 2 decimals. */
|
|
87
|
+
export interface PayoutFiatValue {
|
|
88
|
+
currency: PayoutCurrencyType;
|
|
89
|
+
amount: string;
|
|
90
|
+
}
|
|
91
|
+
export declare function isPayoutCurrency(value: string): value is PayoutCurrencyType;
|
|
92
|
+
export declare function isCashoutOracleCurrency(value: string): value is PayoutOracleCurrencyType;
|
|
93
|
+
export declare function payoutRailPaysCurrency(rail: PayoutFiatRailType, currency: PayoutCurrencyType): boolean;
|
|
94
|
+
/** A rail whose payout-method request carries `currency`: its catalog has more than one. */
|
|
95
|
+
export declare function isPayoutMultiCurrencyRail(rail: PayoutFiatRailType): boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Fiat cents for `units` USDC base units at `rate` (fiat per USDC, 18 decimals), rounded up: Curator's buyer quote rule.
|
|
98
|
+
* While a USDC unit is worth less than a cent (rate below 10,000), it recovers exactly the cents a buyer paid from the
|
|
99
|
+
* attestation's floored release amount.
|
|
100
|
+
*/
|
|
101
|
+
export declare function payoutFiatCents(units: bigint, rate: bigint): bigint;
|
|
102
|
+
export declare function formatPayoutFiatCents(cents: bigint): string;
|
|
103
|
+
/** Fiat per USDC with 6 decimals, rounded half up: "0.892698". Display only. */
|
|
104
|
+
export declare function formatPayoutRate(rate: bigint): string;
|
|
105
|
+
/** A stored 18-decimal rate; null unless it is a positive integer string without leading zeros. */
|
|
106
|
+
export declare function parseCashoutRate(value: string | null): bigint | null;
|
|
107
|
+
export declare function cashoutFiatValue(currency: PayoutCurrencyType, units: bigint, rate: bigint): PayoutFiatValue;
|
|
108
|
+
/** Group a non-negative fiat amount with exactly two decimals; reject malformed amounts and preserve cents beyond Number's safe range. */
|
|
109
|
+
export declare function formatPayoutFiatValue(value: PayoutFiatValue): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { PayoutFiatRail } from './types.js';
|
|
2
|
+
/** Currency metadata in selector order. Names follow the SDK's currencyInfo. */
|
|
3
|
+
export const PAYOUT_CURRENCY_INFO = {
|
|
4
|
+
USD: { name: 'United States Dollar', prefix: '$', minorUnits: 2 },
|
|
5
|
+
EUR: { name: 'Euro', prefix: '€', minorUnits: 2 },
|
|
6
|
+
GBP: { name: 'British Pound', prefix: '£', minorUnits: 2 },
|
|
7
|
+
AUD: { name: 'Australian Dollar', prefix: 'A$', minorUnits: 2 },
|
|
8
|
+
CAD: { name: 'Canadian Dollar', prefix: 'C$', minorUnits: 2 },
|
|
9
|
+
CHF: { name: 'Swiss Franc', prefix: 'CHF ', minorUnits: 2 },
|
|
10
|
+
CNY: { name: 'Chinese Yuan', prefix: 'CN¥', minorUnits: 2 },
|
|
11
|
+
MXN: { name: 'Mexican Peso', prefix: 'MX$', minorUnits: 2 },
|
|
12
|
+
NZD: { name: 'New Zealand Dollar', prefix: 'NZ$', minorUnits: 2 },
|
|
13
|
+
SGD: { name: 'Singapore Dollar', prefix: 'S$', minorUnits: 2 },
|
|
14
|
+
TRY: { name: 'Turkish Lira', prefix: '₺', minorUnits: 2 },
|
|
15
|
+
ZAR: { name: 'South African Rand', prefix: 'R', minorUnits: 2 },
|
|
16
|
+
};
|
|
17
|
+
// The keys of this local, closed catalog are exactly PayoutCurrencyType.
|
|
18
|
+
const CURRENCY_CODES = Object.keys(PAYOUT_CURRENCY_INFO);
|
|
19
|
+
// Every catalog key maps to itself; Object.fromEntries otherwise loses that key/value relationship.
|
|
20
|
+
export const PayoutCurrency = Object.fromEntries(CURRENCY_CODES.map(code => [code, code]));
|
|
21
|
+
/** Oracle currencies in catalog order; payoutCurrencies follows it. */
|
|
22
|
+
export const PAYOUT_ORACLE_CURRENCIES = CURRENCY_CODES.filter((code) => code !== 'USD');
|
|
23
|
+
/** Each rail's supported currencies, USD first then selector order. The API validates every pair against the SDK at boot. */
|
|
24
|
+
export const PAYOUT_RAIL_CURRENCIES = {
|
|
25
|
+
[PayoutFiatRail.VENMO]: ['USD'],
|
|
26
|
+
[PayoutFiatRail.CASHAPP]: ['USD'],
|
|
27
|
+
[PayoutFiatRail.PAYPAL]: ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'NZD', 'SGD'],
|
|
28
|
+
[PayoutFiatRail.ZELLE]: ['USD'],
|
|
29
|
+
[PayoutFiatRail.REVOLUT]: ['USD', 'EUR', 'GBP', 'AUD', 'CAD', 'CHF', 'CNY', 'MXN', 'NZD', 'SGD', 'TRY', 'ZAR'],
|
|
30
|
+
[PayoutFiatRail.CHIME]: ['USD'],
|
|
31
|
+
};
|
|
32
|
+
function currencyLabels(field) {
|
|
33
|
+
// The mapping visits every catalog key once, preserving a complete record.
|
|
34
|
+
return Object.fromEntries(CURRENCY_CODES.map(code => [code, PAYOUT_CURRENCY_INFO[code][field]]));
|
|
35
|
+
}
|
|
36
|
+
export const PAYOUT_CURRENCY_NAMES = currencyLabels('name');
|
|
37
|
+
export const PAYOUT_CURRENCY_SYMBOLS = currencyLabels('prefix');
|
|
38
|
+
/** A USD listing's rate: exactly 1.00 USD per USDC in 18-decimal units; USD never uses an oracle. */
|
|
39
|
+
export const CASHOUT_FIXED_USD_RATE = 10n ** 18n;
|
|
40
|
+
/** An oracle listing's fixed floor; below any market rate, so the escrow's effective rate is the oracle's (cash's ORACLE_MIN_CONVERSION_RATE_SENTINEL). */
|
|
41
|
+
export const CASHOUT_ORACLE_MIN_RATE_SENTINEL = 1n;
|
|
42
|
+
const CURRENCY_SET = new Set(Object.values(PayoutCurrency));
|
|
43
|
+
export function isPayoutCurrency(value) {
|
|
44
|
+
return CURRENCY_SET.has(value);
|
|
45
|
+
}
|
|
46
|
+
export function isCashoutOracleCurrency(value) {
|
|
47
|
+
return isPayoutCurrency(value) && value !== PayoutCurrency.USD;
|
|
48
|
+
}
|
|
49
|
+
export function payoutRailPaysCurrency(rail, currency) {
|
|
50
|
+
const currencies = PAYOUT_RAIL_CURRENCIES[rail];
|
|
51
|
+
return currencies.includes(currency);
|
|
52
|
+
}
|
|
53
|
+
/** A rail whose payout-method request carries `currency`: its catalog has more than one. */
|
|
54
|
+
export function isPayoutMultiCurrencyRail(rail) {
|
|
55
|
+
return PAYOUT_RAIL_CURRENCIES[rail].length > 1;
|
|
56
|
+
}
|
|
57
|
+
/** 1e6 USDC units × 1e18 rate units ÷ 100 cents. */
|
|
58
|
+
const CENTS_DENOMINATOR = 10n ** 22n;
|
|
59
|
+
/**
|
|
60
|
+
* Fiat cents for `units` USDC base units at `rate` (fiat per USDC, 18 decimals), rounded up: Curator's buyer quote rule.
|
|
61
|
+
* While a USDC unit is worth less than a cent (rate below 10,000), it recovers exactly the cents a buyer paid from the
|
|
62
|
+
* attestation's floored release amount.
|
|
63
|
+
*/
|
|
64
|
+
export function payoutFiatCents(units, rate) {
|
|
65
|
+
if (units < 0n)
|
|
66
|
+
throw new Error('USDC units must not be negative');
|
|
67
|
+
if (rate <= 0n)
|
|
68
|
+
throw new Error('Rate must be positive');
|
|
69
|
+
return (units * rate + CENTS_DENOMINATOR - 1n) / CENTS_DENOMINATOR;
|
|
70
|
+
}
|
|
71
|
+
export function formatPayoutFiatCents(cents) {
|
|
72
|
+
return `${cents / 100n}.${(cents % 100n).toString().padStart(2, '0')}`;
|
|
73
|
+
}
|
|
74
|
+
/** Fiat per USDC with 6 decimals, rounded half up: "0.892698". Display only. */
|
|
75
|
+
export function formatPayoutRate(rate) {
|
|
76
|
+
const micro = (rate + 500000000000n) / 1000000000000n;
|
|
77
|
+
return `${micro / 1000000n}.${(micro % 1000000n).toString().padStart(6, '0')}`;
|
|
78
|
+
}
|
|
79
|
+
/** A stored 18-decimal rate; null unless it is a positive integer string without leading zeros. */
|
|
80
|
+
export function parseCashoutRate(value) {
|
|
81
|
+
if (value === null || !/^[1-9][0-9]{0,77}$/u.test(value))
|
|
82
|
+
return null;
|
|
83
|
+
return BigInt(value);
|
|
84
|
+
}
|
|
85
|
+
export function cashoutFiatValue(currency, units, rate) {
|
|
86
|
+
return { currency, amount: formatPayoutFiatCents(payoutFiatCents(units, rate)) };
|
|
87
|
+
}
|
|
88
|
+
/** Group a non-negative fiat amount with exactly two decimals; reject malformed amounts and preserve cents beyond Number's safe range. */
|
|
89
|
+
export function formatPayoutFiatValue(value) {
|
|
90
|
+
if (!/^[0-9]+\.[0-9]{2}$/u.test(value.amount))
|
|
91
|
+
throw new Error('Fiat amount must have exactly two decimals');
|
|
92
|
+
const [whole, fraction] = value.amount.split('.');
|
|
93
|
+
return `${PAYOUT_CURRENCY_SYMBOLS[value.currency]}${whole.replace(/\B(?=(\d{3})+(?!\d))/gu, ',')}.${fraction}`;
|
|
94
|
+
}
|
package/dist/cashoutRails.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { type CashoutBuyerProofRailType, type
|
|
1
|
+
import { type CashoutBuyerProofRailType, type PayoutCryptoRailType, type PayoutFiatRailType, type PayoutSarRailType } from './types.js';
|
|
2
2
|
/**
|
|
3
3
|
* The cashout rails SAR_SUPPORTED_FIAT_RAILS lists, in rail order: Venmo, Cash App and PayPal. Wise is SAR but not a
|
|
4
4
|
* cashout rail yet.
|
|
5
5
|
*/
|
|
6
|
-
export declare const CASHOUT_SAR_RAILS: ReadonlyArray<
|
|
7
|
-
/** A rail in CASHOUT_SAR_RAILS. Exact rails only; a variant such as "venmo-x" is not a
|
|
8
|
-
export declare function
|
|
6
|
+
export declare const CASHOUT_SAR_RAILS: ReadonlyArray<PayoutSarRailType>;
|
|
7
|
+
/** A rail in CASHOUT_SAR_RAILS. Exact rails only; a variant such as "venmo-x" is not a payout rail. */
|
|
8
|
+
export declare function isPayoutSarRail(rail: string): rail is PayoutSarRailType;
|
|
9
9
|
/** A cashout fiat rail with no connect step: Zelle, Revolut and Chime. */
|
|
10
10
|
export declare function isCashoutBuyerProofRail(rail: string): rail is CashoutBuyerProofRailType;
|
|
11
11
|
/** Every crypto payout network's rail, in rail order (checkout's relay rail order). */
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const PAYOUT_CRYPTO_RAILS: ReadonlyArray<PayoutCryptoRailType>;
|
|
13
13
|
/** An exact crypto payout rail; replaces every comparison with the retired `crypto` rail. */
|
|
14
|
-
export declare function
|
|
15
|
-
export declare function
|
|
16
|
-
export declare function cashoutCryptoRailForChain(chainId: number):
|
|
14
|
+
export declare function isPayoutCryptoRail(rail: string): rail is PayoutCryptoRailType;
|
|
15
|
+
export declare function payoutCryptoRailChainId(rail: PayoutCryptoRailType): number;
|
|
16
|
+
export declare function cashoutCryptoRailForChain(chainId: number): PayoutCryptoRailType | null;
|
|
17
17
|
/** The payout chains a rail list offers, in rail order; the checkout's pickers and the server's checks read it. */
|
|
18
18
|
export declare function cashoutRailsChainIds(rails: ReadonlyArray<string>): number[];
|
|
19
|
-
export declare function
|
|
19
|
+
export declare function hasPayoutCryptoRail(rails: ReadonlyArray<string>): boolean;
|
|
20
20
|
/**
|
|
21
21
|
* Venmo and PayPal listings get the Peer Pay merchant group. The set is @zkp2p/core's
|
|
22
22
|
* DISPUTE_PROTECTION_STAKE_PLATFORMS, which @zkp2p/sdk keeps private, and
|
|
@@ -31,4 +31,4 @@ export declare function isCashoutPeerPayGroupRail(rail: string): rail is Cashout
|
|
|
31
31
|
* A payout account as its rail writes it: "@alice" (Venmo, Revolut), "$alice1" (Cash App), "paypal.me/bob" (PayPal),
|
|
32
32
|
* the email (Zelle) and "$chimesign" (Chime, whose stored handle already carries its "$").
|
|
33
33
|
*/
|
|
34
|
-
export declare function
|
|
34
|
+
export declare function payoutAccountLabel(rail: PayoutFiatRailType, handle: string): string;
|
package/dist/cashoutRails.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { SAR_SUPPORTED_FIAT_RAILS, parseCryptoRailChainId } from './rails.js';
|
|
2
|
-
import {
|
|
3
|
-
const CASHOUT_FIAT_RAIL_SET = new Set(Object.values(
|
|
2
|
+
import { PayoutCryptoRail, PayoutFiatRail, PayoutRail, } from './types.js';
|
|
3
|
+
const CASHOUT_FIAT_RAIL_SET = new Set(Object.values(PayoutFiatRail));
|
|
4
4
|
const SAR_SUPPORTED_FIAT_RAIL_SET = new Set(SAR_SUPPORTED_FIAT_RAILS);
|
|
5
5
|
/**
|
|
6
6
|
* The cashout rails SAR_SUPPORTED_FIAT_RAILS lists, in rail order: Venmo, Cash App and PayPal. Wise is SAR but not a
|
|
7
7
|
* cashout rail yet.
|
|
8
8
|
*/
|
|
9
|
-
export const CASHOUT_SAR_RAILS = Object.values(
|
|
9
|
+
export const CASHOUT_SAR_RAILS = Object.values(PayoutFiatRail).filter((rail) => SAR_SUPPORTED_FIAT_RAIL_SET.has(rail));
|
|
10
10
|
const CASHOUT_SAR_RAIL_SET = new Set(CASHOUT_SAR_RAILS);
|
|
11
|
-
/** A rail in CASHOUT_SAR_RAILS. Exact rails only; a variant such as "venmo-x" is not a
|
|
12
|
-
export function
|
|
11
|
+
/** A rail in CASHOUT_SAR_RAILS. Exact rails only; a variant such as "venmo-x" is not a payout rail. */
|
|
12
|
+
export function isPayoutSarRail(rail) {
|
|
13
13
|
return CASHOUT_SAR_RAIL_SET.has(rail);
|
|
14
14
|
}
|
|
15
15
|
/** A cashout fiat rail with no connect step: Zelle, Revolut and Chime. */
|
|
@@ -17,35 +17,35 @@ export function isCashoutBuyerProofRail(rail) {
|
|
|
17
17
|
return CASHOUT_FIAT_RAIL_SET.has(rail) && !CASHOUT_SAR_RAIL_SET.has(rail);
|
|
18
18
|
}
|
|
19
19
|
/** Every crypto payout network's rail, in rail order (checkout's relay rail order). */
|
|
20
|
-
export const
|
|
21
|
-
const CASHOUT_CRYPTO_RAIL_SET = new Set(
|
|
20
|
+
export const PAYOUT_CRYPTO_RAILS = Object.values(PayoutCryptoRail);
|
|
21
|
+
const CASHOUT_CRYPTO_RAIL_SET = new Set(PAYOUT_CRYPTO_RAILS);
|
|
22
22
|
/** An exact crypto payout rail; replaces every comparison with the retired `crypto` rail. */
|
|
23
|
-
export function
|
|
23
|
+
export function isPayoutCryptoRail(rail) {
|
|
24
24
|
return CASHOUT_CRYPTO_RAIL_SET.has(rail);
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
26
|
+
export function payoutCryptoRailChainId(rail) {
|
|
27
27
|
const chainId = parseCryptoRailChainId(rail);
|
|
28
28
|
if (chainId === null)
|
|
29
29
|
throw new Error(`Cashout crypto rail ${rail} names no chain`);
|
|
30
30
|
return chainId;
|
|
31
31
|
}
|
|
32
|
-
const CASHOUT_CRYPTO_RAIL_BY_CHAIN = new Map(
|
|
32
|
+
const CASHOUT_CRYPTO_RAIL_BY_CHAIN = new Map(PAYOUT_CRYPTO_RAILS.map((rail) => [payoutCryptoRailChainId(rail), rail]));
|
|
33
33
|
export function cashoutCryptoRailForChain(chainId) {
|
|
34
34
|
return CASHOUT_CRYPTO_RAIL_BY_CHAIN.get(chainId) ?? null;
|
|
35
35
|
}
|
|
36
36
|
/** The payout chains a rail list offers, in rail order; the checkout's pickers and the server's checks read it. */
|
|
37
37
|
export function cashoutRailsChainIds(rails) {
|
|
38
|
-
return
|
|
38
|
+
return PAYOUT_CRYPTO_RAILS.filter((rail) => rails.includes(rail)).map(payoutCryptoRailChainId);
|
|
39
39
|
}
|
|
40
|
-
export function
|
|
41
|
-
return rails.some(
|
|
40
|
+
export function hasPayoutCryptoRail(rails) {
|
|
41
|
+
return rails.some(isPayoutCryptoRail);
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Venmo and PayPal listings get the Peer Pay merchant group. The set is @zkp2p/core's
|
|
45
45
|
* DISPUTE_PROTECTION_STAKE_PLATFORMS, which @zkp2p/sdk keeps private, and
|
|
46
46
|
* zkp2p-mobile's CHARGEBACK_PRONE_SELL_PLATFORMS. Cash App left that set on 2026-08-28.
|
|
47
47
|
*/
|
|
48
|
-
export const CASHOUT_PEER_PAY_GROUP_RAILS = [
|
|
48
|
+
export const CASHOUT_PEER_PAY_GROUP_RAILS = [PayoutRail.VENMO, PayoutRail.PAYPAL];
|
|
49
49
|
const CASHOUT_PEER_PAY_GROUP_RAIL_SET = new Set(CASHOUT_PEER_PAY_GROUP_RAILS);
|
|
50
50
|
/** A rail in CASHOUT_PEER_PAY_GROUP_RAILS. */
|
|
51
51
|
export function isCashoutPeerPayGroupRail(rail) {
|
|
@@ -55,17 +55,17 @@ export function isCashoutPeerPayGroupRail(rail) {
|
|
|
55
55
|
* A payout account as its rail writes it: "@alice" (Venmo, Revolut), "$alice1" (Cash App), "paypal.me/bob" (PayPal),
|
|
56
56
|
* the email (Zelle) and "$chimesign" (Chime, whose stored handle already carries its "$").
|
|
57
57
|
*/
|
|
58
|
-
export function
|
|
58
|
+
export function payoutAccountLabel(rail, handle) {
|
|
59
59
|
switch (rail) {
|
|
60
|
-
case
|
|
61
|
-
case
|
|
60
|
+
case PayoutRail.VENMO:
|
|
61
|
+
case PayoutRail.REVOLUT:
|
|
62
62
|
return `@${handle.replace(/^@/u, '')}`;
|
|
63
|
-
case
|
|
63
|
+
case PayoutRail.CASHAPP:
|
|
64
64
|
return `$${handle.replace(/^\$/u, '')}`;
|
|
65
|
-
case
|
|
65
|
+
case PayoutRail.PAYPAL:
|
|
66
66
|
return `paypal.me/${handle}`;
|
|
67
|
-
case
|
|
68
|
-
case
|
|
67
|
+
case PayoutRail.ZELLE:
|
|
68
|
+
case PayoutRail.CHIME:
|
|
69
69
|
return handle;
|
|
70
70
|
}
|
|
71
71
|
}
|
package/dist/crypto.d.ts
CHANGED
|
@@ -68,13 +68,13 @@ export declare function resolvePayCryptoTokenConfig(chainId: number, symbol: str
|
|
|
68
68
|
export declare function resolvePayCryptoTokenConfigByAddress(chainId: number, address: string | null | undefined): SupportedCryptoTokenConfig | null;
|
|
69
69
|
export declare function getSupportedDestinationBalanceTokenConfigsForChain(chainId: number, enabledSymbols?: readonly string[] | null): SupportedCryptoTokenConfig[];
|
|
70
70
|
export declare function resolveDestinationBalanceTokenConfig(chainId: number, symbol: string | null | undefined): SupportedCryptoTokenConfig | null;
|
|
71
|
-
/** Chains a
|
|
72
|
-
export declare const
|
|
71
|
+
/** Chains a payout can be funded from through Relay. Zcash is out: ZEC funding is out of scope (2026-10-07). */
|
|
72
|
+
export declare const PAYOUT_FUNDING_CHAIN_IDS: readonly number[];
|
|
73
73
|
/**
|
|
74
|
-
* The tokens a
|
|
74
|
+
* The tokens a payout can be funded with: every supported pay-crypto token on a Relay-fundable chain. An explicit list,
|
|
75
75
|
* because isEvmChain answers true for chains the table doesn't know, which let Bitcoin and Zcash in by accident.
|
|
76
76
|
*/
|
|
77
|
-
export declare function
|
|
77
|
+
export declare function getPayoutFundingTokenConfigs(): SupportedCryptoTokenConfig[];
|
|
78
78
|
/** The address formats a cashout address can take. */
|
|
79
79
|
export declare const CashoutAddressFamily: {
|
|
80
80
|
readonly EVM: "EVM";
|
package/dist/crypto.js
CHANGED
|
@@ -299,17 +299,17 @@ export function getSupportedDestinationBalanceTokenConfigsForChain(chainId, enab
|
|
|
299
299
|
export function resolveDestinationBalanceTokenConfig(chainId, symbol) {
|
|
300
300
|
return resolvePayCryptoTokenConfig(chainId, symbol);
|
|
301
301
|
}
|
|
302
|
-
/** Chains a
|
|
303
|
-
export const
|
|
302
|
+
/** Chains a payout can be funded from through Relay. Zcash is out: ZEC funding is out of scope (2026-10-07). */
|
|
303
|
+
export const PAYOUT_FUNDING_CHAIN_IDS = [
|
|
304
304
|
ETHEREUM_CHAIN_ID, 10, 56, 137, 480, HYPEREVM_CHAIN_ID, 5042, BASE_CHAIN_ID, 42161, BITCOIN_CHAIN_ID,
|
|
305
305
|
];
|
|
306
306
|
/**
|
|
307
|
-
* The tokens a
|
|
307
|
+
* The tokens a payout can be funded with: every supported pay-crypto token on a Relay-fundable chain. An explicit list,
|
|
308
308
|
* because isEvmChain answers true for chains the table doesn't know, which let Bitcoin and Zcash in by accident.
|
|
309
309
|
*/
|
|
310
|
-
export function
|
|
310
|
+
export function getPayoutFundingTokenConfigs() {
|
|
311
311
|
return getSupportedPayCryptoChainIds(PAY_CRYPTO_TOKEN_SYMBOLS)
|
|
312
|
-
.filter((chainId) =>
|
|
312
|
+
.filter((chainId) => PAYOUT_FUNDING_CHAIN_IDS.includes(chainId))
|
|
313
313
|
.flatMap((chainId) => getSupportedPayCryptoTokenConfigsForChain(chainId, PAY_CRYPTO_TOKEN_SYMBOLS))
|
|
314
314
|
.filter((token) => resolvePayCryptoTokenConfigByAddress(token.chainId, token.address) !== null);
|
|
315
315
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './fees.js';
|
|
|
5
5
|
export * from './crypto.js';
|
|
6
6
|
export * from './rails.js';
|
|
7
7
|
export * from './cashoutRails.js';
|
|
8
|
+
export * from './cashoutCurrencies.js';
|
|
8
9
|
export * from './buyerTee.js';
|
|
9
10
|
export * from './bitcoin.js';
|
|
10
11
|
export * from './addressValidators.js';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from './fees.js';
|
|
|
5
5
|
export * from './crypto.js';
|
|
6
6
|
export * from './rails.js';
|
|
7
7
|
export * from './cashoutRails.js';
|
|
8
|
+
export * from './cashoutCurrencies.js';
|
|
8
9
|
export * from './buyerTee.js';
|
|
9
10
|
export * from './bitcoin.js';
|
|
10
11
|
export * from './addressValidators.js';
|