@zerohash-sdk/fund-react 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -0
- package/dist/index.js +36 -35
- 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,14 @@ 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;
|
|
199
213
|
/**
|
|
200
214
|
* Callback invoked when an error occurs during the fund flow.
|
|
201
215
|
*
|
package/dist/index.js
CHANGED
|
@@ -91,18 +91,18 @@ 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: _, onError: g } = e;
|
|
95
95
|
if (typeof document > "u")
|
|
96
96
|
return x;
|
|
97
97
|
const d = `${t}-script-${a}`;
|
|
98
98
|
if (customElements.get(t) || document.getElementById(d))
|
|
99
99
|
return x;
|
|
100
|
-
const b = J(s),
|
|
101
|
-
let
|
|
102
|
-
const
|
|
100
|
+
const b = J(s), R = e.report ?? ((p) => G(c && P(c, a, s), p, r));
|
|
101
|
+
let f = !1, w = 0, C;
|
|
102
|
+
const v = () => {
|
|
103
103
|
C !== void 0 && clearTimeout(C);
|
|
104
104
|
}, k = (p, h, l) => {
|
|
105
|
-
if (
|
|
105
|
+
if (f)
|
|
106
106
|
return;
|
|
107
107
|
const U = Math.round(performance.now() - w), T = {
|
|
108
108
|
webComponentTag: t,
|
|
@@ -114,24 +114,24 @@ const $ = {
|
|
|
114
114
|
elapsedMs: U,
|
|
115
115
|
claims: b
|
|
116
116
|
};
|
|
117
|
-
|
|
117
|
+
R(T);
|
|
118
118
|
const O = l ? void 0 : F(i ?? {}, a, s);
|
|
119
119
|
if (O && O !== h) {
|
|
120
120
|
E(O, !0);
|
|
121
121
|
return;
|
|
122
122
|
}
|
|
123
|
-
|
|
123
|
+
f = !0, v(), document.getElementById(d)?.remove(), g?.(T);
|
|
124
124
|
}, E = (p, h) => {
|
|
125
|
-
|
|
125
|
+
v(), w = performance.now();
|
|
126
126
|
const l = document.createElement("script");
|
|
127
127
|
l.id = d, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
|
|
128
128
|
setTimeout(() => {
|
|
129
|
-
|
|
129
|
+
f || (customElements.get(t) ? (f = !0, v(), _?.()) : k("not-defined", p, h));
|
|
130
130
|
}, 0);
|
|
131
|
-
}, l.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h),
|
|
131
|
+
}, l.onerror = () => k("network", p, h), C = setTimeout(() => k("timeout", p, h), m), document.getElementById(d)?.remove(), document.head.appendChild(l);
|
|
132
132
|
}, N = F(n, a, s);
|
|
133
133
|
return N ? (E(N, !1), () => {
|
|
134
|
-
|
|
134
|
+
f = !0, v();
|
|
135
135
|
}) : x;
|
|
136
136
|
}, u = {
|
|
137
137
|
local: "http://localhost:5173",
|
|
@@ -153,7 +153,7 @@ 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: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("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:
|
|
175
|
+
}, children: [y("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: y("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" }) }), y("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), y("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), y("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, [_, g] = z(!1), [d, b] = 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
|
-
|
|
215
|
+
m,
|
|
216
216
|
d
|
|
217
217
|
]);
|
|
218
|
-
const
|
|
219
|
-
return { loadFailed: _, retry:
|
|
218
|
+
const R = D(() => b((f) => f + 1), []);
|
|
219
|
+
return { loadFailed: _, 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,29 @@ const R = {
|
|
|
224
224
|
branding: r,
|
|
225
225
|
isPay: n = !1,
|
|
226
226
|
onCompleted: i,
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
227
|
+
onFailed: c,
|
|
228
|
+
onError: a,
|
|
229
|
+
onClose: s,
|
|
230
|
+
onLoaded: m,
|
|
231
|
+
onEvent: _,
|
|
232
|
+
...g
|
|
232
233
|
}) => {
|
|
233
|
-
const
|
|
234
|
-
X(
|
|
235
|
-
const { loadFailed:
|
|
234
|
+
const d = M(null);
|
|
235
|
+
X(d, { isPay: n, theme: o, branding: r, onCompleted: i, onFailed: c, onError: a, onClose: s, onLoaded: m, onEvent: _ });
|
|
236
|
+
const { loadFailed: b, retry: R } = Y({
|
|
236
237
|
webComponentTag: A,
|
|
237
238
|
scriptUrls: ee,
|
|
238
239
|
// fallbackScriptUrls: FALLBACK_SCRIPT_URLS, // enable once the host is confirmed (AUTH-3095)
|
|
239
240
|
env: t,
|
|
240
241
|
jwt: e
|
|
241
242
|
});
|
|
242
|
-
return
|
|
243
|
-
ref:
|
|
243
|
+
return b ? /* @__PURE__ */ y(Q, { onRetry: R }) : j.createElement(A, {
|
|
244
|
+
ref: d,
|
|
244
245
|
jwt: e,
|
|
245
246
|
env: t,
|
|
246
247
|
theme: o,
|
|
247
248
|
ispay: n ? "true" : void 0,
|
|
248
|
-
...
|
|
249
|
+
...g
|
|
249
250
|
});
|
|
250
251
|
};
|
|
251
252
|
export {
|