@rhinestone/deposit-modal 0.20.1 → 0.21.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/README.md +42 -17
- package/dist/{BankOnrampStep-4D24HVHV.mjs → BankOnrampStep-JTU7WS5R.mjs} +22 -12
- package/dist/{BankOnrampStep-3SNUX6V2.cjs → BankOnrampStep-QCPISCAQ.cjs} +34 -24
- package/dist/{DepositModalReown-SYQ2SCHC.mjs → DepositModalReown-FJBSF4VL.mjs} +5 -3
- package/dist/{DepositModalReown-7EHOJTFW.cjs → DepositModalReown-QJ6O2FWY.cjs} +18 -16
- package/dist/{WithdrawModal-LXDIT4UV.mjs → WithdrawModal-CB7RNEPI.mjs} +3 -3
- package/dist/WithdrawModal-E2BTWJV7.cjs +12 -0
- package/dist/{chunk-ZOJMB5TZ.mjs → chunk-2D3J53PX.mjs} +1 -1
- package/dist/{chunk-KXSU24RU.cjs → chunk-4O2UGFFT.cjs} +71 -62
- package/dist/{chunk-IPKT3FU6.mjs → chunk-7CHQA2OZ.mjs} +1 -1
- package/dist/chunk-ADEWTBSN.cjs +19 -0
- package/dist/{chunk-O5OW4S7L.cjs → chunk-AV3SA7TW.cjs} +3 -3
- package/dist/{chunk-FW7ZMXQS.mjs → chunk-B2LUWNFX.mjs} +179 -96
- package/dist/{chunk-PVFEZ3UG.cjs → chunk-CAIRS4LK.cjs} +449 -366
- package/dist/{chunk-LVMNNMOZ.cjs → chunk-CG3JKPUF.cjs} +2 -2
- package/dist/{chunk-JPX4MEHV.mjs → chunk-CXEQFRX4.mjs} +1 -1
- package/dist/chunk-PP4QE32S.mjs +19 -0
- package/dist/{chunk-YQCRXJIL.mjs → chunk-PZIKRYMO.mjs} +1 -1
- package/dist/{chunk-CIVFT5KR.cjs → chunk-U7NYYT4Q.cjs} +58 -58
- package/dist/{chunk-OZPMRTW3.mjs → chunk-UNXUOV3F.mjs} +39 -30
- package/dist/{chunk-D3R3O4CY.cjs → chunk-VQAV6ESI.cjs} +1 -1
- package/dist/{chunk-EJDBIWNH.mjs → chunk-WK2ELRL3.mjs} +5 -16
- package/dist/{chunk-IPHKBBUV.cjs → chunk-X425VJFY.cjs} +10 -21
- package/dist/compliance.cjs +4 -4
- package/dist/compliance.mjs +3 -3
- package/dist/constants.cjs +2 -2
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.mjs +1 -1
- package/dist/deposit.cjs +6 -4
- package/dist/deposit.d.cts +2 -2
- package/dist/deposit.d.ts +2 -2
- package/dist/deposit.mjs +5 -3
- package/dist/embed.cjs +16 -14
- package/dist/embed.d.cts +1 -1
- package/dist/embed.d.ts +1 -1
- package/dist/embed.mjs +6 -4
- package/dist/index.cjs +7 -5
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +6 -4
- package/dist/onramp.cjs +5 -4
- package/dist/onramp.mjs +4 -3
- package/dist/server.cjs +12 -8
- package/dist/server.mjs +11 -7
- package/dist/{types-BEEMfNi2.d.cts → types-BrxDZNEr.d.cts} +20 -10
- package/dist/{types-DQDUqzsZ.d.ts → types-DCUB4DY8.d.ts} +20 -10
- package/dist/withdraw.cjs +4 -4
- package/dist/withdraw.d.cts +2 -2
- package/dist/withdraw.d.ts +2 -2
- package/dist/withdraw.mjs +3 -3
- package/package.json +3 -3
- package/dist/WithdrawModal-LLJLEYXZ.cjs +0 -12
|
@@ -59,6 +59,7 @@ import {
|
|
|
59
59
|
getExchangeLogoSrc,
|
|
60
60
|
getPublicClient,
|
|
61
61
|
hasReached,
|
|
62
|
+
hostedOrderState,
|
|
62
63
|
hostedOrderStateFromSwapped,
|
|
63
64
|
isDepositEvent,
|
|
64
65
|
isDepositPolicyRefusal,
|
|
@@ -97,7 +98,7 @@ import {
|
|
|
97
98
|
useTokenDisplay,
|
|
98
99
|
useTokenDisplays,
|
|
99
100
|
warnRemovedProps
|
|
100
|
-
} from "./chunk-
|
|
101
|
+
} from "./chunk-UNXUOV3F.mjs";
|
|
101
102
|
import {
|
|
102
103
|
AppleIcon,
|
|
103
104
|
BankIcon,
|
|
@@ -118,6 +119,12 @@ import {
|
|
|
118
119
|
WalletIcon,
|
|
119
120
|
useLatestRef
|
|
120
121
|
} from "./chunk-YY4ZOAH5.mjs";
|
|
122
|
+
import {
|
|
123
|
+
rampQuery
|
|
124
|
+
} from "./chunk-PP4QE32S.mjs";
|
|
125
|
+
import {
|
|
126
|
+
createBearerTransport
|
|
127
|
+
} from "./chunk-PZIKRYMO.mjs";
|
|
121
128
|
import {
|
|
122
129
|
HYPERCORE_CHAIN_ID,
|
|
123
130
|
HYPERCORE_MIN_DEPOSIT_USD,
|
|
@@ -169,7 +176,7 @@ function getReownDependencies() {
|
|
|
169
176
|
|
|
170
177
|
// src/DepositModal.tsx
|
|
171
178
|
import {
|
|
172
|
-
useMemo as
|
|
179
|
+
useMemo as useMemo10,
|
|
173
180
|
useEffect as useEffect15,
|
|
174
181
|
useRef as useRef11,
|
|
175
182
|
useState as useState15,
|
|
@@ -4185,7 +4192,7 @@ SwappedProviderStep.displayName = "SwappedProviderStep";
|
|
|
4185
4192
|
// src/components/steps/RampOrderStep.tsx
|
|
4186
4193
|
import { jsx as jsx18 } from "react/jsx-runtime";
|
|
4187
4194
|
var BankOnrampStep = lazy2(async () => {
|
|
4188
|
-
const module = await import("./BankOnrampStep-
|
|
4195
|
+
const module = await import("./BankOnrampStep-JTU7WS5R.mjs");
|
|
4189
4196
|
return { default: module.BankOnrampStep };
|
|
4190
4197
|
});
|
|
4191
4198
|
var HOSTED = {
|
|
@@ -4210,7 +4217,7 @@ function RampOrderStep(props) {
|
|
|
4210
4217
|
{
|
|
4211
4218
|
backendUrl: order.backendUrl,
|
|
4212
4219
|
smartAccount,
|
|
4213
|
-
|
|
4220
|
+
getCustomerSession: order.getCustomerSession,
|
|
4214
4221
|
onJourney: order.onJourney,
|
|
4215
4222
|
onGoBack: props.onGoBack,
|
|
4216
4223
|
onError: props.onError,
|
|
@@ -4274,6 +4281,47 @@ function HostedOrder({
|
|
|
4274
4281
|
}
|
|
4275
4282
|
RampOrderStep.displayName = "RampOrderStep";
|
|
4276
4283
|
|
|
4284
|
+
// src/core/ramp-rows.ts
|
|
4285
|
+
var NOT_SERVED_NOTICE = "Bank transfer isn't available in your region.";
|
|
4286
|
+
function resolveRampRows(input) {
|
|
4287
|
+
const { providers } = input;
|
|
4288
|
+
const has = (provider, kind) => providers === null || providers !== "loading" && providers.some((p) => p.provider === provider && p.kinds.includes(kind));
|
|
4289
|
+
const loading = providers === "loading";
|
|
4290
|
+
const exchange = !input.enableExchangeConnect ? "hidden" : loading ? "loading" : has("swapped", "exchange") ? "offered" : "hidden";
|
|
4291
|
+
const bankRequested = input.virtualAccounts && input.customerSession && input.bankTransferAllowed;
|
|
4292
|
+
const swappedFiat = has("swapped", "fiat");
|
|
4293
|
+
const bankBy = !bankRequested ? null : has("noah", "fiat") && !input.noahNotServed ? "noah" : swappedFiat && !refusesBank(input.swappedMethods) ? "swapped" : null;
|
|
4294
|
+
const notice = bankRequested && input.noahNotServed && !bankBy ? NOT_SERVED_NOTICE : null;
|
|
4295
|
+
const offered = input.enableFiatOnramp && swappedFiat ? input.swappedMethods : { kind: "hidden" };
|
|
4296
|
+
const swapped = offered.kind === "hidden" && bankBy ? {
|
|
4297
|
+
kind: "list",
|
|
4298
|
+
methods: [],
|
|
4299
|
+
recommendedMethod: input.bankRow.method,
|
|
4300
|
+
country: null,
|
|
4301
|
+
source: "configured"
|
|
4302
|
+
} : offered;
|
|
4303
|
+
if (loading && (input.enableFiatOnramp || bankRequested)) {
|
|
4304
|
+
return { cash: { kind: "loading" }, exchange, notice: null };
|
|
4305
|
+
}
|
|
4306
|
+
if (swapped.kind !== "list") return { cash: swapped, exchange, notice };
|
|
4307
|
+
const methods = swapped.methods.map((m) => ({
|
|
4308
|
+
...m,
|
|
4309
|
+
provider: isBankRow(m) && bankBy ? bankBy : "swapped"
|
|
4310
|
+
}));
|
|
4311
|
+
if (bankBy && !methods.some(isBankRow)) {
|
|
4312
|
+
methods.push({ ...input.bankRow, provider: bankBy });
|
|
4313
|
+
}
|
|
4314
|
+
return { cash: { ...swapped, methods }, exchange, notice };
|
|
4315
|
+
}
|
|
4316
|
+
function refusesBank(swapped) {
|
|
4317
|
+
if (swapped.kind === "hidden") return true;
|
|
4318
|
+
if (swapped.kind !== "list" || swapped.source === "fallback") return false;
|
|
4319
|
+
return !swapped.methods.some(isBankRow);
|
|
4320
|
+
}
|
|
4321
|
+
function isBankRow(m) {
|
|
4322
|
+
return m.method === "bank-transfer";
|
|
4323
|
+
}
|
|
4324
|
+
|
|
4277
4325
|
// src/components/steps/ExchangeSelectStep.tsx
|
|
4278
4326
|
import { useCallback as useCallback4, useEffect as useEffect9, useState as useState9 } from "react";
|
|
4279
4327
|
import { jsx as jsx19, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
@@ -6117,6 +6165,7 @@ function analyticsStepForFlowStep(method, step) {
|
|
|
6117
6165
|
}
|
|
6118
6166
|
var BANK_FAILURES = {
|
|
6119
6167
|
BANK_ONRAMP_OPTIONS_FAILED: "bank_options_failed",
|
|
6168
|
+
BANK_ONRAMP_SESSION_REFUSED: "bank_session_refused",
|
|
6120
6169
|
BANK_ONRAMP_SETUP_FAILED: "bank_setup_failed",
|
|
6121
6170
|
BANK_ONRAMP_DETAILS_FAILED: "bank_details_failed",
|
|
6122
6171
|
BANK_ONRAMP_DETAILS_PENDING: "bank_details_pending"
|
|
@@ -7663,7 +7712,8 @@ function DepositFlow({
|
|
|
7663
7712
|
initialAssetMigration,
|
|
7664
7713
|
enableWallet = true,
|
|
7665
7714
|
enableFiatOnramp = false,
|
|
7666
|
-
|
|
7715
|
+
virtualAccountOnramp,
|
|
7716
|
+
getCustomerSession,
|
|
7667
7717
|
onBankJourney,
|
|
7668
7718
|
backendUrl,
|
|
7669
7719
|
enableQrTransfer = true,
|
|
@@ -7720,7 +7770,7 @@ function DepositFlow({
|
|
|
7720
7770
|
[debug]
|
|
7721
7771
|
);
|
|
7722
7772
|
const bankOnrampEnabled = Boolean(
|
|
7723
|
-
|
|
7773
|
+
virtualAccountOnramp && getCustomerSession && (fiatMethods === void 0 || fiatMethods["bank-transfer"] === true)
|
|
7724
7774
|
);
|
|
7725
7775
|
const hasSwappedFiatMethod = Boolean(
|
|
7726
7776
|
enableFiatOnramp && (!fiatMethods || Object.entries(fiatMethods).some(
|
|
@@ -8692,11 +8742,6 @@ function DepositFlow({
|
|
|
8692
8742
|
clearTimeout(timer);
|
|
8693
8743
|
};
|
|
8694
8744
|
}, [bankOnrampEnabled, enableExchangeConnect, enableFiatOnramp, service]);
|
|
8695
|
-
const providersLoading = providers === "loading";
|
|
8696
|
-
const offers = (provider, kind) => providers === null || providers !== "loading" && providers.some((p) => p.provider === provider && p.kinds.includes(kind));
|
|
8697
|
-
const swappedFiatOffered = offers("swapped", "fiat");
|
|
8698
|
-
const noahOffered = offers("noah", "fiat");
|
|
8699
|
-
const exchangeOffered = enableExchangeConnect && offers("swapped", "exchange");
|
|
8700
8745
|
const [regionalMethods, setRegionalMethods] = useState13({
|
|
8701
8746
|
status: "loading",
|
|
8702
8747
|
country: null,
|
|
@@ -8743,57 +8788,51 @@ function DepositFlow({
|
|
|
8743
8788
|
clearTimeout(timeoutTimer);
|
|
8744
8789
|
};
|
|
8745
8790
|
}, [analytics, enableFiatOnramp, hasConfiguredFiatMethods, service]);
|
|
8746
|
-
const
|
|
8747
|
-
() =>
|
|
8791
|
+
const swappedMethods = useMemo8(
|
|
8792
|
+
() => hasConfiguredFiatMethods ? {
|
|
8748
8793
|
kind: "list",
|
|
8749
8794
|
methods: configuredFiatMethods,
|
|
8750
8795
|
recommendedMethod: configuredFiatMethods[0]?.method ?? "bank-transfer",
|
|
8751
8796
|
country: null,
|
|
8752
8797
|
source: "configured"
|
|
8753
8798
|
} : composeFiatMethods(regionalMethods, FIAT_ONRAMP_METHODS),
|
|
8799
|
+
[configuredFiatMethods, hasConfiguredFiatMethods, regionalMethods]
|
|
8800
|
+
);
|
|
8801
|
+
const [noahNotServedFor, setNoahNotServedFor] = useState13(null);
|
|
8802
|
+
const noahNotServed = noahNotServedFor !== null && noahNotServedFor === setupSlice.smartAccount?.toLowerCase();
|
|
8803
|
+
const rampRowInputs = useMemo8(
|
|
8804
|
+
() => ({
|
|
8805
|
+
enableFiatOnramp,
|
|
8806
|
+
virtualAccounts: Boolean(virtualAccountOnramp),
|
|
8807
|
+
customerSession: Boolean(getCustomerSession),
|
|
8808
|
+
bankTransferAllowed: fiatMethods === void 0 || fiatMethods["bank-transfer"] === true,
|
|
8809
|
+
enableExchangeConnect,
|
|
8810
|
+
providers,
|
|
8811
|
+
swappedMethods,
|
|
8812
|
+
bankRow: FIAT_ONRAMP_METHODS.find(({ method }) => method === "bank-transfer"),
|
|
8813
|
+
noahNotServed
|
|
8814
|
+
}),
|
|
8754
8815
|
[
|
|
8755
|
-
|
|
8816
|
+
enableExchangeConnect,
|
|
8756
8817
|
enableFiatOnramp,
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8818
|
+
fiatMethods,
|
|
8819
|
+
getCustomerSession,
|
|
8820
|
+
noahNotServed,
|
|
8821
|
+
providers,
|
|
8822
|
+
swappedMethods,
|
|
8823
|
+
virtualAccountOnramp
|
|
8760
8824
|
]
|
|
8761
8825
|
);
|
|
8762
|
-
const
|
|
8763
|
-
const
|
|
8764
|
-
const
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
const swappedDisplay = swappedCashDisplay;
|
|
8773
|
-
if (!bankRowOffered || swappedDisplay.kind === "loading") {
|
|
8774
|
-
return swappedDisplay;
|
|
8775
|
-
}
|
|
8776
|
-
const asNoah = (m) => m.method === "bank-transfer" ? { ...m, provider: "noah" } : m;
|
|
8777
|
-
if (swappedOffersBank && swappedDisplay.kind === "list") {
|
|
8778
|
-
return { ...swappedDisplay, methods: swappedDisplay.methods.map(asNoah) };
|
|
8779
|
-
}
|
|
8780
|
-
const bankTransfer = asNoah(
|
|
8781
|
-
FIAT_ONRAMP_METHODS.find(({ method }) => method === "bank-transfer")
|
|
8782
|
-
);
|
|
8783
|
-
return {
|
|
8784
|
-
kind: "list",
|
|
8785
|
-
methods: swappedDisplay.kind === "list" ? [...swappedDisplay.methods, bankTransfer] : [bankTransfer],
|
|
8786
|
-
recommendedMethod: swappedDisplay.kind === "list" ? swappedDisplay.recommendedMethod : bankTransfer.method,
|
|
8787
|
-
country: swappedDisplay.kind === "list" ? swappedDisplay.country : null,
|
|
8788
|
-
source: swappedDisplay.kind === "list" ? swappedDisplay.source : "configured"
|
|
8789
|
-
};
|
|
8790
|
-
}, [
|
|
8791
|
-
bankRowOffered,
|
|
8792
|
-
fiatEnabled,
|
|
8793
|
-
providersLoading,
|
|
8794
|
-
swappedCashDisplay,
|
|
8795
|
-
swappedOffersBank
|
|
8796
|
-
]);
|
|
8826
|
+
const rampRows = useMemo8(() => resolveRampRows(rampRowInputs), [rampRowInputs]);
|
|
8827
|
+
const cashDisplay = rampRows.cash;
|
|
8828
|
+
const handleNoahNotServed = useCallback6(
|
|
8829
|
+
(smartAccount) => {
|
|
8830
|
+
setNoahNotServedFor(smartAccount.toLowerCase());
|
|
8831
|
+
const after = resolveRampRows({ ...rampRowInputs, noahNotServed: true });
|
|
8832
|
+
if (after.notice) handleProviderBack();
|
|
8833
|
+
},
|
|
8834
|
+
[handleProviderBack, rampRowInputs]
|
|
8835
|
+
);
|
|
8797
8836
|
useEffect13(() => {
|
|
8798
8837
|
if (cashDisplay.kind === "hidden" && fiatEnabled) {
|
|
8799
8838
|
analytics.friction(
|
|
@@ -9354,12 +9393,12 @@ function DepositFlow({
|
|
|
9354
9393
|
),
|
|
9355
9394
|
fiatPaymentMethods: cashDisplay.kind === "list" ? cashDisplay.methods : void 0,
|
|
9356
9395
|
fiatLoading: cashDisplay.kind === "loading",
|
|
9357
|
-
fiatNotice:
|
|
9396
|
+
fiatNotice: rampRows.notice ?? void 0,
|
|
9358
9397
|
recommendedMethod: cashDisplay.kind === "list" ? cashDisplay.recommendedMethod : void 0,
|
|
9359
9398
|
onSelectFiatMethod: cashDisplay.kind === "list" ? handleSelectDisplayedFiatMethod : void 0,
|
|
9360
9399
|
onPrefetchFiatMethod: cashDisplay.kind === "list" ? handlePrefetchDisplayedFiatMethod : void 0,
|
|
9361
|
-
onSelectFundFromExchange:
|
|
9362
|
-
fundFromExchangeLoading:
|
|
9400
|
+
onSelectFundFromExchange: rampRows.exchange === "hidden" ? void 0 : () => handleSelectExchange(),
|
|
9401
|
+
fundFromExchangeLoading: rampRows.exchange === "loading",
|
|
9363
9402
|
onRequestConnect: enableWallet ? onRequestConnect : void 0,
|
|
9364
9403
|
onConnect: enableWallet ? onConnect : void 0,
|
|
9365
9404
|
onDisconnect,
|
|
@@ -9510,12 +9549,12 @@ function DepositFlow({
|
|
|
9510
9549
|
{
|
|
9511
9550
|
...rampCallbacks,
|
|
9512
9551
|
smartAccount: step.smartAccount,
|
|
9513
|
-
order: step.provider === "noah" &&
|
|
9552
|
+
order: step.provider === "noah" && !noahNotServed && getCustomerSession ? {
|
|
9514
9553
|
flow: "funding_account",
|
|
9515
9554
|
backendUrl,
|
|
9516
|
-
|
|
9555
|
+
getCustomerSession,
|
|
9517
9556
|
onJourney: onBankJourney,
|
|
9518
|
-
onUnavailable:
|
|
9557
|
+
onUnavailable: () => handleNoahNotServed(step.smartAccount)
|
|
9519
9558
|
} : {
|
|
9520
9559
|
flow: "hosted",
|
|
9521
9560
|
kind: "fiat",
|
|
@@ -9964,9 +10003,9 @@ function DepositFlow({
|
|
|
9964
10003
|
] });
|
|
9965
10004
|
}
|
|
9966
10005
|
|
|
9967
|
-
// src/components/history/
|
|
9968
|
-
import { useCallback as useCallback7, useEffect as useEffect14, useRef as useRef10, useState as useState14 } from "react";
|
|
9969
|
-
function
|
|
10006
|
+
// src/components/history/useOrderHistory.ts
|
|
10007
|
+
import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo9, useRef as useRef10, useState as useState14 } from "react";
|
|
10008
|
+
function useOrderHistory(source, open, panelOpen) {
|
|
9970
10009
|
const [orders, setOrders] = useState14([]);
|
|
9971
10010
|
const [unread, setUnread] = useState14(false);
|
|
9972
10011
|
const [loading, setLoading] = useState14(false);
|
|
@@ -9992,9 +10031,11 @@ function useBankHistory(source, open, panelOpen) {
|
|
|
9992
10031
|
...next ? { cursor: next } : {}
|
|
9993
10032
|
});
|
|
9994
10033
|
if (current !== generation.current) return;
|
|
9995
|
-
const
|
|
10034
|
+
const listed = page.items.filter(
|
|
10035
|
+
(order) => order.provider === "noah" || hostedOrderState(order).progress !== "awaiting_payment"
|
|
10036
|
+
);
|
|
9996
10037
|
let changed = false;
|
|
9997
|
-
for (const order of
|
|
10038
|
+
for (const order of listed) {
|
|
9998
10039
|
const fingerprint = JSON.stringify(order.stages);
|
|
9999
10040
|
if (!next && seen.current.get(order.id) !== fingerprint)
|
|
10000
10041
|
changed = true;
|
|
@@ -10004,7 +10045,7 @@ function useBankHistory(source, open, panelOpen) {
|
|
|
10004
10045
|
if (!next) baselined.current = true;
|
|
10005
10046
|
setOrders((previous) => {
|
|
10006
10047
|
const merged = new Map(previous.map((order) => [order.id, order]));
|
|
10007
|
-
for (const order of
|
|
10048
|
+
for (const order of listed) merged.set(order.id, order);
|
|
10008
10049
|
return [...merged.values()].sort(
|
|
10009
10050
|
(a, b) => b.createdAt.localeCompare(a.createdAt)
|
|
10010
10051
|
);
|
|
@@ -10014,7 +10055,7 @@ function useBankHistory(source, open, panelOpen) {
|
|
|
10014
10055
|
setError(null);
|
|
10015
10056
|
} catch {
|
|
10016
10057
|
if (current === generation.current)
|
|
10017
|
-
setError("
|
|
10058
|
+
setError("Order history is unavailable. Try again shortly.");
|
|
10018
10059
|
} finally {
|
|
10019
10060
|
if (current === generation.current) {
|
|
10020
10061
|
busy.current = false;
|
|
@@ -10067,12 +10108,53 @@ function useBankHistory(source, open, panelOpen) {
|
|
|
10067
10108
|
}
|
|
10068
10109
|
};
|
|
10069
10110
|
}
|
|
10111
|
+
function useSessionOrders(backendUrl, getCustomerSession, smartAccount) {
|
|
10112
|
+
const getSession = useLatestRef(getCustomerSession);
|
|
10113
|
+
const enabled = Boolean(getCustomerSession);
|
|
10114
|
+
return useMemo9(() => {
|
|
10115
|
+
if (!enabled || !smartAccount) return null;
|
|
10116
|
+
return {
|
|
10117
|
+
listOrders: async ({ cursor, limit }) => {
|
|
10118
|
+
let refused = false;
|
|
10119
|
+
const request = createBearerTransport({
|
|
10120
|
+
backendUrl,
|
|
10121
|
+
getSession: async () => {
|
|
10122
|
+
try {
|
|
10123
|
+
return await getSession.current(smartAccount, {
|
|
10124
|
+
resumeOnly: true
|
|
10125
|
+
});
|
|
10126
|
+
} catch (error) {
|
|
10127
|
+
refused = true;
|
|
10128
|
+
throw error;
|
|
10129
|
+
}
|
|
10130
|
+
}
|
|
10131
|
+
});
|
|
10132
|
+
try {
|
|
10133
|
+
return await request(
|
|
10134
|
+
`/onramp/orders?${rampQuery({ cursor, limit })}`
|
|
10135
|
+
);
|
|
10136
|
+
} catch (error) {
|
|
10137
|
+
if (refused) return { items: [], nextCursor: null };
|
|
10138
|
+
throw error;
|
|
10139
|
+
}
|
|
10140
|
+
}
|
|
10141
|
+
};
|
|
10142
|
+
}, [backendUrl, enabled, smartAccount, getSession]);
|
|
10143
|
+
}
|
|
10070
10144
|
|
|
10071
10145
|
// src/DepositModal.tsx
|
|
10072
10146
|
import { jsx as jsx28, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
10147
|
+
var warnedNoCustomerSession = false;
|
|
10148
|
+
function warnNoCustomerSession() {
|
|
10149
|
+
if (warnedNoCustomerSession) return;
|
|
10150
|
+
warnedNoCustomerSession = true;
|
|
10151
|
+
console.warn(
|
|
10152
|
+
"[rhinestone] `virtualAccountOnramp` needs `getCustomerSession`; it is ignored without one."
|
|
10153
|
+
);
|
|
10154
|
+
}
|
|
10073
10155
|
var ReownDepositInner = lazy4(async () => {
|
|
10074
10156
|
await loadReownDependencies();
|
|
10075
|
-
const module = await import("./DepositModalReown-
|
|
10157
|
+
const module = await import("./DepositModalReown-FJBSF4VL.mjs");
|
|
10076
10158
|
return { default: module.DepositModalReown };
|
|
10077
10159
|
});
|
|
10078
10160
|
function buildDepositAnalyticsSessionProperties({
|
|
@@ -10131,6 +10213,7 @@ function hasSuppliedWalletClient(props) {
|
|
|
10131
10213
|
}
|
|
10132
10214
|
function DepositModal(props) {
|
|
10133
10215
|
warnRemovedProps("DepositModal", props);
|
|
10216
|
+
if (props.virtualAccountOnramp && !props.getCustomerSession) warnNoCustomerSession();
|
|
10134
10217
|
checkBackendUrl("DepositModal", props.backendUrl);
|
|
10135
10218
|
const needsReown = !!props.reownAppId;
|
|
10136
10219
|
const hasWalletClientProp = hasSuppliedWalletClient(props);
|
|
@@ -10174,7 +10257,8 @@ function DepositModalInner({
|
|
|
10174
10257
|
assetMigrations,
|
|
10175
10258
|
initialAssetMigration,
|
|
10176
10259
|
enableFiatOnramp = false,
|
|
10177
|
-
|
|
10260
|
+
virtualAccountOnramp,
|
|
10261
|
+
getCustomerSession,
|
|
10178
10262
|
enableQrTransfer = true,
|
|
10179
10263
|
enableGaslessDeposit = false,
|
|
10180
10264
|
fiatMethods,
|
|
@@ -10208,22 +10292,10 @@ function DepositModalInner({
|
|
|
10208
10292
|
const onReadyRef = useLatestRef(onReady);
|
|
10209
10293
|
const onUiStateRef = useLatestRef(onUiState);
|
|
10210
10294
|
const [currentScreen, setCurrentScreen] = useState15("connect");
|
|
10211
|
-
const bankScope = `${backendUrl}:${recipient}:${typeof targetChainProp === "string" ? targetChainProp : getChainId(targetChainProp)}:${targetToken}`;
|
|
10212
|
-
const [bankSession, setBankSession] = useState15(null);
|
|
10213
10295
|
const [bankJourneyVisible, setBankJourneyVisible] = useState15(false);
|
|
10214
|
-
const
|
|
10215
|
-
setBankJourneyVisible(Boolean(journey));
|
|
10216
|
-
if (journey)
|
|
10217
|
-
setBankSession(
|
|
10218
|
-
journey.source ? { source: journey.source, scope: bankScope } : null
|
|
10219
|
-
);
|
|
10220
|
-
}, [bankScope]);
|
|
10221
|
-
const bankSource = bankSession?.scope === bankScope ? bankSession.source : null;
|
|
10296
|
+
const [smartAccount, setSmartAccount] = useState15(null);
|
|
10222
10297
|
useEffect15(() => {
|
|
10223
|
-
if (!isOpen)
|
|
10224
|
-
setBankSession(null);
|
|
10225
|
-
setBankJourneyVisible(false);
|
|
10226
|
-
}
|
|
10298
|
+
if (!isOpen) setBankJourneyVisible(false);
|
|
10227
10299
|
}, [isOpen]);
|
|
10228
10300
|
const [swappedImmersive, setSwappedImmersive] = useState15(false);
|
|
10229
10301
|
const [submitting, setSubmitting] = useState15(false);
|
|
@@ -10238,15 +10310,21 @@ function DepositModalInner({
|
|
|
10238
10310
|
}));
|
|
10239
10311
|
const targetChain = typeof targetChainProp === "string" ? targetChainProp : getChainId(targetChainProp);
|
|
10240
10312
|
const sourceChain = sourceChainProp ? getChainId(sourceChainProp) : void 0;
|
|
10313
|
+
const accountScope = `${isOpen}|${backendUrl}|${recipient}|${targetChain}|${targetToken}`;
|
|
10314
|
+
const [scope, setScope] = useState15(accountScope);
|
|
10315
|
+
if (scope !== accountScope) {
|
|
10316
|
+
setScope(accountScope);
|
|
10317
|
+
setSmartAccount(null);
|
|
10318
|
+
}
|
|
10241
10319
|
const rpcUrls = useStableRpcUrls(rpcUrlsProp);
|
|
10242
|
-
const service =
|
|
10320
|
+
const service = useMemo10(
|
|
10243
10321
|
() => createDepositService(backendUrl, {
|
|
10244
10322
|
debug,
|
|
10245
10323
|
debugScope: "service:deposit"
|
|
10246
10324
|
}),
|
|
10247
10325
|
[backendUrl, debug]
|
|
10248
10326
|
);
|
|
10249
|
-
const historyAnalytics =
|
|
10327
|
+
const historyAnalytics = useMemo10(
|
|
10250
10328
|
() => createHistoryAnalytics({
|
|
10251
10329
|
modal: "deposit",
|
|
10252
10330
|
controllerRef: analyticsControllerRef,
|
|
@@ -10261,18 +10339,21 @@ function DepositModalInner({
|
|
|
10261
10339
|
canRecover: Boolean(signRecovery),
|
|
10262
10340
|
analytics: historyAnalytics
|
|
10263
10341
|
});
|
|
10264
|
-
const
|
|
10265
|
-
|
|
10342
|
+
const orderHistory = useOrderHistory(
|
|
10343
|
+
useSessionOrders(backendUrl, getCustomerSession, smartAccount),
|
|
10344
|
+
isOpen && !payment,
|
|
10345
|
+
history.isPanelOpen
|
|
10346
|
+
);
|
|
10266
10347
|
const historyDepositsRef = useLatestRef(history.deposits);
|
|
10267
10348
|
useEffect15(() => {
|
|
10268
|
-
const waitingForSettlement =
|
|
10349
|
+
const waitingForSettlement = orderHistory.orders.some((order) => {
|
|
10269
10350
|
if (order.stages.delivery.status !== "completed") return false;
|
|
10270
10351
|
const { depositId } = order.stages.delivery;
|
|
10271
10352
|
const deposit = historyDepositsRef.current.find((item) => item.id === depositId);
|
|
10272
10353
|
return !deposit || deposit.status === "pending" || deposit.status === "processing";
|
|
10273
10354
|
});
|
|
10274
10355
|
if (waitingForSettlement) history.markStale();
|
|
10275
|
-
}, [
|
|
10356
|
+
}, [orderHistory.orders, history.markStale, historyDepositsRef]);
|
|
10276
10357
|
const {
|
|
10277
10358
|
markStale: markHistoryStale,
|
|
10278
10359
|
invalidate: invalidateHistory,
|
|
@@ -10296,7 +10377,7 @@ function DepositModalInner({
|
|
|
10296
10377
|
console.debug("[deposit] client setup config (not shown yet)", clientSetup);
|
|
10297
10378
|
}
|
|
10298
10379
|
}, [debug, clientSetup]);
|
|
10299
|
-
const store =
|
|
10380
|
+
const store = useMemo10(
|
|
10300
10381
|
() => createDepositStore({ targetChain, targetToken }),
|
|
10301
10382
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
10302
10383
|
[]
|
|
@@ -10339,8 +10420,9 @@ function DepositModalInner({
|
|
|
10339
10420
|
const handleLifecycle = useCallback8(
|
|
10340
10421
|
(event) => {
|
|
10341
10422
|
onLifecycleRef.current?.(event);
|
|
10342
|
-
if (event.type === "smart-account-changed"
|
|
10343
|
-
|
|
10423
|
+
if (event.type === "smart-account-changed") {
|
|
10424
|
+
setSmartAccount(event.evm);
|
|
10425
|
+
if (!event.evm && !event.solana) invalidateHistory();
|
|
10344
10426
|
}
|
|
10345
10427
|
if (event.type === "submitted" || event.type === "complete" || event.type === "failed") {
|
|
10346
10428
|
markHistoryStale();
|
|
@@ -10404,7 +10486,7 @@ function DepositModalInner({
|
|
|
10404
10486
|
sourceToken,
|
|
10405
10487
|
defaultAmount,
|
|
10406
10488
|
bankOnrampEnabled: Boolean(
|
|
10407
|
-
|
|
10489
|
+
virtualAccountOnramp && getCustomerSession && (fiatMethods === void 0 || fiatMethods["bank-transfer"] === true)
|
|
10408
10490
|
),
|
|
10409
10491
|
walletIntegration,
|
|
10410
10492
|
targetChain,
|
|
@@ -10454,7 +10536,7 @@ function DepositModalInner({
|
|
|
10454
10536
|
HistoryEntryButton,
|
|
10455
10537
|
{
|
|
10456
10538
|
badge: bankJourneyVisible ? null : history.badge,
|
|
10457
|
-
unread:
|
|
10539
|
+
unread: orderHistory.unread,
|
|
10458
10540
|
onClick: history.openPanel,
|
|
10459
10541
|
disabled: !recipient
|
|
10460
10542
|
}
|
|
@@ -10492,8 +10574,9 @@ function DepositModalInner({
|
|
|
10492
10574
|
assetMigrations,
|
|
10493
10575
|
initialAssetMigration,
|
|
10494
10576
|
enableFiatOnramp,
|
|
10495
|
-
|
|
10496
|
-
|
|
10577
|
+
virtualAccountOnramp,
|
|
10578
|
+
getCustomerSession,
|
|
10579
|
+
onBankJourney: setBankJourneyVisible,
|
|
10497
10580
|
backendUrl,
|
|
10498
10581
|
enableQrTransfer,
|
|
10499
10582
|
enableGaslessDeposit,
|
|
@@ -10523,8 +10606,8 @@ function DepositModalInner({
|
|
|
10523
10606
|
HistoryOverlay,
|
|
10524
10607
|
{
|
|
10525
10608
|
controller: history,
|
|
10526
|
-
|
|
10527
|
-
bankSupportUrl:
|
|
10609
|
+
orderHistory,
|
|
10610
|
+
bankSupportUrl: virtualAccountOnramp?.supportUrl,
|
|
10528
10611
|
backLabel: "Deposit",
|
|
10529
10612
|
recipient,
|
|
10530
10613
|
backendUrl,
|