@babylonlabs-io/wallet-connector 0.5.0 → 0.5.2
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 +5 -2
- package/dist/context/LifecycleHooks.context.d.ts +4 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/wallets/btc/okx/provider.d.ts +1 -1
- package/dist/core/wallets/btc/onekey/provider.d.ts +1 -1
- package/dist/core/wallets/btc/unisat/provider.d.ts +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +62 -59
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -82795,38 +82795,41 @@ function useWalletConnectors({ accountStorage: e, onError: t }) {
|
|
|
82795
82795
|
confirm: u,
|
|
82796
82796
|
close: c,
|
|
82797
82797
|
reset: v
|
|
82798
|
-
} = useWidgetState(), { showAgain: w } = useInscriptionProvider(), { verifyBTCAddress: b } = useLifeCycleHooks();
|
|
82798
|
+
} = useWidgetState(), { showAgain: w } = useInscriptionProvider(), { verifyBTCAddress: b, acceptTermsOfService: E } = useLifeCycleHooks();
|
|
82799
82799
|
useEffect(() => {
|
|
82800
|
-
const
|
|
82801
|
-
(
|
|
82802
|
-
n == null || n(
|
|
82800
|
+
const M = Object.values(r).filter(Boolean).map(
|
|
82801
|
+
(q) => q.on("connecting", (k) => {
|
|
82802
|
+
n == null || n(k);
|
|
82803
82803
|
})
|
|
82804
82804
|
);
|
|
82805
|
-
return () =>
|
|
82805
|
+
return () => M.forEach((q) => q());
|
|
82806
82806
|
}, [n, r]), useEffect(() => {
|
|
82807
|
-
const
|
|
82808
|
-
BTC: (
|
|
82809
|
-
var
|
|
82810
|
-
|
|
82811
|
-
|
|
82807
|
+
const B = Object.values(r).filter(Boolean), M = {
|
|
82808
|
+
BTC: (k) => async (F) => {
|
|
82809
|
+
var y, T, D;
|
|
82810
|
+
F && F.account && (s == null || s("BTC", F), e.set(k.id, F.id), E == null || E({
|
|
82811
|
+
address: F.account.address,
|
|
82812
|
+
public_key: F.account.publicKeyHex
|
|
82813
|
+
}));
|
|
82814
|
+
const j = () => void (w ? l == null ? void 0 : l() : a == null ? void 0 : a());
|
|
82812
82815
|
if (!validateAddressWithPK(
|
|
82813
|
-
((
|
|
82814
|
-
((
|
|
82815
|
-
|
|
82816
|
+
((y = F.account) == null ? void 0 : y.address) ?? "",
|
|
82817
|
+
((T = F.account) == null ? void 0 : T.publicKeyHex) ?? "",
|
|
82818
|
+
k.config.network
|
|
82816
82819
|
)) {
|
|
82817
82820
|
p == null || p({
|
|
82818
82821
|
title: "Public Key Mismatch",
|
|
82819
82822
|
description: "The Bitcoin address and Public Key for this wallet do not match. Please contact your wallet provider for support.",
|
|
82820
|
-
onSubmit:
|
|
82823
|
+
onSubmit: j,
|
|
82821
82824
|
onCancel: () => {
|
|
82822
|
-
o == null || o(
|
|
82825
|
+
o == null || o(k.id), a == null || a();
|
|
82823
82826
|
}
|
|
82824
82827
|
});
|
|
82825
82828
|
return;
|
|
82826
82829
|
}
|
|
82827
|
-
if (b && !await b(((
|
|
82828
|
-
for (const
|
|
82829
|
-
await
|
|
82830
|
+
if (b && !await b(((D = F.account) == null ? void 0 : D.address) ?? "")) {
|
|
82831
|
+
for (const L of B)
|
|
82832
|
+
await L.disconnect();
|
|
82830
82833
|
p == null || p({
|
|
82831
82834
|
title: "Connection Failed",
|
|
82832
82835
|
description: "The wallet cannot be connected.",
|
|
@@ -82838,20 +82841,20 @@ function useWalletConnectors({ accountStorage: e, onError: t }) {
|
|
|
82838
82841
|
});
|
|
82839
82842
|
return;
|
|
82840
82843
|
}
|
|
82841
|
-
|
|
82844
|
+
j();
|
|
82842
82845
|
},
|
|
82843
|
-
BBN: (
|
|
82844
|
-
|
|
82846
|
+
BBN: (k) => (F) => {
|
|
82847
|
+
F && (s == null || s(k.id, F), e.set(k.id, F.id)), a == null || a();
|
|
82845
82848
|
}
|
|
82846
|
-
},
|
|
82847
|
-
(
|
|
82848
|
-
var
|
|
82849
|
-
return
|
|
82849
|
+
}, q = B.map(
|
|
82850
|
+
(k) => {
|
|
82851
|
+
var F;
|
|
82852
|
+
return k.on("connect", (F = M[k.id]) == null ? void 0 : F.call(M, k));
|
|
82850
82853
|
}
|
|
82851
82854
|
);
|
|
82852
|
-
return
|
|
82853
|
-
s == null || s(
|
|
82854
|
-
}), () =>
|
|
82855
|
+
return B.forEach((k) => {
|
|
82856
|
+
s == null || s(k.id, k.connectedWallet);
|
|
82857
|
+
}), () => q.forEach((k) => k());
|
|
82855
82858
|
}, [
|
|
82856
82859
|
s,
|
|
82857
82860
|
o,
|
|
@@ -82863,37 +82866,37 @@ function useWalletConnectors({ accountStorage: e, onError: t }) {
|
|
|
82863
82866
|
r,
|
|
82864
82867
|
w
|
|
82865
82868
|
]), useEffect(() => {
|
|
82866
|
-
const
|
|
82867
|
-
(
|
|
82868
|
-
|
|
82869
|
+
const M = Object.values(r).filter(Boolean).map(
|
|
82870
|
+
(q) => q.on("disconnect", (k) => {
|
|
82871
|
+
k && (o == null || o(q.id), a == null || a(), e.delete(q.id));
|
|
82869
82872
|
})
|
|
82870
82873
|
);
|
|
82871
|
-
return () =>
|
|
82874
|
+
return () => M.forEach((q) => q());
|
|
82872
82875
|
}, [o, a, r]), useEffect(() => {
|
|
82873
|
-
const
|
|
82874
|
-
(
|
|
82875
|
-
t == null || t(
|
|
82876
|
+
const M = Object.values(r).filter(Boolean).map(
|
|
82877
|
+
(q) => q.on("error", (k) => {
|
|
82878
|
+
t == null || t(k), a == null || a();
|
|
82876
82879
|
})
|
|
82877
82880
|
);
|
|
82878
|
-
return () =>
|
|
82881
|
+
return () => M.forEach((q) => q());
|
|
82879
82882
|
}, [t, a, r]), useEffect(() => {
|
|
82880
|
-
const
|
|
82881
|
-
|
|
82883
|
+
const B = Object.values(r).filter(Boolean);
|
|
82884
|
+
B.length && B.every((M) => e.has(M.id)) && (u == null || u(), a == null || a());
|
|
82882
82885
|
}, [r, u, a]);
|
|
82883
|
-
const
|
|
82884
|
-
async (
|
|
82885
|
-
const
|
|
82886
|
-
await (
|
|
82886
|
+
const I = useCallback(
|
|
82887
|
+
async (B, M) => {
|
|
82888
|
+
const q = r[B.id];
|
|
82889
|
+
await (q == null ? void 0 : q.connect(M.id));
|
|
82887
82890
|
},
|
|
82888
82891
|
[r]
|
|
82889
|
-
),
|
|
82890
|
-
async (
|
|
82891
|
-
const
|
|
82892
|
-
await (
|
|
82892
|
+
), x = useCallback(
|
|
82893
|
+
async (B) => {
|
|
82894
|
+
const M = r[B];
|
|
82895
|
+
await (M == null ? void 0 : M.disconnect());
|
|
82893
82896
|
},
|
|
82894
82897
|
[r]
|
|
82895
82898
|
);
|
|
82896
|
-
return { connect:
|
|
82899
|
+
return { connect: I, disconnect: x };
|
|
82897
82900
|
}
|
|
82898
82901
|
function useWalletWidgets(e, t) {
|
|
82899
82902
|
const r = useCallback(
|
|
@@ -83328,29 +83331,29 @@ function Screen(e) {
|
|
|
83328
83331
|
}
|
|
83329
83332
|
const ANIMATION_DELAY = 1e3;
|
|
83330
83333
|
function WalletDialog({ storage: e, config: t, onError: r }) {
|
|
83331
|
-
const { visible: s, screen: o, confirmed: n, close: a, confirm: l, displayChains: p } = useWidgetState(), { toggleShowAgain: u, toggleLockInscriptions: c } = useInscriptionProvider(), v = useChainProviders(), w = useWalletWidgets(v, t), { connect: b, disconnect: E } = useWalletConnectors({ accountStorage: e, onError: r }), { disconnect: I } = useWalletConnect(),
|
|
83332
|
-
p == null || p()
|
|
83333
|
-
}, [p
|
|
83334
|
-
(
|
|
83335
|
-
u == null || u(
|
|
83334
|
+
const { visible: s, screen: o, confirmed: n, close: a, confirm: l, displayChains: p } = useWidgetState(), { toggleShowAgain: u, toggleLockInscriptions: c } = useInscriptionProvider(), v = useChainProviders(), w = useWalletWidgets(v, t), { connect: b, disconnect: E } = useWalletConnectors({ accountStorage: e, onError: r }), { disconnect: I } = useWalletConnect(), x = useCallback(() => {
|
|
83335
|
+
p == null || p();
|
|
83336
|
+
}, [p]), B = useCallback(
|
|
83337
|
+
(k, F) => {
|
|
83338
|
+
u == null || u(F), c == null || c(k), p == null || p();
|
|
83336
83339
|
},
|
|
83337
83340
|
[u, c, p]
|
|
83338
|
-
),
|
|
83341
|
+
), M = useCallback(() => {
|
|
83339
83342
|
a == null || a(), n || setTimeout(I, ANIMATION_DELAY);
|
|
83340
|
-
}, [a, I, n]),
|
|
83343
|
+
}, [a, I, n]), q = useCallback(() => {
|
|
83341
83344
|
l == null || l(), a == null || a();
|
|
83342
83345
|
}, [l]);
|
|
83343
|
-
return /* @__PURE__ */ jsx(ResponsiveDialog, { className: "min-h-[80%]", open: s, onClose:
|
|
83346
|
+
return /* @__PURE__ */ jsx(ResponsiveDialog, { className: "min-h-[80%]", open: s, onClose: M, children: /* @__PURE__ */ jsx(
|
|
83344
83347
|
Screen,
|
|
83345
83348
|
{
|
|
83346
83349
|
current: o,
|
|
83347
83350
|
widgets: w,
|
|
83348
83351
|
className: "min-h-0 md:size-[600px]",
|
|
83349
|
-
onClose:
|
|
83350
|
-
onConfirm:
|
|
83352
|
+
onClose: M,
|
|
83353
|
+
onConfirm: q,
|
|
83351
83354
|
onSelectWallet: b,
|
|
83352
|
-
onAccepTermsOfService:
|
|
83353
|
-
onToggleInscriptions:
|
|
83355
|
+
onAccepTermsOfService: x,
|
|
83356
|
+
onToggleInscriptions: B,
|
|
83354
83357
|
onDisconnectWallet: E
|
|
83355
83358
|
}
|
|
83356
83359
|
) });
|