@zkp2p/pay-shared 0.0.1
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/chains.d.ts +137 -0
- package/dist/chains.d.ts.map +1 -0
- package/dist/chains.js +341 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/types.d.ts +370 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +90 -0
- package/package.json +21 -0
- package/src/chains.ts +417 -0
- package/src/index.d.ts +2 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +1 -0
- package/src/index.ts +2 -0
- package/src/types.d.ts +132 -0
- package/src/types.d.ts.map +1 -0
- package/src/types.js +29 -0
- package/src/types.ts +464 -0
package/src/chains.ts
ADDED
|
@@ -0,0 +1,417 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized chain configuration for ZKP2P Pay.
|
|
3
|
+
*
|
|
4
|
+
* All supported chains and their USDC addresses are defined here.
|
|
5
|
+
* Import this module instead of duplicating chain configs in each app.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Chain IDs
|
|
9
|
+
export const BASE_CHAIN_ID = 8453;
|
|
10
|
+
export const HYPEREVM_CHAIN_ID = 999;
|
|
11
|
+
export const SOLANA_CHAIN_ID = 34268394551451;
|
|
12
|
+
|
|
13
|
+
export const SUPPORTED_DESTINATION_TOKEN_ALIASES = ['USDC', 'USDT'] as const;
|
|
14
|
+
export type DestinationTokenAlias = (typeof SUPPORTED_DESTINATION_TOKEN_ALIASES)[number];
|
|
15
|
+
export const DEFAULT_DESTINATION_TOKEN_ALIAS: DestinationTokenAlias = 'USDC';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Chain configuration interface.
|
|
19
|
+
*
|
|
20
|
+
* Note: We don't store spokePoolAddress for each chain because bridging
|
|
21
|
+
* always originates from Base, and the hook contract handles the Base SpokePool.
|
|
22
|
+
*/
|
|
23
|
+
export interface ChainConfig {
|
|
24
|
+
chainId: number;
|
|
25
|
+
name: string;
|
|
26
|
+
shortName: string;
|
|
27
|
+
usdcAddress: string;
|
|
28
|
+
isOriginChain: boolean;
|
|
29
|
+
isEvm: boolean;
|
|
30
|
+
explorerUrl?: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface DestinationTokenAddressMap {
|
|
34
|
+
usdt?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Mainnet chain configurations
|
|
38
|
+
export const MAINNET_CHAINS: Record<number, ChainConfig> = {
|
|
39
|
+
// Origin chain (Base)
|
|
40
|
+
[BASE_CHAIN_ID]: {
|
|
41
|
+
chainId: BASE_CHAIN_ID,
|
|
42
|
+
name: 'Base',
|
|
43
|
+
shortName: 'BASE',
|
|
44
|
+
usdcAddress: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
|
|
45
|
+
isOriginChain: true,
|
|
46
|
+
isEvm: true,
|
|
47
|
+
explorerUrl: 'https://basescan.org',
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
// EVM Destination chains
|
|
51
|
+
1: {
|
|
52
|
+
chainId: 1,
|
|
53
|
+
name: 'Ethereum',
|
|
54
|
+
shortName: 'ETH',
|
|
55
|
+
usdcAddress: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
|
|
56
|
+
isOriginChain: false,
|
|
57
|
+
isEvm: true,
|
|
58
|
+
explorerUrl: 'https://etherscan.io',
|
|
59
|
+
},
|
|
60
|
+
10: {
|
|
61
|
+
chainId: 10,
|
|
62
|
+
name: 'Optimism',
|
|
63
|
+
shortName: 'OP',
|
|
64
|
+
usdcAddress: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
|
|
65
|
+
isOriginChain: false,
|
|
66
|
+
isEvm: true,
|
|
67
|
+
explorerUrl: 'https://optimistic.etherscan.io',
|
|
68
|
+
},
|
|
69
|
+
42161: {
|
|
70
|
+
chainId: 42161,
|
|
71
|
+
name: 'Arbitrum',
|
|
72
|
+
shortName: 'ARB',
|
|
73
|
+
usdcAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
|
|
74
|
+
isOriginChain: false,
|
|
75
|
+
isEvm: true,
|
|
76
|
+
explorerUrl: 'https://arbiscan.io',
|
|
77
|
+
},
|
|
78
|
+
137: {
|
|
79
|
+
chainId: 137,
|
|
80
|
+
name: 'Polygon',
|
|
81
|
+
shortName: 'MATIC',
|
|
82
|
+
usdcAddress: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359',
|
|
83
|
+
isOriginChain: false,
|
|
84
|
+
isEvm: true,
|
|
85
|
+
explorerUrl: 'https://polygonscan.com',
|
|
86
|
+
},
|
|
87
|
+
480: {
|
|
88
|
+
chainId: 480,
|
|
89
|
+
name: 'World Chain',
|
|
90
|
+
shortName: 'WLD',
|
|
91
|
+
usdcAddress: '0x79A02482A880bCE3F13e09Da970dC34db4CD24d1', // USDC.e on World Chain
|
|
92
|
+
isOriginChain: false,
|
|
93
|
+
isEvm: true,
|
|
94
|
+
explorerUrl: 'https://worldscan.org',
|
|
95
|
+
},
|
|
96
|
+
56: {
|
|
97
|
+
chainId: 56,
|
|
98
|
+
name: 'BNB Smart Chain',
|
|
99
|
+
shortName: 'BNB',
|
|
100
|
+
usdcAddress: '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d',
|
|
101
|
+
isOriginChain: false,
|
|
102
|
+
isEvm: true,
|
|
103
|
+
explorerUrl: 'https://bscscan.com',
|
|
104
|
+
},
|
|
105
|
+
[HYPEREVM_CHAIN_ID]: {
|
|
106
|
+
chainId: HYPEREVM_CHAIN_ID,
|
|
107
|
+
name: 'Hyperliquid',
|
|
108
|
+
shortName: 'HL',
|
|
109
|
+
usdcAddress: '0xb88339CB7199b77E23DB6E890353E22632Ba630f', // Native USDC on HyperEVM
|
|
110
|
+
isOriginChain: false,
|
|
111
|
+
isEvm: true,
|
|
112
|
+
explorerUrl: 'https://hyperscan.xyz',
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
// Non-EVM Destination chains
|
|
116
|
+
[SOLANA_CHAIN_ID]: {
|
|
117
|
+
chainId: SOLANA_CHAIN_ID,
|
|
118
|
+
name: 'Solana',
|
|
119
|
+
shortName: 'SOL',
|
|
120
|
+
usdcAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
121
|
+
isOriginChain: false,
|
|
122
|
+
isEvm: false,
|
|
123
|
+
explorerUrl: 'https://solscan.io',
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
function normalizeChainSelectionKey(value: string): string {
|
|
128
|
+
return value.trim().toLowerCase().replace(/[^a-z0-9]/g, '');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const SUPPORTED_CHAIN_IDS = Object.keys(MAINNET_CHAINS).map(Number);
|
|
132
|
+
const SUPPORTED_CHAIN_ID_SET = new Set(SUPPORTED_CHAIN_IDS);
|
|
133
|
+
|
|
134
|
+
const CHAIN_SELECTION_ALIASES: Record<string, number> = {
|
|
135
|
+
base: 8453,
|
|
136
|
+
ethereum: 1,
|
|
137
|
+
eth: 1,
|
|
138
|
+
optimism: 10,
|
|
139
|
+
op: 10,
|
|
140
|
+
arbitrum: 42161,
|
|
141
|
+
arb: 42161,
|
|
142
|
+
polygon: 137,
|
|
143
|
+
matic: 137,
|
|
144
|
+
world: 480,
|
|
145
|
+
worldchain: 480,
|
|
146
|
+
bnb: 56,
|
|
147
|
+
bsc: 56,
|
|
148
|
+
binancesmartchain: 56,
|
|
149
|
+
hyperliquid: 999,
|
|
150
|
+
hyperevm: 999,
|
|
151
|
+
hl: 999,
|
|
152
|
+
solana: 34268394551451,
|
|
153
|
+
sol: 34268394551451,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
for (const chainId of SUPPORTED_CHAIN_IDS) {
|
|
157
|
+
const chainConfig = MAINNET_CHAINS[chainId];
|
|
158
|
+
const normalizedName = normalizeChainSelectionKey(chainConfig.name);
|
|
159
|
+
const normalizedShortName = normalizeChainSelectionKey(chainConfig.shortName);
|
|
160
|
+
|
|
161
|
+
if (!(normalizedName in CHAIN_SELECTION_ALIASES)) {
|
|
162
|
+
CHAIN_SELECTION_ALIASES[normalizedName] = chainId;
|
|
163
|
+
}
|
|
164
|
+
if (!(normalizedShortName in CHAIN_SELECTION_ALIASES)) {
|
|
165
|
+
CHAIN_SELECTION_ALIASES[normalizedShortName] = chainId;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const DESTINATION_TOKEN_ADDRESSES: Record<number, DestinationTokenAddressMap> = {
|
|
170
|
+
// Ethereum
|
|
171
|
+
1: {
|
|
172
|
+
usdt: '0xdAC17F958D2ee523a2206206994597C13D831ec7',
|
|
173
|
+
},
|
|
174
|
+
// Optimism
|
|
175
|
+
10: {
|
|
176
|
+
usdt: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58',
|
|
177
|
+
},
|
|
178
|
+
// BNB Smart Chain
|
|
179
|
+
56: {
|
|
180
|
+
usdt: '0x55d398326f99059fF775485246999027B3197955',
|
|
181
|
+
},
|
|
182
|
+
// Arbitrum
|
|
183
|
+
42161: {
|
|
184
|
+
usdt: '0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9',
|
|
185
|
+
},
|
|
186
|
+
// Polygon
|
|
187
|
+
137: {
|
|
188
|
+
usdt: '0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
|
|
189
|
+
},
|
|
190
|
+
// Hyperliquid
|
|
191
|
+
999: {
|
|
192
|
+
usdt: '0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb',
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
function isKnownDestinationTokenAlias(value: string): value is DestinationTokenAlias {
|
|
197
|
+
return (SUPPORTED_DESTINATION_TOKEN_ALIASES as readonly string[]).includes(value);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Normalize destination token aliases (USDC/USDT) into canonical uppercase symbols.
|
|
202
|
+
* Returns null if the value is empty or not a known alias.
|
|
203
|
+
*/
|
|
204
|
+
export function normalizeDestinationTokenAlias(
|
|
205
|
+
value: string | null | undefined
|
|
206
|
+
): DestinationTokenAlias | null {
|
|
207
|
+
const normalized = value?.trim().toUpperCase();
|
|
208
|
+
if (!normalized) {
|
|
209
|
+
return null;
|
|
210
|
+
}
|
|
211
|
+
return isKnownDestinationTokenAlias(normalized) ? normalized : null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Check whether a value is a supported destination token alias.
|
|
216
|
+
*/
|
|
217
|
+
export function isDestinationTokenAlias(
|
|
218
|
+
value: string | null | undefined
|
|
219
|
+
): value is DestinationTokenAlias {
|
|
220
|
+
return normalizeDestinationTokenAlias(value) !== null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Resolve destination token alias, falling back to the hard default.
|
|
225
|
+
*/
|
|
226
|
+
export function resolveDefaultDestinationTokenAlias(
|
|
227
|
+
value: string | null | undefined
|
|
228
|
+
): DestinationTokenAlias {
|
|
229
|
+
return normalizeDestinationTokenAlias(value) ?? DEFAULT_DESTINATION_TOKEN_ALIAS;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Parse a user-provided chain selection into a supported chain ID.
|
|
234
|
+
* Accepts numeric chain IDs as well as common aliases (e.g. "polygon", "arb", "sol").
|
|
235
|
+
*/
|
|
236
|
+
export function parseSupportedChainSelection(value: string): number | null {
|
|
237
|
+
const trimmed = value.trim();
|
|
238
|
+
if (!trimmed) {
|
|
239
|
+
return null;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (/^\d+$/.test(trimmed)) {
|
|
243
|
+
const parsed = Number(trimmed);
|
|
244
|
+
return SUPPORTED_CHAIN_ID_SET.has(parsed) ? parsed : null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
const normalized = normalizeChainSelectionKey(trimmed);
|
|
248
|
+
return CHAIN_SELECTION_ALIASES[normalized] ?? null;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Get chain configurations.
|
|
253
|
+
*/
|
|
254
|
+
export function getChainConfigs(): Record<number, ChainConfig> {
|
|
255
|
+
return MAINNET_CHAINS;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Get chain config by chain ID.
|
|
260
|
+
*/
|
|
261
|
+
export function getChainConfig(chainId: number): ChainConfig | undefined {
|
|
262
|
+
return getChainConfigs()[chainId];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Check if chain ID is the origin chain (Base).
|
|
267
|
+
*/
|
|
268
|
+
export function isOriginChain(chainId: number): boolean {
|
|
269
|
+
const chain = getChainConfig(chainId);
|
|
270
|
+
return chain?.isOriginChain ?? false;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Check if chain ID is an EVM chain.
|
|
275
|
+
*/
|
|
276
|
+
export function isEvmChain(chainId: number): boolean {
|
|
277
|
+
const chain = getChainConfig(chainId);
|
|
278
|
+
return chain?.isEvm ?? true; // Default to EVM if unknown
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Get origin chain ID for current environment.
|
|
283
|
+
*/
|
|
284
|
+
export function getOriginChainId(): number {
|
|
285
|
+
const chains = getChainConfigs();
|
|
286
|
+
const originChain = Object.values(chains).find((c) => c.isOriginChain);
|
|
287
|
+
return originChain?.chainId ?? BASE_CHAIN_ID;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Get USDC address for a chain.
|
|
292
|
+
*/
|
|
293
|
+
export function getUsdcAddress(chainId: number): string | undefined {
|
|
294
|
+
return getChainConfig(chainId)?.usdcAddress;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Resolve destination token alias to chain-specific token address.
|
|
299
|
+
* Supported aliases:
|
|
300
|
+
* - USDC: map to configured USDC address
|
|
301
|
+
* - USDT: map to configured USDT address (if available)
|
|
302
|
+
* - fallback: return token string as provided (for explicit token addresses)
|
|
303
|
+
*/
|
|
304
|
+
export function resolveDestinationTokenAddress(
|
|
305
|
+
destinationToken: string,
|
|
306
|
+
destinationChainId: number
|
|
307
|
+
): string | null {
|
|
308
|
+
const token = destinationToken.trim();
|
|
309
|
+
if (!token) {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const chainId = destinationChainId;
|
|
314
|
+
const tokenAlias = normalizeDestinationTokenAlias(token);
|
|
315
|
+
const chainAddresses = DESTINATION_TOKEN_ADDRESSES[chainId];
|
|
316
|
+
|
|
317
|
+
if (tokenAlias === 'USDC') {
|
|
318
|
+
return getUsdcAddress(chainId) ?? null;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
if (tokenAlias === 'USDT') {
|
|
322
|
+
return chainAddresses?.usdt ?? null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
return token;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Get supported destination token aliases for a destination chain.
|
|
330
|
+
* Token support is derived from resolvable token addresses for the chain.
|
|
331
|
+
*/
|
|
332
|
+
export function getSupportedDestinationTokenAliasesForChain(
|
|
333
|
+
destinationChainId: number
|
|
334
|
+
): DestinationTokenAlias[] {
|
|
335
|
+
return SUPPORTED_DESTINATION_TOKEN_ALIASES.filter((tokenAlias) =>
|
|
336
|
+
Boolean(resolveDestinationTokenAddress(tokenAlias, destinationChainId))
|
|
337
|
+
);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Get all supported chain IDs.
|
|
342
|
+
*/
|
|
343
|
+
export function getSupportedChainIds(): number[] {
|
|
344
|
+
return [...SUPPORTED_CHAIN_IDS];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Get destination chain IDs (excludes origin).
|
|
349
|
+
*/
|
|
350
|
+
export function getDestinationChainIds(): number[] {
|
|
351
|
+
return Object.entries(getChainConfigs())
|
|
352
|
+
.filter(([, cfg]) => !cfg.isOriginChain)
|
|
353
|
+
.map(([id]) => Number(id));
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Get EVM chain IDs only.
|
|
358
|
+
*/
|
|
359
|
+
export function getEvmChainIds(): number[] {
|
|
360
|
+
return Object.entries(getChainConfigs())
|
|
361
|
+
.filter(([, cfg]) => cfg.isEvm)
|
|
362
|
+
.map(([id]) => Number(id));
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Get non-EVM chain IDs (e.g., Solana).
|
|
367
|
+
*/
|
|
368
|
+
export function getNonEvmChainIds(): number[] {
|
|
369
|
+
return Object.entries(getChainConfigs())
|
|
370
|
+
.filter(([, cfg]) => !cfg.isEvm)
|
|
371
|
+
.map(([id]) => Number(id));
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* Get chain name for display.
|
|
376
|
+
*/
|
|
377
|
+
export function getChainName(chainId: number): string {
|
|
378
|
+
return getChainConfig(chainId)?.name ?? `Chain ${chainId}`;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Get chain short name for badges/tags.
|
|
383
|
+
*/
|
|
384
|
+
export function getChainShortName(chainId: number): string {
|
|
385
|
+
return getChainConfig(chainId)?.shortName ?? `${chainId}`;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Get explorer URL for a chain.
|
|
390
|
+
*/
|
|
391
|
+
export function getExplorerUrl(chainId: number): string | undefined {
|
|
392
|
+
return getChainConfig(chainId)?.explorerUrl;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* Array of supported chains for UI dropdowns.
|
|
397
|
+
* Includes origin chain marked with isOrigin flag.
|
|
398
|
+
*/
|
|
399
|
+
export const SUPPORTED_CHAINS = Object.values(MAINNET_CHAINS).map((chain) => ({
|
|
400
|
+
chainId: chain.chainId,
|
|
401
|
+
name: chain.name,
|
|
402
|
+
shortName: chain.shortName,
|
|
403
|
+
isOrigin: chain.isOriginChain,
|
|
404
|
+
isEvm: chain.isEvm,
|
|
405
|
+
}));
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* Array of destination chains only (excludes Base).
|
|
409
|
+
*/
|
|
410
|
+
export const DESTINATION_CHAINS = SUPPORTED_CHAINS.filter((c) => !c.isOrigin);
|
|
411
|
+
|
|
412
|
+
/**
|
|
413
|
+
* Mapping of chain ID to name for backward compatibility.
|
|
414
|
+
*/
|
|
415
|
+
export const SupportedChainsMap = Object.fromEntries(
|
|
416
|
+
Object.entries(MAINNET_CHAINS).map(([id, cfg]) => [Number(id), cfg.name])
|
|
417
|
+
) as Record<number, string>;
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './types.js';
|
package/src/index.ts
ADDED
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
export declare const PaymentPlatform: {
|
|
2
|
+
readonly VENMO: "venmo";
|
|
3
|
+
readonly CASHAPP: "cashapp";
|
|
4
|
+
readonly REVOLUT: "revolut";
|
|
5
|
+
readonly WISE: "wise";
|
|
6
|
+
readonly ZELLE: "zelle";
|
|
7
|
+
readonly PAYPAL: "paypal";
|
|
8
|
+
readonly MONZO: "monzo";
|
|
9
|
+
readonly N26: "n26";
|
|
10
|
+
};
|
|
11
|
+
export type PaymentPlatformType = typeof PaymentPlatform[keyof typeof PaymentPlatform];
|
|
12
|
+
export declare const OrderStatus: {
|
|
13
|
+
readonly SESSION_CREATED: "SESSION_CREATED";
|
|
14
|
+
readonly SIGNAL_SENT: "SIGNAL_SENT";
|
|
15
|
+
readonly SIGNAL_MINED: "SIGNAL_MINED";
|
|
16
|
+
readonly PAYMENT_SENT: "PAYMENT_SENT";
|
|
17
|
+
readonly PROOF_SUBMITTED: "PROOF_SUBMITTED";
|
|
18
|
+
readonly FULFILL_SUBMITTED: "FULFILL_SUBMITTED";
|
|
19
|
+
readonly FULFILLED: "FULFILLED";
|
|
20
|
+
readonly CANCELLED: "CANCELLED";
|
|
21
|
+
readonly EXPIRED: "EXPIRED";
|
|
22
|
+
readonly FAILED: "FAILED";
|
|
23
|
+
};
|
|
24
|
+
export type OrderStatusType = typeof OrderStatus[keyof typeof OrderStatus];
|
|
25
|
+
export declare const SessionStatus: {
|
|
26
|
+
readonly CREATED: "CREATED";
|
|
27
|
+
readonly ACTIVE: "ACTIVE";
|
|
28
|
+
readonly COMPLETED: "COMPLETED";
|
|
29
|
+
readonly EXPIRED: "EXPIRED";
|
|
30
|
+
readonly CANCELLED: "CANCELLED";
|
|
31
|
+
};
|
|
32
|
+
export type SessionStatusType = typeof SessionStatus[keyof typeof SessionStatus];
|
|
33
|
+
export type Merchant = {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
apiKey: string;
|
|
37
|
+
createdAt: string;
|
|
38
|
+
};
|
|
39
|
+
export type CheckoutSession = {
|
|
40
|
+
id: string;
|
|
41
|
+
merchantId: string;
|
|
42
|
+
amountUsdc: string;
|
|
43
|
+
destinationChainId: number;
|
|
44
|
+
destinationToken: string;
|
|
45
|
+
recipientAddress: string;
|
|
46
|
+
status: SessionStatusType;
|
|
47
|
+
paymentPlatforms: PaymentPlatformType[];
|
|
48
|
+
fiatCurrency: string;
|
|
49
|
+
successUrl?: string | null;
|
|
50
|
+
cancelUrl?: string | null;
|
|
51
|
+
metadata?: Record<string, string> | null;
|
|
52
|
+
createdAt: string;
|
|
53
|
+
updatedAt: string;
|
|
54
|
+
};
|
|
55
|
+
export type QuoteIntent = {
|
|
56
|
+
depositId: string;
|
|
57
|
+
processorName: string;
|
|
58
|
+
amount: string;
|
|
59
|
+
toAddress: string;
|
|
60
|
+
payeeDetails: string;
|
|
61
|
+
processorIntentData: Record<string, unknown>;
|
|
62
|
+
fiatCurrencyCode: string;
|
|
63
|
+
chainId: string;
|
|
64
|
+
};
|
|
65
|
+
export type Quote = {
|
|
66
|
+
fiatAmount: string;
|
|
67
|
+
fiatAmountFormatted: string;
|
|
68
|
+
tokenAmount: string;
|
|
69
|
+
tokenAmountFormatted: string;
|
|
70
|
+
paymentMethod: string;
|
|
71
|
+
payeeAddress: string;
|
|
72
|
+
conversionRate: string;
|
|
73
|
+
intent: QuoteIntent;
|
|
74
|
+
payeeData?: Record<string, string>;
|
|
75
|
+
};
|
|
76
|
+
export type Order = {
|
|
77
|
+
id: string;
|
|
78
|
+
sessionId: string;
|
|
79
|
+
merchantId: string;
|
|
80
|
+
status: OrderStatusType;
|
|
81
|
+
intentHash?: string | null;
|
|
82
|
+
signalTx?: string | null;
|
|
83
|
+
fulfillTx?: string | null;
|
|
84
|
+
paymentPlatform?: PaymentPlatformType | null;
|
|
85
|
+
fiatCurrency?: string | null;
|
|
86
|
+
amountUsdc?: string | null;
|
|
87
|
+
netAmountUsdc?: string | null;
|
|
88
|
+
conversionRate?: string | null;
|
|
89
|
+
recipient?: string | null;
|
|
90
|
+
quote?: Quote | null;
|
|
91
|
+
createdAt: string;
|
|
92
|
+
updatedAt: string;
|
|
93
|
+
};
|
|
94
|
+
export type CreateSessionRequest = {
|
|
95
|
+
merchantId: string;
|
|
96
|
+
amountUsdc: string;
|
|
97
|
+
destinationChainId: number;
|
|
98
|
+
destinationToken: string;
|
|
99
|
+
recipientAddress: string;
|
|
100
|
+
paymentPlatforms?: PaymentPlatformType[];
|
|
101
|
+
fiatCurrency?: string;
|
|
102
|
+
successUrl?: string;
|
|
103
|
+
cancelUrl?: string;
|
|
104
|
+
metadata?: Record<string, string>;
|
|
105
|
+
};
|
|
106
|
+
export type CreateSessionResponse = {
|
|
107
|
+
session: CheckoutSession;
|
|
108
|
+
checkoutUrl: string;
|
|
109
|
+
};
|
|
110
|
+
export type StartSessionRequest = {
|
|
111
|
+
paymentPlatform?: PaymentPlatformType;
|
|
112
|
+
fiatCurrency?: string;
|
|
113
|
+
};
|
|
114
|
+
export type StartSessionResponse = {
|
|
115
|
+
session: CheckoutSession;
|
|
116
|
+
order: Order;
|
|
117
|
+
quote: Quote;
|
|
118
|
+
intentHash: string;
|
|
119
|
+
expiresAt?: string | null;
|
|
120
|
+
};
|
|
121
|
+
export type MarkPaymentSentResponse = {
|
|
122
|
+
order: Order;
|
|
123
|
+
};
|
|
124
|
+
export type FulfillIntentRequest = {
|
|
125
|
+
intentHash: string;
|
|
126
|
+
proof: Record<string, unknown> | string;
|
|
127
|
+
};
|
|
128
|
+
export type FulfillIntentResponse = {
|
|
129
|
+
order: Order;
|
|
130
|
+
txHash: string;
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe;;;;;;;;;;CAUlB,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEvF,eAAO,MAAM,WAAW;;;;;;;;;;;CAWd,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,OAAO,WAAW,CAAC,MAAM,OAAO,WAAW,CAAC,CAAC;AAE3E,eAAO,MAAM,aAAa;;;;;;CAMhB,CAAC;AAEX,MAAM,MAAM,iBAAiB,GAAG,OAAO,aAAa,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AAEjF,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC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B,GAAG;IAClC,OAAO,EAAE,eAAe,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,eAAe,CAAC;IACzB,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC;CACzC,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/src/types.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const PaymentPlatform = {
|
|
2
|
+
VENMO: 'venmo',
|
|
3
|
+
CASHAPP: 'cashapp',
|
|
4
|
+
REVOLUT: 'revolut',
|
|
5
|
+
WISE: 'wise',
|
|
6
|
+
ZELLE: 'zelle',
|
|
7
|
+
PAYPAL: 'paypal',
|
|
8
|
+
MONZO: 'monzo',
|
|
9
|
+
N26: 'n26',
|
|
10
|
+
};
|
|
11
|
+
export const OrderStatus = {
|
|
12
|
+
SESSION_CREATED: 'SESSION_CREATED',
|
|
13
|
+
SIGNAL_SENT: 'SIGNAL_SENT',
|
|
14
|
+
SIGNAL_MINED: 'SIGNAL_MINED',
|
|
15
|
+
PAYMENT_SENT: 'PAYMENT_SENT',
|
|
16
|
+
PROOF_SUBMITTED: 'PROOF_SUBMITTED',
|
|
17
|
+
FULFILL_SUBMITTED: 'FULFILL_SUBMITTED',
|
|
18
|
+
FULFILLED: 'FULFILLED',
|
|
19
|
+
CANCELLED: 'CANCELLED',
|
|
20
|
+
EXPIRED: 'EXPIRED',
|
|
21
|
+
FAILED: 'FAILED',
|
|
22
|
+
};
|
|
23
|
+
export const SessionStatus = {
|
|
24
|
+
CREATED: 'CREATED',
|
|
25
|
+
ACTIVE: 'ACTIVE',
|
|
26
|
+
COMPLETED: 'COMPLETED',
|
|
27
|
+
EXPIRED: 'EXPIRED',
|
|
28
|
+
CANCELLED: 'CANCELLED',
|
|
29
|
+
};
|