@provex/utils 1.0.16 → 1.2.4
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/dist/chain.d.ts +446 -0
- package/dist/chain.js +98 -0
- package/dist/chain.test.js +112 -0
- package/dist/contracts.d.ts +206 -0
- package/dist/contracts.js +292 -0
- package/dist/contracts.test.js +243 -0
- package/dist/conversionRates.d.ts +215 -0
- package/dist/{src/conversionRates.js → conversionRates.js} +74 -4
- package/dist/conversionRates.test.js +473 -0
- package/dist/currencies.d.ts +248 -0
- package/dist/{src/currencies.js → currencies.js} +119 -38
- package/dist/currencies.test.js +343 -0
- package/dist/data/countries.json +1099 -0
- package/dist/deposit.d.ts +69 -0
- package/dist/deposit.js +52 -0
- package/dist/depositKeys.d.ts +154 -0
- package/dist/depositKeys.js +104 -0
- package/dist/depositKeys.test.d.ts +1 -0
- package/dist/depositKeys.test.js +231 -0
- package/dist/events.d.ts +41 -0
- package/dist/events.js +92 -0
- package/dist/events.test.d.ts +1 -0
- package/dist/events.test.js +111 -0
- package/dist/fees.d.ts +136 -0
- package/dist/fees.js +178 -0
- package/dist/fees.test.d.ts +1 -0
- package/dist/fees.test.js +165 -0
- package/dist/ids.d.ts +175 -0
- package/dist/ids.js +231 -0
- package/dist/ids.test.d.ts +1 -0
- package/dist/ids.test.js +607 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +45 -0
- package/dist/input.d.ts +26 -0
- package/dist/{src/input.js → input.js} +23 -4
- package/dist/intent.d.ts +50 -0
- package/dist/intent.js +28 -0
- package/dist/intent.test.d.ts +1 -0
- package/dist/intent.test.js +119 -0
- package/dist/json.d.ts +55 -0
- package/dist/json.js +80 -0
- package/dist/participants.d.ts +22 -0
- package/dist/participants.js +28 -0
- package/dist/payment.d.ts +481 -0
- package/dist/payment.js +1149 -0
- package/dist/payment.test.d.ts +1 -0
- package/dist/payment.test.js +272 -0
- package/dist/peer-types.d.ts +327 -0
- package/dist/peer-types.js +169 -0
- package/dist/profit.d.ts +49 -0
- package/dist/profit.js +57 -0
- package/dist/profit.test.d.ts +1 -0
- package/dist/profit.test.js +315 -0
- package/dist/reputation.d.ts +125 -0
- package/dist/reputation.js +188 -0
- package/dist/reputation.test.d.ts +1 -0
- package/dist/reputation.test.js +156 -0
- package/dist/sort.d.ts +75 -0
- package/dist/sort.js +70 -0
- package/dist/sort.test.d.ts +1 -0
- package/dist/sort.test.js +216 -0
- package/dist/stateKey.d.ts +35 -0
- package/dist/stateKey.js +36 -0
- package/dist/stats.d.ts +61 -0
- package/dist/stats.js +53 -0
- package/dist/stats.test.d.ts +1 -0
- package/dist/stats.test.js +104 -0
- package/dist/time.d.ts +104 -0
- package/dist/time.js +162 -0
- package/dist/time.test.d.ts +1 -0
- package/dist/time.test.js +231 -0
- package/dist/tokens.d.ts +15502 -0
- package/dist/{src/tokens.js → tokens.js} +98 -17
- package/dist/tokens.test.d.ts +1 -0
- package/dist/tokens.test.js +193 -0
- package/dist/units.d.ts +200 -0
- package/dist/units.js +279 -0
- package/dist/units.test.d.ts +1 -0
- package/dist/units.test.js +327 -0
- package/package.json +119 -29
- package/dist/scripts/convert-svg.js +0 -17
- package/dist/src/chain.d.ts +0 -14
- package/dist/src/chain.js +0 -18
- package/dist/src/contracts.d.ts +0 -30
- package/dist/src/contracts.js +0 -64
- package/dist/src/conversionRates.d.ts +0 -124
- package/dist/src/currencies.d.ts +0 -144
- package/dist/src/data/countries.json +0 -1099
- package/dist/src/deposit.d.ts +0 -1
- package/dist/src/events.d.ts +0 -3
- package/dist/src/events.js +0 -16
- package/dist/src/ids.d.ts +0 -72
- package/dist/src/ids.js +0 -81
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -16
- package/dist/src/input.d.ts +0 -7
- package/dist/src/intent.d.ts +0 -14
- package/dist/src/json.d.ts +0 -18
- package/dist/src/json.js +0 -44
- package/dist/src/participants.d.ts +0 -7
- package/dist/src/participants.js +0 -13
- package/dist/src/payment.d.ts +0 -164
- package/dist/src/payment.js +0 -439
- package/dist/src/profit.d.ts +0 -28
- package/dist/src/profit.js +0 -34
- package/dist/src/sort.d.ts +0 -36
- package/dist/src/sort.js +0 -39
- package/dist/src/stats.d.ts +0 -7
- package/dist/src/stats.js +0 -8
- package/dist/src/time.d.ts +0 -54
- package/dist/src/time.js +0 -106
- package/dist/src/tokens.d.ts +0 -3675
- package/dist/src/units.d.ts +0 -17
- package/dist/src/units.js +0 -79
- package/dist/src/zkp2p-types.d.ts +0 -48
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/scripts/convert-svg.ts +0 -22
- package/src/chain.ts +0 -27
- package/src/contracts.ts +0 -89
- package/src/conversionRates.ts +0 -356
- package/src/currencies.ts +0 -286
- package/src/data/countries.json +0 -1099
- package/src/deposit.ts +0 -2
- package/src/events.ts +0 -21
- package/src/flags/eur.svg +0 -4
- package/src/flags/usd.svg +0 -25
- package/src/flags.ts +0 -4
- package/src/global.d.ts +0 -9
- package/src/ids.ts +0 -137
- package/src/index.ts +0 -16
- package/src/input.ts +0 -35
- package/src/intent.ts +0 -15
- package/src/json.ts +0 -42
- package/src/participants.ts +0 -14
- package/src/payment.ts +0 -573
- package/src/profit.ts +0 -55
- package/src/sort.ts +0 -49
- package/src/stats.ts +0 -10
- package/src/time.ts +0 -123
- package/src/tokens.ts +0 -159
- package/src/units.ts +0 -120
- package/src/zkp2p-types.ts +0 -55
- package/tsconfig.json +0 -18
- /package/dist/{scripts/convert-svg.d.ts → chain.test.d.ts} +0 -0
- /package/dist/{src/deposit.js → contracts.test.d.ts} +0 -0
- /package/dist/{src/intent.js → conversionRates.test.d.ts} +0 -0
- /package/dist/{src/zkp2p-types.js → currencies.test.d.ts} +0 -0
- /package/dist/{src/flags.d.ts → flags.d.ts} +0 -0
- /package/dist/{src/flags.js → flags.js} +0 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Payment provider definitions and utilities for Provex protocol.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single source of truth for all supported payment methods,
|
|
5
|
+
* including their contract IDs, icons, risk levels, and tier requirements.
|
|
6
|
+
*
|
|
7
|
+
* @remarks
|
|
8
|
+
* **Supported Payment Providers:**
|
|
9
|
+
* - US: Venmo, Zelle (Chase/BoFA/Citi), CashApp, PayPal, Chime
|
|
10
|
+
* - International: Revolut, Wise, Monzo, N26, Alipay, MercadoPago, RBC
|
|
11
|
+
*
|
|
12
|
+
* **Provider Identification:**
|
|
13
|
+
* - V2: Per-provider verifier contract addresses
|
|
14
|
+
* - V3: keccak256(providerKey) as bytes32 payment method ID
|
|
15
|
+
*
|
|
16
|
+
* **Risk Levels (Base chain only):**
|
|
17
|
+
* - Low risk (Revolut, Wise, Monzo, MercadoPago): 5x cap multiplier, no cooldown
|
|
18
|
+
* - Medium risk (Zelle): 1.5x cap multiplier, cooldown applies
|
|
19
|
+
* - High risk (Venmo, CashApp): 1x cap multiplier, cooldown applies
|
|
20
|
+
* - Highest risk (PayPal): 0.75x cap multiplier, requires Peer Plus tier
|
|
21
|
+
*
|
|
22
|
+
* @see {@link reputation} for tier system
|
|
23
|
+
* @see {@link currencies} for supported currencies per provider
|
|
24
|
+
*/
|
|
25
|
+
import { type Hex } from "viem";
|
|
26
|
+
/** Returns true if a provider should be hidden from user-facing flows. */
|
|
27
|
+
export declare function isProviderDisabled(key: string, configDisabled?: boolean): boolean;
|
|
28
|
+
import type { TokenInfo } from "./tokens.js";
|
|
29
|
+
import type { ConversionRateInfo, ProviderRates } from "./conversionRates.js";
|
|
30
|
+
import { type Currency } from "./currencies.js";
|
|
31
|
+
import { ChainId } from "./chain.js";
|
|
32
|
+
/**
|
|
33
|
+
* Generate a contract ID (keccak256 hash) for a provider key.
|
|
34
|
+
* Used to identify payment methods on-chain (e.g., 'venmo' → bytes32).
|
|
35
|
+
*
|
|
36
|
+
* @param key - The provider key (e.g., 'venmo', 'zelle')
|
|
37
|
+
* @returns The contract ID as a hex string
|
|
38
|
+
*/
|
|
39
|
+
export declare const providerKeyToContractId: (key: string) => `0x${string}`;
|
|
40
|
+
/**
|
|
41
|
+
* Compute the payeeDetailsHash for a plaintext payment identifier.
|
|
42
|
+
* This is the on-chain hash stored in deposit verifier records.
|
|
43
|
+
*
|
|
44
|
+
* The depositor passes this hash when creating a deposit. Buyers look it up
|
|
45
|
+
* via an API (or custom storage) to get the plaintext back.
|
|
46
|
+
*
|
|
47
|
+
* Uses `keccak256(utf8bytes(identifier))` — matches the contract and API convention.
|
|
48
|
+
*
|
|
49
|
+
* @param identifier - Plaintext payment ID (e.g., '@myvenmo', 'user@email.com', '+1234567890')
|
|
50
|
+
* @returns The payeeDetailsHash as a hex string
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```ts
|
|
54
|
+
* import { computePayeeDetailsHash } from '@provex/utils/payment'
|
|
55
|
+
*
|
|
56
|
+
* const hash = computePayeeDetailsHash('@myvenmo')
|
|
57
|
+
* // Use in createDeposit({ paymentMethodData: [{ payeeDetails: hash, ... }] })
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare const computePayeeDetailsHash: (identifier: string) => Hex;
|
|
61
|
+
/**
|
|
62
|
+
* Payment providers, including manual
|
|
63
|
+
*/
|
|
64
|
+
export declare const providers: {
|
|
65
|
+
readonly VENMO: "venmo";
|
|
66
|
+
readonly ZELLE: "zelle";
|
|
67
|
+
readonly CASHAPP: "cashapp";
|
|
68
|
+
readonly REVOLUT: "revolut";
|
|
69
|
+
readonly WISE: "wise";
|
|
70
|
+
readonly MERCADOPAGO: "mercadopago";
|
|
71
|
+
readonly MANUAL: "manual";
|
|
72
|
+
readonly PAYPAL: "paypal";
|
|
73
|
+
readonly MONZO: "monzo";
|
|
74
|
+
readonly N26: "n26";
|
|
75
|
+
readonly ALIPAY: "alipay";
|
|
76
|
+
readonly CHIME: "chime";
|
|
77
|
+
readonly ROYALBANKCANADA: "royalbankcanada";
|
|
78
|
+
readonly IDFC: "idfc";
|
|
79
|
+
};
|
|
80
|
+
export type ProviderKey = typeof providers[keyof typeof providers];
|
|
81
|
+
/** Distinct keys for payment sub-providers (currently only used by Zelle) */
|
|
82
|
+
export declare const subProviders: {
|
|
83
|
+
readonly CHASE: "zelle-chase";
|
|
84
|
+
readonly BANK_OF_AMERICA: "zelle-bofa";
|
|
85
|
+
readonly CITI: "zelle-citi";
|
|
86
|
+
};
|
|
87
|
+
/** Sub-provider key (providers within providers) */
|
|
88
|
+
export type SubProviderKey = typeof subProviders[keyof typeof subProviders];
|
|
89
|
+
/**
|
|
90
|
+
* Extension platform keys - the platform identifiers used by the PeerAuth extension.
|
|
91
|
+
* For Zelle sub-providers, these are the bank names without the 'zelle-' prefix.
|
|
92
|
+
* Must match the folder names in @zkp2p/providers package.
|
|
93
|
+
*/
|
|
94
|
+
export declare const extensionPlatforms: {
|
|
95
|
+
readonly CHASE: "chase";
|
|
96
|
+
readonly BOFA: "bankofamerica";
|
|
97
|
+
readonly CITI: "citi";
|
|
98
|
+
};
|
|
99
|
+
/** Extension platform key type */
|
|
100
|
+
export type ExtensionPlatformKey = typeof extensionPlatforms[keyof typeof extensionPlatforms];
|
|
101
|
+
/** Action type for a provider */
|
|
102
|
+
export type ProviderKeyActionType = 'transfer' | 'send';
|
|
103
|
+
/** Validatable provider key */
|
|
104
|
+
export type ValidatableProviderKey = Exclude<ProviderKey, typeof providers.MANUAL>;
|
|
105
|
+
/** Transparent platforms */
|
|
106
|
+
export type TransparentPlatforms = typeof providers.ZELLE;
|
|
107
|
+
/** Platform key (includes extension platform keys for type safety) */
|
|
108
|
+
export type PlatformKey = Exclude<ValidatableProviderKey, TransparentPlatforms> | SubProviderKey | ExtensionPlatformKey;
|
|
109
|
+
/** Action type */
|
|
110
|
+
export type ActionType = `${ProviderKeyActionType}_${ProviderKey}`;
|
|
111
|
+
/**
|
|
112
|
+
* Platform risk levels for the reputation system (Base chain only)
|
|
113
|
+
* Determines cap multipliers and cooldown enforcement
|
|
114
|
+
*/
|
|
115
|
+
export type PlatformRiskLevel = 'low' | 'medium' | 'high' | 'highest';
|
|
116
|
+
/**
|
|
117
|
+
* Universal taker tier names for the reputation system.
|
|
118
|
+
* Use this const instead of string literals wherever a tier is referenced.
|
|
119
|
+
*/
|
|
120
|
+
export declare const tiers: {
|
|
121
|
+
readonly PEASANT: "peasant";
|
|
122
|
+
readonly NEUTRAL: "neutral";
|
|
123
|
+
readonly PLUS: "plus";
|
|
124
|
+
readonly PRO: "pro";
|
|
125
|
+
readonly PLATINUM: "platinum";
|
|
126
|
+
/** Manually assigned VIP tier — cannot be reached via volume alone */
|
|
127
|
+
readonly PRESIDENT: "president";
|
|
128
|
+
};
|
|
129
|
+
export type TakerTier = typeof tiers[keyof typeof tiers];
|
|
130
|
+
/** Valid peer tier names */
|
|
131
|
+
export type PeerTier = 'peer_peasant' | 'peer' | 'peer_plus' | 'peer_pro' | 'peer_platinum' | 'peer_president';
|
|
132
|
+
/**
|
|
133
|
+
* Mapping from universal tier names to peer-specific tier names
|
|
134
|
+
*/
|
|
135
|
+
export declare const tierToPeerTier: Record<TakerTier, PeerTier>;
|
|
136
|
+
/**
|
|
137
|
+
* Mapping from peer tier names to universal tier names
|
|
138
|
+
*/
|
|
139
|
+
export declare const peerTierToTier: Record<PeerTier, TakerTier>;
|
|
140
|
+
/**
|
|
141
|
+
* Convert a peer tier name to universal tier name
|
|
142
|
+
* @param peerTier - peer tier name (e.g., 'peer_peasant')
|
|
143
|
+
* @returns Universal tier name
|
|
144
|
+
* @throws Error if peerTier is not a valid peer tier
|
|
145
|
+
*/
|
|
146
|
+
export declare function fromPeerTier(peerTier: PeerTier): TakerTier;
|
|
147
|
+
/** Provider key to validation key */
|
|
148
|
+
export declare const providerKeyToValidationKey: Record<ValidatableProviderKey, string>;
|
|
149
|
+
/** Validation key */
|
|
150
|
+
export type ValidationKey = typeof providerKeyToValidationKey[keyof typeof providerKeyToValidationKey];
|
|
151
|
+
/** Limits for a payment method */
|
|
152
|
+
export type Limits = {
|
|
153
|
+
min: number;
|
|
154
|
+
};
|
|
155
|
+
/** Send link options */
|
|
156
|
+
export type SendLinkOptions = {
|
|
157
|
+
username: string;
|
|
158
|
+
amount: bigint;
|
|
159
|
+
subProvider?: SubProviderKey;
|
|
160
|
+
qrCode?: boolean;
|
|
161
|
+
};
|
|
162
|
+
/** Send link */
|
|
163
|
+
export type SendLink = (options: SendLinkOptions) => string | null;
|
|
164
|
+
/** Payment sub-provider config */
|
|
165
|
+
export type PaymentSubProviderConfig = {
|
|
166
|
+
key: SubProviderKey;
|
|
167
|
+
name: string;
|
|
168
|
+
icon?: string;
|
|
169
|
+
color?: string;
|
|
170
|
+
usernameType?: string;
|
|
171
|
+
v2Verifiers: (chain: ChainId) => Hex[];
|
|
172
|
+
sendLink: SendLink;
|
|
173
|
+
paymentMethod: number;
|
|
174
|
+
/**
|
|
175
|
+
* Platform key used by the PeerAuth extension for this sub-provider.
|
|
176
|
+
* For Zelle sub-providers, this is the bank name without the 'zelle-' prefix.
|
|
177
|
+
* e.g., 'zelle-chase' -> 'chase', 'zelle-bofa' -> 'bofa'
|
|
178
|
+
*/
|
|
179
|
+
extensionPlatform: ExtensionPlatformKey;
|
|
180
|
+
};
|
|
181
|
+
/** Payment config */
|
|
182
|
+
export type PaymentConfig = {
|
|
183
|
+
icon: string;
|
|
184
|
+
key: ProviderKey;
|
|
185
|
+
name: string;
|
|
186
|
+
color: string;
|
|
187
|
+
/**
|
|
188
|
+
* Optional color to use specifically for charts, distinct from brand color if needed
|
|
189
|
+
*/
|
|
190
|
+
chartColor?: string;
|
|
191
|
+
/**
|
|
192
|
+
* Optional chart color overrides for light/dark themes
|
|
193
|
+
*/
|
|
194
|
+
chartColorLight?: string;
|
|
195
|
+
chartColorDark?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Optional background color for the icon (useful for dark icons that need contrast)
|
|
198
|
+
*/
|
|
199
|
+
backgroundColor?: string;
|
|
200
|
+
usernameType: string;
|
|
201
|
+
validationKey: ValidationKey | null;
|
|
202
|
+
/**
|
|
203
|
+
* V2 verifier contract addresses (legacy, for backward compatibility)
|
|
204
|
+
*/
|
|
205
|
+
v2Verifiers: string[];
|
|
206
|
+
limits: Limits;
|
|
207
|
+
/**
|
|
208
|
+
* Contract ID (keccak256 hash of the provider key) for V3 indexer lookups
|
|
209
|
+
* This is the primary identifier for payment methods in V3
|
|
210
|
+
*/
|
|
211
|
+
contractId: Hex;
|
|
212
|
+
/**
|
|
213
|
+
* Set of sub-provider keys that this payment method supports. Empty when none.
|
|
214
|
+
*/
|
|
215
|
+
subProviders: Set<PaymentSubProviderConfig>;
|
|
216
|
+
list: Hex[];
|
|
217
|
+
sendLink?: SendLink;
|
|
218
|
+
/**
|
|
219
|
+
* Risk level for reputation system (Base only)
|
|
220
|
+
* Determines cap multiplier and cooldown enforcement
|
|
221
|
+
*/
|
|
222
|
+
riskLevel?: PlatformRiskLevel;
|
|
223
|
+
/**
|
|
224
|
+
* Cap multiplier for reputation system
|
|
225
|
+
* Applied to base tier cap to get effective cap
|
|
226
|
+
*/
|
|
227
|
+
capMultiplier?: number;
|
|
228
|
+
/**
|
|
229
|
+
* Whether cooldown applies to this platform
|
|
230
|
+
*/
|
|
231
|
+
hasCooldown?: boolean;
|
|
232
|
+
/**
|
|
233
|
+
* Whether the extension sends transaction amounts in cents (integer, e.g. 5000 for $50).
|
|
234
|
+
* When true, divide by 100 before displaying amounts to the user.
|
|
235
|
+
*/
|
|
236
|
+
amountInCents?: boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Minimum tier required to access (null = no restriction)
|
|
239
|
+
*/
|
|
240
|
+
minimumTier?: TakerTier | null;
|
|
241
|
+
/**
|
|
242
|
+
* Whether this payment method requires manual approval from the peer.xyz
|
|
243
|
+
* backend before deposits become visible to buyers.
|
|
244
|
+
* Approval is handled by peer.xyz — use approvalFormUrl to direct makers.
|
|
245
|
+
*/
|
|
246
|
+
depositRequiresApproval?: boolean;
|
|
247
|
+
/**
|
|
248
|
+
* URL of the approval form to direct makers to when depositRequiresApproval is true.
|
|
249
|
+
*/
|
|
250
|
+
approvalFormUrl?: string;
|
|
251
|
+
/**
|
|
252
|
+
* When true, this provider is hidden from user-facing flows (provider
|
|
253
|
+
* selection, deposit creation, buy flows). The config still exists for
|
|
254
|
+
* dev/testing — set VITE_ENABLE_PAYPAL=true to override in dev.
|
|
255
|
+
*/
|
|
256
|
+
disabled?: boolean;
|
|
257
|
+
};
|
|
258
|
+
/** Validation deposit data payment identifier */
|
|
259
|
+
export type ValidationDepositDataPaymentIdentifier = Partial<{
|
|
260
|
+
[key in Exclude<ValidationKey, null>]: string;
|
|
261
|
+
}>;
|
|
262
|
+
/** Validation deposit data */
|
|
263
|
+
export type ValidationDepositData = ValidationDepositDataPaymentIdentifier & {
|
|
264
|
+
telegramUsername: string;
|
|
265
|
+
};
|
|
266
|
+
/** Data encoding for zelle urls */
|
|
267
|
+
export declare const dataEncoding: (data: string) => string;
|
|
268
|
+
/** Default Zelle send link */
|
|
269
|
+
export declare const defaultZelleSendLink: (options: SendLinkOptions) => string | null;
|
|
270
|
+
/** Global configuration for all supported sub-providers. Other modules can import this directly. */
|
|
271
|
+
export declare const subProviderConfigs: Partial<Record<ProviderKey, Record<SubProviderKey, PaymentSubProviderConfig>>>;
|
|
272
|
+
/** Payment method icon mappings */
|
|
273
|
+
export declare const providerConfigs: (chainId: ChainId) => Record<ProviderKey, PaymentConfig>;
|
|
274
|
+
/**
|
|
275
|
+
* Default platform risk configuration for providers not explicitly configured
|
|
276
|
+
* Assumes medium risk as a safe default
|
|
277
|
+
*/
|
|
278
|
+
export declare const DEFAULT_PLATFORM_RISK: {
|
|
279
|
+
riskLevel: PlatformRiskLevel;
|
|
280
|
+
capMultiplier: number;
|
|
281
|
+
hasCooldown: boolean;
|
|
282
|
+
minimumTier: TakerTier | null;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Platform risk configuration interface
|
|
286
|
+
*/
|
|
287
|
+
export interface PlatformRiskConfig {
|
|
288
|
+
riskLevel: PlatformRiskLevel;
|
|
289
|
+
capMultiplier: number;
|
|
290
|
+
hasCooldown: boolean;
|
|
291
|
+
minimumTier: TakerTier | null;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Get the risk configuration for a payment platform
|
|
295
|
+
* @param chainId - The chain ID
|
|
296
|
+
* @param providerKey - The provider key
|
|
297
|
+
* @returns Platform risk configuration
|
|
298
|
+
*/
|
|
299
|
+
export declare function getPlatformRisk(chainId: ChainId, providerKey: ProviderKey): PlatformRiskConfig;
|
|
300
|
+
/**
|
|
301
|
+
* Payment verifier to key map
|
|
302
|
+
* Includes both main providers and flattened sub-providers
|
|
303
|
+
*/
|
|
304
|
+
export declare const paymentVerifierToKey: (chainId: ChainId | null) => Map<string, ProviderKey>;
|
|
305
|
+
/**
|
|
306
|
+
* Provider contractId to config map (reverse lookup by keccak256 hash)
|
|
307
|
+
* Includes both main providers and flattened sub-providers with their own contract IDs
|
|
308
|
+
* Note: Keys are stored as lowercase for case-insensitive lookup
|
|
309
|
+
*/
|
|
310
|
+
export declare const providerByContractId: (chainId: ChainId) => Map<`0x${string}`, PaymentConfig>;
|
|
311
|
+
/**
|
|
312
|
+
* Get provider config by contractId (keccak256 hash)
|
|
313
|
+
* Supports both main providers and sub-providers (e.g., zelle-chase, zelle-bofa, zelle-citi)
|
|
314
|
+
* @param chainId - The chain ID
|
|
315
|
+
* @param contractId - The contract ID (keccak256 hash) to lookup
|
|
316
|
+
* @returns PaymentConfig or null if not found
|
|
317
|
+
*/
|
|
318
|
+
export declare const getProviderByContractId: (chainId: ChainId, contractId: Hex) => PaymentConfig | null;
|
|
319
|
+
/**
|
|
320
|
+
* Get provider name by contractId (keccak256 hash)
|
|
321
|
+
* Supports both main providers and sub-providers
|
|
322
|
+
* @param chainId - The chain ID
|
|
323
|
+
* @param contractId - The contract ID (keccak256 hash) to lookup
|
|
324
|
+
* @returns Provider name or the contract ID if not found
|
|
325
|
+
*/
|
|
326
|
+
export declare const getProviderNameByContractId: (chainId: ChainId, contractId: Hex) => string;
|
|
327
|
+
/** Provider key to V2 verifiers map (legacy, for backward compatibility) */
|
|
328
|
+
export declare const providerKeyToVerifiersMap: (chainId: ChainId) => Map<ProviderKey, `0x${string}`[]>;
|
|
329
|
+
/** Provider key to verifiers */
|
|
330
|
+
export declare const providerKeyToVerifiers: (chainId: ChainId, providerKey: ProviderKey) => Hex[] | null;
|
|
331
|
+
/** Verifier gets key */
|
|
332
|
+
export declare const verifierGetsKey: (chainId: ChainId | null, verifierAddress: string) => ProviderKey;
|
|
333
|
+
/**
|
|
334
|
+
* Utility function to get payment method icon
|
|
335
|
+
* @param key - The provider key (main provider or sub-provider like 'zelle-chase')
|
|
336
|
+
* @returns The icon string used for iconify
|
|
337
|
+
*/
|
|
338
|
+
export declare const getPaymentIcon: (chainId: ChainId | null, key: ProviderKey) => string;
|
|
339
|
+
/**
|
|
340
|
+
* Utility function to get payment method configuration by verifier address
|
|
341
|
+
* @param verifierAddress - The verifier address
|
|
342
|
+
* @returns The payment method configuration
|
|
343
|
+
*/
|
|
344
|
+
export declare const getPaymentMethodConfig: (chainId: ChainId | null, verifierAddress: string) => PaymentConfig | null;
|
|
345
|
+
/**
|
|
346
|
+
* Utility function to get payment method minimum limit by verifier address
|
|
347
|
+
* @param key - The provider key
|
|
348
|
+
* @returns The minimum limit
|
|
349
|
+
*/
|
|
350
|
+
export declare const getPaymentMethodMinimum: (chainId: ChainId | null, key: ProviderKey) => number;
|
|
351
|
+
/**
|
|
352
|
+
* Utility function to get payment method name by verifier address or provider key
|
|
353
|
+
* Handles both main providers and sub-providers (e.g., 'zelle-chase')
|
|
354
|
+
*/
|
|
355
|
+
export declare const getPaymentMethodName: (chainId: ChainId | null, verifierAddress: string | ProviderKey) => string;
|
|
356
|
+
/**
|
|
357
|
+
* Calculate effective minimum amount (higher of user minimum or payment provider minimum)
|
|
358
|
+
* @param userMinAmountWei - The user minimum amount
|
|
359
|
+
* @param tokenInfo - The token info
|
|
360
|
+
* @param providerRates - The provider rates
|
|
361
|
+
* @returns The effective minimum amount
|
|
362
|
+
*/
|
|
363
|
+
export declare function calculateEffectiveMinimum(chainId: ChainId, userMinAmountWei: string | bigint, tokenInfo: TokenInfo, providerRates?: ProviderRates<ConversionRateInfo>): {
|
|
364
|
+
userMinAmountWei: bigint;
|
|
365
|
+
providerMinAmountWei: bigint;
|
|
366
|
+
effectiveMinAmountWei: bigint;
|
|
367
|
+
formattedEffectiveMin: string;
|
|
368
|
+
};
|
|
369
|
+
/**
|
|
370
|
+
* Helper function to get payment provider minimum limit (returns decimal number for config)
|
|
371
|
+
* @param key - The provider key
|
|
372
|
+
* @returns The minimum limit
|
|
373
|
+
*/
|
|
374
|
+
export declare function getPaymentProviderMinimum(chainId: ChainId, key: ProviderKey): number;
|
|
375
|
+
/**
|
|
376
|
+
* External/unregistered payment methods that are known but not in providerConfigs.
|
|
377
|
+
* These are payment methods registered by external parties (e.g., other protocols).
|
|
378
|
+
* Maps payment method ID to metadata to prevent error logging.
|
|
379
|
+
*/
|
|
380
|
+
export declare const externalPaymentMethods: Record<Hex, {
|
|
381
|
+
name: string;
|
|
382
|
+
originTxHash: Hex;
|
|
383
|
+
chainId: ChainId;
|
|
384
|
+
description?: string;
|
|
385
|
+
}>;
|
|
386
|
+
/**
|
|
387
|
+
* Check if a payment method is an external/unregistered payment method
|
|
388
|
+
* @param paymentMethodId - The payment method ID
|
|
389
|
+
* @returns True if the payment method is external, false otherwise
|
|
390
|
+
*/
|
|
391
|
+
export declare const isExternalPaymentMethod: (paymentMethodId: Hex) => boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Get external payment method info
|
|
394
|
+
* @param paymentMethodId - The payment method ID
|
|
395
|
+
* @returns The external payment method info or undefined
|
|
396
|
+
*/
|
|
397
|
+
export declare const getExternalPaymentMethod: (paymentMethodId: Hex) => {
|
|
398
|
+
name: string;
|
|
399
|
+
originTxHash: Hex;
|
|
400
|
+
chainId: ChainId;
|
|
401
|
+
description?: string;
|
|
402
|
+
};
|
|
403
|
+
/**
|
|
404
|
+
* Check if a payment method is known (either in providerConfigs or external)
|
|
405
|
+
* @param chainId - The chain ID
|
|
406
|
+
* @param verifierAddress - The verifier address
|
|
407
|
+
* @returns True if the payment method is known, false otherwise
|
|
408
|
+
*/
|
|
409
|
+
export declare const isPaymentMethodKnown: (chainId: ChainId | null, verifierAddress: string) => boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Check if a payment method ID is known (either in providerConfigs or external)
|
|
412
|
+
* @param chainId - The chain ID
|
|
413
|
+
* @param paymentMethodId - The payment method ID
|
|
414
|
+
* @param verifierAddress - Optional verifier address for checking providerConfigs
|
|
415
|
+
* @returns True if the payment method is known, false otherwise
|
|
416
|
+
*/
|
|
417
|
+
export declare const isPaymentMethodIdKnown: (chainId: ChainId | null, paymentMethodId: Hex, verifierAddress?: string) => boolean;
|
|
418
|
+
/**
|
|
419
|
+
* Get all payment methods including sub-providers
|
|
420
|
+
* @param includeSubProviders - Whether to include sub-providers as separate entries (default: false)
|
|
421
|
+
* @returns All payment methods
|
|
422
|
+
*/
|
|
423
|
+
export declare const getAllPaymentMethods: (chainId: ChainId, includeSubProviders?: boolean) => ProviderKey[];
|
|
424
|
+
/**
|
|
425
|
+
* Get all verifiable payment methods including sub-providers
|
|
426
|
+
* @param includeSubProviders - Whether to include sub-providers as separate entries (default: false)
|
|
427
|
+
* @returns All verifiable payment methods
|
|
428
|
+
*/
|
|
429
|
+
export declare const verifiablePaymentMethods: (chainId: ChainId, includeSubProviders?: boolean) => ProviderKey[];
|
|
430
|
+
/**
|
|
431
|
+
* Get supported currencies for a payment provider.
|
|
432
|
+
* Returns only the currencies that are in the provider's supported list.
|
|
433
|
+
*
|
|
434
|
+
* @param config - The payment provider configuration
|
|
435
|
+
* @returns Array of Currency objects supported by this provider
|
|
436
|
+
*
|
|
437
|
+
* @example
|
|
438
|
+
* ```ts
|
|
439
|
+
* const zelle = providerConfigs(base.id).zelle
|
|
440
|
+
* const currencies = getCurrenciesForProvider(zelle)
|
|
441
|
+
* // Returns [Currency(USD)] - Zelle only supports USD
|
|
442
|
+
*
|
|
443
|
+
* const revolut = providerConfigs(base.id).revolut
|
|
444
|
+
* const currencies = getCurrenciesForProvider(revolut)
|
|
445
|
+
* // Returns [Currency(USD), Currency(EUR), Currency(GBP), ...] - Revolut supports many
|
|
446
|
+
* ```
|
|
447
|
+
*/
|
|
448
|
+
export declare function getCurrenciesForProvider(config: PaymentConfig): Currency[];
|
|
449
|
+
/**
|
|
450
|
+
* Check if a provider key is a sub-provider (e.g., 'zelle-chase', 'zelle-bofa')
|
|
451
|
+
* @param key - The provider key to check
|
|
452
|
+
* @returns True if the key is a sub-provider
|
|
453
|
+
*/
|
|
454
|
+
export declare function isSubProviderKey(key: string): key is SubProviderKey;
|
|
455
|
+
/**
|
|
456
|
+
* Get the parent provider key for a sub-provider.
|
|
457
|
+
* Returns null if the key is not a sub-provider.
|
|
458
|
+
* @param key - The sub-provider key (e.g., 'zelle-chase')
|
|
459
|
+
* @returns The parent provider key (e.g., 'zelle') or null
|
|
460
|
+
*/
|
|
461
|
+
export declare function getParentProviderKey(key: string): ProviderKey | null;
|
|
462
|
+
/**
|
|
463
|
+
* Get the extension platform key for a provider or sub-provider.
|
|
464
|
+
* For sub-providers like 'zelle-chase', returns the extensionPlatform from config (e.g., 'chase').
|
|
465
|
+
* For main providers, returns the provider key itself.
|
|
466
|
+
* @param key - The provider or sub-provider key
|
|
467
|
+
* @returns The platform key to use with the PeerAuth extension
|
|
468
|
+
*/
|
|
469
|
+
export declare function getExtensionPlatform(key: ProviderKey | SubProviderKey): PlatformKey;
|
|
470
|
+
/**
|
|
471
|
+
* Get icon and color info for both parent and sub-provider.
|
|
472
|
+
* Returns array of icon configs: [parent, subProvider] for sub-providers, [provider] for main providers.
|
|
473
|
+
* @param chainId - The chain ID for config lookup
|
|
474
|
+
* @param key - The provider or sub-provider key
|
|
475
|
+
* @returns Array of icon configs with icon string and optional color
|
|
476
|
+
*/
|
|
477
|
+
export declare function getProviderIconStack(chainId: ChainId, key: ProviderKey | SubProviderKey): Array<{
|
|
478
|
+
icon: string;
|
|
479
|
+
color?: string;
|
|
480
|
+
name: string;
|
|
481
|
+
}>;
|