@swype-org/react-sdk 0.1.219 → 0.1.220
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.cjs +31 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +31 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -491,9 +491,11 @@ async function throwApiError(res) {
|
|
|
491
491
|
throw new Error(`${res.status} \u2014 ${code}: ${msg}`);
|
|
492
492
|
}
|
|
493
493
|
async function fetchProviders(apiBaseUrl, token) {
|
|
494
|
-
const
|
|
495
|
-
|
|
496
|
-
|
|
494
|
+
const headers = {};
|
|
495
|
+
if (token) {
|
|
496
|
+
headers.Authorization = `Bearer ${token}`;
|
|
497
|
+
}
|
|
498
|
+
const res = await fetch(`${apiBaseUrl}/v1/providers`, { headers });
|
|
497
499
|
if (!res.ok) await throwApiError(res);
|
|
498
500
|
const data = await res.json();
|
|
499
501
|
return data.items;
|
|
@@ -7991,6 +7993,32 @@ function usePaymentEffects(deps) {
|
|
|
7991
7993
|
state.selectedAccountId,
|
|
7992
7994
|
depositAmount
|
|
7993
7995
|
]);
|
|
7996
|
+
react.useEffect(() => {
|
|
7997
|
+
if (authenticated || state.providers.length > 0) return;
|
|
7998
|
+
if (state.step !== "wallet-picker") return;
|
|
7999
|
+
let cancelled = false;
|
|
8000
|
+
const loadProviders = async () => {
|
|
8001
|
+
try {
|
|
8002
|
+
const providers = await fetchProviders(apiBaseUrl);
|
|
8003
|
+
if (cancelled) return;
|
|
8004
|
+
dispatch({
|
|
8005
|
+
type: "DATA_LOADED",
|
|
8006
|
+
providers,
|
|
8007
|
+
accounts: state.accounts,
|
|
8008
|
+
chains: state.chains,
|
|
8009
|
+
defaults: null
|
|
8010
|
+
});
|
|
8011
|
+
} catch (err) {
|
|
8012
|
+
if (!cancelled) {
|
|
8013
|
+
captureException(err);
|
|
8014
|
+
}
|
|
8015
|
+
}
|
|
8016
|
+
};
|
|
8017
|
+
loadProviders();
|
|
8018
|
+
return () => {
|
|
8019
|
+
cancelled = true;
|
|
8020
|
+
};
|
|
8021
|
+
}, [authenticated, state.step, state.providers.length, apiBaseUrl]);
|
|
7994
8022
|
react.useEffect(() => {
|
|
7995
8023
|
if (!polling.transfer) return;
|
|
7996
8024
|
if (polling.transfer.status === "COMPLETED") {
|