@zerohash-sdk/fund-react 1.8.1 → 1.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +20 -0
- package/dist/index.js +64 -51
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -101,6 +101,12 @@ declare type FundCompletedData = {
|
|
|
101
101
|
assetSymbol?: string;
|
|
102
102
|
/** Amount to be deposited */
|
|
103
103
|
amount?: string;
|
|
104
|
+
/** Backend transaction id for the deposit */
|
|
105
|
+
transactionId?: string;
|
|
106
|
+
/** Fund id the deposit was credited to */
|
|
107
|
+
fundId?: string;
|
|
108
|
+
/** Notional (fiat) amount of the deposit */
|
|
109
|
+
notionalAmount?: string;
|
|
104
110
|
};
|
|
105
111
|
|
|
106
112
|
/**
|
|
@@ -196,6 +202,16 @@ declare interface FundProps {
|
|
|
196
202
|
* ```
|
|
197
203
|
*/
|
|
198
204
|
onCompleted?: (data: FundCompletedData) => void;
|
|
205
|
+
/**
|
|
206
|
+
* Callback invoked when a deposit transaction reaches a terminal **failed**
|
|
207
|
+
* state (the "Transaction failed" page). Distinct from `onError` — this
|
|
208
|
+
* carries the failed transaction's details, not an SDK/request error.
|
|
209
|
+
*
|
|
210
|
+
* @param data - Details about the failed transaction (transactionId, fundId, amount…)
|
|
211
|
+
*/
|
|
212
|
+
onFailed?: (data: FundCompletedData) => void;
|
|
213
|
+
/** Invoked when the user taps "Provide info" on the travel-rule pending screen; open the Travel Rule SDK scoped to `depositId`. */
|
|
214
|
+
onProvideInfo?: (data: FundProvideInfoData) => void;
|
|
199
215
|
/**
|
|
200
216
|
* Callback invoked when an error occurs during the fund flow.
|
|
201
217
|
*
|
|
@@ -252,6 +268,10 @@ declare interface FundProps {
|
|
|
252
268
|
onEvent?: (event: FundEvent) => void;
|
|
253
269
|
}
|
|
254
270
|
|
|
271
|
+
declare type FundProvideInfoData = {
|
|
272
|
+
depositId: string;
|
|
273
|
+
};
|
|
274
|
+
|
|
255
275
|
/**
|
|
256
276
|
* Theme mode for the Connect Fund interface.
|
|
257
277
|
*
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsxs as W, jsx as
|
|
1
|
+
import { jsxs as W, jsx as _ } from "react/jsx-runtime";
|
|
2
2
|
import j, { useEffect as B, useState as z, useCallback as D, useRef as M } from "react";
|
|
3
3
|
const $ = {
|
|
4
4
|
dev: "https://grafana-faro-collector.dev.0hash.com/collect",
|
|
@@ -91,49 +91,49 @@ const $ = {
|
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}, Z = (e) => {
|
|
94
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs:
|
|
94
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m = 15e3, onLoad: b, onError: g } = e;
|
|
95
95
|
if (typeof document > "u")
|
|
96
96
|
return x;
|
|
97
|
-
const
|
|
98
|
-
if (customElements.get(t) || document.getElementById(
|
|
97
|
+
const p = `${t}-script-${a}`;
|
|
98
|
+
if (customElements.get(t) || document.getElementById(p))
|
|
99
99
|
return x;
|
|
100
|
-
const
|
|
101
|
-
let
|
|
102
|
-
const
|
|
100
|
+
const h = J(s), R = e.report ?? ((u) => G(c && P(c, a, s), u, r));
|
|
101
|
+
let d = !1, w = 0, C;
|
|
102
|
+
const v = () => {
|
|
103
103
|
C !== void 0 && clearTimeout(C);
|
|
104
|
-
}, k = (
|
|
105
|
-
if (
|
|
104
|
+
}, k = (u, y, l) => {
|
|
105
|
+
if (d)
|
|
106
106
|
return;
|
|
107
107
|
const U = Math.round(performance.now() - w), T = {
|
|
108
108
|
webComponentTag: t,
|
|
109
109
|
appName: o,
|
|
110
110
|
env: a,
|
|
111
|
-
scriptUrl:
|
|
112
|
-
reason:
|
|
111
|
+
scriptUrl: y,
|
|
112
|
+
reason: u,
|
|
113
113
|
triedFallback: l,
|
|
114
114
|
elapsedMs: U,
|
|
115
|
-
claims:
|
|
115
|
+
claims: h
|
|
116
116
|
};
|
|
117
|
-
|
|
117
|
+
R(T);
|
|
118
118
|
const O = l ? void 0 : F(i ?? {}, a, s);
|
|
119
|
-
if (O && O !==
|
|
119
|
+
if (O && O !== y) {
|
|
120
120
|
E(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
|
|
124
|
-
}, E = (
|
|
125
|
-
|
|
123
|
+
d = !0, v(), document.getElementById(p)?.remove(), g?.(T);
|
|
124
|
+
}, E = (u, y) => {
|
|
125
|
+
v(), w = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
|
-
l.id =
|
|
127
|
+
l.id = p, l.src = u, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
|
|
129
|
+
d || (customElements.get(t) ? (d = !0, v(), b?.()) : k("not-defined", u, y));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () => k("network",
|
|
131
|
+
}, l.onerror = () => k("network", u, y), C = setTimeout(() => k("timeout", u, y), m), document.getElementById(p)?.remove(), document.head.appendChild(l);
|
|
132
132
|
}, N = F(n, a, s);
|
|
133
133
|
return N ? (E(N, !1), () => {
|
|
134
|
-
|
|
134
|
+
d = !0, v();
|
|
135
135
|
}) : x;
|
|
136
|
-
},
|
|
136
|
+
}, f = {
|
|
137
137
|
local: "http://localhost:5173",
|
|
138
138
|
dev: "https://sdk-cdn.dev.0hash.com",
|
|
139
139
|
cert: "https://sdk-cdn.cert.zerohash.com",
|
|
@@ -141,19 +141,19 @@ const $ = {
|
|
|
141
141
|
"eu-cert": "https://sdk-cdn.cert.zerohash.eu",
|
|
142
142
|
"eu-prod": "https://sdk-cdn.zerohash.eu"
|
|
143
143
|
}, q = (e, t, o = {}) => {
|
|
144
|
-
const { eu: r = !1, legacyAliases: n = !1, local: i =
|
|
144
|
+
const { eu: r = !1, legacyAliases: n = !1, local: i = f.local } = o, c = (s) => `${s}/${e}/${t}`, a = {
|
|
145
145
|
local: c(i),
|
|
146
|
-
dev: c(
|
|
147
|
-
cert: c(
|
|
148
|
-
prod: c(
|
|
146
|
+
dev: c(f.dev),
|
|
147
|
+
cert: c(f.cert),
|
|
148
|
+
prod: c(f.prod)
|
|
149
149
|
};
|
|
150
|
-
return n && (a.sandbox = c(
|
|
150
|
+
return n && (a.sandbox = c(f.cert), a.production = c(f.prod)), r && (a["eu-cert"] = c(f["eu-cert"]), a["eu-prod"] = c(f["eu-prod"])), a;
|
|
151
151
|
};
|
|
152
152
|
var L;
|
|
153
153
|
(function(e) {
|
|
154
154
|
e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
|
|
155
155
|
})(L || (L = {}));
|
|
156
|
-
const
|
|
156
|
+
const S = {
|
|
157
157
|
evergreen: "#00381D",
|
|
158
158
|
green: "#CCFFD0",
|
|
159
159
|
offBlack: "#1C1B1C",
|
|
@@ -168,18 +168,18 @@ const R = {
|
|
|
168
168
|
padding: "32px 24px",
|
|
169
169
|
textAlign: "center",
|
|
170
170
|
fontFamily: "inherit",
|
|
171
|
-
color:
|
|
171
|
+
color: S.offBlack,
|
|
172
172
|
background: "#FFFFFF",
|
|
173
|
-
border: `1px solid ${
|
|
173
|
+
border: `1px solid ${S.grayLight}`,
|
|
174
174
|
borderRadius: "12px"
|
|
175
|
-
}, children: [
|
|
175
|
+
}, children: [_("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: _("path", { d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: S.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), _("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), _("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), _("button", { type: "button", onClick: e, style: {
|
|
176
176
|
marginTop: "8px",
|
|
177
177
|
padding: "8px 20px",
|
|
178
178
|
fontSize: "14px",
|
|
179
179
|
fontWeight: 600,
|
|
180
180
|
fontFamily: "inherit",
|
|
181
|
-
color:
|
|
182
|
-
background:
|
|
181
|
+
color: S.green,
|
|
182
|
+
background: S.evergreen,
|
|
183
183
|
border: "none",
|
|
184
184
|
borderRadius: "8px",
|
|
185
185
|
cursor: "pointer"
|
|
@@ -191,8 +191,8 @@ const R = {
|
|
|
191
191
|
n !== void 0 && (o[r] = n);
|
|
192
192
|
});
|
|
193
193
|
}, Y = (e) => {
|
|
194
|
-
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs:
|
|
195
|
-
B(() => (
|
|
194
|
+
const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: n, fallbackScriptUrls: i, collectorUrls: c, env: a, jwt: s, timeoutMs: m } = e, [b, g] = z(!1), [p, h] = z(0);
|
|
195
|
+
B(() => (g(!1), Z({
|
|
196
196
|
webComponentTag: t,
|
|
197
197
|
appName: o ?? t,
|
|
198
198
|
appVersion: r,
|
|
@@ -201,8 +201,8 @@ const R = {
|
|
|
201
201
|
collectorUrls: c ?? $,
|
|
202
202
|
env: a,
|
|
203
203
|
jwt: s,
|
|
204
|
-
timeoutMs:
|
|
205
|
-
onError: () =>
|
|
204
|
+
timeoutMs: m,
|
|
205
|
+
onError: () => g(!0)
|
|
206
206
|
})), [
|
|
207
207
|
t,
|
|
208
208
|
o,
|
|
@@ -212,11 +212,11 @@ const R = {
|
|
|
212
212
|
c,
|
|
213
213
|
a,
|
|
214
214
|
s,
|
|
215
|
-
|
|
216
|
-
|
|
215
|
+
m,
|
|
216
|
+
p
|
|
217
217
|
]);
|
|
218
|
-
const
|
|
219
|
-
return { loadFailed:
|
|
218
|
+
const R = D(() => h((d) => d + 1), []);
|
|
219
|
+
return { loadFailed: b, retry: R };
|
|
220
220
|
}, ee = q("fund-web", "index.js", { eu: !0 }), A = "zerohash-fund", re = ({
|
|
221
221
|
jwt: e,
|
|
222
222
|
env: t = "prod",
|
|
@@ -224,28 +224,41 @@ const R = {
|
|
|
224
224
|
branding: r,
|
|
225
225
|
isPay: n = !1,
|
|
226
226
|
onCompleted: i,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
227
|
+
onFailed: c,
|
|
228
|
+
onProvideInfo: a,
|
|
229
|
+
onError: s,
|
|
230
|
+
onClose: m,
|
|
231
|
+
onLoaded: b,
|
|
230
232
|
onEvent: g,
|
|
231
|
-
...
|
|
233
|
+
...p
|
|
232
234
|
}) => {
|
|
233
|
-
const
|
|
234
|
-
X(
|
|
235
|
-
|
|
235
|
+
const h = M(null);
|
|
236
|
+
X(h, {
|
|
237
|
+
isPay: n,
|
|
238
|
+
theme: o,
|
|
239
|
+
branding: r,
|
|
240
|
+
onCompleted: i,
|
|
241
|
+
onFailed: c,
|
|
242
|
+
onProvideInfo: a,
|
|
243
|
+
onError: s,
|
|
244
|
+
onClose: m,
|
|
245
|
+
onLoaded: b,
|
|
246
|
+
onEvent: g
|
|
247
|
+
});
|
|
248
|
+
const { loadFailed: R, retry: d } = Y({
|
|
236
249
|
webComponentTag: A,
|
|
237
250
|
scriptUrls: ee,
|
|
238
251
|
// fallbackScriptUrls: FALLBACK_SCRIPT_URLS, // enable once the host is confirmed (AUTH-3095)
|
|
239
252
|
env: t,
|
|
240
253
|
jwt: e
|
|
241
254
|
});
|
|
242
|
-
return
|
|
243
|
-
ref:
|
|
255
|
+
return R ? /* @__PURE__ */ _(Q, { onRetry: d }) : j.createElement(A, {
|
|
256
|
+
ref: h,
|
|
244
257
|
jwt: e,
|
|
245
258
|
env: t,
|
|
246
259
|
theme: o,
|
|
247
260
|
ispay: n ? "true" : void 0,
|
|
248
|
-
...
|
|
261
|
+
...p
|
|
249
262
|
});
|
|
250
263
|
};
|
|
251
264
|
export {
|