@unifold/ui-web 0.1.46 → 0.1.48
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 +64 -4
- package/dist/index.mjs +64 -4
- package/package.json +8 -5
package/dist/index.js
CHANGED
|
@@ -43351,6 +43351,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
43351
43351
|
if (request.subdivision_code) {
|
|
43352
43352
|
params.append("subdivision_code", request.subdivision_code);
|
|
43353
43353
|
}
|
|
43354
|
+
if (request.external_id) {
|
|
43355
|
+
params.append("external_id", request.external_id);
|
|
43356
|
+
}
|
|
43354
43357
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
43355
43358
|
}
|
|
43356
43359
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -43674,6 +43677,38 @@ async function getDepositQuote(request, publishableKey) {
|
|
|
43674
43677
|
const json = await response.json();
|
|
43675
43678
|
return json.data;
|
|
43676
43679
|
}
|
|
43680
|
+
function generatePrefixedKSUID(prefix) {
|
|
43681
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
43682
|
+
const KSUID_EPOCH = 14e8;
|
|
43683
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
43684
|
+
const payload = new Uint8Array(20);
|
|
43685
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
43686
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
43687
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
43688
|
+
payload[3] = timestampSeconds & 255;
|
|
43689
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
43690
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
43691
|
+
} else {
|
|
43692
|
+
for (let i = 4; i < 20; i++) {
|
|
43693
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
43694
|
+
}
|
|
43695
|
+
}
|
|
43696
|
+
let value = 0n;
|
|
43697
|
+
for (const byte of payload) {
|
|
43698
|
+
value = value << 8n | BigInt(byte);
|
|
43699
|
+
}
|
|
43700
|
+
let encoded = "";
|
|
43701
|
+
while (value > 0n) {
|
|
43702
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
43703
|
+
value = value / 62n;
|
|
43704
|
+
}
|
|
43705
|
+
encoded = encoded.padStart(27, "0");
|
|
43706
|
+
return `${prefix}_${encoded}`;
|
|
43707
|
+
}
|
|
43708
|
+
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
43709
|
+
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
43710
|
+
return DepositEventType2;
|
|
43711
|
+
})(DepositEventType || {});
|
|
43677
43712
|
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
43678
43713
|
var use = React25[" use ".trim().toString()];
|
|
43679
43714
|
function isPromiseLike(value) {
|
|
@@ -50007,6 +50042,7 @@ function BuyWithCard({
|
|
|
50007
50042
|
destinationTokenAddress,
|
|
50008
50043
|
onDepositSuccess,
|
|
50009
50044
|
onDepositError,
|
|
50045
|
+
onEvent,
|
|
50010
50046
|
themeClass = "",
|
|
50011
50047
|
wallets: externalWallets,
|
|
50012
50048
|
assetCdnUrl,
|
|
@@ -50360,6 +50396,7 @@ function BuyWithCard({
|
|
|
50360
50396
|
setQuotesError("Wallet address not available");
|
|
50361
50397
|
return;
|
|
50362
50398
|
}
|
|
50399
|
+
const externalId = generatePrefixedKSUID("orsext");
|
|
50363
50400
|
const sessionRequest = {
|
|
50364
50401
|
service_provider: selectedProvider.service_provider,
|
|
50365
50402
|
country_code: selectedProvider.country_code.toUpperCase() || "US",
|
|
@@ -50368,7 +50405,8 @@ function BuyWithCard({
|
|
|
50368
50405
|
destination_currency: selectedProvider.destination_currency,
|
|
50369
50406
|
destination_network: selectedProvider.destination_network,
|
|
50370
50407
|
wallet_address: wallet.address,
|
|
50371
|
-
subdivision_code: userIpInfo?.state || void 0
|
|
50408
|
+
subdivision_code: userIpInfo?.state || void 0,
|
|
50409
|
+
external_id: externalId
|
|
50372
50410
|
};
|
|
50373
50411
|
const sessionStartUrl = getOnrampSessionStartUrl(
|
|
50374
50412
|
sessionRequest,
|
|
@@ -50378,7 +50416,14 @@ function BuyWithCard({
|
|
|
50378
50416
|
provider: selectedProvider,
|
|
50379
50417
|
sourceCurrency: currency,
|
|
50380
50418
|
sourceAmount: amount,
|
|
50381
|
-
sessionUrl: sessionStartUrl
|
|
50419
|
+
sessionUrl: sessionStartUrl,
|
|
50420
|
+
externalId
|
|
50421
|
+
});
|
|
50422
|
+
onEvent?.({
|
|
50423
|
+
id: generatePrefixedKSUID("sevt"),
|
|
50424
|
+
type: DepositEventType.ONRAMP_SESSION_CREATED,
|
|
50425
|
+
created: Math.floor(Date.now() / 1e3),
|
|
50426
|
+
data: { object: { externalId } }
|
|
50382
50427
|
});
|
|
50383
50428
|
window.open(sessionStartUrl, "_blank");
|
|
50384
50429
|
handleViewChange("onramp");
|
|
@@ -59141,6 +59186,7 @@ function DepositModal({
|
|
|
59141
59186
|
hideDisplayDescription = false,
|
|
59142
59187
|
onDepositSuccess,
|
|
59143
59188
|
onDepositError,
|
|
59189
|
+
onEvent,
|
|
59144
59190
|
theme = "dark",
|
|
59145
59191
|
hideOverlay = false,
|
|
59146
59192
|
initialScreen = "main",
|
|
@@ -59655,6 +59701,7 @@ function DepositModal({
|
|
|
59655
59701
|
destinationTokenAddress,
|
|
59656
59702
|
onDepositSuccess,
|
|
59657
59703
|
onDepositError,
|
|
59704
|
+
onEvent,
|
|
59658
59705
|
themeClass,
|
|
59659
59706
|
wallets,
|
|
59660
59707
|
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
@@ -59838,6 +59885,10 @@ function CheckoutModal({
|
|
|
59838
59885
|
publishableKey,
|
|
59839
59886
|
modalTitle,
|
|
59840
59887
|
enableConnectWallet = false,
|
|
59888
|
+
defaultSourceChainType,
|
|
59889
|
+
defaultSourceChainId,
|
|
59890
|
+
defaultSourceTokenAddress,
|
|
59891
|
+
defaultSourceSymbol,
|
|
59841
59892
|
theme = "dark",
|
|
59842
59893
|
onCheckoutSuccess,
|
|
59843
59894
|
onCheckoutError
|
|
@@ -60335,6 +60386,10 @@ function CheckoutModal({
|
|
|
60335
60386
|
destinationChainType: paymentIntent.destination_chain_type,
|
|
60336
60387
|
destinationChainId: paymentIntent.destination_chain_id,
|
|
60337
60388
|
destinationTokenAddress: paymentIntent.destination_token_address,
|
|
60389
|
+
defaultSourceChainType,
|
|
60390
|
+
defaultSourceChainId,
|
|
60391
|
+
defaultSourceTokenAddress,
|
|
60392
|
+
defaultSourceSymbol,
|
|
60338
60393
|
depositConfirmationMode: "auto_ui",
|
|
60339
60394
|
wallets,
|
|
60340
60395
|
onSourceTokenChange: setSelectedSource,
|
|
@@ -60987,8 +61042,8 @@ function WithdrawForm({
|
|
|
60987
61042
|
setAmount(fiat.toFixed(2));
|
|
60988
61043
|
setInputUnit("fiat");
|
|
60989
61044
|
} else {
|
|
60990
|
-
const
|
|
60991
|
-
setAmount(
|
|
61045
|
+
const crypto2 = val / exchangeRate;
|
|
61046
|
+
setAmount(crypto2.toFixed(sourceDecimals > 6 ? 6 : sourceDecimals));
|
|
60992
61047
|
setInputUnit("crypto");
|
|
60993
61048
|
}
|
|
60994
61049
|
}, [amount, inputUnit, exchangeRate, sourceDecimals]);
|
|
@@ -62185,6 +62240,10 @@ function UnifoldProvider2({
|
|
|
62185
62240
|
clientSecret: checkoutConfig.clientSecret,
|
|
62186
62241
|
publishableKey,
|
|
62187
62242
|
enableConnectWallet: config?.enableConnectWallet,
|
|
62243
|
+
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
62244
|
+
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
62245
|
+
defaultSourceTokenAddress: checkoutConfig.defaultSourceTokenAddress,
|
|
62246
|
+
defaultSourceSymbol: checkoutConfig.defaultSourceSymbol,
|
|
62188
62247
|
theme: resolvedTheme,
|
|
62189
62248
|
onCheckoutSuccess: handleCheckoutSuccess,
|
|
62190
62249
|
onCheckoutError: handleCheckoutError
|
|
@@ -62235,6 +62294,7 @@ function UnifoldProvider2({
|
|
|
62235
62294
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
62236
62295
|
onDepositSuccess: handleDepositSuccess,
|
|
62237
62296
|
onDepositError: handleDepositError,
|
|
62297
|
+
onEvent: depositConfig.onEvent,
|
|
62238
62298
|
theme: resolvedTheme,
|
|
62239
62299
|
initialScreen: depositConfig.initialScreen ?? config?.defaultInitialScreen,
|
|
62240
62300
|
transferCryptoTitle: config?.transferCryptoTitle,
|
package/dist/index.mjs
CHANGED
|
@@ -43338,6 +43338,9 @@ function getOnrampSessionStartUrl(request, publishableKey) {
|
|
|
43338
43338
|
if (request.subdivision_code) {
|
|
43339
43339
|
params.append("subdivision_code", request.subdivision_code);
|
|
43340
43340
|
}
|
|
43341
|
+
if (request.external_id) {
|
|
43342
|
+
params.append("external_id", request.external_id);
|
|
43343
|
+
}
|
|
43341
43344
|
return `${API_BASE_URL}/v1/public/onramps/sessions/start?${params.toString()}`;
|
|
43342
43345
|
}
|
|
43343
43346
|
async function getDefaultOnrampToken(params, publishableKey) {
|
|
@@ -43661,6 +43664,38 @@ async function getDepositQuote(request, publishableKey) {
|
|
|
43661
43664
|
const json = await response.json();
|
|
43662
43665
|
return json.data;
|
|
43663
43666
|
}
|
|
43667
|
+
function generatePrefixedKSUID(prefix) {
|
|
43668
|
+
const BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
43669
|
+
const KSUID_EPOCH = 14e8;
|
|
43670
|
+
const timestampSeconds = Math.floor(Date.now() / 1e3) - KSUID_EPOCH;
|
|
43671
|
+
const payload = new Uint8Array(20);
|
|
43672
|
+
payload[0] = timestampSeconds >>> 24 & 255;
|
|
43673
|
+
payload[1] = timestampSeconds >>> 16 & 255;
|
|
43674
|
+
payload[2] = timestampSeconds >>> 8 & 255;
|
|
43675
|
+
payload[3] = timestampSeconds & 255;
|
|
43676
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
43677
|
+
crypto.getRandomValues(payload.subarray(4));
|
|
43678
|
+
} else {
|
|
43679
|
+
for (let i = 4; i < 20; i++) {
|
|
43680
|
+
payload[i] = Math.floor(Math.random() * 256);
|
|
43681
|
+
}
|
|
43682
|
+
}
|
|
43683
|
+
let value = 0n;
|
|
43684
|
+
for (const byte of payload) {
|
|
43685
|
+
value = value << 8n | BigInt(byte);
|
|
43686
|
+
}
|
|
43687
|
+
let encoded = "";
|
|
43688
|
+
while (value > 0n) {
|
|
43689
|
+
encoded = BASE62[Number(value % 62n)] + encoded;
|
|
43690
|
+
value = value / 62n;
|
|
43691
|
+
}
|
|
43692
|
+
encoded = encoded.padStart(27, "0");
|
|
43693
|
+
return `${prefix}_${encoded}`;
|
|
43694
|
+
}
|
|
43695
|
+
var DepositEventType = /* @__PURE__ */ ((DepositEventType2) => {
|
|
43696
|
+
DepositEventType2["ONRAMP_SESSION_CREATED"] = "onramp_session.created";
|
|
43697
|
+
return DepositEventType2;
|
|
43698
|
+
})(DepositEventType || {});
|
|
43664
43699
|
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
43665
43700
|
var use = React25[" use ".trim().toString()];
|
|
43666
43701
|
function isPromiseLike(value) {
|
|
@@ -49994,6 +50029,7 @@ function BuyWithCard({
|
|
|
49994
50029
|
destinationTokenAddress,
|
|
49995
50030
|
onDepositSuccess,
|
|
49996
50031
|
onDepositError,
|
|
50032
|
+
onEvent,
|
|
49997
50033
|
themeClass = "",
|
|
49998
50034
|
wallets: externalWallets,
|
|
49999
50035
|
assetCdnUrl,
|
|
@@ -50347,6 +50383,7 @@ function BuyWithCard({
|
|
|
50347
50383
|
setQuotesError("Wallet address not available");
|
|
50348
50384
|
return;
|
|
50349
50385
|
}
|
|
50386
|
+
const externalId = generatePrefixedKSUID("orsext");
|
|
50350
50387
|
const sessionRequest = {
|
|
50351
50388
|
service_provider: selectedProvider.service_provider,
|
|
50352
50389
|
country_code: selectedProvider.country_code.toUpperCase() || "US",
|
|
@@ -50355,7 +50392,8 @@ function BuyWithCard({
|
|
|
50355
50392
|
destination_currency: selectedProvider.destination_currency,
|
|
50356
50393
|
destination_network: selectedProvider.destination_network,
|
|
50357
50394
|
wallet_address: wallet.address,
|
|
50358
|
-
subdivision_code: userIpInfo?.state || void 0
|
|
50395
|
+
subdivision_code: userIpInfo?.state || void 0,
|
|
50396
|
+
external_id: externalId
|
|
50359
50397
|
};
|
|
50360
50398
|
const sessionStartUrl = getOnrampSessionStartUrl(
|
|
50361
50399
|
sessionRequest,
|
|
@@ -50365,7 +50403,14 @@ function BuyWithCard({
|
|
|
50365
50403
|
provider: selectedProvider,
|
|
50366
50404
|
sourceCurrency: currency,
|
|
50367
50405
|
sourceAmount: amount,
|
|
50368
|
-
sessionUrl: sessionStartUrl
|
|
50406
|
+
sessionUrl: sessionStartUrl,
|
|
50407
|
+
externalId
|
|
50408
|
+
});
|
|
50409
|
+
onEvent?.({
|
|
50410
|
+
id: generatePrefixedKSUID("sevt"),
|
|
50411
|
+
type: DepositEventType.ONRAMP_SESSION_CREATED,
|
|
50412
|
+
created: Math.floor(Date.now() / 1e3),
|
|
50413
|
+
data: { object: { externalId } }
|
|
50369
50414
|
});
|
|
50370
50415
|
window.open(sessionStartUrl, "_blank");
|
|
50371
50416
|
handleViewChange("onramp");
|
|
@@ -59128,6 +59173,7 @@ function DepositModal({
|
|
|
59128
59173
|
hideDisplayDescription = false,
|
|
59129
59174
|
onDepositSuccess,
|
|
59130
59175
|
onDepositError,
|
|
59176
|
+
onEvent,
|
|
59131
59177
|
theme = "dark",
|
|
59132
59178
|
hideOverlay = false,
|
|
59133
59179
|
initialScreen = "main",
|
|
@@ -59642,6 +59688,7 @@ function DepositModal({
|
|
|
59642
59688
|
destinationTokenAddress,
|
|
59643
59689
|
onDepositSuccess,
|
|
59644
59690
|
onDepositError,
|
|
59691
|
+
onEvent,
|
|
59645
59692
|
themeClass,
|
|
59646
59693
|
wallets,
|
|
59647
59694
|
assetCdnUrl: projectConfig?.asset_cdn_url,
|
|
@@ -59825,6 +59872,10 @@ function CheckoutModal({
|
|
|
59825
59872
|
publishableKey,
|
|
59826
59873
|
modalTitle,
|
|
59827
59874
|
enableConnectWallet = false,
|
|
59875
|
+
defaultSourceChainType,
|
|
59876
|
+
defaultSourceChainId,
|
|
59877
|
+
defaultSourceTokenAddress,
|
|
59878
|
+
defaultSourceSymbol,
|
|
59828
59879
|
theme = "dark",
|
|
59829
59880
|
onCheckoutSuccess,
|
|
59830
59881
|
onCheckoutError
|
|
@@ -60322,6 +60373,10 @@ function CheckoutModal({
|
|
|
60322
60373
|
destinationChainType: paymentIntent.destination_chain_type,
|
|
60323
60374
|
destinationChainId: paymentIntent.destination_chain_id,
|
|
60324
60375
|
destinationTokenAddress: paymentIntent.destination_token_address,
|
|
60376
|
+
defaultSourceChainType,
|
|
60377
|
+
defaultSourceChainId,
|
|
60378
|
+
defaultSourceTokenAddress,
|
|
60379
|
+
defaultSourceSymbol,
|
|
60325
60380
|
depositConfirmationMode: "auto_ui",
|
|
60326
60381
|
wallets,
|
|
60327
60382
|
onSourceTokenChange: setSelectedSource,
|
|
@@ -60974,8 +61029,8 @@ function WithdrawForm({
|
|
|
60974
61029
|
setAmount(fiat.toFixed(2));
|
|
60975
61030
|
setInputUnit("fiat");
|
|
60976
61031
|
} else {
|
|
60977
|
-
const
|
|
60978
|
-
setAmount(
|
|
61032
|
+
const crypto2 = val / exchangeRate;
|
|
61033
|
+
setAmount(crypto2.toFixed(sourceDecimals > 6 ? 6 : sourceDecimals));
|
|
60979
61034
|
setInputUnit("crypto");
|
|
60980
61035
|
}
|
|
60981
61036
|
}, [amount, inputUnit, exchangeRate, sourceDecimals]);
|
|
@@ -62172,6 +62227,10 @@ function UnifoldProvider2({
|
|
|
62172
62227
|
clientSecret: checkoutConfig.clientSecret,
|
|
62173
62228
|
publishableKey,
|
|
62174
62229
|
enableConnectWallet: config?.enableConnectWallet,
|
|
62230
|
+
defaultSourceChainType: checkoutConfig.defaultSourceChainType,
|
|
62231
|
+
defaultSourceChainId: checkoutConfig.defaultSourceChainId,
|
|
62232
|
+
defaultSourceTokenAddress: checkoutConfig.defaultSourceTokenAddress,
|
|
62233
|
+
defaultSourceSymbol: checkoutConfig.defaultSourceSymbol,
|
|
62175
62234
|
theme: resolvedTheme,
|
|
62176
62235
|
onCheckoutSuccess: handleCheckoutSuccess,
|
|
62177
62236
|
onCheckoutError: handleCheckoutError
|
|
@@ -62222,6 +62281,7 @@ function UnifoldProvider2({
|
|
|
62222
62281
|
enablePayWithExchange: config?.enablePayWithExchange,
|
|
62223
62282
|
onDepositSuccess: handleDepositSuccess,
|
|
62224
62283
|
onDepositError: handleDepositError,
|
|
62284
|
+
onEvent: depositConfig.onEvent,
|
|
62225
62285
|
theme: resolvedTheme,
|
|
62226
62286
|
initialScreen: depositConfig.initialScreen ?? config?.defaultInitialScreen,
|
|
62227
62287
|
transferCryptoTitle: config?.transferCryptoTitle,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unifold/ui-web",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.48",
|
|
4
4
|
"description": "Unifold UI Web - Framework-agnostic deposit widget",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"dist",
|
|
20
20
|
"README.md"
|
|
21
21
|
],
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@solana/web3.js": "^1.87.0"
|
|
24
|
+
},
|
|
22
25
|
"devDependencies": {
|
|
23
26
|
"@tanstack/react-query": "^5.90.11",
|
|
24
27
|
"react": "^18.2.0 || ^19.0.0",
|
|
@@ -27,10 +30,10 @@
|
|
|
27
30
|
"@types/react-dom": "^19.0.0",
|
|
28
31
|
"tsup": "^8.0.0",
|
|
29
32
|
"typescript": "^5.0.0",
|
|
30
|
-
"@unifold/connect-react": "0.1.
|
|
31
|
-
"@unifold/react-provider": "0.1.
|
|
32
|
-
"@unifold/core": "0.1.
|
|
33
|
-
"@unifold/ui-react": "0.1.
|
|
33
|
+
"@unifold/connect-react": "0.1.48",
|
|
34
|
+
"@unifold/react-provider": "0.1.48",
|
|
35
|
+
"@unifold/core": "0.1.48",
|
|
36
|
+
"@unifold/ui-react": "0.1.48"
|
|
34
37
|
},
|
|
35
38
|
"keywords": [
|
|
36
39
|
"unifold",
|