@nairaramp/react 0.0.0-stage → 0.2.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/LICENSE +201 -0
- package/README.md +349 -3
- package/dist/index.cjs +1370 -0
- package/dist/index.d.cts +173 -0
- package/dist/index.d.ts +173 -0
- package/dist/index.js +1354 -0
- package/package.json +56 -6
package/dist/index.js
ADDED
|
@@ -0,0 +1,1354 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/NairaRampContext.tsx
|
|
4
|
+
import {
|
|
5
|
+
createContext,
|
|
6
|
+
useContext
|
|
7
|
+
} from "react";
|
|
8
|
+
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
var NairaRampContext = createContext(void 0);
|
|
10
|
+
function NairaRampProvider({
|
|
11
|
+
ramp,
|
|
12
|
+
children
|
|
13
|
+
}) {
|
|
14
|
+
return /* @__PURE__ */ jsx(NairaRampContext.Provider, { value: ramp, children });
|
|
15
|
+
}
|
|
16
|
+
function useNairaRamp(overrideRamp) {
|
|
17
|
+
const contextRamp = useContext(NairaRampContext);
|
|
18
|
+
const resolved = overrideRamp ?? contextRamp;
|
|
19
|
+
if (!resolved) {
|
|
20
|
+
throw new Error(
|
|
21
|
+
"No Ramp instance found. Pass a `ramp` prop/option or wrap your component tree in <NairaRampProvider>."
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
return resolved;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// src/usePayWithNaira.ts
|
|
28
|
+
import { useState, useCallback, useRef, useEffect } from "react";
|
|
29
|
+
import {
|
|
30
|
+
TERMINAL_STATUSES,
|
|
31
|
+
NairaRampError as NairaRampError2
|
|
32
|
+
} from "@nairaramp/core";
|
|
33
|
+
|
|
34
|
+
// src/utils.ts
|
|
35
|
+
import { NairaRampError, isNairaRampError } from "@nairaramp/core";
|
|
36
|
+
function ensureNairaRampError(err) {
|
|
37
|
+
if (isNairaRampError(err)) {
|
|
38
|
+
return err;
|
|
39
|
+
}
|
|
40
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
41
|
+
return new NairaRampError("TRANSACTION_FAILED", message, { cause: err });
|
|
42
|
+
}
|
|
43
|
+
function isSafeHttpUrl(rawUrl) {
|
|
44
|
+
try {
|
|
45
|
+
const parsed = new URL(rawUrl);
|
|
46
|
+
return parsed.protocol === "https:" || parsed.protocol === "http:";
|
|
47
|
+
} catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function getStellarExplorerUrl(txHash, network = "testnet") {
|
|
52
|
+
if (!txHash || !/^[0-9a-fA-F]{64}$/.test(txHash)) {
|
|
53
|
+
return void 0;
|
|
54
|
+
}
|
|
55
|
+
const segment = network === "mainnet" ? "public" : "testnet";
|
|
56
|
+
return `https://stellar.expert/explorer/${segment}/tx/${txHash}`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// src/usePayWithNaira.ts
|
|
60
|
+
function usePayWithNaira({
|
|
61
|
+
ramp: rampOption,
|
|
62
|
+
assetCode
|
|
63
|
+
}) {
|
|
64
|
+
const ramp = useNairaRamp(rampOption);
|
|
65
|
+
const [phase, setPhase] = useState("idle");
|
|
66
|
+
const [status, setStatus] = useState(void 0);
|
|
67
|
+
const [transactionId, setTransactionId] = useState(void 0);
|
|
68
|
+
const [transaction, setTransaction] = useState(void 0);
|
|
69
|
+
const [stellarTransactionId, setStellarTransactionId] = useState(void 0);
|
|
70
|
+
const [url, setUrl] = useState(void 0);
|
|
71
|
+
const [error, setError] = useState(void 0);
|
|
72
|
+
const phaseRef = useRef("idle");
|
|
73
|
+
const subscriptionRef = useRef(void 0);
|
|
74
|
+
const isMountedRef = useRef(true);
|
|
75
|
+
const attemptIdRef = useRef(0);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
phaseRef.current = phase;
|
|
78
|
+
}, [phase]);
|
|
79
|
+
const stopWatcher = useCallback(() => {
|
|
80
|
+
if (subscriptionRef.current) {
|
|
81
|
+
subscriptionRef.current.stop();
|
|
82
|
+
subscriptionRef.current = void 0;
|
|
83
|
+
}
|
|
84
|
+
}, []);
|
|
85
|
+
const reset = useCallback(() => {
|
|
86
|
+
attemptIdRef.current += 1;
|
|
87
|
+
stopWatcher();
|
|
88
|
+
phaseRef.current = "idle";
|
|
89
|
+
if (isMountedRef.current) {
|
|
90
|
+
setPhase("idle");
|
|
91
|
+
setStatus(void 0);
|
|
92
|
+
setTransactionId(void 0);
|
|
93
|
+
setTransaction(void 0);
|
|
94
|
+
setStellarTransactionId(void 0);
|
|
95
|
+
setUrl(void 0);
|
|
96
|
+
setError(void 0);
|
|
97
|
+
}
|
|
98
|
+
}, [stopWatcher]);
|
|
99
|
+
const start = useCallback(
|
|
100
|
+
async (amount) => {
|
|
101
|
+
if (phaseRef.current !== "idle") {
|
|
102
|
+
return void 0;
|
|
103
|
+
}
|
|
104
|
+
const attemptId = ++attemptIdRef.current;
|
|
105
|
+
phaseRef.current = "starting";
|
|
106
|
+
if (isMountedRef.current) {
|
|
107
|
+
setPhase("starting");
|
|
108
|
+
setTransaction(void 0);
|
|
109
|
+
setStellarTransactionId(void 0);
|
|
110
|
+
setError(void 0);
|
|
111
|
+
}
|
|
112
|
+
let depositResult;
|
|
113
|
+
try {
|
|
114
|
+
depositResult = await ramp.deposit({
|
|
115
|
+
assetCode,
|
|
116
|
+
...amount !== void 0 ? { amount } : {}
|
|
117
|
+
});
|
|
118
|
+
} catch (err) {
|
|
119
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) {
|
|
120
|
+
return void 0;
|
|
121
|
+
}
|
|
122
|
+
const wrapped = ensureNairaRampError(err);
|
|
123
|
+
phaseRef.current = "failed";
|
|
124
|
+
setError(wrapped);
|
|
125
|
+
setPhase("failed");
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) {
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
131
|
+
const { id, url: hostedUrl } = depositResult;
|
|
132
|
+
setTransactionId(id);
|
|
133
|
+
setUrl(hostedUrl);
|
|
134
|
+
phaseRef.current = "awaiting_user";
|
|
135
|
+
setPhase("awaiting_user");
|
|
136
|
+
stopWatcher();
|
|
137
|
+
const subscription = ramp.watch(id, {
|
|
138
|
+
onStatus: (nextStatus, tx) => {
|
|
139
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
140
|
+
setStatus(nextStatus);
|
|
141
|
+
if (tx) {
|
|
142
|
+
setTransaction(tx);
|
|
143
|
+
if (tx.stellar_transaction_id) {
|
|
144
|
+
setStellarTransactionId(tx.stellar_transaction_id);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (nextStatus === "completed") {
|
|
148
|
+
stopWatcher();
|
|
149
|
+
phaseRef.current = "completed";
|
|
150
|
+
setPhase("completed");
|
|
151
|
+
} else if (TERMINAL_STATUSES.includes(nextStatus)) {
|
|
152
|
+
stopWatcher();
|
|
153
|
+
const detail = tx?.message ? `Transaction ${nextStatus}: ${tx.message}` : `Transaction ${nextStatus}`;
|
|
154
|
+
setError(new NairaRampError2("TRANSACTION_FAILED", detail));
|
|
155
|
+
phaseRef.current = "failed";
|
|
156
|
+
setPhase("failed");
|
|
157
|
+
} else if (nextStatus === "pending_user_transfer_start" || nextStatus === "incomplete") {
|
|
158
|
+
phaseRef.current = "awaiting_user";
|
|
159
|
+
setPhase("awaiting_user");
|
|
160
|
+
} else {
|
|
161
|
+
phaseRef.current = "processing";
|
|
162
|
+
setPhase("processing");
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
onComplete: (tx) => {
|
|
166
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
167
|
+
stopWatcher();
|
|
168
|
+
if (tx) {
|
|
169
|
+
setTransaction(tx);
|
|
170
|
+
if (tx.stellar_transaction_id) {
|
|
171
|
+
setStellarTransactionId(tx.stellar_transaction_id);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
setStatus("completed");
|
|
175
|
+
phaseRef.current = "completed";
|
|
176
|
+
setPhase("completed");
|
|
177
|
+
},
|
|
178
|
+
onError: (err) => {
|
|
179
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
180
|
+
stopWatcher();
|
|
181
|
+
const wrapped = ensureNairaRampError(err);
|
|
182
|
+
setError(wrapped);
|
|
183
|
+
phaseRef.current = "failed";
|
|
184
|
+
setPhase("failed");
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
subscriptionRef.current = subscription;
|
|
188
|
+
return depositResult;
|
|
189
|
+
},
|
|
190
|
+
[ramp, assetCode, stopWatcher]
|
|
191
|
+
);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
isMountedRef.current = true;
|
|
194
|
+
return () => {
|
|
195
|
+
isMountedRef.current = false;
|
|
196
|
+
attemptIdRef.current += 1;
|
|
197
|
+
stopWatcher();
|
|
198
|
+
};
|
|
199
|
+
}, [stopWatcher]);
|
|
200
|
+
return {
|
|
201
|
+
start,
|
|
202
|
+
phase,
|
|
203
|
+
status,
|
|
204
|
+
transactionId,
|
|
205
|
+
transaction,
|
|
206
|
+
stellarTransactionId,
|
|
207
|
+
url,
|
|
208
|
+
error,
|
|
209
|
+
reset
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
// src/PayWithNaira.tsx
|
|
214
|
+
import {
|
|
215
|
+
useState as useState4,
|
|
216
|
+
useRef as useRef3,
|
|
217
|
+
useEffect as useEffect4,
|
|
218
|
+
useCallback as useCallback3
|
|
219
|
+
} from "react";
|
|
220
|
+
import {
|
|
221
|
+
NairaRampError as NairaRampErrorClass
|
|
222
|
+
} from "@nairaramp/core";
|
|
223
|
+
|
|
224
|
+
// src/theme.ts
|
|
225
|
+
import { useState as useState2, useEffect as useEffect2 } from "react";
|
|
226
|
+
var LIGHT_THEME = {
|
|
227
|
+
text: "#111827",
|
|
228
|
+
secondaryText: "#1f2937",
|
|
229
|
+
mutedText: "#4b5563",
|
|
230
|
+
pendingText: "#6b7280",
|
|
231
|
+
doneText: "#059669",
|
|
232
|
+
primaryBtnBg: "#059669",
|
|
233
|
+
primaryBtnText: "#ffffff",
|
|
234
|
+
disabledBtnBg: "#6b7280",
|
|
235
|
+
disabledBtnText: "#ffffff",
|
|
236
|
+
retryBtnBg: "#f3f4f6",
|
|
237
|
+
retryBtnText: "#1f2937",
|
|
238
|
+
retryBtnBorder: "#d1d5db",
|
|
239
|
+
errorText: "#b91c1c",
|
|
240
|
+
linkText: "#2563eb",
|
|
241
|
+
failureBg: "#fef2f2",
|
|
242
|
+
failureBorder: "#fee2e2",
|
|
243
|
+
failureTitle: "#991b1b",
|
|
244
|
+
activeBadgeBg: "#2563eb",
|
|
245
|
+
doneBadgeBg: "#059669",
|
|
246
|
+
activeOrDoneBadgeText: "#ffffff",
|
|
247
|
+
pendingBadgeBg: "#e5e7eb",
|
|
248
|
+
pendingBadgeText: "#374151",
|
|
249
|
+
focusPrimary: "#047857",
|
|
250
|
+
focusAccent: "#2563eb"
|
|
251
|
+
};
|
|
252
|
+
var DARK_THEME = {
|
|
253
|
+
text: "#f9fafb",
|
|
254
|
+
secondaryText: "#e5e7eb",
|
|
255
|
+
mutedText: "#d1d5db",
|
|
256
|
+
pendingText: "#9ca3af",
|
|
257
|
+
doneText: "#34d399",
|
|
258
|
+
primaryBtnBg: "#059669",
|
|
259
|
+
primaryBtnText: "#ffffff",
|
|
260
|
+
disabledBtnBg: "#4b5563",
|
|
261
|
+
disabledBtnText: "#ffffff",
|
|
262
|
+
retryBtnBg: "#1f2937",
|
|
263
|
+
retryBtnText: "#f9fafb",
|
|
264
|
+
retryBtnBorder: "#374151",
|
|
265
|
+
errorText: "#fca5a5",
|
|
266
|
+
linkText: "#60a5fa",
|
|
267
|
+
failureBg: "#450a0a",
|
|
268
|
+
failureBorder: "#7f1d1d",
|
|
269
|
+
failureTitle: "#fecaca",
|
|
270
|
+
activeBadgeBg: "#3b82f6",
|
|
271
|
+
doneBadgeBg: "#059669",
|
|
272
|
+
activeOrDoneBadgeText: "#ffffff",
|
|
273
|
+
pendingBadgeBg: "#374151",
|
|
274
|
+
pendingBadgeText: "#e5e7eb",
|
|
275
|
+
focusPrimary: "#34d399",
|
|
276
|
+
focusAccent: "#60a5fa"
|
|
277
|
+
};
|
|
278
|
+
function getSystemDarkPreference() {
|
|
279
|
+
if (typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
283
|
+
}
|
|
284
|
+
function useResolvedTheme(theme = "system") {
|
|
285
|
+
const [systemDark, setSystemDark] = useState2(
|
|
286
|
+
() => theme === "system" ? getSystemDarkPreference() : false
|
|
287
|
+
);
|
|
288
|
+
useEffect2(() => {
|
|
289
|
+
if (theme !== "system" || typeof window === "undefined" || typeof window.matchMedia !== "function") {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
293
|
+
setSystemDark(mediaQuery.matches);
|
|
294
|
+
const handleChange = (event) => {
|
|
295
|
+
setSystemDark(event.matches);
|
|
296
|
+
};
|
|
297
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
298
|
+
return () => {
|
|
299
|
+
mediaQuery.removeEventListener("change", handleChange);
|
|
300
|
+
};
|
|
301
|
+
}, [theme]);
|
|
302
|
+
if (theme === "dark") return DARK_THEME;
|
|
303
|
+
if (theme === "light") return LIGHT_THEME;
|
|
304
|
+
return systemDark ? DARK_THEME : LIGHT_THEME;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// src/useAnchorPopup.ts
|
|
308
|
+
import { useState as useState3, useRef as useRef2, useCallback as useCallback2, useEffect as useEffect3 } from "react";
|
|
309
|
+
var rampContainerStyle = {
|
|
310
|
+
width: "100%",
|
|
311
|
+
maxWidth: "420px",
|
|
312
|
+
boxSizing: "border-box",
|
|
313
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
314
|
+
fontSize: "16px",
|
|
315
|
+
lineHeight: 1.5,
|
|
316
|
+
color: "#111827",
|
|
317
|
+
textAlign: "center"
|
|
318
|
+
};
|
|
319
|
+
var baseButtonStyle = {
|
|
320
|
+
width: "100%",
|
|
321
|
+
boxSizing: "border-box",
|
|
322
|
+
padding: "12px 16px",
|
|
323
|
+
fontSize: "16px",
|
|
324
|
+
fontWeight: 600,
|
|
325
|
+
borderRadius: "8px",
|
|
326
|
+
border: "1px solid transparent",
|
|
327
|
+
cursor: "pointer",
|
|
328
|
+
textAlign: "center",
|
|
329
|
+
display: "inline-block",
|
|
330
|
+
transition: "outline 0.15s ease"
|
|
331
|
+
};
|
|
332
|
+
var rampPrimaryButtonStyle = {
|
|
333
|
+
...baseButtonStyle,
|
|
334
|
+
color: "#ffffff",
|
|
335
|
+
backgroundColor: "#059669"
|
|
336
|
+
};
|
|
337
|
+
var rampDisabledButtonStyle = {
|
|
338
|
+
...baseButtonStyle,
|
|
339
|
+
color: "#ffffff",
|
|
340
|
+
backgroundColor: "#9ca3af",
|
|
341
|
+
cursor: "not-allowed",
|
|
342
|
+
opacity: 0.8
|
|
343
|
+
};
|
|
344
|
+
var rampRetryButtonStyle = {
|
|
345
|
+
...baseButtonStyle,
|
|
346
|
+
marginTop: "12px",
|
|
347
|
+
padding: "10px 16px",
|
|
348
|
+
fontSize: "15px",
|
|
349
|
+
color: "#1f2937",
|
|
350
|
+
backgroundColor: "#f3f4f6",
|
|
351
|
+
border: "1px solid #d1d5db"
|
|
352
|
+
};
|
|
353
|
+
var rampStatusTextStyle = {
|
|
354
|
+
margin: "8px 0",
|
|
355
|
+
fontSize: "16px",
|
|
356
|
+
fontWeight: 500,
|
|
357
|
+
color: "#1f2937"
|
|
358
|
+
};
|
|
359
|
+
var rampErrorTextStyle = {
|
|
360
|
+
margin: "8px 0",
|
|
361
|
+
fontSize: "15px",
|
|
362
|
+
fontWeight: 500,
|
|
363
|
+
color: "#b91c1c",
|
|
364
|
+
wordBreak: "break-word"
|
|
365
|
+
};
|
|
366
|
+
var rampLinkStyle = {
|
|
367
|
+
display: "inline-block",
|
|
368
|
+
fontSize: "15px",
|
|
369
|
+
fontWeight: 600,
|
|
370
|
+
color: "#2563eb",
|
|
371
|
+
textDecoration: "underline",
|
|
372
|
+
wordBreak: "break-all",
|
|
373
|
+
cursor: "pointer"
|
|
374
|
+
};
|
|
375
|
+
function useAnchorPopup() {
|
|
376
|
+
const [popupBlocked, setPopupBlocked] = useState3(false);
|
|
377
|
+
const popupRef = useRef2(null);
|
|
378
|
+
const closePopup = useCallback2(() => {
|
|
379
|
+
if (popupRef.current && !popupRef.current.closed) {
|
|
380
|
+
try {
|
|
381
|
+
popupRef.current.close();
|
|
382
|
+
} catch {
|
|
383
|
+
}
|
|
384
|
+
popupRef.current = null;
|
|
385
|
+
}
|
|
386
|
+
}, []);
|
|
387
|
+
const openPopup = useCallback2(() => {
|
|
388
|
+
setPopupBlocked(false);
|
|
389
|
+
let popup = null;
|
|
390
|
+
if (typeof window !== "undefined" && typeof window.open === "function") {
|
|
391
|
+
try {
|
|
392
|
+
popup = window.open("", "nairaramp_anchor");
|
|
393
|
+
} catch {
|
|
394
|
+
popup = null;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
popupRef.current = popup;
|
|
398
|
+
if (!popup) {
|
|
399
|
+
setPopupBlocked(true);
|
|
400
|
+
}
|
|
401
|
+
return popup;
|
|
402
|
+
}, []);
|
|
403
|
+
const navigatePopup = useCallback2(
|
|
404
|
+
(popup, targetUrl) => {
|
|
405
|
+
if (targetUrl && isSafeHttpUrl(targetUrl)) {
|
|
406
|
+
if (popup && !popup.closed) {
|
|
407
|
+
popup.location.href = targetUrl;
|
|
408
|
+
}
|
|
409
|
+
} else {
|
|
410
|
+
closePopup();
|
|
411
|
+
}
|
|
412
|
+
},
|
|
413
|
+
[closePopup]
|
|
414
|
+
);
|
|
415
|
+
const clearPopupBlocked = useCallback2(() => {
|
|
416
|
+
setPopupBlocked(false);
|
|
417
|
+
}, []);
|
|
418
|
+
useEffect3(() => {
|
|
419
|
+
return () => {
|
|
420
|
+
closePopup();
|
|
421
|
+
};
|
|
422
|
+
}, [closePopup]);
|
|
423
|
+
return {
|
|
424
|
+
popupBlocked,
|
|
425
|
+
openPopup,
|
|
426
|
+
navigatePopup,
|
|
427
|
+
closePopup,
|
|
428
|
+
clearPopupBlocked
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
// src/PayWithNaira.tsx
|
|
433
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
434
|
+
function PayWithNaira({
|
|
435
|
+
ramp,
|
|
436
|
+
assetCode,
|
|
437
|
+
amount,
|
|
438
|
+
onComplete,
|
|
439
|
+
onError,
|
|
440
|
+
label = "Pay with Naira",
|
|
441
|
+
theme = "system",
|
|
442
|
+
className,
|
|
443
|
+
style
|
|
444
|
+
}) {
|
|
445
|
+
const tokens = useResolvedTheme(theme);
|
|
446
|
+
const { start, phase, error, url, reset } = usePayWithNaira({
|
|
447
|
+
ramp,
|
|
448
|
+
assetCode
|
|
449
|
+
});
|
|
450
|
+
const {
|
|
451
|
+
popupBlocked,
|
|
452
|
+
openPopup,
|
|
453
|
+
navigatePopup,
|
|
454
|
+
closePopup,
|
|
455
|
+
clearPopupBlocked
|
|
456
|
+
} = useAnchorPopup();
|
|
457
|
+
const [isPrimaryFocused, setIsPrimaryFocused] = useState4(false);
|
|
458
|
+
const [isRetryFocused, setIsRetryFocused] = useState4(false);
|
|
459
|
+
const [isLinkFocused, setIsLinkFocused] = useState4(false);
|
|
460
|
+
const onCompleteRef = useRef3(onComplete);
|
|
461
|
+
const onErrorRef = useRef3(onError);
|
|
462
|
+
const completedFiredRef = useRef3(false);
|
|
463
|
+
const errorFiredRef = useRef3(false);
|
|
464
|
+
useEffect4(() => {
|
|
465
|
+
onCompleteRef.current = onComplete;
|
|
466
|
+
}, [onComplete]);
|
|
467
|
+
useEffect4(() => {
|
|
468
|
+
onErrorRef.current = onError;
|
|
469
|
+
}, [onError]);
|
|
470
|
+
const handleClick = useCallback3(async () => {
|
|
471
|
+
const popup = openPopup();
|
|
472
|
+
const result = await start(amount);
|
|
473
|
+
navigatePopup(popup, result?.url);
|
|
474
|
+
}, [openPopup, start, amount, navigatePopup]);
|
|
475
|
+
const handleRetry = useCallback3(() => {
|
|
476
|
+
clearPopupBlocked();
|
|
477
|
+
closePopup();
|
|
478
|
+
completedFiredRef.current = false;
|
|
479
|
+
errorFiredRef.current = false;
|
|
480
|
+
reset();
|
|
481
|
+
}, [clearPopupBlocked, closePopup, reset]);
|
|
482
|
+
useEffect4(() => {
|
|
483
|
+
if (phase === "completed") {
|
|
484
|
+
if (!completedFiredRef.current) {
|
|
485
|
+
completedFiredRef.current = true;
|
|
486
|
+
onCompleteRef.current?.();
|
|
487
|
+
}
|
|
488
|
+
} else if (phase === "failed") {
|
|
489
|
+
closePopup();
|
|
490
|
+
if (!errorFiredRef.current) {
|
|
491
|
+
errorFiredRef.current = true;
|
|
492
|
+
const finalError = error ?? new NairaRampErrorClass("TRANSACTION_FAILED", "Payment failed");
|
|
493
|
+
onErrorRef.current?.(finalError);
|
|
494
|
+
}
|
|
495
|
+
} else if (phase === "idle") {
|
|
496
|
+
completedFiredRef.current = false;
|
|
497
|
+
errorFiredRef.current = false;
|
|
498
|
+
}
|
|
499
|
+
}, [phase, error, closePopup]);
|
|
500
|
+
return /* @__PURE__ */ jsxs("div", { className, style: { ...rampContainerStyle, color: tokens.text, ...style }, children: [
|
|
501
|
+
phase === "idle" && /* @__PURE__ */ jsx2(
|
|
502
|
+
"button",
|
|
503
|
+
{
|
|
504
|
+
type: "button",
|
|
505
|
+
onClick: handleClick,
|
|
506
|
+
onFocus: () => setIsPrimaryFocused(true),
|
|
507
|
+
onBlur: () => setIsPrimaryFocused(false),
|
|
508
|
+
style: {
|
|
509
|
+
...rampPrimaryButtonStyle,
|
|
510
|
+
color: tokens.primaryBtnText,
|
|
511
|
+
backgroundColor: tokens.primaryBtnBg,
|
|
512
|
+
outline: isPrimaryFocused ? `3px solid ${tokens.focusPrimary}` : "2px solid transparent",
|
|
513
|
+
outlineOffset: "2px"
|
|
514
|
+
},
|
|
515
|
+
children: label
|
|
516
|
+
}
|
|
517
|
+
),
|
|
518
|
+
/* @__PURE__ */ jsxs("div", { "aria-live": "polite", "aria-atomic": "true", children: [
|
|
519
|
+
phase === "starting" && /* @__PURE__ */ jsx2(
|
|
520
|
+
"button",
|
|
521
|
+
{
|
|
522
|
+
type: "button",
|
|
523
|
+
disabled: true,
|
|
524
|
+
style: {
|
|
525
|
+
...rampDisabledButtonStyle,
|
|
526
|
+
color: tokens.disabledBtnText,
|
|
527
|
+
backgroundColor: tokens.disabledBtnBg
|
|
528
|
+
},
|
|
529
|
+
children: "Connecting..."
|
|
530
|
+
}
|
|
531
|
+
),
|
|
532
|
+
phase === "awaiting_user" && /* @__PURE__ */ jsxs("div", { children: [
|
|
533
|
+
/* @__PURE__ */ jsx2("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Complete the steps in the anchor window" }),
|
|
534
|
+
popupBlocked && url && isSafeHttpUrl(url) && /* @__PURE__ */ jsx2("p", { style: { margin: "8px 0 0 0" }, children: /* @__PURE__ */ jsx2(
|
|
535
|
+
"a",
|
|
536
|
+
{
|
|
537
|
+
href: url,
|
|
538
|
+
target: "_blank",
|
|
539
|
+
rel: "noopener noreferrer",
|
|
540
|
+
onFocus: () => setIsLinkFocused(true),
|
|
541
|
+
onBlur: () => setIsLinkFocused(false),
|
|
542
|
+
style: {
|
|
543
|
+
...rampLinkStyle,
|
|
544
|
+
color: tokens.linkText,
|
|
545
|
+
outline: isLinkFocused ? `2px solid ${tokens.focusAccent}` : "2px solid transparent",
|
|
546
|
+
outlineOffset: "2px"
|
|
547
|
+
},
|
|
548
|
+
children: "Continue to the anchor"
|
|
549
|
+
}
|
|
550
|
+
) })
|
|
551
|
+
] }),
|
|
552
|
+
phase === "processing" && /* @__PURE__ */ jsx2("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Processing your payment" }),
|
|
553
|
+
phase === "completed" && /* @__PURE__ */ jsx2("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Payment completed" }),
|
|
554
|
+
phase === "failed" && /* @__PURE__ */ jsxs("div", { children: [
|
|
555
|
+
/* @__PURE__ */ jsx2("p", { style: { ...rampErrorTextStyle, color: tokens.errorText }, children: error?.message ?? "Payment failed" }),
|
|
556
|
+
/* @__PURE__ */ jsx2(
|
|
557
|
+
"button",
|
|
558
|
+
{
|
|
559
|
+
type: "button",
|
|
560
|
+
onClick: handleRetry,
|
|
561
|
+
onFocus: () => setIsRetryFocused(true),
|
|
562
|
+
onBlur: () => setIsRetryFocused(false),
|
|
563
|
+
style: {
|
|
564
|
+
...rampRetryButtonStyle,
|
|
565
|
+
color: tokens.retryBtnText,
|
|
566
|
+
backgroundColor: tokens.retryBtnBg,
|
|
567
|
+
border: `1px solid ${tokens.retryBtnBorder}`,
|
|
568
|
+
outline: isRetryFocused ? `2px solid ${tokens.focusAccent}` : "2px solid transparent",
|
|
569
|
+
outlineOffset: "2px"
|
|
570
|
+
},
|
|
571
|
+
children: "Try again"
|
|
572
|
+
}
|
|
573
|
+
)
|
|
574
|
+
] })
|
|
575
|
+
] })
|
|
576
|
+
] });
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// src/useCashOutToNaira.ts
|
|
580
|
+
import { useState as useState5, useCallback as useCallback4, useRef as useRef4, useEffect as useEffect5 } from "react";
|
|
581
|
+
import {
|
|
582
|
+
TERMINAL_STATUSES as TERMINAL_STATUSES2,
|
|
583
|
+
NairaRampError as NairaRampError3
|
|
584
|
+
} from "@nairaramp/core";
|
|
585
|
+
function useCashOutToNaira({
|
|
586
|
+
ramp: rampOption,
|
|
587
|
+
assetCode
|
|
588
|
+
}) {
|
|
589
|
+
const ramp = useNairaRamp(rampOption);
|
|
590
|
+
const [phase, setPhase] = useState5("idle");
|
|
591
|
+
const [status, setStatus] = useState5(void 0);
|
|
592
|
+
const [transactionId, setTransactionId] = useState5(void 0);
|
|
593
|
+
const [transaction, setTransaction] = useState5(void 0);
|
|
594
|
+
const [url, setUrl] = useState5(void 0);
|
|
595
|
+
const [txHash, setTxHash] = useState5(void 0);
|
|
596
|
+
const [error, setError] = useState5(void 0);
|
|
597
|
+
const phaseRef = useRef4("idle");
|
|
598
|
+
const subscriptionRef = useRef4(void 0);
|
|
599
|
+
const isMountedRef = useRef4(true);
|
|
600
|
+
const completionStartedRef = useRef4(false);
|
|
601
|
+
const attemptIdRef = useRef4(0);
|
|
602
|
+
useEffect5(() => {
|
|
603
|
+
phaseRef.current = phase;
|
|
604
|
+
}, [phase]);
|
|
605
|
+
const stopWatcher = useCallback4(() => {
|
|
606
|
+
if (subscriptionRef.current) {
|
|
607
|
+
subscriptionRef.current.stop();
|
|
608
|
+
subscriptionRef.current = void 0;
|
|
609
|
+
}
|
|
610
|
+
}, []);
|
|
611
|
+
const reset = useCallback4(() => {
|
|
612
|
+
attemptIdRef.current += 1;
|
|
613
|
+
stopWatcher();
|
|
614
|
+
phaseRef.current = "idle";
|
|
615
|
+
completionStartedRef.current = false;
|
|
616
|
+
if (isMountedRef.current) {
|
|
617
|
+
setPhase("idle");
|
|
618
|
+
setStatus(void 0);
|
|
619
|
+
setTransactionId(void 0);
|
|
620
|
+
setTransaction(void 0);
|
|
621
|
+
setUrl(void 0);
|
|
622
|
+
setTxHash(void 0);
|
|
623
|
+
setError(void 0);
|
|
624
|
+
}
|
|
625
|
+
}, [stopWatcher]);
|
|
626
|
+
const start = useCallback4(
|
|
627
|
+
async (amount) => {
|
|
628
|
+
if (phaseRef.current !== "idle") {
|
|
629
|
+
return void 0;
|
|
630
|
+
}
|
|
631
|
+
const attemptId = ++attemptIdRef.current;
|
|
632
|
+
completionStartedRef.current = false;
|
|
633
|
+
phaseRef.current = "starting";
|
|
634
|
+
if (isMountedRef.current) {
|
|
635
|
+
setPhase("starting");
|
|
636
|
+
setTransaction(void 0);
|
|
637
|
+
setError(void 0);
|
|
638
|
+
setTxHash(void 0);
|
|
639
|
+
}
|
|
640
|
+
let withdrawResult;
|
|
641
|
+
try {
|
|
642
|
+
withdrawResult = await ramp.withdraw({
|
|
643
|
+
assetCode,
|
|
644
|
+
...amount !== void 0 ? { amount } : {}
|
|
645
|
+
});
|
|
646
|
+
} catch (err) {
|
|
647
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) {
|
|
648
|
+
return void 0;
|
|
649
|
+
}
|
|
650
|
+
const wrapped = ensureNairaRampError(err);
|
|
651
|
+
phaseRef.current = "failed";
|
|
652
|
+
setError(wrapped);
|
|
653
|
+
setPhase("failed");
|
|
654
|
+
return void 0;
|
|
655
|
+
}
|
|
656
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) {
|
|
657
|
+
return void 0;
|
|
658
|
+
}
|
|
659
|
+
const { id, url: hostedUrl } = withdrawResult;
|
|
660
|
+
setTransactionId(id);
|
|
661
|
+
setUrl(hostedUrl);
|
|
662
|
+
phaseRef.current = "awaiting_user";
|
|
663
|
+
setPhase("awaiting_user");
|
|
664
|
+
stopWatcher();
|
|
665
|
+
const subscription = ramp.watch(id, {
|
|
666
|
+
onStatus: (nextStatus, tx) => {
|
|
667
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
668
|
+
setStatus(nextStatus);
|
|
669
|
+
if (tx) {
|
|
670
|
+
setTransaction(tx);
|
|
671
|
+
if (tx.stellar_transaction_id) {
|
|
672
|
+
setTxHash((prev) => prev ?? tx.stellar_transaction_id);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
if (nextStatus === "completed") {
|
|
676
|
+
stopWatcher();
|
|
677
|
+
phaseRef.current = "completed";
|
|
678
|
+
setPhase("completed");
|
|
679
|
+
return;
|
|
680
|
+
}
|
|
681
|
+
if (TERMINAL_STATUSES2.includes(nextStatus)) {
|
|
682
|
+
stopWatcher();
|
|
683
|
+
const detail = tx?.message ? `Transaction ${nextStatus}: ${tx.message}` : `Transaction ${nextStatus}`;
|
|
684
|
+
setError(new NairaRampError3("TRANSACTION_FAILED", detail));
|
|
685
|
+
phaseRef.current = "failed";
|
|
686
|
+
setPhase("failed");
|
|
687
|
+
return;
|
|
688
|
+
}
|
|
689
|
+
if (nextStatus === "pending_user_transfer_start") {
|
|
690
|
+
if (!completionStartedRef.current) {
|
|
691
|
+
completionStartedRef.current = true;
|
|
692
|
+
phaseRef.current = "completing";
|
|
693
|
+
setPhase("completing");
|
|
694
|
+
ramp.completeWithdrawal(id).then(({ hash }) => {
|
|
695
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
696
|
+
setTxHash(hash);
|
|
697
|
+
if (phaseRef.current === "completing") {
|
|
698
|
+
phaseRef.current = "processing";
|
|
699
|
+
setPhase("processing");
|
|
700
|
+
}
|
|
701
|
+
}).catch((err) => {
|
|
702
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
703
|
+
stopWatcher();
|
|
704
|
+
setError(ensureNairaRampError(err));
|
|
705
|
+
phaseRef.current = "failed";
|
|
706
|
+
setPhase("failed");
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
return;
|
|
710
|
+
}
|
|
711
|
+
if (nextStatus === "incomplete" || nextStatus === "pending_user") {
|
|
712
|
+
phaseRef.current = "awaiting_user";
|
|
713
|
+
setPhase("awaiting_user");
|
|
714
|
+
} else {
|
|
715
|
+
phaseRef.current = "processing";
|
|
716
|
+
setPhase("processing");
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
onComplete: (tx) => {
|
|
720
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
721
|
+
stopWatcher();
|
|
722
|
+
if (tx) {
|
|
723
|
+
setTransaction(tx);
|
|
724
|
+
if (tx.stellar_transaction_id) {
|
|
725
|
+
setTxHash((prev) => prev ?? tx.stellar_transaction_id);
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
setStatus("completed");
|
|
729
|
+
phaseRef.current = "completed";
|
|
730
|
+
setPhase("completed");
|
|
731
|
+
},
|
|
732
|
+
onError: (err) => {
|
|
733
|
+
if (!isMountedRef.current || attemptId !== attemptIdRef.current) return;
|
|
734
|
+
stopWatcher();
|
|
735
|
+
setError(ensureNairaRampError(err));
|
|
736
|
+
phaseRef.current = "failed";
|
|
737
|
+
setPhase("failed");
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
subscriptionRef.current = subscription;
|
|
741
|
+
return withdrawResult;
|
|
742
|
+
},
|
|
743
|
+
[ramp, assetCode, stopWatcher]
|
|
744
|
+
);
|
|
745
|
+
useEffect5(() => {
|
|
746
|
+
isMountedRef.current = true;
|
|
747
|
+
return () => {
|
|
748
|
+
isMountedRef.current = false;
|
|
749
|
+
attemptIdRef.current += 1;
|
|
750
|
+
stopWatcher();
|
|
751
|
+
};
|
|
752
|
+
}, [stopWatcher]);
|
|
753
|
+
return {
|
|
754
|
+
start,
|
|
755
|
+
phase,
|
|
756
|
+
status,
|
|
757
|
+
transactionId,
|
|
758
|
+
transaction,
|
|
759
|
+
url,
|
|
760
|
+
txHash,
|
|
761
|
+
error,
|
|
762
|
+
reset
|
|
763
|
+
};
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
// src/CashOutToNaira.tsx
|
|
767
|
+
import {
|
|
768
|
+
useState as useState6,
|
|
769
|
+
useRef as useRef5,
|
|
770
|
+
useEffect as useEffect6,
|
|
771
|
+
useCallback as useCallback5
|
|
772
|
+
} from "react";
|
|
773
|
+
import {
|
|
774
|
+
NairaRampError as NairaRampErrorClass2
|
|
775
|
+
} from "@nairaramp/core";
|
|
776
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
777
|
+
function CashOutToNaira({
|
|
778
|
+
ramp,
|
|
779
|
+
assetCode,
|
|
780
|
+
amount,
|
|
781
|
+
onComplete,
|
|
782
|
+
onError,
|
|
783
|
+
label = "Cash out to Naira",
|
|
784
|
+
theme = "system",
|
|
785
|
+
className,
|
|
786
|
+
style
|
|
787
|
+
}) {
|
|
788
|
+
const tokens = useResolvedTheme(theme);
|
|
789
|
+
const { start, phase, error, url, txHash, reset } = useCashOutToNaira({
|
|
790
|
+
ramp,
|
|
791
|
+
assetCode
|
|
792
|
+
});
|
|
793
|
+
const {
|
|
794
|
+
popupBlocked,
|
|
795
|
+
openPopup,
|
|
796
|
+
navigatePopup,
|
|
797
|
+
closePopup,
|
|
798
|
+
clearPopupBlocked
|
|
799
|
+
} = useAnchorPopup();
|
|
800
|
+
const [isPrimaryFocused, setIsPrimaryFocused] = useState6(false);
|
|
801
|
+
const [isRetryFocused, setIsRetryFocused] = useState6(false);
|
|
802
|
+
const [isLinkFocused, setIsLinkFocused] = useState6(false);
|
|
803
|
+
const onCompleteRef = useRef5(onComplete);
|
|
804
|
+
const onErrorRef = useRef5(onError);
|
|
805
|
+
const completedFiredRef = useRef5(false);
|
|
806
|
+
const errorFiredRef = useRef5(false);
|
|
807
|
+
useEffect6(() => {
|
|
808
|
+
onCompleteRef.current = onComplete;
|
|
809
|
+
}, [onComplete]);
|
|
810
|
+
useEffect6(() => {
|
|
811
|
+
onErrorRef.current = onError;
|
|
812
|
+
}, [onError]);
|
|
813
|
+
const handleClick = useCallback5(async () => {
|
|
814
|
+
const popup = openPopup();
|
|
815
|
+
const result = await start(amount);
|
|
816
|
+
navigatePopup(popup, result?.url);
|
|
817
|
+
}, [openPopup, start, amount, navigatePopup]);
|
|
818
|
+
const handleRetry = useCallback5(() => {
|
|
819
|
+
clearPopupBlocked();
|
|
820
|
+
closePopup();
|
|
821
|
+
completedFiredRef.current = false;
|
|
822
|
+
errorFiredRef.current = false;
|
|
823
|
+
reset();
|
|
824
|
+
}, [clearPopupBlocked, closePopup, reset]);
|
|
825
|
+
useEffect6(() => {
|
|
826
|
+
if (phase === "completed") {
|
|
827
|
+
if (!completedFiredRef.current) {
|
|
828
|
+
completedFiredRef.current = true;
|
|
829
|
+
onCompleteRef.current?.(txHash);
|
|
830
|
+
}
|
|
831
|
+
} else if (phase === "failed") {
|
|
832
|
+
closePopup();
|
|
833
|
+
if (!errorFiredRef.current) {
|
|
834
|
+
errorFiredRef.current = true;
|
|
835
|
+
const finalError = error ?? new NairaRampErrorClass2("TRANSACTION_FAILED", "Cash out failed");
|
|
836
|
+
onErrorRef.current?.(finalError);
|
|
837
|
+
}
|
|
838
|
+
} else if (phase === "idle") {
|
|
839
|
+
completedFiredRef.current = false;
|
|
840
|
+
errorFiredRef.current = false;
|
|
841
|
+
}
|
|
842
|
+
}, [phase, error, txHash, closePopup]);
|
|
843
|
+
return /* @__PURE__ */ jsxs2("div", { className, style: { ...rampContainerStyle, color: tokens.text, ...style }, children: [
|
|
844
|
+
phase === "idle" && /* @__PURE__ */ jsx3(
|
|
845
|
+
"button",
|
|
846
|
+
{
|
|
847
|
+
type: "button",
|
|
848
|
+
onClick: handleClick,
|
|
849
|
+
onFocus: () => setIsPrimaryFocused(true),
|
|
850
|
+
onBlur: () => setIsPrimaryFocused(false),
|
|
851
|
+
style: {
|
|
852
|
+
...rampPrimaryButtonStyle,
|
|
853
|
+
color: tokens.primaryBtnText,
|
|
854
|
+
backgroundColor: tokens.primaryBtnBg,
|
|
855
|
+
outline: isPrimaryFocused ? `3px solid ${tokens.focusPrimary}` : "2px solid transparent",
|
|
856
|
+
outlineOffset: "2px"
|
|
857
|
+
},
|
|
858
|
+
children: label
|
|
859
|
+
}
|
|
860
|
+
),
|
|
861
|
+
/* @__PURE__ */ jsxs2("div", { "aria-live": "polite", "aria-atomic": "true", children: [
|
|
862
|
+
phase === "starting" && /* @__PURE__ */ jsx3(
|
|
863
|
+
"button",
|
|
864
|
+
{
|
|
865
|
+
type: "button",
|
|
866
|
+
disabled: true,
|
|
867
|
+
style: {
|
|
868
|
+
...rampDisabledButtonStyle,
|
|
869
|
+
color: tokens.disabledBtnText,
|
|
870
|
+
backgroundColor: tokens.disabledBtnBg
|
|
871
|
+
},
|
|
872
|
+
children: "Connecting..."
|
|
873
|
+
}
|
|
874
|
+
),
|
|
875
|
+
phase === "awaiting_user" && /* @__PURE__ */ jsxs2("div", { children: [
|
|
876
|
+
/* @__PURE__ */ jsx3("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Complete the steps in the anchor window" }),
|
|
877
|
+
popupBlocked && url && isSafeHttpUrl(url) && /* @__PURE__ */ jsx3("p", { style: { margin: "8px 0 0 0" }, children: /* @__PURE__ */ jsx3(
|
|
878
|
+
"a",
|
|
879
|
+
{
|
|
880
|
+
href: url,
|
|
881
|
+
target: "_blank",
|
|
882
|
+
rel: "noopener noreferrer",
|
|
883
|
+
onFocus: () => setIsLinkFocused(true),
|
|
884
|
+
onBlur: () => setIsLinkFocused(false),
|
|
885
|
+
style: {
|
|
886
|
+
...rampLinkStyle,
|
|
887
|
+
color: tokens.linkText,
|
|
888
|
+
outline: isLinkFocused ? `2px solid ${tokens.focusAccent}` : "2px solid transparent",
|
|
889
|
+
outlineOffset: "2px"
|
|
890
|
+
},
|
|
891
|
+
children: "Continue to the anchor"
|
|
892
|
+
}
|
|
893
|
+
) })
|
|
894
|
+
] }),
|
|
895
|
+
phase === "completing" && /* @__PURE__ */ jsx3("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Submitting Stellar transfer..." }),
|
|
896
|
+
phase === "processing" && /* @__PURE__ */ jsx3("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Processing your cash out" }),
|
|
897
|
+
phase === "completed" && /* @__PURE__ */ jsx3("p", { style: { ...rampStatusTextStyle, color: tokens.secondaryText }, children: "Cash out completed" }),
|
|
898
|
+
phase === "failed" && /* @__PURE__ */ jsxs2("div", { children: [
|
|
899
|
+
/* @__PURE__ */ jsx3("p", { style: { ...rampErrorTextStyle, color: tokens.errorText }, children: error?.message ?? "Cash out failed" }),
|
|
900
|
+
/* @__PURE__ */ jsx3(
|
|
901
|
+
"button",
|
|
902
|
+
{
|
|
903
|
+
type: "button",
|
|
904
|
+
onClick: handleRetry,
|
|
905
|
+
onFocus: () => setIsRetryFocused(true),
|
|
906
|
+
onBlur: () => setIsRetryFocused(false),
|
|
907
|
+
style: {
|
|
908
|
+
...rampRetryButtonStyle,
|
|
909
|
+
color: tokens.retryBtnText,
|
|
910
|
+
backgroundColor: tokens.retryBtnBg,
|
|
911
|
+
border: `1px solid ${tokens.retryBtnBorder}`,
|
|
912
|
+
outline: isRetryFocused ? `2px solid ${tokens.focusAccent}` : "2px solid transparent",
|
|
913
|
+
outlineOffset: "2px"
|
|
914
|
+
},
|
|
915
|
+
children: "Try again"
|
|
916
|
+
}
|
|
917
|
+
)
|
|
918
|
+
] })
|
|
919
|
+
] })
|
|
920
|
+
] });
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
// src/StatusTimeline.tsx
|
|
924
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
925
|
+
var TIMELINE_STEPS = [
|
|
926
|
+
"Started",
|
|
927
|
+
"Waiting for your payment",
|
|
928
|
+
"Payment received",
|
|
929
|
+
"Anchor processing",
|
|
930
|
+
"Sending on Stellar",
|
|
931
|
+
"Completed"
|
|
932
|
+
];
|
|
933
|
+
var YORUBA_LABELS = {
|
|
934
|
+
Started: "B\u1EB9r\u1EB9",
|
|
935
|
+
"Waiting for your payment": "Nduro de owo r\u1EB9",
|
|
936
|
+
"Payment received": "A ti gba owo",
|
|
937
|
+
"Anchor processing": "Anchor n \u1E63i\u1E63\u1EB9 lori r\u1EB9",
|
|
938
|
+
"Sending on Stellar": "Nfi ran\u1E63\u1EB9 lori Stellar",
|
|
939
|
+
Completed: "Pari"
|
|
940
|
+
};
|
|
941
|
+
var HAUSA_LABELS = {
|
|
942
|
+
Started: "An fara",
|
|
943
|
+
"Waiting for your payment": "Ana jiran biyan ku",
|
|
944
|
+
"Payment received": "An kar\u0253i biya",
|
|
945
|
+
"Anchor processing": "Anchor yana sarrafawa",
|
|
946
|
+
"Sending on Stellar": "Ana aikawa ta Stellar",
|
|
947
|
+
Completed: "An kammala"
|
|
948
|
+
};
|
|
949
|
+
var IGBO_LABELS = {
|
|
950
|
+
Started: "Amalitela",
|
|
951
|
+
"Waiting for your payment": "Na-eche ugwo gi",
|
|
952
|
+
"Payment received": "Anatala ugwo",
|
|
953
|
+
"Anchor processing": "Anchor na-ar\u1EE5 \u1ECDr\u1EE5",
|
|
954
|
+
"Sending on Stellar": "Na-eziga na Stellar",
|
|
955
|
+
Completed: "Emechala"
|
|
956
|
+
};
|
|
957
|
+
var PIDGIN_LABELS = {
|
|
958
|
+
Started: "Don start",
|
|
959
|
+
"Waiting for your payment": "Dey wait for your money",
|
|
960
|
+
"Payment received": "We don collect the money",
|
|
961
|
+
"Anchor processing": "Anchor dey process am",
|
|
962
|
+
"Sending on Stellar": "Dey send am on Stellar",
|
|
963
|
+
Completed: "Don finish"
|
|
964
|
+
};
|
|
965
|
+
var STATUS_MAP = {
|
|
966
|
+
incomplete: {
|
|
967
|
+
kind: "step",
|
|
968
|
+
stepIndex: 0,
|
|
969
|
+
label: "Started"
|
|
970
|
+
},
|
|
971
|
+
pending_user_transfer_start: {
|
|
972
|
+
kind: "step",
|
|
973
|
+
stepIndex: 1,
|
|
974
|
+
label: "Waiting for your payment"
|
|
975
|
+
},
|
|
976
|
+
pending_user_transfer_complete: {
|
|
977
|
+
kind: "step",
|
|
978
|
+
stepIndex: 2,
|
|
979
|
+
label: "Payment received"
|
|
980
|
+
},
|
|
981
|
+
pending_external: {
|
|
982
|
+
kind: "step",
|
|
983
|
+
stepIndex: 2,
|
|
984
|
+
label: "Payment received"
|
|
985
|
+
},
|
|
986
|
+
pending_anchor: {
|
|
987
|
+
kind: "step",
|
|
988
|
+
stepIndex: 3,
|
|
989
|
+
label: "Anchor processing"
|
|
990
|
+
},
|
|
991
|
+
pending_stellar: {
|
|
992
|
+
kind: "step",
|
|
993
|
+
stepIndex: 4,
|
|
994
|
+
label: "Sending on Stellar"
|
|
995
|
+
},
|
|
996
|
+
pending_trust: {
|
|
997
|
+
kind: "step",
|
|
998
|
+
stepIndex: 4,
|
|
999
|
+
label: "Sending on Stellar"
|
|
1000
|
+
},
|
|
1001
|
+
pending_user: {
|
|
1002
|
+
kind: "step",
|
|
1003
|
+
stepIndex: 1,
|
|
1004
|
+
label: "Waiting for your payment"
|
|
1005
|
+
},
|
|
1006
|
+
completed: {
|
|
1007
|
+
kind: "step",
|
|
1008
|
+
stepIndex: 5,
|
|
1009
|
+
label: "Completed"
|
|
1010
|
+
},
|
|
1011
|
+
refunded: {
|
|
1012
|
+
kind: "failure",
|
|
1013
|
+
label: "Refunded"
|
|
1014
|
+
},
|
|
1015
|
+
expired: {
|
|
1016
|
+
kind: "failure",
|
|
1017
|
+
label: "Expired"
|
|
1018
|
+
},
|
|
1019
|
+
no_market: {
|
|
1020
|
+
kind: "failure",
|
|
1021
|
+
label: "No market"
|
|
1022
|
+
},
|
|
1023
|
+
too_small: {
|
|
1024
|
+
kind: "failure",
|
|
1025
|
+
label: "Too small"
|
|
1026
|
+
},
|
|
1027
|
+
too_large: {
|
|
1028
|
+
kind: "failure",
|
|
1029
|
+
label: "Too large"
|
|
1030
|
+
},
|
|
1031
|
+
error: {
|
|
1032
|
+
kind: "failure",
|
|
1033
|
+
label: "Error"
|
|
1034
|
+
}
|
|
1035
|
+
};
|
|
1036
|
+
var containerStyle = {
|
|
1037
|
+
width: "100%",
|
|
1038
|
+
maxWidth: "420px",
|
|
1039
|
+
boxSizing: "border-box",
|
|
1040
|
+
fontFamily: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
|
|
1041
|
+
fontSize: "15px",
|
|
1042
|
+
lineHeight: 1.5,
|
|
1043
|
+
color: "#111827"
|
|
1044
|
+
};
|
|
1045
|
+
var listStyle = {
|
|
1046
|
+
listStyle: "none",
|
|
1047
|
+
padding: 0,
|
|
1048
|
+
margin: 0,
|
|
1049
|
+
display: "flex",
|
|
1050
|
+
flexDirection: "column",
|
|
1051
|
+
gap: "12px"
|
|
1052
|
+
};
|
|
1053
|
+
var failureContainerStyle = {
|
|
1054
|
+
...containerStyle,
|
|
1055
|
+
padding: "16px",
|
|
1056
|
+
borderRadius: "8px",
|
|
1057
|
+
backgroundColor: "#fef2f2",
|
|
1058
|
+
border: "1px solid #fee2e2",
|
|
1059
|
+
textAlign: "center"
|
|
1060
|
+
};
|
|
1061
|
+
var failureTitleStyle = {
|
|
1062
|
+
margin: 0,
|
|
1063
|
+
fontSize: "16px",
|
|
1064
|
+
fontWeight: 600,
|
|
1065
|
+
color: "#991b1b"
|
|
1066
|
+
};
|
|
1067
|
+
var messageTextStyle = {
|
|
1068
|
+
margin: "6px 0 0 0",
|
|
1069
|
+
fontSize: "14px",
|
|
1070
|
+
color: "#4b5563"
|
|
1071
|
+
};
|
|
1072
|
+
function resolveStatusMapping(status) {
|
|
1073
|
+
if (status === void 0) {
|
|
1074
|
+
return {
|
|
1075
|
+
kind: "step",
|
|
1076
|
+
stepIndex: 0,
|
|
1077
|
+
label: "Started"
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1080
|
+
if (Object.prototype.hasOwnProperty.call(STATUS_MAP, status)) {
|
|
1081
|
+
return STATUS_MAP[status];
|
|
1082
|
+
}
|
|
1083
|
+
return {
|
|
1084
|
+
kind: "failure",
|
|
1085
|
+
label: "Unknown status"
|
|
1086
|
+
};
|
|
1087
|
+
}
|
|
1088
|
+
function StatusTimeline({
|
|
1089
|
+
status,
|
|
1090
|
+
message,
|
|
1091
|
+
labels,
|
|
1092
|
+
failureLabels,
|
|
1093
|
+
theme = "system",
|
|
1094
|
+
className,
|
|
1095
|
+
style
|
|
1096
|
+
}) {
|
|
1097
|
+
const tokens = useResolvedTheme(theme);
|
|
1098
|
+
const mapping = resolveStatusMapping(status);
|
|
1099
|
+
if (mapping.kind === "failure") {
|
|
1100
|
+
const failureText = failureLabels?.[mapping.label] ?? mapping.label;
|
|
1101
|
+
return /* @__PURE__ */ jsxs3(
|
|
1102
|
+
"div",
|
|
1103
|
+
{
|
|
1104
|
+
className,
|
|
1105
|
+
style: {
|
|
1106
|
+
...failureContainerStyle,
|
|
1107
|
+
color: tokens.text,
|
|
1108
|
+
backgroundColor: tokens.failureBg,
|
|
1109
|
+
border: `1px solid ${tokens.failureBorder}`,
|
|
1110
|
+
...style
|
|
1111
|
+
},
|
|
1112
|
+
role: "alert",
|
|
1113
|
+
children: [
|
|
1114
|
+
/* @__PURE__ */ jsx4("p", { style: { ...failureTitleStyle, color: tokens.failureTitle }, children: failureText }),
|
|
1115
|
+
message && /* @__PURE__ */ jsx4("p", { style: { ...messageTextStyle, color: tokens.mutedText }, children: message })
|
|
1116
|
+
]
|
|
1117
|
+
}
|
|
1118
|
+
);
|
|
1119
|
+
}
|
|
1120
|
+
const activeIndex = mapping.stepIndex;
|
|
1121
|
+
return /* @__PURE__ */ jsxs3("div", { className, style: { ...containerStyle, color: tokens.text, ...style }, children: [
|
|
1122
|
+
/* @__PURE__ */ jsx4("ol", { style: listStyle, "aria-label": "Payment status timeline", children: TIMELINE_STEPS.map((step, index) => {
|
|
1123
|
+
const isDone = index < activeIndex;
|
|
1124
|
+
const isActive = index === activeIndex;
|
|
1125
|
+
const displayLabel = labels?.[step] ?? step;
|
|
1126
|
+
const itemStyle = {
|
|
1127
|
+
display: "flex",
|
|
1128
|
+
alignItems: "center",
|
|
1129
|
+
gap: "12px",
|
|
1130
|
+
color: isActive ? tokens.text : isDone ? tokens.doneText : tokens.pendingText,
|
|
1131
|
+
fontWeight: isActive ? 600 : isDone ? 500 : 400
|
|
1132
|
+
};
|
|
1133
|
+
const badgeStyle = {
|
|
1134
|
+
width: "24px",
|
|
1135
|
+
height: "24px",
|
|
1136
|
+
borderRadius: "50%",
|
|
1137
|
+
display: "inline-flex",
|
|
1138
|
+
alignItems: "center",
|
|
1139
|
+
justifyContent: "center",
|
|
1140
|
+
fontSize: "12px",
|
|
1141
|
+
fontWeight: 700,
|
|
1142
|
+
boxSizing: "border-box",
|
|
1143
|
+
backgroundColor: isActive ? tokens.activeBadgeBg : isDone ? tokens.doneBadgeBg : tokens.pendingBadgeBg,
|
|
1144
|
+
color: isActive || isDone ? tokens.activeOrDoneBadgeText : tokens.pendingBadgeText
|
|
1145
|
+
};
|
|
1146
|
+
return /* @__PURE__ */ jsxs3(
|
|
1147
|
+
"li",
|
|
1148
|
+
{
|
|
1149
|
+
"aria-current": isActive ? "step" : void 0,
|
|
1150
|
+
style: itemStyle,
|
|
1151
|
+
children: [
|
|
1152
|
+
/* @__PURE__ */ jsx4("span", { style: badgeStyle, "aria-hidden": "true", children: isDone ? "\u2713" : index + 1 }),
|
|
1153
|
+
/* @__PURE__ */ jsx4("span", { children: displayLabel })
|
|
1154
|
+
]
|
|
1155
|
+
},
|
|
1156
|
+
step
|
|
1157
|
+
);
|
|
1158
|
+
}) }),
|
|
1159
|
+
message && /* @__PURE__ */ jsx4("p", { style: { ...messageTextStyle, color: tokens.mutedText }, children: message })
|
|
1160
|
+
] });
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// src/useRampQuote.ts
|
|
1164
|
+
import { useState as useState7, useCallback as useCallback6, useRef as useRef6, useEffect as useEffect7 } from "react";
|
|
1165
|
+
import {
|
|
1166
|
+
NairaRampError as NairaRampError4,
|
|
1167
|
+
isNairaRampError as isNairaRampError2
|
|
1168
|
+
} from "@nairaramp/core";
|
|
1169
|
+
function toQuoteError(err) {
|
|
1170
|
+
if (isNairaRampError2(err)) {
|
|
1171
|
+
return err;
|
|
1172
|
+
}
|
|
1173
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1174
|
+
return new NairaRampError4("QUOTE_UNAVAILABLE", message, { cause: err });
|
|
1175
|
+
}
|
|
1176
|
+
function useRampQuote({
|
|
1177
|
+
ramp: rampOption,
|
|
1178
|
+
sellAsset,
|
|
1179
|
+
buyAsset,
|
|
1180
|
+
sellAmount,
|
|
1181
|
+
buyAmount,
|
|
1182
|
+
context,
|
|
1183
|
+
debounceMs = 300,
|
|
1184
|
+
pollIntervalMs,
|
|
1185
|
+
enabled = true
|
|
1186
|
+
}) {
|
|
1187
|
+
const ramp = useNairaRamp(rampOption);
|
|
1188
|
+
const [quote, setQuote] = useState7(void 0);
|
|
1189
|
+
const [loading, setLoading] = useState7(false);
|
|
1190
|
+
const [error, setError] = useState7(void 0);
|
|
1191
|
+
const isMountedRef = useRef6(true);
|
|
1192
|
+
const requestIdRef = useRef6(0);
|
|
1193
|
+
const hasAmount = sellAmount !== void 0 && sellAmount.trim() !== "" || buyAmount !== void 0 && buyAmount.trim() !== "";
|
|
1194
|
+
const fetchQuote = useCallback6(async () => {
|
|
1195
|
+
if (!enabled || !hasAmount) {
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1198
|
+
const reqId = ++requestIdRef.current;
|
|
1199
|
+
if (isMountedRef.current) {
|
|
1200
|
+
setLoading(true);
|
|
1201
|
+
setError(void 0);
|
|
1202
|
+
}
|
|
1203
|
+
const options = {
|
|
1204
|
+
sellAsset,
|
|
1205
|
+
buyAsset,
|
|
1206
|
+
...sellAmount !== void 0 && sellAmount.trim() !== "" ? { sellAmount } : {},
|
|
1207
|
+
...buyAmount !== void 0 && buyAmount.trim() !== "" ? { buyAmount } : {},
|
|
1208
|
+
...context !== void 0 ? { context } : {}
|
|
1209
|
+
};
|
|
1210
|
+
try {
|
|
1211
|
+
const nextQuote = await ramp.getPrice(options);
|
|
1212
|
+
if (!isMountedRef.current || reqId !== requestIdRef.current) {
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
setQuote(nextQuote);
|
|
1216
|
+
setError(void 0);
|
|
1217
|
+
} catch (err) {
|
|
1218
|
+
if (!isMountedRef.current || reqId !== requestIdRef.current) {
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
setError(toQuoteError(err));
|
|
1222
|
+
} finally {
|
|
1223
|
+
if (isMountedRef.current && reqId === requestIdRef.current) {
|
|
1224
|
+
setLoading(false);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}, [ramp, sellAsset, buyAsset, sellAmount, buyAmount, context, enabled, hasAmount]);
|
|
1228
|
+
useEffect7(() => {
|
|
1229
|
+
isMountedRef.current = true;
|
|
1230
|
+
return () => {
|
|
1231
|
+
isMountedRef.current = false;
|
|
1232
|
+
};
|
|
1233
|
+
}, []);
|
|
1234
|
+
useEffect7(() => {
|
|
1235
|
+
if (!enabled || !hasAmount) {
|
|
1236
|
+
requestIdRef.current++;
|
|
1237
|
+
setQuote(void 0);
|
|
1238
|
+
setError(void 0);
|
|
1239
|
+
setLoading(false);
|
|
1240
|
+
return;
|
|
1241
|
+
}
|
|
1242
|
+
const delay = Math.max(0, debounceMs);
|
|
1243
|
+
const debounceTimer = setTimeout(() => {
|
|
1244
|
+
void fetchQuote();
|
|
1245
|
+
}, delay);
|
|
1246
|
+
return () => {
|
|
1247
|
+
clearTimeout(debounceTimer);
|
|
1248
|
+
};
|
|
1249
|
+
}, [enabled, hasAmount, debounceMs, fetchQuote]);
|
|
1250
|
+
useEffect7(() => {
|
|
1251
|
+
if (!enabled || !hasAmount || !pollIntervalMs || pollIntervalMs <= 0) {
|
|
1252
|
+
return;
|
|
1253
|
+
}
|
|
1254
|
+
const interval = setInterval(() => {
|
|
1255
|
+
void fetchQuote();
|
|
1256
|
+
}, pollIntervalMs);
|
|
1257
|
+
return () => {
|
|
1258
|
+
clearInterval(interval);
|
|
1259
|
+
};
|
|
1260
|
+
}, [enabled, hasAmount, pollIntervalMs, fetchQuote]);
|
|
1261
|
+
return {
|
|
1262
|
+
quote,
|
|
1263
|
+
loading,
|
|
1264
|
+
error,
|
|
1265
|
+
refresh: fetchQuote
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
// src/useAnchors.ts
|
|
1270
|
+
import { useMemo, useCallback as useCallback7 } from "react";
|
|
1271
|
+
import {
|
|
1272
|
+
listAnchors
|
|
1273
|
+
} from "@nairaramp/core";
|
|
1274
|
+
function useAnchors(options = {}) {
|
|
1275
|
+
const { network, country, assetCode, sep } = options;
|
|
1276
|
+
const anchors = useMemo(() => {
|
|
1277
|
+
const coreFilter = network !== void 0 || country !== void 0 ? {
|
|
1278
|
+
...network !== void 0 ? { network } : {},
|
|
1279
|
+
...country !== void 0 ? { country } : {}
|
|
1280
|
+
} : void 0;
|
|
1281
|
+
const baseAnchors = listAnchors(coreFilter);
|
|
1282
|
+
return baseAnchors.filter((anchor) => {
|
|
1283
|
+
if (assetCode !== void 0 && !anchor.assets.some(
|
|
1284
|
+
(asset) => asset.code.toUpperCase() === assetCode.toUpperCase()
|
|
1285
|
+
)) {
|
|
1286
|
+
return false;
|
|
1287
|
+
}
|
|
1288
|
+
if (sep !== void 0 && !anchor.seps.includes(sep)) {
|
|
1289
|
+
return false;
|
|
1290
|
+
}
|
|
1291
|
+
return true;
|
|
1292
|
+
});
|
|
1293
|
+
}, [network, country, assetCode, sep]);
|
|
1294
|
+
const getAnchorById = useCallback7(
|
|
1295
|
+
(id) => anchors.find((anchor) => anchor.id === id),
|
|
1296
|
+
[anchors]
|
|
1297
|
+
);
|
|
1298
|
+
return { anchors, getAnchorById };
|
|
1299
|
+
}
|
|
1300
|
+
|
|
1301
|
+
// src/errorMessages.ts
|
|
1302
|
+
var ERROR_MESSAGES = {
|
|
1303
|
+
AUTH_FAILED: "Authentication with the anchor failed. Please try signing in again.",
|
|
1304
|
+
ANCHOR_UNREACHABLE: "Could not reach the anchor server. Check your connection and try again.",
|
|
1305
|
+
ANCHOR_NOT_FOUND: "The selected Stellar anchor is not recognized.",
|
|
1306
|
+
KYC_REQUIRED: "Identity verification (KYC) is required by the anchor before continuing.",
|
|
1307
|
+
QUOTE_EXPIRED: "Your exchange rate quote expired. Request a fresh quote to continue.",
|
|
1308
|
+
QUOTE_UNAVAILABLE: "Exchange rate quote is currently unavailable for this pair or amount.",
|
|
1309
|
+
UNSUPPORTED_ASSET: "This Stellar asset is not supported by the selected anchor.",
|
|
1310
|
+
SIGNER_REJECTED: "Wallet signature was cancelled or rejected.",
|
|
1311
|
+
TRANSACTION_FAILED: "The transaction could not be completed. Please try again.",
|
|
1312
|
+
MAINNET_NOT_ALLOWED: "Mainnet transactions are disabled in the current configuration.",
|
|
1313
|
+
ANCHOR_NOT_VERIFIED: "This anchor's mainnet verification is outdated and cannot be used."
|
|
1314
|
+
};
|
|
1315
|
+
function getErrorMessage(error, overrides) {
|
|
1316
|
+
if (!error) {
|
|
1317
|
+
return void 0;
|
|
1318
|
+
}
|
|
1319
|
+
const code = error.code;
|
|
1320
|
+
if (overrides && Object.prototype.hasOwnProperty.call(overrides, code)) {
|
|
1321
|
+
const custom = overrides[code];
|
|
1322
|
+
if (custom !== void 0) {
|
|
1323
|
+
return custom;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (Object.prototype.hasOwnProperty.call(ERROR_MESSAGES, code)) {
|
|
1327
|
+
return ERROR_MESSAGES[code];
|
|
1328
|
+
}
|
|
1329
|
+
return error.message;
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1332
|
+
// src/index.ts
|
|
1333
|
+
var VERSION = "0.2.0";
|
|
1334
|
+
export {
|
|
1335
|
+
CashOutToNaira,
|
|
1336
|
+
ERROR_MESSAGES,
|
|
1337
|
+
HAUSA_LABELS,
|
|
1338
|
+
IGBO_LABELS,
|
|
1339
|
+
NairaRampProvider,
|
|
1340
|
+
PIDGIN_LABELS,
|
|
1341
|
+
PayWithNaira,
|
|
1342
|
+
STATUS_MAP,
|
|
1343
|
+
StatusTimeline,
|
|
1344
|
+
TIMELINE_STEPS,
|
|
1345
|
+
VERSION,
|
|
1346
|
+
YORUBA_LABELS,
|
|
1347
|
+
getErrorMessage,
|
|
1348
|
+
getStellarExplorerUrl,
|
|
1349
|
+
useAnchors,
|
|
1350
|
+
useCashOutToNaira,
|
|
1351
|
+
useNairaRamp,
|
|
1352
|
+
usePayWithNaira,
|
|
1353
|
+
useRampQuote
|
|
1354
|
+
};
|