@getpara/react-common 1.5.0 → 1.6.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/dist/index.js +166 -113
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/package.json +4 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __spreadValues = (a, b) => {
|
|
10
|
+
for (var prop in b || (b = {}))
|
|
11
|
+
if (__hasOwnProp.call(b, prop))
|
|
12
|
+
__defNormalProp(a, prop, b[prop]);
|
|
13
|
+
if (__getOwnPropSymbols)
|
|
14
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
15
|
+
if (__propIsEnum.call(b, prop))
|
|
16
|
+
__defNormalProp(a, prop, b[prop]);
|
|
17
|
+
}
|
|
18
|
+
return a;
|
|
19
|
+
};
|
|
20
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
|
+
var __async = (__this, __arguments, generator) => {
|
|
22
|
+
return new Promise((resolve, reject) => {
|
|
23
|
+
var fulfilled = (value) => {
|
|
24
|
+
try {
|
|
25
|
+
step(generator.next(value));
|
|
26
|
+
} catch (e) {
|
|
27
|
+
reject(e);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
var rejected = (value) => {
|
|
31
|
+
try {
|
|
32
|
+
step(generator.throw(value));
|
|
33
|
+
} catch (e) {
|
|
34
|
+
reject(e);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
38
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
39
|
+
});
|
|
40
|
+
};
|
|
2
41
|
|
|
3
42
|
// src/classes/ParaInternal.ts
|
|
4
43
|
import ParaWeb from "@getpara/web-sdk";
|
|
@@ -37,70 +76,73 @@ import {
|
|
|
37
76
|
|
|
38
77
|
// src/utils/offRampSend.ts
|
|
39
78
|
import { hexStringToBase64, WalletType } from "@getpara/web-sdk";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const { tx, network, asset } = await para.ctx.client.generateOffRampTx(para.getUserId(), {
|
|
53
|
-
walletId,
|
|
54
|
-
walletType,
|
|
55
|
-
provider,
|
|
56
|
-
chainId,
|
|
57
|
-
destinationAddress,
|
|
58
|
-
sourceAddress: address,
|
|
59
|
-
contractAddress,
|
|
60
|
-
testMode,
|
|
61
|
-
assetQuantity
|
|
62
|
-
});
|
|
63
|
-
let signature;
|
|
64
|
-
switch (walletType) {
|
|
65
|
-
case WalletType.EVM:
|
|
66
|
-
signature = (await para.signTransaction({
|
|
67
|
-
walletId,
|
|
68
|
-
rlpEncodedTxBase64: hexStringToBase64(tx),
|
|
69
|
-
chainId
|
|
70
|
-
}))?.signature;
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
throw new Error(`Unsupported wallet type: ${walletType}`);
|
|
79
|
+
function offRampSend(_0, _1, _2, _3) {
|
|
80
|
+
return __async(this, arguments, function* (para, { id: purchaseId, provider, walletId, walletType, address, testMode = false }, setOnRampPurchase, {
|
|
81
|
+
assetQuantity,
|
|
82
|
+
fiat,
|
|
83
|
+
fiatQuantity,
|
|
84
|
+
chainId,
|
|
85
|
+
destinationAddress,
|
|
86
|
+
contractAddress
|
|
87
|
+
}) {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
if (!purchaseId || !walletId || !walletType || !provider) {
|
|
90
|
+
throw new Error("Missing required fields");
|
|
74
91
|
}
|
|
75
|
-
|
|
76
|
-
tx,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
try {
|
|
93
|
+
const { tx, network, asset } = yield para.ctx.client.generateOffRampTx(para.getUserId(), {
|
|
94
|
+
walletId,
|
|
95
|
+
walletType,
|
|
96
|
+
provider,
|
|
97
|
+
chainId,
|
|
98
|
+
destinationAddress,
|
|
99
|
+
sourceAddress: address,
|
|
100
|
+
contractAddress,
|
|
101
|
+
testMode,
|
|
102
|
+
assetQuantity
|
|
103
|
+
});
|
|
104
|
+
let signature;
|
|
105
|
+
switch (walletType) {
|
|
106
|
+
case WalletType.EVM:
|
|
107
|
+
signature = (_a = yield para.signTransaction({
|
|
108
|
+
walletId,
|
|
109
|
+
rlpEncodedTxBase64: hexStringToBase64(tx),
|
|
110
|
+
chainId
|
|
111
|
+
})) == null ? void 0 : _a.signature;
|
|
112
|
+
break;
|
|
113
|
+
default:
|
|
114
|
+
throw new Error(`Unsupported wallet type: ${walletType}`);
|
|
92
115
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
116
|
+
const { txHash } = yield para.ctx.client.sendOffRampTx(para.getUserId(), {
|
|
117
|
+
tx,
|
|
118
|
+
signature: walletType === "EVM" ? `0x${signature}` : signature,
|
|
119
|
+
network,
|
|
120
|
+
walletId,
|
|
121
|
+
walletType
|
|
122
|
+
});
|
|
123
|
+
const updated = yield para.ctx.client.updateOnRampPurchase({
|
|
124
|
+
userId: para.getUserId(),
|
|
125
|
+
walletId,
|
|
126
|
+
purchaseId,
|
|
127
|
+
updates: {
|
|
128
|
+
fiat,
|
|
129
|
+
fiatQuantity,
|
|
130
|
+
assetQuantity,
|
|
131
|
+
network,
|
|
132
|
+
asset
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
setOnRampPurchase(updated);
|
|
136
|
+
return txHash;
|
|
137
|
+
} catch (e) {
|
|
138
|
+
throw new Error(((_b = e.response) == null ? void 0 : _b.data) || e.message);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
99
141
|
}
|
|
100
142
|
|
|
101
143
|
// src/utils/getDeviceLogo.ts
|
|
102
144
|
var getDeviceLogo = (vendor, isMobile2) => {
|
|
103
|
-
switch (vendor
|
|
145
|
+
switch (vendor == null ? void 0 : vendor.toLowerCase()) {
|
|
104
146
|
case "apple": {
|
|
105
147
|
return "apple";
|
|
106
148
|
}
|
|
@@ -309,7 +351,8 @@ var formatBiometricHints = (hints) => {
|
|
|
309
351
|
let hasMobileDevice = false, isOnKnownDevice = false;
|
|
310
352
|
const deviceParsedUA = UAParser2();
|
|
311
353
|
const formattedHintsByKey = {};
|
|
312
|
-
hints
|
|
354
|
+
hints == null ? void 0 : hints.forEach((hint) => {
|
|
355
|
+
var _a;
|
|
313
356
|
let isMobile2 = false, isKnownDevice = false, passwordManager, parsedUA, key = "";
|
|
314
357
|
if (hint.useragent) {
|
|
315
358
|
parsedUA = new UAParser2(hint.useragent).getResult();
|
|
@@ -323,16 +366,16 @@ var formatBiometricHints = (hints) => {
|
|
|
323
366
|
isKnownDevice = true;
|
|
324
367
|
}
|
|
325
368
|
}
|
|
326
|
-
key = `${parsedUA
|
|
369
|
+
key = `${parsedUA == null ? void 0 : parsedUA.browser.name}-${parsedUA == null ? void 0 : parsedUA.device.type}-${parsedUA == null ? void 0 : parsedUA.device.vendor}-${parsedUA == null ? void 0 : parsedUA.device.model}`;
|
|
327
370
|
}
|
|
328
371
|
if (hint.aaguid) {
|
|
329
372
|
const formattedAaguid = formatStringToUUID(hint.aaguid);
|
|
330
373
|
if (formattedAaguid) {
|
|
331
|
-
passwordManager = aaguidMetadata[formattedAaguid]
|
|
374
|
+
passwordManager = (_a = aaguidMetadata[formattedAaguid]) == null ? void 0 : _a.name;
|
|
332
375
|
}
|
|
333
376
|
key = `${key}${key ? "-" : ""}${passwordManager}`;
|
|
334
377
|
}
|
|
335
|
-
formattedHintsByKey[key] = { passwordManager, isMobile: isMobile2, isKnownDevice, key,
|
|
378
|
+
formattedHintsByKey[key] = __spreadValues({ passwordManager, isMobile: isMobile2, isKnownDevice, key }, parsedUA);
|
|
336
379
|
});
|
|
337
380
|
return {
|
|
338
381
|
hasMobileDevice,
|
|
@@ -345,7 +388,7 @@ var formatBiometricHints = (hints) => {
|
|
|
345
388
|
import parsePhoneNumberFromString from "libphonenumber-js";
|
|
346
389
|
var formatPhoneNumber = (phone, countryCode) => {
|
|
347
390
|
phone = phone.toString();
|
|
348
|
-
countryCode = countryCode
|
|
391
|
+
countryCode = countryCode == null ? void 0 : countryCode.toString();
|
|
349
392
|
let sanitizedNumber, parsedNumber;
|
|
350
393
|
if (!!countryCode) {
|
|
351
394
|
sanitizedNumber = phone.replace(/\D/g, "");
|
|
@@ -357,7 +400,7 @@ var formatPhoneNumber = (phone, countryCode) => {
|
|
|
357
400
|
sanitizedNumber = `${phone.startsWith("+") ? "" : "+"}${phone.replace(/[^\d+]/g, "")}`;
|
|
358
401
|
parsedNumber = parsePhoneNumberFromString(sanitizedNumber);
|
|
359
402
|
}
|
|
360
|
-
if (parsedNumber
|
|
403
|
+
if (parsedNumber == null ? void 0 : parsedNumber.isValid()) {
|
|
361
404
|
return parsedNumber.formatInternational();
|
|
362
405
|
}
|
|
363
406
|
return null;
|
|
@@ -374,14 +417,15 @@ function getCurrencyCodes({ assetInfo, allowedAssets, defaultOnRampNetwork, defa
|
|
|
374
417
|
walletType,
|
|
375
418
|
allowed: allowedAssets ? Object.keys(allowedAssets) : void 0
|
|
376
419
|
}).sort((a, b) => a === defaultOnRampNetwork ? -1 : b === defaultOnRampNetwork ? 1 : 0).reduce((acc, network) => {
|
|
377
|
-
const allowed = Array.isArray(allowedAssets
|
|
420
|
+
const allowed = Array.isArray(allowedAssets == null ? void 0 : allowedAssets[network]) ? allowedAssets[network] : void 0;
|
|
378
421
|
return [
|
|
379
422
|
...acc,
|
|
380
423
|
...getOnRampAssets(assetInfo, { walletType, network, allowed }).sort((a, b) => a === defaultOnRampAsset ? -1 : b === defaultOnRampAsset ? 1 : 0).map((asset) => {
|
|
424
|
+
var _a, _b, _c, _d, _e, _f;
|
|
381
425
|
if (network === defaultOnRampNetwork && asset === defaultOnRampAsset) {
|
|
382
|
-
defaultCurrencyCode = assetInfo[walletType]
|
|
426
|
+
defaultCurrencyCode = (_c = (_b = (_a = assetInfo[walletType]) == null ? void 0 : _a[network]) == null ? void 0 : _b[asset]) == null ? void 0 : _c[provider][0];
|
|
383
427
|
}
|
|
384
|
-
return assetInfo[walletType]
|
|
428
|
+
return (_f = (_e = (_d = assetInfo[walletType]) == null ? void 0 : _d[network]) == null ? void 0 : _e[asset]) == null ? void 0 : _f[provider];
|
|
385
429
|
}).filter((entry) => !!entry && !!entry[1][purchaseType]).map(([code]) => code)
|
|
386
430
|
];
|
|
387
431
|
}, []).filter((code) => !!code);
|
|
@@ -391,14 +435,16 @@ function reverseCurrencyLookup(data, provider, code) {
|
|
|
391
435
|
const row = toAssetInfoArray(data).find(
|
|
392
436
|
([_, __, ___, providers]) => [code.toUpperCase(), code.toLowerCase()].includes(providers[provider][0])
|
|
393
437
|
);
|
|
394
|
-
return [row
|
|
438
|
+
return [row == null ? void 0 : row[1], row == null ? void 0 : row[2]];
|
|
395
439
|
}
|
|
396
440
|
var TestNetworks = [{ main: Network.ETHEREUM, test: Network.SEPOLIA }];
|
|
397
441
|
function getNetworkTestEquivalent(network) {
|
|
398
|
-
|
|
442
|
+
var _a;
|
|
443
|
+
return (_a = TestNetworks.find(({ main }) => main === network)) == null ? void 0 : _a.test;
|
|
399
444
|
}
|
|
400
445
|
function getNetworkOrMainNetEquivalent(network, testMode) {
|
|
401
|
-
|
|
446
|
+
var _a, _b;
|
|
447
|
+
return testMode ? (_b = (_a = TestNetworks.find(({ test }) => test === network)) == null ? void 0 : _a.main) != null ? _b : network : network;
|
|
402
448
|
}
|
|
403
449
|
var NetworkChainIds = [
|
|
404
450
|
{ chainId: "11155111", network: Network.SEPOLIA },
|
|
@@ -410,10 +456,12 @@ var NetworkChainIds = [
|
|
|
410
456
|
{ chainId: "10", network: Network.OPTIMISM }
|
|
411
457
|
];
|
|
412
458
|
function getChainId(network) {
|
|
413
|
-
|
|
459
|
+
var _a, _b;
|
|
460
|
+
return (_b = (_a = NetworkChainIds.find(({ network: n }) => n === network)) == null ? void 0 : _a.chainId) != null ? _b : void 0;
|
|
414
461
|
}
|
|
415
462
|
function getNetworkFromChainId(chainId) {
|
|
416
|
-
|
|
463
|
+
var _a;
|
|
464
|
+
return chainId ? (_a = NetworkChainIds.find(({ chainId: c }) => c === chainId)) == null ? void 0 : _a.network : void 0;
|
|
417
465
|
}
|
|
418
466
|
var ETH_CONTRACT_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
419
467
|
var NetworkAssetAddresses = [
|
|
@@ -427,19 +475,21 @@ var NetworkAssetAddresses = [
|
|
|
427
475
|
{ network: Network.SEPOLIA, asset: OnRampAsset.USDC, address: "0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238" }
|
|
428
476
|
];
|
|
429
477
|
function getAssetFromContractAddress(network, contractAddress) {
|
|
478
|
+
var _a, _b;
|
|
430
479
|
if (contractAddress === ETH_CONTRACT_ADDRESS) {
|
|
431
480
|
return OnRampAsset.ETHEREUM;
|
|
432
481
|
}
|
|
433
|
-
const checkNetworks = [network, getNetworkOrMainNetEquivalent(network)
|
|
434
|
-
return NetworkAssetAddresses.find(
|
|
482
|
+
const checkNetworks = [network, (_a = getNetworkOrMainNetEquivalent(network)) != null ? _a : void 0].filter((n) => !!n).map((n) => Network[n]);
|
|
483
|
+
return (_b = NetworkAssetAddresses.find(
|
|
435
484
|
(row) => checkNetworks.includes(row.network) && row.asset.toLowerCase() === contractAddress.toLowerCase()
|
|
436
|
-
)
|
|
485
|
+
)) == null ? void 0 : _b.asset;
|
|
437
486
|
}
|
|
438
487
|
function getContractAddressFromAsset(network, asset) {
|
|
488
|
+
var _a;
|
|
439
489
|
if (asset === OnRampAsset.ETHEREUM) {
|
|
440
490
|
return ETH_CONTRACT_ADDRESS;
|
|
441
491
|
}
|
|
442
|
-
return NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)
|
|
492
|
+
return (_a = NetworkAssetAddresses.find((row) => row.network === network && row.asset === asset)) == null ? void 0 : _a.address;
|
|
443
493
|
}
|
|
444
494
|
|
|
445
495
|
// src/components/MoonPayEmbed.tsx
|
|
@@ -467,11 +517,11 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
467
517
|
}, []);
|
|
468
518
|
const apiKey = onRampPurchase.testMode ? MOONPAY_PUBLISHABLE_KEY_TEST : MOONPAY_PUBLISHABLE_KEY;
|
|
469
519
|
const onUrlSignatureRequested = useCallback(
|
|
470
|
-
|
|
520
|
+
(url) => __async(void 0, null, function* () {
|
|
471
521
|
if (!para.getUserId() || !onRampPurchase.walletType) {
|
|
472
522
|
throw new Error("missing required fields");
|
|
473
523
|
}
|
|
474
|
-
const res =
|
|
524
|
+
const res = yield para.ctx.client.signMoonPayUrl(para.getUserId(), {
|
|
475
525
|
url,
|
|
476
526
|
type: onRampPurchase.walletType,
|
|
477
527
|
cosmosPrefix: para.cosmosPrefix,
|
|
@@ -480,7 +530,7 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
480
530
|
externalWalletAddress: onRampPurchase.externalWalletAddress || void 0
|
|
481
531
|
});
|
|
482
532
|
return res.data.signature;
|
|
483
|
-
},
|
|
533
|
+
}),
|
|
484
534
|
[onRampPurchase.walletId, onRampPurchase.walletType, para.cosmosPrefix, onRampPurchase.testMode, para]
|
|
485
535
|
);
|
|
486
536
|
const { currencyCodes, defaultCurrencyCode } = useMemo(
|
|
@@ -489,17 +539,17 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
489
539
|
walletType: onRampPurchase.walletType,
|
|
490
540
|
purchaseType: onRampPurchase.type
|
|
491
541
|
}),
|
|
492
|
-
[onRampPurchase.walletType, onRampPurchase.type, onRampConfig.assetInfo, onRampConfig
|
|
542
|
+
[onRampPurchase.walletType, onRampPurchase.type, onRampConfig.assetInfo, onRampConfig == null ? void 0 : onRampConfig.allowedAssets]
|
|
493
543
|
);
|
|
494
544
|
const onTransactionCompleted = useCallback(
|
|
495
|
-
|
|
545
|
+
(payload) => __async(void 0, null, function* () {
|
|
496
546
|
try {
|
|
497
547
|
const [network, asset] = reverseCurrencyLookup(
|
|
498
548
|
onRampConfig.assetInfo,
|
|
499
549
|
OnRampProvider2.MOONPAY,
|
|
500
550
|
payload.quoteCurrency.code
|
|
501
551
|
);
|
|
502
|
-
const updated =
|
|
552
|
+
const updated = yield para.ctx.client.updateOnRampPurchase({
|
|
503
553
|
userId: para.getUserId(),
|
|
504
554
|
walletId: onRampPurchase.walletId,
|
|
505
555
|
purchaseId: onRampPurchase.id,
|
|
@@ -524,12 +574,12 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
524
574
|
} catch (e) {
|
|
525
575
|
console.error(e);
|
|
526
576
|
}
|
|
527
|
-
},
|
|
577
|
+
}),
|
|
528
578
|
[onRampPurchase.walletId, onRampPurchase.id, onRampPurchase.externalWalletAddress, isEmbedded]
|
|
529
579
|
);
|
|
530
580
|
const onInitiateDeposit = useCallback(
|
|
531
|
-
|
|
532
|
-
const txHash =
|
|
581
|
+
(payload) => __async(void 0, null, function* () {
|
|
582
|
+
const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
|
|
533
583
|
assetQuantity: payload.cryptoCurrencyAmount,
|
|
534
584
|
fiatQuantity: payload.fiatCurrencyAmount || void 0,
|
|
535
585
|
fiat: payload.fiatCurrency.code.toUpperCase(),
|
|
@@ -538,7 +588,7 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
538
588
|
chainId: payload.cryptoCurrency.chainId
|
|
539
589
|
});
|
|
540
590
|
return { depositId: txHash, cancelTransactionOnError: false };
|
|
541
|
-
},
|
|
591
|
+
}),
|
|
542
592
|
[
|
|
543
593
|
para,
|
|
544
594
|
onRampPurchase.id,
|
|
@@ -553,7 +603,7 @@ var MoonPayEmbed = ({ para, isDark, isEmbedded, onRampConfig, onRampPurchase, se
|
|
|
553
603
|
return null;
|
|
554
604
|
}
|
|
555
605
|
const walletAddresses = currencyCodes.reduce((acc, code) => {
|
|
556
|
-
return {
|
|
606
|
+
return __spreadProps(__spreadValues({}, acc), { [code.toLowerCase()]: onRampPurchase.address });
|
|
557
607
|
}, {});
|
|
558
608
|
return onRampPurchase.type === "BUY" ? /* @__PURE__ */ jsx(
|
|
559
609
|
LazyMoonPayBuyWidget,
|
|
@@ -659,15 +709,15 @@ var RampEmbed = ({
|
|
|
659
709
|
hostApiKey: apiKey,
|
|
660
710
|
userAddress: onRampPurchase.address,
|
|
661
711
|
userEmailAddress: para.getEmail(),
|
|
662
|
-
url: onRampPurchase
|
|
712
|
+
url: (onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? "https://app.demo.ramp.network" : "https://app.ramp.network",
|
|
663
713
|
enabledFlows: [onRampPurchase.type === "BUY" ? "ONRAMP" : "OFFRAMP"],
|
|
664
714
|
useSendCryptoCallback: true,
|
|
665
715
|
variant: "embedded-mobile",
|
|
666
716
|
containerNode: document.getElementById("ramp-container")
|
|
667
|
-
}).on("PURCHASE_CREATED",
|
|
717
|
+
}).on("PURCHASE_CREATED", (e) => __async(void 0, null, function* () {
|
|
668
718
|
const p = e.payload.purchase;
|
|
669
719
|
const [network, asset] = onRampPurchase.testMode ? [Network2.ETHEREUM, OnRampAsset2.ETHEREUM] : reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider3.RAMP, p.asset.symbol) || [];
|
|
670
|
-
const updated =
|
|
720
|
+
const updated = yield para.ctx.client.updateOnRampPurchase({
|
|
671
721
|
userId: para.getUserId(),
|
|
672
722
|
walletId: onRampPurchase.walletId,
|
|
673
723
|
externalWalletAddress: onRampPurchase.externalWalletAddress,
|
|
@@ -682,8 +732,8 @@ var RampEmbed = ({
|
|
|
682
732
|
}
|
|
683
733
|
});
|
|
684
734
|
setOnRampPurchase(updated);
|
|
685
|
-
}).on("WIDGET_CLOSE",
|
|
686
|
-
onClose
|
|
735
|
+
})).on("WIDGET_CLOSE", () => __async(void 0, null, function* () {
|
|
736
|
+
onClose == null ? void 0 : onClose();
|
|
687
737
|
if (!isEmbedded) {
|
|
688
738
|
setTimeout(() => {
|
|
689
739
|
if (typeof window !== "undefined") {
|
|
@@ -691,10 +741,10 @@ var RampEmbed = ({
|
|
|
691
741
|
}
|
|
692
742
|
}, 5e3);
|
|
693
743
|
}
|
|
694
|
-
}).onSendCrypto(
|
|
744
|
+
})).onSendCrypto((assetInfo, amount, address) => __async(void 0, null, function* () {
|
|
695
745
|
try {
|
|
696
746
|
const [network, asset] = reverseCurrencyLookup(onRampConfig.assetInfo, OnRampProvider3.RAMP, assetInfo.symbol);
|
|
697
|
-
const txHash =
|
|
747
|
+
const txHash = yield offRampSend(para, onRampPurchase, setOnRampPurchase, {
|
|
698
748
|
assetQuantity: amount,
|
|
699
749
|
destinationAddress: address,
|
|
700
750
|
contractAddress: getContractAddressFromAsset(network, asset),
|
|
@@ -705,7 +755,7 @@ var RampEmbed = ({
|
|
|
705
755
|
} catch (e) {
|
|
706
756
|
console.error(e);
|
|
707
757
|
}
|
|
708
|
-
});
|
|
758
|
+
}));
|
|
709
759
|
widget.show();
|
|
710
760
|
isMounted.current = true;
|
|
711
761
|
} catch (e) {
|
|
@@ -804,8 +854,8 @@ var StripeEmbed = ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase
|
|
|
804
854
|
const [isReady, setIsReady] = useState2(false);
|
|
805
855
|
const isStripeEmbed = useMemo2(() => onRampPurchase.provider === OnRampProvider4.STRIPE, [onRampPurchase]);
|
|
806
856
|
const clientSecret = useMemo2(
|
|
807
|
-
() => onRampPurchase
|
|
808
|
-
[onRampPurchase
|
|
857
|
+
() => (onRampPurchase == null ? void 0 : onRampPurchase.provider) === OnRampProvider4.STRIPE ? onRampPurchase == null ? void 0 : onRampPurchase.providerKey : void 0,
|
|
858
|
+
[onRampPurchase == null ? void 0 : onRampPurchase.provider, onRampPurchase == null ? void 0 : onRampPurchase.providerKey]
|
|
809
859
|
);
|
|
810
860
|
const [stripeOnRamp, setStripeOnRamp] = useState2();
|
|
811
861
|
const onrampElementRef = React.useRef(null);
|
|
@@ -825,20 +875,20 @@ var StripeEmbed = ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase
|
|
|
825
875
|
}
|
|
826
876
|
}, [clientSecret, stripeOnRamp]);
|
|
827
877
|
useEffect3(() => {
|
|
828
|
-
loadStripeOnramp(onRampPurchase
|
|
878
|
+
loadStripeOnramp((onRampPurchase == null ? void 0 : onRampPurchase.testMode) ? STRIPE_PUBLISHABLE_KEY_TEST : STRIPE_PUBLISHABLE_KEY).then(setStripeOnRamp);
|
|
829
879
|
}, []);
|
|
830
880
|
const onReady = useCallback2(() => {
|
|
831
881
|
setIsReady(true);
|
|
832
882
|
}, []);
|
|
833
883
|
const onSessionChange = useCallback2(
|
|
834
|
-
|
|
884
|
+
(_0) => __async(void 0, [_0], function* ({ session: session2 }) {
|
|
835
885
|
if (!isStripeEmbed) {
|
|
836
886
|
return;
|
|
837
887
|
}
|
|
838
888
|
switch (session2.status) {
|
|
839
889
|
case "fulfillment_processing":
|
|
840
890
|
case "fulfillment_complete":
|
|
841
|
-
const updatedPurchase =
|
|
891
|
+
const updatedPurchase = yield para.ctx.client.updateOnRampPurchase({
|
|
842
892
|
userId: para.getUserId(),
|
|
843
893
|
walletId: onRampPurchase.walletId,
|
|
844
894
|
externalWalletAddress: onRampPurchase.externalWalletAddress,
|
|
@@ -865,7 +915,7 @@ var StripeEmbed = ({ para, isDark, isEmbedded, onRampPurchase, setOnRampPurchase
|
|
|
865
915
|
default:
|
|
866
916
|
break;
|
|
867
917
|
}
|
|
868
|
-
},
|
|
918
|
+
}),
|
|
869
919
|
[isStripeEmbed]
|
|
870
920
|
);
|
|
871
921
|
useOnrampSessionListener("onramp_ui_loaded", session, onReady);
|
|
@@ -963,16 +1013,16 @@ function useCopyToClipboard() {
|
|
|
963
1013
|
setCopied(false);
|
|
964
1014
|
}, 3e3);
|
|
965
1015
|
};
|
|
966
|
-
const copy = useCallback3(
|
|
1016
|
+
const copy = useCallback3((text) => __async(this, null, function* () {
|
|
967
1017
|
if (typeof navigator === "undefined") {
|
|
968
1018
|
return;
|
|
969
1019
|
}
|
|
970
|
-
if (!navigator
|
|
1020
|
+
if (!(navigator == null ? void 0 : navigator.clipboard)) {
|
|
971
1021
|
console.warn("Clipboard not supported");
|
|
972
1022
|
return false;
|
|
973
1023
|
}
|
|
974
1024
|
try {
|
|
975
|
-
|
|
1025
|
+
yield navigator.clipboard.writeText(text);
|
|
976
1026
|
setCopied(true);
|
|
977
1027
|
clearState();
|
|
978
1028
|
return true;
|
|
@@ -981,7 +1031,7 @@ function useCopyToClipboard() {
|
|
|
981
1031
|
setCopied(false);
|
|
982
1032
|
return false;
|
|
983
1033
|
}
|
|
984
|
-
}, []);
|
|
1034
|
+
}), []);
|
|
985
1035
|
return [copied, copy];
|
|
986
1036
|
}
|
|
987
1037
|
|
|
@@ -1069,14 +1119,17 @@ var KnownDevices = ({ hints, link, showCurrentDevice }) => {
|
|
|
1069
1119
|
return /* @__PURE__ */ jsxs4(Container3, { children: [
|
|
1070
1120
|
/* @__PURE__ */ jsx6(CenteredText, { weight: "semiBold", children: "Continue with one of your other known devices" }),
|
|
1071
1121
|
!!hints.formattedHints.length && /* @__PURE__ */ jsx6(DevicesContainer, { children: hints.formattedHints.map(
|
|
1072
|
-
(hint) =>
|
|
1073
|
-
|
|
1074
|
-
/* @__PURE__ */
|
|
1075
|
-
|
|
1076
|
-
/* @__PURE__ */ jsx6(CpslText4, { weight: "medium", color: "
|
|
1077
|
-
/* @__PURE__ */
|
|
1078
|
-
|
|
1079
|
-
|
|
1122
|
+
(hint) => {
|
|
1123
|
+
var _a, _b, _c;
|
|
1124
|
+
return (showCurrentDevice && hint.isKnownDevice || !hint.isKnownDevice) && /* @__PURE__ */ jsxs4(DeviceListItem, { children: [
|
|
1125
|
+
/* @__PURE__ */ jsx6(DeviceLogo, { icon: getDeviceLogo(hint.device.vendor, hint.isMobile) }),
|
|
1126
|
+
/* @__PURE__ */ jsx6(CpslText4, { weight: "medium", color: "contrast", children: (_b = (_a = getDeviceModelName(hint.device.model)) != null ? _a : hint.device.vendor) != null ? _b : hint.os.name }),
|
|
1127
|
+
(hint.browser || hint.passwordManager) && /* @__PURE__ */ jsxs4(Fragment, { children: [
|
|
1128
|
+
/* @__PURE__ */ jsx6(CpslText4, { weight: "medium", color: "secondary", children: "using" }),
|
|
1129
|
+
/* @__PURE__ */ jsx6(CpslText4, { weight: "medium", color: "contrast", children: (_c = hint.passwordManager) != null ? _c : hint.browser.name })
|
|
1130
|
+
] })
|
|
1131
|
+
] }, hint.key);
|
|
1132
|
+
}
|
|
1080
1133
|
) }),
|
|
1081
1134
|
hints.hasMobileDevice ? /* @__PURE__ */ jsx6(QRCode, { link, icon: "paraIconQr" }) : /* @__PURE__ */ jsxs4(CenteredColumnContainer, { children: [
|
|
1082
1135
|
/* @__PURE__ */ jsx6(FullWidthFilledDisabledInput, { noAutoDisable: true, readonly: true, disabled: true, value: link, children: /* @__PURE__ */ jsx6(CpslButton3, { slot: "end", variant: "ghost", onClick: handleCopy, children: /* @__PURE__ */ jsx6(CpslIcon3, { icon: isCopied ? "check" : "copy" }) }) }),
|
package/dist/index.js.br
CHANGED
|
Binary file
|
package/dist/index.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getpara/react-common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
"*.css"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@getpara/react-components": "1.
|
|
15
|
-
"@getpara/web-sdk": "1.
|
|
14
|
+
"@getpara/react-components": "1.6.0",
|
|
15
|
+
"@getpara/web-sdk": "1.6.0",
|
|
16
16
|
"@moonpay/moonpay-react": "^1.8.3",
|
|
17
17
|
"@ramp-network/ramp-instant-sdk": "^4.0.5",
|
|
18
18
|
"@stripe/crypto": "^0.0.4",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"resolutions": {
|
|
44
44
|
"styled-components": "^6"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2dd6c8ea893d72d693804e5c5b0856d2ea6c3a7a"
|
|
47
47
|
}
|