@provex/utils 1.0.16 → 1.2.3
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/src/chain.d.ts +436 -4
- package/dist/src/chain.js +80 -0
- package/dist/src/chain.test.d.ts +1 -0
- package/dist/src/chain.test.js +112 -0
- package/dist/src/contracts.d.ts +196 -20
- package/dist/src/contracts.js +245 -17
- package/dist/src/contracts.test.d.ts +1 -0
- package/dist/src/contracts.test.js +243 -0
- package/dist/src/conversionRates.d.ts +99 -8
- package/dist/src/conversionRates.js +74 -4
- package/dist/src/conversionRates.test.d.ts +1 -0
- package/dist/src/conversionRates.test.js +473 -0
- package/dist/src/currencies.d.ts +113 -9
- package/dist/src/currencies.js +119 -38
- package/dist/src/currencies.test.d.ts +1 -0
- package/dist/src/currencies.test.js +343 -0
- package/dist/src/data/countries.json +166 -166
- package/dist/src/deposit.d.ts +69 -1
- package/dist/src/deposit.js +52 -1
- package/dist/src/depositKeys.d.ts +154 -0
- package/dist/src/depositKeys.js +104 -0
- package/dist/src/depositKeys.test.d.ts +1 -0
- package/dist/src/depositKeys.test.js +231 -0
- package/dist/src/endpoints.d.ts +51 -0
- package/dist/src/endpoints.js +70 -0
- package/dist/src/endpoints.test.d.ts +1 -0
- package/dist/src/endpoints.test.js +54 -0
- package/dist/src/events.d.ts +40 -2
- package/dist/src/events.js +86 -10
- package/dist/src/events.test.d.ts +1 -0
- package/dist/src/events.test.js +111 -0
- package/dist/src/fees.d.ts +136 -0
- package/dist/src/fees.js +178 -0
- package/dist/src/fees.test.d.ts +1 -0
- package/dist/src/fees.test.js +165 -0
- package/dist/src/ids.d.ts +125 -22
- package/dist/src/ids.js +211 -61
- package/dist/src/ids.test.d.ts +1 -0
- package/dist/src/ids.test.js +607 -0
- package/dist/src/index.d.ts +30 -1
- package/dist/src/index.js +30 -1
- package/dist/src/input.d.ts +23 -4
- package/dist/src/input.js +23 -4
- package/dist/src/intent.d.ts +38 -2
- package/dist/src/intent.js +28 -1
- package/dist/src/intent.test.d.ts +1 -0
- package/dist/src/intent.test.js +119 -0
- package/dist/src/json.d.ts +38 -1
- package/dist/src/json.js +38 -2
- package/dist/src/normalization.d.ts +224 -0
- package/dist/src/normalization.js +119 -0
- package/dist/src/normalization.test.d.ts +1 -0
- package/dist/src/normalization.test.js +284 -0
- package/dist/src/participants.d.ts +19 -4
- package/dist/src/participants.js +19 -4
- package/dist/src/payment.d.ts +333 -16
- package/dist/src/payment.js +768 -58
- package/dist/src/payment.test.d.ts +1 -0
- package/dist/src/payment.test.js +272 -0
- package/dist/src/peer-types.d.ts +327 -0
- package/dist/src/peer-types.js +169 -0
- package/dist/src/profit.d.ts +26 -5
- package/dist/src/profit.js +31 -8
- package/dist/src/profit.test.d.ts +1 -0
- package/dist/src/profit.test.js +315 -0
- package/dist/src/reputation.d.ts +125 -0
- package/dist/src/reputation.js +188 -0
- package/dist/src/reputation.test.d.ts +1 -0
- package/dist/src/reputation.test.js +156 -0
- package/dist/src/sort.d.ts +49 -10
- package/dist/src/sort.js +40 -9
- package/dist/src/sort.test.d.ts +1 -0
- package/dist/src/sort.test.js +216 -0
- package/dist/src/stateKey.d.ts +35 -0
- package/dist/src/stateKey.js +36 -0
- package/dist/src/stats.d.ts +55 -1
- package/dist/src/stats.js +46 -1
- package/dist/src/stats.test.d.ts +1 -0
- package/dist/src/stats.test.js +104 -0
- package/dist/src/time.d.ts +59 -9
- package/dist/src/time.js +71 -15
- package/dist/src/time.test.d.ts +1 -0
- package/dist/src/time.test.js +231 -0
- package/dist/src/tokens.d.ts +11972 -145
- package/dist/src/tokens.js +98 -17
- package/dist/src/tokens.test.d.ts +1 -0
- package/dist/src/tokens.test.js +193 -0
- package/dist/src/units.d.ts +183 -0
- package/dist/src/units.js +206 -6
- package/dist/src/units.test.d.ts +1 -0
- package/dist/src/units.test.js +327 -0
- package/dist/src/zkp2p-types.d.ts +273 -4
- package/dist/src/zkp2p-types.js +169 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +116 -26
- 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/src/payment.d.ts
CHANGED
|
@@ -1,7 +1,63 @@
|
|
|
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
|
+
*/
|
|
1
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;
|
|
2
28
|
import type { TokenInfo } from "./tokens.js";
|
|
3
29
|
import type { ConversionRateInfo, ProviderRates } from "./conversionRates.js";
|
|
30
|
+
import { type Currency } from "./currencies.js";
|
|
4
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;
|
|
5
61
|
/**
|
|
6
62
|
* Payment providers, including manual
|
|
7
63
|
*/
|
|
@@ -15,26 +71,79 @@ export declare const providers: {
|
|
|
15
71
|
readonly MANUAL: "manual";
|
|
16
72
|
readonly PAYPAL: "paypal";
|
|
17
73
|
readonly MONZO: "monzo";
|
|
74
|
+
readonly N26: "n26";
|
|
75
|
+
readonly ALIPAY: "alipay";
|
|
76
|
+
readonly CHIME: "chime";
|
|
77
|
+
readonly ROYALBANKCANADA: "royalbankcanada";
|
|
78
|
+
readonly IDFC: "idfc";
|
|
18
79
|
};
|
|
19
80
|
export type ProviderKey = typeof providers[keyof typeof providers];
|
|
20
81
|
/** Distinct keys for payment sub-providers (currently only used by Zelle) */
|
|
21
82
|
export declare const subProviders: {
|
|
22
|
-
readonly CHASE: "chase";
|
|
23
|
-
readonly BANK_OF_AMERICA: "
|
|
24
|
-
readonly CITI: "citi";
|
|
83
|
+
readonly CHASE: "zelle-chase";
|
|
84
|
+
readonly BANK_OF_AMERICA: "zelle-bofa";
|
|
85
|
+
readonly CITI: "zelle-citi";
|
|
25
86
|
};
|
|
26
87
|
/** Sub-provider key (providers within providers) */
|
|
27
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];
|
|
28
101
|
/** Action type for a provider */
|
|
29
102
|
export type ProviderKeyActionType = 'transfer' | 'send';
|
|
30
103
|
/** Validatable provider key */
|
|
31
104
|
export type ValidatableProviderKey = Exclude<ProviderKey, typeof providers.MANUAL>;
|
|
32
105
|
/** Transparent platforms */
|
|
33
106
|
export type TransparentPlatforms = typeof providers.ZELLE;
|
|
34
|
-
/** Platform key */
|
|
35
|
-
export type PlatformKey = Exclude<ValidatableProviderKey, TransparentPlatforms> | SubProviderKey;
|
|
107
|
+
/** Platform key (includes extension platform keys for type safety) */
|
|
108
|
+
export type PlatformKey = Exclude<ValidatableProviderKey, TransparentPlatforms> | SubProviderKey | ExtensionPlatformKey;
|
|
36
109
|
/** Action type */
|
|
37
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;
|
|
38
147
|
/** Provider key to validation key */
|
|
39
148
|
export declare const providerKeyToValidationKey: Record<ValidatableProviderKey, string>;
|
|
40
149
|
/** Validation key */
|
|
@@ -59,9 +168,15 @@ export type PaymentSubProviderConfig = {
|
|
|
59
168
|
icon?: string;
|
|
60
169
|
color?: string;
|
|
61
170
|
usernameType?: string;
|
|
62
|
-
|
|
171
|
+
v2Verifiers: (chain: ChainId) => Hex[];
|
|
63
172
|
sendLink: SendLink;
|
|
64
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;
|
|
65
180
|
};
|
|
66
181
|
/** Payment config */
|
|
67
182
|
export type PaymentConfig = {
|
|
@@ -69,16 +184,76 @@ export type PaymentConfig = {
|
|
|
69
184
|
key: ProviderKey;
|
|
70
185
|
name: string;
|
|
71
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;
|
|
72
200
|
usernameType: string;
|
|
73
201
|
validationKey: ValidationKey | null;
|
|
74
|
-
|
|
202
|
+
/**
|
|
203
|
+
* V2 verifier contract addresses (legacy, for backward compatibility)
|
|
204
|
+
*/
|
|
205
|
+
v2Verifiers: string[];
|
|
75
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;
|
|
76
212
|
/**
|
|
77
213
|
* Set of sub-provider keys that this payment method supports. Empty when none.
|
|
78
214
|
*/
|
|
79
215
|
subProviders: Set<PaymentSubProviderConfig>;
|
|
80
216
|
list: Hex[];
|
|
81
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;
|
|
82
257
|
};
|
|
83
258
|
/** Validation deposit data payment identifier */
|
|
84
259
|
export type ValidationDepositDataPaymentIdentifier = Partial<{
|
|
@@ -96,9 +271,60 @@ export declare const defaultZelleSendLink: (options: SendLinkOptions) => string
|
|
|
96
271
|
export declare const subProviderConfigs: Partial<Record<ProviderKey, Record<SubProviderKey, PaymentSubProviderConfig>>>;
|
|
97
272
|
/** Payment method icon mappings */
|
|
98
273
|
export declare const providerConfigs: (chainId: ChainId) => Record<ProviderKey, PaymentConfig>;
|
|
99
|
-
/**
|
|
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
|
+
*/
|
|
100
304
|
export declare const paymentVerifierToKey: (chainId: ChainId | null) => Map<string, ProviderKey>;
|
|
101
|
-
/**
|
|
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) */
|
|
102
328
|
export declare const providerKeyToVerifiersMap: (chainId: ChainId) => Map<ProviderKey, `0x${string}`[]>;
|
|
103
329
|
/** Provider key to verifiers */
|
|
104
330
|
export declare const providerKeyToVerifiers: (chainId: ChainId, providerKey: ProviderKey) => Hex[] | null;
|
|
@@ -106,7 +332,7 @@ export declare const providerKeyToVerifiers: (chainId: ChainId, providerKey: Pro
|
|
|
106
332
|
export declare const verifierGetsKey: (chainId: ChainId | null, verifierAddress: string) => ProviderKey;
|
|
107
333
|
/**
|
|
108
334
|
* Utility function to get payment method icon
|
|
109
|
-
* @param key - The provider key
|
|
335
|
+
* @param key - The provider key (main provider or sub-provider like 'zelle-chase')
|
|
110
336
|
* @returns The icon string used for iconify
|
|
111
337
|
*/
|
|
112
338
|
export declare const getPaymentIcon: (chainId: ChainId | null, key: ProviderKey) => string;
|
|
@@ -123,7 +349,8 @@ export declare const getPaymentMethodConfig: (chainId: ChainId | null, verifierA
|
|
|
123
349
|
*/
|
|
124
350
|
export declare const getPaymentMethodMinimum: (chainId: ChainId | null, key: ProviderKey) => number;
|
|
125
351
|
/**
|
|
126
|
-
* Utility function to get payment method name by verifier address
|
|
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')
|
|
127
354
|
*/
|
|
128
355
|
export declare const getPaymentMethodName: (chainId: ChainId | null, verifierAddress: string | ProviderKey) => string;
|
|
129
356
|
/**
|
|
@@ -146,19 +373,109 @@ export declare function calculateEffectiveMinimum(chainId: ChainId, userMinAmoun
|
|
|
146
373
|
*/
|
|
147
374
|
export declare function getPaymentProviderMinimum(chainId: ChainId, key: ProviderKey): number;
|
|
148
375
|
/**
|
|
149
|
-
*
|
|
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)
|
|
150
405
|
* @param chainId - The chain ID
|
|
151
406
|
* @param verifierAddress - The verifier address
|
|
152
407
|
* @returns True if the payment method is known, false otherwise
|
|
153
408
|
*/
|
|
154
409
|
export declare const isPaymentMethodKnown: (chainId: ChainId | null, verifierAddress: string) => boolean;
|
|
155
410
|
/**
|
|
156
|
-
*
|
|
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)
|
|
157
421
|
* @returns All payment methods
|
|
158
422
|
*/
|
|
159
|
-
export declare const getAllPaymentMethods: (chainId: ChainId) => ProviderKey[];
|
|
423
|
+
export declare const getAllPaymentMethods: (chainId: ChainId, includeSubProviders?: boolean) => ProviderKey[];
|
|
160
424
|
/**
|
|
161
|
-
* Get all verifiable payment methods
|
|
425
|
+
* Get all verifiable payment methods including sub-providers
|
|
426
|
+
* @param includeSubProviders - Whether to include sub-providers as separate entries (default: false)
|
|
162
427
|
* @returns All verifiable payment methods
|
|
163
428
|
*/
|
|
164
|
-
export declare const verifiablePaymentMethods: (chainId: ChainId) => ProviderKey[];
|
|
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
|
+
}>;
|